diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8069db5e6f..02b824a88d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -427,7 +427,7 @@ jobs:
FunctionsSchedule,
GraphQL,
Health,
- Insights,
+ Advisor,
Locale,
Projects,
Realtime,
diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php
index 56677b9810..03877333fa 100644
--- a/app/config/collections/platform.php
+++ b/app/config/collections/platform.php
@@ -2102,7 +2102,7 @@ $platformCollections = [
'$id' => ID::custom('_key_project_target'),
'type' => Database::INDEX_KEY,
'attributes' => ['projectInternalId', 'targetType', 'target'],
- 'lengths' => [0, 0, 700],
+ 'lengths' => [null, null, 700],
'orders' => [],
],
],
diff --git a/app/config/scopes/project.php b/app/config/scopes/project.php
index 9891c1041e..e55ad370cd 100644
--- a/app/config/scopes/project.php
+++ b/app/config/scopes/project.php
@@ -362,23 +362,21 @@ return [
'category' => 'Other',
],
- // Insights
+ // Advisor
'insights.read' => [
- 'description' => 'Access to read insights and their CTAs.',
+ 'description' => 'Access to read insights under Advisor service.',
'category' => 'Other',
],
'insights.write' => [
- 'description' => 'Reserved for advisor insight ingestion outside CE.',
+ 'description' => 'Reserved for Advisor insight ingestion outside CE.',
'category' => 'Other',
],
-
- // Reports
'reports.read' => [
- 'description' => 'Access to read analyzer reports and their insights.',
+ 'description' => 'Access to read reports under Advisor service.',
'category' => 'Other',
],
'reports.write' => [
- 'description' => 'Access to delete analyzer reports.',
+ 'description' => 'Access to delete reports under Advisor service.',
'category' => 'Other',
],
];
diff --git a/app/config/services.php b/app/config/services.php
index 6ce828c4c0..f829937623 100644
--- a/app/config/services.php
+++ b/app/config/services.php
@@ -313,11 +313,11 @@ return [
'key' => 'advisor',
'name' => 'Advisor',
'subtitle' => 'The Advisor service surfaces actionable reports about your project resources, with CTA descriptors for one-click remediation in the console.',
- 'description' => '/docs/services/insights.md',
+ 'description' => '/docs/services/advisor.md',
'controller' => '', // Uses modules
'sdk' => true,
'docs' => true,
- 'docsUrl' => 'https://appwrite.io/docs/server/insights',
+ 'docsUrl' => 'https://appwrite.io/docs/server/advisor',
'tests' => true,
'optional' => true,
'icon' => '/images/services/insights.png',
diff --git a/app/init/constants.php b/app/init/constants.php
index 8c570b1865..7ff63d7380 100644
--- a/app/init/constants.php
+++ b/app/init/constants.php
@@ -1,12 +1,12 @@
value; // legacy databases.createIndex
-const INSIGHT_TYPE_TABLES_DB_INDEX = InsightType::TABLES_DB_INDEX->value; // tablesDB.createIndex
-const INSIGHT_TYPE_DOCUMENTS_DB_INDEX = InsightType::DOCUMENTS_DB_INDEX->value; // documentsDB.createIndex
-const INSIGHT_TYPE_VECTORS_DB_INDEX = InsightType::VECTORS_DB_INDEX->value; // vectorsDB.createIndex
-const INSIGHT_TYPE_DATABASE_PERFORMANCE = InsightType::DATABASE_PERFORMANCE->value;
-const INSIGHT_TYPE_SITE_PERFORMANCE = InsightType::SITE_PERFORMANCE->value;
-const INSIGHT_TYPE_SITE_ACCESSIBILITY = InsightType::SITE_ACCESSIBILITY->value;
-const INSIGHT_TYPE_SITE_SEO = InsightType::SITE_SEO->value;
-const INSIGHT_TYPE_FUNCTION_PERFORMANCE = InsightType::FUNCTION_PERFORMANCE->value;
-
const INSIGHT_TYPES = [
- INSIGHT_TYPE_DATABASE_INDEX,
- INSIGHT_TYPE_TABLES_DB_INDEX,
- INSIGHT_TYPE_DOCUMENTS_DB_INDEX,
- INSIGHT_TYPE_VECTORS_DB_INDEX,
- INSIGHT_TYPE_DATABASE_PERFORMANCE,
- INSIGHT_TYPE_SITE_PERFORMANCE,
- INSIGHT_TYPE_SITE_ACCESSIBILITY,
- INSIGHT_TYPE_SITE_SEO,
- INSIGHT_TYPE_FUNCTION_PERFORMANCE,
+ Type::DATABASE_INDEX->value, // legacy databases.createIndex
+ Type::TABLES_DB_INDEX->value, // tablesDB.createIndex
+ Type::DOCUMENTS_DB_INDEX->value, // documentsDB.createIndex
+ Type::VECTORS_DB_INDEX->value, // vectorsDB.createIndex
+ Type::DATABASE_PERFORMANCE->value,
+ Type::SITE_PERFORMANCE->value,
+ Type::SITE_ACCESSIBILITY->value,
+ Type::SITE_SEO->value,
+ Type::FUNCTION_PERFORMANCE->value,
];
// Public API services (SDK namespaces) that an insight CTA's `service` can reference.
// Analyzers must pick the one matching the engine the resource lives in.
-const INSIGHT_CTA_SERVICE_DATABASES = InsightCTAService::DATABASES->value; // legacy
-const INSIGHT_CTA_SERVICE_TABLES_DB = InsightCTAService::TABLES_DB->value;
-const INSIGHT_CTA_SERVICE_DOCUMENTS_DB = InsightCTAService::DOCUMENTS_DB->value;
-const INSIGHT_CTA_SERVICE_VECTORS_DB = InsightCTAService::VECTORS_DB->value;
+const INSIGHT_CTA_SERVICES = [
+ CTAService::DATABASES->value, // legacy
+ CTAService::TABLES_DB->value,
+ CTAService::DOCUMENTS_DB->value,
+ CTAService::VECTORS_DB->value,
+];
// Public API method names that an insight CTA's `method` can reference for index suggestions.
-const INSIGHT_CTA_METHOD_CREATE_INDEX = InsightCTAMethod::CREATE_INDEX->value;
+const INSIGHT_CTA_METHODS = [
+ CTAMethod::CREATE_INDEX->value,
+];
// Insight severities
-const INSIGHT_SEVERITY_INFO = InsightSeverity::INFO->value;
-const INSIGHT_SEVERITY_WARNING = InsightSeverity::WARNING->value;
-const INSIGHT_SEVERITY_CRITICAL = InsightSeverity::CRITICAL->value;
-
const INSIGHT_SEVERITIES = [
- INSIGHT_SEVERITY_INFO,
- INSIGHT_SEVERITY_WARNING,
- INSIGHT_SEVERITY_CRITICAL,
+ Severity::INFO->value,
+ Severity::WARNING->value,
+ Severity::CRITICAL->value,
];
// Insight statuses
-const INSIGHT_STATUS_ACTIVE = InsightStatus::ACTIVE->value;
-const INSIGHT_STATUS_DISMISSED = InsightStatus::DISMISSED->value;
-
const INSIGHT_STATUSES = [
- INSIGHT_STATUS_ACTIVE,
- INSIGHT_STATUS_DISMISSED,
+ Status::ACTIVE->value,
+ Status::DISMISSED->value,
];
// Report types
-const REPORT_TYPE_LIGHTHOUSE = ReportType::LIGHTHOUSE->value;
-const REPORT_TYPE_AUDIT = ReportType::AUDIT->value;
-const REPORT_TYPE_DATABASE_ANALYZER = ReportType::DATABASE_ANALYZER->value;
-
const REPORT_TYPES = [
- REPORT_TYPE_LIGHTHOUSE,
- REPORT_TYPE_AUDIT,
- REPORT_TYPE_DATABASE_ANALYZER,
+ Report::LIGHTHOUSE->value,
+ Report::AUDIT->value,
+ Report::DATABASE_ANALYZER->value,
];
// Resource types for Tokens
diff --git a/docs/services/advisor.md b/docs/services/advisor.md
new file mode 100644
index 0000000000..2fa3943829
--- /dev/null
+++ b/docs/services/advisor.md
@@ -0,0 +1,3 @@
+The Advisor service provides read access to analyzer reports and their nested insights for a project.
+
+Use the reports endpoints to list and fetch analyzer runs, then use the insights endpoints to inspect individual findings attached to a report.
diff --git a/phpunit.xml b/phpunit.xml
index 1202cbebbe..32e865fe35 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -38,7 +38,7 @@
./tests/e2e/Services/Messaging
./tests/e2e/Services/Migrations
./tests/e2e/Services/Project
- ./tests/e2e/Services/Insights
+ ./tests/e2e/Services/Advisor
./tests/e2e/Services/Functions/FunctionsBase.php
./tests/e2e/Services/Functions/FunctionsCustomServerTest.php
./tests/e2e/Services/Functions/FunctionsCustomClientTest.php
diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Get.php b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Get.php
index 126ea759ae..2c986c1feb 100644
--- a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Get.php
+++ b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Get.php
@@ -34,7 +34,7 @@ class Get extends Action
->label('sdk', new Method(
namespace: 'advisor',
group: 'insights',
- name: 'get',
+ name: 'getInsight',
description: <<getDocument('insights', $insightId);
+ $insight = $report->find('$id', $insightId, 'insights');
- if (
- $insight->isEmpty()
- || $insight->getAttribute('projectInternalId') !== $project->getSequence()
- || $insight->getAttribute('reportInternalId') !== $report->getSequence()
- ) {
+ if (empty($insight)) {
throw new Exception(Exception::INSIGHT_NOT_FOUND);
}
+ $insight = $insight instanceof Document ? $insight : new Document($insight);
+
$response->dynamic($insight, Response::MODEL_INSIGHT);
}
}
diff --git a/tests/e2e/Services/Insights/InsightsBase.php b/tests/e2e/Services/Advisor/AdvisorBase.php
similarity index 98%
rename from tests/e2e/Services/Insights/InsightsBase.php
rename to tests/e2e/Services/Advisor/AdvisorBase.php
index b1b73931f1..029fcf83e1 100644
--- a/tests/e2e/Services/Insights/InsightsBase.php
+++ b/tests/e2e/Services/Advisor/AdvisorBase.php
@@ -1,11 +1,11 @@