diff --git a/app/config/collections.php b/app/config/collections.php index 87a68177b3..e55c694ea3 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3,7 +3,7 @@ use Appwrite\Auth\Auth; use Utopia\Config\Config; use Utopia\Database\Database; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; $providers = Config::getParam('providers', []); $auth = Config::getParam('auth', []); diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 74ea1b5e7c..6473050592 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -29,10 +29,10 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\DateTime; use Utopia\Database\Exception\Duplicate; -use Utopia\Database\ID; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Locale\Locale; @@ -53,7 +53,6 @@ App::post('/v1/account/invite') ->label('audits.event', 'user.create') ->label('audits.resource', 'user/{response.$id}') ->label('audits.userId', '{response.$id}') - ->label('usage.metric', 'users.{scope}.requests.create') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) ->label('sdk.namespace', 'account') ->label('sdk.method', 'createWithInviteCode') diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 7fbcbcf215..3c410c4fd0 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -4,10 +4,10 @@ use Utopia\App; use Appwrite\Event\Delete; use Appwrite\Extend\Exception; use Utopia\Audit\Audit; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\DatetimeValidator; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Validator\Boolean; use Utopia\Validator\FloatValidator; use Utopia\Validator\Integer; @@ -851,7 +851,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string ->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).') ->param('key', '', new Key(), 'Attribute Key.') ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Range::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.') - ->param('required', null, new Boolean(true), 'Is attribute required?') + ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Text(0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') @@ -2447,9 +2447,9 @@ App::get('/v1/databases/usage') } $response->dynamic(new Document([ 'range' => $range, - 'databasesCount' => $usage[$metrics[0]], - 'collectionsCount' => $usage[$metrics[1]], - 'documentsCount' => $usage[$metrics[2]], + 'databasesTotal' => $usage[$metrics[0]], + 'collectionsTotal' => $usage[$metrics[1]], + 'documentsTotal' => $usage[$metrics[2]], ]), Response::MODEL_USAGE_DATABASES); }); @@ -2522,8 +2522,8 @@ App::get('/v1/databases/:databaseId/usage') $response->dynamic(new Document([ 'range' => $range, - 'collectionsCount' => $usage[$metrics[0]], - 'documentsCount' => $usage[$metrics[1]], + 'collectionsTotal' => $usage[$metrics[0]], + 'documentsTotal' => $usage[$metrics[1]], ]), Response::MODEL_USAGE_DATABASE); }); @@ -2599,6 +2599,6 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/usage') $response->dynamic(new Document([ 'range' => $range, - 'documentsCount' => $usage[$metrics[0]], + 'documentsTotal' => $usage[$metrics[0]], ]), Response::MODEL_USAGE_COLLECTION); }); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 67c803a700..47495d56ba 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -10,9 +10,9 @@ use Appwrite\Event\Usage; use Appwrite\Event\Validator\Event as ValidatorEvent; use Appwrite\Extend\Exception; use Appwrite\Utopia\Database\Validator\CustomId; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\UID; use Utopia\Storage\Device; use Utopia\Storage\Validator\File; @@ -85,6 +85,7 @@ App::post('/v1/functions') 'deployment' => '', 'events' => $events, 'schedule' => $schedule, + 'scheduleInternalId' => '', 'scheduleUpdatedAt' => DateTime::now(), 'timeout' => $timeout, 'search' => implode(' ', [$functionId, $name, $runtime]) @@ -95,6 +96,7 @@ App::post('/v1/functions') 'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region 'resourceType' => 'function', 'resourceId' => $function->getId(), + 'resourceInternalId' => $function->getInternalId(), 'resourceUpdatedAt' => DateTime::now(), 'projectId' => $project->getId(), 'schedule' => $function->getAttribute('schedule'), @@ -236,8 +238,8 @@ App::get('/v1/functions/:functionId/usage') $stats = $usage = []; $days = $periods[$range]; $metrics = [ - str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS), - str_replace(['{resourceType}', '{resourceInternalId}'], $function->getInternalId(), METRIC_FUNCTION_ID_STORAGE), + str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS), + str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE), @@ -694,6 +696,7 @@ App::post('/v1/functions/:functionId/deployments') 'resourceInternalId' => $function->getInternalId(), 'resourceId' => $function->getId(), 'resourceType' => 'functions', + 'buildInternalId' => '', 'entrypoint' => $entrypoint, 'path' => $path, 'size' => $fileSize, @@ -725,6 +728,7 @@ App::post('/v1/functions/:functionId/deployments') 'resourceInternalId' => $function->getInternalId(), 'resourceId' => $function->getId(), 'resourceType' => 'functions', + 'buildInternalId' => '', 'entrypoint' => $entrypoint, 'path' => $path, 'size' => $fileSize, @@ -1168,8 +1172,8 @@ App::post('/v1/functions/:functionId/executions') * Sync execution compute usage from */ $queueForUsage - ->addMetric('executions.compute', (int)($executionResponse['duration'] * 1000))// per project - ->addMetric("{$function->getInternalId()}" . ".executions.compute", (int)($executionResponse['duration'] * 1000))// per function + ->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($executionResponse['duration'] * 1000))// per project + ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($executionResponse['duration'] * 1000))// per function ; } catch (\Throwable $th) { $interval = (new \DateTime())->diff(new \DateTime($execution->getCreatedAt())); diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 26ecf5d0f1..40b47b2913 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -29,15 +29,15 @@ App::get('/v1/project/usage') $stats = $usage = []; $days = $periods[$range]; $metrics = [ - 'network.requests', - 'network.inbound', - 'network.outbound', - 'executions', - 'documents', - 'databases', - 'users', - 'files.storage', - 'buckets', + METRIC_NETWORK_REQUESTS, + METRIC_NETWORK_INBOUND, + METRIC_NETWORK_OUTBOUND, + METRIC_EXECUTIONS, + METRIC_DOCUMENTS, + METRIC_DATABASES, + METRIC_USERS, + METRIC_BUCKETS, + METRIC_FILES_STORAGE ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -50,6 +50,7 @@ App::get('/v1/project/usage') Query::limit($limit), Query::orderDesc('time'), ]); + $stats[$metric] = []; foreach ($results as $result) { $stats[$metric][$result->getAttribute('time')] = [ @@ -59,6 +60,7 @@ App::get('/v1/project/usage') } }); + $format = match ($days['period']) { '1h' => 'Y-m-d\TH:00:00.000P', '1d' => 'Y-m-d\T00:00:00.000P', @@ -77,15 +79,16 @@ App::get('/v1/project/usage') } } + $response->dynamic(new Document([ 'range' => $range, - 'requests' => ($usage[$metrics[0]]), + 'requestsTotal' => ($usage[$metrics[0]]), 'network' => ($usage[$metrics[1]] + $usage[$metrics[2]]), - 'executions' => $usage[$metrics[3]], - 'documents' => $usage[$metrics[4]], - 'databases' => $usage[$metrics[5]], - 'users' => $usage[$metrics[6]], - 'storage' => $usage[$metrics[7]], - 'buckets' => $usage[$metrics[8]], + 'executionsTotal' => $usage[$metrics[3]], + 'documentsTotal' => $usage[$metrics[4]], + 'databasesTotal' => $usage[$metrics[5]], + 'usersTotal' => $usage[$metrics[6]], + 'bucketsTotal' => $usage[$metrics[7]], + 'filesStorage' => $usage[$metrics[8]], ]), Response::MODEL_USAGE_PROJECT); }); diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 5fef7eab78..8c2725fc1c 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -17,11 +17,11 @@ use Utopia\Audit\Audit; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\DateTime; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\DatetimeValidator; use Utopia\Database\Validator\UID; use Utopia\Domains\Domain; diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index dcf5900b46..3098d91b2d 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -16,10 +16,10 @@ use Utopia\Database\Exception\Duplicate; use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\Structure as StructureException; -use Utopia\Database\ID; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; @@ -1439,8 +1439,8 @@ App::get('/v1/storage/:bucketId/usage') $stats = $usage = []; $days = $periods[$range]; $metrics = [ - $bucket->getInternalId() . '.files', - $bucket->getInternalId() . '.files.storage', + str_replace('{bucketId}', $bucket->getInternalId(), METRIC_BUCKET_ID_FILES), + str_replace('{bucketId}', $bucket->getInternalId(), METRIC_BUCKET_ID_FILES_STORAGE), ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -1483,7 +1483,7 @@ App::get('/v1/storage/:bucketId/usage') $response->dynamic(new Document([ 'range' => $range, - 'filesCount' => $usage[$metrics[0]], + 'filesTotal' => $usage[$metrics[0]], 'filesStorage' => $usage[$metrics[1]], ]), Response::MODEL_USAGE_BUCKETS); }); @@ -1507,9 +1507,9 @@ App::get('/v1/storage/usage') $stats = $usage = []; $days = $periods[$range]; $metrics = [ - 'buckets', - 'files', - 'files.storage', + METRIC_BUCKETS, + METRIC_FILES, + METRIC_FILES_STORAGE, ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -1551,8 +1551,8 @@ App::get('/v1/storage/usage') $response->dynamic(new Document([ 'range' => $range, - 'bucketsCount' => $usage[$metrics[0]], - 'filesCount' => $usage[$metrics[1]], + 'bucketsTotal' => $usage[$metrics[0]], + 'filesTotal' => $usage[$metrics[1]], 'filesStorage' => $usage[$metrics[2]], ]), Response::MODEL_USAGE_STORAGE); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 572b6f02a8..9d202ad355 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -25,11 +25,11 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Duplicate; -use Utopia\Database\ID; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; use Utopia\Database\DateTime; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 0df53a0dff..47b7b16947 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -16,9 +16,9 @@ use Appwrite\Utopia\Response; use Utopia\App; use Utopia\Audit\Audit; use Utopia\Config\Config; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Locale\Locale; use Appwrite\Extend\Exception; use Utopia\Database\Document; @@ -1089,8 +1089,8 @@ App::get('/v1/users/usage') $stats = $usage = []; $days = $periods[$range]; $metrics = [ - 'users', - 'sessions', + METRIC_USERS, + METRIC_SESSIONS, ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -1132,7 +1132,7 @@ App::get('/v1/users/usage') $response->dynamic(new Document([ 'range' => $range, - 'usersCount' => $usage[$metrics[0]], - 'sessionsCount' => $usage[$metrics[1]], + 'usersTotal' => $usage[$metrics[0]], + 'sessionsTotal' => $usage[$metrics[1]], ]), Response::MODEL_USAGE_USERS); }); diff --git a/app/controllers/general.php b/app/controllers/general.php index d251e4ab93..9923fd74ff 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../init.php'; use Utopia\App; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Locale\Locale; use Utopia\Logger\Logger; use Utopia\Logger\Log; diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 034f18165b..b980f09938 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -7,14 +7,13 @@ use Utopia\Database\Document; use Appwrite\Network\Validator\Host; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; -use Appwrite\Utopia\Response\Model; use Utopia\App; use Utopia\Validator\ArrayList; use Utopia\Validator\Integer; use Utopia\Validator\Text; use Utopia\Storage\Validator\File; use Utopia\Validator\WhiteList; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; App::get('/v1/mock/tests/foo') ->desc('Get Foo') diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 8f68e48092..fff8c9ade6 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -137,7 +137,7 @@ $databaseListener = function (string $event, Document $document, Document $proje ->addMetric(METRIC_DEPLOYMENTS, $value) // per project ->addMetric(METRIC_DEPLOYMENTS_STORAGE, $document->getAttribute('size') * $value) // per project ->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_DEPLOYMENTS), $value)// per function - ->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_STORAGE), $document->getAttribute('size') * $value);// per function + ->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [$document->getAttribute('resourceType'), $document->getAttribute('resourceInternalId')], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE), $document->getAttribute('size') * $value);// per function break; case $document->getCollection() === 'executions': @@ -514,19 +514,20 @@ App::shutdown() } } + + if ($project->getId() !== 'console') { if ($mode !== APP_MODE_ADMIN) { $fileSize = 0; $file = $request->getFiles('file'); - if (!empty($file)) { $fileSize = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size']; } $queueForUsage - ->addMetric('network.requests', 1) - ->addMetric("network.inbound", $request->getSize() + $fileSize) - ->addMetric("network.outbound", $response->getSize()); + ->addMetric(METRIC_NETWORK_REQUESTS, 1) + ->addMetric(METRIC_NETWORK_INBOUND, $request->getSize() + $fileSize) + ->addMetric(METRIC_NETWORK_OUTBOUND, $response->getSize()); } $queueForUsage diff --git a/app/http.php b/app/http.php index 23fd0dbcc9..f241b9e155 100644 --- a/app/http.php +++ b/app/http.php @@ -10,9 +10,9 @@ use Swoole\Http\Response as SwooleResponse; use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Audit\Audit; use Utopia\Abuse\Adapters\TimeLimit; diff --git a/app/init.php b/app/init.php index 3d74845416..1c8e6eb5cd 100644 --- a/app/init.php +++ b/app/init.php @@ -41,7 +41,7 @@ use Appwrite\URL\URL as AppwriteURL; use Utopia\App; use Utopia\Validator\Range; use Utopia\Validator\WhiteList; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\Document; use Utopia\Database\Database; use Utopia\Database\Query; @@ -199,12 +199,14 @@ const METRIC_FUNCTION_ID_BUILDS = '{functionInternalId}.builds'; const METRIC_FUNCTION_ID_BUILDS_STORAGE = '{functionInternalId}.builds.storage'; const METRIC_FUNCTION_ID_BUILDS_COMPUTE = '{functionInternalId}.builds.compute'; const METRIC_FUNCTION_ID_DEPLOYMENTS = '{resourceType}.{resourceInternalId}.deployments'; -const METRIC_FUNCTION_ID_STORAGE = '{resourceType}.{resourceInternalId}.deployments.storage'; +const METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE = '{resourceType}.{resourceInternalId}.deployments.storage'; const METRIC_EXECUTIONS = 'executions'; const METRIC_EXECUTIONS_COMPUTE = 'executions.compute'; const METRIC_FUNCTION_ID_EXECUTIONS = '{functionInternalId}.executions'; const METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE = '{functionInternalId}.executions.compute'; - +const METRIC_NETWORK_REQUESTS = 'network.requests'; +const METRIC_NETWORK_INBOUND = 'network.inbound'; +const METRIC_NETWORK_OUTBOUND = 'network.outbound'; $register = new Registry(); diff --git a/app/realtime.php b/app/realtime.php index 4b40e2a9dd..f7f40de84c 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -13,8 +13,8 @@ use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; use Utopia\Logger\Log; use Utopia\Database\DateTime; use Utopia\Database\Document; diff --git a/app/worker.php b/app/worker.php index 78671d731c..6be41e4488 100644 --- a/app/worker.php +++ b/app/worker.php @@ -107,7 +107,7 @@ Server::setResource('pools', function ($register) { $pools = $register->get('pools'); $connection = $pools->get('queue')->pop()->getResource(); $workerNumber = swoole_cpu_num() * intval(App::getEnv('_APP_WORKER_PER_CORE', 6)); - +$workerNumber = 1; if (empty(App::getEnv('QUEUE'))) { throw new Exception('Please configure "QUEUE" environemnt variable.'); } diff --git a/app/workers/builds.php b/app/workers/builds.php index bfcb297700..9145808b6c 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -9,7 +9,7 @@ use Executor\Executor; use Utopia\Database\DateTime; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\DSN\DSN; use Utopia\Database\Document; use Utopia\Config\Config; diff --git a/app/workers/certificates.php b/app/workers/certificates.php index b4f0701c46..60ee3e8e0b 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -8,7 +8,7 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Domains\Domain; diff --git a/app/workers/functions.php b/app/workers/functions.php index e649fed2f5..60b9bec5a4 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -14,10 +14,10 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\ID; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Queue\Server; diff --git a/app/workers/usage.php b/app/workers/usage.php index 450de6955e..a4d7315ab7 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -45,27 +45,27 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools switch (true) { case $document->getCollection() === 'users': // users - $sessions = count($document->getAttribute('sessions', 0)); + $sessions = count($document->getAttribute(METRIC_SESSIONS, 0)); if (!empty($sessions)) { $metrics[] = [ - 'key' => 'sessions', + 'key' => METRIC_SESSIONS, 'value' => ($sessions * -1), ]; } break; case $document->getCollection() === 'databases': // databases - $collections = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".collections")); - $documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".documents")); + $collections = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{databaseId}', $document->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS))); + $documents = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{databaseId}', $document->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS))); if (!empty($collections['value'])) { $metrics[] = [ - 'key' => 'collections', + 'key' => METRIC_COLLECTIONS, 'value' => ($collections['value'] * -1), ]; } if (!empty($documents['value'])) { $metrics[] = [ - 'key' => 'documents', + 'key' => METRIC_DOCUMENTS, 'value' => ($documents['value'] * -1), ]; } @@ -73,93 +73,93 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections $parts = explode('_', $document->getCollection()); $databaseId = $parts[1] ?? 0; - $documents = $dbForProject->getDocument('stats', md5("_inf_" . "{$databaseId}" . "." . "{$document->getInternalId()}" . ".documents")); + $documents = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{databaseId}', '{collectionId}'], [$databaseId, $document->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS))); if (!empty($documents['value'])) { $metrics[] = [ - 'key' => 'documents', + 'key' => METRIC_DOCUMENTS, 'value' => ($documents['value'] * -1), ]; $metrics[] = [ - 'key' => "{$databaseId}" . ".documents", + 'key' => str_replace('{databaseId}', $databaseId, METRIC_DATABASE_ID_DOCUMENTS), 'value' => ($documents['value'] * -1), ]; } break; case $document->getCollection() === 'buckets': - $files = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".files")); - $storage = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".files.storage")); + $files = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{bucketId}', $document->getInternalId(), METRIC_BUCKET_ID_FILES))); + $storage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{bucketId}', $document->getInternalId(), METRIC_BUCKET_ID_FILES_STORAGE))); if (!empty($files['value'])) { $metrics[] = [ - 'key' => 'files', + 'key' => METRIC_FILES, 'value' => ($files['value'] * -1), ]; } if (!empty($storage['value'])) { $metrics[] = [ - 'key' => 'files.storage', + 'key' => METRIC_FILES_STORAGE, 'value' => ($storage['value'] * -1), ]; } break; case $document->getCollection() === 'functions': - $deployments = $dbForProject->getDocument('stats', md5("_inf_function." . "{$document->getInternalId()}" . ".deployments")); - $deploymentsStorage = $dbForProject->getDocument('stats', md5("_inf_function." . "{$document->getInternalId()}" . ".deployments.storage")); - $builds = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds")); - $buildsStorage = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds.storage")); - $buildsCompute = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".builds.compute")); - $executions = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".executions")); - $executionsCompute = $dbForProject->getDocument('stats', md5("_inf_" . "{$document->getInternalId()}" . ".executions.compute")); + $deployments = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $document->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS))); + $deploymentsStorage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $document->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE))); + $builds = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS))); + $buildsStorage = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE))); + $buildsCompute = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE))); + $executions = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS))); + $executionsCompute = $dbForProject->getDocument('stats', md5("_inf_" . str_replace('{functionInternalId}', $document->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE))); if (!empty($deployments['value'])) { $metrics[] = [ - 'key' => 'deployments', + 'key' => METRIC_DEPLOYMENTS, 'value' => ($deployments['value'] * -1), ]; } if (!empty($deploymentsStorage['value'])) { $metrics[] = [ - 'key' => 'deployments.storage', + 'key' => METRIC_DEPLOYMENTS_STORAGE, 'value' => ($deploymentsStorage['value'] * -1), ]; } if (!empty($builds['value'])) { $metrics[] = [ - 'key' => 'builds', + 'key' => METRIC_BUILDS, 'value' => ($builds['value'] * -1), ]; } if (!empty($buildsStorage['value'])) { $metrics[] = [ - 'key' => 'builds.storage', + 'key' => METRIC_BUILDS_STORAGE, 'value' => ($buildsStorage['value'] * -1), ]; } if (!empty($buildsCompute['value'])) { $metrics[] = [ - 'key' => 'builds.compute', + 'key' => METRIC_BUILDS_COMPUTE, 'value' => ($buildsCompute['value'] * -1), ]; } if (!empty($executions['value'])) { $metrics[] = [ - 'key' => 'executions', + 'key' => METRIC_EXECUTIONS, 'value' => ($executionsCompute['value'] * -1), ]; } if (!empty($executionsCompute['value'])) { $metrics[] = [ - 'key' => 'executions.compute', + 'key' => METRIC_EXECUTIONS_COMPUTE, 'value' => ($executionsCompute['value'] * -1), ]; } @@ -234,7 +234,7 @@ $server $dbForProject->setNamespace('_' . $projectInternalId); - foreach ($project['keys'] as $key => $value) { + foreach ($project['keys'] ?? [] as $key => $value) { if ($value == 0) { continue; } @@ -271,10 +271,12 @@ $server } } } - $dbForProject->createDocument('statsLogger', new Document([ - 'time' => DateTime::now(), - 'metrics' => $project['keys'], - ])); + if (!empty($project['keys'])) { + $dbForProject->createDocument('statsLogger', new Document([ + 'time' => DateTime::now(), + 'metrics' => $project['keys'], + ])); + } } catch (\Exception $e) { console::error("[logger] " . " {DateTime::now()} " . " {$projectInternalId} " . " {$e->getMessage()}"); } finally { diff --git a/composer.lock b/composer.lock index 3af341a1cc..2e7ffda63a 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "36ef20efb91c04f1985f7dbaf52450f5", + "content-hash": "290f8f03716871b264f9dd88b0ef60a9", "packages": [ { "name": "adhocore/jwt", @@ -2246,16 +2246,16 @@ }, { "name": "utopia-php/storage", - "version": "0.13.0", + "version": "0.13.2", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "f34c010e4f8394a6b4aff70b6de55041d9a145d3" + "reference": "ad1c00f24ca56e73888acc2af3deee4919b1194b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/f34c010e4f8394a6b4aff70b6de55041d9a145d3", - "reference": "f34c010e4f8394a6b4aff70b6de55041d9a145d3", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/ad1c00f24ca56e73888acc2af3deee4919b1194b", + "reference": "ad1c00f24ca56e73888acc2af3deee4919b1194b", "shasum": "" }, "require": { @@ -2295,9 +2295,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.13.0" + "source": "https://github.com/utopia-php/storage/tree/0.13.2" }, - "time": "2022-11-17T15:10:18+00:00" + "time": "2022-12-20T11:11:35+00:00" }, { "name": "utopia-php/swoole", @@ -3162,20 +3162,20 @@ }, { "name": "phpspec/prophecy", - "version": "v1.16.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be8cac52a0827776ff9ccda8c381ac5b71aeb359" + "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be8cac52a0827776ff9ccda8c381ac5b71aeb359", - "reference": "be8cac52a0827776ff9ccda8c381ac5b71aeb359", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/15873c65b207b07765dbc3c95d20fdf4a320cbe2", + "reference": "15873c65b207b07765dbc3c95d20fdf4a320cbe2", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2", + "doctrine/instantiator": "^1.2 || ^2.0", "php": "^7.2 || 8.0.* || 8.1.* || 8.2.*", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", @@ -3183,6 +3183,7 @@ }, "require-dev": { "phpspec/phpspec": "^6.0 || ^7.0", + "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", @@ -3223,9 +3224,9 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.16.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.17.0" }, - "time": "2022-11-29T15:06:56+00:00" + "time": "2023-02-02T15:41:36+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4014,16 +4015,16 @@ }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -4065,7 +4066,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -4073,7 +4074,7 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", @@ -4387,16 +4388,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -4435,10 +4436,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -4446,7 +4447,7 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", @@ -4505,16 +4506,16 @@ }, { "name": "sebastian/type", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -4549,7 +4550,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -4557,7 +4558,7 @@ "type": "github" } ], - "time": "2022-09-12T14:47:03+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", diff --git a/docker-compose.yml b/docker-compose.yml index d1025c822b..05eb75f193 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -554,6 +554,8 @@ services: environment: - _APP_ENV - _APP_WORKER_PER_CORE + - _APP_CONNECTIONS_MAX + - _APP_POOL_CLIENTS - _APP_DOMAIN - _APP_DOMAIN_TARGET - _APP_OPENSSL_KEY_V1 @@ -653,7 +655,7 @@ services: image: openruntimes/executor:0.2.0 networks: - appwrite - - openruntimes-runtimes + - runtimes volumes: - /var/run/docker.sock:/var/run/docker.sock - appwrite-builds:/storage/builds:rw @@ -809,8 +811,8 @@ networks: name: gateway appwrite: name: appwrite - openruntimes-runtimes: - name: openruntimes-runtimes + runtimes: + name: runtimes volumes: appwrite-mariadb: diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index b397e9ea77..63b6a254f0 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -9,10 +9,9 @@ use Appwrite\Auth\Hash\Phpass; use Appwrite\Auth\Hash\Scrypt; use Appwrite\Auth\Hash\Scryptmodified; use Appwrite\Auth\Hash\Sha; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\DateTime; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Roles; diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index dddbc59e7f..435972d0f5 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -6,8 +6,8 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Appwrite\Messaging\Adapter; use Utopia\App; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; class Realtime extends Adapter { diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index a0c237fd5f..251e72fe66 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -10,7 +10,7 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Exception; use Utopia\App; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\Authorization; Runtime::enableCoroutine(SWOOLE_HOOK_ALL); diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index f549c7fbdf..ac948d01d2 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -11,9 +11,9 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class V15 extends Migration { diff --git a/src/Appwrite/Platform/Tasks/PatchCreateMissingSchedules.php b/src/Appwrite/Platform/Tasks/PatchCreateMissingSchedules.php index 32b9886347..74ef644498 100644 --- a/src/Appwrite/Platform/Tasks/PatchCreateMissingSchedules.php +++ b/src/Appwrite/Platform/Tasks/PatchCreateMissingSchedules.php @@ -8,7 +8,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Database; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\Authorization; class PatchCreateMissingSchedules extends Action diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index fb7208c569..1ad5dfd895 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -5,8 +5,8 @@ namespace Appwrite\Specification\Format; use Appwrite\Specification\Format; use Appwrite\Template\Template; use Appwrite\Utopia\Response\Model; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Validator; class OpenAPI3 extends Format diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 6eb27a11aa..7d056bea60 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -5,8 +5,8 @@ namespace Appwrite\Specification\Format; use Appwrite\Specification\Format; use Appwrite\Template\Template; use Appwrite\Utopia\Response\Model; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Validator; class Swagger2 extends Format diff --git a/src/Appwrite/Utopia/Request/Filters/V15.php b/src/Appwrite/Utopia/Request/Filters/V15.php index 65b09e1f24..50e5ec0db7 100644 --- a/src/Appwrite/Utopia/Request/Filters/V15.php +++ b/src/Appwrite/Utopia/Request/Filters/V15.php @@ -4,9 +4,9 @@ namespace Appwrite\Utopia\Request\Filters; use Appwrite\Utopia\Request\Filter; use Utopia\Database\Database; -use Utopia\Database\Permission; +use Utopia\Database\Helpers\Permission; use Utopia\Database\Query; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; class V15 extends Filter { diff --git a/src/Appwrite/Utopia/Response/Filters/V15.php b/src/Appwrite/Utopia/Response/Filters/V15.php index a74f0f32ad..232feec201 100644 --- a/src/Appwrite/Utopia/Response/Filters/V15.php +++ b/src/Appwrite/Utopia/Response/Filters/V15.php @@ -5,8 +5,8 @@ namespace Appwrite\Utopia\Response\Filters; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Filter; use Utopia\Database\Database; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class V15 extends Filter { diff --git a/src/Appwrite/Utopia/Response/Model/Execution.php b/src/Appwrite/Utopia/Response/Model/Execution.php index 13011a24b7..8672a91598 100644 --- a/src/Appwrite/Utopia/Response/Model/Execution.php +++ b/src/Appwrite/Utopia/Response/Model/Execution.php @@ -4,7 +4,7 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Role; class Execution extends Model { diff --git a/src/Appwrite/Utopia/Response/Model/UsageBuckets.php b/src/Appwrite/Utopia/Response/Model/UsageBuckets.php index 40d5c6c4a6..83b8744760 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageBuckets.php +++ b/src/Appwrite/Utopia/Response/Model/UsageBuckets.php @@ -16,7 +16,7 @@ class UsageBuckets extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('filesCount', [ + ->addRule('filesTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of files in this bucket.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageCollection.php b/src/Appwrite/Utopia/Response/Model/UsageCollection.php index 1f60076d02..5abcf46b7d 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageCollection.php +++ b/src/Appwrite/Utopia/Response/Model/UsageCollection.php @@ -16,7 +16,7 @@ class UsageCollection extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('documentsCount', [ + ->addRule('documentsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of documents.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php index 7f3aab29aa..58d49c506e 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php @@ -16,14 +16,14 @@ class UsageDatabase extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('collectionsCount', [ + ->addRule('collectionsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of collections.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('documentsCount', [ + ->addRule('documentsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of documents.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php index a37639c28e..a6008ca9e6 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php @@ -16,21 +16,21 @@ class UsageDatabases extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('databasesCount', [ + ->addRule('databasesTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of documents.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('collectionsCount', [ + ->addRule('collectionsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of collections.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('documentsCount', [ + ->addRule('documentsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of documents.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageProject.php b/src/Appwrite/Utopia/Response/Model/UsageProject.php index e37bc5928d..641613809a 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageProject.php +++ b/src/Appwrite/Utopia/Response/Model/UsageProject.php @@ -16,7 +16,7 @@ class UsageProject extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('requests', [ + ->addRule('requestsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for number of requests.', 'default' => [], @@ -30,42 +30,42 @@ class UsageProject extends Model 'example' => [], 'array' => true ]) - ->addRule('executions', [ + ->addRule('executionsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for function executions.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('documents', [ + ->addRule('documentsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for number of documents.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('databases', [ + ->addRule('databasesTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for number of databases.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('users', [ + ->addRule('usersTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for number of users.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('storage', [ + ->addRule('filesStorage', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for the occupied storage size (in bytes).', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('buckets', [ + ->addRule('bucketsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for number of buckets.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageStorage.php b/src/Appwrite/Utopia/Response/Model/UsageStorage.php index fe2f605677..88d0beca01 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageStorage.php +++ b/src/Appwrite/Utopia/Response/Model/UsageStorage.php @@ -16,14 +16,14 @@ class UsageStorage extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('bucketsCount', [ + ->addRule('bucketsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of buckets.', 'default' => [], 'example' => [], 'array' => true ]) - ->addRule('filesCount', [ + ->addRule('filesTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of files.', 'default' => [], diff --git a/src/Appwrite/Utopia/Response/Model/UsageUsers.php b/src/Appwrite/Utopia/Response/Model/UsageUsers.php index 335cb351a5..c0cc4baa54 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageUsers.php +++ b/src/Appwrite/Utopia/Response/Model/UsageUsers.php @@ -16,7 +16,7 @@ class UsageUsers extends Model 'default' => '', 'example' => '30d', ]) - ->addRule('usersCount', [ + ->addRule('usersTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for total number of users.', 'default' => [], @@ -24,7 +24,7 @@ class UsageUsers extends Model 'array' => true ]) - ->addRule('sessionsCount', [ + ->addRule('sessionsTotal', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated stats for sessions created.', 'default' => [], diff --git a/tests/e2e/General/AbuseTest.php b/tests/e2e/General/AbuseTest.php index 90a4b33800..f5a2829974 100644 --- a/tests/e2e/General/AbuseTest.php +++ b/tests/e2e/General/AbuseTest.php @@ -8,9 +8,9 @@ use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideNone; use Utopia\App; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class AbuseTest extends Scope { diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 6fffb037ab..f171e1e77a 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -9,8 +9,9 @@ use Tests\E2E\Scopes\SideServer; use CURLFile; use Tests\E2E\Services\Functions\FunctionsBase; use Utopia\Database\DateTime; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; +use Utopia\Database\Validator\DatetimeValidator; class UsageTest extends Scope { @@ -45,8 +46,8 @@ class UsageTest extends Scope $headers['x-appwrite-key'] = $project['apiKey']; $headers['content-type'] = 'application/json'; - $usersCount = 0; - $requestsCount = 0; + $usersTotal = 0; + $requestsTotal = 0; for ($i = 0; $i < self::CREATE; $i++) { $email = uniqid() . 'user@usage.test'; $password = 'password'; @@ -65,23 +66,23 @@ class UsageTest extends Scope $this->assertEquals($email, $res['body']['email']); $this->assertNotEmpty($res['body']['$id']); - $usersCount++; - $requestsCount++; + $usersTotal++; + $requestsTotal++; if ($i < (self::CREATE / 2)) { $userId = $res['body']['$id']; $res = $this->client->call(Client::METHOD_DELETE, '/users/' . $userId, $headers); $this->assertEmpty($res['body']); - $requestsCount++; - $usersCount--; + $requestsTotal++; + $usersTotal--; } } return [ 'projectId' => $projectId, 'headers' => $headers, - 'usersCount' => $usersCount, - 'requestsCount' => $requestsCount + 'usersTotal' => $usersTotal, + 'requestsTotal' => $requestsTotal ]; } @@ -94,8 +95,8 @@ class UsageTest extends Scope $projectId = $data['projectId']; $headers = $data['headers']; - $usersCount = $data['usersCount']; - $requestsCount = $data['requestsCount']; + $usersTotal = $data['usersTotal']; + $requestsTotal = $data['requestsTotal']; $consoleHeaders = [ 'origin' => 'http://localhost', @@ -114,12 +115,12 @@ class UsageTest extends Scope $this->assertEquals('24h', $res['range']); $this->assertEquals(9, count($res)); - $this->assertEquals(24, count($res['requests'])); - $this->assertEquals(24, count($res['users'])); - $this->assertEquals($usersCount, $res['users'][array_key_last($res['users'])]['value']); - $this->validateDates($res['users']); - $this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']); - $this->validateDates($res['requests']); + $this->assertEquals(24, count($res['requestsTotal'])); + $this->assertEquals(24, count($res['usersTotal'])); + $this->assertEquals($usersTotal, $res['usersTotal'][array_key_last($res['usersTotal'])]['value']); + $this->validateDates($res['usersTotal']); + $this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']); + $this->validateDates($res['requestsTotal']); $res = $this->client->call( Client::METHOD_GET, @@ -129,15 +130,15 @@ class UsageTest extends Scope $res = $res['body']; $this->assertEquals('90d', $res['range']); - $this->assertEquals(90, count($res['usersCount'])); - $this->assertEquals(90, count($res['sessionsCount'])); - $this->assertEquals((self::CREATE / 2), $res['usersCount'][array_key_last($res['usersCount'])]['value']); + $this->assertEquals(90, count($res['usersTotal'])); + $this->assertEquals(90, count($res['sessionsTotal'])); + $this->assertEquals((self::CREATE / 2), $res['usersTotal'][array_key_last($res['usersTotal'])]['value']); return [ 'projectId' => $projectId, 'headers' => $headers, 'consoleHeaders' => $consoleHeaders, - 'requestsCount' => $requestsCount, + 'requestsTotal' => $requestsTotal, ]; } @@ -145,10 +146,10 @@ class UsageTest extends Scope public function testPrepareStorageStats(array $data): array { $headers = $data['headers']; - $bucketsCount = 0; - $requestsCount = $data['requestsCount']; + $bucketsTotal = 0; + $requestsTotal = $data['requestsTotal']; $storageTotal = 0; - $filesCount = 0; + $filesTotal = 0; for ($i = 0; $i < self::CREATE; $i++) { @@ -177,8 +178,8 @@ class UsageTest extends Scope $this->assertEquals($name, $res['body']['name']); $this->assertNotEmpty($res['body']['$id']); $bucketId = $res['body']['$id']; - $bucketsCount++; - $requestsCount++; + $bucketsTotal++; + $requestsTotal++; if ($i < (self::CREATE / 2)) { $res = $this->client->call( @@ -187,8 +188,8 @@ class UsageTest extends Scope $headers ); $this->assertEmpty($res['body']); - $requestsCount++; - $bucketsCount--; + $requestsTotal++; + $bucketsTotal--; } } @@ -229,8 +230,8 @@ class UsageTest extends Scope $fileSize = $res['body']['sizeOriginal']; $storageTotal += $fileSize; - $filesCount++; - $requestsCount++; + $filesTotal++; + $requestsTotal++; $fileId = $res['body']['$id']; if ($i < (self::CREATE / 2)) { @@ -240,18 +241,18 @@ class UsageTest extends Scope $headers ); $this->assertEmpty($res['body']); - $requestsCount++; - $filesCount--; + $requestsTotal++; + $filesTotal--; $storageTotal -= $fileSize; } } return array_merge($data, [ 'bucketId' => $bucketId, - 'bucketsCount' => $bucketsCount, - 'requestsCount' => $requestsCount, + 'bucketsTotal' => $bucketsTotal, + 'requestsTotal' => $requestsTotal, 'storageTotal' => $storageTotal, - 'filesCount' => $filesCount, + 'filesTotal' => $filesTotal, ]); } @@ -261,10 +262,10 @@ class UsageTest extends Scope public function testStorageStats(array $data): array { $bucketId = $data['bucketId']; - $bucketsCount = $data['bucketsCount']; - $requestsCount = $data['requestsCount']; + $bucketsTotal = $data['bucketsTotal']; + $requestsTotal = $data['requestsTotal']; $storageTotal = $data['storageTotal']; - $filesCount = $data['filesCount']; + $filesTotal = $data['filesTotal']; sleep(self::WAIT); @@ -279,12 +280,12 @@ class UsageTest extends Scope $res = $res['body']; $this->assertEquals(9, count($res)); - $this->assertEquals(30, count($res['requests'])); - $this->assertEquals(30, count($res['storage'])); - $this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']); - $this->validateDates($res['requests']); - $this->assertEquals($storageTotal, $res['storage'][array_key_last($res['storage'])]['value']); - $this->validateDates($res['storage']); + $this->assertEquals(30, count($res['requestsTotal'])); + $this->assertEquals(30, count($res['filesStorage'])); + $this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']); + $this->validateDates($res['requestsTotal']); + $this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']); + $this->validateDates($res['filesStorage']); $res = $this->client->call( Client::METHOD_GET, @@ -296,12 +297,12 @@ class UsageTest extends Scope ); $res = $res['body']; - $this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']); + $this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesTotal'])]['value']); $this->validateDates($res['filesStorage']); - $this->assertEquals($bucketsCount, $res['bucketsCount'][array_key_last($res['bucketsCount'])]['value']); - $this->validateDates($res['bucketsCount']); - $this->assertEquals($filesCount, $res['filesCount'][array_key_last($res['filesCount'])]['value']); - $this->validateDates($res['filesCount']); + $this->assertEquals($bucketsTotal, $res['bucketsTotal'][array_key_last($res['bucketsTotal'])]['value']); + $this->validateDates($res['bucketsTotal']); + $this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']); + $this->validateDates($res['filesTotal']); $res = $this->client->call( Client::METHOD_GET, @@ -314,9 +315,9 @@ class UsageTest extends Scope $res = $res['body']; $this->assertEquals($storageTotal, $res['filesStorage'][array_key_last($res['filesStorage'])]['value']); - $this->assertEquals($filesCount, $res['filesCount'][array_key_last($res['filesCount'])]['value']); + $this->assertEquals($filesTotal, $res['filesTotal'][array_key_last($res['filesTotal'])]['value']); - $data['requestsCount'] = $requestsCount; + $data['requestsTotal'] = $requestsTotal; return $data; } @@ -326,10 +327,10 @@ class UsageTest extends Scope { $headers = $data['headers']; - $requestsCount = $data['requestsCount']; - $databasesCount = 0; - $collectionsCount = 0; - $documentsCount = 0; + $requestsTotal = $data['requestsTotal']; + $databasesTotal = 0; + $collectionsTotal = 0; + $documentsTotal = 0; for ($i = 0; $i < self::CREATE; $i++) { $name = uniqid() . ' database'; @@ -348,8 +349,8 @@ class UsageTest extends Scope $this->assertNotEmpty($res['body']['$id']); $databaseId = $res['body']['$id']; - $requestsCount++; - $databasesCount++; + $requestsTotal++; + $databasesTotal++; if ($i < (self::CREATE / 2)) { $res = $this->client->call( @@ -359,8 +360,8 @@ class UsageTest extends Scope ); $this->assertEmpty($res['body']); - $databasesCount--; - $requestsCount++; + $databasesTotal--; + $requestsTotal++; } } @@ -387,8 +388,8 @@ class UsageTest extends Scope $this->assertNotEmpty($res['body']['$id']); $collectionId = $res['body']['$id']; - $requestsCount++; - $collectionsCount++; + $requestsTotal++; + $collectionsTotal++; if ($i < (self::CREATE / 2)) { $res = $this->client->call( @@ -397,8 +398,8 @@ class UsageTest extends Scope $headers ); $this->assertEmpty($res['body']); - $collectionsCount--; - $requestsCount++; + $collectionsTotal--; + $requestsTotal++; } } @@ -414,7 +415,7 @@ class UsageTest extends Scope ); $this->assertEquals('name', $res['body']['key']); - $requestsCount++; + $requestsTotal++; sleep(self::WAIT); @@ -433,8 +434,8 @@ class UsageTest extends Scope $this->assertNotEmpty($res['body']['$id']); $documentId = $res['body']['$id']; - $requestsCount++; - $documentsCount++; + $requestsTotal++; + $documentsTotal++; if ($i < (self::CREATE / 2)) { $res = $this->client->call( @@ -443,18 +444,18 @@ class UsageTest extends Scope $headers ); $this->assertEmpty($res['body']); - $documentsCount--; - $requestsCount++; + $documentsTotal--; + $requestsTotal++; } } return array_merge($data, [ 'databaseId' => $databaseId, 'collectionId' => $collectionId, - 'requestsCount' => $requestsCount, - 'databasesCount' => $databasesCount, - 'collectionsCount' => $collectionsCount, - 'documentsCount' => $documentsCount, + 'requestsTotal' => $requestsTotal, + 'databasesTotal' => $databasesTotal, + 'collectionsTotal' => $collectionsTotal, + 'documentsTotal' => $documentsTotal, ]); } @@ -466,10 +467,10 @@ class UsageTest extends Scope $projectId = $data['projectId']; $databaseId = $data['databaseId']; $collectionId = $data['collectionId']; - $requestsCount = $data['requestsCount']; - $databasesCount = $data['databasesCount']; - $collectionsCount = $data['collectionsCount']; - $documentsCount = $data['documentsCount']; + $requestsTotal = $data['requestsTotal']; + $databasesTotal = $data['databasesTotal']; + $collectionsTotal = $data['collectionsTotal']; + $documentsTotal = $data['documentsTotal']; sleep(self::WAIT); @@ -481,14 +482,14 @@ class UsageTest extends Scope $res = $res['body']; $this->assertEquals(9, count($res)); - $this->assertEquals(30, count($res['requests'])); - $this->assertEquals(30, count($res['storage'])); - $this->assertEquals($requestsCount, $res['requests'][array_key_last($res['requests'])]['value']); - $this->validateDates($res['requests']); - $this->assertEquals($databasesCount, $res['databases'][array_key_last($res['databases'])]['value']); - $this->validateDates($res['databases']); - $this->assertEquals($documentsCount, $res['documents'][array_key_last($res['documents'])]['value']); - $this->validateDates($res['documents']); + $this->assertEquals(30, count($res['requestsTotal'])); + $this->assertEquals(30, count($res['filesStorage'])); + $this->assertEquals($requestsTotal, $res['requestsTotal'][array_key_last($res['requestsTotal'])]['value']); + $this->validateDates($res['requestsTotal']); + $this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']); + $this->validateDates($res['databasesTotal']); + $this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']); + $this->validateDates($res['documentsTotal']); $res = $this->client->call( Client::METHOD_GET, @@ -497,12 +498,12 @@ class UsageTest extends Scope ); $res = $res['body']; - $this->assertEquals($databasesCount, $res['databasesCount'][array_key_last($res['databasesCount'])]['value']); - $this->validateDates($res['databasesCount']); - $this->assertEquals($collectionsCount, $res['collectionsCount'][array_key_last($res['collectionsCount'])]['value']); - $this->validateDates($res['collectionsCount']); - $this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']); - $this->validateDates($res['documentsCount']); + $this->assertEquals($databasesTotal, $res['databasesTotal'][array_key_last($res['databasesTotal'])]['value']); + $this->validateDates($res['databasesTotal']); + $this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']); + $this->validateDates($res['collectionsTotal']); + $this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']); + $this->validateDates($res['documentsTotal']); $res = $this->client->call( Client::METHOD_GET, @@ -511,19 +512,19 @@ class UsageTest extends Scope ); $res = $res['body']; - $this->assertEquals($collectionsCount, $res['collectionsCount'][array_key_last($res['collectionsCount'])]['value']); - $this->validateDates($res['collectionsCount']); + $this->assertEquals($collectionsTotal, $res['collectionsTotal'][array_key_last($res['collectionsTotal'])]['value']); + $this->validateDates($res['collectionsTotal']); - $this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']); - $this->validateDates($res['documentsCount']); + $this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']); + $this->validateDates($res['documentsTotal']); $res = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/usage?range=30d', $data['consoleHeaders']); $res = $res['body']; - $this->assertEquals($documentsCount, $res['documentsCount'][array_key_last($res['documentsCount'])]['value']); - $this->validateDates($res['documentsCount']); + $this->assertEquals($documentsTotal, $res['documentsTotal'][array_key_last($res['documentsTotal'])]['value']); + $this->validateDates($res['documentsTotal']); - $data['requestsCount'] = $requestsCount; + $data['requestsTotal'] = $requestsTotal; return $data; } @@ -582,7 +583,7 @@ class UsageTest extends Scope $this->assertEquals(202, $deployment['headers']['status-code']); $this->assertNotEmpty($deployment['body']['$id']); - $this->assertEquals(true, DateTime::isValid($deployment['body']['$createdAt'])); + $this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt'])); $this->assertEquals('index.php', $deployment['body']['entrypoint']); // Wait for deployment to build. @@ -596,8 +597,10 @@ class UsageTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(true, DateTime::isValid($response['body']['$createdAt'])); - $this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt'])); + + + $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$createdAt'])); + $this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['$updatedAt'])); $this->assertEquals($deploymentId, $response['body']['deployment']); $execution = $this->client->call( @@ -695,20 +698,19 @@ class UsageTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(8, count($response['body'])); $this->assertEquals('30d', $response['body']['range']); - $this->assertIsArray($response['body']['deployments']); + $this->assertIsArray($response['body']['deploymentsTotal']); $this->assertIsArray($response['body']['deploymentsStorage']); - $this->assertIsArray($response['body']['builds']); - $this->assertIsArray($response['body']['buildsCompute']); - $this->assertIsArray($response['body']['executions']); - $this->assertIsArray($response['body']['executionsCompute']); + $this->assertIsArray($response['body']['buildsTotal']); + $this->assertIsArray($response['body']['buildsTime']); + $this->assertIsArray($response['body']['executionsTotal']); + $this->assertIsArray($response['body']['executionsTime']); $response = $response['body']; - $this->assertEquals($executions, $response['executions'][array_key_last($response['executions'])]['value']); - $this->validateDates($response['executions']); - - $this->assertEquals($executionTime, $response['executionsCompute'][array_key_last($response['executionsCompute'])]['value']); - $this->validateDates($response['executionsCompute']); + $this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']); + $this->validateDates($response['executionsTotal']); + $this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']); + $this->validateDates($response['executionsTime']); $response = $this->client->call( Client::METHOD_GET, @@ -719,28 +721,28 @@ class UsageTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(9, count($response['body'])); $this->assertEquals($response['body']['range'], '30d'); - $this->assertIsArray($response['body']['functions']); - $this->assertIsArray($response['body']['deployments']); + $this->assertIsArray($response['body']['functionsTotal']); + $this->assertIsArray($response['body']['deploymentsTotal']); $this->assertIsArray($response['body']['deploymentsStorage']); - $this->assertIsArray($response['body']['builds']); - $this->assertIsArray($response['body']['buildsCompute']); - $this->assertIsArray($response['body']['executions']); - $this->assertIsArray($response['body']['executionsCompute']); + $this->assertIsArray($response['body']['buildsTotal']); + $this->assertIsArray($response['body']['buildsTime']); + $this->assertIsArray($response['body']['executionsTotal']); + $this->assertIsArray($response['body']['executionsTime']); $response = $response['body']; - $this->assertEquals($executions, $response['executions'][array_key_last($response['executions'])]['value']); - $this->validateDates($response['executions']); - $this->assertEquals($executionTime, $response['executionsCompute'][array_key_last($response['executionsCompute'])]['value']); - $this->validateDates($response['executionsCompute']); - $this->assertGreaterThan(0, $response['buildsCompute'][array_key_last($response['buildsCompute'])]['value']); - $this->validateDates($response['buildsCompute']); + $this->assertEquals($executions, $response['executionsTotal'][array_key_last($response['executionsTotal'])]['value']); + $this->validateDates($response['executionsTotal']); + $this->assertEquals($executionTime, $response['executionsTime'][array_key_last($response['executionsTime'])]['value']); + $this->validateDates($response['executionsTime']); + $this->assertGreaterThan(0, $response['buildsTime'][array_key_last($response['buildsTime'])]['value']); + $this->validateDates($response['buildsTime']); } public function tearDown(): void { - $this->usersCount = 0; - $this->requestsCount = 0; + $this->usersTotal = 0; + $this->requestsTotal = 0; $projectId = ''; $headers = []; } diff --git a/tests/e2e/Scopes/ProjectConsole.php b/tests/e2e/Scopes/ProjectConsole.php index bc8ce4c0cf..dcc4aa7c33 100644 --- a/tests/e2e/Scopes/ProjectConsole.php +++ b/tests/e2e/Scopes/ProjectConsole.php @@ -2,7 +2,7 @@ namespace Tests\E2E\Scopes; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; trait ProjectConsole { diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index f2e4e84685..4d780d04c6 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -3,7 +3,7 @@ namespace Tests\E2E\Scopes; use Tests\E2E\Client; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; trait ProjectCustom { diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index 2a9f205272..939de516b6 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -5,7 +5,7 @@ namespace Tests\E2E\Scopes; use Appwrite\Tests\Retryable; use Tests\E2E\Client; use PHPUnit\Framework\TestCase; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; abstract class Scope extends TestCase { diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index e8bf146316..880323e728 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Account; use Appwrite\Tests\Retry; use Tests\E2E\Client; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\DateTime; trait AccountBase diff --git a/tests/e2e/Services/Account/AccountConsoleClientTest.php b/tests/e2e/Services/Account/AccountConsoleClientTest.php index 4258004ecf..c8ef193f28 100644 --- a/tests/e2e/Services/Account/AccountConsoleClientTest.php +++ b/tests/e2e/Services/Account/AccountConsoleClientTest.php @@ -6,7 +6,7 @@ use Appwrite\Extend\Exception; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectConsole; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\DateTime; use Tests\E2E\Client; diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index ea24d06bdb..3c246ac52e 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -9,7 +9,7 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use function sleep; diff --git a/tests/e2e/Services/Account/AccountCustomServerTest.php b/tests/e2e/Services/Account/AccountCustomServerTest.php index 85d140c829..143277608d 100644 --- a/tests/e2e/Services/Account/AccountCustomServerTest.php +++ b/tests/e2e/Services/Account/AccountCustomServerTest.php @@ -6,7 +6,7 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class AccountCustomServerTest extends Scope { diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index a183325039..c81afcdd4e 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -3,11 +3,10 @@ namespace Tests\E2E\Services\Databases; use Tests\E2E\Client; -use Utopia\Database\Database; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; use Utopia\Database\DateTime; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; trait DatabasesBase { diff --git a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php index cdbeda00b6..0e0ef9fe8c 100644 --- a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Client; use Tests\E2E\Scopes\SideConsole; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class DatabasesConsoleClientTest extends Scope { diff --git a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php index 9f86bb66c0..748070161d 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class DatabasesCustomClientTest extends Scope { diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index bd4e8aa77b..19a56941eb 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -6,10 +6,9 @@ use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; use Tests\E2E\Client; -use Utopia\Database\Database; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class DatabasesCustomServerTest extends Scope { diff --git a/tests/e2e/Services/Databases/DatabasesPermissionsGuestTest.php b/tests/e2e/Services/Databases/DatabasesPermissionsGuestTest.php index 1c15a363a8..b1d197f010 100644 --- a/tests/e2e/Services/Databases/DatabasesPermissionsGuestTest.php +++ b/tests/e2e/Services/Databases/DatabasesPermissionsGuestTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; class DatabasesPermissionsGuestTest extends Scope diff --git a/tests/e2e/Services/Databases/DatabasesPermissionsMemberTest.php b/tests/e2e/Services/Databases/DatabasesPermissionsMemberTest.php index 59091956b0..860fb7fb12 100644 --- a/tests/e2e/Services/Databases/DatabasesPermissionsMemberTest.php +++ b/tests/e2e/Services/Databases/DatabasesPermissionsMemberTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class DatabasesPermissionsMemberTest extends Scope { diff --git a/tests/e2e/Services/Databases/DatabasesPermissionsTeamTest.php b/tests/e2e/Services/Databases/DatabasesPermissionsTeamTest.php index 07275c7524..8377b9c803 100644 --- a/tests/e2e/Services/Databases/DatabasesPermissionsTeamTest.php +++ b/tests/e2e/Services/Databases/DatabasesPermissionsTeamTest.php @@ -6,9 +6,9 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class DatabasesPermissionsTeamTest extends Scope { diff --git a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php index 9cba3719cb..b473b082ca 100644 --- a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php @@ -6,8 +6,8 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Client; use Tests\E2E\Scopes\SideConsole; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; class FunctionsConsoleClientTest extends Scope { diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 56b72e4468..cd669a6b5e 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -7,10 +7,8 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -use Utopia\CLI\Console; -use Utopia\Database\Database; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; class FunctionsCustomClientTest extends Scope { diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e97c1412b6..8635c4dd1d 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -8,10 +8,8 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class FunctionsCustomServerTest extends Scope { diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 789020bf42..4f8b8bef77 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -6,11 +6,9 @@ use Appwrite\Auth\Auth; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectConsole; use Tests\E2E\Scopes\SideClient; -use Tests\E2E\Services\Projects\ProjectsBase; use Tests\E2E\Client; -use Utopia\Database\Database; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class ProjectsConsoleClientTest extends Scope { diff --git a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php index 500b3d48be..cd2fb6f13b 100644 --- a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php @@ -8,9 +8,9 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideConsole; use Tests\E2E\Services\Functions\FunctionsBase; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class RealtimeConsoleClientTest extends Scope { diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index f4b959274a..d4c8f53426 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -8,9 +8,9 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; use Utopia\CLI\Console; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use WebSocket\ConnectionException; class RealtimeCustomClientTest extends Scope diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index b4c28b0fa2..359989e114 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -5,9 +5,9 @@ namespace Tests\E2E\Services\Storage; use CURLFile; use Tests\E2E\Client; use Utopia\Database\DateTime; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; trait StorageBase { diff --git a/tests/e2e/Services/Storage/StorageConsoleClientTest.php b/tests/e2e/Services/Storage/StorageConsoleClientTest.php index e24ac524a6..521f022cb7 100644 --- a/tests/e2e/Services/Storage/StorageConsoleClientTest.php +++ b/tests/e2e/Services/Storage/StorageConsoleClientTest.php @@ -6,7 +6,7 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideConsole; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class StorageConsoleClientTest extends Scope { @@ -97,7 +97,7 @@ class StorageConsoleClientTest extends Scope $this->assertEquals($response['headers']['status-code'], 200); $this->assertEquals(count($response['body']), 3); $this->assertEquals($response['body']['range'], '24h'); - $this->assertIsArray($response['body']['filesCount']); + $this->assertIsArray($response['body']['filesTotal']); $this->assertIsArray($response['body']['filesStorage']); } } diff --git a/tests/e2e/Services/Storage/StorageCustomClientTest.php b/tests/e2e/Services/Storage/StorageCustomClientTest.php index fdb158ae5b..8af9f7b3eb 100644 --- a/tests/e2e/Services/Storage/StorageCustomClientTest.php +++ b/tests/e2e/Services/Storage/StorageCustomClientTest.php @@ -13,10 +13,9 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; use Utopia\Database\DateTime; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; -use Utopia\Database\Validator\Authorization; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class StorageCustomClientTest extends Scope { diff --git a/tests/e2e/Services/Storage/StorageCustomServerTest.php b/tests/e2e/Services/Storage/StorageCustomServerTest.php index ac03f2b83c..2395e1d8fc 100644 --- a/tests/e2e/Services/Storage/StorageCustomServerTest.php +++ b/tests/e2e/Services/Storage/StorageCustomServerTest.php @@ -7,7 +7,7 @@ use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class StorageCustomServerTest extends Scope { diff --git a/tests/e2e/Services/Teams/TeamsBase.php b/tests/e2e/Services/Teams/TeamsBase.php index 854a041503..7b4e77482b 100644 --- a/tests/e2e/Services/Teams/TeamsBase.php +++ b/tests/e2e/Services/Teams/TeamsBase.php @@ -3,9 +3,8 @@ namespace Tests\E2E\Services\Teams; use Tests\E2E\Client; -use Utopia\Database\Database; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; trait TeamsBase { diff --git a/tests/e2e/Services/Teams/TeamsBaseClient.php b/tests/e2e/Services/Teams/TeamsBaseClient.php index 788626b102..0eb578e325 100644 --- a/tests/e2e/Services/Teams/TeamsBaseClient.php +++ b/tests/e2e/Services/Teams/TeamsBaseClient.php @@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Teams; use Tests\E2E\Client; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; trait TeamsBaseClient { diff --git a/tests/e2e/Services/Teams/TeamsConsoleClientTest.php b/tests/e2e/Services/Teams/TeamsConsoleClientTest.php index 0f32425c92..e86c18a8e2 100644 --- a/tests/e2e/Services/Teams/TeamsConsoleClientTest.php +++ b/tests/e2e/Services/Teams/TeamsConsoleClientTest.php @@ -6,7 +6,7 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectConsole; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class TeamsConsoleClientTest extends Scope { diff --git a/tests/e2e/Services/Users/UsersBase.php b/tests/e2e/Services/Users/UsersBase.php index ac3b116b32..75cce56537 100644 --- a/tests/e2e/Services/Users/UsersBase.php +++ b/tests/e2e/Services/Users/UsersBase.php @@ -4,7 +4,7 @@ namespace Tests\E2E\Services\Users; use Appwrite\Tests\Retry; use Tests\E2E\Client; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; trait UsersBase { diff --git a/tests/e2e/Services/Webhooks/WebhooksBase.php b/tests/e2e/Services/Webhooks/WebhooksBase.php index bb7edfdb46..d3d700a222 100644 --- a/tests/e2e/Services/Webhooks/WebhooksBase.php +++ b/tests/e2e/Services/Webhooks/WebhooksBase.php @@ -6,9 +6,9 @@ use Appwrite\Tests\Retry; use CURLFile; use Tests\E2E\Client; use Utopia\Database\DateTime; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; trait WebhooksBase { diff --git a/tests/e2e/Services/Webhooks/WebhooksCustomClientTest.php b/tests/e2e/Services/Webhooks/WebhooksCustomClientTest.php index 9e26322931..1a49b4b3f0 100644 --- a/tests/e2e/Services/Webhooks/WebhooksCustomClientTest.php +++ b/tests/e2e/Services/Webhooks/WebhooksCustomClientTest.php @@ -8,7 +8,7 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; use Utopia\Database\DateTime; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class WebhooksCustomClientTest extends Scope { diff --git a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php index f2f4b27260..51f5ef2532 100644 --- a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php +++ b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php @@ -9,9 +9,9 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; use Utopia\CLI\Console; use Utopia\Database\DateTime; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class WebhooksCustomServerTest extends Scope { diff --git a/tests/unit/Auth/AuthTest.php b/tests/unit/Auth/AuthTest.php index a4ed5740cb..c3c8e904d1 100644 --- a/tests/unit/Auth/AuthTest.php +++ b/tests/unit/Auth/AuthTest.php @@ -5,11 +5,10 @@ namespace Tests\Unit\Auth; use Appwrite\Auth\Auth; use Utopia\Database\DateTime; use Utopia\Database\Document; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; use PHPUnit\Framework\TestCase; -use Utopia\Database\Database; use Utopia\Database\Validator\Roles; class AuthTest extends TestCase diff --git a/tests/unit/Messaging/MessagingChannelsTest.php b/tests/unit/Messaging/MessagingChannelsTest.php index 392f6d56fe..6fe7dda71f 100644 --- a/tests/unit/Messaging/MessagingChannelsTest.php +++ b/tests/unit/Messaging/MessagingChannelsTest.php @@ -6,8 +6,8 @@ use Appwrite\Auth\Auth; use Utopia\Database\Document; use Appwrite\Messaging\Adapter\Realtime; use PHPUnit\Framework\TestCase; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; class MessagingChannelsTest extends TestCase { diff --git a/tests/unit/Messaging/MessagingGuestTest.php b/tests/unit/Messaging/MessagingGuestTest.php index d8ed58ad40..1aaa1febca 100644 --- a/tests/unit/Messaging/MessagingGuestTest.php +++ b/tests/unit/Messaging/MessagingGuestTest.php @@ -4,8 +4,8 @@ namespace Tests\Unit\Messaging; use Appwrite\Messaging\Adapter\Realtime; use PHPUnit\Framework\TestCase; -use Utopia\Database\ID; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Role; class MessagingGuestTest extends TestCase { diff --git a/tests/unit/Messaging/MessagingTest.php b/tests/unit/Messaging/MessagingTest.php index 0b7baf2631..c2e3971945 100644 --- a/tests/unit/Messaging/MessagingTest.php +++ b/tests/unit/Messaging/MessagingTest.php @@ -5,9 +5,9 @@ namespace Tests\Unit\Messaging; use Utopia\Database\Document; use Appwrite\Messaging\Adapter\Realtime; use PHPUnit\Framework\TestCase; -use Utopia\Database\ID; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; class MessagingTest extends TestCase { diff --git a/tests/unit/Network/Validators/OriginTest.php b/tests/unit/Network/Validators/OriginTest.php index 2392ae4cfa..30d18ecaa9 100644 --- a/tests/unit/Network/Validators/OriginTest.php +++ b/tests/unit/Network/Validators/OriginTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Network\Validators; use Appwrite\Network\Validator\Origin; use PHPUnit\Framework\TestCase; -use Utopia\Database\ID; +use Utopia\Database\Helpers\ID; class OriginTest extends TestCase { diff --git a/tests/unit/Utopia/Response/Filters/V15Test.php b/tests/unit/Utopia/Response/Filters/V15Test.php index ce7870483c..fc38e5320b 100644 --- a/tests/unit/Utopia/Response/Filters/V15Test.php +++ b/tests/unit/Utopia/Response/Filters/V15Test.php @@ -4,10 +4,9 @@ namespace Tests\Unit\Utopia\Response\Filters; use Appwrite\Utopia\Response\Filters\V15; use Appwrite\Utopia\Response; -use Utopia\Database\Permission; -use Utopia\Database\Role; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use PHPUnit\Framework\TestCase; -use stdClass; class V15Test extends TestCase {