From ac796048d8878e7b624f9c7dbabc018356f4a15c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 1 Dec 2021 12:48:23 +0100 Subject: [PATCH 1/6] replace old collections file --- app/config/collections.old.php | 1628 ++++++++ app/config/collections.php | 3529 ++++++++++------- app/config/collections2.php | 2337 ----------- app/controllers/api/projects.php | 8 +- app/http.php | 2 +- app/init.php | 19 - app/tasks/migrate.php | 6 +- .../Projects/ProjectsConsoleClientTest.php | 21 +- tests/unit/General/CollectionsTest.php | 8 +- 9 files changed, 3763 insertions(+), 3795 deletions(-) create mode 100644 app/config/collections.old.php delete mode 100644 app/config/collections2.php diff --git a/app/config/collections.old.php b/app/config/collections.old.php new file mode 100644 index 0000000000..e72967f0d8 --- /dev/null +++ b/app/config/collections.old.php @@ -0,0 +1,1628 @@ + [ + '$id' => 'console', + '$collection' => 'projects', + '$permissions' => ['read' => ['role:all']], + 'name' => 'Appwrite', + 'description' => 'Appwrite core engine', + 'logo' => '', + 'teamId' => -1, + 'webhooks' => [], + 'keys' => [], + 'platforms' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + 'name' => 'Production', + 'type' => 'web', + 'hostname' => 'appwrite.io', + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + 'name' => 'Development', + 'type' => 'web', + 'hostname' => 'appwrite.test', + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + 'name' => 'Localhost', + 'type' => 'web', + 'hostname' => 'localhost', + ], // Current host is added on app init + ], + 'legalName' => '', + 'legalCountry' => '', + 'legalState' => '', + 'legalCity' => '', + 'legalAddress' => '', + 'legalTaxId' => '', + 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], + 'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], + 'usersAuthLimit' => (App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user + ], + Database::SYSTEM_COLLECTION_COLLECTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Collections', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Updated', + 'key' => 'dateUpdated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Structure', + 'key' => 'structure', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => false, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Rules', + 'key' => 'rules', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => true, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_RULES], + ], + ], + ], + Database::SYSTEM_COLLECTION_RULES => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_RULES, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Collections Rule', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Label', + 'key' => 'label', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Key', + 'key' => 'key', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Type', + 'key' => 'type', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Default', + 'key' => 'default', + 'type' => Database::SYSTEM_VAR_TYPE_WILDCARD, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Required', + 'key' => 'required', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => true, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Array', + 'key' => 'array', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => true, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'list', + 'key' => 'list', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + //'default' => '', + 'required' => false, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Filter', + 'key' => 'filter', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'required' => false, + 'array' => true, + ], + ], + ], + Database::SYSTEM_COLLECTION_USERS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_USERS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'User', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Email', + 'key' => 'email', + 'type' => Database::SYSTEM_VAR_TYPE_EMAIL, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Status', + 'key' => 'status', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Password', + 'key' => 'password', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Password Update Date', + 'key' => 'passwordUpdate', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Prefs', + 'key' => 'prefs', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + 'filter' => ['json'] + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Registration Date', + 'key' => 'registration', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Email Verification Status', + 'key' => 'emailVerification', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Reset', + 'key' => 'reset', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Sessions', + 'key' => 'sessions', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_SESSIONS], + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Tokens', + 'key' => 'tokens', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_TOKENS], + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Memberships', + 'key' => 'memberships', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_MEMBERSHIPS], + ], + ], + ], + Database::SYSTEM_COLLECTION_SESSIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_SESSIONS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Session', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User ID', + 'key' => 'userId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Provider', + 'key' => 'provider', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Provider User Identifier', + 'key' => 'providerUid', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Provider Token', + 'key' => 'providerToken', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Secret', + 'key' => 'secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Expire', + 'key' => 'expire', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User Agent', + 'key' => 'userAgent', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'IP', + 'key' => 'ip', + 'type' => Database::SYSTEM_VAR_TYPE_IP, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Code', + 'key' => 'osCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Name', + 'key' => 'osName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OS Version', + 'key' => 'osVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Type', + 'key' => 'clientType', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Code', + 'key' => 'clientCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Name', + 'key' => 'clientName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Version', + 'key' => 'clientVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Engine', + 'key' => 'clientEngine', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Client Engine Version', + 'key' => 'clientEngineVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Name', + 'key' => 'deviceName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Brand', + 'key' => 'deviceBrand', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Device Model', + 'key' => 'deviceModel', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Country Code', + 'key' => 'countryCode', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_TOKENS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Token', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User ID', + 'key' => 'userId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Type', + 'key' => 'type', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Secret', + 'key' => 'secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Expire', + 'key' => 'expire', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User Agent', + 'key' => 'userAgent', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'IP', + 'key' => 'ip', + 'type' => Database::SYSTEM_VAR_TYPE_IP, + 'default' => '', + 'required' => true, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_MEMBERSHIPS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Membership', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Team ID', + 'key' => 'teamId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User ID', + 'key' => 'userId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Roles', + 'key' => 'roles', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Invited', + 'key' => 'invited', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, //FIXME SHOULD BE REQUIRED + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Joined', + 'key' => 'joined', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Confirm', + 'key' => 'confirm', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Secret', + 'key' => 'secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_TEAMS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_TEAMS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Team', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Sum', + 'key' => 'sum', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_PROJECTS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_PROJECTS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Project', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Description', + 'key' => 'description', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Logo', + 'key' => 'logo', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'URL', + 'key' => 'url', + 'type' => Database::SYSTEM_VAR_TYPE_URL, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Team ID', + 'key' => 'teamId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal Name', + 'key' => 'legalName', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal Country', + 'key' => 'legalCountry', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal State', + 'key' => 'legalState', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal City', + 'key' => 'legalCity', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal Address', + 'key' => 'legalAddress', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Legal Tax ID', + 'key' => 'legalTaxId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Max users allowed', + 'key' => 'usersAuthLimit', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Version', + 'key' => 'version', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Webhooks', + 'key' => 'webhooks', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_WEBHOOKS], + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'API Keys', + 'key' => 'keys', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_KEYS], + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Platforms', + 'key' => 'platforms', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_PLATFORMS], + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Domains', + 'key' => 'domains', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_DOMAINS], + ], + ], + ], + Database::SYSTEM_COLLECTION_WEBHOOKS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_WEBHOOKS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Webhook', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Events', + 'key' => 'events', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'URL', + 'key' => 'url', + 'type' => Database::SYSTEM_VAR_TYPE_URL, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Security', + 'key' => 'security', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'HTTP User', + 'key' => 'httpUser', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'HTTP Password', + 'key' => 'httpPass', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + 'filter' => ['encrypt'], + ], + ], + ], + Database::SYSTEM_COLLECTION_KEYS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_KEYS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Key', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Scopes', + 'key' => 'scopes', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Secret', + 'key' => 'secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'filter' => ['encrypt'], + ], + ], + ], + Database::SYSTEM_COLLECTION_PLATFORMS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_PLATFORMS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Platform', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Type', + 'key' => 'type', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Updated', + 'key' => 'dateUpdated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Key', + 'key' => 'key', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Store', + 'key' => 'store', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Hostname', + 'key' => 'hostname', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_DOMAINS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_DOMAINS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Domains', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Domain', + 'key' => 'domain', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Updated', + 'key' => 'updated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Top Level Domain', + 'key' => 'tld', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Registerable Domain', + 'key' => 'registerable', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Verification', + 'key' => 'verification', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => false, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Certificate ID', + 'key' => 'certificateId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_CERTIFICATES => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_CERTIFICATES, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Certificates', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Domain', + 'key' => 'domain', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Issue Date', + 'key' => 'issueDate', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Renew Date', + 'key' => 'renewDate', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Attempts', + 'key' => 'attempts', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Log', + 'key' => 'log', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Updated Date', + 'key' => 'updated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Certificate ID', + 'key' => 'certificateId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_FILES => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_FILES, + '$permissions' => ['read' => ['role:all']], + 'name' => 'File', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Folder ID', + 'key' => 'folderId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Path', + 'key' => 'path', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Signature', + 'key' => 'signature', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Mime Type', + 'key' => 'mimeType', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Original Size', + 'key' => 'sizeOriginal', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Actual Size', + 'key' => 'sizeActual', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Algorithm', + 'key' => 'algorithm', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Token', + 'key' => 'token', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Comment', + 'key' => 'comment', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'File OpenSSL Version', + 'key' => 'fileOpenSSLVersion', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'File OpenSSL Cipher', + 'key' => 'fileOpenSSLCipher', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'File OpenSSL Tag', + 'key' => 'fileOpenSSLTag', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'File OpenSSL IV', + 'key' => 'fileOpenSSLIV', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_FUNCTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_FUNCTIONS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Functions', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Updated', + 'key' => 'dateUpdated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Status', + 'key' => 'status', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Name', + 'key' => 'name', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Runtime', + 'key' => 'runtime', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Tag', + 'key' => 'tag', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Vars', + 'key' => 'vars', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + 'filter' => ['json', 'encrypt'] + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Events', + 'key' => 'events', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => true, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule', + 'key' => 'schedule', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule Previous Run', + 'key' => 'schedulePrevious', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Schedule Next Run', + 'key' => 'scheduleNext', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Timeout', + 'key' => 'timeout', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_TAGS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_TAGS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Tags', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Function ID', + 'key' => 'functionId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Command', + 'key' => 'command', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Code Path', + 'key' => 'path', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Code Size', + 'key' => 'size', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_EXECUTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_EXECUTIONS, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Executions', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Date Created', + 'key' => 'dateCreated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Function ID', + 'key' => 'functionId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Tag ID', + 'key' => 'tagId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Trigger', + 'key' => 'trigger', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Status', + 'key' => 'status', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Exit Code', + 'key' => 'exitCode', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Stdout', + 'key' => 'stdout', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Stderr', + 'key' => 'stderr', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Time', + 'key' => 'time', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => '', + 'required' => false, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_CONNECTIONS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_CONNECTIONS, + '$permissions' => ['read' => ['*']], + 'name' => 'Realtime Connections', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, + 'label' => 'Container', + 'key' => 'container', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, + 'label' => 'Timestamp', + 'key' => 'timestamp', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, + 'label' => 'Value', + 'key' => 'value', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'required' => true, + 'array' => false, + ], + ], + ], + Database::SYSTEM_COLLECTION_RESERVED => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_RESERVED, + '$permissions' => ['read' => ['role:all']], + 'name' => 'Reserved', + 'structure' => true, + ], +]; + +/* + * Add enabled OAuth2 providers to default data rules + */ +foreach ($providers as $index => $provider) { + if (!$provider['enabled']) { + continue; + } + + $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OAuth2 '.\ucfirst($index).' ID', + 'key' => 'usersOauth2'.\ucfirst($index).'Appid', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + ]; + + $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'OAuth2 '.\ucfirst($index).' Secret', + 'key' => 'usersOauth2'.\ucfirst($index).'Secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, + 'array' => false, + 'filter' => ['encrypt'], + ]; +} + +foreach ($auth as $index => $method) { + $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => $method['name'] || '', + 'key' => $method['key'] || '', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => true, + 'required' => false, + ]; +} + +return $collections; \ No newline at end of file diff --git a/app/config/collections.php b/app/config/collections.php index e72967f0d8..4122cd9f06 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1,1628 +1,2337 @@ [ - '$id' => 'console', - '$collection' => 'projects', - '$permissions' => ['read' => ['role:all']], - 'name' => 'Appwrite', - 'description' => 'Appwrite core engine', - 'logo' => '', - 'teamId' => -1, - 'webhooks' => [], - 'keys' => [], - 'platforms' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - 'name' => 'Production', - 'type' => 'web', - 'hostname' => 'appwrite.io', - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - 'name' => 'Development', - 'type' => 'web', - 'hostname' => 'appwrite.test', - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - 'name' => 'Localhost', - 'type' => 'web', - 'hostname' => 'localhost', - ], // Current host is added on app init - ], - 'legalName' => '', - 'legalCountry' => '', - 'legalState' => '', - 'legalCity' => '', - 'legalAddress' => '', - 'legalTaxId' => '', - 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], - 'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], - 'usersAuthLimit' => (App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user - ], - Database::SYSTEM_COLLECTION_COLLECTIONS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$permissions' => ['read' => ['role:all']], + 'collections' => [ + '$collection' => Database::METADATA, + '$id' => 'collections', 'name' => 'Collections', - 'structure' => true, - 'rules' => [ + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'size' => 256, 'required' => true, + 'signed' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Updated', - 'key' => 'dateUpdated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, + '$id' => 'dateUpdated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Structure', - 'key' => 'structure', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => false, - 'required' => true, + '$id' => 'permission', + 'type' => Database::VAR_STRING, + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Rules', - 'key' => 'rules', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], - 'required' => true, + '$id' => 'attributes', + 'type' => Database::VAR_STRING, + 'size' => 1000000, + 'required' => false, + 'signed' => true, + 'array' => false, + 'filters' => ['subQueryAttributes'], + ], + [ + '$id' => 'indexes', + 'type' => Database::VAR_STRING, + 'size' => 1000000, + 'required' => false, + 'signed' => true, + 'array' => false, + 'filters' => ['subQueryIndexes'], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_fulltext_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [1024], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'attributes' => [ + '$collection' => Database::METADATA, + '$id' => 'attributes', + 'name' => 'Attributes', + 'attributes' => [ + [ + '$id' => 'collectionId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'key', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'type', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'status', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'size', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'required', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'default', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['casting'], + ], + [ + '$id' => 'signed', + 'type' => Database::VAR_BOOLEAN, + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'array', + 'type' => Database::VAR_BOOLEAN, + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'format', + 'type' => Database::VAR_STRING, + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'formatOptions', + 'type' => Database::VAR_STRING, + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => new stdClass, + 'array' => false, + 'filters' => ['json', 'range', 'enum'], + ], + [ + '$id' => 'filters', + 'type' => Database::VAR_STRING, + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_RULES], + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_collection', + 'type' => Database::INDEX_KEY, + 'attributes' => ['collectionId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_RULES => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_RULES, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Collections Rule', - 'structure' => true, - 'rules' => [ + + 'indexes' => [ + '$collection' => Database::METADATA, + '$id' => 'indexes', + 'name' => 'Indexes', + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Label', - 'key' => 'label', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Key', - 'key' => 'key', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Type', - 'key' => 'type', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Default', - 'key' => 'default', - 'type' => Database::SYSTEM_VAR_TYPE_WILDCARD, - 'default' => '', + '$id' => 'collectionId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Required', - 'key' => 'required', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => true, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Array', - 'key' => 'array', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => true, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'list', - 'key' => 'list', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - //'default' => '', + '$id' => 'key', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'type', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'status', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'attributes', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => true, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Filter', - 'key' => 'filter', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'lengths', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => true, + 'filters' => [], ], - ], - ], - Database::SYSTEM_COLLECTION_USERS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_USERS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'User', - 'structure' => true, - 'rules' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Email', - 'key' => 'email', - 'type' => Database::SYSTEM_VAR_TYPE_EMAIL, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Status', - 'key' => 'status', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Password', - 'key' => 'password', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Password Update Date', - 'key' => 'passwordUpdate', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Prefs', - 'key' => 'prefs', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - 'filter' => ['json'] - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Registration Date', - 'key' => 'registration', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Email Verification Status', - 'key' => 'emailVerification', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Reset', - 'key' => 'reset', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Sessions', - 'key' => 'sessions', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'orders', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 4, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_SESSIONS], + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_collection', + 'type' => Database::INDEX_KEY, + 'attributes' => ['collectionId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'projects' => [ + '$collection' => Database::METADATA, + '$id' => 'projects', + 'name' => 'Projects', + 'attributes' => [ + [ + '$id' => 'teamId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Tokens', - 'key' => 'tokens', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'description', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'logo', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'url', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'version', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalName', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalCountry', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalState', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalCity', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalAddress', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'legalTaxId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'services', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['json'], + ], + [ + '$id' => 'auths', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['json'], + ], + [ + '$id' => 'providers', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['json'], + ], + [ + '$id' => 'platforms', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['subQueryPlatforms'], + ], + [ + '$id' => 'webhooks', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['subQueryWebhooks'], + ], + [ + '$id' => 'keys', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['subQueryKeys'], + ], + [ + '$id' => 'domains', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['subQueryDomains'], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'platforms' => [ + '$collection' => Database::METADATA, + '$id' => 'platforms', + 'name' => 'platforms', + 'attributes' => [ + [ + '$id' => 'projectId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'type', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'key', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'store', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'hostname', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'dateUpdated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_project', + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'domains' => [ + '$collection' => Database::METADATA, + '$id' => 'domains', + 'name' => 'domains', + 'attributes' => [ + [ + '$id' => 'projectId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'updated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'domain', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'tld', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'registerable', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'verification', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'certificateId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_project', + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'keys' => [ + '$collection' => Database::METADATA, + '$id' => 'keys', + 'name' => 'keys', + 'attributes' => [ + [ + '$id' => 'projectId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'scopes', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_TOKENS], + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Memberships', - 'key' => 'memberships', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'secret', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, // var_dump of \bin2hex(\random_bytes(128)) => string(256) + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_project', + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'webhooks' => [ + '$collection' => Database::METADATA, + '$id' => 'webhooks', + 'name' => 'webhooks', + 'attributes' => [ + [ + '$id' => 'projectId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'url', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'httpUser', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'httpPass', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'security', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'events', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_MEMBERSHIPS], + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_project', + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_SESSIONS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_SESSIONS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Session', - 'structure' => true, - 'rules' => [ + + 'users' => [ + '$collection' => Database::METADATA, + '$id' => 'users', + 'name' => 'Users', + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'User ID', - 'key' => 'userId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, 'default' => null, - 'required' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Provider', - 'key' => 'provider', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Provider User Identifier', - 'key' => 'providerUid', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'email', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 320, + 'signed' => true, 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Provider Token', - 'key' => 'providerToken', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Secret', - 'key' => 'secret', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Expire', - 'key' => 'expire', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'User Agent', - 'key' => 'userAgent', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'IP', - 'key' => 'ip', - 'type' => Database::SYSTEM_VAR_TYPE_IP, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OS Code', - 'key' => 'osCode', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OS Name', - 'key' => 'osName', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OS Version', - 'key' => 'osVersion', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Type', - 'key' => 'clientType', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Code', - 'key' => 'clientCode', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Name', - 'key' => 'clientName', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Version', - 'key' => 'clientVersion', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Engine', - 'key' => 'clientEngine', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Client Engine Version', - 'key' => 'clientEngineVersion', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Device Name', - 'key' => 'deviceName', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Device Brand', - 'key' => 'deviceBrand', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Device Model', - 'key' => 'deviceModel', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Country Code', - 'key' => 'countryCode', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_TOKENS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_TOKENS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Token', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'User ID', - 'key' => 'userId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'status', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Type', - 'key' => 'type', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, 'default' => null, - 'required' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Secret', - 'key' => 'secret', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Expire', - 'key' => 'expire', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'User Agent', - 'key' => 'userAgent', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'IP', - 'key' => 'ip', - 'type' => Database::SYSTEM_VAR_TYPE_IP, - 'default' => '', - 'required' => true, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_MEMBERSHIPS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Membership', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Team ID', - 'key' => 'teamId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'password', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, 'default' => null, - 'required' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'User ID', - 'key' => 'userId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'passwordUpdate', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, 'default' => null, - 'required' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Roles', - 'key' => 'roles', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, + '$id' => 'prefs', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['json'], + ], + [ + '$id' => 'registration', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'emailVerification', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'reset', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'sessions', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => true, + 'filters' => ['json'], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Invited', - 'key' => 'invited', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, //FIXME SHOULD BE REQUIRED - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Joined', - 'key' => 'joined', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Confirm', - 'key' => 'confirm', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Secret', - 'key' => 'secret', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'tokens', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_TEAMS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_TEAMS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Team', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Sum', - 'key' => 'sum', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_PROJECTS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_PROJECTS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Project', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Description', - 'key' => 'description', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Logo', - 'key' => 'logo', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'URL', - 'key' => 'url', - 'type' => Database::SYSTEM_VAR_TYPE_URL, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Team ID', - 'key' => 'teamId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal Name', - 'key' => 'legalName', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal Country', - 'key' => 'legalCountry', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal State', - 'key' => 'legalState', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal City', - 'key' => 'legalCity', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal Address', - 'key' => 'legalAddress', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Legal Tax ID', - 'key' => 'legalTaxId', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Max users allowed', - 'key' => 'usersAuthLimit', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Version', - 'key' => 'version', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Webhooks', - 'key' => 'webhooks', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], - 'required' => false, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_WEBHOOKS], + 'filters' => ['json'], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'API Keys', - 'key' => 'keys', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'memberships', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_KEYS], + 'filters' => ['json'], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Platforms', - 'key' => 'platforms', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'deleted', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_email', + 'type' => Database::INDEX_UNIQUE, + 'attributes' => ['email'], + 'lengths' => [320], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_deleted_email', + 'type' => Database::INDEX_KEY, + 'attributes' => ['deleted', 'email'], + 'lengths' => [0, 320], + 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], + ], + ], + ], + + 'sessions' => [ + '$collection' => Database::METADATA, + '$id' => 'sessions', + 'name' => 'Sessions', + 'attributes' => [ + [ + '$id' => 'userId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'provider', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'providerUid', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'providerToken', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'secret', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 64, // https://www.tutorialspoint.com/how-long-is-the-sha256-hash-in-mysql + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'expire', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'userAgent', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'ip', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 45, // https://stackoverflow.com/a/166157/2299554 + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'countryCode', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'osCode', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'osName', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'osVersion', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientType', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientCode', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientName', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientVersion', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientEngine', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'clientEngineVersion', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'deviceName', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'deviceBrand', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'deviceModel', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_provider_providerUid', + 'type' => Database::INDEX_KEY, + 'attributes' => ['provider', 'providerUid'], + 'lengths' => [100, 100], + 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], + ], + ], + ], + + 'teams' => [ + '$collection' => Database::METADATA, + '$id' => 'teams', + 'name' => 'Teams', + 'attributes' => [ + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'sum', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + + 'memberships' => [ + '$collection' => Database::METADATA, + '$id' => 'memberships', + 'name' => 'Memberships', + 'attributes' => [ + [ + '$id' => 'teamId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'userId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'roles', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_PLATFORMS], + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Domains', - 'key' => 'domains', - 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, - 'default' => [], + '$id' => 'invited', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, - 'array' => true, - 'list' => [Database::SYSTEM_COLLECTION_DOMAINS], + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'joined', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'confirm', + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'secret', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_unique', + 'type' => Database::INDEX_UNIQUE, + 'attributes' => ['teamId', 'userId'], + 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], + ], + [ + '$id' => '_key_team', + 'type' => Database::INDEX_KEY, + 'attributes' => ['teamId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_user', + 'type' => Database::INDEX_KEY, + 'attributes' => ['userId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_WEBHOOKS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_WEBHOOKS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Webhook', - 'structure' => true, - 'rules' => [ + + 'files' => [ + '$collection' => Database::METADATA, + '$id' => 'files', + 'name' => 'Files', + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, 'default' => null, - 'required' => true, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Events', - 'key' => 'events', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'array' => false, + '$id' => 'bucketId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, 'default' => null, - 'required' => false, - 'array' => true, + 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'URL', - 'key' => 'url', - 'type' => Database::SYSTEM_VAR_TYPE_URL, - 'default' => '', + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Security', - 'key' => 'security', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => '', + '$id' => 'path', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'HTTP User', - 'key' => 'httpUser', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'signature', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'HTTP Password', - 'key' => 'httpPass', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'mimeType', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 127, // https://tools.ietf.org/html/rfc4288#section-4.2 + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, - 'filter' => ['encrypt'], + 'filters' => [], + ], + [ + '$id' => 'sizeOriginal', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'sizeActual', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'algorithm', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 255, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'comment', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'openSSLVersion', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'openSSLCipher', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'openSSLTag', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'openSSLIV', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_bucket', + 'type' => Database::INDEX_KEY, + 'attributes' => ['bucketId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_KEYS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_KEYS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Key', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Scopes', - 'key' => 'scopes', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => false, - 'array' => true, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Secret', - 'key' => 'secret', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'filter' => ['encrypt'], - ], - ], - ], - Database::SYSTEM_COLLECTION_PLATFORMS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_PLATFORMS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Platform', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Type', - 'key' => 'type', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Updated', - 'key' => 'dateUpdated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Key', - 'key' => 'key', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Store', - 'key' => 'store', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Hostname', - 'key' => 'hostname', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_DOMAINS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_DOMAINS, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Domains', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Domain', - 'key' => 'domain', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Updated', - 'key' => 'updated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Top Level Domain', - 'key' => 'tld', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Registerable Domain', - 'key' => 'registerable', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Verification', - 'key' => 'verification', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => false, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Certificate ID', - 'key' => 'certificateId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_CERTIFICATES => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_CERTIFICATES, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Certificates', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Domain', - 'key' => 'domain', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => null, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Issue Date', - 'key' => 'issueDate', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Renew Date', - 'key' => 'renewDate', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Attempts', - 'key' => 'attempts', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Log', - 'key' => 'log', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Updated Date', - 'key' => 'updated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Certificate ID', - 'key' => 'certificateId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_FILES => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_FILES, - '$permissions' => ['read' => ['role:all']], - 'name' => 'File', - 'structure' => true, - 'rules' => [ - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Folder ID', - 'key' => 'folderId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Path', - 'key' => 'path', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Signature', - 'key' => 'signature', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Mime Type', - 'key' => 'mimeType', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Original Size', - 'key' => 'sizeOriginal', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Actual Size', - 'key' => 'sizeActual', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Algorithm', - 'key' => 'algorithm', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Token', - 'key' => 'token', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => true, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Comment', - 'key' => 'comment', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'File OpenSSL Version', - 'key' => 'fileOpenSSLVersion', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'File OpenSSL Cipher', - 'key' => 'fileOpenSSLCipher', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'File OpenSSL Tag', - 'key' => 'fileOpenSSLTag', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'File OpenSSL IV', - 'key' => 'fileOpenSSLIV', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - ], - ], - Database::SYSTEM_COLLECTION_FUNCTIONS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_FUNCTIONS, - '$permissions' => ['read' => ['role:all']], + + 'functions' => [ + '$collection' => Database::METADATA, + '$id' => 'functions', 'name' => 'Functions', - 'structure' => true, - 'rules' => [ + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Updated', - 'key' => 'dateUpdated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Status', - 'key' => 'status', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Name', - 'key' => 'name', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Runtime', - 'key' => 'runtime', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Tag', - 'key' => 'tag', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', - 'required' => false, - 'array' => false, - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Vars', - 'key' => 'vars', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - 'filter' => ['json', 'encrypt'] - ], - [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Events', - 'key' => 'events', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'execute', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => true, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Schedule', - 'key' => 'schedule', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Schedule Previous Run', - 'key' => 'schedulePrevious', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Schedule Next Run', - 'key' => 'scheduleNext', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', + '$id' => 'dateUpdated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Timeout', - 'key' => 'timeout', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', - 'required' => false, 'array' => false, + '$id' => 'status', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'runtime', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'tag', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'vars', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 8192, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['json', 'encrypt'], + ], + [ + '$id' => 'events', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => true, + 'filters' => [], + ], + [ + '$id' => 'schedule', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'schedulePrevious', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'scheduleNext', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'timeout', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_TAGS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_TAGS, - '$permissions' => ['read' => ['role:all']], + + 'tags' => [ + '$collection' => Database::METADATA, + '$id' => 'tags', 'name' => 'Tags', - 'structure' => true, - 'rules' => [ + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Function ID', - 'key' => 'functionId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', + '$id' => 'functionId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Command', - 'key' => 'command', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, 'array' => false, + '$id' => 'command', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Code Path', - 'key' => 'path', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'path', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Code Size', - 'key' => 'size', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', + '$id' => 'size', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_function', + 'type' => Database::INDEX_KEY, + 'attributes' => ['functionId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_EXECUTIONS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_EXECUTIONS, - '$permissions' => ['read' => ['role:all']], + + 'executions' => [ + '$collection' => Database::METADATA, + '$id' => 'executions', 'name' => 'Executions', - 'structure' => true, - 'rules' => [ + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Date Created', - 'key' => 'dateCreated', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => 0, + '$id' => 'dateCreated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Function ID', - 'key' => 'functionId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', + '$id' => 'functionId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Tag ID', - 'key' => 'tagId', - 'type' => Database::SYSTEM_VAR_TYPE_KEY, - 'default' => '', + '$id' => 'tagId', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Trigger', - 'key' => 'trigger', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, 'array' => false, + '$id' => 'trigger', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Status', - 'key' => 'status', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'status', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Exit Code', - 'key' => 'exitCode', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', + '$id' => 'stdout', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Stdout', - 'key' => 'stdout', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'stderr', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Stderr', - 'key' => 'stderr', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + '$id' => 'exitCode', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Time', - 'key' => 'time', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => '', + '$id' => 'time', + 'type' => Database::VAR_FLOAT, + 'format' => '', + 'size' => 0, + 'signed' => true, 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_function', + 'type' => Database::INDEX_KEY, + 'attributes' => ['functionId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_fulltext_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [16384], + 'orders' => [Database::ORDER_ASC], ], ], ], - Database::SYSTEM_COLLECTION_CONNECTIONS => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_CONNECTIONS, - '$permissions' => ['read' => ['*']], + + 'certificates' => [ + '$collection' => Database::METADATA, + '$id' => 'certificates', + 'name' => 'Certificates', + 'attributes' => [ + [ + '$id' => 'domain', + 'type' => Database::VAR_STRING, + 'format' => '', + // The maximum total length of a domain name or number is 255 characters. + // https://datatracker.ietf.org/doc/html/rfc2821#section-4.5.3.1 + // https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1.2 + 'size' => 255, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'issueDate', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'renewDate', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'attempts', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'log', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'updated', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_domain', + 'type' => Database::INDEX_KEY, + 'attributes' => ['domain'], + 'lengths' => [255], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + 'stats' => [ + '$collection' => Database::METADATA, + '$id' => 'stats', + 'name' => 'Stats', + 'attributes' => [ + [ + '$id' => 'metric', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 255, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'value', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'time', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'period', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 4, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => 'type', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 1, + 'signed' => false, + 'required' => true, + 'default' => 0, // 0 -> count, 1 -> sum + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => '_key_time', + 'type' => Database::INDEX_KEY, + 'attributes' => ['time'], + 'lengths' => [], + 'orders' => [Database::ORDER_DESC], + ], + [ + '$id' => '_key_metric', + 'type' => Database::INDEX_KEY, + 'attributes' => ['metric'], + 'lengths' => [], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_metric_period', + 'type' => Database::INDEX_KEY, + 'attributes' => ['metric', 'period'], + 'lengths' => [], + 'orders' => [Database::ORDER_DESC], + ], + ], + ], + 'realtime' => [ + '$collection' => Database::METADATA, + '$id' => 'realtime', 'name' => 'Realtime Connections', - 'structure' => true, - 'rules' => [ + 'attributes' => [ [ - '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, - 'label' => 'Container', - 'key' => 'container', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'container', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, 'required' => true, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, - 'label' => 'Timestamp', - 'key' => 'timestamp', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'required' => true, + '$id' => 'timestamp', + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, 'array' => false, + 'filters' => [], ], [ - '$collection' => Database::SYSTEM_COLLECTION_CONNECTIONS, - 'label' => 'Value', - 'key' => 'value', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + '$id' => 'value', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, 'required' => true, + 'default' => null, 'array' => false, - ], + 'filters' => [], //TODO: use json filter + ] ], - ], - Database::SYSTEM_COLLECTION_RESERVED => [ - '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_RESERVED, - '$permissions' => ['read' => ['role:all']], - 'name' => 'Reserved', - 'structure' => true, + 'indexes' => [ + [ + '$id' => '_key_timestamp', + 'type' => Database::INDEX_KEY, + 'attributes' => ['timestamp'], + 'lengths' => [], + 'orders' => [Database::ORDER_DESC], + ], + ] ], ]; -/* - * Add enabled OAuth2 providers to default data rules - */ -foreach ($providers as $index => $provider) { - if (!$provider['enabled']) { - continue; - } - - $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth2 '.\ucfirst($index).' ID', - 'key' => 'usersOauth2'.\ucfirst($index).'Appid', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - ]; - - $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth2 '.\ucfirst($index).' Secret', - 'key' => 'usersOauth2'.\ucfirst($index).'Secret', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, - 'filter' => ['encrypt'], - ]; -} - -foreach ($auth as $index => $method) { - $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => $method['name'] || '', - 'key' => $method['key'] || '', - 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, - 'default' => true, - 'required' => false, - ]; -} - return $collections; \ No newline at end of file diff --git a/app/config/collections2.php b/app/config/collections2.php deleted file mode 100644 index 4122cd9f06..0000000000 --- a/app/config/collections2.php +++ /dev/null @@ -1,2337 +0,0 @@ - [ - '$collection' => Database::METADATA, - '$id' => 'collections', - 'name' => 'Collections', - 'attributes' => [ - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'size' => 256, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateUpdated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'permission', - 'type' => Database::VAR_STRING, - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'attributes', - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryAttributes'], - ], - [ - '$id' => 'indexes', - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryIndexes'], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_fulltext_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [1024], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'attributes' => [ - '$collection' => Database::METADATA, - '$id' => 'attributes', - 'name' => 'Attributes', - 'attributes' => [ - [ - '$id' => 'collectionId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'key', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'type', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'size', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'required', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'default', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['casting'], - ], - [ - '$id' => 'signed', - 'type' => Database::VAR_BOOLEAN, - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'array', - 'type' => Database::VAR_BOOLEAN, - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'format', - 'type' => Database::VAR_STRING, - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'formatOptions', - 'type' => Database::VAR_STRING, - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => new stdClass, - 'array' => false, - 'filters' => ['json', 'range', 'enum'], - ], - [ - '$id' => 'filters', - 'type' => Database::VAR_STRING, - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_collection', - 'type' => Database::INDEX_KEY, - 'attributes' => ['collectionId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'indexes' => [ - '$collection' => Database::METADATA, - '$id' => 'indexes', - 'name' => 'Indexes', - 'attributes' => [ - [ - '$id' => 'collectionId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'key', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'type', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'attributes', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'lengths', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'orders', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_collection', - 'type' => Database::INDEX_KEY, - 'attributes' => ['collectionId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'projects' => [ - '$collection' => Database::METADATA, - '$id' => 'projects', - 'name' => 'Projects', - 'attributes' => [ - [ - '$id' => 'teamId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'description', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'logo', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'url', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'version', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalName', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalCountry', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalState', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalCity', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalAddress', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'legalTaxId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'services', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => 'auths', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => 'providers', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => 'platforms', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryPlatforms'], - ], - [ - '$id' => 'webhooks', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryWebhooks'], - ], - [ - '$id' => 'keys', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryKeys'], - ], - [ - '$id' => 'domains', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryDomains'], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'platforms' => [ - '$collection' => Database::METADATA, - '$id' => 'platforms', - 'name' => 'platforms', - 'attributes' => [ - [ - '$id' => 'projectId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'type', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'key', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'store', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'hostname', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateUpdated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_project', - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'domains' => [ - '$collection' => Database::METADATA, - '$id' => 'domains', - 'name' => 'domains', - 'attributes' => [ - [ - '$id' => 'projectId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'updated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'domain', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'tld', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'registerable', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'verification', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'certificateId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_project', - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'keys' => [ - '$collection' => Database::METADATA, - '$id' => 'keys', - 'name' => 'keys', - 'attributes' => [ - [ - '$id' => 'projectId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'scopes', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'secret', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, // var_dump of \bin2hex(\random_bytes(128)) => string(256) - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_project', - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'webhooks' => [ - '$collection' => Database::METADATA, - '$id' => 'webhooks', - 'name' => 'webhooks', - 'attributes' => [ - [ - '$id' => 'projectId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'url', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'httpUser', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'httpPass', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'security', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'events', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_project', - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'users' => [ - '$collection' => Database::METADATA, - '$id' => 'users', - 'name' => 'Users', - 'attributes' => [ - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'email', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 320, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'status', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'password', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'passwordUpdate', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'prefs', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => 'registration', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'emailVerification', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'reset', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'sessions', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => ['json'], - ], - [ - '$id' => 'tokens', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => ['json'], - ], - [ - '$id' => 'memberships', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => ['json'], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'deleted', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_email', - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['email'], - 'lengths' => [320], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deleted_email', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deleted', 'email'], - 'lengths' => [0, 320], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - ], - ], - - 'sessions' => [ - '$collection' => Database::METADATA, - '$id' => 'sessions', - 'name' => 'Sessions', - 'attributes' => [ - [ - '$id' => 'userId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'provider', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'providerUid', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'providerToken', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'secret', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 64, // https://www.tutorialspoint.com/how-long-is-the-sha256-hash-in-mysql - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'expire', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'userAgent', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'ip', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 45, // https://stackoverflow.com/a/166157/2299554 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'countryCode', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'osCode', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'osName', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'osVersion', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientType', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientCode', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientName', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientVersion', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientEngine', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'clientEngineVersion', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'deviceName', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'deviceBrand', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'deviceModel', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_provider_providerUid', - 'type' => Database::INDEX_KEY, - 'attributes' => ['provider', 'providerUid'], - 'lengths' => [100, 100], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - ], - ], - - 'teams' => [ - '$collection' => Database::METADATA, - '$id' => 'teams', - 'name' => 'Teams', - 'attributes' => [ - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'sum', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'memberships' => [ - '$collection' => Database::METADATA, - '$id' => 'memberships', - 'name' => 'Memberships', - 'attributes' => [ - [ - '$id' => 'teamId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'userId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'roles', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'invited', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'joined', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'confirm', - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'secret', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_unique', - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['teamId', 'userId'], - 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => '_key_team', - 'type' => Database::INDEX_KEY, - 'attributes' => ['teamId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_user', - 'type' => Database::INDEX_KEY, - 'attributes' => ['userId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'files' => [ - '$collection' => Database::METADATA, - '$id' => 'files', - 'name' => 'Files', - 'attributes' => [ - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => 'bucketId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'path', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'signature', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'mimeType', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 127, // https://tools.ietf.org/html/rfc4288#section-4.2 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'sizeOriginal', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'sizeActual', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'algorithm', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'comment', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'openSSLVersion', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'openSSLCipher', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'openSSLTag', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'openSSLIV', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_bucket', - 'type' => Database::INDEX_KEY, - 'attributes' => ['bucketId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'functions' => [ - '$collection' => Database::METADATA, - '$id' => 'functions', - 'name' => 'Functions', - 'attributes' => [ - [ - '$id' => 'execute', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'name', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'dateUpdated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'runtime', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'tag', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'vars', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 8192, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => 'events', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'schedule', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'schedulePrevious', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'scheduleNext', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'timeout', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'tags' => [ - '$collection' => Database::METADATA, - '$id' => 'tags', - 'name' => 'Tags', - 'attributes' => [ - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'functionId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => 'command', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'path', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'size', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_function', - 'type' => Database::INDEX_KEY, - 'attributes' => ['functionId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'executions' => [ - '$collection' => Database::METADATA, - '$id' => 'executions', - 'name' => 'Executions', - 'attributes' => [ - [ - '$id' => 'dateCreated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'functionId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'tagId', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => 'trigger', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'stdout', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'stderr', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'exitCode', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'time', - 'type' => Database::VAR_FLOAT, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'search', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_function', - 'type' => Database::INDEX_KEY, - 'attributes' => ['functionId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_fulltext_search', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [16384], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - - 'certificates' => [ - '$collection' => Database::METADATA, - '$id' => 'certificates', - 'name' => 'Certificates', - 'attributes' => [ - [ - '$id' => 'domain', - 'type' => Database::VAR_STRING, - 'format' => '', - // The maximum total length of a domain name or number is 255 characters. - // https://datatracker.ietf.org/doc/html/rfc2821#section-4.5.3.1 - // https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1.2 - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'issueDate', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'renewDate', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'attempts', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'log', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'updated', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_domain', - 'type' => Database::INDEX_KEY, - 'attributes' => ['domain'], - 'lengths' => [255], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - 'stats' => [ - '$collection' => Database::METADATA, - '$id' => 'stats', - 'name' => 'Stats', - 'attributes' => [ - [ - '$id' => 'metric', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'value', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'time', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'period', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'type', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 1, - 'signed' => false, - 'required' => true, - 'default' => 0, // 0 -> count, 1 -> sum - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => '_key_time', - 'type' => Database::INDEX_KEY, - 'attributes' => ['time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => '_key_metric', - 'type' => Database::INDEX_KEY, - 'attributes' => ['metric'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_metric_period', - 'type' => Database::INDEX_KEY, - 'attributes' => ['metric', 'period'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - ], - ], - 'realtime' => [ - '$collection' => Database::METADATA, - '$id' => 'realtime', - 'name' => 'Realtime Connections', - 'attributes' => [ - [ - '$id' => 'container', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'timestamp', - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'value', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], //TODO: use json filter - ] - ], - 'indexes' => [ - [ - '$id' => '_key_timestamp', - 'type' => Database::INDEX_KEY, - 'attributes' => ['timestamp'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - ] - ], -]; - -return $collections; \ No newline at end of file diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 66ac25d8a9..e652dad628 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -59,13 +59,11 @@ App::post('/v1/projects') ->inject('dbForConsole') ->inject('dbForInternal') ->inject('dbForExternal') - ->inject('consoleDB') - ->action(function ($projectId, $name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal, $consoleDB) { + ->action(function ($projectId, $name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Database $dbForInternal */ /** @var Utopia\Database\Database $dbForExternal */ - /** @var Appwrite\Database\Database $consoleDB */ $team = $dbForConsole->getDocument('teams', $teamId); @@ -106,7 +104,7 @@ App::post('/v1/projects') 'search' => implode(' ', [$projectId, $name]), ])); - $collections = Config::getParam('collections2', []); /** @var array $collections */ + $collections = Config::getParam('collections', []); /** @var array $collections */ $dbForInternal->setNamespace('project_' . $project->getId() . '_internal'); $dbForInternal->create(); @@ -148,8 +146,6 @@ App::post('/v1/projects') $dbForInternal->createCollection($key, $attributes, $indexes); } - $consoleDB->createNamespace($project->getId()); - $response->setStatusCode(Response::STATUS_CODE_CREATED); $response->dynamic($project, Response::MODEL_PROJECT); }); diff --git a/app/http.php b/app/http.php index 82b6e73e3e..28b070d3a4 100644 --- a/app/http.php +++ b/app/http.php @@ -90,7 +90,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { if(!$dbForConsole->exists()) { Console::success('[Setup] - Server database init started...'); - $collections = Config::getParam('collections2', []); /** @var array $collections */ + $collections = Config::getParam('collections', []); /** @var array $collections */ $redis->flushAll(); diff --git a/app/init.php b/app/init.php index 132215a520..6992728987 100644 --- a/app/init.php +++ b/app/init.php @@ -128,7 +128,6 @@ Config::load('auth', __DIR__.'/config/auth.php'); Config::load('providers', __DIR__.'/config/providers.php'); Config::load('platforms', __DIR__.'/config/platforms.php'); Config::load('collections', __DIR__.'/config/collections.php'); -Config::load('collections2', __DIR__.'/config/collections2.php'); Config::load('runtimes', __DIR__.'/config/runtimes.php'); Config::load('roles', __DIR__.'/config/roles.php'); // User roles and scopes Config::load('scopes', __DIR__.'/config/scopes.php'); // User roles and scopes @@ -805,24 +804,6 @@ App::setResource('console', function() { ]); }, []); -App::setResource('consoleDB', function($db, $cache) { - $consoleDB = new DatabaseOld(); - $consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); - $consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects - $consoleDB->setMocks(Config::getParam('collections', [])); - - return $consoleDB; -}, ['db', 'cache']); - -App::setResource('projectDB', function($db, $cache, $project) { - $projectDB = new DatabaseOld(); - $projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)); - $projectDB->setNamespace('app_'.$project->getId()); - $projectDB->setMocks(Config::getParam('collections', [])); - - return $projectDB; -}, ['db', 'cache', 'project']); - App::setResource('dbForInternal', function($db, $cache, $project) { $cache = new Cache(new RedisCache($cache)); diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index be80c6e228..22ce22af13 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -11,6 +11,8 @@ use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Migration\Migration; use Utopia\Validator\Text; +Config::load('collections.old', __DIR__.'/../config/collections.old.php'); + $cli ->task('migrate') ->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true) @@ -29,12 +31,12 @@ $cli $consoleDB ->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)) ->setNamespace('app_console') // Main DB - ->setMocks(Config::getParam('collections', [])); + ->setMocks(Config::getParam('collections.old', [])); $projectDB = new Database(); $projectDB ->setAdapter(new RedisAdapter(new MySQLAdapter($db, $cache), $cache)) - ->setMocks(Config::getParam('collections', [])); + ->setMocks(Config::getParam('collections.old', [])); $console = $consoleDB->getDocument('console'); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index ef151ce3f1..836d00ee1f 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1377,22 +1377,9 @@ class ProjectsConsoleClientTest extends Scope 'store' => '', 'hostname' => 'localhost', ]); - + $this->assertEquals(400, $response['headers']['status-code']); - // $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ - // 'content-type' => 'application/json', - // 'x-appwrite-project' => $this->getProject()['$id'], - // ], $this->getHeaders()), [ - // 'type' => 'web', - // 'name' => 'Web App', - // 'key' => '', - // 'store' => '', - // 'hostname' => 'https://localhost', - // ]); - - // $this->assertEquals(400, $response['headers']['status-code']); - return $data; } @@ -1402,7 +1389,9 @@ class ProjectsConsoleClientTest extends Scope public function testListProjectPlatform($data): array { $id = $data['projectId'] ?? ''; - + + sleep(1); + $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1424,7 +1413,7 @@ class ProjectsConsoleClientTest extends Scope public function testGetProjectPlatform($data): array { $id = $data['projectId'] ?? ''; - + $platformWebId = $data['platformWebId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ diff --git a/tests/unit/General/CollectionsTest.php b/tests/unit/General/CollectionsTest.php index b5d29bd24b..ee79400f2e 100644 --- a/tests/unit/General/CollectionsTest.php +++ b/tests/unit/General/CollectionsTest.php @@ -20,11 +20,11 @@ class CollectionsTest extends TestCase public function testDuplicateRules() { foreach ($this->collections as $key => $collection) { - if (array_key_exists('rules', $collection)) { - foreach ($collection['rules'] as $check) { + if (array_key_exists('attributes', $collection)) { + foreach ($collection['attributes'] as $check) { $occurences = 0; - foreach ($collection['rules'] as $rule) { - if ($rule['key'] == $check['key']) { + foreach ($collection['attributes'] as $attribute) { + if ($attribute['$id'] == $check['$id']) { $occurences++; } } From b55c5a26609a37bcaa6823e9670c11a73007795d Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 1 Dec 2021 12:56:40 +0100 Subject: [PATCH 2/6] fix(ui): elements issue --- public/dist/scripts/app-all.js | 2 +- public/dist/scripts/app.js | 2 +- public/scripts/views/ui/modal.js | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index bfbed66bbf..e8d1a58f26 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -3757,7 +3757,7 @@ if(selected&&list[selected].dataset["selected"]){let parent=element.querySelecto if(!buttonAlias){buttonElements.forEach(button=>{button.innerText=buttonText;button.className=buttonClass;button.type=buttonElement;if(buttonIcon){let iconElement=document.createElement("i");iconElement.className=buttonIcon;button.insertBefore(iconElement,button.firstChild);}});} if(buttonEvent){buttonElements.forEach(button=>{button.addEventListener("click",function(){document.dispatchEvent(new CustomEvent(buttonEvent,{bubbles:false,cancelable:true}));});});} element.classList.add("modal");if(!buttonAlias&&!buttonHide){buttonElements.forEach(button=>{element.parentNode.insertBefore(button,element);});} -let open=function(){document.documentElement.classList.add("modal-open");document.dispatchEvent(new CustomEvent("modal-open",{bubbles:false,cancelable:true}));element.classList.add("open");element.classList.remove("close");let form=element.querySelector('form');let elements=(form&&form.elements)?[...form.elements]:[];for(let index=0;index{button.addEventListener("click",open);});document.addEventListener("keydown",function(event){if(event.which===27){close();}});element.addEventListener("blur",close);let closeButtons=element.querySelectorAll("[data-ui-modal-close]");for(let i=0;i{button.innerText=buttonText;button.className=buttonClass;button.type=buttonElement;if(buttonIcon){let iconElement=document.createElement("i");iconElement.className=buttonIcon;button.insertBefore(iconElement,button.firstChild);}});} if(buttonEvent){buttonElements.forEach(button=>{button.addEventListener("click",function(){document.dispatchEvent(new CustomEvent(buttonEvent,{bubbles:false,cancelable:true}));});});} element.classList.add("modal");if(!buttonAlias&&!buttonHide){buttonElements.forEach(button=>{element.parentNode.insertBefore(button,element);});} -let open=function(){document.documentElement.classList.add("modal-open");document.dispatchEvent(new CustomEvent("modal-open",{bubbles:false,cancelable:true}));element.classList.add("open");element.classList.remove("close");let form=element.querySelector('form');let elements=(form&&form.elements)?[...form.elements]:[];for(let index=0;index{button.addEventListener("click",open);});document.addEventListener("keydown",function(event){if(event.which===27){close();}});element.addEventListener("blur",close);let closeButtons=element.querySelectorAll("[data-ui-modal-close]");for(let i=0;i Date: Wed, 1 Dec 2021 13:05:24 +0100 Subject: [PATCH 3/6] fix(ui): creat enum attribute validation --- public/dist/scripts/app-all.js | 5 +++-- public/dist/scripts/app.js | 5 +++-- public/scripts/init.js | 10 ++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index e8d1a58f26..e17498357c 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -3433,8 +3433,9 @@ const highest=history.reduce((prev,curr)=>{return(curr.value>prev)?curr.value:pr newHistory[project]=history;} let currentSnapshot={...current};for(let index=.1;index<=1;index+=.05){let currentTransition={...currentSnapshot};for(const project in current){if(project in newHistory){let base=newHistory[project][bars-2].value;let cur=currentSnapshot[project];let offset=(cur-base)*index;currentTransition[project]=base+Math.floor(offset);}} realtime.setCurrent(currentTransition);await sleep(250);} -realtime.setHistory(newHistory);}});window.formValidation=(form,fields)=>{const elements=form.elements;const actionHandler=(action,attribute)=>{switch(action){case"disable":elements[attribute].setAttribute("disabled",true);elements[attribute].dispatchEvent(new Event('change'));break;case"enable":elements[attribute].removeAttribute("disabled");elements[attribute].dispatchEvent(new Event('change'));break;case"unvalue":elements[attribute].value="";break;case"check":elements[attribute].value="true";break;case"uncheck":elements[attribute].value="false";break;}};for(const field in fields){for(const attribute in fields[field]){const attr=fields[field][attribute];if(Array.isArray(attr)){attr.forEach(action=>{if(elements[field].value==="true"){actionHandler(action,attribute);}})}else{const condition=attr.if.some(c=>{return elements[c].value==="true";});if(condition){for(const thenAction in attr.then){attr.then[thenAction].forEach(action=>{actionHandler(action,thenAction);});}}else{for(const elseAction in attr.else){attr.else[elseAction].forEach(action=>{actionHandler(action,elseAction);});}}}}} -form.addEventListener("reset",()=>{for(const key in fields){if(Object.hasOwnProperty.call(fields,key)){const element=form.elements[key];element.setAttribute("value","");element.removeAttribute("disabled");element.dispatchEvent(new Event("change"));}}});};(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;message.remove=function(){scope.remove(message.id);};scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;} +realtime.setHistory(newHistory);}});window.formValidation=(form,fields)=>{const elements=Array.from(form.querySelectorAll('[name]')).reduce((prev,curr)=>{if(!curr.name){return prev;} +prev[curr.name]=curr;return prev;},{});const actionHandler=(action,attribute)=>{switch(action){case"disable":elements[attribute].setAttribute("disabled",true);elements[attribute].dispatchEvent(new Event('change'));break;case"enable":elements[attribute].removeAttribute("disabled");elements[attribute].dispatchEvent(new Event('change'));break;case"unvalue":elements[attribute].value="";break;case"check":elements[attribute].value="true";break;case"uncheck":elements[attribute].value="false";break;}};for(const field in fields){for(const attribute in fields[field]){const attr=fields[field][attribute];if(Array.isArray(attr)){attr.forEach(action=>{if(elements[field].value==="true"){actionHandler(action,attribute);}})}else{const condition=attr.if.some(c=>{return elements[c].value==="true";});if(condition){for(const thenAction in attr.then){attr.then[thenAction].forEach(action=>{actionHandler(action,thenAction);});}}else{for(const elseAction in attr.else){attr.else[elseAction].forEach(action=>{actionHandler(action,elseAction);});}}}}} +form.addEventListener("reset",()=>{for(const key in fields){if(Object.hasOwnProperty.call(fields,key)){const element=elements[key];element.setAttribute("value","");element.removeAttribute("disabled");element.dispatchEvent(new Event("change"));}}});};(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;message.remove=function(){scope.remove(message.id);};scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;} if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);} return message.id;},remove:function(id){let scope=this;for(let index=0;index{if(elements[field].value==="true"){actionHandler(action,attribute);}})}else{const condition=attr.if.some(c=>{return elements[c].value==="true";});if(condition){for(const thenAction in attr.then){attr.then[thenAction].forEach(action=>{actionHandler(action,thenAction);});}}else{for(const elseAction in attr.else){attr.else[elseAction].forEach(action=>{actionHandler(action,elseAction);});}}}}} -form.addEventListener("reset",()=>{for(const key in fields){if(Object.hasOwnProperty.call(fields,key)){const element=form.elements[key];element.setAttribute("value","");element.removeAttribute("disabled");element.dispatchEvent(new Event("change"));}}});};(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;message.remove=function(){scope.remove(message.id);};scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;} +realtime.setHistory(newHistory);}});window.formValidation=(form,fields)=>{const elements=Array.from(form.querySelectorAll('[name]')).reduce((prev,curr)=>{if(!curr.name){return prev;} +prev[curr.name]=curr;return prev;},{});const actionHandler=(action,attribute)=>{switch(action){case"disable":elements[attribute].setAttribute("disabled",true);elements[attribute].dispatchEvent(new Event('change'));break;case"enable":elements[attribute].removeAttribute("disabled");elements[attribute].dispatchEvent(new Event('change'));break;case"unvalue":elements[attribute].value="";break;case"check":elements[attribute].value="true";break;case"uncheck":elements[attribute].value="false";break;}};for(const field in fields){for(const attribute in fields[field]){const attr=fields[field][attribute];if(Array.isArray(attr)){attr.forEach(action=>{if(elements[field].value==="true"){actionHandler(action,attribute);}})}else{const condition=attr.if.some(c=>{return elements[c].value==="true";});if(condition){for(const thenAction in attr.then){attr.then[thenAction].forEach(action=>{actionHandler(action,thenAction);});}}else{for(const elseAction in attr.else){attr.else[elseAction].forEach(action=>{actionHandler(action,elseAction);});}}}}} +form.addEventListener("reset",()=>{for(const key in fields){if(Object.hasOwnProperty.call(fields,key)){const element=elements[key];element.setAttribute("value","");element.removeAttribute("disabled");element.dispatchEvent(new Event("change"));}}});};(function(window){"use strict";window.ls.container.set('alerts',function(window){return{list:[],ids:0,counter:0,max:5,add:function(message,time){var scope=this;message.id=scope.ids++;message.remove=function(){scope.remove(message.id);};scope.counter++;scope.list.unshift(message);if(scope.counter>scope.max){scope.list.pop();scope.counter--;} if(time>0){window.setTimeout(function(message){return function(){scope.remove(message.id)}}(message),time);} return message.id;},remove:function(id){let scope=this;for(let index=0;index { }); window.formValidation = (form, fields) => { - const elements = form.elements; + const elements = Array.from(form.querySelectorAll('[name]')).reduce((prev, curr) => { + if(!curr.name) { + return prev; + } + prev[curr.name] = curr; + return prev; + }, {}); const actionHandler = (action, attribute) => { switch (action) { case "disable": @@ -178,7 +184,7 @@ window.formValidation = (form, fields) => { form.addEventListener("reset", () => { for (const key in fields) { if (Object.hasOwnProperty.call(fields, key)) { - const element = form.elements[key]; + const element = elements[key]; element.setAttribute("value", ""); element.removeAttribute("disabled"); element.dispatchEvent(new Event("change")); From c8d7ea807120519fc74eea61fea57bfab7c5c6fb Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 1 Dec 2021 13:19:15 +0100 Subject: [PATCH 4/6] fix(ui): collection tables --- app/views/console/database/collection.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index ea97bad34b..a8b59e8d4a 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -78,11 +78,11 @@ $logs = $this->getParam('logs', null);