diff --git a/app/config/collections.php b/app/config/collections.php index 1d2d4e8741..7826d51306 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1216,14 +1216,14 @@ $commonCollections = [ 'type' => Database::INDEX_FULLTEXT, 'attributes' => ['name'], 'lengths' => [], - 'orders' => [Database::ORDER_ASC], + 'orders' => [], ], [ '$id' => ID::custom('_key_search'), 'type' => Database::INDEX_FULLTEXT, 'attributes' => ['search'], 'lengths' => [], - 'orders' => [Database::ORDER_ASC], + 'orders' => [], ], [ '$id' => ID::custom('_key_enabled'), @@ -2078,7 +2078,7 @@ $projectCollections = array_merge([ 'type' => Database::INDEX_FULLTEXT, 'attributes' => ['search'], 'lengths' => [], - 'orders' => [Database::ORDER_ASC], + 'orders' => [], ], [ '$id' => ID::custom('_key_name'), @@ -2938,7 +2938,7 @@ $projectCollections = array_merge([ 'array' => false, 'filters' => [], ], - ], + ], 'indexes' => [ [ '$id' => '_key_accessedAt', @@ -3035,22 +3035,22 @@ $projectCollections = array_merge([ 'type' => Database::INDEX_KEY, 'attributes' => ['resourceInternalId'], 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_resourceId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], + 'orders' => [], ], [ '$id' => '_key_resourceType', 'type' => Database::INDEX_KEY, 'attributes' => ['resourceType'], - 'lengths' => [100], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => '_key_resourceId_resourceType', + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceId', 'resourceType'], + 'lengths' => [Database::LENGTH_KEY, 100], + 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], + ], [ '$id' => '_key_uniqueKey', 'type' => Database::INDEX_UNIQUE, @@ -3607,7 +3607,7 @@ $consoleCollections = array_merge([ [ '$id' => ID::custom('_key_region_resourceType_resourceUpdatedAt'), 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'resourceType','resourceUpdatedAt'], + 'attributes' => ['region', 'resourceType', 'resourceUpdatedAt'], 'lengths' => [], 'orders' => [], ], @@ -4213,7 +4213,7 @@ $consoleCollections = array_merge([ '$id' => '_key_resourceType', 'type' => Database::INDEX_KEY, 'attributes' => ['resourceType'], - 'lengths' => [100], + 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], ], @@ -4849,7 +4849,7 @@ $bucketCollections = [ 'type' => Database::INDEX_FULLTEXT, 'attributes' => ['search'], 'lengths' => [], - 'orders' => [Database::ORDER_ASC], + 'orders' => [], ], [ '$id' => ID::custom('_key_bucket'), diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index c55dc0e4dc..e8f4670417 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -33,8 +33,8 @@ App::post('/v1/proxy/rules') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_PROXY_RULE) ->param('domain', null, new ValidatorDomain(), 'Domain name.') - ->param('resourceType', null, new WhiteList(['api', 'function']), 'Action definition for the rule. Possible values are "api", "function", or "redirect"') - ->param('resourceId', '', new UID(), 'ID of resource for the action type. If resourceType is "api" or "url", leave empty. If resourceType is "function", provide ID of the function.', true) + ->param('resourceType', null, new WhiteList(['api', 'function']), 'Action definition for the rule. Possible values are "api", "function"') + ->param('resourceId', '', new UID(), 'ID of resource for the action type. If resourceType is "api", leave empty. If resourceType is "function", provide ID of the function.', true) ->inject('response') ->inject('project') ->inject('events') diff --git a/docker-compose.yml b/docker-compose.yml index 83627def16..7c2f574ae7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,8 +72,6 @@ services: - traefik.http.routers.appwrite_api_https.rule=PathPrefix(`/`) - traefik.http.routers.appwrite_api_https.service=appwrite_api - traefik.http.routers.appwrite_api_https.tls=true - - traefik.http.routers.appwrite_api_https.tls.domains[0].main=$_APP_DOMAIN_FUNCTIONS - - traefik.http.routers.appwrite_api_https.tls.domains[0].sans=*.$_APP_DOMAIN_FUNCTIONS volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 1f56a51e0d..7cc15647f8 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -263,6 +263,8 @@ class Response extends SwooleResponse public const MODEL_PERMISSIONS = 'permissions'; public const MODEL_RULE = 'rule'; public const MODEL_TASK = 'task'; + public const MODEL_DOMAIN = 'domain'; + public const MODEL_DOMAIN_LIST = 'domainList'; // Tests (keep last) public const MODEL_MOCK = 'mock'; diff --git a/src/Appwrite/Utopia/Response/Filters/V12.php b/src/Appwrite/Utopia/Response/Filters/V12.php index d9e4caacfd..79d22ad044 100644 --- a/src/Appwrite/Utopia/Response/Filters/V12.php +++ b/src/Appwrite/Utopia/Response/Filters/V12.php @@ -81,6 +81,7 @@ class V12 extends Filter case Response::MODEL_WEBHOOK_LIST: case Response::MODEL_KEY_LIST: case Response::MODEL_PLATFORM_LIST: + case Response::MODEL_DOMAIN_LIST: case Response::MODEL_COUNTRY_LIST: case Response::MODEL_CONTINENT_LIST: case Response::MODEL_LANGUAGE_LIST: diff --git a/tests/resources/functions/node/index.js b/tests/resources/functions/node/index.js index f15c32ccaa..041e4a8c12 100644 --- a/tests/resources/functions/node/index.js +++ b/tests/resources/functions/node/index.js @@ -2,17 +2,17 @@ module.exports = async(context) => { context.log('Amazing Function Log'); return context.res.json({ - 'APPWRITE_FUNCTION_ID' : process.env.APPWRITE_FUNCTION_ID ? ? '', - 'APPWRITE_FUNCTION_NAME' : process.env.APPWRITE_FUNCTION_NAME ? ? '', - 'APPWRITE_FUNCTION_DEPLOYMENT' : process.env.APPWRITE_FUNCTION_DEPLOYMENT ? ? '', - 'APPWRITE_FUNCTION_TRIGGER' : context.req.headers['x-appwrite-trigger'] ? ? '', + 'APPWRITE_FUNCTION_ID' : process.env.APPWRITE_FUNCTION_ID ?? '', + 'APPWRITE_FUNCTION_NAME' : process.env.APPWRITE_FUNCTION_NAME ?? '', + 'APPWRITE_FUNCTION_DEPLOYMENT' : process.env.APPWRITE_FUNCTION_DEPLOYMENT ?? '', + 'APPWRITE_FUNCTION_TRIGGER' : context.req.headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' : process.env.APPWRITE_FUNCTION_RUNTIME_NAME, 'APPWRITE_FUNCTION_RUNTIME_VERSION' : process.env.APPWRITE_FUNCTION_RUNTIME_VERSION, - 'APPWRITE_FUNCTION_EVENT' : context.req.headers['x-appwrite-event'] ? ? '', - 'APPWRITE_FUNCTION_EVENT_DATA' : context.req.bodyRaw ? ? '', - 'APPWRITE_FUNCTION_DATA' : context.req.bodyRaw ? ? '', - 'APPWRITE_FUNCTION_USER_ID' : context.req.headers['x-appwrite-user-id'] ? ? '', - 'APPWRITE_FUNCTION_JWT' : context.req.headers['x-appwrite-user-jwt'] ? ? '', + 'APPWRITE_FUNCTION_EVENT' : context.req.headers['x-appwrite-event'] ?? '', + 'APPWRITE_FUNCTION_EVENT_DATA' : context.req.bodyRaw ?? '', + 'APPWRITE_FUNCTION_DATA' : context.req.bodyRaw ?? '', + 'APPWRITE_FUNCTION_USER_ID' : context.req.headers['x-appwrite-user-id'] ?? '', + 'APPWRITE_FUNCTION_JWT' : context.req.headers['x-appwrite-user-jwt'] ?? '', 'APPWRITE_FUNCTION_PROJECT_ID' : process.env.APPWRITE_FUNCTION_PROJECT_ID, 'CUSTOM_VARIABLE' : process.env.CUSTOM_VARIABLE }); diff --git a/tests/unit/Utopia/Response/Filters/V15Test.php b/tests/unit/Utopia/Response/Filters/V15Test.php index e174a6c3c7..fc38e5320b 100644 --- a/tests/unit/Utopia/Response/Filters/V15Test.php +++ b/tests/unit/Utopia/Response/Filters/V15Test.php @@ -562,6 +562,40 @@ class V15Test extends TestCase $this->assertEquals($expected, $result); } + /** + * @dataProvider createdAtUpdatedAtProvider + */ + public function testDomain(array $content, array $expected): void + { + $model = Response::MODEL_DOMAIN; + + $result = $this->filter->parse($content, $model); + + $this->assertEquals($expected, $result); + } + + /** + * @dataProvider createdAtUpdatedAtProvider + */ + public function testDomainList(array $content, array $expected): void + { + $model = Response::MODEL_DOMAIN_LIST; + + $content = [ + 'domains' => [$content], + 'total' => 1, + ]; + + $expected = [ + 'domains' => [$expected], + 'total' => 1, + ]; + + $result = $this->filter->parse($content, $model); + + $this->assertEquals($expected, $result); + } + public function executionProvider(): array { return [