diff --git a/src/Appwrite/Network/Platform.php b/src/Appwrite/Network/Platform.php index 6bdbfa16c5..23fb087010 100644 --- a/src/Appwrite/Network/Platform.php +++ b/src/Appwrite/Network/Platform.php @@ -47,6 +47,36 @@ class Platform self::SCHEME_TAURI => 'Web (Tauri)', ]; + /** + * Map deprecated platform types to their new consolidated types. + * + * The 1.9.x refactor consolidated ~15 platform types into 5 new ones. + * Existing platforms in the database may still have old type values. + * + * @param string $type + * @return string The mapped type, or the original if not deprecated. + */ + public static function mapDeprecatedType(string $type): string + { + $mapping = [ + 'flutter-web' => self::TYPE_WEB, + 'unity' => self::TYPE_WEB, + 'flutter-ios' => self::TYPE_APPLE, + 'flutter-macos' => self::TYPE_APPLE, + 'apple-ios' => self::TYPE_APPLE, + 'apple-macos' => self::TYPE_APPLE, + 'apple-watchos' => self::TYPE_APPLE, + 'apple-tvos' => self::TYPE_APPLE, + 'react-native-ios' => self::TYPE_APPLE, + 'flutter-android' => self::TYPE_ANDROID, + 'react-native-android' => self::TYPE_ANDROID, + 'flutter-windows' => self::TYPE_WINDOWS, + 'flutter-linux' => self::TYPE_LINUX, + ]; + + return $mapping[$type] ?? $type; + } + /** * Get user-friendly platform name from a scheme. * diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php b/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php index de086b13a2..4bbbc2fc8c 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/Get.php @@ -75,7 +75,8 @@ class Get extends Action throw new Exception(Exception::PLATFORM_NOT_FOUND); } - $type = $platform->getAttribute('type'); + $type = Platform::mapDeprecatedType($platform->getAttribute('type')); + $platform->setAttribute('type', $type); $model = match($type) { Platform::TYPE_WEB => Response::MODEL_PLATFORM_WEB, diff --git a/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php b/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php index 2953adb4c2..3913f08e75 100644 --- a/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php +++ b/src/Appwrite/Platform/Modules/Project/Http/Project/Platforms/XList.php @@ -3,6 +3,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms; use Appwrite\Extend\Exception; +use Appwrite\Network\Platform; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; @@ -117,6 +118,10 @@ class XList extends Action throw new Exception(Exception::DATABASE_QUERY_ORDER_NULL, "The order attribute '{$e->getAttribute()}' had a null value. Cursor pagination requires all documents order attribute values are non-null."); } + foreach ($platforms as $platform) { + $platform->setAttribute('type', Platform::mapDeprecatedType($platform->getAttribute('type'))); + } + $response->dynamic(new Document([ 'platforms' => $platforms, 'total' => $total,