From 752731050ea30d44fa8321a6be9aa41f400abb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 25 Jan 2026 21:55:52 +0100 Subject: [PATCH] Proper quality to template usecases enums --- app/config/templates/function.php | 108 ++++++++++------ app/config/templates/site.php | 118 ++++++++++-------- .../Functions/Http/Templates/XList.php | 3 +- .../Modules/Sites/Http/Templates/XList.php | 3 +- 4 files changed, 140 insertions(+), 92 deletions(-) diff --git a/app/config/templates/function.php b/app/config/templates/function.php index e10cd4648c..6bdfb5ab80 100644 --- a/app/config/templates/function.php +++ b/app/config/templates/function.php @@ -20,6 +20,34 @@ function getRuntimes($runtimes, $commands, $entrypoint, $providerRootDirectory, })); } + +class FunctionUseCases +{ + public const STARTER = 'starter'; + public const DATABASES = 'databases'; + public const AI = 'ai'; + public const MESSAGING = 'messaging'; + public const UTILITIES = 'utilities'; + public const DEV_TOOLS = 'dev-tools'; + public const AUTH = 'auth'; + + /** + * @var array + */ + public static function getAll(): array + { + return [ + self::STARTER, + self::DATABASES, + self::AI, + self::MESSAGING, + self::UTILITIES, + self::DEV_TOOLS, + self::AUTH, + ]; + } +} + return [ [ 'icon' => 'icon-lightning-bolt', @@ -32,7 +60,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['starter'], + 'useCases' => [FunctionUseCases::STARTER], 'runtimes' => [ ...getRuntimes($templateRuntimes['NODE'], 'npm install', 'src/main.js', 'node/starter', $allowList), ...getRuntimes( @@ -73,7 +101,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -119,7 +147,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -164,7 +192,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -218,7 +246,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -257,7 +285,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -326,7 +354,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -392,7 +420,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['messaging'], + 'useCases' => [FunctionUseCases::MESSAGING], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -459,7 +487,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -497,7 +525,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -548,7 +576,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes($templateRuntimes['NODE'], 'npm install', 'src/main.js', 'node/generate-pdf', $allowList) ], @@ -571,7 +599,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['dev-tools'], + 'useCases' => [FunctionUseCases::DEV_TOOLS], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -616,7 +644,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -669,7 +697,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -754,7 +782,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['databases'], + 'useCases' => [FunctionUseCases::DATABASES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -853,7 +881,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['messaging'], + 'useCases' => [FunctionUseCases::MESSAGING], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -946,7 +974,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['messaging'], + 'useCases' => [FunctionUseCases::MESSAGING], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1004,7 +1032,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1091,7 +1119,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1134,7 +1162,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1193,7 +1221,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 30, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1229,7 +1257,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 30, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1265,7 +1293,7 @@ return [ 'events' => ['buckets.*.files.*.create'], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1325,7 +1353,7 @@ return [ 'events' => ['buckets.*.files.*.create'], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1385,7 +1413,7 @@ return [ 'events' => ['buckets.*.files.*.create'], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1448,7 +1476,7 @@ return [ ], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1508,7 +1536,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 300, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1545,7 +1573,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 300, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1589,7 +1617,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1632,7 +1660,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 300, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1669,7 +1697,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 30, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1734,7 +1762,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 30, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1799,7 +1827,7 @@ return [ 'cron' => '', 'events' => [], 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1856,7 +1884,7 @@ return [ 'cron' => '', 'events' => [], 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1899,7 +1927,7 @@ return [ 'cron' => '', 'events' => [], 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1942,7 +1970,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -1986,7 +2014,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 300, - 'useCases' => ['ai'], + 'useCases' => [FunctionUseCases::AI], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -2023,7 +2051,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -2080,7 +2108,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['utilities'], + 'useCases' => [FunctionUseCases::UTILITIES], 'runtimes' => [ ...getRuntimes( $templateRuntimes['NODE'], @@ -2153,7 +2181,7 @@ return [ 'events' => [], 'cron' => '', 'timeout' => 15, - 'useCases' => ['auth'], + 'useCases' => [FunctionUseCases::AUTH], 'runtimes' => [ ...getRuntimes($templateRuntimes['DART'], 'dart pub get', 'lib/main.dart', 'dart/sign_in_with_apple', $allowList) ], diff --git a/app/config/templates/site.php b/app/config/templates/site.php index e330979597..2181262e18 100644 --- a/app/config/templates/site.php +++ b/app/config/templates/site.php @@ -13,7 +13,7 @@ $hostname = $platform['consoleHostname'] ?? ''; $url = $protocol . '://' . $hostname; -class UseCases +class SiteUseCases { public const PORTFOLIO = 'portfolio'; public const STARTER = 'starter'; @@ -21,9 +21,27 @@ class UseCases public const ECOMMERCE = 'ecommerce'; public const DOCUMENTATION = 'documentation'; public const BLOG = 'blog'; - public const AI = 'artificial intelligence'; + public const AI = 'ai'; public const FORMS = 'forms'; public const DASHBOARD = 'dashboard'; + + /** + * @var array + */ + public static function getAll(): array + { + return [ + self::PORTFOLIO, + self::STARTER, + self::EVENTS, + self::ECOMMERCE, + self::DOCUMENTATION, + self::BLOG, + self::AI, + self::FORMS, + self::DASHBOARD, + ]; + } } const TEMPLATE_FRAMEWORKS = [ @@ -188,7 +206,7 @@ return [ 'name' => 'Documentation template', 'tagline' => 'Modern site to store your knowledge with a clean design, full-text search, dark mode, and more.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DOCUMENTATION], + 'useCases' => [SiteUseCases::DOCUMENTATION], 'screenshotDark' => $url . '/images/sites/templates/template-for-documentation-dark.png', 'screenshotLight' => $url . '/images/sites/templates/template-for-documentation-light.png', 'frameworks' => [ @@ -209,7 +227,7 @@ return [ // When we add Lynx with Appwrite SDK, use following tagline for it: // 'tagline' => 'Sample application built with Lynx, a cross-platform framework focused on performance.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-lynx-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-lynx-light.png', 'frameworks' => [ @@ -228,7 +246,7 @@ return [ 'name' => 'Vitepress', 'tagline' => 'Platform for documentation and knowledge sharing powered by Vite.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DOCUMENTATION], + 'useCases' => [SiteUseCases::DOCUMENTATION], 'screenshotDark' => $url . '/images/sites/templates/vitepress-dark.png', 'screenshotLight' => $url . '/images/sites/templates/vitepress-light.png', 'frameworks' => [ @@ -251,7 +269,7 @@ return [ 'name' => 'Vuepress', 'tagline' => 'Platform for documentation and knowledge sharing powered by Vue.', 'score' => 4, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DOCUMENTATION], + 'useCases' => [SiteUseCases::DOCUMENTATION], 'screenshotDark' => $url . '/images/sites/templates/vuepress-dark.png', 'screenshotLight' => $url . '/images/sites/templates/vuepress-light.png', 'frameworks' => [ @@ -274,7 +292,7 @@ return [ 'name' => 'Docusaurus', 'tagline' => 'Platform for documentation and knowledge sharing powered by React.', 'score' => 4, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DOCUMENTATION], + 'useCases' => [SiteUseCases::DOCUMENTATION], 'screenshotDark' => $url . '/images/sites/templates/docusaurus-dark.png', 'screenshotLight' => $url . '/images/sites/templates/docusaurus-light.png', 'frameworks' => [ @@ -297,7 +315,7 @@ return [ 'name' => 'Nxt Lnk', 'tagline' => 'Personal website for creators to merge all URLs to social profiles.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/nxt-lnk-dark.png', 'screenshotLight' => $url . '/images/sites/templates/nxt-lnk-light.png', 'frameworks' => [ @@ -316,7 +334,7 @@ return [ 'name' => 'Magic Portfolio', 'tagline' => 'Complex personal website to showcase your projects, articles, and more.', 'score' => 7, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/magic-portfolio-dark.png', 'screenshotLight' => $url . '/images/sites/templates/magic-portfolio-light.png', 'frameworks' => [ @@ -335,7 +353,7 @@ return [ 'name' => 'LittleLink', 'tagline' => 'Personal website for creators to merge all URLs to social profiles.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/littlelink-dark.png', 'screenshotLight' => $url . '/images/sites/templates/littlelink-light.png', 'frameworks' => [ @@ -354,7 +372,7 @@ return [ 'name' => 'Logspot', 'tagline' => 'Website to publish changelogs of your application.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::BLOG], + 'useCases' => [SiteUseCases::BLOG], 'screenshotDark' => $url . '/images/sites/templates/logspot-dark.png', 'screenshotLight' => $url . '/images/sites/templates/logspot-light.png', 'frameworks' => [ @@ -376,7 +394,7 @@ return [ 'name' => 'Astro Nano', 'tagline' => 'Minimal personal website to showcase your projects, articles, and more.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/astro-nano-dark.png', 'screenshotLight' => $url . '/images/sites/templates/astro-nano-light.png', 'frameworks' => [ @@ -397,7 +415,7 @@ return [ 'name' => 'Astro Starlight', 'tagline' => 'Platform for documentation and knowledge sharing powered by Astro.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DOCUMENTATION], + 'useCases' => [SiteUseCases::DOCUMENTATION], 'screenshotDark' => $url . '/images/sites/templates/astro-starlight-dark.png', 'screenshotLight' => $url . '/images/sites/templates/astro-starlight-light.png', 'frameworks' => [ @@ -418,7 +436,7 @@ return [ 'name' => 'Astro Sphere', 'tagline' => 'Modern personal website to showcase your projects, articles, and more.', 'score' => 7, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/astro-sphere-dark.png', 'screenshotLight' => $url . '/images/sites/templates/astro-sphere-light.png', 'frameworks' => [ @@ -439,7 +457,7 @@ return [ 'name' => 'Astro Starlog', 'tagline' => 'Platform for publishing written content and media powered by Astro.', 'score' => 5, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::BLOG], + 'useCases' => [SiteUseCases::BLOG], 'screenshotDark' => $url . '/images/sites/templates/astro-starlog-dark.png', 'screenshotLight' => $url . '/images/sites/templates/astro-starlog-light.png', 'frameworks' => [ @@ -460,7 +478,7 @@ return [ 'name' => 'Onelink', 'tagline' => 'Personal website for creators to merge all URLs to social profiles.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/onelink-dark.png', 'screenshotLight' => $url . '/images/sites/templates/onelink-light.png', 'frameworks' => [ @@ -480,7 +498,7 @@ return [ [ 'key' => 'starter-for-flutter', 'name' => 'Flutter starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Flutter application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-flutter-dark.png', @@ -525,7 +543,7 @@ return [ [ 'key' => 'starter-for-js', 'name' => 'JavaScript starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple JavaScript application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-js-dark.png', @@ -569,7 +587,7 @@ return [ [ 'key' => 'starter-for-angular', 'name' => 'Angular starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Angular application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-angular-dark.png', @@ -615,7 +633,7 @@ return [ [ 'key' => 'starter-for-astro', 'name' => 'Astro starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Astro application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-astro-dark.png', @@ -660,7 +678,7 @@ return [ [ 'key' => 'starter-for-analog', 'name' => 'Analog starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Analog application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-analog-dark.png', @@ -704,7 +722,7 @@ return [ [ 'key' => 'starter-for-remix', 'name' => 'Remix starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Remix application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-remix-dark.png', @@ -748,7 +766,7 @@ return [ [ 'key' => 'starter-for-svelte', 'name' => 'Svelte starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Svelte application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-svelte-dark.png', @@ -792,7 +810,7 @@ return [ [ 'key' => 'starter-for-react', 'name' => 'React starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple React application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-react-dark.png', @@ -836,7 +854,7 @@ return [ [ 'key' => 'starter-for-vue', 'name' => 'Vue starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Vue application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-vue-dark.png', @@ -880,7 +898,7 @@ return [ [ 'key' => 'starter-for-react-native', 'name' => 'React Native starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple React Native application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-react-native-dark.png', @@ -924,7 +942,7 @@ return [ [ 'key' => 'starter-for-nextjs', 'name' => 'Next.js starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Next.js application integrated with Appwrite SDK.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-nextjs-dark.png', @@ -968,7 +986,7 @@ return [ [ 'key' => 'starter-for-tanstack-start', 'name' => 'TanStack Start starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple TanStack Start application integrated with Appwrite SDK.', 'score' => 9, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-tanstack-start-dark.png', @@ -1012,7 +1030,7 @@ return [ [ 'key' => 'starter-for-nuxt', 'name' => 'Nuxt starter', - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'tagline' => 'Simple Nuxt application integrated with Appwrite SDK.', 'score' => 3, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) 'screenshotDark' => $url . '/images/sites/templates/starter-for-nuxt-dark.png', @@ -1058,7 +1076,7 @@ return [ 'name' => 'Event template', 'tagline' => 'Hackathon landing page with support for project submissions.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::EVENTS], + 'useCases' => [SiteUseCases::EVENTS], 'screenshotDark' => $url . '/images/sites/templates/template-for-event-dark.png', 'screenshotLight' => $url . '/images/sites/templates/template-for-event-light.png', 'frameworks' => [ @@ -1096,7 +1114,7 @@ return [ 'name' => 'Portfolio template', 'tagline' => 'Simple personal website to showcase your projects, articles, and more.', 'score' => 6, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::PORTFOLIO], + 'useCases' => [SiteUseCases::PORTFOLIO], 'screenshotDark' => $url . '/images/sites/templates/template-for-portfolio-dark.png', 'screenshotLight' => $url . '/images/sites/templates/template-for-portfolio-light.png', 'frameworks' => [ @@ -1115,7 +1133,7 @@ return [ 'name' => 'Store template', 'tagline' => 'E-commerce platform for selling products with Stripe integration.', 'score' => 7, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::ECOMMERCE], + 'useCases' => [SiteUseCases::ECOMMERCE], 'screenshotDark' => $url . '/images/sites/templates/template-for-store-dark.png', 'screenshotLight' => $url . '/images/sites/templates/template-for-store-light.png', 'frameworks' => [ @@ -1159,7 +1177,7 @@ return [ 'name' => 'Blog template', 'tagline' => 'Platform for publishing written content and media.', 'score' => 7, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::BLOG], + 'useCases' => [SiteUseCases::BLOG], 'screenshotDark' => $url . '/images/sites/templates/template-for-blog-dark.png', 'screenshotLight' => $url . '/images/sites/templates/template-for-blog-light.png', 'frameworks' => [ @@ -1178,7 +1196,7 @@ return [ 'name' => 'Astro playground', 'tagline' => 'A basic Astro website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-astro-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-astro-light.png', 'frameworks' => [ @@ -1197,7 +1215,7 @@ return [ 'name' => 'Remix playground', 'tagline' => 'A basic Remix website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-remix-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-remix-light.png', 'frameworks' => [ @@ -1216,7 +1234,7 @@ return [ 'name' => 'Next.js playground', 'tagline' => 'A basic Next.js website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-nextjs-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-nextjs-light.png', 'frameworks' => [ @@ -1235,7 +1253,7 @@ return [ 'name' => 'Flutter playground', 'tagline' => 'A basic Flutter website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-flutter-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-flutter-light.png', 'frameworks' => [ @@ -1254,7 +1272,7 @@ return [ 'name' => 'Vite playground', 'tagline' => 'A basic Vite website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-vite-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-vite-light.png', 'frameworks' => [ @@ -1273,7 +1291,7 @@ return [ 'name' => 'Angular playground', 'tagline' => 'A basic Angular website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-angular-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-angular-light.png', 'frameworks' => [ @@ -1293,7 +1311,7 @@ return [ 'name' => 'Analog playground', 'tagline' => 'A basic Analog website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-analog-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-analog-light.png', 'frameworks' => [ @@ -1312,7 +1330,7 @@ return [ 'name' => 'Svelte playground', 'tagline' => 'A basic Svelte website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-svelte-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-svelte-light.png', 'frameworks' => [ @@ -1332,7 +1350,7 @@ return [ 'name' => 'React playground', 'tagline' => 'A basic React website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-react-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-react-light.png', 'frameworks' => [ @@ -1353,7 +1371,7 @@ return [ 'name' => 'Vue playground', 'tagline' => 'A basic Vue website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-vue-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-vue-light.png', 'frameworks' => [ @@ -1372,7 +1390,7 @@ return [ 'name' => 'Nuxt playground', 'tagline' => 'A basic Nuxt website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-nuxt-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-nuxt-light.png', 'frameworks' => [ @@ -1391,7 +1409,7 @@ return [ 'name' => 'TanStack Start playground', 'tagline' => 'A basic TanStack Start website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-tanstack-start-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-tanstack-start-light.png', 'frameworks' => [ @@ -1410,7 +1428,7 @@ return [ 'name' => 'React Native playground', 'tagline' => 'A basic React Native website without Appwrite SDK integration.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/playground-for-react-native-dark.png', 'screenshotLight' => $url . '/images/sites/templates/playground-for-react-native-light.png', 'frameworks' => [ @@ -1429,7 +1447,7 @@ return [ 'name' => 'Lynx gallery', 'tagline' => 'A Lynx website showcasing gallery with smooth animations.', 'score' => 1, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::STARTER], + 'useCases' => [SiteUseCases::STARTER], 'screenshotDark' => $url . '/images/sites/templates/gallery-for-lynx-dark.png', 'screenshotLight' => $url . '/images/sites/templates/gallery-for-lynx-light.png', 'frameworks' => [ @@ -1448,7 +1466,7 @@ return [ 'name' => 'Text-to-speech with ElevenLabs', 'tagline' => 'Next.js app that transforms text into natural, human-like speech using ElevenLabs', 'score' => 10, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::AI], + 'useCases' => [SiteUseCases::AI], 'screenshotDark' => $url . '/images/sites/templates/text-to-speech-dark.png', 'screenshotLight' => $url . '/images/sites/templates/text-to-speech-light.png', 'frameworks' => [ @@ -1476,7 +1494,7 @@ return [ 'name' => 'CRM dashboard with React Admin', 'tagline' => 'A React-based admin dashboard template with CRM features.', 'score' => 4, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::DASHBOARD], + 'useCases' => [SiteUseCases::DASHBOARD], 'screenshotDark' => $url . '/images/sites/templates/crm-dashboard-react-admin-dark.png', 'screenshotLight' => $url . '/images/sites/templates/crm-dashboard-react-admin-light.png', 'frameworks' => [ @@ -1579,7 +1597,7 @@ return [ 'name' => 'Job applications form with Formspree', 'tagline' => 'A simple form submission template using Formspree.', 'score' => 4, // 0 to 10 based on looks of screenshot (avoid 1,2,3,8,9,10 if possible) - 'useCases' => [UseCases::FORMS], + 'useCases' => [SiteUseCases::FORMS], 'screenshotDark' => $url . '/images/sites/templates/job-applications-formspree-dark.png', 'screenshotLight' => $url . '/images/sites/templates/job-applications-formspree-light.png', 'frameworks' => [ diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php index 26b85c8065..91cb787b70 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Templates/XList.php @@ -7,6 +7,7 @@ use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; +use FunctionUseCases; use Utopia\Config\Config; use Utopia\Database\Document; use Utopia\Platform\Action; @@ -50,7 +51,7 @@ class XList extends Base ] )) ->param('runtimes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('runtimes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of runtimes allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' runtimes are allowed.', true) - ->param('useCases', [], new ArrayList(new WhiteList(['dev-tools','starter','databases','ai','messaging','utilities']), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) + ->param('useCases', [], new ArrayList(new WhiteList(FunctionUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) ->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true) ->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php index 4fe00f3edf..4dea0908cf 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Templates/XList.php @@ -7,6 +7,7 @@ use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; +use SiteUseCases; use Utopia\Config\Config; use Utopia\Database\Document; use Utopia\Platform\Action; @@ -49,7 +50,7 @@ class XList extends Base ] )) ->param('frameworks', [], new ArrayList(new WhiteList(\array_keys(Config::getParam('frameworks')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of frameworks allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' frameworks are allowed.', true) - ->param('useCases', [], new ArrayList(new WhiteList(['dev-tools', 'starter', 'databases', 'ai', 'messaging', 'utilities']), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) + ->param('useCases', [], new ArrayList(new WhiteList(SiteUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) ->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true) ->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true) ->inject('response')