update: request, response filters.

This commit is contained in:
Darshan 2025-05-06 11:31:35 +05:30
parent 3a8f097c17
commit 86d195c1c0
2 changed files with 26 additions and 8 deletions

View file

@ -6,20 +6,36 @@ use Appwrite\Utopia\Request\Filter;
class V19 extends Filter
{
// Map old params to new
private const PARAMS_MAP = [
'documentId' => 'rowId',
'attributes' => 'columns',
'collectionId' => 'tableId',
'attributeId' => 'columnId',
'$collectionId' => '$tableId',
'relatedCollection' => 'relatedTable',
'relatedCollectionId' => 'relatedTableId',
];
// Convert 1.6 params to 1.7
public function parse(array $content, string $model): array
{
return match ($model) {
'databases.createRelationshipColumn' => $this->convertV16RelationshipParams($content),
default => $content
};
$content = $this->overrideDatabaseParams($content, $model);
return $content;
}
protected function convertV16RelationshipParams(array $content): array
protected function overrideDatabaseParams(array $content, string $model): array
{
if (isset($content['relatedCollectionId'])) {
$content['relatedTableId'] = $content['relatedCollectionId'];
unset($content['relatedCollectionId']);
if (!str_starts_with($model, 'databases.')) {
return $content;
}
$intersect = array_intersect_key(self::PARAMS_MAP, $content);
foreach ($intersect as $oldKey => $newKey) {
$content[$newKey] = $content[$oldKey];
unset($content[$oldKey]);
}
return $content;

View file

@ -10,8 +10,10 @@ class V19 extends Filter
private const DATABASE_MAPPINGS = [
'table' => 'collection',
'tables' => 'collections',
'$tableId' => '$collectionId',
'tablesTotal' => 'collectionsTotal',
'relatedTable' => 'relatedCollection',
'relatedTableId' => 'relatedCollectionId',
'column' => 'attribute',
'columns' => 'attributes',