Merge pull request #1087 from TorstenDittmann/refactor-whitelist-type-spec

Refactor: whitelist type for spec generation
This commit is contained in:
Eldad A. Fux 2021-04-15 23:23:32 +03:00 committed by GitHub
commit 42a449da6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 597 additions and 181 deletions

View file

@ -84,17 +84,17 @@ return [
],
'database.documents.create' => [
'description' => 'This event triggers when a database document is created.',
'model' => Response::MODEL_ANY,
'model' => Response::MODEL_DOCUMENT,
'note' => '',
],
'database.documents.update' => [
'description' => 'This event triggers when a database document is updated.',
'model' => Response::MODEL_ANY,
'model' => Response::MODEL_DOCUMENT,
'note' => '',
],
'database.documents.delete' => [
'description' => 'This event triggers when a database document is deleted.',
'model' => Response::MODEL_ANY,
'model' => Response::MODEL_DOCUMENT,
'note' => '',
],
'storage.files.create' => [

View file

@ -294,7 +294,7 @@ App::post('/v1/database/collections/:collectionId/documents')
->label('sdk.description', '/docs/references/database/create-document.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->label('sdk.response.model', Response::MODEL_DOCUMENT)
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
->param('data', [], new JSON(), 'Document data as JSON object.')
->param('read', null, new ArrayList(new Text(64)), 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true)
@ -401,7 +401,7 @@ App::post('/v1/database/collections/:collectionId/documents')
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($data, Response::MODEL_ANY)
->dynamic($data, Response::MODEL_DOCUMENT)
;
});
@ -478,7 +478,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
->label('sdk.description', '/docs/references/database/get-document.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->label('sdk.response.model', Response::MODEL_DOCUMENT)
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
->param('documentId', null, new UID(), 'Document unique ID.')
->inject('response')
@ -494,7 +494,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId')
throw new Exception('No document found', 404);
}
$response->dynamic($document, Response::MODEL_ANY);
$response->dynamic($document, Response::MODEL_DOCUMENT);
});
App::patch('/v1/database/collections/:collectionId/documents/:documentId')
@ -508,7 +508,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->label('sdk.description', '/docs/references/database/update-document.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_ANY)
->label('sdk.response.model', Response::MODEL_DOCUMENT)
->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).')
->param('documentId', null, new UID(), 'Document unique ID.')
->param('data', [], new JSON(), 'Document data as JSON object.')
@ -566,7 +566,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
->setParam('data', $data->getArrayCopy())
;
$response->dynamic($data, Response::MODEL_ANY);
$response->dynamic($data, Response::MODEL_DOCUMENT);
});
App::delete('/v1/database/collections/:collectionId/documents/:documentId')
@ -614,7 +614,7 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId')
}
$events
->setParam('payload', $response->output($document, Response::MODEL_ANY))
->setParam('payload', $response->output($document, Response::MODEL_DOCUMENT))
;
$audits

View file

@ -3,12 +3,12 @@
global $utopia, $request, $response;
use Appwrite\Database\Document;
use Appwrite\Network\Validator\Host;
use Appwrite\Utopia\Response;
use Utopia\App;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Host;
use Utopia\Storage\Validator\File;
App::get('/v1/mock/tests/foo')

View file

@ -520,7 +520,7 @@ $maxCells = 10;
<div data-ls-loop="project-collections.collections" data-ls-as="project" data-ls-key="$index2" class="tiles cell-3 margin-bottom-negative">
<div class="margin-bottom" data-ls-if="{{project.$id}} != {{router.params.id}}">
<input type="radio" name="list" data-ls-attrs="value={{project.$id}},id={{project.$id}}" data-ls-bind="{{rule.list|firstElement}}" data-cast-to="array" required />
<input type="radio" data-ls-attrs="value={{project.$id}},id=[{{rule.$id}}].{{project.$id}},name=[{{rule.$id}}].list" data-ls-bind="{{rule.list|firstElement}}" data-cast-to="array" required />
<label data-ls-attrs="for={{project.$id}}"data-ls-bind="{{project.name}}"></label>
</div>
</div>

View file

@ -37,7 +37,7 @@
"appwrite/php-clamav": "1.0.*",
"utopia-php/framework": "0.12.*",
"utopia-php/framework": "0.13.*",
"utopia-php/abuse": "0.4.*",
"utopia-php/analytics": "0.2.*",
"utopia-php/audit": "0.5.*",
@ -50,7 +50,7 @@
"utopia-php/domains": "0.2.*",
"utopia-php/swoole": "0.2.*",
"utopia-php/system": "0.4.*",
"utopia-php/storage": "0.4.*",
"utopia-php/storage": "0.5.*",
"utopia-php/image": "0.1.*",
"resque/php-resque": "1.3.6",

203
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": "a5a066bf0b739b7b412149aeb0e9a396",
"content-hash": "fb036a60be94e5d0751a7ab5d3c07efc",
"packages": [
{
"name": "adhocore/jwt",
@ -1706,16 +1706,16 @@
},
{
"name": "utopia-php/framework",
"version": "0.12.3",
"version": "0.13.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework.git",
"reference": "78be43a0eb711f3677769dfb445e5111bfafaa88"
"reference": "b54ee9c79b4fae52f196825aa6e659318fb8adb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/78be43a0eb711f3677769dfb445e5111bfafaa88",
"reference": "78be43a0eb711f3677769dfb445e5111bfafaa88",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/b54ee9c79b4fae52f196825aa6e659318fb8adb6",
"reference": "b54ee9c79b4fae52f196825aa6e659318fb8adb6",
"shasum": ""
},
"require": {
@ -1749,9 +1749,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/framework/issues",
"source": "https://github.com/utopia-php/framework/tree/0.12.3"
"source": "https://github.com/utopia-php/framework/tree/0.13.0"
},
"time": "2021-03-22T22:02:23+00:00"
"time": "2021-04-13T07:30:50+00:00"
},
{
"name": "utopia-php/image",
@ -1964,16 +1964,16 @@
},
{
"name": "utopia-php/storage",
"version": "0.4.3",
"version": "0.5.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7"
"reference": "92ae20c7a2ac329f573a58a82dc245134cc63408"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7",
"reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/92ae20c7a2ac329f573a58a82dc245134cc63408",
"reference": "92ae20c7a2ac329f573a58a82dc245134cc63408",
"shasum": ""
},
"require": {
@ -2010,9 +2010,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/0.4.3"
"source": "https://github.com/utopia-php/storage/tree/0.5.0"
},
"time": "2021-03-02T20:25:02+00:00"
"time": "2021-04-15T16:43:12+00:00"
},
{
"name": "utopia-php/swoole",
@ -2276,12 +2276,12 @@
"source": {
"type": "git",
"url": "https://github.com/amphp/byte-stream.git",
"reference": "f813a658f0446192c5e17f96727070ee9342b93a"
"reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/f813a658f0446192c5e17f96727070ee9342b93a",
"reference": "f813a658f0446192c5e17f96727070ee9342b93a",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e",
"reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e",
"shasum": ""
},
"require": {
@ -2346,7 +2346,7 @@
"type": "github"
}
],
"time": "2020-08-30T19:23:04+00:00"
"time": "2021-04-05T20:23:22+00:00"
},
{
"name": "appwrite/sdk-generator",
@ -2544,16 +2544,16 @@
},
{
"name": "composer/xdebug-handler",
"version": "1.4.5",
"version": "1.4.x-dev",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "f28d44c286812c714741478d968104c5e604a1d4"
"reference": "f27e06cd9675801df441b3656569b328e04aa37c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4",
"reference": "f28d44c286812c714741478d968104c5e604a1d4",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c",
"reference": "f27e06cd9675801df441b3656569b328e04aa37c",
"shasum": ""
},
"require": {
@ -2561,7 +2561,8 @@
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8"
"phpstan/phpstan": "^0.12.55",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
"autoload": {
@ -2587,7 +2588,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/xdebug-handler/issues",
"source": "https://github.com/composer/xdebug-handler/tree/1.4.5"
"source": "https://github.com/composer/xdebug-handler/tree/1.4.6"
},
"funding": [
{
@ -2603,7 +2604,7 @@
"type": "tidelift"
}
],
"time": "2020-11-13T08:04:11+00:00"
"time": "2021-03-25T17:01:18+00:00"
},
{
"name": "dnoegel/php-xdg-base-dir",
@ -3509,12 +3510,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "ad069801f3d0cdb7102e58afd5f9f32834ec7160"
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ad069801f3d0cdb7102e58afd5f9f32834ec7160",
"reference": "ad069801f3d0cdb7102e58afd5f9f32834ec7160",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
"shasum": ""
},
"require": {
@ -3570,7 +3571,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
},
"funding": [
{
@ -3578,7 +3579,7 @@
"type": "github"
}
],
"time": "2021-02-08T09:55:27+00:00"
"time": "2021-03-28T07:26:59+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -3586,12 +3587,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "b2ce4cf415b9989fac88e8c27c39b5ba2faad72b"
"reference": "97eb187efc3560da69c5b501235cd3eb1ebfec86"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/b2ce4cf415b9989fac88e8c27c39b5ba2faad72b",
"reference": "b2ce4cf415b9989fac88e8c27c39b5ba2faad72b",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/97eb187efc3560da69c5b501235cd3eb1ebfec86",
"reference": "97eb187efc3560da69c5b501235cd3eb1ebfec86",
"shasum": ""
},
"require": {
@ -3639,7 +3640,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:19+00:00"
"time": "2021-04-02T08:22:03+00:00"
},
{
"name": "phpunit/php-invoker",
@ -3647,12 +3648,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-invoker.git",
"reference": "e2905d5648ac5e9bd0aa85b50d240e5890f76493"
"reference": "de89b92643f75d97135fd0f895d4369630952c95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/e2905d5648ac5e9bd0aa85b50d240e5890f76493",
"reference": "e2905d5648ac5e9bd0aa85b50d240e5890f76493",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/de89b92643f75d97135fd0f895d4369630952c95",
"reference": "de89b92643f75d97135fd0f895d4369630952c95",
"shasum": ""
},
"require": {
@ -3703,7 +3704,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:27+00:00"
"time": "2021-04-02T08:22:12+00:00"
},
{
"name": "phpunit/php-text-template",
@ -3711,12 +3712,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "e6a2483ffd3659d723996fb8b2ca638244b87e7c"
"reference": "f46a87d94ad351b46c836f6cdda98795e8a6c979"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/e6a2483ffd3659d723996fb8b2ca638244b87e7c",
"reference": "e6a2483ffd3659d723996fb8b2ca638244b87e7c",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/f46a87d94ad351b46c836f6cdda98795e8a6c979",
"reference": "f46a87d94ad351b46c836f6cdda98795e8a6c979",
"shasum": ""
},
"require": {
@ -3763,7 +3764,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:59+00:00"
"time": "2021-04-02T08:22:46+00:00"
},
{
"name": "phpunit/php-timer",
@ -3771,12 +3772,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "c0187813193d3709a455b94916bbee2881a1c6e3"
"reference": "bd80d581ad411a5a4b7e613541a7f4cd09cf0da9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/c0187813193d3709a455b94916bbee2881a1c6e3",
"reference": "c0187813193d3709a455b94916bbee2881a1c6e3",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/bd80d581ad411a5a4b7e613541a7f4cd09cf0da9",
"reference": "bd80d581ad411a5a4b7e613541a7f4cd09cf0da9",
"shasum": ""
},
"require": {
@ -3823,7 +3824,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:35+00:00"
"time": "2021-04-02T08:22:20+00:00"
},
{
"name": "phpunit/phpunit",
@ -3982,12 +3983,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git",
"reference": "845853b8c553f6b61d9a708b8f26066806bcc7dd"
"reference": "e59dfbeeaf6ccdff168c537427cbc9f7fed6b160"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/845853b8c553f6b61d9a708b8f26066806bcc7dd",
"reference": "845853b8c553f6b61d9a708b8f26066806bcc7dd",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/e59dfbeeaf6ccdff168c537427cbc9f7fed6b160",
"reference": "e59dfbeeaf6ccdff168c537427cbc9f7fed6b160",
"shasum": ""
},
"require": {
@ -4031,7 +4032,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:18:24+00:00"
"time": "2021-04-02T08:23:11+00:00"
},
{
"name": "sebastian/code-unit",
@ -4095,12 +4096,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "ab4d610891809670894a4fc260c17e5d5960ba4c"
"reference": "f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ab4d610891809670894a4fc260c17e5d5960ba4c",
"reference": "ab4d610891809670894a4fc260c17e5d5960ba4c",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9",
"reference": "f7ee1d817bdd8a8bdfb76b11fa851204132ef6d9",
"shasum": ""
},
"require": {
@ -4143,7 +4144,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:16+00:00"
"time": "2021-04-02T08:20:56+00:00"
},
{
"name": "sebastian/comparator",
@ -4151,12 +4152,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "d3d66b8faa86ac57e1236d576ad003f73097c9cd"
"reference": "604de433dd3e1467ded9a92414b3561a812554c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d3d66b8faa86ac57e1236d576ad003f73097c9cd",
"reference": "d3d66b8faa86ac57e1236d576ad003f73097c9cd",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/604de433dd3e1467ded9a92414b3561a812554c5",
"reference": "604de433dd3e1467ded9a92414b3561a812554c5",
"shasum": ""
},
"require": {
@ -4218,7 +4219,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:24+00:00"
"time": "2021-04-02T08:21:05+00:00"
},
{
"name": "sebastian/complexity",
@ -4283,12 +4284,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "e81849c6dfbe34442b4685fa457fd6f012370e54"
"reference": "3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e81849c6dfbe34442b4685fa457fd6f012370e54",
"reference": "e81849c6dfbe34442b4685fa457fd6f012370e54",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec",
"reference": "3fa178cf5772d7a09bcfe01bfb7acc13edcf8aec",
"shasum": ""
},
"require": {
@ -4342,7 +4343,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:31+00:00"
"time": "2021-04-02T08:21:13+00:00"
},
{
"name": "sebastian/environment",
@ -4350,12 +4351,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "c25633688d84a9f8694989223479051b5a8a23e7"
"reference": "1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/c25633688d84a9f8694989223479051b5a8a23e7",
"reference": "c25633688d84a9f8694989223479051b5a8a23e7",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465",
"reference": "1fe23c75ca20a9cfe5ef8af473c726f9ef7e9465",
"shasum": ""
},
"require": {
@ -4406,7 +4407,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:40+00:00"
"time": "2021-04-02T08:21:21+00:00"
},
{
"name": "sebastian/exporter",
@ -4414,12 +4415,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "9119858d42f3963d01b737f029bb90f8464fd0ca"
"reference": "31abe95278f9b406051b4a26faf2677fbcc01755"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/9119858d42f3963d01b737f029bb90f8464fd0ca",
"reference": "9119858d42f3963d01b737f029bb90f8464fd0ca",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/31abe95278f9b406051b4a26faf2677fbcc01755",
"reference": "31abe95278f9b406051b4a26faf2677fbcc01755",
"shasum": ""
},
"require": {
@ -4484,7 +4485,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:48+00:00"
"time": "2021-04-02T08:21:30+00:00"
},
{
"name": "sebastian/global-state",
@ -4492,12 +4493,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "fe610de5530e3d29007134f76ee8dc79581a607d"
"reference": "8684de2d84cd6a819f5e22a1292cd3b2e1f26487"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/fe610de5530e3d29007134f76ee8dc79581a607d",
"reference": "fe610de5530e3d29007134f76ee8dc79581a607d",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/8684de2d84cd6a819f5e22a1292cd3b2e1f26487",
"reference": "8684de2d84cd6a819f5e22a1292cd3b2e1f26487",
"shasum": ""
},
"require": {
@ -4549,7 +4550,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:16:56+00:00"
"time": "2021-04-02T08:21:38+00:00"
},
{
"name": "sebastian/lines-of-code",
@ -4614,12 +4615,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "01ab82e49081de59e2da70c351d5f698c77c33c5"
"reference": "b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/01ab82e49081de59e2da70c351d5f698c77c33c5",
"reference": "01ab82e49081de59e2da70c351d5f698c77c33c5",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc",
"reference": "b331fc5975a2225e6b93c7e6cd9fce0a57f0fddc",
"shasum": ""
},
"require": {
@ -4664,7 +4665,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:03+00:00"
"time": "2021-04-02T08:21:47+00:00"
},
{
"name": "sebastian/object-reflector",
@ -4672,12 +4673,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
"reference": "7ed67aee59862b40785138f0203e86f1fde1b93a"
"reference": "297a334e3ae78670a7633e36569d7362bb7397bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/7ed67aee59862b40785138f0203e86f1fde1b93a",
"reference": "7ed67aee59862b40785138f0203e86f1fde1b93a",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/297a334e3ae78670a7633e36569d7362bb7397bf",
"reference": "297a334e3ae78670a7633e36569d7362bb7397bf",
"shasum": ""
},
"require": {
@ -4720,7 +4721,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:11+00:00"
"time": "2021-04-02T08:21:54+00:00"
},
{
"name": "sebastian/recursion-context",
@ -4728,12 +4729,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "249976376508ed7e83b6dc429cd883a44b2a3c51"
"reference": "78526ace5bac7c10048020f0317c58fd310a14ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/249976376508ed7e83b6dc429cd883a44b2a3c51",
"reference": "249976376508ed7e83b6dc429cd883a44b2a3c51",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/78526ace5bac7c10048020f0317c58fd310a14ec",
"reference": "78526ace5bac7c10048020f0317c58fd310a14ec",
"shasum": ""
},
"require": {
@ -4784,7 +4785,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:43+00:00"
"time": "2021-04-02T08:22:30+00:00"
},
{
"name": "sebastian/resource-operations",
@ -4848,12 +4849,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "e02c851008e26557b4f1b4ffd139b71c96937b04"
"reference": "17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/e02c851008e26557b4f1b4ffd139b71c96937b04",
"reference": "e02c851008e26557b4f1b4ffd139b71c96937b04",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51",
"reference": "17fc98bb3c75a02a1a99ffdd022e84ac6d22bd51",
"shasum": ""
},
"require": {
@ -4897,7 +4898,7 @@
"type": "github"
}
],
"time": "2021-03-17T06:17:51+00:00"
"time": "2021-04-02T08:36:52+00:00"
},
{
"name": "sebastian/version",
@ -4996,12 +4997,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47"
"reference": "9a90698d4624b85a578007a00312338d3adecaf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/5da8b675121f9f4419b7052caa0cc6118a3ccd47",
"reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47",
"url": "https://api.github.com/repos/symfony/console/zipball/9a90698d4624b85a578007a00312338d3adecaf8",
"reference": "9a90698d4624b85a578007a00312338d3adecaf8",
"shasum": ""
},
"require": {
@ -5087,7 +5088,7 @@
"type": "tidelift"
}
],
"time": "2021-03-23T14:20:07+00:00"
"time": "2021-04-09T09:54:19+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -5575,12 +5576,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "1309413986521646bb0ba91140afdc2a61ed8cfe"
"reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/1309413986521646bb0ba91140afdc2a61ed8cfe",
"reference": "1309413986521646bb0ba91140afdc2a61ed8cfe",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
"reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
"shasum": ""
},
"require": {
@ -5647,7 +5648,7 @@
"type": "tidelift"
}
],
"time": "2021-03-23T23:28:01+00:00"
"time": "2021-04-01T10:43:52+00:00"
},
{
"name": "symfony/string",
@ -5789,12 +5790,12 @@
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e"
"reference": "f7250c6ea6b6cdd724e25ce7c56e2a60006203cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/116bfb0bc9ec2a39db93431b7fe67144164d251e",
"reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/f7250c6ea6b6cdd724e25ce7c56e2a60006203cb",
"reference": "f7250c6ea6b6cdd724e25ce7c56e2a60006203cb",
"shasum": ""
},
"require": {
@ -5860,7 +5861,7 @@
"type": "tidelift"
}
],
"time": "2021-03-22T08:23:49+00:00"
"time": "2021-04-10T08:17:25+00:00"
},
{
"name": "vimeo/psalm",

View file

@ -2211,9 +2211,11 @@ match=text.match(new RegExp(regex,'gi'))
if(!match){return fail}
for(i=0,len=match.length;i<len;i++){if(!process(match[i])){return fail}}
return(date.getTime()/1000)}
return{format:format,strtotime:strtotime}}(),true);})(window);(function(window){"use strict";window.ls.container.set('env',function(){return APP_ENV;},true);})(window);(function(window){"use strict";window.ls.container.set('form',function(){function cast(value,to){switch(to){case'int':case'integer':value=parseInt(value);break;case'numeric':value=Number(value);break;case'string':value=value.toString();break;case'json':value=(value)?JSON.parse(value):[];break;case'array':value=(value&&value.constructor&&value.constructor===Array)?value:[value];break;case'array-empty':value=[];break;case'bool':case'boolean':value=(value==='false')?false:value;value=!!value;break;}
return{format:format,strtotime:strtotime}}(),true);})(window);(function(window){"use strict";window.ls.container.set('env',function(){return APP_ENV;},true);})(window);(function(window){"use strict";window.ls.container.set('form',function(){function cast(value,to){if(value&&Array.isArray(value)&&to!=='array'){value=value.map(element=>cast(element,to));return value;}
switch(to){case'int':case'integer':value=parseInt(value);break;case'numeric':value=Number(value);break;case'string':value=value.toString();break;case'json':value=(value)?JSON.parse(value):[];break;case'array':value=(value&&value.constructor&&value.constructor===Array)?value:[value];break;case'array-empty':value=[];break;case'bool':case'boolean':value=(value==='false')?false:value;value=!!value;break;}
return value;}
function toJson(element,json){json=json||{};let name=element.getAttribute('name');let type=element.getAttribute('type');let castTo=element.getAttribute('data-cast-to');let ref=json;if(name&&'FORM'!==element.tagName){if('FIELDSET'===element.tagName){if(castTo==='object'){if(json[name]===undefined){json[name]={};}
function toJson(element,json){json=json||{};let name=element.getAttribute('name');let type=element.getAttribute('type');let castTo=element.getAttribute('data-cast-to');let ref=json;if(name&&'FORM'!==element.tagName){if(name.startsWith('[')){let splitName=name.split('.');if(splitName.length>1&&splitName[0].endsWith(']')){name=splitName[splitName.length-1];}}
if('FIELDSET'===element.tagName){if(castTo==='object'){if(json[name]===undefined){json[name]={};}
ref=json[name];}
else{if(!Array.isArray(json[name])){json[name]=[];}
json[name].push({});ref=json[name][json[name].length-1];}}

View file

@ -256,9 +256,11 @@ match=text.match(new RegExp(regex,'gi'))
if(!match){return fail}
for(i=0,len=match.length;i<len;i++){if(!process(match[i])){return fail}}
return(date.getTime()/1000)}
return{format:format,strtotime:strtotime}}(),true);})(window);(function(window){"use strict";window.ls.container.set('env',function(){return APP_ENV;},true);})(window);(function(window){"use strict";window.ls.container.set('form',function(){function cast(value,to){switch(to){case'int':case'integer':value=parseInt(value);break;case'numeric':value=Number(value);break;case'string':value=value.toString();break;case'json':value=(value)?JSON.parse(value):[];break;case'array':value=(value&&value.constructor&&value.constructor===Array)?value:[value];break;case'array-empty':value=[];break;case'bool':case'boolean':value=(value==='false')?false:value;value=!!value;break;}
return{format:format,strtotime:strtotime}}(),true);})(window);(function(window){"use strict";window.ls.container.set('env',function(){return APP_ENV;},true);})(window);(function(window){"use strict";window.ls.container.set('form',function(){function cast(value,to){if(value&&Array.isArray(value)&&to!=='array'){value=value.map(element=>cast(element,to));return value;}
switch(to){case'int':case'integer':value=parseInt(value);break;case'numeric':value=Number(value);break;case'string':value=value.toString();break;case'json':value=(value)?JSON.parse(value):[];break;case'array':value=(value&&value.constructor&&value.constructor===Array)?value:[value];break;case'array-empty':value=[];break;case'bool':case'boolean':value=(value==='false')?false:value;value=!!value;break;}
return value;}
function toJson(element,json){json=json||{};let name=element.getAttribute('name');let type=element.getAttribute('type');let castTo=element.getAttribute('data-cast-to');let ref=json;if(name&&'FORM'!==element.tagName){if('FIELDSET'===element.tagName){if(castTo==='object'){if(json[name]===undefined){json[name]={};}
function toJson(element,json){json=json||{};let name=element.getAttribute('name');let type=element.getAttribute('type');let castTo=element.getAttribute('data-cast-to');let ref=json;if(name&&'FORM'!==element.tagName){if(name.startsWith('[')){let splitName=name.split('.');if(splitName.length>1&&splitName[0].endsWith(']')){name=splitName[splitName.length-1];}}
if('FIELDSET'===element.tagName){if(castTo==='object'){if(json[name]===undefined){json[name]={};}
ref=json[name];}
else{if(!Array.isArray(json[name])){json[name]=[];}
json[name].push({});ref=json[name][json[name].length-1];}}

View file

@ -4,6 +4,10 @@
window.ls.container.set('form', function () {
function cast(value, to) {
if (value && Array.isArray(value) && to !== 'array') {
value = value.map(element => cast(element, to));
return value;
}
switch (to) {
case 'int':
case 'integer':
@ -42,6 +46,12 @@
let ref = json;
if (name && 'FORM' !== element.tagName) {
if (name.startsWith('[')) { // Check for array names
let splitName = name.split('.');
if (splitName.length > 1 && splitName[0].endsWith(']')) {
name = splitName[splitName.length-1];
}
}
if ('FIELDSET' === element.tagName) { // Fieldset Array / Object
if (castTo === 'object') {
@ -118,4 +128,4 @@
}
}, true, false);
})(window);
})(window);

View file

@ -40,4 +40,28 @@ class Password extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -188,4 +188,28 @@ class Authorization extends Validator
{
self::$status = self::$statusDefault;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_ARRAY;
}
}

View file

@ -78,4 +78,28 @@ class DocumentId extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -48,4 +48,27 @@ class Key extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -74,4 +74,27 @@ class Permissions extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_ARRAY;
}
}

View file

@ -285,4 +285,28 @@ class Structure extends Validator
{
return $this->database->getDocument($id);
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_OBJECT;
}
}

View file

@ -43,4 +43,28 @@ class UID extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -54,4 +54,28 @@ class CNAME extends Validator
return false;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -51,4 +51,28 @@ class Domain extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -25,18 +25,6 @@ class Email extends Validator
return 'Value must be a valid email address';
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType()
{
return 'string';
}
/**
* Is valid
*
@ -53,4 +41,28 @@ class Email extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -35,18 +35,6 @@ class Host extends Validator
return 'URL host must be one of: ' . \implode(', ', $this->whitelist);
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType()
{
return 'string';
}
/**
* Is valid
*
@ -69,4 +57,28 @@ class Host extends Validator
return false;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -51,18 +51,6 @@ class IP extends Validator
return 'Value must be a valid IP address';
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType()
{
return 'string';
}
/**
* Is valid
*
@ -99,4 +87,28 @@ class IP extends Validator
return false;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -119,4 +119,28 @@ class Origin extends Validator
return false;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -25,18 +25,6 @@ class URL extends Validator
return 'Value must be a valid URL';
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType()
{
return 'string';
}
/**
* Is valid
*
@ -53,4 +41,28 @@ class URL extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -83,7 +83,9 @@ class OpenAPI3 extends Format
$output['components']['securitySchemes']['Mode']['x-appwrite'] = ['demo' => ''];
}
foreach ($this->routes as $route) { /* @var $route \Utopia\Route */
$usedModels = [];
foreach ($this->routes as $route) { /** @var \Utopia\Route $route */
$url = \str_replace('/v1', '', $route->getURL());
$scope = $route->getLabel('scope', '');
$hide = $route->getLabel('sdk.hide', false);
@ -146,6 +148,7 @@ class OpenAPI3 extends Format
// ],
];
} else {
$usedModels[] = $model->getType();
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
'description' => $model->getName(),
'content' => [
@ -236,7 +239,7 @@ class OpenAPI3 extends Format
$node['schema']['format'] = 'format';
$node['schema']['x-example'] = 'password';
break;
case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
$node['schema']['type'] = 'integer';
$node['schema']['format'] = 'int32';
$node['schema']['x-example'] = $validator->getMin();
@ -248,14 +251,18 @@ class OpenAPI3 extends Format
case 'Utopia\Validator\Length':
$node['schema']['type'] = 'string';
break;
case 'Utopia\Validator\Host':
case 'Appwrite\Network\Validator\Host':
$node['schema']['type'] = 'string';
$node['schema']['format'] = 'url';
$node['schema']['x-example'] = 'https://example.com';
break;
case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */
$node['schema']['type'] = 'string';
case 'Utopia\Validator\WhiteList': /** @var \Utopia\Validator\WhiteList $validator */
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = $validator->getList()[0];
if ($validator->getType() === 'integer') {
$node['format'] = 'int32';
}
break;
default:
$node['schema']['type'] = 'string';
@ -307,8 +314,18 @@ class OpenAPI3 extends Format
$output['paths'][$url][\strtolower($route->getMethod())] = $temp;
}
foreach ($this->models as $model) {
foreach ($model->getRules() as $rule) {
if (!in_array($rule['type'], ['string', 'integer', 'boolean', 'json', 'float'])) {
$usedModels[] = $rule['type'];
}
}
}
foreach ($this->models as $model) {
if (!in_array($model->getType(), $usedModels) && $model->getType() !== 'error') {
continue;
}
$required = $model->getRequired();
$rules = $model->getRules();

View file

@ -4,6 +4,7 @@ namespace Appwrite\Specification\Format;
use Appwrite\Specification\Format;
use Appwrite\Template\Template;
use Appwrite\Utopia\Response\Model;
use stdClass;
class Swagger2 extends Format
@ -81,7 +82,9 @@ class Swagger2 extends Format
$output['securityDefinitions']['Mode']['x-appwrite'] = ['demo' => ''];
}
foreach ($this->routes as $route) { /* @var $route \Utopia\Route */
$usedModels = [];
foreach ($this->routes as $route) { /** @var \Utopia\Route $route */
$url = \str_replace('/v1', '', $route->getURL());
$scope = $route->getLabel('scope', '');
$hide = $route->getLabel('sdk.hide', false);
@ -148,6 +151,7 @@ class Swagger2 extends Format
],
];
} else {
$usedModels[] = $model->getType();
$temp['responses'][(string)$route->getLabel('sdk.response.code', '500')] = [
'description' => $model->getName(),
'schema' => [
@ -232,7 +236,7 @@ class Swagger2 extends Format
$node['format'] = 'format';
$node['x-example'] = 'password';
break;
case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
$node['type'] = 'integer';
$node['format'] = 'int32';
$node['x-example'] = $validator->getMin();
@ -244,14 +248,18 @@ class Swagger2 extends Format
case 'Utopia\Validator\Length':
$node['type'] = 'string';
break;
case 'Utopia\Validator\Host':
case 'Appwrite\Network\Validator\Host':
$node['type'] = 'string';
$node['format'] = 'url';
$node['x-example'] = 'https://example.com';
break;
case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */
$node['type'] = 'string';
case 'Utopia\Validator\WhiteList': /** @var \Utopia\Validator\WhiteList $validator */
$node['type'] = $validator->getType();
$node['x-example'] = $validator->getList()[0];
if ($validator->getType() === 'integer') {
$node['format'] = 'int32';
}
break;
default:
$node['type'] = 'string';
@ -308,8 +316,18 @@ class Swagger2 extends Format
$output['paths'][$url][\strtolower($route->getMethod())] = $temp;
}
foreach ($this->models as $model) {
foreach ($model->getRules() as $rule) {
if (!in_array($rule['type'], ['string', 'integer', 'boolean', 'json', 'float'])) {
$usedModels[] = $rule['type'];
}
}
}
foreach ($this->models as $model) {
if (!in_array($model->getType(), $usedModels) && $model->getType() !== 'error') {
continue;
}
$required = $model->getRequired();
$rules = $model->getRules();

View file

@ -40,4 +40,28 @@ class Cron extends Validator
return true;
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}

View file

@ -15,6 +15,7 @@ use Appwrite\Utopia\Response\Model\Collection;
use Appwrite\Utopia\Response\Model\Continent;
use Appwrite\Utopia\Response\Model\Country;
use Appwrite\Utopia\Response\Model\Currency;
use Appwrite\Utopia\Response\Model\Document as ModelDocument;
use Appwrite\Utopia\Response\Model\Domain;
use Appwrite\Utopia\Response\Model\Error;
use Appwrite\Utopia\Response\Model\ErrorDev;
@ -61,6 +62,7 @@ class Response extends SwooleResponse
const MODEL_COLLECTION = 'collection';
const MODEL_COLLECTION_LIST = 'collectionList';
const MODEL_RULE = 'rule';
const MODEL_DOCUMENT = 'document';
const MODEL_DOCUMENT_LIST = 'documentList';
// Users
@ -145,7 +147,7 @@ class Response extends SwooleResponse
->setModel(new ErrorDev())
// Lists
->setModel(new BaseList('Collections List', self::MODEL_COLLECTION_LIST, 'collections', self::MODEL_COLLECTION))
->setModel(new BaseList('Documents List', self::MODEL_DOCUMENT_LIST, 'documents', self::MODEL_ANY))
->setModel(new BaseList('Documents List', self::MODEL_DOCUMENT_LIST, 'documents', self::MODEL_DOCUMENT))
->setModel(new BaseList('Users List', self::MODEL_USER_LIST, 'users', self::MODEL_USER))
->setModel(new BaseList('Sessions List', self::MODEL_SESSION_LIST, 'sessions', self::MODEL_SESSION))
->setModel(new BaseList('Logs List', self::MODEL_LOG_LIST, 'logs', self::MODEL_LOG, false))
@ -169,6 +171,7 @@ class Response extends SwooleResponse
// Entities
->setModel(new Permissions())
->setModel(new Collection())
->setModel(new ModelDocument())
->setModel(new Rule())
->setModel(new Log())
->setModel(new User())

View file

@ -108,6 +108,7 @@ class V06 extends Filter {
break;
case Response::MODEL_ANY :
case Response::MODEL_DOCUMENT :
$parsedResponse = $content;
break;

View file

@ -0,0 +1,52 @@
<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
class Document extends Any
{
/**
* Get Name
*
* @return string
*/
public function getName(): string
{
return 'Document';
}
/**
* Get Collection
*
* @return string
*/
public function getType(): string
{
return Response::MODEL_DOCUMENT;
}
public function __construct()
{
$this
->addRule('$id', [
'type' => self::TYPE_STRING,
'description' => 'Document ID.',
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('$collection', [
'type' => self::TYPE_STRING,
'description' => 'Collection ID.',
'default' => '',
'example' => '5e5ea5c15117e',
])
->addRule('$permissions', [
'type' => Response::MODEL_PERMISSIONS,
'description' => 'Document permissions.',
'default' => new \stdClass,
'example' => new \stdClass,
'array' => false,
]);
}
}