From 4f438ffe34c5e1a447c18e4a775a661927200735 Mon Sep 17 00:00:00 2001 From: Char Date: Thu, 16 Jul 2026 11:02:16 +0200 Subject: [PATCH 1/6] feat: Serenity sentiment-overview brand-presence endpoint (LLMO-6300) Add GET /v2/orgs/:spaceCatId/brands/:brandId/serenity/brand-presence/sentiment-overview, sourcing per-week brand sentiment from the Semrush SENTIMENT element and emitting the legacy { weeklyTrends } contract so the existing chart consumes it drop-in. Direct parallel of the LLMO-6179 url-inspector cutover. - definition (buildSentimentOverviewPayload + transformSentimentOverviewResponse): mirrors cited-domains' verified filter shape; rolls the element's daily bar rows into ISO weeks - getSentimentOverview service method (single call, like cited-domains) - listSentimentOverview controller handler: authorizeOrg, required+validated dates, 366-day span cap, region->project_id resolution - route + required-capabilities (brand:read) + FACS llmo/can_view classification - OpenAPI path + SerenityBrandPresenceSentimentOverview schema - serenity OpenAPI contract fixture covering the new endpoint Transform verified against a live dev probe of the SENTIMENT element. Note: the element's three sentiment legends are overlapping sets (a mixed-sentiment prompt counts in each), so promptsWithSentiment can exceed totalPrompts; percentages are unaffected (internal ratios). Co-Authored-By: Claude Opus 4.8 --- docs/index.html | 76 ++++++- docs/openapi/api.yaml | 2 + docs/openapi/schemas.yaml | 73 ++++++ docs/openapi/serenity-api.yaml | 113 ++++++++++ src/controllers/elements.js | 78 +++++++ src/routes/facs-capabilities.js | 1 + src/routes/index.js | 1 + src/routes/required-capabilities.js | 1 + src/support/elements/definitions/index.js | 4 + .../definitions/sentiment-overview.js | 211 ++++++++++++++++++ src/support/elements/elements-service.js | 26 +++ test/openapi-contract/serenity-api.test.js | 35 ++- test/routes/index.test.js | 1 + 13 files changed, 616 insertions(+), 6 deletions(-) create mode 100644 src/support/elements/definitions/sentiment-overview.js diff --git a/docs/index.html b/docs/index.html index 377fce609..e53077052 100644 --- a/docs/index.html +++ b/docs/index.html @@ -489,7 +489,7 @@ " aria-expanded="false" class="sc-tYrig hNMAOR">