Remove dead code found by static analysis

Adds shipmonk/dead-code-detector as a PHPStan extension behind
`composer dead-code`, and removes what it found.

Every candidate was cross-checked against appwrite/cloud, which consumes
this repository as appwrite/server-ce. Symbols that repository still
references are listed in phpstan-deadcode.neon with the reason, alongside
abstract declarations with live implementations and one method called from
a .phtml view, so the check runs green and records the cross-check.

Removed:
- Appwrite\Event\{Audit,Execution,Func,Migration,Screenshot,StatsResources}
  and Appwrite\Event\Delete -- superseded by Appwrite\Event\Publisher\*
- Appwrite\Functions\Validator\Payload
- 159 unused methods and constants across 61 files
- utopia-php/analytics and utopia-php/preloader, referenced nowhere

Executor\Exception\Timeout kept its timeout only to feed the getter that
went away, so the value moved into the exception message.

league/csv stays: appwrite/cloud uses it without declaring it, so it has
to be added there first. appwrite/cloud also has a stale
`use Appwrite\Event\Delete;` in app/controllers/general.php to drop.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Opus 5 committed 2026-08-13 16:18:14 +01:00
1 parent 65d560b313
commit 35873e59fb
73 files changed
+169 -2267

No files matched your search

+1
View File
@@ -29,3 +29,4 @@ docker-compose.web-installer.yml
docker-compose.web-installer.yml.**.backup
tests/playwright/screenshots
.playwright-mcp/
.phpstan-cache-deadcode
+3 -3
View File
@@ -16,6 +16,7 @@
"analyze": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G",
"bench": "vendor/bin/phpbench run --report=benchmark",
"check": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G",
"dead-code": "./vendor/bin/phpstan analyse -c phpstan-deadcode.neon --memory-limit=2G",
"refactor": "vendor/bin/rector process",
"refactor:check": "vendor/bin/rector process --dry-run",
"installer:clean": "php src/Appwrite/Platform/Installer/Server.php --clean",
@@ -65,7 +66,6 @@
"appwrite/php-clamav": "2.0.*",
"utopia-php/abuse": "2.0.*",
"utopia-php/agents": "2.*",
"utopia-php/analytics": "0.15.*",
"utopia-php/audit": "3.0.*",
"utopia-php/auth": "^0.10",
"utopia-php/cache": "^4.0.0",
@@ -91,7 +91,6 @@
"utopia-php/platform": "^1.0@RC",
"utopia-php/pools": "2.*",
"utopia-php/span": "3.0.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/queue": "^1.0.0",
"utopia-php/servers": "0.4.*",
"utopia-php/registry": "0.5.*",
@@ -123,7 +122,8 @@
"textalk/websocket": "1.5.*",
"czproject/git-php": "4.*",
"laravel/pint": "1.*",
"rector/rector": "^2.4"
"rector/rector": "^2.4",
"shipmonk/dead-code-detector": "^0.13"
},
"provide": {
"ext-phpiredis": "*"
Generated
+78 -100
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4ad47c6924e38efc505314c491e8315e",
"content-hash": "1e71e6593aadcb27e643cd2caefb88f8",
"packages": [
{
"name": "adhocore/jwt",
@@ -3120,52 +3120,6 @@
},
"time": "2026-05-29T10:44:54+00:00"
},
{
"name": "utopia-php/analytics",
"version": "0.15.2",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/analytics.git",
"reference": "ce5be7042ad518b83e401dcd785d20c4cc872c67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/analytics/zipball/ce5be7042ad518b83e401dcd785d20c4cc872c67",
"reference": "ce5be7042ad518b83e401dcd785d20c4cc872c67",
"shasum": ""
},
"require": {
"php": ">=8.0"
},
"require-dev": {
"laravel/pint": "dev-main",
"phpunit/phpunit": "^9.3",
"utopia-php/system": "0.10.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Utopia\\Analytics\\": "src/Analytics"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A simple library to track events & users.",
"keywords": [
"analytics",
"framework",
"php",
"upf",
"utopia"
],
"support": {
"issues": "https://github.com/utopia-php/analytics/issues",
"source": "https://github.com/utopia-php/analytics/tree/0.15.2"
},
"time": "2026-02-09T12:46:39+00:00"
},
{
"name": "utopia-php/audit",
"version": "3.0.1",
@@ -4578,59 +4532,6 @@
},
"time": "2026-08-05T18:07:20+00:00"
},
{
"name": "utopia-php/preloader",
"version": "0.2.4",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/preloader.git",
"reference": "65ef48392e72172f584b0baa2e224f9a1cebcce0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/preloader/zipball/65ef48392e72172f584b0baa2e224f9a1cebcce0",
"reference": "65ef48392e72172f584b0baa2e224f9a1cebcce0",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "4.0.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Utopia\\Preloader\\": "src/Preloader"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eldad Fux",
"email": "team@appwrite.io"
}
],
"description": "Utopia Preloader library is simple and lite library for managing PHP preloading configuration",
"keywords": [
"framework",
"php",
"preload",
"preloader",
"preloading",
"upf",
"utopia"
],
"support": {
"issues": "https://github.com/utopia-php/preloader/issues",
"source": "https://github.com/utopia-php/preloader/tree/0.2.4"
},
"time": "2020-10-24T07:04:59+00:00"
},
{
"name": "utopia-php/psr7",
"version": "0.2.0",
@@ -7644,6 +7545,83 @@
],
"time": "2025-02-07T05:00:38+00:00"
},
{
"name": "shipmonk/dead-code-detector",
"version": "0.13.5",
"source": {
"type": "git",
"url": "https://github.com/shipmonk-rnd/dead-code-detector.git",
"reference": "a12cdd093624362743c8814a96a54fcc0a57d96d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/shipmonk-rnd/dead-code-detector/zipball/a12cdd093624362743c8814a96a54fcc0a57d96d",
"reference": "a12cdd093624362743c8814a96a54fcc0a57d96d",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.12"
},
"require-dev": {
"composer-runtime-api": "^2.0",
"composer/semver": "^3.4",
"doctrine/orm": "^2.19 || ^3.0",
"editorconfig-checker/editorconfig-checker": "^10.6.0",
"ergebnis/composer-normalize": "^2.45.0",
"nette/application": "^3.1",
"nette/component-model": "^3.0",
"nette/utils": "^3.0 || ^4.0",
"nikic/php-parser": "^5.4.0",
"phpstan/phpstan-phpunit": "^2.0.4",
"phpstan/phpstan-strict-rules": "^2.0.3",
"phpstan/phpstan-symfony": "^2.0.2",
"phpunit/phpcov": "^8.2",
"phpunit/phpunit": "^9.6.22",
"shipmonk/coding-standard": "^0.1.3",
"shipmonk/composer-dependency-analyser": "^1.8.2",
"shipmonk/name-collision-detector": "^2.1.1",
"shipmonk/phpstan-dev": "^0.1.1",
"shipmonk/phpstan-rules": "^4.1.0",
"symfony/contracts": "^2.5 || ^3.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/routing": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"twig/twig": "^3.0"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"ShipMonk\\PHPStan\\DeadCode\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.",
"keywords": [
"PHPStan",
"dead code",
"static analysis",
"unused code"
],
"support": {
"issues": "https://github.com/shipmonk-rnd/dead-code-detector/issues",
"source": "https://github.com/shipmonk-rnd/dead-code-detector/tree/0.13.5"
},
"time": "2025-10-13T12:19:42+00:00"
},
{
"name": "staabm/side-effects-detector",
"version": "1.0.5",
+86
View File
@@ -0,0 +1,86 @@
# Dead code detection: unused methods, constants and enum cases.
#
# composer dead-code
#
# Anything listed under ignoreErrors is dead as far as this repository can see,
# but must not be removed -- each group explains why. Appwrite is the base
# server for appwrite/cloud, so a symbol unused here may still be consumed
# there; check that repository before deleting anything this reports.
includes:
- vendor/shipmonk/dead-code-detector/rules.neon
parameters:
level: 0
tmpDir: .phpstan-cache-deadcode
bootstrapFiles:
- app/init/constants.php
scanDirectories:
- vendor/swoole/ide-helper
paths:
- src
- app
- bin
- tests
excludePaths:
- tests/resources
ignoreErrors:
# Referenced in appwrite/cloud.
- '#^Unused Appwrite\\Auth\\MFA\\Challenge::challenge$#'
- '#^Unused Appwrite\\Auth\\MFA\\Challenge::verify$#'
- '#^Unused Appwrite\\Certificates\\Adapter::getCertificateStatus$#'
- '#^Unused Appwrite\\Certificates\\LetsEncrypt::getCertificateStatus$#'
- '#^Unused Appwrite\\Event\\Certificate::getAction$#'
- '#^Unused Appwrite\\Event\\Certificate::getDomain$#'
- '#^Unused Appwrite\\Event\\Database::getDatabase$#'
- '#^Unused Appwrite\\Event\\Database::setDatabase$#'
- '#^Unused Appwrite\\Event\\Database::setTable$#'
- '#^Unused Appwrite\\Event\\Event::EXECUTIONS_QUEUE_NAME$#'
- '#^Unused Appwrite\\Event\\Event::setPaused$#'
- '#^Unused Appwrite\\Event\\Event::setPlatform$#'
- '#^Unused Appwrite\\Event\\Message\\Audit::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Base::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Build::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Execution::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Executions::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Mail::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Messaging::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\StatsResources::fromArray$#'
- '#^Unused Appwrite\\Event\\Message\\Usage::fromArray$#'
- '#^Unused Appwrite\\Event\\Publisher\\Execution::enqueue$#'
- '#^Unused Appwrite\\Event\\Publisher\\Execution::getSize$#'
- '#^Unused Appwrite\\Event\\Publisher\\StatsResources::enqueue$#'
- '#^Unused Appwrite\\Filter\\Filter::apply$#'
- '#^Unused Appwrite\\GraphQL\\Resolvers::document$#'
- '#^Unused Appwrite\\GraphQL\\Schema::collections$#'
- '#^Unused Appwrite\\Messaging\\Adapter::subscribe$#'
- '#^Unused Appwrite\\Platform\\Action::disableSubqueries$#'
- '#^Unused Appwrite\\Platform\\Action::dump$#'
- '#^Unused Appwrite\\Platform\\Action::foreachDocument$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Documents\\Action::getResourceId$#'
- '#^Unused Appwrite\\Promises\\Promise::all$#'
- '#^Unused Appwrite\\SDK\\Specification\\Format::getServices$#'
- '#^Unused Appwrite\\Usage\\Context::getResourceId$#'
- '#^Unused Appwrite\\Usage\\Context::getResourcePath$#'
- '#^Unused Appwrite\\Usage\\Context::getService$#'
- '#^Unused Appwrite\\Usage\\Context::setResourceId$#'
- '#^Unused Appwrite\\Usage\\Context::setService$#'
- '#^Unused Appwrite\\Utopia\\Fetch\\BodyMultipart::getPart$#'
- '#^Unused Appwrite\\Utopia\\Messaging\\Messages\\Console::getTo$#'
- '#^Unused Appwrite\\Utopia\\Messaging\\Messages\\Webhook::getTo$#'
- '#^Unused Executor\\Executor::flatten$#'
- '#^Unused Executor\\Executor::parseCookie$#'
# Abstract or interface declaration whose implementations are live.
- '#^Unused Appwrite\\Messaging\\Adapter::unsubscribe$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Action::getResponseModel$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Attributes\\Action::getResponseModel$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Documents\\Action::getResponseModel$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Indexes\\Action::getResponseModel$#'
- '#^Unused Tests\\E2E\\Scopes\\Scope::getHeaders$#'
# Implements an abstract parent -- removing it would leave the class incomplete.
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Databases\\Collections\\Attributes\\Delete::getResponseModel$#'
- '#^Unused Appwrite\\Platform\\Modules\\Databases\\Http\\Embeddings\\Text\\Create::getResponseModel$#'
# Called from a .phtml view, which PHPStan does not analyse.
- '#^Unused Appwrite\\Extend\\Exception::getCTAs$#'
-10
View File
@@ -22,11 +22,6 @@ abstract class Type
return $this;
}
public function getLabel(): ?string
{
return $this->instance->getLabel();
}
public function setIssuer(string $issuer): self
{
$this->instance->setIssuer($issuer);
@@ -34,11 +29,6 @@ abstract class Type
return $this;
}
public function getIssuer(): ?string
{
return $this->instance->getIssuer();
}
public function getSecret(): string
{
return $this->instance->getSecret();
@@ -222,25 +222,6 @@ class TransactionState
return max(0, $adjustedCount);
}
/**
* Check if a document exists with transaction-aware logic
*
* @param Document $database Target database document
* @param string $collectionId Collection ID
* @param string $documentId Document ID
* @param string|null $transactionId Optional transaction ID
* @return bool True if document exists
*/
public function documentExists(
Document $database,
string $collectionId,
string $documentId,
?string $transactionId = null
): bool {
$doc = $this->getDocument($database, $collectionId, $documentId, $transactionId);
return !$doc->isEmpty();
}
/**
* Apply bulk update to documents in transaction state that match queries
*
-212
View File
@@ -1,212 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class Audit extends Event
{
protected string $resource = '';
protected string $mode = '';
protected string $userAgent = '';
protected string $ip = '';
protected string $hostname = '';
protected string $sdk = '';
protected string $sdkVersion = '';
protected bool $critical = false;
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_AUDITS_QUEUE_NAME', Event::AUDITS_QUEUE_NAME))
->setClass(System::getEnv('_APP_AUDITS_CLASS_NAME', Event::AUDITS_CLASS_NAME));
}
/**
* Set resource for this audit event.
*
* @param string $resource
* @return self
*/
public function setResource(string $resource): self
{
$this->resource = $resource;
return $this;
}
/**
* Returns the set audit resource.
*
* @return string
*/
public function getResource(): string
{
return $this->resource;
}
/**
* Set mode for this audit event
*
* @param string $mode
* @return self
*/
public function setMode(string $mode): self
{
$this->mode = $mode;
return $this;
}
/**
* Returns the set audit mode.
*
* @return string
*/
public function getMode(): string
{
return $this->mode;
}
/**
* Set user agent for this audit event.
*
* @param string $userAgent
* @return self
*/
public function setUserAgent(string $userAgent): self
{
$this->userAgent = $userAgent;
return $this;
}
/**
* Returns the set audit user agent.
*
* @return string
*/
public function getUserAgent(): string
{
return $this->userAgent;
}
/**
* Set IP for this audit event.
*
* @param string $ip
* @return self
*/
public function setIP(string $ip): self
{
$this->ip = $ip;
return $this;
}
/**
* Returns the set audit IP.
*
* @return string
*/
public function getIP(): string
{
return $this->ip;
}
/**
* Set the hostname.
*
* @param string $hostname
*
* @return self
*/
public function setHostname(string $hostname): self
{
$this->hostname = $hostname;
return $this;
}
/**
* Get the hostname.
*
* @return string
*/
public function getHostname(): string
{
return $this->hostname;
}
/**
* Set SDK name for this audit event.
*
* @param string $sdk
* @return self
*/
public function setSdk(string $sdk): self
{
$this->sdk = $sdk;
return $this;
}
/**
* Returns the set audit SDK name.
*
* @return string
*/
public function getSdk(): string
{
return $this->sdk;
}
/**
* Set SDK version for this audit event.
*
* @param string $sdkVersion
* @return self
*/
public function setSdkVersion(string $sdkVersion): self
{
$this->sdkVersion = $sdkVersion;
return $this;
}
/**
* Returns the set audit SDK version.
*
* @return string
*/
public function getSdkVersion(): string
{
return $this->sdkVersion;
}
/**
* Prepare payload for queue.
*
* @return array
*/
protected function preparePayload(): array
{
return [
'project' => $this->project,
'user' => $this->user,
'payload' => $this->payload,
'resource' => $this->resource,
'mode' => $this->mode,
'ip' => $this->ip,
'userAgent' => $this->userAgent,
'event' => $this->event,
'hostname' => $this->hostname,
'sdk' => $this->sdk,
'sdkVersion' => $this->sdkVersion
];
}
}
-60
View File
@@ -24,19 +24,6 @@ class Certificate extends Event
->setClass(System::getEnv('_APP_CERTIFICATES_CLASS_NAME', Event::CERTIFICATES_CLASS_NAME));
}
/**
* Set domain for this certificates event.
*
* @param Document $domain
* @return self
*/
public function setDomain(Document $domain): self
{
$this->domain = $domain;
return $this;
}
/**
* Returns the set domain for this certificate event.
*
@@ -47,53 +34,6 @@ class Certificate extends Event
return $this->domain;
}
/**
* Set if the certificate needs to be validated.
*
* @param bool $skipRenewCheck
* @return self
*/
public function setSkipRenewCheck(bool $skipRenewCheck): self
{
$this->skipRenewCheck = $skipRenewCheck;
return $this;
}
/**
* Set override for main domain used for validation
*
* @param string|null $validationDomain
* @return self
*/
public function setValidationDomain(?string $validationDomain): self
{
$this->validationDomain = $validationDomain;
return $this;
}
/**
* Get validation domain
*
* @return string|null
*/
public function getValidationDomain(): ?string
{
return $this->validationDomain;
}
/**
* Return if the certificate needs be validated.
*
* @return bool
*/
public function getSkipRenewCheck(): bool
{
return $this->skipRenewCheck;
}
/**
* Set action for this certificate event.
*
-58
View File
@@ -85,51 +85,6 @@ class Database extends Event
return $this;
}
/**
* Returns set table for this event.
*
* @return null|Document
*/
public function getTable(): ?Document
{
return $this->table;
}
/**
* Set the row for this database event.
*
* @param Document $row
* @return self
*/
public function setRow(Document $row): self
{
$this->row = $row;
return $this;
}
/**
* Returns set row for this database event.
* @return null|Document
*/
public function getRow(): ?Document
{
return $this->row;
}
/**
* Set the collection for this database event.
*
* @param Document $collection
* @return self
*/
public function setCollection(Document $collection): self
{
$this->collection = $collection;
return $this;
}
/**
* Returns set collection for this event.
*
@@ -140,19 +95,6 @@ class Database extends Event
return $this->collection;
}
/**
* Set the document for this database event.
*
* @param Document $document
* @return self
*/
public function setDocument(Document $document): self
{
$this->document = $document;
return $this;
}
/**
* Returns set document for this database event.
* @return null|Document
-151
View File
@@ -1,151 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Database\Document;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class Delete extends Event
{
protected string $type = '';
protected ?Document $document = null;
protected ?string $resourceType = null;
protected ?string $resource = null;
protected ?string $datetime = null;
protected ?string $hourlyUsageRetentionDatetime = null;
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_DELETE_QUEUE_NAME', Event::DELETE_QUEUE_NAME))
->setClass(System::getEnv('_APP_DELETE_CLASS_NAME', Event::DELETE_CLASS_NAME));
}
/**
* Sets the type for the delete event (use the constants starting with DELETE_TYPE_*).
*
* @param string $type
* @return self
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* Returns the set type for the delete event.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* set Datetime.
*
* @param string $datetime
* @return self
*/
public function setDatetime(string $datetime): self
{
$this->datetime = $datetime;
return $this;
}
/**
* Sets datetime for 1h interval.
*
* @param string $datetime
* @return self
*/
public function setUsageRetentionHourlyDateTime(string $datetime): self
{
$this->hourlyUsageRetentionDatetime = $datetime;
return $this;
}
/**
* Sets the document for the delete event.
*
* @param Document $document
* @return self
*/
public function setDocument(Document $document): self
{
$this->document = $document;
return $this;
}
/**
* Returns the resource for the delete event.
*
* @return string
*/
public function getResource(): string
{
return $this->resource;
}
/**
* Sets the resource for the delete event.
*
* @param string $resource
* @return self
*/
public function setResource(string $resource): self
{
$this->resource = $resource;
return $this;
}
/**
* Sets the resource type for the delete event.
*
* @param string $resourceType
* @return self
*/
public function setResourceType(string $resourceType): self
{
$this->resourceType = $resourceType;
return $this;
}
/**
* Returns the set document for the delete event.
*
* @return null|Document
*/
public function getDocument(): ?Document
{
return $this->document;
}
/**
* Prepare the payload for the event
*
* @return array
*/
protected function preparePayload(): array
{
return [
'project' => $this->project,
'type' => $this->type,
'document' => $this->document,
'resource' => $this->resource,
'resourceType' => $this->resourceType,
'datetime' => $this->datetime,
'hourlyUsageRetentionDatetime' => $this->hourlyUsageRetentionDatetime
];
}
}
-46
View File
@@ -13,26 +13,19 @@ class Event
public const DATABASE_CLASS_NAME = 'DatabaseV1';
public const DELETE_QUEUE_NAME = 'v1-deletes';
public const DELETE_CLASS_NAME = 'DeletesV1';
public const AUDITS_QUEUE_NAME = 'v1-audits';
public const AUDITS_CLASS_NAME = 'AuditsV1';
public const MAILS_QUEUE_NAME = 'v1-mails';
public const MAILS_CLASS_NAME = 'MailsV1';
public const NOTIFICATIONS_QUEUE_NAME = 'v1-notifications';
public const NOTIFICATIONS_CLASS_NAME = 'NotificationsV1';
public const FUNCTIONS_QUEUE_NAME = 'v1-functions';
public const FUNCTIONS_CLASS_NAME = 'FunctionsV1';
public const FUNCTIONS_QUEUE_TTL = 60 * 60 * 24 * 7; // 7 days
public const STATS_RESOURCES_QUEUE_NAME = 'v1-stats-resources';
public const STATS_RESOURCES_CLASS_NAME = 'StatsResourcesV1';
public const STATS_USAGE_QUEUE_NAME = 'v1-stats-usage';
public const STATS_USAGE_CLASS_NAME = 'StatsUsageV1';
public const WEBHOOK_QUEUE_NAME = 'v1-webhooks';
public const WEBHOOK_CLASS_NAME = 'WebhooksV1';
@@ -41,22 +34,16 @@ class Event
public const CERTIFICATES_CLASS_NAME = 'CertificatesV1';
public const BUILDS_QUEUE_NAME = 'v1-builds';
public const BUILDS_CLASS_NAME = 'BuildsV1';
public const JOBS_QUEUE_NAME = 'v1-jobs';
public const JOBS_CLASS_NAME = 'JobsV1';
public const SCREENSHOTS_QUEUE_NAME = 'v1-screenshots';
public const SCREENSHOTS_CLASS_NAME = 'ScreenshotsV1';
public const MESSAGING_QUEUE_NAME = 'v1-messaging';
public const MESSAGING_CLASS_NAME = 'MessagingV1';
public const EXECUTIONS_QUEUE_NAME = 'v1-executions';
public const EXECUTIONS_CLASS_NAME = 'ExecutionsV1';
public const MIGRATIONS_QUEUE_NAME = 'v1-migrations';
public const MIGRATIONS_CLASS_NAME = 'MigrationsV1';
protected string $queue = '';
protected string $class = '';
@@ -95,14 +82,6 @@ class Event
return $this;
}
/**
* Get paused state for this event.
*/
public function getPaused(): bool
{
return $this->paused;
}
/**
* Set queue used for this event.
*
@@ -126,19 +105,6 @@ class Event
return $this->queue;
}
/**
* Set TTL (time-to-live) for jobs in this queue.
*
* @param int $ttl TTL in seconds
* @return static
*/
public function setTTL(int $ttl): static
{
$this->ttl = $ttl;
return $this;
}
/**
* Get TTL (time-to-live) for jobs in this queue.
*
@@ -228,18 +194,6 @@ class Event
return $this;
}
/**
* Set user ID for this event.
*
* @return static
*/
public function setUserId(string $userId): static
{
$this->userId = $userId;
return $this;
}
/**
* Get user responsible for triggering this event.
*
-75
View File
@@ -1,75 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Database\Document;
use Utopia\Queue\Publisher;
class Execution extends Event
{
protected ?Document $execution = null;
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(Event::EXECUTIONS_QUEUE_NAME)
->setClass(Event::EXECUTIONS_CLASS_NAME);
}
/**
* Sets execution document for the execution event.
*
* @param Document $execution
* @return self
*/
public function setExecution(Document $execution): self
{
$this->execution = $execution;
return $this;
}
/**
* Returns set execution document for the execution event.
*
* @return null|Document
*/
public function getExecution(): ?Document
{
return $this->execution;
}
/**
* Prepare payload for the execution event.
*
* @return array
*/
protected function preparePayload(): array
{
return [
'project' => $this->project,
'execution' => $this->execution,
];
}
/**
* Trim payload for the execution event.
* Only the project ID is needed — the worker DI fetches the full project from the platform database.
*
* @return array
*/
protected function trimPayload(): array
{
$trimmed = [];
if ($this->project) {
$trimmed['project'] = new Document([
'$id' => $this->project->getId(),
]);
}
return $trimmed;
}
}
-229
View File
@@ -1,229 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Config\Config;
use Utopia\Database\Document;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class Func extends Event
{
protected string $jwt = '';
protected string $type = '';
protected string $body = '';
protected string $path = '';
protected string $method = '';
protected array $headers = [];
protected ?string $functionId = null;
protected ?Document $function = null;
protected ?Document $execution = null;
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_FUNCTIONS_QUEUE_NAME', Event::FUNCTIONS_QUEUE_NAME))
->setClass(System::getEnv('_APP_FUNCTIONS_CLASS_NAME', Event::FUNCTIONS_CLASS_NAME))
->setTTL(Event::FUNCTIONS_QUEUE_TTL);
}
/**
* Sets function document for the function event.
*
* @param Document $function
* @return self
*/
public function setFunction(Document $function): self
{
$this->function = $function;
return $this;
}
/**
* Returns set function document for the function event.
*
* @return null|Document
*/
public function getFunction(): ?Document
{
return $this->function;
}
/**
* Sets function id for the function event.
*
* @param string $functionId
*/
public function setFunctionId(string $functionId): self
{
$this->functionId = $functionId;
return $this;
}
/**
* Returns set function id for the function event.
*
* @return string|null
*/
public function getFunctionId(): ?string
{
return $this->functionId;
}
/**
* Sets execution for the function event.
*
* @param Document $execution
* @return self
*/
public function setExecution(Document $execution): self
{
$this->execution = $execution;
return $this;
}
/**
* Returns set execution for the function event.
*
* @return null|Document
*/
public function getExecution(): ?Document
{
return $this->execution;
}
/**
* Sets type for the function event.
*
* @param string $type Can be `schedule`, `event` or `http`.
* @return self
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* Returns set type for the function event.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* Sets custom body for the function event.
*
* @param string $body
* @return self
*/
public function setBody(string $body): self
{
$this->body = $body;
return $this;
}
/**
* Sets custom method for the function event.
*
* @param string $method
* @return self
*/
public function setMethod(string $method): self
{
$this->method = $method;
return $this;
}
/**
* Sets custom path for the function event.
*
* @param string $path
* @return self
*/
public function setPath(string $path): self
{
$this->path = $path;
return $this;
}
/**
* Sets custom headers for the function event.
*
* @param array $headers
* @return self
*/
public function setHeaders(array $headers): self
{
$this->headers = $headers;
return $this;
}
/**
* Returns set JWT for the function event.
*
* @return string
*/
public function getJWT(): string
{
return $this->jwt;
}
/**
* Sets JWT for the function event.
*
* @param string $jwt
* @return self
*/
public function setJWT(string $jwt): self
{
$this->jwt = $jwt;
return $this;
}
/**
* Prepare payload for the function event.
*
* @return array
*/
protected function preparePayload(): array
{
$events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null;
$platform = $this->platform;
if (empty($platform)) {
$platform = Config::getParam('platform', []);
}
return [
'project' => $this->project,
'user' => $this->user,
'userId' => $this->userId,
'function' => $this->function,
'functionId' => $this->functionId,
'execution' => $this->execution,
'type' => $this->type,
'jwt' => $this->jwt,
'payload' => $this->payload,
'events' => $events,
'body' => $this->body,
'path' => $this->path,
'headers' => $this->headers,
'method' => $this->method,
'platform' => $platform,
];
}
}
-90
View File
@@ -1,90 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Config\Config;
use Utopia\Database\Document;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class Migration extends Event
{
protected string $type = '';
protected ?Document $migration = null;
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_MIGRATIONS_QUEUE_NAME', Event::MIGRATIONS_QUEUE_NAME))
->setClass(System::getEnv('_APP_MIGRATIONS_CLASS_NAME', Event::MIGRATIONS_CLASS_NAME));
}
/**
* Sets migration document for the migration event.
*
* @param Document $migration
* @return self
*/
public function setMigration(Document $migration): self
{
$this->migration = $migration;
return $this;
}
/**
* Returns set migration document for the function event.
*
* @return null|Document
*/
public function getMigration(): ?Document
{
return $this->migration;
}
/**
* Sets migration type for the migration event.
*
* @param string $type
*
* @return self
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* Returns set migration type for the migration event.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* Prepare the payload for the migration event.
*
* @return array
*/
protected function preparePayload(): array
{
$platform = $this->platform;
if (empty($platform)) {
$platform = Config::getParam('platform', []);
}
return [
'project' => $this->project,
'user' => $this->user,
'migration' => $this->migration,
'platform' => $platform,
];
}
}
-50
View File
@@ -1,50 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Config\Config;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class Screenshot extends Event
{
protected string $deploymentId = '';
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_SCREENSHOTS_QUEUE_NAME', Event::SCREENSHOTS_QUEUE_NAME))
->setClass(System::getEnv('_APP_SCREENSHOTS_CLASS_NAME', Event::SCREENSHOTS_CLASS_NAME));
}
public function setDeploymentId(string $deploymentId): self
{
$this->deploymentId = $deploymentId;
return $this;
}
protected function preparePayload(): array
{
$platform = $this->platform;
if (empty($platform)) {
$platform = Config::getParam('platform', []);
}
return [
'project' => $this->project,
'deploymentId' => $this->deploymentId,
'platform' => $platform,
];
}
public function reset(): self
{
$this->deploymentId = '';
parent::reset();
return $this;
}
}
-74
View File
@@ -1,74 +0,0 @@
<?php
namespace Appwrite\Event;
use Utopia\Queue\Publisher;
use Utopia\System\System;
class StatsResources extends Event
{
protected bool $critical = false;
/**
* Pre-computed gauge metric snapshots to write to the stats collection. When non-empty,
* the StatsResources worker takes the fast path: it writes these directly via
* upsertDocuments (replace semantics) and skips the standard counting work.
*
* Each entry is a tuple of (metric key, value). The worker writes one stats document per
* (metric, period) tuple using the project's region.
*
* @var array<int, array{metric: string, value: int}>
*/
protected array $gauges = [];
public function __construct(protected Publisher $publisher)
{
parent::__construct($publisher);
$this
->setQueue(System::getEnv('_APP_STATS_RESOURCES_QUEUE_NAME', Event::STATS_RESOURCES_QUEUE_NAME))
->setClass(System::getEnv('_APP_STATS_RESOURCES_CLASS_NAME', Event::STATS_RESOURCES_CLASS_NAME));
}
/**
* Set the full set of pre-computed gauge metrics for this message. Replaces any
* previously-set gauges.
*
* @param array<int, array{metric: string, value: int}> $gauges
*/
public function setGauges(array $gauges): self
{
$this->gauges = $gauges;
return $this;
}
/**
* Append a single pre-computed gauge metric to this message.
*/
public function addGauge(string $metric, int $value): self
{
$this->gauges[] = ['metric' => $metric, 'value' => $value];
return $this;
}
/**
* @return array<int, array{metric: string, value: int}>
*/
public function getGauges(): array
{
return $this->gauges;
}
/**
* Prepare the payload for the usage event.
*
* @return array
*/
protected function preparePayload(): array
{
return [
'project' => $this->project,
'gauges' => $this->gauges,
];
}
}
-1
View File
@@ -99,7 +99,6 @@ class Exception extends \Exception
public const string USER_EMAIL_NOT_VERIFIED = 'user_email_not_verified';
public const string USER_MISSING_ID = 'user_missing_id';
public const string USER_MORE_FACTORS_REQUIRED = 'user_more_factors_required';
public const string USER_INVALID_CHALLENGE = 'user_invalid_challenge';
public const string USER_AUTHENTICATOR_NOT_FOUND = 'user_authenticator_not_found';
public const string USER_AUTHENTICATOR_ALREADY_VERIFIED = 'user_authenticator_already_verified';
public const string USER_RECOVERY_CODES_ALREADY_EXISTS = 'user_recovery_codes_already_exists';
@@ -1,18 +0,0 @@
<?php
namespace Appwrite\Functions\Validator;
use Utopia\Validator\Text;
class Payload extends Text
{
public function __construct(int $length, int $min = 1)
{
parent::__construct($length, $min);
}
public function getType(): string
{
return self::TYPE_STRING;
}
}
-5
View File
@@ -11,9 +11,4 @@ class Exception extends AppwriteException implements ClientAware
{
return true;
}
public function getCategory(): string
{
return 'appwrite';
}
}
@@ -30,7 +30,6 @@ class Server
public const string STEP_DOCKER_CONTAINERS = 'docker-containers';
public const string STEP_ACCOUNT_SETUP = 'account-setup';
public const string STEP_MIGRATION = 'migration';
public const string STEP_SSL_CERTIFICATE = 'ssl-certificate';
public const string STATUS_IN_PROGRESS = 'in-progress';
public const string STATUS_COMPLETED = 'completed';
@@ -108,66 +108,6 @@ abstract class Action extends DatabasesAction
: Exception::TABLE_LIMIT_EXCEEDED;
}
/**
* Get the appropriate format unsupported exception.
*/
protected function getFormatUnsupportedException(): string
{
return $this->isCollectionsAPI()
? Exception::ATTRIBUTE_FORMAT_UNSUPPORTED
: Exception::COLUMN_FORMAT_UNSUPPORTED;
}
/**
* Get the correct default unsupported message.
*/
protected function getDefaultUnsupportedException(): string
{
return $this->isCollectionsAPI()
? Exception::ATTRIBUTE_DEFAULT_UNSUPPORTED
: Exception::COLUMN_DEFAULT_UNSUPPORTED;
}
/**
* Get the appropriate parent level not found exception.
*/
protected function getParentNotFoundException(): string
{
return $this->isCollectionsAPI()
? Exception::COLLECTION_NOT_FOUND
: Exception::TABLE_NOT_FOUND;
}
/**
* Get the correct invalid structure message.
*/
protected function getStructureException(): string
{
return $this->isCollectionsAPI()
? Exception::DOCUMENT_INVALID_STRUCTURE
: Exception::ROW_INVALID_STRUCTURE;
}
/**
* Get the exception for unknown attribute/column in index.
*/
protected function getParentUnknownException(): string
{
return $this->isCollectionsAPI()
? Exception::ATTRIBUTE_UNKNOWN
: Exception::COLUMN_UNKNOWN;
}
/**
* Get the exception for invalid attribute/column type in index.
*/
protected function getParentInvalidTypeException(): string
{
return $this->isCollectionsAPI()
? Exception::ATTRIBUTE_TYPE_INVALID
: Exception::COLUMN_TYPE_INVALID;
}
/**
* Add row bytes information to a collection/table document.
*/
@@ -24,11 +24,6 @@ class Create extends Action
return 'createDatabasesTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -23,11 +23,6 @@ class Delete extends Action
return 'deleteDatabasesTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_NONE;
}
public function __construct()
{
$this
@@ -20,11 +20,6 @@ class Get extends Action
return 'getDatabasesTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -31,11 +31,6 @@ class Create extends Action
return 'createDatabasesTransactionOperations';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -23,11 +23,6 @@ class XList extends Action
return 'listDatabasesTransactions';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION_LIST;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Create extends TransactionsCreate
return 'createDocumentsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Delete extends TransactionsDelete
return 'deleteDocumentsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_NONE;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Get extends TransactionsGet
return 'getDocumentsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -20,11 +20,6 @@ class Create extends OperationsCreate
return 'createDocumentsDBOperations';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class XList extends TransactionsList
return 'listDocumentsDBTransactions';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION_LIST;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Create extends TransactionsCreate
return 'createTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -19,11 +19,6 @@ class Delete extends TransactionsDelete
return 'deleteTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_NONE;
}
public function __construct()
{
$this
@@ -19,11 +19,6 @@ class Get extends TransactionsGet
return 'getTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -21,11 +21,6 @@ class Create extends OperationsCreate
return 'createOperations';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class XList extends TransactionsList
return 'listTransactions';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION_LIST;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Create extends TransactionsCreate
return 'createVectorsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Delete extends TransactionsDelete
return 'deleteVectorsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_NONE;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class Get extends TransactionsGet
return 'getVectorsDBTransaction';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -20,11 +20,6 @@ class Create extends OperationsCreate
return 'createVectorsDBOperations';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION;
}
public function __construct()
{
$this
@@ -18,11 +18,6 @@ class XList extends TransactionsList
return 'listVectorsDBTransactions';
}
protected function getResponseModel(): string
{
return UtopiaResponse::MODEL_TRANSACTION_LIST;
}
public function __construct()
{
$this
@@ -24,7 +24,6 @@ use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP;
use Utopia\Pools\Group;
use Utopia\System\System;
use Utopia\Validator;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
@@ -37,11 +36,6 @@ class Create extends Action
return 'createProject';
}
protected function getQueriesValidator(): Validator
{
return new Projects();
}
public function __construct()
{
$this
@@ -7,14 +7,12 @@ use Appwrite\Platform\Modules\Projects\Http\Projects\Action;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Database\Validator\Queries\Projects;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator;
class Update extends Action
{
@@ -25,11 +23,6 @@ class Update extends Action
return 'updateProjectTeam';
}
protected function getQueriesValidator(): Validator
{
return new Projects();
}
public function __construct()
{
$this
@@ -3,12 +3,10 @@
namespace Appwrite\Platform\Modules\Projects\Http\Projects;
use Appwrite\Extend\Exception;
use Appwrite\Utopia\Database\Validator\Queries\Projects;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator;
use Utopia\Validator\Text;
use Utopia\Validator\URL;
@@ -21,11 +19,6 @@ class Update extends Action
return 'updateProject';
}
protected function getQueriesValidator(): Validator
{
return new Projects();
}
public function __construct()
{
$this
-37
View File
@@ -45,43 +45,6 @@ abstract class Promise
return new static($promise);
}
/**
* Resolve promise with given value.
*
* @param mixed $value
* @return self
*/
public static function resolve(mixed $value): self
{
return new static(function (callable $resolve) use ($value) {
$resolve($value);
});
}
/**
* Rejects the promise with the given reason.
*
* @param mixed $value
* @return self
*/
public static function reject(mixed $value): self
{
return new static(function (callable $resolve, callable $reject) use ($value) {
$reject($value);
});
}
/**
* Catch any exception thrown by the executor.
*
* @param callable $onRejected
* @return self
*/
public function catch(callable $onRejected): self
{
return $this->then(null, $onRejected);
}
/**
* Execute the promise.
*
@@ -32,14 +32,6 @@ class Dispatcher
return $this;
}
/**
* @return array<string, Action>
*/
public function getHandlers(): array
{
return $this->handlers;
}
/**
* Routes a parsed websocket message to the handler that registered for its `type`,
* runs param validation + dependency injection, and returns whatever the handler returns.
-80
View File
@@ -236,97 +236,17 @@ class Method
return $this;
}
public function setMethodName(string $name): self
{
$this->name = $name;
return $this;
}
public function setDesc(string $desc): self
{
$this->desc = $desc;
return $this;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function setAuth(array $auth): self
{
$this->validateAuthTypes($auth);
$this->auth = $auth;
return $this;
}
/**
* @param array<SDKResponse> $responses
*/
public function setResponses(array $responses): self
{
foreach ($responses as $response) {
$this->validateResponseModel($response->getModel());
$this->validateNoContent($response);
}
$this->responses = $responses;
return $this;
}
public function setContentType(ContentType $contentType): self
{
$this->contentType = $contentType;
return $this;
}
public function setType(?MethodType $type): self
{
$this->type = $type;
return $this;
}
public function setDeprecated(bool|Deprecated $deprecated): self
{
$this->deprecated = $deprecated;
return $this;
}
public function setHide(bool|Deprecated $hide): self
{
$this->hide = $hide;
return $this;
}
public function setPackaging(bool $packaging): self
{
$this->packaging = $packaging;
return $this;
}
public function setRequestType(ContentType $requestType): self
{
$this->requestType = $requestType;
return $this;
}
public function setParameters(array $parameters): self
{
$this->parameters = $parameters;
return $this;
}
public function isPublic(): bool
{
return $this->public;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
public static function getErrors(): array
{
return self::$errors;
-36
View File
@@ -29,23 +29,11 @@ class Parameter
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getDefault(): mixed
{
return $this->default === Undefined::Value ? null : $this->default;
@@ -56,23 +44,11 @@ class Parameter
return $this->default !== Undefined::Value;
}
public function setDefault(mixed $default): static
{
$this->default = $default;
return $this;
}
public function getValidator(): mixed
{
return $this->validator;
}
public function setValidator(mixed $validator): static
{
$this->validator = $validator;
return $this;
}
public function getOptional(): bool
{
return $this->optional === Undefined::Value ? false : $this->optional;
@@ -83,20 +59,8 @@ class Parameter
return $this->optional !== Undefined::Value;
}
public function setOptional(bool $optional): static
{
$this->optional = $optional;
return $this;
}
public function getHide(): bool
{
return $this->hide;
}
public function setHide(bool $hide): static
{
$this->hide = $hide;
return $this;
}
}
-15
View File
@@ -156,21 +156,6 @@ abstract class Format
return ['type' => 'object'];
}
/**
* Set Services.
*
* Set services value
*
* @param array $services
*
* @return self
*/
public function setServices(array $services): self
{
$this->services = $services;
return $this;
}
/**
* Set Services.
*
-20
View File
@@ -23,16 +23,6 @@ class Context
return $this;
}
/**
* Add a document to reduce
*/
public function addReduce(Document $document): self
{
$this->reduce[] = $document;
return $this;
}
/**
* Get all metrics
*
@@ -86,11 +76,6 @@ class Context
return $this;
}
public function getResource(): string
{
return '';
}
public function setResourceId(string $resourceId): self
{
return $this;
@@ -106,11 +91,6 @@ class Context
return $this;
}
public function getResourceInternalId(): string
{
return '';
}
/**
* Reset the context
*/
@@ -11,7 +11,6 @@ use Utopia\Database\Validator\Roles;
class User extends Document
{
public const ROLE_ANY = 'any';
public const ROLE_GUESTS = 'guests';
public const ROLE_USERS = 'users';
public const ROLE_ADMIN = 'admin';
@@ -20,16 +19,6 @@ class User extends Document
public const ROLE_KEYS = 'keys';
public const ROLE_SYSTEM = 'system';
public function getEmail(): ?string
{
return $this->getAttribute('email');
}
public function getPhone(): ?string
{
return $this->getAttribute('phone');
}
/**
* Returns all roles for a user.
*
@@ -83,17 +72,6 @@ class User extends Document
return $roles;
}
/**
* Check if user is anonymous.
*
* @return bool
*/
public function isAnonymous(): bool
{
return is_null($this->getEmail())
&& is_null($this->getPhone());
}
/**
* Is Privileged User?
*
@@ -106,17 +106,6 @@ class BodyMultipart
return $this;
}
public function getBoundary(): string
{
return $this->boundary;
}
public function setBoundary(string $boundary): self
{
$this->boundary = $boundary;
return $this;
}
public function exportHeader(): string
{
return 'multipart/form-data; boundary=' . $this->boundary;
-11
View File
@@ -123,17 +123,6 @@ class Request extends UtopiaRequest
return $this->filters;
}
/**
* Reset filters
*
* @return void
*/
public function resetFilters(): void
{
$this->filters = [];
$this->filteredParams = null;
}
/**
* Check if a filter has been set
*
@@ -14,8 +14,6 @@ class V17 extends Filter
protected const CHAR_SPACE = ' ';
protected const CHAR_BRACKET_START = '[';
protected const CHAR_BRACKET_END = ']';
protected const CHAR_PARENTHESES_START = '(';
protected const CHAR_PARENTHESES_END = ')';
protected const CHAR_BACKSLASH = '\\';
// Convert 1.4 params to 1.5
-27
View File
@@ -29,7 +29,6 @@ class Response extends SwooleResponse
public const MODEL_METRIC_LIST = 'metricList';
public const MODEL_METRIC_BREAKDOWN = 'metricBreakdown';
public const MODEL_ERROR_DEV = 'errorDev';
public const MODEL_BASE_LIST = 'baseList';
public const MODEL_USAGE_DOCUMENTSDBS = 'usageDocumentsDBs';
public const MODEL_USAGE_DOCUMENTSDB = 'usageDocumentsDB';
public const MODEL_USAGE_VECTORSDBS = 'usageVectorsDBs';
@@ -132,7 +131,6 @@ class Response extends SwooleResponse
// MFA
public const MODEL_MFA_TYPE = 'mfaType';
public const MODEL_MFA_FACTORS = 'mfaFactors';
public const MODEL_MFA_OTP = 'mfaTotp';
public const MODEL_MFA_CHALLENGE = 'mfaChallenge';
public const MODEL_MFA_CHALLENGE_SECRET = 'mfaChallengeSecret';
public const MODEL_MFA_RECOVERY_CODES = 'mfaRecoveryCodes';
@@ -191,7 +189,6 @@ class Response extends SwooleResponse
public const MODEL_INSTALLATION = 'installation';
public const MODEL_INSTALLATION_LIST = 'installationList';
public const MODEL_PROVIDER_REPOSITORY = 'providerRepository';
public const MODEL_PROVIDER_REPOSITORY_LIST = 'providerRepositoryList';
public const MODEL_PROVIDER_REPOSITORY_FRAMEWORK = 'providerRepositoryFramework';
public const MODEL_PROVIDER_REPOSITORY_FRAMEWORK_LIST = 'providerRepositoryFrameworkList';
public const MODEL_PROVIDER_REPOSITORY_RUNTIME = 'providerRepositoryRuntime';
@@ -225,7 +222,6 @@ class Response extends SwooleResponse
public const MODEL_DEPLOYMENT_LIST = 'deploymentList';
public const MODEL_EXECUTION = 'execution';
public const MODEL_EXECUTION_LIST = 'executionList';
public const MODEL_FUNC_PERMISSIONS = 'funcPermissions';
public const MODEL_HEADERS = 'headers';
public const MODEL_SPECIFICATION = 'specification';
public const MODEL_SPECIFICATION_LIST = 'specificationList';
@@ -288,7 +284,6 @@ class Response extends SwooleResponse
public const MODEL_PLATFORM_LIST = 'platformList';
public const MODEL_VARIABLE = 'variable';
public const MODEL_VARIABLE_LIST = 'variableList';
public const MODEL_VCS = 'vcs';
public const MODEL_EMAIL_TEMPLATE = 'emailTemplate';
public const MODEL_EMAIL_TEMPLATE_LIST = 'emailTemplateList';
public const MODEL_OAUTH2_GITHUB = 'oAuth2Github';
@@ -358,13 +353,6 @@ class Response extends SwooleResponse
public const MODEL_CONSOLE_KEY_SCOPE = 'consoleKeyScope';
public const MODEL_CONSOLE_KEY_SCOPE_LIST = 'consoleKeyScopeList';
// Deprecated
public const MODEL_PERMISSIONS = 'permissions';
public const MODEL_RULE = 'rule';
public const MODEL_TASK = 'task';
public const MODEL_DOMAIN = 'domain';
public const MODEL_DOMAIN_LIST = 'domainList';
// Tests (keep last)
public const MODEL_MOCK = 'mock';
@@ -753,16 +741,6 @@ class Response extends SwooleResponse
return $this->filters;
}
/**
* Reset filters
*
* @return void
*/
public function resetFilters(): void
{
$this->filters = [];
}
/**
* Check if a filter has been set
*
@@ -809,9 +787,4 @@ class Response extends SwooleResponse
{
$this->impersonatorUser = $impersonatorUser->isEmpty() ? null : $impersonatorUser;
}
public function getImpersonatorUser(): ?Document
{
return $this->impersonatorUser;
}
}
-22
View File
@@ -14,7 +14,6 @@ abstract class Model
public const TYPE_DATETIME = 'datetime';
public const TYPE_DATETIME_EXAMPLE = '2020-10-15T06:38:00.000+00:00';
public const TYPE_RELATIONSHIP = 'relationship';
public const TYPE_PAYLOAD = 'payload';
public const TYPE_ARRAY = 'array';
public const TYPE_ENUM = 'enum';
public const TYPE_ID = 'id';
@@ -118,27 +117,6 @@ abstract class Model
return $list;
}
/**
* Get Readonly Fields
*
* Returns list of field names that are marked as readOnly
* and should not be allowed in create/update payloads
*
* @return array
*/
public function getReadonlyFields(): array
{
$list = [];
foreach ($this->rules as $key => $rule) {
if ($rule['readOnly'] ?? false) {
$list[] = $key;
}
}
return $list;
}
/**
* Is None
*
-13
View File
@@ -6,17 +6,4 @@ use Utopia\Http\View as OldView;
class View extends OldView
{
/**
* Escape
*
* Convert all applicable characters to HTML entities
*
* @param string $str
* @return string
* @deprecated Use print method with escape filter
*/
public function escape($str)
{
return \htmlentities($str, ENT_QUOTES, 'UTF-8');
}
}
-1
View File
@@ -5,7 +5,6 @@ namespace Executor;
class Exception extends \Exception
{
public const string GENERAL_UNKNOWN = 'general_unknown';
public const string BUILD_FAILED = 'build_failed';
public function __construct(
string $message = '',
-14
View File
@@ -3,21 +3,7 @@
namespace Executor\Exception;
use Executor\Exception;
use Throwable;
class Timeout extends Exception
{
public function __construct(
string $message,
private readonly int $timeoutSeconds,
int $code = 0,
?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
public function getTimeoutSeconds(): int
{
return $this->timeoutSeconds;
}
}
+1 -33
View File
@@ -17,13 +17,7 @@ class Executor
public const METHOD_GET = 'GET';
public const METHOD_POST = 'POST';
public const METHOD_PUT = 'PUT';
public const METHOD_PATCH = 'PATCH';
public const METHOD_DELETE = 'DELETE';
public const METHOD_HEAD = 'HEAD';
public const METHOD_OPTIONS = 'OPTIONS';
public const METHOD_CONNECT = 'CONNECT';
public const METHOD_TRACE = 'TRACE';
protected bool $selfSigned = false;
@@ -173,32 +167,6 @@ class Executor
return $response['body'];
}
public function createCommand(
string $deploymentId,
string $projectId,
string $command,
int $timeout
) {
$runtimeId = "$projectId-$deploymentId-build";
$route = "/runtimes/$runtimeId/commands";
$params = [
'command' => $command,
'timeout' => $timeout
];
$response = $this->call($this->endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
$status = $response['headers']['status-code'];
if ($status >= 400) {
$message = \is_string($response['body']) ? $response['body'] : ($response['body']['message'] ?? '');
$type = \is_array($response['body']) ? ($response['body']['type'] ?? ExecutorException::GENERAL_UNKNOWN) : ExecutorException::GENERAL_UNKNOWN;
throw new ExecutorException($message, $status, type: $type);
}
return $response['body'];
}
/**
* Call
*
@@ -324,7 +292,7 @@ class Executor
if ($curlError) {
if ($curlError == CURLE_OPERATION_TIMEDOUT) {
throw new ExecutorTimeout('Executor request timed out', $timeout);
throw new ExecutorTimeout('Executor request timed out after ' . $timeout . ' seconds');
}
throw new ExecutorException($curlErrorMessage . ' with status code ' . $responseStatus, $responseStatus);
}
-73
View File
@@ -14,8 +14,6 @@ class Client
public const METHOD_DELETE = 'DELETE';
public const METHOD_HEAD = 'HEAD';
public const METHOD_OPTIONS = 'OPTIONS';
public const METHOD_CONNECT = 'CONNECT';
public const METHOD_TRACE = 'TRACE';
/**
* Is Self Signed Certificates Allowed?
@@ -48,66 +46,6 @@ class Client
{
}
/**
* Set Project
*
* Your Appwrite project ID. You can find your project ID in your Appwrite console project settings.
*
* @param string $value
*
* @return self $this
*/
public function setProject(string $value): self
{
$this->addHeader('X-Appwrite-Project', $value);
return $this;
}
/**
* Set Key
*
* Your Appwrite project secret key. You can can create a new API key from your Appwrite console API keys dashboard.
*
* @param string $value
*
* @return self $this
*/
public function setKey(string $value): self
{
$this->addHeader('X-Appwrite-Key', $value);
return $this;
}
/**
* Set Locale
*
* @param string $value
*
* @return self $this
*/
public function setLocale(string $value): self
{
$this->addHeader('X-Appwrite-Locale', $value);
return $this;
}
/**
* Set Mode
*
* @param string $value
*
* @return self $this
*/
public function setMode(string $value): self
{
$this->addHeader('X-Appwrite-Mode', $value);
return $this;
}
/**
* Set Response Format
*
@@ -122,17 +60,6 @@ class Client
return $this;
}
/**
* @param bool $status true
* @return self $this
*/
public function setSelfSigned(bool $status = true): self
{
$this->selfSigned = $status;
return $this;
}
/**
* @param string $endpoint
* @return self $this
-5
View File
@@ -92,11 +92,6 @@ trait ApiDocumentsDB
{
return false;
}
protected function getSupportForIntegerIds(): bool
{
return false;
}
protected function getSupportForOperators(): bool
{
return false;
-86
View File
@@ -47,92 +47,6 @@ trait SchemaPolling
}, $timeoutMs, $waitMs);
}
/**
* Wait for multiple attributes to become available.
*
* @param string $databaseId The database ID
* @param string $containerId The collection/table ID
* @param array $attributeKeys Array of attribute keys to wait for
* @param int $timeoutMs Maximum time to wait in milliseconds
* @param int $waitMs Time between polling attempts in milliseconds
*/
protected function waitForAttributes(string $databaseId, string $containerId, array $attributeKeys, int $timeoutMs = 240000, int $waitMs = 500): void
{
$this->assertEventually(function () use ($databaseId, $containerId, $attributeKeys) {
$container = $this->client->call(
Client::METHOD_GET,
$this->getContainerUrl($databaseId, $containerId),
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
])
);
$this->assertEquals(200, $container['headers']['status-code']);
$this->assertArrayHasKey('body', $container);
$this->assertArrayHasKey($this->getSchemaResource(), $container['body']);
$attributes = $container['body'][$this->getSchemaResource()];
$availableKeys = [];
foreach ($attributes as $attr) {
if ($attr['status'] === 'failed') {
throw new Critical("Attribute '{$attr['key']}' failed: " . ($attr['error'] ?? 'unknown error'));
}
if ($attr['status'] === 'available') {
$availableKeys[] = $attr['key'];
}
}
foreach ($attributeKeys as $key) {
$this->assertContains($key, $availableKeys, "Attribute '$key' is not available yet");
}
}, $timeoutMs, $waitMs);
}
/**
* Wait for the collection/table to have at least a certain number of available attributes.
*
* @param string $databaseId The database ID
* @param string $containerId The collection/table ID
* @param int $count Minimum number of available attributes required
* @param int $timeoutMs Maximum time to wait in milliseconds
* @param int $waitMs Time between polling attempts in milliseconds
*/
protected function waitForAttributeCount(string $databaseId, string $containerId, int $count, int $timeoutMs = 240000, int $waitMs = 500): void
{
$this->assertEventually(function () use ($databaseId, $containerId, $count) {
$container = $this->client->call(
Client::METHOD_GET,
$this->getContainerUrl($databaseId, $containerId),
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
])
);
$this->assertEquals(200, $container['headers']['status-code']);
$this->assertArrayHasKey('body', $container);
$this->assertArrayHasKey($this->getSchemaResource(), $container['body']);
$attributes = $container['body'][$this->getSchemaResource()];
$availableCount = 0;
foreach ($attributes as $attr) {
if ($attr['status'] === 'failed') {
throw new Critical("Attribute '{$attr['key']}' failed: " . ($attr['error'] ?? 'unknown error'));
}
if ($attr['status'] === 'available') {
$availableCount++;
}
}
$this->assertGreaterThanOrEqual($count, $availableCount, "Expected at least $count available attributes, got $availableCount");
}, $timeoutMs, $waitMs);
}
/**
* Wait for an index to become available.
*
-42
View File
@@ -130,22 +130,6 @@ abstract class Scope extends TestCase
return $this->getConsoleVariables()['supportForMultipleFulltextIndexes'] ?? true;
}
/**
* Check if the database adapter supports resizing attributes
*/
protected function getSupportForAttributeResizing(): bool
{
return $this->getConsoleVariables()['supportForAttributeResizing'] ?? true;
}
/**
* Check if the database adapter supports fixed schemas with row width limits
*/
protected function getSupportForSchemas(): bool
{
return $this->getConsoleVariables()['supportForSchemas'] ?? true;
}
/**
* Check if the database adapter supports attributes
*/
@@ -162,14 +146,6 @@ abstract class Scope extends TestCase
return $this->getConsoleVariables()['maxIndexLength'] ?? 767;
}
/**
* Check if the database adapter uses integer sequence IDs
*/
protected function getSupportForIntegerIds(): bool
{
return $this->getConsoleVariables()['supportForIntegerIds'] ?? true;
}
protected function getLastEmail(int $limit = 1, ?callable $probe = null): array
{
$result = [];
@@ -274,24 +250,6 @@ abstract class Scope extends TestCase
return [];
}
protected function assertLastRequest(callable $probe, string $type, $timeoutMs = 20_000, $waitMs = 500): array
{
$hostname = match ($type) {
'webhook' => 'request-catcher-webhook',
'sms' => 'request-catcher-sms',
default => throw new \Exception('Invalid request catcher type.'),
};
$this->assertEventually(function () use (&$request, $probe, $hostname) {
$request = json_decode(file_get_contents('http://' . $hostname . ':5000/__last_request__'), true);
$request['data'] = json_decode($request['data'], true);
call_user_func($probe, $request);
}, $timeoutMs, $waitMs);
return $request;
}
protected function assertSamePixels(string $expectedImagePath, string $actualImageBlob): void
{
$expected = new \Imagick($expectedImagePath);
-8
View File
@@ -8,12 +8,4 @@ trait SideNone
{
return [];
}
/**
* @return string
*/
public function getSide()
{
return 'none';
}
}
@@ -195,46 +195,6 @@ trait FunctionsBase
return $variable;
}
protected function getVariable(string $functionId, string $variableId): mixed
{
$variable = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/variables/' . $variableId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
return $variable;
}
protected function updateVariable(string $functionId, string $variableId, mixed $params): mixed
{
$variable = $this->client->call(Client::METHOD_PUT, '/functions/' . $functionId . '/variables/' . $variableId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), $params);
return $variable;
}
protected function listVariables(string $functionId, mixed $params = []): mixed
{
$variables = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/variables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), $params);
return $variables;
}
protected function deleteVariable(string $functionId, string $variableId): mixed
{
$variable = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId . '/variables/' . $variableId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
return $variable;
}
protected function getFunction(string $functionId): mixed
{
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId, array_merge([
@@ -255,16 +215,6 @@ trait FunctionsBase
return $deployment;
}
protected function getExecution(string $functionId, $executionId): mixed
{
$execution = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $executionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
return $execution;
}
protected function listFunctions(mixed $params = []): mixed
{
$functions = $this->client->call(Client::METHOD_GET, '/functions', array_merge([
@@ -285,16 +235,6 @@ trait FunctionsBase
return $deployments;
}
protected function listExecutions(string $functionId, mixed $params = []): mixed
{
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), $params);
return $executions;
}
protected function packageFunction(string $function): CURLFile
{
$folderPath = realpath(__DIR__ . '/../../../resources/functions') . "/$function";
@@ -447,27 +387,6 @@ trait FunctionsBase
return $response;
}
protected function setupDuplicateDeployment(string $functionId, string $deploymentId): string
{
$deployment = $this->createDuplicateDeployment($functionId, $deploymentId);
$this->assertEquals(202, $deployment['headers']['status-code']);
$deploymentId = $deployment['body']['$id'];
$this->assertNotEmpty($deploymentId);
$this->assertEventually(function () use ($functionId, $deploymentId) {
$deployment = $this->getDeployment($functionId, $deploymentId);
$this->assertEquals('ready', $deployment['body']['status'], 'Deployment status is not ready, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
}, 100000, 500);
$this->assertEventually(function () use ($functionId, $deploymentId) {
$function = $this->getFunction($functionId);
$this->assertEquals($deploymentId, $function['body']['deploymentId'], 'Deployment is not activated, deployment: ' . json_encode($function['body'], JSON_PRETTY_PRINT));
}, 100000, 500);
return $deploymentId;
}
protected function createDuplicateDeployment(string $functionId, string $deploymentId): mixed
{
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments/duplicate', array_merge([
-6
View File
@@ -46,9 +46,6 @@ trait Base
public const string CREATE_IP_ATTRIBUTE = 'create_ip_attribute';
public const string CREATE_ENUM_ATTRIBUTE = 'create_enum_attribute';
public const string CREATE_DATETIME_ATTRIBUTE = 'create_datetime_attribute';
public const string CREATE_POINT_ATTRIBUTE = 'create_point_attribute';
public const string CREATE_LINE_ATTRIBUTE = 'create_line_attribute';
public const string CREATE_POLYGON_ATTRIBUTE = 'create_polygon_attribute';
public const string CREATE_RELATIONSHIP_ATTRIBUTE = 'create_relationship_attribute';
public const string UPDATE_STRING_ATTRIBUTE = 'update_string_attribute';
@@ -60,9 +57,6 @@ trait Base
public const string UPDATE_IP_ATTRIBUTE = 'update_ip_attribute';
public const string UPDATE_ENUM_ATTRIBUTE = 'update_enum_attribute';
public const string UPDATE_DATETIME_ATTRIBUTE = 'update_datetime_attribute';
public const string UPDATE_POINT_ATTRIBUTE = 'update_point_attribute';
public const string UPDATE_LINE_ATTRIBUTE = 'update_line_attribute';
public const string UPDATE_POLYGON_ATTRIBUTE = 'update_polygon_attribute';
public const string UPDATE_RELATIONSHIP_ATTRIBUTE = 'update_relationship_attribute';
public const string GET_ATTRIBUTES = 'get_attributes';
@@ -651,42 +651,6 @@ final class DatabaseServerTest extends Scope
return self::$cachedRelationshipColumnData[$cacheKey];
}
protected function setupUpdatedRelationshipColumn(): array
{
$data = $this->setupRelationshipColumn();
$projectId = $this->getProject()['$id'];
$databaseId = $data['database']['_id'];
$tableId = $data['table2']['_id'];
$this->assertEventually(function () use ($databaseId, $tableId) {
$response = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns/actors', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]));
$this->assertEquals('available', $response['body']['status']);
}, 240000, 500);
$query = $this->getQuery(self::UPDATE_RELATIONSHIP_COLUMN);
$gqlPayload = [
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'tableId' => $tableId,
'key' => 'actors',
'onDelete' => Database::RELATION_MUTATE_CASCADE,
]
];
$this->client->call(Client::METHOD_POST, '/graphql', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
return $data;
}
protected function setupIPColumn(): array
{
$cacheKey = $this->getProject()['$id'] ?? 'default';
@@ -717,43 +681,6 @@ final class DatabaseServerTest extends Scope
return self::$cachedIPColumnData[$cacheKey];
}
protected function setupUpdatedIPColumn(): array
{
$data = $this->setupIPColumn();
$projectId = $this->getProject()['$id'];
$databaseId = $data['database']['_id'];
$tableId = $data['table']['_id'];
$this->assertEventually(function () use ($databaseId, $tableId) {
$response = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns/ip', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]));
$this->assertEquals('available', $response['body']['status']);
}, 240000, 500);
$query = $this->getQuery(self::UPDATE_IP_COLUMN);
$gqlPayload = [
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'tableId' => $tableId,
'key' => 'ip',
'required' => false,
'default' => '127.0.0.1'
]
];
$this->client->call(Client::METHOD_POST, '/graphql', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
return $data;
}
protected function setupURLColumn(): array
{
$cacheKey = $this->getProject()['$id'] ?? 'default';
@@ -784,43 +711,6 @@ final class DatabaseServerTest extends Scope
return self::$cachedURLColumnData[$cacheKey];
}
protected function setupUpdatedURLColumn(): array
{
$data = $this->setupURLColumn();
$projectId = $this->getProject()['$id'];
$databaseId = $data['database']['_id'];
$tableId = $data['table']['_id'];
$this->assertEventually(function () use ($databaseId, $tableId) {
$response = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns/url', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]));
$this->assertEquals('available', $response['body']['status']);
}, 240000, 500);
$query = $this->getQuery(self::UPDATE_URL_COLUMN);
$gqlPayload = [
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'tableId' => $tableId,
'key' => 'url',
'required' => false,
'default' => 'https://cloud.appwrite.io'
]
];
$this->client->call(Client::METHOD_POST, '/graphql', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
return $data;
}
protected function setupIndex(): array
{
$cacheKey = $this->getProject()['$id'] ?? 'default';
@@ -19,11 +19,6 @@ trait RealtimeQueryBase
use ProjectCustom;
use SideClient;
protected function supportForCheckConnectionStatus(): bool
{
return false;
}
private function assertConnectionStatusIfSupported($client): ?array
{
if (!$this->supportForCheckConnectionStatus()) {
-72
View File
@@ -210,16 +210,6 @@ trait SitesBase
return $deployment;
}
protected function getLog(string $siteId, $logId): mixed
{
$log = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs/' . $logId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
return $log;
}
protected function listSites(mixed $params = []): mixed
{
$sites = $this->client->call(Client::METHOD_GET, '/sites', array_merge([
@@ -240,18 +230,6 @@ trait SitesBase
return $deployments;
}
protected function listLogs(string $siteId, array $queries = []): mixed
{
$logs = $this->client->call(Client::METHOD_GET, '/sites/' . $siteId . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => $queries
]);
return $logs;
}
protected function packageSite(string $site): CURLFile
{
$folderPath = realpath(__DIR__ . '/../../../resources/sites') . "/$site";
@@ -286,27 +264,6 @@ trait SitesBase
return $deployment;
}
protected function setupDuplicateDeployment(string $siteId, string $deploymentId): string
{
$deployment = $this->createDuplicateDeployment($siteId, $deploymentId);
$this->assertEquals(202, $deployment['headers']['status-code']);
$deploymentId = $deployment['body']['$id'];
$this->assertNotEmpty($deploymentId);
$this->assertEventually(function () use ($siteId, $deploymentId) {
$deployment = $this->getDeployment($siteId, $deploymentId);
$this->assertEquals('ready', $deployment['body']['status'], 'Deployment status is not ready, deployment: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT));
}, 120000, 500);
$this->assertEventually(function () use ($siteId, $deploymentId) {
$site = $this->getSite($siteId);
$this->assertEquals($deploymentId, $site['body']['deploymentId'], 'Deployment is not activated, deployment: ' . json_encode($site['body'], JSON_PRETTY_PRINT));
}, 60000, 500);
return $deploymentId;
}
protected function createDuplicateDeployment(string $siteId, string $deploymentId): mixed
{
$deployment = $this->client->call(Client::METHOD_POST, '/sites/' . $siteId . '/deployments/duplicate', array_merge([
@@ -339,35 +296,6 @@ trait SitesBase
return $template;
}
protected function helperGetLatestCommit(string $owner, string $repository): ?string
{
$maxRetries = 3;
for ($attempt = 0; $attempt < $maxRetries; $attempt++) {
if ($attempt > 0) {
sleep(2);
}
$ch = curl_init("https://api.github.com/repos/{$owner}/{$repository}/commits/main");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User-Agent: Appwrite',
'Accept: application/vnd.github.v3+json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode === 200) {
$commitData = json_decode($response, true);
if (isset($commitData['sha'])) {
return $commitData['sha'];
}
}
}
return null;
}
protected function deleteSite(string $siteId): mixed
{
$site = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, array_merge([
-8
View File
@@ -84,12 +84,4 @@ class RetrySubscriber implements FailedSubscriber
return 0;
}
}
/**
* Reset retry counts between test runs (useful for testing)
*/
public static function reset(): void
{
self::$retryCounts = [];
}
}
-22
View File
@@ -12,26 +12,4 @@ namespace Appwrite\Tests;
*/
trait Retryable
{
/**
* Get the number of retries configured for the current test method.
*
* @return int
* @throws \ReflectionException
*/
public function getNumberOfRetries(): int
{
$root = new \ReflectionClass($this);
$name = $this->name();
if (!$root->hasMethod($name)) {
return 0;
}
$method = $root->getMethod($name);
$attributes = $method->getAttributes(Retry::class);
$attribute = $attributes[0] ?? null;
$args = $attribute?->getArguments();
$retries = $args['count'] ?? $args[0] ?? 0;
return \max(0, $retries);
}
}
@@ -146,19 +146,4 @@ final class V17Test extends TestCase
$this->assertEquals($expected, $result);
}
public static function webhookProvider(): array
{
return [
'remove webhook additions' => [
[
'enabled' => true,
'logs' => ['test', 'test'],
'attempts' => 1
],
[
],
],
];
}
}