Merge remote-tracking branch 'origin/feat-update-db-to-0.6' into feat-create-attribute-routes
This commit is contained in:
commit
d65e808a58
|
@ -156,7 +156,7 @@ App::post('/v1/account/sessions')
|
|||
$email = \strtolower($email);
|
||||
$protocol = $request->getProtocol();
|
||||
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (!$profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) {
|
||||
$audits
|
||||
|
@ -442,16 +442,16 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
}
|
||||
}
|
||||
|
||||
$user = ($user->isEmpty()) ? $dbForInternal->findFirst('sessions', [ // Get user by provider id
|
||||
$user = ($user->isEmpty()) ? $dbForInternal->findOne('sessions', [ // Get user by provider id
|
||||
new Query('provider', QUERY::TYPE_EQUAL, [$provider]),
|
||||
new Query('providerUid', QUERY::TYPE_EQUAL, [$oauth2ID]),
|
||||
], 1) : $user;
|
||||
]) : $user;
|
||||
|
||||
if ($user === false || $user->isEmpty()) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email
|
||||
$name = $oauth2->getUserName($accessToken);
|
||||
$email = $oauth2->getUserEmail($accessToken);
|
||||
|
||||
$user = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$user = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if ($user === false || $user->isEmpty()) { // Last option -> create the user, generate random password
|
||||
$limit = $project->getAttribute('usersAuthLimit', 0);
|
||||
|
@ -1074,7 +1074,7 @@ App::patch('/v1/account/email')
|
|||
}
|
||||
|
||||
$email = \strtolower($email);
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])]); // Get user by email address
|
||||
|
||||
if ($profile) {
|
||||
throw new Exception('User already registered', 400);
|
||||
|
@ -1379,7 +1379,7 @@ App::post('/v1/account/recovery')
|
|||
$isAppUser = Auth::isAppUser(Authorization::$roles);
|
||||
|
||||
$email = \strtolower($email);
|
||||
$profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (!$profile) {
|
||||
throw new Exception('User not found', 404);
|
||||
|
|
|
@ -273,7 +273,7 @@ App::post('/v1/teams/:teamId/memberships')
|
|||
throw new Exception('Team not found', 404);
|
||||
}
|
||||
|
||||
$invitee = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address
|
||||
$invitee = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address
|
||||
|
||||
if (empty($invitee)) { // Create new user if no user with same email found
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons
|
|||
} else {
|
||||
Authorization::disable();
|
||||
|
||||
$certificate = $dbForConsole->findFirst('certificates', [
|
||||
$certificate = $dbForConsole->findOne('certificates', [
|
||||
new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()])
|
||||
], /*limit*/ 1);
|
||||
]);
|
||||
|
||||
if (empty($certificate)) {
|
||||
$certificate = new Document([
|
||||
|
|
|
@ -78,9 +78,9 @@ class CertificatesV1 extends Worker
|
|||
}
|
||||
}
|
||||
|
||||
$certificate = $dbForConsole->findFirst('certificates', [
|
||||
$certificate = $dbForConsole->findOne('certificates', [
|
||||
new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()])
|
||||
], /*limit*/ 1);
|
||||
]);
|
||||
|
||||
// $condition = ($certificate
|
||||
// && $certificate instanceof Document
|
||||
|
|
|
@ -71,7 +71,7 @@ class DatabaseV1 extends Worker
|
|||
$default = $attribute->getAttribute('default', null);
|
||||
$signed = $attribute->getAttribute('signed', true);
|
||||
$array = $attribute->getAttribute('array', false);
|
||||
$format = $attribute->getAttribute('format', '');
|
||||
$format = $attribute->getAttribute('format', null);
|
||||
$filters = $attribute->getAttribute('filters', []);
|
||||
|
||||
$success = $dbForExternal->createAttribute($collectionId, $id, $type, $size, $required, $default, $signed, $array, $format, $filters);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"utopia-php/cache": "0.4.*",
|
||||
"utopia-php/cli": "0.11.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "dev-feat-attribute-format-validators as 0.5.1",
|
||||
"utopia-php/database": "0.6.*",
|
||||
"utopia-php/locale": "0.3.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
|
@ -62,12 +62,7 @@
|
|||
"adhocore/jwt": "1.1.2",
|
||||
"slickdeals/statsd": "3.1.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database"
|
||||
}
|
||||
],
|
||||
"repositories": [],
|
||||
"require-dev": {
|
||||
"appwrite/sdk-generator": "0.13.0",
|
||||
"swoole/ide-helper": "4.6.7",
|
||||
|
|
67
composer.lock
generated
67
composer.lock
generated
|
@ -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": "6c240e73a06b648ec38d71e56ffbb67c",
|
||||
"content-hash": "f9727be2725e573a92b2d1aeeb77b421",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -1666,22 +1666,22 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "f568f97467eca66450af6fba18038ddeb8e8d05a"
|
||||
"reference": "c9078aa3a87750d66060f0ed7642e03e5815da17"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/f568f97467eca66450af6fba18038ddeb8e8d05a",
|
||||
"reference": "f568f97467eca66450af6fba18038ddeb8e8d05a",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/c9078aa3a87750d66060f0ed7642e03e5815da17",
|
||||
"reference": "c9078aa3a87750d66060f0ed7642e03e5815da17",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"php": ">=7.4",
|
||||
"utopia-php/database": "0.5.*"
|
||||
"utopia-php/database": "0.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.4",
|
||||
|
@ -1713,9 +1713,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.6.0"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/0.6.1"
|
||||
},
|
||||
"time": "2021-08-01T11:16:50+00:00"
|
||||
"time": "2021-08-03T19:31:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/analytics",
|
||||
|
@ -1774,22 +1774,22 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e"
|
||||
"reference": "971dcd5c88309656df31ac20f326d3ac8b555594"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e",
|
||||
"reference": "f81bbe0bf64d74c9668ca7ab90d0b6eb3df4d47e",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/971dcd5c88309656df31ac20f326d3ac8b555594",
|
||||
"reference": "971dcd5c88309656df31ac20f326d3ac8b555594",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"php": ">=7.4",
|
||||
"utopia-php/database": "0.5.*"
|
||||
"utopia-php/database": "0.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3",
|
||||
|
@ -1821,9 +1821,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.6.0"
|
||||
"source": "https://github.com/utopia-php/audit/tree/0.6.1"
|
||||
},
|
||||
"time": "2021-08-01T11:14:31+00:00"
|
||||
"time": "2021-08-03T19:29:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
|
@ -1984,11 +1984,17 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "dev-feat-attribute-format-validators",
|
||||
"version": "0.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database",
|
||||
"reference": "d54d9c3de3a11796c0454548cb62a5296f601259"
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "561adc215fce3bd3b8c3ebb971ca354fb1526f26"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/561adc215fce3bd3b8c3ebb971ca354fb1526f26",
|
||||
"reference": "561adc215fce3bd3b8c3ebb971ca354fb1526f26",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mongodb": "*",
|
||||
|
@ -2011,11 +2017,7 @@
|
|||
"Utopia\\Database\\": "src/Database"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Utopia\\Tests\\": "tests/Database"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
|
@ -2037,7 +2039,11 @@
|
|||
"upf",
|
||||
"utopia"
|
||||
],
|
||||
"time": "2021-07-27T18:20:30+00:00"
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.6.0"
|
||||
},
|
||||
"time": "2021-08-03T15:13:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
@ -6248,18 +6254,9 @@
|
|||
"time": "2015-12-17T08:42:14+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/database",
|
||||
"version": "dev-feat-attribute-format-validators",
|
||||
"alias": "0.5.1",
|
||||
"alias_normalized": "0.5.1.0"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"utopia-php/database": 20
|
||||
},
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
|
2
public/dist/styles/default-ltr.css
vendored
2
public/dist/styles/default-ltr.css
vendored
File diff suppressed because one or more lines are too long
2
public/dist/styles/default-rtl.css
vendored
2
public/dist/styles/default-rtl.css
vendored
File diff suppressed because one or more lines are too long
|
@ -634,13 +634,13 @@ input[type=checkbox], input[type=radio] {
|
|||
position: absolute;
|
||||
top: 0;
|
||||
.func-end(0);
|
||||
.func-border-start(1px);
|
||||
border: solid 1px var(--config-color-fade-light);
|
||||
height: ~"calc(100% - 2px)";
|
||||
width: 50px;
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
background: var(--config-color-background-focus);
|
||||
margin: 1px;
|
||||
margin: 0;
|
||||
border-radius: 0 10px 10px 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -653,7 +653,7 @@
|
|||
.provider {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background: #f5f5f5;
|
||||
background: var(--config-color-background-focus);
|
||||
color: #868686;
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
|
|
|
@ -39,7 +39,6 @@ use Appwrite\Utopia\Response\Model\Platform;
|
|||
use Appwrite\Utopia\Response\Model\Project;
|
||||
use Appwrite\Utopia\Response\Model\Rule;
|
||||
use Appwrite\Utopia\Response\Model\Tag;
|
||||
use Appwrite\Utopia\Response\Model\Task;
|
||||
use Appwrite\Utopia\Response\Model\Token;
|
||||
use Appwrite\Utopia\Response\Model\Webhook;
|
||||
use Appwrite\Utopia\Response\Model\Preferences;
|
||||
|
@ -59,7 +58,6 @@ class Response extends SwooleResponse
|
|||
const MODEL_ERROR = 'error';
|
||||
const MODEL_ERROR_DEV = 'errorDev';
|
||||
const MODEL_BASE_LIST = 'baseList';
|
||||
const MODEL_PERMISSIONS = 'permissions';
|
||||
|
||||
// Database
|
||||
const MODEL_COLLECTION = 'collection';
|
||||
|
@ -68,7 +66,6 @@ class Response extends SwooleResponse
|
|||
const MODEL_ATTRIBUTE_LIST = 'attributeList';
|
||||
const MODEL_INDEX = 'index';
|
||||
const MODEL_INDEX_LIST = 'indexList';
|
||||
const MODEL_RULE = 'rule';
|
||||
const MODEL_DOCUMENT = 'document';
|
||||
const MODEL_DOCUMENT_LIST = 'documentList';
|
||||
|
||||
|
@ -125,6 +122,10 @@ class Response extends SwooleResponse
|
|||
const MODEL_DOMAIN = 'domain';
|
||||
const MODEL_DOMAIN_LIST = 'domainList';
|
||||
|
||||
// Deprecated
|
||||
const MODEL_PERMISSIONS = 'permissions';
|
||||
const MODEL_RULE = 'rule';
|
||||
|
||||
// Tests (keep last)
|
||||
const MODEL_MOCK = 'mock';
|
||||
|
||||
|
@ -176,12 +177,10 @@ class Response extends SwooleResponse
|
|||
->setModel(new BaseList('Currencies List', self::MODEL_CURRENCY_LIST, 'currencies', self::MODEL_CURRENCY))
|
||||
->setModel(new BaseList('Phones List', self::MODEL_PHONE_LIST, 'phones', self::MODEL_PHONE))
|
||||
// Entities
|
||||
->setModel(new Permissions())
|
||||
->setModel(new Collection())
|
||||
->setModel(new Attribute())
|
||||
->setModel(new Index())
|
||||
->setModel(new ModelDocument())
|
||||
->setModel(new Rule())
|
||||
->setModel(new Log())
|
||||
->setModel(new User())
|
||||
->setModel(new Preferences())
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Permissions extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Read permissions.',
|
||||
'default' => [],
|
||||
'example' => 'user:5e5ea5c16897e',
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('write', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Write permissions.',
|
||||
'default' => [],
|
||||
'example' => 'user:5e5ea5c16897e',
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Permissions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_PERMISSIONS;
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Rule extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$collection', [ // TODO remove this from public response
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule Collection.',
|
||||
'example' => '5e5e66c16897e',
|
||||
])
|
||||
->addRule('type', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule type. Possible values: ',
|
||||
'default' => '',
|
||||
'example' => 'title',
|
||||
])
|
||||
->addRule('key', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule key.',
|
||||
'default' => '',
|
||||
'example' => 'title',
|
||||
])
|
||||
->addRule('label', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule label.',
|
||||
'default' => '',
|
||||
'example' => 'Title',
|
||||
])
|
||||
->addRule('default', [ // TODO should be of mixed types
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Rule default value.',
|
||||
'default' => '',
|
||||
'example' => 'Movie Name',
|
||||
])
|
||||
->addRule('array', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is array?',
|
||||
'default' => false,
|
||||
'example' => false,
|
||||
])
|
||||
->addRule('required', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is required?',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('list', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'List of allowed values',
|
||||
'array' => true,
|
||||
'default' => [],
|
||||
'example' => '5e5ea5c168099',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Rule';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_RULE;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue