mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
(fix): resolve PermissionType enum, Method enum, VectorsDB and database library issues
- Use PermissionType->value when constructing Permission objects (Documents/Create, Upsert, Transactions/Create, Storage/Files/Create) - Convert Method enum to string in Realtime adapter implode and interpolation - Use Attribute/Index object property access in VectorsDB Collections/Create - Update utopia-php/database with Structure Float case, TenantFilter alias fix, and Document::getTenant() type cast removal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7de44f16b1
commit
a9fd6c6282
7 files changed
+30
-32
No files matched your search
Generated
+4
-4
@@ -4038,12 +4038,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "2444fe6006d173ccc655f9e00fc4b294a4217a30"
|
||||
"reference": "89e7afcc42863673766df3007c8f2feed31445e2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/2444fe6006d173ccc655f9e00fc4b294a4217a30",
|
||||
"reference": "2444fe6006d173ccc655f9e00fc4b294a4217a30",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/89e7afcc42863673766df3007c8f2feed31445e2",
|
||||
"reference": "89e7afcc42863673766df3007c8f2feed31445e2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4091,7 +4091,7 @@
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/feat-query-lib"
|
||||
},
|
||||
"time": "2026-03-31T05:55:38+00:00"
|
||||
"time": "2026-03-31T06:36:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
|
||||
@@ -415,7 +415,7 @@ class Realtime extends MessagingAdapter
|
||||
{
|
||||
$queries = Query::parseQueries($queries);
|
||||
$stack = $queries;
|
||||
$allowed = implode(', ', RuntimeQuery::ALLOWED_QUERIES);
|
||||
$allowed = implode(', ', array_map(fn (Method $m) => $m->value, RuntimeQuery::ALLOWED_QUERIES));
|
||||
|
||||
while (!empty($stack)) {
|
||||
$query = array_pop($stack);
|
||||
@@ -423,7 +423,7 @@ class Realtime extends MessagingAdapter
|
||||
|
||||
if (!in_array($method, RuntimeQuery::ALLOWED_QUERIES, true)) {
|
||||
throw new QueryException(
|
||||
"Query method '{$method}' is not supported in Realtime queries. Allowed: {$allowed}"
|
||||
"Query method '{$method->value}' is not supported in Realtime queries. Allowed: {$allowed}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ class Create extends Action
|
||||
$permissions = [];
|
||||
if (!empty($user->getId()) && !$isPrivilegedUser) {
|
||||
foreach ($allowedPermissions as $permission) {
|
||||
$permissions[] = (new Permission($permission, 'user', $user->getId()))->toString();
|
||||
$permissions[] = (new Permission($permission->value, 'user', $user->getId()))->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ class Upsert extends Action
|
||||
if (!empty($user->getId())) {
|
||||
$defaultPermissions = [];
|
||||
foreach ($allowedPermissions as $permission) {
|
||||
$defaultPermissions[] = (new Permission($permission, 'user', $user->getId()))->toString();
|
||||
$defaultPermissions[] = (new Permission($permission->value, 'user', $user->getId()))->toString();
|
||||
}
|
||||
$permissions = $defaultPermissions;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Create extends Action
|
||||
];
|
||||
|
||||
foreach ($allowedPermissions as $permission) {
|
||||
$permissions[] = (new Permission($permission, 'user', $user->getId()))->toString();
|
||||
$permissions[] = (new Permission($permission->value, 'user', $user->getId()))->toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use Utopia\Database\Exception\Limit as LimitException;
|
||||
use Utopia\Database\Exception\NotFound as NotFoundException;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Index;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Permissions;
|
||||
use Utopia\Database\Validator\UID;
|
||||
@@ -141,45 +142,42 @@ class Create extends CollectionAction
|
||||
);
|
||||
// Create attribute and indexes metadata documents in the attributes and indexes collections
|
||||
// needed for the get and list calls
|
||||
$attributeDocs = array_map(function ($attributeConfig) use ($database, $collection, $databaseId, $collectionId, $dimension) {
|
||||
$key = \is_string($attributeConfig['$id']) ? $attributeConfig['$id'] : (string) $attributeConfig['$id'];
|
||||
$attributeDocs = array_map(function (Attribute $attributeConfig) use ($database, $collection, $databaseId, $collectionId, $dimension) {
|
||||
return new Document([
|
||||
'$id' => ID::custom($database->getSequence() . '_' . $collection->getSequence() . '_' . $key),
|
||||
'key' => $key,
|
||||
'$id' => ID::custom($database->getSequence() . '_' . $collection->getSequence() . '_' . $attributeConfig->key),
|
||||
'key' => $attributeConfig->key,
|
||||
'databaseInternalId' => $database->getSequence(),
|
||||
'databaseId' => $databaseId,
|
||||
'collectionInternalId' => $collection->getSequence(),
|
||||
'collectionId' => $collectionId,
|
||||
'type' => $attributeConfig['type'],
|
||||
'type' => $attributeConfig->type->value,
|
||||
'status' => 'available',
|
||||
'size' => $dimension,
|
||||
'required' => $attributeConfig['required'] ?? false,
|
||||
'signed' => $attributeConfig['signed'] ?? false,
|
||||
'default' => $attributeConfig['default'] ?? null,
|
||||
'array' => $attributeConfig['array'] ?? false,
|
||||
'format' => $attributeConfig['format'] ?? '',
|
||||
'formatOptions' => $attributeConfig['formatOptions'] ?? [],
|
||||
'filters' => $attributeConfig['filters'] ?? [],
|
||||
'options' => $attributeConfig['options'] ?? [],
|
||||
'required' => $attributeConfig->required,
|
||||
'signed' => $attributeConfig->signed,
|
||||
'default' => $attributeConfig->default,
|
||||
'array' => $attributeConfig->array,
|
||||
'format' => $attributeConfig->format ?? '',
|
||||
'formatOptions' => $attributeConfig->formatOptions,
|
||||
'filters' => $attributeConfig->filters,
|
||||
'options' => $attributeConfig->options ?? [],
|
||||
]);
|
||||
}, $collections['defaultAttributes']);
|
||||
$dbForProject->createDocuments('attributes', $attributeDocs);
|
||||
|
||||
$indexDocs = array_map(function ($indexConfig) use ($database, $collection, $databaseId, $collectionId) {
|
||||
$key = \is_string($indexConfig['$id']) ? $indexConfig['$id'] : (string) $indexConfig['$id'];
|
||||
|
||||
$indexDocs = array_map(function (Index $indexConfig) use ($database, $collection, $databaseId, $collectionId) {
|
||||
return new Document([
|
||||
'$id' => ID::custom($database->getSequence() . '_' . $collection->getSequence() . '_' . $key),
|
||||
'key' => $key,
|
||||
'$id' => ID::custom($database->getSequence() . '_' . $collection->getSequence() . '_' . $indexConfig->key),
|
||||
'key' => $indexConfig->key,
|
||||
'status' => 'available',
|
||||
'databaseInternalId' => $database->getSequence(),
|
||||
'databaseId' => $databaseId,
|
||||
'collectionInternalId' => $collection->getSequence(),
|
||||
'collectionId' => $collectionId,
|
||||
'type' => $indexConfig['type'],
|
||||
'attributes' => $indexConfig['attributes'] ?? [],
|
||||
'lengths' => $indexConfig['lengths'] ?? [],
|
||||
'orders' => $indexConfig['orders'] ?? [],
|
||||
'type' => $indexConfig->type->value,
|
||||
'attributes' => $indexConfig->attributes,
|
||||
'lengths' => $indexConfig->lengths,
|
||||
'orders' => $indexConfig->orders,
|
||||
]);
|
||||
}, $collections['defaultIndexes']);
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class Create extends Action
|
||||
$permissions = [];
|
||||
if (!empty($user->getId()) && !$isPrivilegedUser) {
|
||||
foreach ($allowedPermissions as $permission) {
|
||||
$permissions[] = (new Permission($permission, 'user', $user->getId()))->toString();
|
||||
$permissions[] = (new Permission($permission->value, 'user', $user->getId()))->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user