mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
update refactor
This commit is contained in:
@@ -45,13 +45,6 @@ use MaxMind\Db\Reader;
|
||||
/**
|
||||
* Create attribute of varying type
|
||||
*
|
||||
* @param string $collectionId
|
||||
* @param Utopia\Database\Document $attribute
|
||||
* @param Appwrite\Utopia\Response $response
|
||||
* @param Utopia\Database\Database $dbForProject
|
||||
* @param Appwrite\Event\Database $database
|
||||
* @param Appwrite\Event\Audit $audits
|
||||
* @param Appwrite\Stats\Stats $usage
|
||||
*
|
||||
* @return Document Newly created attribute document
|
||||
*/
|
||||
@@ -165,7 +158,7 @@ App::post('/v1/database/collections')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $name, ?string $permission, array $read, array $write, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $name, string $permission, ?array $read, ?array $write, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
$collectionId = $collectionId == 'unique()' ? $dbForProject->getId() : $collectionId;
|
||||
|
||||
@@ -588,7 +581,7 @@ App::put('/v1/database/collections/:collectionId')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $name, string $permission, array $read, array $write, bool $enabled, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $name, string $permission, ?array $read, ?array $write, bool $enabled, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
$collection = $dbForProject->getDocument('collections', $collectionId);
|
||||
|
||||
@@ -705,7 +698,7 @@ App::post('/v1/database/collections/:collectionId/attributes/string')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId,string $key, int $size, bool $required, string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId,string $key, int $size, bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
// Ensure attribute default is within required size
|
||||
$validator = new Text($size);
|
||||
@@ -748,7 +741,7 @@ App::post('/v1/database/collections/:collectionId/attributes/email')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, bool $required, string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, Event $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, Event $audits, Stats $usage, Event $events) {
|
||||
|
||||
$attribute = createAttribute($collectionId, new Document([
|
||||
'key' => $key,
|
||||
@@ -787,7 +780,7 @@ App::post('/v1/database/collections/:collectionId/attributes/enum')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, array $elements, bool $required, string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, array $elements, bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
// use length of longest string as attribute size
|
||||
$size = 0;
|
||||
@@ -841,7 +834,7 @@ App::post('/v1/database/collections/:collectionId/attributes/ip')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, bool $required, string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
$attribute = createAttribute($collectionId, new Document([
|
||||
'key' => $key,
|
||||
@@ -879,7 +872,7 @@ App::post('/v1/database/collections/:collectionId/attributes/url')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, bool $required, string $default, array $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?string $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
$attribute = createAttribute($collectionId, new Document([
|
||||
'key' => $key,
|
||||
@@ -919,7 +912,7 @@ App::post('/v1/database/collections/:collectionId/attributes/integer')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, bool $required, int $min, int $max, int $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?int $min, ?int $max, ?int $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
// Ensure attribute default is within range
|
||||
$min = (is_null($min)) ? PHP_INT_MIN : \intval($min);
|
||||
@@ -986,7 +979,7 @@ App::post('/v1/database/collections/:collectionId/attributes/float')
|
||||
->inject('audits')
|
||||
->inject('events')
|
||||
->inject('usage')
|
||||
->action(function (string $collectionId, string $key, bool $required, int $min, int $max, float $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Event $events, Stats $usage) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?float $min, ?float $max, ?float $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Event $events, Stats $usage) {
|
||||
|
||||
// Ensure attribute default is within range
|
||||
$min = (is_null($min)) ? -PHP_FLOAT_MAX : \floatval($min);
|
||||
@@ -1054,7 +1047,7 @@ App::post('/v1/database/collections/:collectionId/attributes/boolean')
|
||||
->inject('audits')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->action(function (string $collectionId, string $key, bool $required, bool $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
->action(function (string $collectionId, string $key, bool $required, ?bool $default, bool $array, Response $response, Database $dbForProject, EventDatabase $database, EventAudit $audits, Stats $usage, Event $events) {
|
||||
|
||||
$attribute = createAttribute($collectionId, new Document([
|
||||
'key' => $key,
|
||||
@@ -1514,7 +1507,7 @@ App::post('/v1/database/collections/:collectionId/documents')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->inject('mode')
|
||||
->action(function (string $documentId, string $collectionId, array $data, array $read, array $write, Response $response, Database $dbForProject, Document $user, EventAudit $audits, Stats $usage, Event $events, string $mode) {
|
||||
->action(function (string $documentId, string $collectionId, $data, ?array $read, ?array $write, Response $response, Database $dbForProject, Document $user, EventAudit $audits, Stats $usage, Event $events, string $mode) {
|
||||
|
||||
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
|
||||
|
||||
@@ -1628,7 +1621,7 @@ App::get('/v1/database/collections/:collectionId/documents')
|
||||
->inject('dbForProject')
|
||||
->inject('usage')
|
||||
->inject('mode')
|
||||
->action(function (string $collectionId, array $queries, int $limit, int $offset, string $cursor,string $cursorDirection, array $orderAttributes, array $orderTypes, Response $response, Database $dbForProject, Stats $usage, string $mode) {
|
||||
->action(function (string $collectionId, array $queries, int $limit, int $offset, string $cursor, string $cursorDirection, array $orderAttributes, array $orderTypes, Response $response, Database $dbForProject, Stats $usage, string $mode) {
|
||||
|
||||
/**
|
||||
* Skip Authorization to get the collection. Needed in case of empty permissions for document level permissions.
|
||||
@@ -1883,7 +1876,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId')
|
||||
->inject('usage')
|
||||
->inject('events')
|
||||
->inject('mode')
|
||||
->action(function (string $collectionId, string $documentId, array $data, array $read, array $write, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events, string $mode) {
|
||||
->action(function (string $collectionId, string $documentId, $data, ?array $read, ?array $write, Response $response, Database $dbForProject, EventAudit $audits, Stats $usage, Event $events, string $mode) {
|
||||
|
||||
/**
|
||||
* Skip Authorization to get the collection. Needed in case of empty permissions for document level permissions.
|
||||
|
||||
Reference in New Issue
Block a user