From eaf31fdb785ea4bb3fddc25e37d96f28d31ef109 Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Sun, 5 Mar 2023 14:35:47 +0530
Subject: [PATCH 01/14] Updated the error to 501 error code for custom domain
when _APP_DOMAIN and _APP_DOMAIN_TARGET is setup incorrectly
---
app/config/errors.php | 5 +++++
app/controllers/api/projects.php | 2 +-
src/Appwrite/Extend/Exception.php | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/app/config/errors.php b/app/config/errors.php
index 266e017e93..741fb406b8 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -474,6 +474,11 @@ return [
'description' => 'Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
'code' => 404,
],
+ Exception::ENV_VARIABLE_INCORRECT_SETUP => [
+ 'name' => Exception::ENV_VARIABLE_INCORRECT_SETUP,
+ 'description' => 'For Custom Domain ENV Variable is not setup correctly',
+ 'code' => 501,
+ ],
Exception::PROJECT_UNKNOWN => [
'name' => Exception::PROJECT_UNKNOWN,
'description' => 'The project ID is either missing or not valid. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php
index 29a193748d..6dc543d2c0 100644
--- a/app/controllers/api/projects.php
+++ b/app/controllers/api/projects.php
@@ -1340,7 +1340,7 @@ App::post('/v1/projects/:projectId/domains')
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
- throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.');
+ throw new Exception(Exception::ENV_VARIABLE_INCORRECT_SETUP, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.');
}
$domain = new Domain($domain);
diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php
index 8b240aa971..35ebc04b0c 100644
--- a/src/Appwrite/Extend/Exception.php
+++ b/src/Appwrite/Extend/Exception.php
@@ -177,6 +177,7 @@ class Exception extends \Exception
public const DOMAIN_NOT_FOUND = 'domain_not_found';
public const DOMAIN_ALREADY_EXISTS = 'domain_already_exists';
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
+ public const ENV_VARIABLE_INCORRECT_SETUP = 'env_variable_setup_incorrectly';
/** GraphqQL */
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
From 7f3000439a39de4ba9184f0502d9ac6892a8ac72 Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Sun, 5 Mar 2023 14:35:47 +0530
Subject: [PATCH 02/14] Updated ENV_VARIABLE_INCORRECT_SETUP to
DOMAIN_VARIABLE_INCORRECT
---
app/config/errors.php | 5 +++++
app/controllers/api/projects.php | 2 +-
src/Appwrite/Extend/Exception.php | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/config/errors.php b/app/config/errors.php
index 741fb406b8..0e965d9d7e 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -539,6 +539,11 @@ return [
'description' => 'A Domain with the requested ID already exists.',
'code' => 409,
],
+ Exception::DOMAIN_VERIFICATION_FAILED => [
+ 'name' => Exception::DOMAIN_VARIABLE_INCORRECT,
+ 'description' => 'Your Appwrite instance is not publicly accessible. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.',
+ 'code' => 501,
+ ],
Exception::VARIABLE_NOT_FOUND => [
'name' => Exception::VARIABLE_NOT_FOUND,
'description' => 'Variable with the requested ID could not be found.',
diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php
index 6dc543d2c0..d9c556b462 100644
--- a/app/controllers/api/projects.php
+++ b/app/controllers/api/projects.php
@@ -1340,7 +1340,7 @@ App::post('/v1/projects/:projectId/domains')
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
- throw new Exception(Exception::ENV_VARIABLE_INCORRECT_SETUP, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.');
+ throw new Exception(Exception::DOMAIN_VERIFICATION_FAILED, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
}
$domain = new Domain($domain);
diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php
index 35ebc04b0c..fda96b4bcd 100644
--- a/src/Appwrite/Extend/Exception.php
+++ b/src/Appwrite/Extend/Exception.php
@@ -177,7 +177,7 @@ class Exception extends \Exception
public const DOMAIN_NOT_FOUND = 'domain_not_found';
public const DOMAIN_ALREADY_EXISTS = 'domain_already_exists';
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
- public const ENV_VARIABLE_INCORRECT_SETUP = 'env_variable_setup_incorrectly';
+ public const DOMAIN_VARIABLE_INCORRECT = 'domain_variable_incorrect';
/** GraphqQL */
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
From 7a4cea9f79efc0a7ef555b9d26f6a471a5426689 Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Wed, 8 Mar 2023 17:21:37 +0530
Subject: [PATCH 03/14] Removed ENV_VARIABLE_INCORRECT_SETUP
---
app/config/errors.php | 6 ------
1 file changed, 6 deletions(-)
diff --git a/app/config/errors.php b/app/config/errors.php
index 0e965d9d7e..8adb8634d5 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -473,12 +473,6 @@ return [
'name' => Exception::PROJECT_NOT_FOUND,
'description' => 'Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
'code' => 404,
- ],
- Exception::ENV_VARIABLE_INCORRECT_SETUP => [
- 'name' => Exception::ENV_VARIABLE_INCORRECT_SETUP,
- 'description' => 'For Custom Domain ENV Variable is not setup correctly',
- 'code' => 501,
- ],
Exception::PROJECT_UNKNOWN => [
'name' => Exception::PROJECT_UNKNOWN,
'description' => 'The project ID is either missing or not valid. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
From b16c789282d94524c0f9cdbd63fc73f399d981dd Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Wed, 8 Mar 2023 17:23:15 +0530
Subject: [PATCH 04/14] Fixing the bracket
---
app/config/errors.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/config/errors.php b/app/config/errors.php
index 8adb8634d5..a682882d2e 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -473,6 +473,7 @@ return [
'name' => Exception::PROJECT_NOT_FOUND,
'description' => 'Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
'code' => 404,
+ ],
Exception::PROJECT_UNKNOWN => [
'name' => Exception::PROJECT_UNKNOWN,
'description' => 'The project ID is either missing or not valid. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.',
From 31a903d1440c50189247f7e29fc2f7d2030b1e4b Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Fri, 10 Mar 2023 00:24:33 +0530
Subject: [PATCH 05/14] Updated the error message for target check fails in
custom domain creation
---
app/config/errors.php | 10 +++++-----
app/controllers/api/projects.php | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/config/errors.php b/app/config/errors.php
index a682882d2e..ef131896fd 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -534,11 +534,6 @@ return [
'description' => 'A Domain with the requested ID already exists.',
'code' => 409,
],
- Exception::DOMAIN_VERIFICATION_FAILED => [
- 'name' => Exception::DOMAIN_VARIABLE_INCORRECT,
- 'description' => 'Your Appwrite instance is not publicly accessible. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.',
- 'code' => 501,
- ],
Exception::VARIABLE_NOT_FOUND => [
'name' => Exception::VARIABLE_NOT_FOUND,
'description' => 'Variable with the requested ID could not be found.',
@@ -554,6 +549,11 @@ return [
'description' => 'Domain verification for the requested domain has failed.',
'code' => 401,
],
+ Exception::DOMAIN_VARIABLE_INCORRECT => [
+ 'name' => Exception::DOMAIN_VARIABLE_INCORRECT,
+ 'description' => 'Your Appwrite instance is not publicly accessible. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.',
+ 'code' => 501,
+ ],
Exception::GRAPHQL_NO_QUERY => [
'name' => Exception::GRAPHQL_NO_QUERY,
'description' => 'Param "query" is not optional.',
diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php
index d9c556b462..bc57cf04ac 100644
--- a/app/controllers/api/projects.php
+++ b/app/controllers/api/projects.php
@@ -1340,7 +1340,7 @@ App::post('/v1/projects/:projectId/domains')
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
- throw new Exception(Exception::DOMAIN_VERIFICATION_FAILED, 'Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
+ throw new Exception(Exception::DOMAIN_VARIABLE_INCORRECT, 'Unreachable CNAME target (' . $target->get() . '). Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
}
$domain = new Domain($domain);
From 8b5e0e1f1a903e7b9205f727bb269867acc41347 Mon Sep 17 00:00:00 2001
From: Bhaskar Singh
Date: Tue, 21 Mar 2023 20:33:42 +0530
Subject: [PATCH 06/14] Updating the exception variable name for easy
readability
---
app/config/errors.php | 4 ++--
app/controllers/api/projects.php | 2 +-
src/Appwrite/Extend/Exception.php | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/config/errors.php b/app/config/errors.php
index ef131896fd..0c1524772d 100644
--- a/app/config/errors.php
+++ b/app/config/errors.php
@@ -549,8 +549,8 @@ return [
'description' => 'Domain verification for the requested domain has failed.',
'code' => 401,
],
- Exception::DOMAIN_VARIABLE_INCORRECT => [
- 'name' => Exception::DOMAIN_VARIABLE_INCORRECT,
+ Exception::DOMAIN_TARGET_INVALID => [
+ 'name' => Exception::DOMAIN_TARGET_INVALID,
'description' => 'Your Appwrite instance is not publicly accessible. Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.',
'code' => 501,
],
diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php
index bc57cf04ac..deff177ab2 100644
--- a/app/controllers/api/projects.php
+++ b/app/controllers/api/projects.php
@@ -1340,7 +1340,7 @@ App::post('/v1/projects/:projectId/domains')
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));
if (!$target->isKnown() || $target->isTest()) {
- throw new Exception(Exception::DOMAIN_VARIABLE_INCORRECT, 'Unreachable CNAME target (' . $target->get() . '). Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
+ throw new Exception(Exception::DOMAIN_TARGET_INVALID, 'Unreachable CNAME target (' . $target->get() . '). Please check the _APP_DOMAIN_TARGET environment variable of your Appwrite server.');
}
$domain = new Domain($domain);
diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php
index fda96b4bcd..9e2e8f9cb1 100644
--- a/src/Appwrite/Extend/Exception.php
+++ b/src/Appwrite/Extend/Exception.php
@@ -177,7 +177,7 @@ class Exception extends \Exception
public const DOMAIN_NOT_FOUND = 'domain_not_found';
public const DOMAIN_ALREADY_EXISTS = 'domain_already_exists';
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
- public const DOMAIN_VARIABLE_INCORRECT = 'domain_variable_incorrect';
+ public const DOMAIN_TARGET_INVALID = 'domain_target_invalid';
/** GraphqQL */
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
From 857898551513a7bf24d37ae67c79d7e200d55bda Mon Sep 17 00:00:00 2001
From: Christy Jacob
Date: Fri, 24 Mar 2023 20:16:20 +0000
Subject: [PATCH 07/14] feat: update readme
---
README-CN.md | 2 +-
README.md | 1 +
composer.lock | 105 ++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 100 insertions(+), 8 deletions(-)
diff --git a/README-CN.md b/README-CN.md
index 6de3770f20..d1243da985 100644
--- a/README-CN.md
+++ b/README-CN.md
@@ -12,7 +12,7 @@
-
+[](https://appwrite.io/company/careers)
[](https://hacktoberfest.appwrite.io)
[](https://appwrite.io/discord?r=Github)
[](https://github.com/appwrite/appwrite/actions)
diff --git a/README.md b/README.md
index fbf577f100..d39bf510d1 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
+[](https://appwrite.io/company/careers)
[](https://hacktoberfest.appwrite.io)
[](https://appwrite.io/discord?r=Github)
[](https://github.com/appwrite/appwrite/actions)
diff --git a/composer.lock b/composer.lock
index c39816465c..bdbdb61572 100644
--- a/composer.lock
+++ b/composer.lock
@@ -3085,6 +3085,49 @@
},
"time": "2023-02-03T05:44:59+00:00"
},
+ {
+ "name": "doctrine/deprecations",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/deprecations.git",
+ "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
+ "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1|^8.0"
+ },
+ "require-dev": {
+ "doctrine/coding-standard": "^9",
+ "phpunit/phpunit": "^7.5|^8.5|^9.5",
+ "psr/log": "^1|^2|^3"
+ },
+ "suggest": {
+ "psr/log": "Allows logging deprecations via PSR-3 logger implementation"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
+ "homepage": "https://www.doctrine-project.org/",
+ "support": {
+ "issues": "https://github.com/doctrine/deprecations/issues",
+ "source": "https://github.com/doctrine/deprecations/tree/v1.0.0"
+ },
+ "time": "2022-05-02T15:47:09+00:00"
+ },
{
"name": "doctrine/instantiator",
"version": "1.5.0",
@@ -3617,24 +3660,27 @@
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.6.2",
+ "version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
+ "reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
- "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
+ "reference": "1534aea9bde19a5c85c5d1e1f834ab63f4c5dcf5",
"shasum": ""
},
"require": {
+ "doctrine/deprecations": "^1.0",
"php": "^7.4 || ^8.0",
- "phpdocumentor/reflection-common": "^2.0"
+ "phpdocumentor/reflection-common": "^2.0",
+ "phpstan/phpdoc-parser": "^1.13"
},
"require-dev": {
"ext-tokenizer": "*",
+ "phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
@@ -3666,9 +3712,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.0"
},
- "time": "2022-10-14T12:47:21+00:00"
+ "time": "2023-03-12T10:13:29+00:00"
},
{
"name": "phpspec/prophecy",
@@ -3738,6 +3784,51 @@
},
"time": "2023-02-02T15:41:36+00:00"
},
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "1.16.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e27e92d939e2e3636f0a1f0afaba59692c0bf571",
+ "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^1.5",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.0",
+ "phpunit/phpunit": "^9.5",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.1"
+ },
+ "time": "2023-02-07T18:11:17+00:00"
+ },
{
"name": "phpunit/php-code-coverage",
"version": "9.2.26",
From a86c1c0a2b5fe7d7f371b58a7625cd4335156e9a Mon Sep 17 00:00:00 2001
From: Steven Nguyen
Date: Fri, 10 Mar 2023 10:51:22 -0800
Subject: [PATCH 08/14] Fix yasd so that the debugger works
* Update the base image since the yasd extension wasn't installed correctly
* Fix the path to the yasd_init.php file
* Use `host.docker.internal` as the remote host because that should always work inside docker
* Mount the dev folder into the appwrite container so the yasd_init.php file is picked up.
---
CONTRIBUTING.md | 3 +--
Dockerfile | 2 +-
dev/yasd_init.php.stub | 2 +-
docker-compose.yml | 2 ++
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index beaa176249..21d9c6df3a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -346,8 +346,7 @@ If you are in PHP Storm you don't need any plugin. Below are the settings requir
1. Create an init file.
2. Duplicate **dev/yasd_init.php.stub** file and name it **dev/yasd_init.php**.
-3. Change the IP address to your development machine's IP. Without the proper IP address, the debugger won't connect.
-4. Set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file.
+3. Set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file.
### VS Code Launch Configuration
diff --git a/Dockerfile b/Dockerfile
index 392f4de5bf..050ccab3cd 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -182,7 +182,7 @@ RUN chmod +x /usr/local/bin/doctor && \
RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/
# Enable Extensions
-RUN if [ "$DEBUG" == "true" ]; then printf "zend_extension=yasd \nyasd.debug_mode=remote \nyasd.init_file=/usr/local/dev/yasd_init.php \nyasd.remote_port=9005 \nyasd.log_level=-1" >> /usr/local/etc/php/conf.d/yasd.ini; fi
+RUN if [ "$DEBUG" == "true" ]; then printf "zend_extension=yasd \nyasd.debug_mode=remote \nyasd.init_file=/usr/src/code/dev/yasd_init.php \nyasd.remote_port=9005 \nyasd.log_level=-1" >> /usr/local/etc/php/conf.d/yasd.ini; fi
RUN if [ "$DEBUG" == "true" ]; then echo "opcache.enable=0" >> /usr/local/etc/php/conf.d/appwrite.ini; fi
RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini
diff --git a/dev/yasd_init.php.stub b/dev/yasd_init.php.stub
index a7d977fbf7..efcc37c0b5 100644
--- a/dev/yasd_init.php.stub
+++ b/dev/yasd_init.php.stub
@@ -1,4 +1,4 @@
Date: Fri, 31 Mar 2023 17:14:59 +0200
Subject: [PATCH 09/14] feat: console service
---
app/config/services.php | 13 +++++
app/controllers/api/console.php | 40 +++++++++++++
docs/references/console/variables.md | 1 +
phpunit.xml | 1 +
src/Appwrite/Utopia/Response.php | 5 ++
.../Response/Model/ConsoleVariables.php | 58 +++++++++++++++++++
tests/e2e/Services/Console/ConsoleBase.php | 7 +++
.../Console/ConsoleConsoleClientTest.php | 33 +++++++++++
.../Console/ConsoleCustomClientTest.php | 27 +++++++++
.../Console/ConsoleCustomServerTest.php | 27 +++++++++
10 files changed, 212 insertions(+)
create mode 100644 app/controllers/api/console.php
create mode 100644 docs/references/console/variables.md
create mode 100644 src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
create mode 100644 tests/e2e/Services/Console/ConsoleBase.php
create mode 100644 tests/e2e/Services/Console/ConsoleConsoleClientTest.php
create mode 100644 tests/e2e/Services/Console/ConsoleCustomClientTest.php
create mode 100644 tests/e2e/Services/Console/ConsoleCustomServerTest.php
diff --git a/app/config/services.php b/app/config/services.php
index e0d5e263f2..eeabbc21d1 100644
--- a/app/config/services.php
+++ b/app/config/services.php
@@ -186,4 +186,17 @@ return [
'optional' => true,
'icon' => '/images/services/graphql.png',
],
+ 'console' => [
+ 'key' => 'console',
+ 'name' => 'Conosle',
+ 'subtitle' => 'The Console service allows you to interact with Console relevant informations.',
+ 'description' => '',
+ 'controller' => 'api/console.php',
+ 'sdk' => true,
+ 'docs' => true,
+ 'docsUrl' => '',
+ 'tests' => false,
+ 'optional' => false,
+ 'icon' => '',
+ ],
];
diff --git a/app/controllers/api/console.php b/app/controllers/api/console.php
new file mode 100644
index 0000000000..eb9bab1fb3
--- /dev/null
+++ b/app/controllers/api/console.php
@@ -0,0 +1,40 @@
+groups(['console'])
+ ->inject('console')
+ ->action(function (Document $project) {
+ if ($project->getId() !== 'console') {
+ throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
+ }
+ });
+
+
+App::get('/v1/console/variables')
+ ->desc('Get Variables')
+ ->groups(['api', 'projects'])
+ ->label('scope', 'projects.read')
+ ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
+ ->label('sdk.namespace', 'console')
+ ->label('sdk.method', 'variables')
+ ->label('sdk.description', '/docs/references/console/variables.md')
+ ->label('sdk.response.code', Response::STATUS_CODE_OK)
+ ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
+ ->label('sdk.response.model', Response::MODEL_CONSOLE_VARIABLES)
+ ->inject('response')
+ ->action(function (Response $response) {
+
+ $variables = new Document([
+ '_APP_DOMAIN_TARGET' => App::getEnv('_APP_DOMAIN_TARGET'),
+ '_APP_STORAGE_LIMIT' => +App::getEnv('_APP_STORAGE_LIMIT'),
+ '_APP_FUNCTIONS_SIZE_LIMIT' => +App::getEnv('_APP_FUNCTIONS_SIZE_LIMIT'),
+ '_APP_USAGE_STATS' => App::getEnv('_APP_USAGE_STATS'),
+ ]);
+
+ $response->dynamic($variables, Response::MODEL_CONSOLE_VARIABLES);
+ });
diff --git a/docs/references/console/variables.md b/docs/references/console/variables.md
new file mode 100644
index 0000000000..ddfa2b9b72
--- /dev/null
+++ b/docs/references/console/variables.md
@@ -0,0 +1 @@
+Get all Environment Variables that are relevant for the console.
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 5b4bcdb99c..f83f9f0fae 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -20,6 +20,7 @@
./tests/e2e/General
./tests/e2e/Scopes
./tests/e2e/Services/Account
+ ./tests/e2e/Services/Console
./tests/e2e/Services/Realtime
./tests/e2e/Services/Avatars
./tests/e2e/Services/Databases
diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php
index 2ab514f91c..1f69dbb772 100644
--- a/src/Appwrite/Utopia/Response.php
+++ b/src/Appwrite/Utopia/Response.php
@@ -44,6 +44,7 @@ use Appwrite\Utopia\Response\Model\Execution;
use Appwrite\Utopia\Response\Model\Build;
use Appwrite\Utopia\Response\Model\File;
use Appwrite\Utopia\Response\Model\Bucket;
+use Appwrite\Utopia\Response\Model\ConsoleVariables;
use Appwrite\Utopia\Response\Model\Func;
use Appwrite\Utopia\Response\Model\Index;
use Appwrite\Utopia\Response\Model\JWT;
@@ -213,6 +214,9 @@ class Response extends SwooleResponse
public const MODEL_HEALTH_TIME = 'healthTime';
public const MODEL_HEALTH_ANTIVIRUS = 'healthAntivirus';
+ // Console
+ public const MODEL_CONSOLE_VARIABLES = 'consoleVariables';
+
// Deprecated
public const MODEL_PERMISSIONS = 'permissions';
public const MODEL_RULE = 'rule';
@@ -341,6 +345,7 @@ class Response extends SwooleResponse
->setModel(new UsageFunctions())
->setModel(new UsageFunction())
->setModel(new UsageProject())
+ ->setModel(new ConsoleVariables())
// Verification
// Recovery
// Tests (keep last)
diff --git a/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
new file mode 100644
index 0000000000..98d3409fbf
--- /dev/null
+++ b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
@@ -0,0 +1,58 @@
+addRule('_APP_DOMAIN_TARGET', [
+ 'type' => self::TYPE_STRING,
+ 'description' => 'CNAME target for your Appwrite custom domains.',
+ 'default' => '',
+ 'example' => '1.3.0',
+ ])
+ ->addRule('_APP_STORAGE_LIMIT', [
+ 'type' => self::TYPE_INTEGER,
+ 'description' => 'Maximum file size allowed for file upload in bytes.',
+ 'default' => '',
+ 'example' => '1.3.0',
+ ])
+ ->addRule('_APP_FUNCTIONS_SIZE_LIMIT', [
+ 'type' => self::TYPE_INTEGER,
+ 'description' => 'Maximum file size allowed for deployment in bytes.',
+ 'default' => '',
+ 'example' => '1.3.0',
+ ])
+ ->addRule('_APP_USAGE_STATS', [
+ 'type' => self::TYPE_STRING,
+ 'description' => 'Defines if usage stats are enabled. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'.',
+ 'default' => '',
+ 'example' => '1.3.0',
+ ]);
+ }
+
+ /**
+ * Get Name
+ *
+ * @return string
+ */
+ public function getName(): string
+ {
+ return 'Console Variables';
+ }
+
+ /**
+ * Get Type
+ *
+ * @return string
+ */
+ public function getType(): string
+ {
+ return Response::MODEL_CONSOLE_VARIABLES;
+ }
+}
diff --git a/tests/e2e/Services/Console/ConsoleBase.php b/tests/e2e/Services/Console/ConsoleBase.php
new file mode 100644
index 0000000000..e7d2eabd01
--- /dev/null
+++ b/tests/e2e/Services/Console/ConsoleBase.php
@@ -0,0 +1,7 @@
+client->call(Client::METHOD_GET, '/console/variables', array_merge([
+ 'content-type' => 'application/json',
+ 'x-appwrite-project' => $this->getProject()['$id'],
+ ], $this->getHeaders()), []);
+
+ $this->assertEquals(200, $response['headers']['status-code']);
+ $this->assertCount(4, $response['body']);
+ $this->assertIsString($response['body']['_APP_DOMAIN_TARGET']);
+ $this->assertIsInt($response['body']['_APP_STORAGE_LIMIT']);
+ $this->assertIsInt($response['body']['_APP_FUNCTIONS_SIZE_LIMIT']);
+ $this->assertIsString($response['body']['_APP_DOMAIN_TARGET']);
+ }
+}
diff --git a/tests/e2e/Services/Console/ConsoleCustomClientTest.php b/tests/e2e/Services/Console/ConsoleCustomClientTest.php
new file mode 100644
index 0000000000..4b78b7f43c
--- /dev/null
+++ b/tests/e2e/Services/Console/ConsoleCustomClientTest.php
@@ -0,0 +1,27 @@
+client->call(Client::METHOD_GET, '/console/variables', array_merge([
+ 'content-type' => 'application/json',
+ 'x-appwrite-project' => $this->getProject()['$id'],
+ ], $this->getHeaders()), []);
+
+ $this->assertEquals(401, $response['headers']['status-code']);
+ }
+}
diff --git a/tests/e2e/Services/Console/ConsoleCustomServerTest.php b/tests/e2e/Services/Console/ConsoleCustomServerTest.php
new file mode 100644
index 0000000000..3748bbe546
--- /dev/null
+++ b/tests/e2e/Services/Console/ConsoleCustomServerTest.php
@@ -0,0 +1,27 @@
+client->call(Client::METHOD_GET, '/console/variables', array_merge([
+ 'content-type' => 'application/json',
+ 'x-appwrite-project' => $this->getProject()['$id'],
+ ], $this->getHeaders()), []);
+
+ $this->assertEquals(401, $response['headers']['status-code']);
+ }
+}
From 42df2435ecd9096f5de8aa34e2d4b266c526cf04 Mon Sep 17 00:00:00 2001
From: Torsten Dittmann
Date: Fri, 31 Mar 2023 17:17:30 +0200
Subject: [PATCH 10/14] fix: sdk.auth for console service
---
app/controllers/api/console.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/api/console.php b/app/controllers/api/console.php
index eb9bab1fb3..7e721bb925 100644
--- a/app/controllers/api/console.php
+++ b/app/controllers/api/console.php
@@ -19,7 +19,7 @@ App::get('/v1/console/variables')
->desc('Get Variables')
->groups(['api', 'projects'])
->label('scope', 'projects.read')
- ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
+ ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
->label('sdk.namespace', 'console')
->label('sdk.method', 'variables')
->label('sdk.description', '/docs/references/console/variables.md')
From 28758d479498d256ae10bf21964e2dcc24563dd5 Mon Sep 17 00:00:00 2001
From: Torsten Dittmann
Date: Fri, 31 Mar 2023 18:47:00 +0200
Subject: [PATCH 11/14] fix: typo
---
app/config/services.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/config/services.php b/app/config/services.php
index eeabbc21d1..f7fe5fe8d1 100644
--- a/app/config/services.php
+++ b/app/config/services.php
@@ -188,8 +188,8 @@ return [
],
'console' => [
'key' => 'console',
- 'name' => 'Conosle',
- 'subtitle' => 'The Console service allows you to interact with Console relevant informations.',
+ 'name' => 'Console',
+ 'subtitle' => 'The Console service allows you to interact with console relevant informations.',
'description' => '',
'controller' => 'api/console.php',
'sdk' => true,
From bd7d28f7d19cd82e2faad67f456b782b6b75153f Mon Sep 17 00:00:00 2001
From: Torsten Dittmann
Date: Fri, 31 Mar 2023 22:48:34 +0200
Subject: [PATCH 12/14] fix: steven review
---
app/controllers/api/console.php | 2 +-
src/Appwrite/Utopia/Response/Model/ConsoleVariables.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/controllers/api/console.php b/app/controllers/api/console.php
index 7e721bb925..060fa10cb5 100644
--- a/app/controllers/api/console.php
+++ b/app/controllers/api/console.php
@@ -7,7 +7,7 @@ use Utopia\Database\Document;
App::init()
->groups(['console'])
- ->inject('console')
+ ->inject('project')
->action(function (Document $project) {
if ($project->getId() !== 'console') {
throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
diff --git a/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
index 98d3409fbf..e52638f82a 100644
--- a/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
+++ b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php
@@ -14,25 +14,25 @@ class ConsoleVariables extends Model
'type' => self::TYPE_STRING,
'description' => 'CNAME target for your Appwrite custom domains.',
'default' => '',
- 'example' => '1.3.0',
+ 'example' => 'appwrite.io',
])
->addRule('_APP_STORAGE_LIMIT', [
'type' => self::TYPE_INTEGER,
'description' => 'Maximum file size allowed for file upload in bytes.',
'default' => '',
- 'example' => '1.3.0',
+ 'example' => '30000000',
])
->addRule('_APP_FUNCTIONS_SIZE_LIMIT', [
'type' => self::TYPE_INTEGER,
'description' => 'Maximum file size allowed for deployment in bytes.',
'default' => '',
- 'example' => '1.3.0',
+ 'example' => '30000000',
])
->addRule('_APP_USAGE_STATS', [
'type' => self::TYPE_STRING,
'description' => 'Defines if usage stats are enabled. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'.',
'default' => '',
- 'example' => '1.3.0',
+ 'example' => 'enabled',
]);
}
From 577ba9b0ec39d136114d2a24e818fb1ba3675d70 Mon Sep 17 00:00:00 2001
From: Steven <1477010+stnguyen90@users.noreply.github.com>
Date: Thu, 6 Apr 2023 13:48:52 -0700
Subject: [PATCH 13/14] Fix email-base.tpl path in certificates worker
---
app/workers/certificates.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/workers/certificates.php b/app/workers/certificates.php
index 33752215b8..03dfe0231c 100644
--- a/app/workers/certificates.php
+++ b/app/workers/certificates.php
@@ -383,7 +383,7 @@ class CertificatesV1 extends Worker
$locale->setDefault('en');
}
- $body = Template::fromFile(__DIR__ . '/../../config/locale/templates/email-base.tpl');
+ $body = Template::fromFile(__DIR__ . '/../config/locale/templates/email-base.tpl');
$subject = \sprintf($locale->getText("emails.certificate.subject"), $domain);
$body->setParam('{{domain}}', $domain);
From 6e9e6aa6b356b796ce154ae183e60a15dfd94dcf Mon Sep 17 00:00:00 2001
From: "Vincent (Wen Yu) Ge"
Date: Mon, 10 Apr 2023 22:18:07 +0000
Subject: [PATCH 14/14] relink to inputfile docs
---
app/controllers/api/storage.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php
index 271f2af6b3..9396d9f29b 100644
--- a/app/controllers/api/storage.php
+++ b/app/controllers/api/storage.php
@@ -348,7 +348,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
->label('sdk.response.model', Response::MODEL_FILE)
->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).')
->param('fileId', '', new CustomId(), 'File ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
- ->param('file', [], new File(), 'Binary file.', false)
+ ->param('file', [], new File(), 'Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](/docs/storage#file-input).', false)
->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).', true)
->inject('request')
->inject('response')