updated routes and endpoints

This commit is contained in:
ArnabChatterjee20k
2025-10-03 19:51:00 +05:30
parent 7d4dfe06e2
commit df23aacbc0
55 changed files with 180 additions and 151 deletions
Generated
+19 -19
View File
@@ -1236,16 +1236,16 @@
},
{
"name": "open-telemetry/api",
"version": "1.6.0",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/api.git",
"reference": "ee17d937652eca06c2341b6fadc0f74c1c1a5af2"
"reference": "610b79ad9d6d97e8368bcb6c4d42394fbb87b522"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/api/zipball/ee17d937652eca06c2341b6fadc0f74c1c1a5af2",
"reference": "ee17d937652eca06c2341b6fadc0f74c1c1a5af2",
"url": "https://api.github.com/repos/opentelemetry-php/api/zipball/610b79ad9d6d97e8368bcb6c4d42394fbb87b522",
"reference": "610b79ad9d6d97e8368bcb6c4d42394fbb87b522",
"shasum": ""
},
"require": {
@@ -1265,7 +1265,7 @@
]
},
"branch-alias": {
"dev-main": "1.4.x-dev"
"dev-main": "1.7.x-dev"
}
},
"autoload": {
@@ -1302,7 +1302,7 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2025-09-19T00:05:49+00:00"
"time": "2025-10-02T23:44:28+00:00"
},
{
"name": "open-telemetry/context",
@@ -1492,22 +1492,22 @@
},
{
"name": "open-telemetry/sdk",
"version": "1.8.0",
"version": "1.9.0",
"source": {
"type": "git",
"url": "https://github.com/opentelemetry-php/sdk.git",
"reference": "105c6e81e3d86150bd5704b00c7e4e165e957b89"
"reference": "8986bcbcbea79cb1ba9e91c1d621541ad63d6b3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/105c6e81e3d86150bd5704b00c7e4e165e957b89",
"reference": "105c6e81e3d86150bd5704b00c7e4e165e957b89",
"url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/8986bcbcbea79cb1ba9e91c1d621541ad63d6b3e",
"reference": "8986bcbcbea79cb1ba9e91c1d621541ad63d6b3e",
"shasum": ""
},
"require": {
"ext-json": "*",
"nyholm/psr7-server": "^1.1",
"open-telemetry/api": "^1.6",
"open-telemetry/api": "^1.7",
"open-telemetry/context": "^1.4",
"open-telemetry/sem-conv": "^1.0",
"php": "^8.1",
@@ -1542,7 +1542,7 @@
]
},
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-main": "1.9.x-dev"
}
},
"autoload": {
@@ -1585,7 +1585,7 @@
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
"source": "https://github.com/open-telemetry/opentelemetry-php"
},
"time": "2025-09-19T00:05:49+00:00"
"time": "2025-10-02T23:44:28+00:00"
},
{
"name": "open-telemetry/sem-conv",
@@ -5224,16 +5224,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "1.4.2",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "07a7d6276bd684b49469ad7b9e8c3c962121c6fd"
"reference": "e1ca749398189f36ec6d6afb8e9f64e9cb37e0a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/07a7d6276bd684b49469ad7b9e8c3c962121c6fd",
"reference": "07a7d6276bd684b49469ad7b9e8c3c962121c6fd",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/e1ca749398189f36ec6d6afb8e9f64e9cb37e0a3",
"reference": "e1ca749398189f36ec6d6afb8e9f64e9cb37e0a3",
"shasum": ""
},
"require": {
@@ -5269,9 +5269,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/1.4.2"
"source": "https://github.com/appwrite/sdk-generator/tree/1.4.3"
},
"time": "2025-10-01T03:23:04+00:00"
"time": "2025-10-01T06:25:19+00:00"
},
{
"name": "doctrine/annotations",
@@ -3,7 +3,6 @@
namespace Appwrite\Platform\Modules\Databases\Http\Databases;
use Utopia\Platform\Action as UtopiaAction;
use Utopia\System\System;
class Action extends UtopiaAction
{
@@ -14,26 +13,6 @@ class Action extends UtopiaAction
return $this->context;
}
public function getDatabaseDSN(): string
{
$database = System::getEnv('_APP_DATABASE_NAME', 'appwrite');
$namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', '');
$schema = match ($this->context) {
'documentsdb' => 'mongodb',
'tablesdb' => 'mysql',
default => 'mysql',
};
$dsn = $schema . '://' . $database;
if (!empty($namespace)) {
$dsn .= '?namespace=' . $namespace;
}
return $dsn;
}
public function setHttpPath(string $path): UtopiaAction
{
if (\str_contains($path, '/tablesdb')) {
@@ -76,12 +76,12 @@ class Create extends Action
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents): void
public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
@@ -109,12 +109,14 @@ class Create extends Action
throw new Exception($this->getDuplicateException());
} catch (LimitException) {
throw new Exception($this->getLimitException());
} catch (NotFoundException $e) {
} catch (NotFoundException) {
throw new Exception(Exception::DATABASE_NOT_FOUND);
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
try {
$dbForDatabaseRecords->createCollection(
$dbForDatabase->createCollection(
id: 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
permissions: $permissions,
documentSecurity: $documentSecurity
@@ -62,13 +62,13 @@ class Delete extends Action
->param('collectionId', '', new UID(), 'Collection ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, EventDatabase $queueForDatabase, Event $queueForEvents): void
public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, EventDatabase $queueForDatabase, Event $queueForEvents): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
if ($database->isEmpty()) {
@@ -85,7 +85,8 @@ class Delete extends Action
throw new Exception(Exception::GENERAL_SERVER_ERROR, "Failed to remove $type from DB");
}
$dbForDatabaseRecords->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence());
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$dbForDatabase->purgeCachedCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence());
$queueForDatabase
->setType(DATABASE_TYPE_DELETE_COLLECTION)
@@ -77,13 +77,13 @@ class Decrement extends Action
->param('min', null, new Numeric(), 'Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $min, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $min, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
if ($database->isEmpty()) {
@@ -95,8 +95,10 @@ class Decrement extends Action
throw new Exception($this->getParentNotFoundException());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
try {
$document = $dbForDatabaseRecords->decreaseDocumentAttribute(
$document = $dbForDatabase->decreaseDocumentAttribute(
collection: 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
id: $documentId,
attribute: $attribute,
@@ -77,13 +77,13 @@ class Increment extends Action
->param('max', null, new Numeric(), 'Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $max, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $max, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
if ($database->isEmpty()) {
@@ -95,8 +95,10 @@ class Increment extends Action
throw new Exception($this->getParentNotFoundException());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
try {
$document = $dbForDatabaseRecords->increaseDocumentAttribute(
$document = $dbForDatabase->increaseDocumentAttribute(
collection: 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
id: $documentId,
attribute: $attribute,
@@ -105,7 +107,7 @@ class Increment extends Action
);
} catch (ConflictException) {
throw new Exception($this->getConflictException());
} catch (NotFoundException $e) {
} catch (NotFoundException) {
throw new Exception($this->getStructureNotFoundException());
} catch (LimitException) {
throw new Exception($this->getLimitException(), $this->getSdkNamespace() . ' "' . $attribute . '" has reached the maximum value of ' . $max);
@@ -72,7 +72,7 @@ class Delete extends Action
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -82,7 +82,7 @@ class Delete extends Action
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
{
$database = $dbForProject->getDocument('databases', $databaseId);
if ($database->isEmpty()) {
@@ -109,10 +109,12 @@ class Delete extends Action
throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$documents = [];
try {
$modified = $dbForDatabaseRecords->deleteDocuments(
$modified = $dbForDatabase->deleteDocuments(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
$queries,
onNext: function (Document $document) use ($plan, &$documents) {
@@ -76,7 +76,7 @@ class Update extends Action
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -86,7 +86,7 @@ class Update extends Action
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string|array $data, array $queries, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
public function action(string $databaseId, string $collectionId, string|array $data, array $queries, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
{
$data = \is_string($data)
? \json_decode($data, true)
@@ -130,11 +130,13 @@ class Update extends Action
$data = $this->removeReadonlyAttributes($data, privileged: true);
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$documents = [];
try {
$modified = $dbForDatabaseRecords->withPreserveDates(function () use ($plan, &$documents, $dbForDatabaseRecords, $database, $collection, $data, $queries) {
return $dbForDatabaseRecords->updateDocuments(
$modified = $dbForDatabase->withPreserveDates(function () use ($plan, &$documents, $dbForDatabase, $database, $collection, $data, $queries) {
return $dbForDatabase->updateDocuments(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
new Document($data),
$queries,
@@ -74,7 +74,7 @@ class Upsert extends Action
->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of document data as JSON objects. May contain partial documents.', false, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -84,7 +84,7 @@ class Upsert extends Action
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, array $documents, UtopiaResponse $response, Database $dbForProject, Database $databasebForDatabaseRecords, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
public function action(string $databaseId, string $collectionId, array $documents, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, StatsUsage $queueForStatsUsage, Event $queueForEvents, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void
{
$database = $dbForProject->getDocument('databases', $databaseId);
if ($database->isEmpty()) {
@@ -110,11 +110,13 @@ class Upsert extends Action
$documents[$key] = new Document($document);
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$upserted = [];
try {
$modified = $databasebForDatabaseRecords->withPreserveDates(function () use ($databasebForDatabaseRecords, $database, $collection, $documents, $plan, &$upserted) {
return $databasebForDatabaseRecords->upsertDocuments(
$modified = $dbForDatabase->withPreserveDates(function () use ($dbForDatabase, $database, $collection, $documents, $plan, &$upserted) {
return $dbForDatabase->upsertDocuments(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
$documents,
onNext: function (Document $document) use ($plan, &$upserted) {
@@ -121,7 +121,7 @@ class Create extends Action
->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of documents data as JSON objects.', true, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('user')
->inject('queueForEvents')
->inject('queueForStatsUsage')
@@ -130,7 +130,7 @@ class Create extends Action
->inject('queueForWebhooks')
->callback($this->action(...));
}
public function action(string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, ?array $documents, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Document $user, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks): void
public function action(string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, ?array $documents, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Document $user, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks): void
{
$data = \is_string($data)
? \json_decode($data, true)
@@ -362,11 +362,13 @@ class Create extends Action
return $document;
}, $documents);
$dbForDatabase = call_user_func($getDatabaseDB, $database);
try {
$created = [];
$dbForDatabaseRecords->withPreserveDates(
function () use (&$created, $dbForDatabaseRecords, $database, $collection, $documents) {
$dbForDatabaseRecords->createDocuments(
$dbForDatabase->withPreserveDates(
function () use (&$created, $dbForDatabase, $database, $collection, $documents) {
$dbForDatabase->createDocuments(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
$documents,
onNext: function ($doc) use (&$created) {
@@ -74,13 +74,13 @@ class Delete extends Action
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
@@ -97,16 +97,18 @@ class Delete extends Action
throw new Exception($this->getParentNotFoundException());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
// Read permission should not be required for delete
$document = Authorization::skip(fn () => $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
$document = Authorization::skip(fn () => $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
if ($document->isEmpty()) {
throw new Exception($this->getNotFoundException());
}
try {
$dbForDatabaseRecords->withRequestTimestamp($requestTimestamp, function () use ($dbForDatabaseRecords, $database, $collection, $documentId) {
$dbForDatabaseRecords->deleteDocument(
$dbForDatabase->withRequestTimestamp($requestTimestamp, function () use ($dbForDatabase, $database, $collection, $documentId) {
$dbForDatabase->deleteDocument(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
$documentId
);
@@ -65,12 +65,12 @@ class Get extends Action
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, array $queries, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, array $queries, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, StatsUsage $queueForStatsUsage): void
{
$isAPIKey = Auth::isAppUser(Authorization::getRoles());
$isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles());
@@ -82,6 +82,8 @@ class Get extends Action
$collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId));
$dbForDatabase = call_user_func($getDatabaseDB, $database);
if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
throw new Exception($this->getParentNotFoundException());
}
@@ -97,10 +99,10 @@ class Get extends Action
if (! empty($selects)) {
// has selects, allow relationship on documents!
$document = $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId, $queries);
$document = $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId, $queries);
} else {
// has no selects, disable relationship looping on documents!
$document = $dbForDatabaseRecords->skipRelationships(fn () => $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId, $queries));
$document = $dbForDatabase->skipRelationships(fn () => $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId, $queries));
}
} catch (QueryException $e) {
throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage());
@@ -80,13 +80,13 @@ class Update extends Action
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
{
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
@@ -110,9 +110,11 @@ class Update extends Action
throw new Exception($this->getParentNotFoundException());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
// Read permission should not be required for update
/** @var Document $document */
$document = Authorization::skip(fn () => $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
$document = Authorization::skip(fn () => $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
if ($document->isEmpty()) {
throw new Exception($this->getNotFoundException());
@@ -233,9 +235,9 @@ class Update extends Action
->addMetric(str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations);
try {
$document = $dbForDatabaseRecords->withRequestTimestamp(
$document = $dbForDatabase->withRequestTimestamp(
$requestTimestamp,
fn () => $dbForDatabaseRecords->withPreserveDates(fn () => $dbForDatabaseRecords->updateDocument(
fn () => $dbForDatabase->withPreserveDates(fn () => $dbForDatabase->updateDocument(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
$document->getId(),
$newDocument
@@ -84,13 +84,13 @@ class Upsert extends Action
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?\DateTime $requestTimestamp, UtopiaResponse $response, Document $user, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?\DateTime $requestTimestamp, UtopiaResponse $response, Document $user, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents, StatsUsage $queueForStatsUsage): void
{
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
@@ -115,6 +115,8 @@ class Upsert extends Action
throw new Exception($this->getParentNotFoundException());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$allowedPermissions = [
Database::PERMISSION_READ,
Database::PERMISSION_UPDATE,
@@ -125,7 +127,7 @@ class Upsert extends Action
// If no permission, upsert permission from the old document if present (update scenario) else add default permission (create scenario)
if (\is_null($permissions)) {
$oldDocument = Authorization::skip(fn () => $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
$oldDocument = Authorization::skip(fn () => $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
if ($oldDocument->isEmpty()) {
if (!empty($user->getId())) {
$defaultPermissions = [];
@@ -166,7 +168,7 @@ class Upsert extends Action
$newDocument = new Document($data);
$operations = 0;
$setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $dbForDatabaseRecords, $database, &$operations) {
$setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $dbForDatabase, $database, &$operations) {
$operations++;
$relationships = \array_filter(
@@ -207,7 +209,7 @@ class Upsert extends Action
if ($relation instanceof Document) {
$relation = $this->removeReadonlyAttributes($relation, $isAPIKey || $isPrivilegedUser);
$oldDocument = Authorization::skip(fn () => $dbForDatabaseRecords->getDocument(
$oldDocument = Authorization::skip(fn () => $dbForDatabase->getDocument(
'database_' . $database->getSequence() . '_collection_' . $relatedCollection->getSequence(),
$relation->getId()
));
@@ -243,8 +245,8 @@ class Upsert extends Action
$upserted = [];
try {
$dbForDatabaseRecords->withPreserveDates(function () use (&$upserted, $dbForDatabaseRecords, $database, $collection, $newDocument) {
return $dbForDatabaseRecords->upsertDocuments(
$dbForDatabase->withPreserveDates(function () use (&$upserted, $dbForDatabase, $database, $collection, $newDocument) {
return $dbForDatabase->upsertDocuments(
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
[$newDocument],
onNext: function (Document $document) use (&$upserted) {
@@ -265,7 +267,7 @@ class Upsert extends Action
$collectionsCache = [];
if (empty($upserted[0])) {
$upserted[0] = $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId);
$upserted[0] = $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId);
}
$document = $upserted[0];
@@ -67,12 +67,12 @@ class XList extends Action
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, StatsUsage $queueForStatsUsage): void
public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, StatsUsage $queueForStatsUsage): void
{
$isAPIKey = Auth::isAppUser(Authorization::getRoles());
$isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles());
@@ -93,6 +93,8 @@ class XList extends Action
throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage());
}
$dbForDatabase = call_user_func($getDatabaseDB, $database);
/**
* Get cursor document if there was a cursor query, we use array_filter and reset for reference $cursor to $queries
*/
@@ -110,7 +112,7 @@ class XList extends Action
$documentId = $cursor->getValue();
$cursorDocument = Authorization::skip(fn () => $dbForDatabaseRecords->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
$cursorDocument = Authorization::skip(fn () => $dbForDatabase->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId));
if ($cursorDocument->isEmpty()) {
$type = ucfirst($this->getContext());
@@ -125,14 +127,14 @@ class XList extends Action
if (! empty($selectQueries)) {
// has selects, allow relationship on documents
$documents = $dbForDatabaseRecords->find('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries);
$documents = $dbForDatabase->find('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries);
} else {
// has no selects, disable relationship loading on documents
/* @type Document[] $documents */
$documents = $dbForDatabaseRecords->skipRelationships(fn () => $dbForDatabaseRecords->find('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries));
$documents = $dbForDatabase->skipRelationships(fn () => $dbForDatabase->find('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries));
}
$total = $dbForDatabaseRecords->count('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries, APP_LIMIT_COUNT);
$total = $dbForDatabase->count('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $queries, APP_LIMIT_COUNT);
} catch (OrderException $e) {
$documents = $this->isCollectionsAPI() ? 'documents' : 'rows';
$attribute = $this->isCollectionsAPI() ? 'attribute' : 'column';
@@ -77,13 +77,13 @@ class Create extends Action
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders, array $lengths, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, EventDatabase $queueForDatabase, Event $queueForEvents): void
public function action(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders, array $lengths, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, EventDatabase $queueForDatabase, Event $queueForEvents): void
{
$db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
@@ -103,7 +103,9 @@ class Create extends Action
Query::equal('databaseInternalId', [$db->getSequence()])
], 61);
$limit = $dbForDatabaseRecords->getLimitForIndexes();
$dbForDatabase = call_user_func($getDatabaseDB, $db);
$limit = $dbForDatabase->getLimitForIndexes();
if ($count >= $limit) {
throw new Exception($this->getLimitException(), 'Index limit exceeded');
@@ -144,7 +146,7 @@ class Create extends Action
];
$contextType = $this->getParentContext();
if ($dbForDatabaseRecords->getAdapter()->getSupportForAttributes()) {
if ($dbForDatabase->getAdapter()->getSupportForAttributes()) {
foreach ($attributes as $i => $attribute) {
// find attribute metadata in collection document
$attributeIndex = \array_search($attribute, array_column($oldAttributes, 'key'));
@@ -208,9 +210,9 @@ class Create extends Action
$supportForSpatialAttributes,
$supportForSpatialIndexNull,
$supportForSpatialIndexOrder,
$dbForDatabaseRecords->getAdapter()->getSupportForAttributes(),
$dbForDatabaseRecords->getAdapter()->getSupportForMultipleFulltextIndexes(),
$dbForDatabaseRecords->getAdapter()->getSupportForIdenticalIndexes(),
$dbForDatabase->getAdapter()->getSupportForAttributes(),
$dbForDatabase->getAdapter()->getSupportForMultipleFulltextIndexes(),
$dbForDatabase->getAdapter()->getSupportForIdenticalIndexes(),
);
if (!$validator->isValid($index)) {
@@ -69,12 +69,12 @@ class Update extends Action
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords, Event $queueForEvents): void
public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB, Event $queueForEvents): void
{
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
if ($database->isEmpty()) {
@@ -104,7 +104,9 @@ class Update extends Action
->setAttribute('search', \implode(' ', [$collectionId, $name]))
);
$dbForDatabaseRecords->updateCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $permissions, $documentSecurity);
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$dbForDatabase->updateCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $permissions, $documentSecurity);
$queueForEvents
->setContext('database', $database)
@@ -63,15 +63,16 @@ class Get extends Action
->param('collectionId', '', new UID(), 'Collection ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->callback($this->action(...));
}
public function action(string $databaseId, string $range, string $collectionId, UtopiaResponse $response, Database $dbForProject, Database $dbForDatabaseRecords): void
public function action(string $databaseId, string $range, string $collectionId, UtopiaResponse $response, Database $dbForProject, callable $getDatabaseDB): void
{
$database = $dbForProject->getDocument('databases', $databaseId);
$collectionDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId);
$collection = $dbForDatabaseRecords->getCollection('database_' . $database->getSequence() . '_collection_' . $collectionDocument->getSequence());
$dbForDatabase = call_user_func($getDatabaseDB, $database);
$collection = $dbForDatabase->getCollection('database_' . $database->getSequence() . '_collection_' . $collectionDocument->getSequence());
if ($collection->isEmpty()) {
throw new Exception($this->getNotFoundException());
@@ -20,6 +20,7 @@ use Utopia\Database\Exception\Limit as LimitException;
use Utopia\Database\Exception\Structure as StructureException;
use Utopia\Database\Helpers\ID;
use Utopia\Swoole\Response as SwooleResponse;
use Utopia\System\System;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text;
@@ -30,6 +31,25 @@ class Create extends Action
return 'createDatabase';
}
protected function getDatabaseDSN(): string
{
$database = System::getEnv('_APP_DATABASE_NAME', 'appwrite');
$namespace = System::getEnv('_APP_DATABASE_SHARED_NAMESPACE', '');
$schema = match ($this->getDatabaseType()) {
'documentsdb' => System::getEnv('_APP_DB_HOST_DOCUMENTSDB', 'mongodb'),
default => System::getEnv('_APP_DB_HOST', 'mariadb'),
};
$dsn = $schema . '://' . $database;
if (!empty($namespace)) {
$dsn .= '?namespace=' . $namespace;
}
return $dsn;
}
public function __construct()
{
$this
@@ -42,7 +42,7 @@ class Create extends CollectionCreate
->label('sdk', new Method(
namespace: 'documentsdb',
group: 'collections',
name: self::getName(),
name: 'createCollection',
description: '/docs/references/documentsdb/create-collection.md',
auth: [AuthType::KEY],
responses: [
@@ -61,7 +61,7 @@ class Create extends CollectionCreate
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
@@ -38,7 +38,7 @@ class Delete extends CollectionDelete
->label('sdk', new Method(
namespace: 'documentsdb',
group: 'collections',
name: self::getName(),
name: 'deleteCollection',
description: '/docs/references/documentsdb/delete-collection.md',
auth: [AuthType::KEY],
responses: [
@@ -53,7 +53,7 @@ class Delete extends CollectionDelete
->param('collectionId', '', new UID(), 'Collection ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
@@ -62,7 +62,7 @@ class Decrement extends DecrementDocumentAttribute
->param('min', null, new Numeric(), 'Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -62,7 +62,7 @@ class Increment extends IncrementDocumentAttribute
->param('max', null, new Numeric(), 'Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -58,7 +58,7 @@ class Delete extends DocumentsDelete
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -60,7 +60,7 @@ class Update extends DocumentsUpdate
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -60,7 +60,7 @@ class Upsert extends DocumentsUpsert
->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of document data as JSON objects. May contain partial documents.', false, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -100,7 +100,7 @@ class Create extends DocumentCreate
->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of documents data as JSON objects.', true, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('user')
->inject('queueForEvents')
->inject('queueForStatsUsage')
@@ -64,7 +64,7 @@ class Delete extends DocumentDelete
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -54,7 +54,7 @@ class Get extends DocumentGet
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
@@ -63,7 +63,7 @@ class Update extends DocumentUpdate
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -66,7 +66,7 @@ class Upsert extends DocumentUpsert
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -53,7 +53,7 @@ class XList extends DocumentXList
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
@@ -35,7 +35,7 @@ class Get extends CollectionGet
->label('sdk', new Method(
namespace: 'documentsdb',
group: 'collections',
name: self::getName(),
name: 'getCollection',
description: '/docs/references/documentsdb/get-collection.md',
auth: [AuthType::KEY],
responses: [
@@ -64,7 +64,7 @@ class Create extends IndexCreate
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
@@ -41,7 +41,7 @@ class Update extends CollectionUpdate
->label('sdk', new Method(
namespace: 'documentsdb',
group: 'collections',
name: self::getName(),
name: 'updateCollection',
description: '/docs/references/documentsdb/update-collection.md',
auth: [AuthType::KEY],
responses: [
@@ -60,7 +60,7 @@ class Update extends CollectionUpdate
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
@@ -52,7 +52,7 @@ class Get extends CollectionUsageGet
->param('collectionId', '', new UID(), 'Collection ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->callback($this->action(...));
}
}
@@ -37,7 +37,7 @@ class XList extends CollectionXList
->label('sdk', new Method(
namespace: 'documentsdb',
group: 'collections',
name: self::getName(),
name: 'listCollections',
description: '/docs/references/documentsdb/list-collections.md',
auth: [AuthType::KEY],
responses: [
@@ -61,7 +61,7 @@ class Create extends CollectionCreate
->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
@@ -53,7 +53,7 @@ class Delete extends CollectionDelete
->param('tableId', '', new UID(), 'Table ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
@@ -64,7 +64,7 @@ class Create extends IndexCreate
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForDatabase')
->inject('queueForEvents')
->callback($this->action(...));
@@ -58,7 +58,7 @@ class Delete extends DocumentsDelete
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -60,7 +60,7 @@ class Update extends DocumentsUpdate
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -60,7 +60,7 @@ class Upsert extends DocumentsUpsert
->param('rows', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of row data as JSON objects. May contain partial rows.', false, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->inject('queueForEvents')
->inject('queueForRealtime')
@@ -62,7 +62,7 @@ class Decrement extends DecrementDocumentAttribute
->param('min', null, new Numeric(), 'Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -62,7 +62,7 @@ class Increment extends IncrementDocumentAttribute
->param('max', null, new Numeric(), 'Maximum value for the column. If the current value is greater than this value, an error will be thrown.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -100,7 +100,7 @@ class Create extends DocumentCreate
->param('rows', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of rows data as JSON objects.', true, ['plan'])
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('user')
->inject('queueForEvents')
->inject('queueForStatsUsage')
@@ -64,7 +64,7 @@ class Delete extends DocumentDelete
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -54,7 +54,7 @@ class Get extends DocumentGet
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
@@ -63,7 +63,7 @@ class Update extends DocumentUpdate
->inject('requestTimestamp')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -66,7 +66,7 @@ class Upsert extends DocumentUpsert
->inject('response')
->inject('user')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->inject('queueForStatsUsage')
->callback($this->action(...));
@@ -53,7 +53,7 @@ class XList extends DocumentXList
->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForStatsUsage')
->callback($this->action(...));
}
@@ -60,7 +60,7 @@ class Update extends CollectionUpdate
->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true)
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->inject('queueForEvents')
->callback($this->action(...));
}
@@ -52,7 +52,7 @@ class Get extends CollectionUsageGet
->param('tableId', '', new UID(), 'Table ID.')
->inject('response')
->inject('dbForProject')
->inject('dbForDatabaseRecords')
->inject('getDatabaseDB')
->callback($this->action(...));
}
}
@@ -6,7 +6,7 @@ use Appwrite\Platform\Modules\Databases\Http\Init\Timeout;
use Appwrite\Platform\Modules\Databases\Services\Registry\Collections as CollectionsRegistry;
use Appwrite\Platform\Modules\Databases\Services\Registry\Databases as DatabasesRegistry;
use Appwrite\Platform\Modules\Databases\Services\Registry\DocumentsDB as DocumentsDBRegistry;
use Appwrite\Platform\Modules\Databases\Services\Registry\Tables as TablesRegistry;
use Appwrite\Platform\Modules\Databases\Services\Registry\TablesDB as TablesDBRegistry;
use Utopia\Platform\Service;
class Http extends Service
@@ -20,7 +20,7 @@ class Http extends Service
foreach ([
DatabasesRegistry::class,
CollectionsRegistry::class,
TablesRegistry::class,
TablesDBRegistry::class,
DocumentsDBRegistry::class
] as $registrar) {
new $registrar($this);
@@ -72,7 +72,7 @@ use Utopia\Platform\Service;
* - Columns
* - Column-Indexes
*/
class Tables extends Base
class TablesDB extends Base
{
protected function register(Service $service): void
{