mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge pull request #11239 from appwrite/upgrade-utopia-queue
This commit is contained in:
@@ -4,9 +4,9 @@ namespace Appwrite\Certificates;
|
||||
|
||||
use Appwrite\Certificates\Exception\CertificateStatus as CertificateStatusException;
|
||||
use Exception;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Http;
|
||||
use Utopia\Logger\Log;
|
||||
|
||||
class LetsEncrypt implements Adapter
|
||||
@@ -24,7 +24,7 @@ class LetsEncrypt implements Adapter
|
||||
$stdout = '';
|
||||
$stderr = '';
|
||||
|
||||
$staging = (App::isProduction()) ? '' : ' --dry-run';
|
||||
$staging = (Http::isProduction()) ? '' : ' --dry-run';
|
||||
$exit = Console::execute(
|
||||
"certbot certonly -v --webroot --noninteractive --agree-tos{$staging}"
|
||||
. " --email " . $this->email
|
||||
|
||||
@@ -6,8 +6,8 @@ use Appwrite\GraphQL\Exception as GQLException;
|
||||
use Appwrite\Promises\Swoole;
|
||||
use Appwrite\Utopia\Request;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\App;
|
||||
use Utopia\Exception;
|
||||
use Utopia\Http;
|
||||
use Utopia\Route;
|
||||
use Utopia\System\System;
|
||||
|
||||
@@ -16,17 +16,17 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for a given API {@see Route}.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param ?Route $route
|
||||
* @return callable
|
||||
*/
|
||||
public static function api(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
?Route $route,
|
||||
): callable {
|
||||
return static fn ($type, $args, $context, $info) => new Swoole(
|
||||
function (callable $resolve, callable $reject) use ($utopia, $route, $args, $context, $info) {
|
||||
/** @var App $utopia */
|
||||
/** @var Http $utopia */
|
||||
/** @var Response $response */
|
||||
/** @var Request $request */
|
||||
|
||||
@@ -61,14 +61,14 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for a document in a specified database and collection with a specific method type.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param string $methodType
|
||||
* @return callable
|
||||
*/
|
||||
public static function document(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $methodType,
|
||||
@@ -83,14 +83,14 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for getting a document in a specified database and collection.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param callable $url
|
||||
* @return callable
|
||||
*/
|
||||
public static function documentGet(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
callable $url,
|
||||
@@ -112,7 +112,7 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for listing documents in a specified database and collection.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param callable $url
|
||||
@@ -120,7 +120,7 @@ class Resolvers
|
||||
* @return callable
|
||||
*/
|
||||
public static function documentList(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
callable $url,
|
||||
@@ -148,7 +148,7 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for creating a document in a specified database and collection.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param callable $url
|
||||
@@ -156,7 +156,7 @@ class Resolvers
|
||||
* @return callable
|
||||
*/
|
||||
public static function documentCreate(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
callable $url,
|
||||
@@ -180,7 +180,7 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for updating a document in a specified database and collection.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param callable $url
|
||||
@@ -188,7 +188,7 @@ class Resolvers
|
||||
* @return callable
|
||||
*/
|
||||
public static function documentUpdate(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
callable $url,
|
||||
@@ -212,14 +212,14 @@ class Resolvers
|
||||
/**
|
||||
* Create a resolver for deleting a document in a specified database and collection.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param string $databaseId
|
||||
* @param string $collectionId
|
||||
* @param callable $url
|
||||
* @return callable
|
||||
*/
|
||||
public static function documentDelete(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
callable $url,
|
||||
@@ -239,7 +239,7 @@ class Resolvers
|
||||
}
|
||||
|
||||
/**
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param callable $resolve
|
||||
@@ -250,7 +250,7 @@ class Resolvers
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function resolve(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
Request $request,
|
||||
Response $response,
|
||||
callable $resolve,
|
||||
|
||||
@@ -6,8 +6,8 @@ use Appwrite\GraphQL\Types\Mapper;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema as GQLSchema;
|
||||
use Utopia\App;
|
||||
use Utopia\Exception;
|
||||
use Utopia\Http;
|
||||
use Utopia\Route;
|
||||
|
||||
class Schema
|
||||
@@ -17,7 +17,7 @@ class Schema
|
||||
|
||||
/**
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param callable $complexity Function to calculate complexity
|
||||
* @param callable $attributes Function to get attributes
|
||||
* @param array $urls Array of functions to get urls for specific method types
|
||||
@@ -26,13 +26,13 @@ class Schema
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function build(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
callable $complexity,
|
||||
callable $attributes,
|
||||
array $urls,
|
||||
array $params,
|
||||
): GQLSchema {
|
||||
App::setResource('utopia:graphql', static function () use ($utopia) {
|
||||
Http::setResource('utopia:graphql', static function () use ($utopia) {
|
||||
return $utopia;
|
||||
});
|
||||
|
||||
@@ -80,12 +80,12 @@ class Schema
|
||||
* This function iterates all API routes and builds a GraphQL
|
||||
* schema defining types and resolvers for all response models.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param callable $complexity
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function api(App $utopia, callable $complexity): array
|
||||
protected static function api(Http $utopia, callable $complexity): array
|
||||
{
|
||||
Mapper::init($utopia
|
||||
->getResource('response')
|
||||
@@ -143,7 +143,7 @@ class Schema
|
||||
* Iterates all of a projects attributes and builds GraphQL
|
||||
* queries and mutations for the collections they make up.
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param callable $complexity
|
||||
* @param callable $attributes
|
||||
* @param array $urls
|
||||
@@ -152,7 +152,7 @@ class Schema
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected static function collections(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
callable $complexity,
|
||||
callable $attributes,
|
||||
array $urls,
|
||||
|
||||
@@ -9,7 +9,7 @@ use Exception;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use Utopia\App;
|
||||
use Utopia\Http;
|
||||
use Utopia\Route;
|
||||
use Utopia\Validator;
|
||||
use Utopia\Validator\Nullable;
|
||||
@@ -79,7 +79,7 @@ class Mapper
|
||||
}
|
||||
|
||||
public static function route(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
Route $route,
|
||||
Method $method,
|
||||
callable $complexity
|
||||
@@ -245,7 +245,7 @@ class Mapper
|
||||
/**
|
||||
* Map a {@see Route} parameter to a GraphQL Type
|
||||
*
|
||||
* @param App $utopia
|
||||
* @param Http $utopia
|
||||
* @param Validator|callable $validator
|
||||
* @param bool $required
|
||||
* @param array $injections
|
||||
@@ -253,7 +253,7 @@ class Mapper
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function param(
|
||||
App $utopia,
|
||||
Http $utopia,
|
||||
Validator|callable $validator,
|
||||
bool $required,
|
||||
array $injections
|
||||
|
||||
@@ -39,12 +39,21 @@ class Realtime extends MessagingAdapter
|
||||
*/
|
||||
public array $subscriptions = [];
|
||||
|
||||
private PubSubPool $pubSubPool;
|
||||
private ?PubSubPool $pubSubPool = null;
|
||||
|
||||
public function __construct()
|
||||
/**
|
||||
* Get the PubSubPool instance, initializing it lazily if needed.
|
||||
* This allows unit tests to work without requiring the global $register.
|
||||
*
|
||||
* @return PubSubPool
|
||||
*/
|
||||
private function getPubSubPool(): PubSubPool
|
||||
{
|
||||
global $register;
|
||||
$this->pubSubPool = new PubSubPool($register->get('pools')->get('pubsub'));
|
||||
if ($this->pubSubPool === null) {
|
||||
global $register;
|
||||
$this->pubSubPool = new PubSubPool($register->get('pools')->get('pubsub'));
|
||||
}
|
||||
return $this->pubSubPool;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +241,7 @@ class Realtime extends MessagingAdapter
|
||||
$permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged'];
|
||||
$userId = array_key_exists('userId', $options) ? $options['userId'] : null;
|
||||
|
||||
$this->pubSubPool->publish('realtime', json_encode([
|
||||
$this->getPubSubPool()->publish('realtime', json_encode([
|
||||
'project' => $projectId,
|
||||
'roles' => $roles,
|
||||
'permissionsChanged' => $permissionsChanged,
|
||||
|
||||
+2
-2
@@ -11,12 +11,12 @@ use Appwrite\SDK\Deprecated;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Key;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Http;
|
||||
use Utopia\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Validator;
|
||||
use Utopia\Validator\Boolean;
|
||||
@@ -98,7 +98,7 @@ class Create extends Action
|
||||
array $plan,
|
||||
Authorization $authorization
|
||||
): void {
|
||||
if (!App::isDevelopment() && $encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) {
|
||||
if (!Http::isDevelopment() && $encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) {
|
||||
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Encrypted string ' . $this->getSDKGroup() . ' are not available on your plan. Please upgrade to create encrypted string ' . $this->getSDKGroup() . '.');
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\Init;
|
||||
|
||||
use Appwrite\Utopia\Request;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Http;
|
||||
use Utopia\Platform\Action;
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ class Timeout extends Action
|
||||
->callback(function (Request $request, Database $dbForProject) {
|
||||
$timeout = \intval($request->getHeader('x-appwrite-timeout'));
|
||||
|
||||
if (!empty($timeout) && App::isDevelopment()) {
|
||||
if (!empty($timeout) && Http::isDevelopment()) {
|
||||
$dbForProject->setTimeout($timeout);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace Appwrite\Platform\Tasks;
|
||||
use Appwrite\ClamAV\Network;
|
||||
use Appwrite\PubSub\Adapter\Pool as PubSubPool;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Utopia\App;
|
||||
use Utopia\Cache\Adapter\Pool as CachePool;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Adapter\Pool as DatabasePool;
|
||||
use Utopia\Domains\Domain;
|
||||
use Utopia\DSN\DSN;
|
||||
use Utopia\Http;
|
||||
use Utopia\Logger\Logger;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Pools\Group;
|
||||
@@ -281,7 +281,7 @@ class Doctor extends Action
|
||||
}
|
||||
|
||||
try {
|
||||
if (App::isProduction()) {
|
||||
if (Http::isProduction()) {
|
||||
Console::log('');
|
||||
$version = \json_decode(@\file_get_contents(System::getEnv('_APP_HOME', 'http://localhost') . '/version'), true);
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ namespace Appwrite\Platform\Tasks;
|
||||
|
||||
use Appwrite\Migration\Migration;
|
||||
use Redis;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Http;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Registry\Registry;
|
||||
use Utopia\Validator\Text;
|
||||
@@ -85,7 +85,7 @@ class Migrate extends Action
|
||||
Console::log('Migrated ' . ++$count . '/' . $total . ' projects...');
|
||||
});
|
||||
|
||||
$console = (new App('UTC'))->getResource('console');
|
||||
$console = (new Http('UTC'))->getResource('console');
|
||||
|
||||
try {
|
||||
$migration
|
||||
|
||||
@@ -12,13 +12,13 @@ use Appwrite\Utopia\Response as AppwriteResponse;
|
||||
use Exception;
|
||||
use Swoole\Http\Request as SwooleRequest;
|
||||
use Swoole\Http\Response as SwooleResponse;
|
||||
use Utopia\App;
|
||||
use Utopia\Cache\Adapter\None;
|
||||
use Utopia\Cache\Cache;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Adapter\MySQL;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Http;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Request as UtopiaRequest;
|
||||
use Utopia\Response as UtopiaResponse;
|
||||
@@ -232,7 +232,7 @@ class Specs extends Action
|
||||
|
||||
public function action(string $version, string $mode): void
|
||||
{
|
||||
$appRoutes = App::getRoutes();
|
||||
$appRoutes = Http::getRoutes();
|
||||
|
||||
/** @var AppwriteResponse $response */
|
||||
$response = $this->getResponse();
|
||||
@@ -240,10 +240,10 @@ class Specs extends Action
|
||||
$mocks = ($mode === 'mocks');
|
||||
|
||||
// Mock dependencies
|
||||
App::setResource('request', fn () => $this->getRequest());
|
||||
App::setResource('response', fn () => $response);
|
||||
App::setResource('dbForPlatform', fn () => new Database(new MySQL(''), new Cache(new None())));
|
||||
App::setResource('dbForProject', fn () => new Database(new MySQL(''), new Cache(new None())));
|
||||
Http::setResource('request', fn () => $this->getRequest());
|
||||
Http::setResource('response', fn () => $response);
|
||||
Http::setResource('dbForPlatform', fn () => new Database(new MySQL(''), new Cache(new None())));
|
||||
Http::setResource('dbForProject', fn () => new Database(new MySQL(''), new Cache(new None())));
|
||||
|
||||
$platforms = static::getPlatforms();
|
||||
$authCounts = $this->getAuthCounts();
|
||||
@@ -332,7 +332,7 @@ class Specs extends Action
|
||||
}
|
||||
|
||||
$arguments = [
|
||||
new App('UTC'),
|
||||
new Http('UTC'),
|
||||
$services,
|
||||
$routes,
|
||||
$models,
|
||||
|
||||
@@ -431,6 +431,7 @@ class Messaging extends Action
|
||||
|
||||
private function sendInternalSMSMessage(Document $message, Document $project, array $recipients, Log $log): void
|
||||
{
|
||||
Span::add('providerType', 'sms');
|
||||
Span::add('recipientsCount', \count($recipients));
|
||||
|
||||
// Extract country codes from phone numbers
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
namespace Appwrite\SDK\Specification;
|
||||
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\App;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Http;
|
||||
use Utopia\Route;
|
||||
|
||||
abstract class Format
|
||||
{
|
||||
protected App $app;
|
||||
protected Http $app;
|
||||
|
||||
/**
|
||||
* @var array<Route>
|
||||
@@ -80,7 +80,7 @@ abstract class Format
|
||||
|
||||
protected array $enumBlacklist = [];
|
||||
|
||||
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount, string $platform)
|
||||
public function __construct(Http $app, array $services, array $routes, array $models, array $keys, int $authCount, string $platform)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->services = $services;
|
||||
|
||||
Reference in New Issue
Block a user