Skip to content

Open source alternative to Semrush and Ahrefs

Make the dashboard a home for monitoring your website (#872)

Ben Senescubdbb56490517
diff --git a/AGENTS.md b/AGENTS.md
index 9e7a88d4..4f4dcc8f 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -31,11 +31,12 @@
## Plugin versions
-- When a PR adds, edits, or removes an MCP tool (including its schema, description, or behavior), a shipped skill, or plugin configuration, bump the OpenSEO plugin version in the same PR. Internal-only skills, tests, and website-only changes do not require a bump.
-- A bump is routine and cheap, never a reason to hold back an MCP change. The plugin only points at the hosted MCP server, so tool changes reach users on deploy either way. When a fix applies to both the app and an MCP tool, ship it to both; the MCP should be as good as the app.
-- Keep `plugins/openseo/.codex-plugin/plugin.json`, `plugins/openseo/.claude-plugin/plugin.json`, and `plugins/openseo/.cursor-plugin/plugin.json` on the same version. Default to a patch bump unless the maintainer requests a minor or major bump.
-- Bump once per PR relative to `origin/main`, not once per edit or tool. If main advances the plugin version before merge, update the branch to a version newer than main. The app's `package.json` version follows its separate release process.
-- Run `pnpm sync-plugin-skills` after changing a shipped skill and include the updated plugin copy. Call out plugin version and instruction changes for maintainer review.
+- Bump the OpenSEO plugin version when a PR adds a new MCP tool, adds a new shipped skill, or substantially changes a shipped skill's workflow or instructions. Substantial skill changes include changing its required steps, tool choices, or expected output.
+- Routine fixes, refactors, and changes to existing tools' implementation, behavior, schemas, or descriptions do not require a bump. Neither do minor skill edits, internal-only skills, tests, website or app changes, or routine plugin configuration edits. Use judgment for other major plugin changes; do not bump merely because a plugin-related file changed.
+- The plugin points at the hosted MCP server, so server changes reach users on deploy without a plugin version bump. When a fix applies to both the app and an MCP tool, ship it to both.
+- When a bump is warranted, keep `plugins/openseo/.codex-plugin/plugin.json`, `plugins/openseo/.claude-plugin/plugin.json`, and `plugins/openseo/.cursor-plugin/plugin.json` on the same version. Default to a patch bump unless the maintainer requests a minor or major bump.
+- Bump once per PR relative to `origin/main`, not once per edit or tool. For a PR that requires a bump, if main advances the plugin version before merge, update the branch to a version newer than main. Otherwise, keep main's version. The app's `package.json` version follows its separate release process.
+- Run `pnpm sync-plugin-skills` after changing a shipped skill and include the updated plugin copy, even when no version bump is needed. Call out plugin version and instruction changes for maintainer review.
## Documentation audience
diff --git a/docs/maintainers/specs/0015-website-dashboard.md b/docs/maintainers/specs/0015-website-dashboard.md
new file mode 100644
index 00000000..8af4abd2
--- /dev/null
+++ b/docs/maintainers/specs/0015-website-dashboard.md
@@ -0,0 +1,37 @@
+# Website dashboard
+
+The dashboard is the home for monitoring the current project's website. Research pages remain available for investigating other websites and exploring larger datasets.
+
+## Views
+
+The dashboard has addressable Overview, Keywords and Backlinks tabs. Opening a tab mounts its detail view; inactive views do not fetch their data. Rank tracking remains in its existing workflow and is omitted from the dashboard.
+
+Overview keeps the existing onboarding checklist and completion rules. The checklist appears only on Overview.
+
+Overview includes new search queries and recent link activity. New referring domains take precedence over new backlinks. When the provider reports no new domains, the card shows new backlinks; when neither exists, it offers a path to the full backlink view. Domain discovery dates identify newly observed referring sites, rather than assuming every recently discovered link comes from a new domain.
+
+Keywords uses Search Console for New keywords, Top keywords and Striking distance. Top keywords sorts by clicks. Striking distance shows query/page pairs at average positions 5–20, sorted by impressions. A link opens full GSC Insights for deeper exploration. New keywords have at least ten impressions in seven completed days and no observations in the preceding 28 days. When the baseline reaches its row limit, each candidate is checked directly against the earlier period. The new view examines up to 25 candidates from the first 25,000 recent queries. Top keywords shows up to 25,000 queries from the last 28 days. The views display Google's average position over the relevant period, rather than a live rank. Keyword tables support text and metric filters, sorting and pagination. Google can omit some queries, so these views do not promise exhaustive coverage. Search Console results are saved and reused between visits. Paid provider snapshots remain available through research workflows.
+
+Backlinks displays recently discovered links, recently checked lost links, and the latest live links, with up to 25 referring domains per view. Text, link type, domain rank and spam score filters refine loaded results. Date semantics and source details are available through an information popover.
+
+Saving a website in the app starts its first 50-page audit with JavaScript rendering, subject to the account's audit capacity and rendering credits. Concurrent saves share one startup attempt. Existing audits are not restarted on later saves. A failed startup preserves the website and tells the user why the scan could not start. The overview Site health card links to Site Audit and shows the latest saved audit matching the project website, progress while running, and a manual scan action when no audit exists. Dashboard visits do not start audits.
+
+The unconnected Google Analytics card first asks whether the user uses GA4. Yes opens the existing connection flow. No permanently dismisses the optional card for that project and suggests using another analytics provider's MCP with their agent. Connecting GA4 later restores the data card.
+
+## Refresh behavior
+
+Provider usage draws from the customer's credits. Link activity, backlink detail views and Search Console keyword views refresh after 24 hours. Refreshes happen on visits, with empty results cached too. Failed refreshes preserve saved data and delay another attempt. Concurrent refresh attempts share a claim. The overview does not request backlink totals.
+
+Client and server cache identities include the relevant site, market or connected property. Changing project settings must not show a previous site's results as current.
+
+## Alternatives
+
+Fetching every view on entry would improve immediate tab switching but spend credits on data the customer never opens. Loading paid detail views on demand keeps the first visit lighter. Free Search Console discovery remains visible on Overview.
+
+Scheduled refreshes would provide updates while customers are away. Visit-triggered refreshes fit this version because inactive projects do not need background updates. Alerts and scheduled digests can be evaluated separately.
+
+Provider keyword snapshots alone cannot reliably identify newly acquired keywords. Search Console comparison gives stronger first-party evidence; source popovers acknowledge both datasets' limits.
+
+A manual first audit would avoid starting work for an unintended site, but delay the first useful result. Automatically scanning a newly saved website shortens that wait. JavaScript rendering makes the initial scan useful for sites whose content depends on scripts.
+
+A complete replacement of audit and performance workflows would duplicate existing capabilities. The dashboard reuses their data and offers direct paths to the full tools.
diff --git a/drizzle/pg/0031_demonic_kinsey_walden.sql b/drizzle/pg/0031_demonic_kinsey_walden.sql
new file mode 100644
index 00000000..03d410e9
--- /dev/null
+++ b/drizzle/pg/0031_demonic_kinsey_walden.sql
@@ -0,0 +1,8 @@
+CREATE TABLE "data_refresh_claims" (
+ "key" text PRIMARY KEY NOT NULL,
+ "organization_id" text NOT NULL,
+ "token" text NOT NULL,
+ "next_attempt_at" bigint NOT NULL
+);
+--> statement-breakpoint
+ALTER TABLE "data_refresh_claims" ADD CONSTRAINT "data_refresh_claims_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;
\ No newline at end of file
diff --git a/drizzle/pg/meta/0031_snapshot.json b/drizzle/pg/meta/0031_snapshot.json
new file mode 100644
index 00000000..01c1fc70
--- /dev/null
+++ b/drizzle/pg/meta/0031_snapshot.json
@@ -0,0 +1,5355 @@
+{
+ "id": "00d55d7e-d89a-4de8-b216-b6a0cfbfb380",
+ "prevId": "638a1969-fe5a-456c-92f0-f7f2f46a9cfb",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.backlink_snapshots": {
+ "name": "backlink_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rank": {
+ "name": "rank",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backlinks": {
+ "name": "backlinks",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "referring_domains": {
+ "name": "referring_domains",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "broken_backlinks": {
+ "name": "broken_backlinks",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_backlinks": {
+ "name": "new_backlinks",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lost_backlinks": {
+ "name": "lost_backlinks",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "new_referring_domains": {
+ "name": "new_referring_domains",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lost_referring_domains": {
+ "name": "lost_referring_domains",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "backlink_snapshots_project_captured_idx": {
+ "name": "backlink_snapshots_project_captured_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "captured_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "backlink_snapshots_project_id_projects_id_fk": {
+ "name": "backlink_snapshots_project_id_projects_id_fk",
+ "tableFrom": "backlink_snapshots",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.crawler_credentials": {
+ "name": "crawler_credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "host": {
+ "name": "host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signature_input": {
+ "name": "signature_input",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signature": {
+ "name": "signature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "crawler_credentials_project_host_idx": {
+ "name": "crawler_credentials_project_host_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "host",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "crawler_credentials_project_id_projects_id_fk": {
+ "name": "crawler_credentials_project_id_projects_id_fk",
+ "tableFrom": "crawler_credentials",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.dashboard_step_dismissals": {
+ "name": "dashboard_step_dismissals",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step": {
+ "name": "step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "dashboard_step_dismissals_project_idx": {
+ "name": "dashboard_step_dismissals_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "dashboard_step_dismissals_user_id_user_id_fk": {
+ "name": "dashboard_step_dismissals_user_id_user_id_fk",
+ "tableFrom": "dashboard_step_dismissals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_step_dismissals_project_id_projects_id_fk": {
+ "name": "dashboard_step_dismissals_project_id_projects_id_fk",
+ "tableFrom": "dashboard_step_dismissals",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "dashboard_step_dismissals_user_id_project_id_step_pk": {
+ "name": "dashboard_step_dismissals_user_id_project_id_step_pk",
+ "columns": [
+ "user_id",
+ "project_id",
+ "step"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.data_refresh_claims": {
+ "name": "data_refresh_claims",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "data_refresh_claims_organization_id_organization_id_fk": {
+ "name": "data_refresh_claims_organization_id_organization_id_fk",
+ "tableFrom": "data_refresh_claims",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.keyword_metrics": {
+ "name": "keyword_metrics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "search_volume": {
+ "name": "search_volume",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cpc": {
+ "name": "cpc",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "competition": {
+ "name": "competition",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "keyword_difficulty": {
+ "name": "keyword_difficulty",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "monthly_searches": {
+ "name": "monthly_searches",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fetched_at": {
+ "name": "fetched_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "keyword_metrics_unique_project_keyword_location_language": {
+ "name": "keyword_metrics_unique_project_keyword_location_language",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "keyword",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "language_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "keyword_metrics_lookup_idx": {
+ "name": "keyword_metrics_lookup_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "keyword",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "language_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "fetched_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "keyword_metrics_project_id_projects_id_fk": {
+ "name": "keyword_metrics_project_id_projects_id_fk",
+ "tableFrom": "keyword_metrics",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization_activation_state": {
+ "name": "organization_activation_state",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "first_mcp_authorized_at": {
+ "name": "first_mcp_authorized_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_mcp_tool_call_at": {
+ "name": "first_mcp_tool_call_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_activation_state_organization_id_organization_id_fk": {
+ "name": "organization_activation_state_organization_id_organization_id_fk",
+ "tableFrom": "organization_activation_state",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_activation_state": {
+ "name": "project_activation_state",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "competitor_step_clicked_at": {
+ "name": "competitor_step_clicked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "keyword_step_clicked_at": {
+ "name": "keyword_step_clicked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_card_dismissed_at": {
+ "name": "mcp_card_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ga4_card_dismissed_at": {
+ "name": "ga4_card_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_activation_state_project_id_projects_id_fk": {
+ "name": "project_activation_state_project_id_projects_id_fk",
+ "tableFrom": "project_activation_state",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.projects": {
+ "name": "projects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ai_research_keywords": {
+ "name": "ai_research_keywords",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "projects_one_default_per_organization_idx": {
+ "name": "projects_one_default_per_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"name\" = 'Default' AND \"projects\".\"domain\" IS NULL AND \"projects\".\"archived_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_organization_id_idx": {
+ "name": "projects_organization_id_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "projects_organization_id_organization_id_fk": {
+ "name": "projects_organization_id_organization_id_fk",
+ "tableFrom": "projects",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rank_check_runs": {
+ "name": "rank_check_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "keywords_total": {
+ "name": "keywords_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "keywords_checked": {
+ "name": "keywords_checked",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "is_subset_run": {
+ "name": "is_subset_run",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "rank_check_runs_config_idx": {
+ "name": "rank_check_runs_config_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rank_check_runs_project_idx": {
+ "name": "rank_check_runs_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rank_check_runs_one_active_per_config_idx": {
+ "name": "rank_check_runs_one_active_per_config_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"rank_check_runs\".\"status\" IN ('pending', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rank_check_runs_config_id_rank_tracking_configs_id_fk": {
+ "name": "rank_check_runs_config_id_rank_tracking_configs_id_fk",
+ "tableFrom": "rank_check_runs",
+ "tableTo": "rank_tracking_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rank_check_runs_project_id_projects_id_fk": {
+ "name": "rank_check_runs_project_id_projects_id_fk",
+ "tableFrom": "rank_check_runs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rank_snapshots": {
+ "name": "rank_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tracking_keyword_id": {
+ "name": "tracking_keyword_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device": {
+ "name": "device",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "serp_features": {
+ "name": "serp_features",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "checked_at": {
+ "name": "checked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "rank_snapshots_keyword_device_idx": {
+ "name": "rank_snapshots_keyword_device_idx",
+ "columns": [
+ {
+ "expression": "tracking_keyword_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "checked_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rank_snapshots_run_keyword_device_idx": {
+ "name": "rank_snapshots_run_keyword_device_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tracking_keyword_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rank_snapshots_run_id_rank_check_runs_id_fk": {
+ "name": "rank_snapshots_run_id_rank_check_runs_id_fk",
+ "tableFrom": "rank_snapshots",
+ "tableTo": "rank_check_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rank_tracking_configs": {
+ "name": "rank_tracking_configs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "devices": {
+ "name": "devices",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'both'"
+ },
+ "serp_depth": {
+ "name": "serp_depth",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "schedule_interval": {
+ "name": "schedule_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'weekly'"
+ },
+ "location_name": {
+ "name": "location_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "last_checked_at": {
+ "name": "last_checked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_check_at": {
+ "name": "next_check_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_skip_reason": {
+ "name": "last_skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "rank_tracking_configs_project_active_created_idx": {
+ "name": "rank_tracking_configs_project_active_created_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "is_active",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rank_tracking_configs_national_idx": {
+ "name": "rank_tracking_configs_national_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"rank_tracking_configs\".\"location_name\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rank_tracking_configs_local_idx": {
+ "name": "rank_tracking_configs_local_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"rank_tracking_configs\".\"location_name\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rank_tracking_configs_project_id_projects_id_fk": {
+ "name": "rank_tracking_configs_project_id_projects_id_fk",
+ "tableFrom": "rank_tracking_configs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rank_tracking_keywords": {
+ "name": "rank_tracking_keywords",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "match_case": {
+ "name": "match_case",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "search_volume": {
+ "name": "search_volume",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "keyword_difficulty": {
+ "name": "keyword_difficulty",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cpc": {
+ "name": "cpc",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metrics_fetched_at": {
+ "name": "metrics_fetched_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "rank_tracking_keywords_config_keyword_idx": {
+ "name": "rank_tracking_keywords_config_keyword_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "keyword",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rank_tracking_keywords_config_id_rank_tracking_configs_id_fk": {
+ "name": "rank_tracking_keywords_config_id_rank_tracking_configs_id_fk",
+ "tableFrom": "rank_tracking_keywords",
+ "tableTo": "rank_tracking_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.saved_keyword_tag_assignments": {
+ "name": "saved_keyword_tag_assignments",
+ "schema": "",
+ "columns": {
+ "saved_keyword_id": {
+ "name": "saved_keyword_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "saved_keyword_tag_assignments_unique_idx": {
+ "name": "saved_keyword_tag_assignments_unique_idx",
+ "columns": [
+ {
+ "expression": "saved_keyword_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "saved_keyword_tag_assignments_tag_idx": {
+ "name": "saved_keyword_tag_assignments_tag_idx",
+ "columns": [
+ {
+ "expression": "tag_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "saved_keyword_tag_assignments_saved_keyword_id_saved_keywords_id_fk": {
+ "name": "saved_keyword_tag_assignments_saved_keyword_id_saved_keywords_id_fk",
+ "tableFrom": "saved_keyword_tag_assignments",
+ "tableTo": "saved_keywords",
+ "columnsFrom": [
+ "saved_keyword_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "saved_keyword_tag_assignments_tag_id_saved_keyword_tags_id_fk": {
+ "name": "saved_keyword_tag_assignments_tag_id_saved_keyword_tags_id_fk",
+ "tableFrom": "saved_keyword_tag_assignments",
+ "tableTo": "saved_keyword_tags",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.saved_keyword_tags": {
+ "name": "saved_keyword_tags",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "normalized_name": {
+ "name": "normalized_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "saved_keyword_tags_project_normalized_name_idx": {
+ "name": "saved_keyword_tags_project_normalized_name_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "normalized_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "saved_keyword_tags_project_name_idx": {
+ "name": "saved_keyword_tags_project_name_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "saved_keyword_tags_project_id_projects_id_fk": {
+ "name": "saved_keyword_tags_project_id_projects_id_fk",
+ "tableFrom": "saved_keyword_tags",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.saved_keywords": {
+ "name": "saved_keywords",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "saved_keywords_unique_project_keyword_location_language": {
+ "name": "saved_keywords_unique_project_keyword_location_language",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "keyword",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "location_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "language_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "saved_keywords_project_created_idx": {
+ "name": "saved_keywords_project_created_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "saved_keywords_project_id_projects_id_fk": {
+ "name": "saved_keywords_project_id_projects_id_fk",
+ "tableFrom": "saved_keywords",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_onboarding_answers": {
+ "name": "user_onboarding_answers",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "interested_features": {
+ "name": "interested_features",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'"
+ },
+ "work_for": {
+ "name": "work_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_website_count": {
+ "name": "client_website_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "found_via": {
+ "name": "found_via",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_setup_intent": {
+ "name": "mcp_setup_intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gsc_nudge_dismissed_at": {
+ "name": "gsc_nudge_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "user_onboarding_answers_organization_idx": {
+ "name": "user_onboarding_answers_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_onboarding_answers_user_id_user_id_fk": {
+ "name": "user_onboarding_answers_user_id_user_id_fk",
+ "tableFrom": "user_onboarding_answers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_onboarding_answers_organization_id_organization_id_fk": {
+ "name": "user_onboarding_answers_organization_id_organization_id_fk",
+ "tableFrom": "user_onboarding_answers",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_competitors": {
+ "name": "project_competitors",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "project_competitors_project_domain_idx": {
+ "name": "project_competitors_project_domain_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_competitors_project_id_projects_id_fk": {
+ "name": "project_competitors_project_id_projects_id_fk",
+ "tableFrom": "project_competitors",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_context_sections": {
+ "name": "project_context_sections",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_context_sections_project_id_projects_id_fk": {
+ "name": "project_context_sections_project_id_projects_id_fk",
+ "tableFrom": "project_context_sections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_context_sections_project_id_key_pk": {
+ "name": "project_context_sections_project_id_key_pk",
+ "columns": [
+ "project_id",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_key_pages": {
+ "name": "project_key_pages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "project_key_pages_project_url_idx": {
+ "name": "project_key_pages_project_url_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_key_pages_project_id_projects_id_fk": {
+ "name": "project_key_pages_project_id_projects_id_fk",
+ "tableFrom": "project_key_pages",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_research_log": {
+ "name": "project_research_log",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entry_date": {
+ "name": "entry_date",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "project_research_log_project_date_idx": {
+ "name": "project_research_log_project_date_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entry_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_research_log_project_id_projects_id_fk": {
+ "name": "project_research_log_project_id_projects_id_fk",
+ "tableFrom": "project_research_log",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.reports": {
+ "name": "reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "html": {
+ "name": "html",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "skill": {
+ "name": "skill",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "template_id": {
+ "name": "template_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "shared_at": {
+ "name": "shared_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "reports_project_updated_idx": {
+ "name": "reports_project_updated_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "size_bytes",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "reports_share_token_idx": {
+ "name": "reports_share_token_idx",
+ "columns": [
+ {
+ "expression": "share_token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "reports_project_id_projects_id_fk": {
+ "name": "reports_project_id_projects_id_fk",
+ "tableFrom": "reports",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.report_templates": {
+ "name": "report_templates",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "report_templates_project_name_idx": {
+ "name": "report_templates_project_name_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "report_templates_project_id_projects_id_fk": {
+ "name": "report_templates_project_id_projects_id_fk",
+ "tableFrom": "report_templates",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_issues": {
+ "name": "audit_issues",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "page_url": {
+ "name": "page_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type": {
+ "name": "issue_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'info'"
+ },
+ "details_json": {
+ "name": "details_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "audit_issues_audit_type_idx": {
+ "name": "audit_issues_audit_type_idx",
+ "columns": [
+ {
+ "expression": "audit_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "issue_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_issues_page_id_idx": {
+ "name": "audit_issues_page_id_idx",
+ "columns": [
+ {
+ "expression": "page_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "audit_issues_audit_id_audits_id_fk": {
+ "name": "audit_issues_audit_id_audits_id_fk",
+ "tableFrom": "audit_issues",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "audit_issues_page_id_audit_pages_id_fk": {
+ "name": "audit_issues_page_id_audit_pages_id_fk",
+ "tableFrom": "audit_issues",
+ "tableTo": "audit_pages",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_lighthouse_results": {
+ "name": "audit_lighthouse_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "performance_score": {
+ "name": "performance_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessibility_score": {
+ "name": "accessibility_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "best_practices_score": {
+ "name": "best_practices_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seo_score": {
+ "name": "seo_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lcp_ms": {
+ "name": "lcp_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cls": {
+ "name": "cls",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inp_ms": {
+ "name": "inp_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ttfb_ms": {
+ "name": "ttfb_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "r2_key": {
+ "name": "r2_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload_size_bytes": {
+ "name": "payload_size_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "audit_lighthouse_results_audit_id_idx": {
+ "name": "audit_lighthouse_results_audit_id_idx",
+ "columns": [
+ {
+ "expression": "audit_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_lighthouse_results_page_id_idx": {
+ "name": "audit_lighthouse_results_page_id_idx",
+ "columns": [
+ {
+ "expression": "page_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "audit_lighthouse_results_audit_id_audits_id_fk": {
+ "name": "audit_lighthouse_results_audit_id_audits_id_fk",
+ "tableFrom": "audit_lighthouse_results",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "audit_lighthouse_results_page_id_audit_pages_id_fk": {
+ "name": "audit_lighthouse_results_page_id_audit_pages_id_fk",
+ "tableFrom": "audit_lighthouse_results",
+ "tableTo": "audit_pages",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_pages": {
+ "name": "audit_pages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_url": {
+ "name": "redirect_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meta_description": {
+ "name": "meta_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canonical_url": {
+ "name": "canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "robots_meta": {
+ "name": "robots_meta",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "og_title": {
+ "name": "og_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "og_description": {
+ "name": "og_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "og_image": {
+ "name": "og_image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "h1_count": {
+ "name": "h1_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "h2_count": {
+ "name": "h2_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "h3_count": {
+ "name": "h3_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "h4_count": {
+ "name": "h4_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "h5_count": {
+ "name": "h5_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "h6_count": {
+ "name": "h6_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "heading_order_json": {
+ "name": "heading_order_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "word_count": {
+ "name": "word_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "images_total": {
+ "name": "images_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "images_missing_alt": {
+ "name": "images_missing_alt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "images_json": {
+ "name": "images_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "internal_link_count": {
+ "name": "internal_link_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "external_link_count": {
+ "name": "external_link_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "has_structured_data": {
+ "name": "has_structured_data",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "hreflang_tags_json": {
+ "name": "hreflang_tags_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_indexable": {
+ "name": "is_indexable",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "x_robots_tag": {
+ "name": "x_robots_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "header_canonical_url": {
+ "name": "header_canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crawl_depth": {
+ "name": "crawl_depth",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "in_sitemap": {
+ "name": "in_sitemap",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "content_hash": {
+ "name": "content_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fetch_class": {
+ "name": "fetch_class",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ok'"
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "audit_pages_audit_url_idx": {
+ "name": "audit_pages_audit_url_idx",
+ "columns": [
+ {
+ "expression": "audit_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "url",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "audit_pages_audit_id_audits_id_fk": {
+ "name": "audit_pages_audit_id_audits_id_fk",
+ "tableFrom": "audit_pages",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audits": {
+ "name": "audits",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_by_user_id": {
+ "name": "started_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "start_url": {
+ "name": "start_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "workflow_instance_id": {
+ "name": "workflow_instance_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "pages_crawled": {
+ "name": "pages_crawled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "pages_total": {
+ "name": "pages_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "lighthouse_total": {
+ "name": "lighthouse_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "lighthouse_completed": {
+ "name": "lighthouse_completed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "lighthouse_failed": {
+ "name": "lighthouse_failed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "current_phase": {
+ "name": "current_phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'discovery'"
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_detail": {
+ "name": "error_detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failed_phase": {
+ "name": "failed_phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "audits_project_id_idx": {
+ "name": "audits_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audits_started_by_user_id_idx": {
+ "name": "audits_started_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "started_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "audits_project_id_projects_id_fk": {
+ "name": "audits_project_id_projects_id_fk",
+ "tableFrom": "audits",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sam_sessions": {
+ "name": "sam_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'New chat'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "sam_sessions_project_updated_idx": {
+ "name": "sam_sessions_project_updated_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sam_sessions_project_id_projects_id_fk": {
+ "name": "sam_sessions_project_id_projects_id_fk",
+ "tableFrom": "sam_sessions",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sam_sessions_user_id_user_id_fk": {
+ "name": "sam_sessions_user_id_user_id_fk",
+ "tableFrom": "sam_sessions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "account_accountId_providerId_idx": {
+ "name": "account_accountId_providerId_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "account_google_grant_owner_idx": {
+ "name": "account_google_grant_owner_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"account\".\"provider_id\" in ('google-search-console', 'google-analytics')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 60000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 120
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.invitation": {
+ "name": "invitation",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "invitation_organizationId_idx": {
+ "name": "invitation_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_organization_id_organization_id_fk": {
+ "name": "invitation_organization_id_organization_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.member": {
+ "name": "member",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "member_organizationId_idx": {
+ "name": "member_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "member_userId_idx": {
+ "name": "member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "member_organizationId_userId_uidx": {
+ "name": "member_organizationId_userId_uidx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "member_organization_id_organization_id_fk": {
+ "name": "member_organization_id_organization_id_fk",
+ "tableFrom": "member",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "member_user_id_user_id_fk": {
+ "name": "member_user_id_user_id_fk",
+ "tableFrom": "member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.organization": {
+ "name": "organization",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "organization_slug_uidx": {
+ "name": "organization_slug_uidx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organization_slug_unique": {
+ "name": "organization_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "analytics_opted_out": {
+ "name": "analytics_opted_out",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_active_organization_id": {
+ "name": "last_active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verification_expiresAt_idx": {
+ "name": "verification_expiresAt_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.billing_customer_status": {
+ "name": "billing_customer_status",
+ "schema": "",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "is_paying": {
+ "name": "is_paying",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "paid_plan_id": {
+ "name": "paid_plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "paid_plan_status": {
+ "name": "paid_plan_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "customer_json": {
+ "name": "customer_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "billing_customer_status_organization_id_organization_id_fk": {
+ "name": "billing_customer_status_organization_id_organization_id_fk",
+ "tableFrom": "billing_customer_status",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ga4_connections": {
+ "name": "ga4_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_display_name": {
+ "name": "property_display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_time_zone": {
+ "name": "property_time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "property_currency_code": {
+ "name": "property_currency_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_by_user_id": {
+ "name": "connected_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ga4_account_id": {
+ "name": "ga4_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_account_email": {
+ "name": "connected_account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "ga4_connections_project_idx": {
+ "name": "ga4_connections_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ga4_connections_organization_idx": {
+ "name": "ga4_connections_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ga4_connections_connector_idx": {
+ "name": "ga4_connections_connector_idx",
+ "columns": [
+ {
+ "expression": "connected_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "ga4_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ga4_connections_project_id_projects_id_fk": {
+ "name": "ga4_connections_project_id_projects_id_fk",
+ "tableFrom": "ga4_connections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ga4_connections_organization_id_organization_id_fk": {
+ "name": "ga4_connections_organization_id_organization_id_fk",
+ "tableFrom": "ga4_connections",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.gsc_connections": {
+ "name": "gsc_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "site_url": {
+ "name": "site_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_by_user_id": {
+ "name": "connected_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "gsc_account_id": {
+ "name": "gsc_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_account_email": {
+ "name": "connected_account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"')"
+ }
+ },
+ "indexes": {
+ "gsc_connections_project_idx": {
+ "name": "gsc_connections_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "gsc_connections_organization_idx": {
+ "name": "gsc_connections_organization_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "gsc_connections_project_id_projects_id_fk": {
+ "name": "gsc_connections_project_id_projects_id_fk",
+ "tableFrom": "gsc_connections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gsc_connections_organization_id_organization_id_fk": {
+ "name": "gsc_connections_organization_id_organization_id_fk",
+ "tableFrom": "gsc_connections",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.telemetry_state": {
+ "name": "telemetry_state",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "default": 1
+ },
+ "install_id": {
+ "name": "install_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_version": {
+ "name": "last_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_tool_call_count": {
+ "name": "mcp_tool_call_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_matches": {
+ "name": "ai_matches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "observation_id": {
+ "name": "observation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "own": {
+ "name": "own",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentioned": {
+ "name": "mentioned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cited": {
+ "name": "cited",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "first_mention": {
+ "name": "first_mention",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ai_matches_observation_domain_idx": {
+ "name": "ai_matches_observation_domain_idx",
+ "columns": [
+ {
+ "expression": "observation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_matches_observation_id_ai_observations_id_fk": {
+ "name": "ai_matches_observation_id_ai_observations_id_fk",
+ "tableFrom": "ai_matches",
+ "tableTo": "ai_observations",
+ "columnsFrom": [
+ "observation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_observations": {
+ "name": "ai_observations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt_id": {
+ "name": "prompt_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "engine": {
+ "name": "engine",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "branded": {
+ "name": "branded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "collected_at": {
+ "name": "collected_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "answer_markdown": {
+ "name": "answer_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ai_observations_run_prompt_engine_idx": {
+ "name": "ai_observations_run_prompt_engine_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "prompt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "engine",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_observations_prompt_idx": {
+ "name": "ai_observations_prompt_idx",
+ "columns": [
+ {
+ "expression": "prompt_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_observations_run_id_ai_runs_id_fk": {
+ "name": "ai_observations_run_id_ai_runs_id_fk",
+ "tableFrom": "ai_observations",
+ "tableTo": "ai_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_observations_prompt_id_ai_prompts_id_fk": {
+ "name": "ai_observations_prompt_id_ai_prompts_id_fk",
+ "tableFrom": "ai_observations",
+ "tableTo": "ai_prompts",
+ "columnsFrom": [
+ "prompt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_prompts": {
+ "name": "ai_prompts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "tracker_id": {
+ "name": "tracker_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "paused": {
+ "name": "paused",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived": {
+ "name": "archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ai_prompts_tracker_idx": {
+ "name": "ai_prompts_tracker_idx",
+ "columns": [
+ {
+ "expression": "tracker_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_prompts_tracker_id_ai_trackers_id_fk": {
+ "name": "ai_prompts_tracker_id_ai_trackers_id_fk",
+ "tableFrom": "ai_prompts",
+ "tableTo": "ai_trackers",
+ "columnsFrom": [
+ "tracker_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_runs": {
+ "name": "ai_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "tracker_id": {
+ "name": "tracker_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "ai_runs_project_created_idx": {
+ "name": "ai_runs_project_created_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_runs_one_active_idx": {
+ "name": "ai_runs_one_active_idx",
+ "columns": [
+ {
+ "expression": "tracker_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"ai_runs\".\"status\" IN ('queued', 'running')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_runs_tracker_id_ai_trackers_id_fk": {
+ "name": "ai_runs_tracker_id_ai_trackers_id_fk",
+ "tableFrom": "ai_runs",
+ "tableTo": "ai_trackers",
+ "columnsFrom": [
+ "tracker_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_runs_project_id_projects_id_fk": {
+ "name": "ai_runs_project_id_projects_id_fk",
+ "tableFrom": "ai_runs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_sources": {
+ "name": "ai_sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "observation_id": {
+ "name": "observation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ai_sources_observation_idx": {
+ "name": "ai_sources_observation_idx",
+ "columns": [
+ {
+ "expression": "observation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_sources_observation_id_ai_observations_id_fk": {
+ "name": "ai_sources_observation_id_ai_observations_id_fk",
+ "tableFrom": "ai_sources",
+ "tableTo": "ai_observations",
+ "columnsFrom": [
+ "observation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_trackers": {
+ "name": "ai_trackers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "chatgpt": {
+ "name": "chatgpt",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "gemini": {
+ "name": "gemini",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "google_ai_overview": {
+ "name": "google_ai_overview",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "schedule_interval": {
+ "name": "schedule_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'weekly'"
+ },
+ "next_check_at": {
+ "name": "next_check_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_skip_reason": {
+ "name": "last_skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "ai_trackers_project_idx": {
+ "name": "ai_trackers_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_trackers_due_idx": {
+ "name": "ai_trackers_due_idx",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_check_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_trackers_project_id_projects_id_fk": {
+ "name": "ai_trackers_project_id_projects_id_fk",
+ "tableFrom": "ai_trackers",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/pg/meta/_journal.json b/drizzle/pg/meta/_journal.json
index e32c3243..148d4025 100644
--- a/drizzle/pg/meta/_journal.json
+++ b/drizzle/pg/meta/_journal.json
@@ -218,6 +218,13 @@
"when": 1791317073759,
"tag": "0030_ai_visibility",
"breakpoints": true
+ },
+ {
+ "idx": 31,
+ "version": "7",
+ "when": 1791339857405,
+ "tag": "0031_demonic_kinsey_walden",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/drizzle/sqlite/0053_chubby_tyger_tiger.sql b/drizzle/sqlite/0053_chubby_tyger_tiger.sql
new file mode 100644
index 00000000..80100df6
--- /dev/null
+++ b/drizzle/sqlite/0053_chubby_tyger_tiger.sql
@@ -0,0 +1,7 @@
+CREATE TABLE `data_refresh_claims` (
+ `key` text PRIMARY KEY NOT NULL,
+ `organization_id` text NOT NULL,
+ `token` text NOT NULL,
+ `next_attempt_at` integer NOT NULL,
+ FOREIGN KEY (`organization_id`) REFERENCES `organization`(`id`) ON UPDATE no action ON DELETE cascade
+);
diff --git a/drizzle/sqlite/meta/0053_snapshot.json b/drizzle/sqlite/meta/0053_snapshot.json
new file mode 100644
index 00000000..b8e9b0c6
--- /dev/null
+++ b/drizzle/sqlite/meta/0053_snapshot.json
@@ -0,0 +1,4863 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "4b201370-fcf1-4b2c-b608-42301f5bc5f7",
+ "prevId": "1045185e-80d7-47f5-9957-9a6b2f8fc306",
+ "tables": {
+ "backlink_snapshots": {
+ "name": "backlink_snapshots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "rank": {
+ "name": "rank",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "backlinks": {
+ "name": "backlinks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "referring_domains": {
+ "name": "referring_domains",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "broken_backlinks": {
+ "name": "broken_backlinks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "new_backlinks": {
+ "name": "new_backlinks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lost_backlinks": {
+ "name": "lost_backlinks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "new_referring_domains": {
+ "name": "new_referring_domains",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lost_referring_domains": {
+ "name": "lost_referring_domains",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "backlink_snapshots_project_captured_idx": {
+ "name": "backlink_snapshots_project_captured_idx",
+ "columns": [
+ "project_id",
+ "captured_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "backlink_snapshots_project_id_projects_id_fk": {
+ "name": "backlink_snapshots_project_id_projects_id_fk",
+ "tableFrom": "backlink_snapshots",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "crawler_credentials": {
+ "name": "crawler_credentials",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "host": {
+ "name": "host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signature_input": {
+ "name": "signature_input",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signature": {
+ "name": "signature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "crawler_credentials_project_host_idx": {
+ "name": "crawler_credentials_project_host_idx",
+ "columns": [
+ "project_id",
+ "host"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "crawler_credentials_project_id_projects_id_fk": {
+ "name": "crawler_credentials_project_id_projects_id_fk",
+ "tableFrom": "crawler_credentials",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "dashboard_step_dismissals": {
+ "name": "dashboard_step_dismissals",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "step": {
+ "name": "step",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "dashboard_step_dismissals_project_idx": {
+ "name": "dashboard_step_dismissals_project_idx",
+ "columns": [
+ "project_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "dashboard_step_dismissals_user_id_user_id_fk": {
+ "name": "dashboard_step_dismissals_user_id_user_id_fk",
+ "tableFrom": "dashboard_step_dismissals",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_step_dismissals_project_id_projects_id_fk": {
+ "name": "dashboard_step_dismissals_project_id_projects_id_fk",
+ "tableFrom": "dashboard_step_dismissals",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "dashboard_step_dismissals_user_id_project_id_step_pk": {
+ "columns": [
+ "user_id",
+ "project_id",
+ "step"
+ ],
+ "name": "dashboard_step_dismissals_user_id_project_id_step_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "data_refresh_claims": {
+ "name": "data_refresh_claims",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "data_refresh_claims_organization_id_organization_id_fk": {
+ "name": "data_refresh_claims_organization_id_organization_id_fk",
+ "tableFrom": "data_refresh_claims",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "keyword_metrics": {
+ "name": "keyword_metrics",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "search_volume": {
+ "name": "search_volume",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cpc": {
+ "name": "cpc",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "competition": {
+ "name": "competition",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "keyword_difficulty": {
+ "name": "keyword_difficulty",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "intent": {
+ "name": "intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "monthly_searches": {
+ "name": "monthly_searches",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fetched_at": {
+ "name": "fetched_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "keyword_metrics_unique_project_keyword_location_language": {
+ "name": "keyword_metrics_unique_project_keyword_location_language",
+ "columns": [
+ "project_id",
+ "keyword",
+ "location_code",
+ "language_code"
+ ],
+ "isUnique": true
+ },
+ "keyword_metrics_lookup_idx": {
+ "name": "keyword_metrics_lookup_idx",
+ "columns": [
+ "project_id",
+ "keyword",
+ "location_code",
+ "language_code",
+ "fetched_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "keyword_metrics_project_id_projects_id_fk": {
+ "name": "keyword_metrics_project_id_projects_id_fk",
+ "tableFrom": "keyword_metrics",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organization_activation_state": {
+ "name": "organization_activation_state",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "first_mcp_authorized_at": {
+ "name": "first_mcp_authorized_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "first_mcp_tool_call_at": {
+ "name": "first_mcp_tool_call_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_activation_state_organization_id_organization_id_fk": {
+ "name": "organization_activation_state_organization_id_organization_id_fk",
+ "tableFrom": "organization_activation_state",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "project_activation_state": {
+ "name": "project_activation_state",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "competitor_step_clicked_at": {
+ "name": "competitor_step_clicked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "keyword_step_clicked_at": {
+ "name": "keyword_step_clicked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mcp_card_dismissed_at": {
+ "name": "mcp_card_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ga4_card_dismissed_at": {
+ "name": "ga4_card_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_activation_state_project_id_projects_id_fk": {
+ "name": "project_activation_state_project_id_projects_id_fk",
+ "tableFrom": "project_activation_state",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "projects": {
+ "name": "projects",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ai_research_keywords": {
+ "name": "ai_research_keywords",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "projects_one_default_per_organization_idx": {
+ "name": "projects_one_default_per_organization_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"name\" = 'Default' AND \"projects\".\"domain\" IS NULL AND \"projects\".\"archived_at\" IS NULL"
+ },
+ "projects_organization_id_idx": {
+ "name": "projects_organization_id_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "projects_organization_id_organization_id_fk": {
+ "name": "projects_organization_id_organization_id_fk",
+ "tableFrom": "projects",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rank_check_runs": {
+ "name": "rank_check_runs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "keywords_total": {
+ "name": "keywords_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "keywords_checked": {
+ "name": "keywords_checked",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "is_subset_run": {
+ "name": "is_subset_run",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "rank_check_runs_config_idx": {
+ "name": "rank_check_runs_config_idx",
+ "columns": [
+ "config_id",
+ "started_at"
+ ],
+ "isUnique": false
+ },
+ "rank_check_runs_project_idx": {
+ "name": "rank_check_runs_project_idx",
+ "columns": [
+ "project_id",
+ "started_at"
+ ],
+ "isUnique": false
+ },
+ "rank_check_runs_one_active_per_config_idx": {
+ "name": "rank_check_runs_one_active_per_config_idx",
+ "columns": [
+ "config_id"
+ ],
+ "isUnique": true,
+ "where": "\"rank_check_runs\".\"status\" IN ('pending', 'running')"
+ }
+ },
+ "foreignKeys": {
+ "rank_check_runs_config_id_rank_tracking_configs_id_fk": {
+ "name": "rank_check_runs_config_id_rank_tracking_configs_id_fk",
+ "tableFrom": "rank_check_runs",
+ "tableTo": "rank_tracking_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rank_check_runs_project_id_projects_id_fk": {
+ "name": "rank_check_runs_project_id_projects_id_fk",
+ "tableFrom": "rank_check_runs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rank_snapshots": {
+ "name": "rank_snapshots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tracking_keyword_id": {
+ "name": "tracking_keyword_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "device": {
+ "name": "device",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "serp_features": {
+ "name": "serp_features",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "checked_at": {
+ "name": "checked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "rank_snapshots_keyword_device_idx": {
+ "name": "rank_snapshots_keyword_device_idx",
+ "columns": [
+ "tracking_keyword_id",
+ "device",
+ "checked_at"
+ ],
+ "isUnique": false
+ },
+ "rank_snapshots_run_keyword_device_idx": {
+ "name": "rank_snapshots_run_keyword_device_idx",
+ "columns": [
+ "run_id",
+ "tracking_keyword_id",
+ "device"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "rank_snapshots_run_id_rank_check_runs_id_fk": {
+ "name": "rank_snapshots_run_id_rank_check_runs_id_fk",
+ "tableFrom": "rank_snapshots",
+ "tableTo": "rank_check_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rank_tracking_configs": {
+ "name": "rank_tracking_configs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "devices": {
+ "name": "devices",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'both'"
+ },
+ "serp_depth": {
+ "name": "serp_depth",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "schedule_interval": {
+ "name": "schedule_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'weekly'"
+ },
+ "location_name": {
+ "name": "location_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "last_checked_at": {
+ "name": "last_checked_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "next_check_at": {
+ "name": "next_check_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_skip_reason": {
+ "name": "last_skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "rank_tracking_configs_project_active_created_idx": {
+ "name": "rank_tracking_configs_project_active_created_idx",
+ "columns": [
+ "project_id",
+ "is_active",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "rank_tracking_configs_national_idx": {
+ "name": "rank_tracking_configs_national_idx",
+ "columns": [
+ "project_id",
+ "domain",
+ "location_code"
+ ],
+ "isUnique": true,
+ "where": "\"rank_tracking_configs\".\"location_name\" IS NULL"
+ },
+ "rank_tracking_configs_local_idx": {
+ "name": "rank_tracking_configs_local_idx",
+ "columns": [
+ "project_id",
+ "domain",
+ "location_code",
+ "location_name"
+ ],
+ "isUnique": true,
+ "where": "\"rank_tracking_configs\".\"location_name\" IS NOT NULL"
+ }
+ },
+ "foreignKeys": {
+ "rank_tracking_configs_project_id_projects_id_fk": {
+ "name": "rank_tracking_configs_project_id_projects_id_fk",
+ "tableFrom": "rank_tracking_configs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "rank_tracking_keywords": {
+ "name": "rank_tracking_keywords",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "match_case": {
+ "name": "match_case",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "search_volume": {
+ "name": "search_volume",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "keyword_difficulty": {
+ "name": "keyword_difficulty",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cpc": {
+ "name": "cpc",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metrics_fetched_at": {
+ "name": "metrics_fetched_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "rank_tracking_keywords_config_keyword_idx": {
+ "name": "rank_tracking_keywords_config_keyword_idx",
+ "columns": [
+ "config_id",
+ "keyword"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "rank_tracking_keywords_config_id_rank_tracking_configs_id_fk": {
+ "name": "rank_tracking_keywords_config_id_rank_tracking_configs_id_fk",
+ "tableFrom": "rank_tracking_keywords",
+ "tableTo": "rank_tracking_configs",
+ "columnsFrom": [
+ "config_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "saved_keyword_tag_assignments": {
+ "name": "saved_keyword_tag_assignments",
+ "columns": {
+ "saved_keyword_id": {
+ "name": "saved_keyword_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "saved_keyword_tag_assignments_unique_idx": {
+ "name": "saved_keyword_tag_assignments_unique_idx",
+ "columns": [
+ "saved_keyword_id",
+ "tag_id"
+ ],
+ "isUnique": true
+ },
+ "saved_keyword_tag_assignments_tag_idx": {
+ "name": "saved_keyword_tag_assignments_tag_idx",
+ "columns": [
+ "tag_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "saved_keyword_tag_assignments_saved_keyword_id_saved_keywords_id_fk": {
+ "name": "saved_keyword_tag_assignments_saved_keyword_id_saved_keywords_id_fk",
+ "tableFrom": "saved_keyword_tag_assignments",
+ "tableTo": "saved_keywords",
+ "columnsFrom": [
+ "saved_keyword_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "saved_keyword_tag_assignments_tag_id_saved_keyword_tags_id_fk": {
+ "name": "saved_keyword_tag_assignments_tag_id_saved_keyword_tags_id_fk",
+ "tableFrom": "saved_keyword_tag_assignments",
+ "tableTo": "saved_keyword_tags",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "saved_keyword_tags": {
+ "name": "saved_keyword_tags",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "normalized_name": {
+ "name": "normalized_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "saved_keyword_tags_project_normalized_name_idx": {
+ "name": "saved_keyword_tags_project_normalized_name_idx",
+ "columns": [
+ "project_id",
+ "normalized_name"
+ ],
+ "isUnique": true
+ },
+ "saved_keyword_tags_project_name_idx": {
+ "name": "saved_keyword_tags_project_name_idx",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "saved_keyword_tags_project_id_projects_id_fk": {
+ "name": "saved_keyword_tags_project_id_projects_id_fk",
+ "tableFrom": "saved_keyword_tags",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "saved_keywords": {
+ "name": "saved_keywords",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyword": {
+ "name": "keyword",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "saved_keywords_unique_project_keyword_location_language": {
+ "name": "saved_keywords_unique_project_keyword_location_language",
+ "columns": [
+ "project_id",
+ "keyword",
+ "location_code",
+ "language_code"
+ ],
+ "isUnique": true
+ },
+ "saved_keywords_project_created_idx": {
+ "name": "saved_keywords_project_created_idx",
+ "columns": [
+ "project_id",
+ "created_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "saved_keywords_project_id_projects_id_fk": {
+ "name": "saved_keywords_project_id_projects_id_fk",
+ "tableFrom": "saved_keywords",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user_onboarding_answers": {
+ "name": "user_onboarding_answers",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "interested_features": {
+ "name": "interested_features",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "work_for": {
+ "name": "work_for",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "client_website_count": {
+ "name": "client_website_count",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "found_via": {
+ "name": "found_via",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mcp_setup_intent": {
+ "name": "mcp_setup_intent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "gsc_nudge_dismissed_at": {
+ "name": "gsc_nudge_dismissed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "user_onboarding_answers_organization_idx": {
+ "name": "user_onboarding_answers_organization_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "user_onboarding_answers_user_id_user_id_fk": {
+ "name": "user_onboarding_answers_user_id_user_id_fk",
+ "tableFrom": "user_onboarding_answers",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_onboarding_answers_organization_id_organization_id_fk": {
+ "name": "user_onboarding_answers_organization_id_organization_id_fk",
+ "tableFrom": "user_onboarding_answers",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "project_competitors": {
+ "name": "project_competitors",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "project_competitors_project_domain_idx": {
+ "name": "project_competitors_project_domain_idx",
+ "columns": [
+ "project_id",
+ "domain"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "project_competitors_project_id_projects_id_fk": {
+ "name": "project_competitors_project_id_projects_id_fk",
+ "tableFrom": "project_competitors",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "project_context_sections": {
+ "name": "project_context_sections",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_context_sections_project_id_projects_id_fk": {
+ "name": "project_context_sections_project_id_projects_id_fk",
+ "tableFrom": "project_context_sections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_context_sections_project_id_key_pk": {
+ "columns": [
+ "project_id",
+ "key"
+ ],
+ "name": "project_context_sections_project_id_key_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "project_key_pages": {
+ "name": "project_key_pages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "project_key_pages_project_url_idx": {
+ "name": "project_key_pages_project_url_idx",
+ "columns": [
+ "project_id",
+ "url"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "project_key_pages_project_id_projects_id_fk": {
+ "name": "project_key_pages_project_id_projects_id_fk",
+ "tableFrom": "project_key_pages",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "project_research_log": {
+ "name": "project_research_log",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entry_date": {
+ "name": "entry_date",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))"
+ }
+ },
+ "indexes": {
+ "project_research_log_project_date_idx": {
+ "name": "project_research_log_project_date_idx",
+ "columns": [
+ "project_id",
+ "entry_date"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "project_research_log_project_id_projects_id_fk": {
+ "name": "project_research_log_project_id_projects_id_fk",
+ "tableFrom": "project_research_log",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "reports": {
+ "name": "reports",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "html": {
+ "name": "html",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "skill": {
+ "name": "skill",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "template_id": {
+ "name": "template_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shared_at": {
+ "name": "shared_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))"
+ }
+ },
+ "indexes": {
+ "reports_project_updated_idx": {
+ "name": "reports_project_updated_idx",
+ "columns": [
+ "project_id",
+ "updated_at",
+ "id",
+ "size_bytes"
+ ],
+ "isUnique": false
+ },
+ "reports_share_token_idx": {
+ "name": "reports_share_token_idx",
+ "columns": [
+ "share_token"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "reports_project_id_projects_id_fk": {
+ "name": "reports_project_id_projects_id_fk",
+ "tableFrom": "reports",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "report_templates": {
+ "name": "report_templates",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ','now'))"
+ }
+ },
+ "indexes": {
+ "report_templates_project_name_idx": {
+ "name": "report_templates_project_name_idx",
+ "columns": [
+ "project_id",
+ "name"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "report_templates_project_id_projects_id_fk": {
+ "name": "report_templates_project_id_projects_id_fk",
+ "tableFrom": "report_templates",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audit_issues": {
+ "name": "audit_issues",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "page_url": {
+ "name": "page_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "issue_type": {
+ "name": "issue_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'info'"
+ },
+ "details_json": {
+ "name": "details_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "audit_issues_audit_type_idx": {
+ "name": "audit_issues_audit_type_idx",
+ "columns": [
+ "audit_id",
+ "issue_type"
+ ],
+ "isUnique": false
+ },
+ "audit_issues_page_id_idx": {
+ "name": "audit_issues_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "audit_issues_audit_id_audits_id_fk": {
+ "name": "audit_issues_audit_id_audits_id_fk",
+ "tableFrom": "audit_issues",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "audit_issues_page_id_audit_pages_id_fk": {
+ "name": "audit_issues_page_id_audit_pages_id_fk",
+ "tableFrom": "audit_issues",
+ "tableTo": "audit_pages",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audit_lighthouse_results": {
+ "name": "audit_lighthouse_results",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "page_id": {
+ "name": "page_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "strategy": {
+ "name": "strategy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "performance_score": {
+ "name": "performance_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "accessibility_score": {
+ "name": "accessibility_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "best_practices_score": {
+ "name": "best_practices_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "seo_score": {
+ "name": "seo_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lcp_ms": {
+ "name": "lcp_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cls": {
+ "name": "cls",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "inp_ms": {
+ "name": "inp_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ttfb_ms": {
+ "name": "ttfb_ms",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "r2_key": {
+ "name": "r2_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "payload_size_bytes": {
+ "name": "payload_size_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "audit_lighthouse_results_audit_id_idx": {
+ "name": "audit_lighthouse_results_audit_id_idx",
+ "columns": [
+ "audit_id"
+ ],
+ "isUnique": false
+ },
+ "audit_lighthouse_results_page_id_idx": {
+ "name": "audit_lighthouse_results_page_id_idx",
+ "columns": [
+ "page_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "audit_lighthouse_results_audit_id_audits_id_fk": {
+ "name": "audit_lighthouse_results_audit_id_audits_id_fk",
+ "tableFrom": "audit_lighthouse_results",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "audit_lighthouse_results_page_id_audit_pages_id_fk": {
+ "name": "audit_lighthouse_results_page_id_audit_pages_id_fk",
+ "tableFrom": "audit_lighthouse_results",
+ "tableTo": "audit_pages",
+ "columnsFrom": [
+ "page_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audit_pages": {
+ "name": "audit_pages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status_code": {
+ "name": "status_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "redirect_url": {
+ "name": "redirect_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "meta_description": {
+ "name": "meta_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "canonical_url": {
+ "name": "canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "robots_meta": {
+ "name": "robots_meta",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "og_title": {
+ "name": "og_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "og_description": {
+ "name": "og_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "og_image": {
+ "name": "og_image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "h1_count": {
+ "name": "h1_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "h2_count": {
+ "name": "h2_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "h3_count": {
+ "name": "h3_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "h4_count": {
+ "name": "h4_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "h5_count": {
+ "name": "h5_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "h6_count": {
+ "name": "h6_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "heading_order_json": {
+ "name": "heading_order_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "word_count": {
+ "name": "word_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "images_total": {
+ "name": "images_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "images_missing_alt": {
+ "name": "images_missing_alt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "images_json": {
+ "name": "images_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "internal_link_count": {
+ "name": "internal_link_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "external_link_count": {
+ "name": "external_link_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "has_structured_data": {
+ "name": "has_structured_data",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "hreflang_tags_json": {
+ "name": "hreflang_tags_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_indexable": {
+ "name": "is_indexable",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "x_robots_tag": {
+ "name": "x_robots_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "header_canonical_url": {
+ "name": "header_canonical_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "crawl_depth": {
+ "name": "crawl_depth",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "in_sitemap": {
+ "name": "in_sitemap",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "content_hash": {
+ "name": "content_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fetch_class": {
+ "name": "fetch_class",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'ok'"
+ },
+ "response_time_ms": {
+ "name": "response_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "audit_pages_audit_url_idx": {
+ "name": "audit_pages_audit_url_idx",
+ "columns": [
+ "audit_id",
+ "url"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "audit_pages_audit_id_audits_id_fk": {
+ "name": "audit_pages_audit_id_audits_id_fk",
+ "tableFrom": "audit_pages",
+ "tableTo": "audits",
+ "columnsFrom": [
+ "audit_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audits": {
+ "name": "audits",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "started_by_user_id": {
+ "name": "started_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "start_url": {
+ "name": "start_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'running'"
+ },
+ "workflow_instance_id": {
+ "name": "workflow_instance_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "pages_crawled": {
+ "name": "pages_crawled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "pages_total": {
+ "name": "pages_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "lighthouse_total": {
+ "name": "lighthouse_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "lighthouse_completed": {
+ "name": "lighthouse_completed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "lighthouse_failed": {
+ "name": "lighthouse_failed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "current_phase": {
+ "name": "current_phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'discovery'"
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error_detail": {
+ "name": "error_detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "failed_phase": {
+ "name": "failed_phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "audits_project_id_idx": {
+ "name": "audits_project_id_idx",
+ "columns": [
+ "project_id"
+ ],
+ "isUnique": false
+ },
+ "audits_started_by_user_id_idx": {
+ "name": "audits_started_by_user_id_idx",
+ "columns": [
+ "started_by_user_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "audits_project_id_projects_id_fk": {
+ "name": "audits_project_id_projects_id_fk",
+ "tableFrom": "audits",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "sam_sessions": {
+ "name": "sam_sessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'New chat'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "sam_sessions_project_updated_idx": {
+ "name": "sam_sessions_project_updated_idx",
+ "columns": [
+ "project_id",
+ "updated_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sam_sessions_project_id_projects_id_fk": {
+ "name": "sam_sessions_project_id_projects_id_fk",
+ "tableFrom": "sam_sessions",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sam_sessions_user_id_user_id_fk": {
+ "name": "sam_sessions_user_id_user_id_fk",
+ "tableFrom": "sam_sessions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "account": {
+ "name": "account",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ },
+ "account_accountId_providerId_idx": {
+ "name": "account_accountId_providerId_idx",
+ "columns": [
+ "account_id",
+ "provider_id"
+ ],
+ "isUnique": false
+ },
+ "account_google_grant_owner_idx": {
+ "name": "account_google_grant_owner_idx",
+ "columns": [
+ "user_id",
+ "provider_id",
+ "account_id"
+ ],
+ "isUnique": true,
+ "where": "\"account\".\"provider_id\" in ('google-search-console', 'google-analytics')"
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "apikey": {
+ "name": "apikey",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 60000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 120
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ "config_id"
+ ],
+ "isUnique": false
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ "reference_id"
+ ],
+ "isUnique": false
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ "key"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "invitation": {
+ "name": "invitation",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "invitation_organizationId_idx": {
+ "name": "invitation_organizationId_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "invitation_organization_id_organization_id_fk": {
+ "name": "invitation_organization_id_organization_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "member": {
+ "name": "member",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "member_organizationId_idx": {
+ "name": "member_organizationId_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ },
+ "member_userId_idx": {
+ "name": "member_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ },
+ "member_organizationId_userId_uidx": {
+ "name": "member_organizationId_userId_uidx",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "member_organization_id_organization_id_fk": {
+ "name": "member_organization_id_organization_id_fk",
+ "tableFrom": "member",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "member_user_id_user_id_fk": {
+ "name": "member_user_id_user_id_fk",
+ "tableFrom": "member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organization": {
+ "name": "organization",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "organization_slug_unique": {
+ "name": "organization_slug_unique",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ },
+ "organization_slug_uidx": {
+ "name": "organization_slug_uidx",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "columns": [
+ "token"
+ ],
+ "isUnique": true
+ },
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "analytics_opted_out": {
+ "name": "analytics_opted_out",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_active_organization_id": {
+ "name": "last_active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "verification": {
+ "name": "verification",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ "identifier"
+ ],
+ "isUnique": false
+ },
+ "verification_expiresAt_idx": {
+ "name": "verification_expiresAt_idx",
+ "columns": [
+ "expires_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "billing_customer_status": {
+ "name": "billing_customer_status",
+ "columns": {
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "is_paying": {
+ "name": "is_paying",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "paid_plan_id": {
+ "name": "paid_plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "paid_plan_status": {
+ "name": "paid_plan_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "customer_json": {
+ "name": "customer_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "billing_customer_status_organization_id_organization_id_fk": {
+ "name": "billing_customer_status_organization_id_organization_id_fk",
+ "tableFrom": "billing_customer_status",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ga4_connections": {
+ "name": "ga4_connections",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "property_id": {
+ "name": "property_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "property_display_name": {
+ "name": "property_display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "property_time_zone": {
+ "name": "property_time_zone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "property_currency_code": {
+ "name": "property_currency_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "connected_by_user_id": {
+ "name": "connected_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ga4_account_id": {
+ "name": "ga4_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "connected_account_email": {
+ "name": "connected_account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "ga4_connections_project_idx": {
+ "name": "ga4_connections_project_idx",
+ "columns": [
+ "project_id"
+ ],
+ "isUnique": true
+ },
+ "ga4_connections_organization_idx": {
+ "name": "ga4_connections_organization_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ },
+ "ga4_connections_connector_idx": {
+ "name": "ga4_connections_connector_idx",
+ "columns": [
+ "connected_by_user_id",
+ "ga4_account_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ga4_connections_project_id_projects_id_fk": {
+ "name": "ga4_connections_project_id_projects_id_fk",
+ "tableFrom": "ga4_connections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ga4_connections_organization_id_organization_id_fk": {
+ "name": "ga4_connections_organization_id_organization_id_fk",
+ "tableFrom": "ga4_connections",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "gsc_connections": {
+ "name": "gsc_connections",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "site_url": {
+ "name": "site_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "connected_by_user_id": {
+ "name": "connected_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "gsc_account_id": {
+ "name": "gsc_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "connected_account_email": {
+ "name": "connected_account_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(current_timestamp)"
+ }
+ },
+ "indexes": {
+ "gsc_connections_project_idx": {
+ "name": "gsc_connections_project_idx",
+ "columns": [
+ "project_id"
+ ],
+ "isUnique": true
+ },
+ "gsc_connections_organization_idx": {
+ "name": "gsc_connections_organization_idx",
+ "columns": [
+ "organization_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "gsc_connections_project_id_projects_id_fk": {
+ "name": "gsc_connections_project_id_projects_id_fk",
+ "tableFrom": "gsc_connections",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "gsc_connections_organization_id_organization_id_fk": {
+ "name": "gsc_connections_organization_id_organization_id_fk",
+ "tableFrom": "gsc_connections",
+ "tableTo": "organization",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "telemetry_state": {
+ "name": "telemetry_state",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "install_id": {
+ "name": "install_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "installed_at": {
+ "name": "installed_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_version": {
+ "name": "last_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mcp_tool_call_count": {
+ "name": "mcp_tool_call_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_matches": {
+ "name": "ai_matches",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "observation_id": {
+ "name": "observation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "own": {
+ "name": "own",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mentioned": {
+ "name": "mentioned",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "cited": {
+ "name": "cited",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "first_mention": {
+ "name": "first_mention",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_matches_observation_domain_idx": {
+ "name": "ai_matches_observation_domain_idx",
+ "columns": [
+ "observation_id",
+ "domain"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "ai_matches_observation_id_ai_observations_id_fk": {
+ "name": "ai_matches_observation_id_ai_observations_id_fk",
+ "tableFrom": "ai_matches",
+ "tableTo": "ai_observations",
+ "columnsFrom": [
+ "observation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_observations": {
+ "name": "ai_observations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "prompt_id": {
+ "name": "prompt_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "engine": {
+ "name": "engine",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "branded": {
+ "name": "branded",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "collected_at": {
+ "name": "collected_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "answer_markdown": {
+ "name": "answer_markdown",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_observations_run_prompt_engine_idx": {
+ "name": "ai_observations_run_prompt_engine_idx",
+ "columns": [
+ "run_id",
+ "prompt_id",
+ "engine"
+ ],
+ "isUnique": true
+ },
+ "ai_observations_prompt_idx": {
+ "name": "ai_observations_prompt_idx",
+ "columns": [
+ "prompt_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ai_observations_run_id_ai_runs_id_fk": {
+ "name": "ai_observations_run_id_ai_runs_id_fk",
+ "tableFrom": "ai_observations",
+ "tableTo": "ai_runs",
+ "columnsFrom": [
+ "run_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_observations_prompt_id_ai_prompts_id_fk": {
+ "name": "ai_observations_prompt_id_ai_prompts_id_fk",
+ "tableFrom": "ai_observations",
+ "tableTo": "ai_prompts",
+ "columnsFrom": [
+ "prompt_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_prompts": {
+ "name": "ai_prompts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tracker_id": {
+ "name": "tracker_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "topic": {
+ "name": "topic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "paused": {
+ "name": "paused",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "archived": {
+ "name": "archived",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_prompts_tracker_idx": {
+ "name": "ai_prompts_tracker_idx",
+ "columns": [
+ "tracker_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ai_prompts_tracker_id_ai_trackers_id_fk": {
+ "name": "ai_prompts_tracker_id_ai_trackers_id_fk",
+ "tableFrom": "ai_prompts",
+ "tableTo": "ai_trackers",
+ "columnsFrom": [
+ "tracker_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_runs": {
+ "name": "ai_runs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tracker_id": {
+ "name": "tracker_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'queued'"
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_runs_project_created_idx": {
+ "name": "ai_runs_project_created_idx",
+ "columns": [
+ "project_id",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "ai_runs_one_active_idx": {
+ "name": "ai_runs_one_active_idx",
+ "columns": [
+ "tracker_id"
+ ],
+ "isUnique": true,
+ "where": "\"ai_runs\".\"status\" IN ('queued', 'running')"
+ }
+ },
+ "foreignKeys": {
+ "ai_runs_tracker_id_ai_trackers_id_fk": {
+ "name": "ai_runs_tracker_id_ai_trackers_id_fk",
+ "tableFrom": "ai_runs",
+ "tableTo": "ai_trackers",
+ "columnsFrom": [
+ "tracker_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_runs_project_id_projects_id_fk": {
+ "name": "ai_runs_project_id_projects_id_fk",
+ "tableFrom": "ai_runs",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_sources": {
+ "name": "ai_sources",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "observation_id": {
+ "name": "observation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_sources_observation_idx": {
+ "name": "ai_sources_observation_idx",
+ "columns": [
+ "observation_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ai_sources_observation_id_ai_observations_id_fk": {
+ "name": "ai_sources_observation_id_ai_observations_id_fk",
+ "tableFrom": "ai_sources",
+ "tableTo": "ai_observations",
+ "columnsFrom": [
+ "observation_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "ai_trackers": {
+ "name": "ai_trackers",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "chatgpt": {
+ "name": "chatgpt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "gemini": {
+ "name": "gemini",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "google_ai_overview": {
+ "name": "google_ai_overview",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "location_code": {
+ "name": "location_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 2840
+ },
+ "language_code": {
+ "name": "language_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'en'"
+ },
+ "schedule_interval": {
+ "name": "schedule_interval",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'weekly'"
+ },
+ "next_check_at": {
+ "name": "next_check_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_skip_reason": {
+ "name": "last_skip_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "ai_trackers_project_idx": {
+ "name": "ai_trackers_project_idx",
+ "columns": [
+ "project_id"
+ ],
+ "isUnique": true
+ },
+ "ai_trackers_due_idx": {
+ "name": "ai_trackers_due_idx",
+ "columns": [
+ "enabled",
+ "next_check_at"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "ai_trackers_project_id_projects_id_fk": {
+ "name": "ai_trackers_project_id_projects_id_fk",
+ "tableFrom": "ai_trackers",
+ "tableTo": "projects",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/sqlite/meta/_journal.json b/drizzle/sqlite/meta/_journal.json
index d97d272d..cea1b2c9 100644
--- a/drizzle/sqlite/meta/_journal.json
+++ b/drizzle/sqlite/meta/_journal.json
@@ -372,6 +372,13 @@
"when": 1791317073141,
"tag": "0052_ai_visibility",
"breakpoints": true
+ },
+ {
+ "idx": 53,
+ "version": "6",
+ "when": 1791339857061,
+ "tag": "0053_chubby_tyger_tiger",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/src/client/components/CardShell.tsx b/src/client/components/CardShell.tsx
index e8fd81db..5debc209 100644
--- a/src/client/components/CardShell.tsx
+++ b/src/client/components/CardShell.tsx
@@ -10,18 +10,18 @@ import {
/**
* Card with a header row and a divided body: dashboard and connection cards.
* It fills its grid cell, and the body grows so content marked `mt-auto`
- * (action rows, the stamp) sits at the bottom of equal-height cards.
+ * (such as action rows) sits at the bottom of equal-height cards.
*/
export function CardShell({
title,
icon,
- stamp,
+ titleInfo,
action,
children,
}: {
title: string;
icon?: ReactNode;
- stamp?: string;
+ titleInfo?: ReactNode;
action?: ReactNode;
children: ReactNode;
}) {
@@ -35,19 +35,13 @@ export function CardShell({
</span>
) : null}
<h2 className="leading-tight">{title}</h2>
+ {titleInfo}
</CardTitle>
{action ? (
<CardAction className="self-center">{action}</CardAction>
) : null}
</CardHeader>
- <CardContent className="flex flex-1 flex-col">
- {children}
- {stamp ? (
- <p className="mt-auto pt-4 text-[11px] text-muted-foreground">
- {stamp}
- </p>
- ) : null}
- </CardContent>
+ <CardContent className="flex flex-1 flex-col">{children}</CardContent>
</Card>
);
}
diff --git a/src/client/components/MetricsTable.tsx b/src/client/components/MetricsTable.tsx
new file mode 100644
index 00000000..77d808c6
--- /dev/null
+++ b/src/client/components/MetricsTable.tsx
@@ -0,0 +1,52 @@
+import type { ReactNode } from "react";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
+
+export function MetricsTable({
+ rows,
+ showChange = false,
+}: {
+ rows: { label: ReactNode; value: ReactNode; change?: ReactNode }[];
+ showChange?: boolean;
+}) {
+ return (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Metric</TableHead>
+ <TableHead className="text-right">Value</TableHead>
+ {showChange && <TableHead className="text-right">Change</TableHead>}
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {rows.map((row, index) => (
+ <TableRow key={index}>
+ <TableCell>{row.label}</TableCell>
+ <TableCell className="text-right tabular-nums">
+ {row.value}
+ </TableCell>
+ {showChange && (
+ <TableCell className="text-right tabular-nums">
+ {row.change ?? "—"}
+ </TableCell>
+ )}
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ );
+}
+
+export function percentChange(
+ current: number | null,
+ previous: number | null,
+): number | null {
+ if (current === null || previous === null || previous <= 0) return null;
+ return Math.round(((current - previous) / previous) * 100);
+}
diff --git a/src/client/components/StatTile.tsx b/src/client/components/StatTile.tsx
deleted file mode 100644
index 1933a4a2..00000000
--- a/src/client/components/StatTile.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { cn } from "cn";
-
-/**
- * One metric: a muted uppercase label over a big tabular number.
- *
- * `delta` compares the value with the previous period and shows the percent
- * change. It shows nothing when either side is missing or the previous value
- * is zero.
- */
-export function StatTile({
- label,
- value,
- tone,
- delta,
- hint,
-}: {
- label: string;
- value: string;
- /** Colors the value, for counts that are good or bad news on their own. */
- tone?: "success" | "destructive";
- delta?: { current: number | null; previous: number | null };
- hint?: string;
-}) {
- const percent = delta ? percentChange(delta.current, delta.previous) : null;
- return (
- <div className="flex min-w-0 flex-col gap-1">
- <p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
- {label}
- </p>
- <p
- className={cn(
- "text-2xl leading-tight font-semibold tabular-nums",
- tone === "success" && "text-success",
- tone === "destructive" && "text-destructive",
- )}
- >
- {value}
- </p>
- {percent === null ? null : (
- <p
- className={cn(
- "text-xs tabular-nums",
- percent > 0 && "text-success",
- percent < 0 && "text-destructive",
- )}
- >
- {percent > 0 ? "▲ " : percent < 0 ? "▼ " : ""}
- {Math.abs(percent)}%
- </p>
- )}
- {hint ? <p className="text-xs text-muted-foreground">{hint}</p> : null}
- </div>
- );
-}
-
-function percentChange(
- current: number | null,
- previous: number | null,
-): number | null {
- if (current === null || previous === null || previous <= 0) return null;
- return Math.round(((current - previous) / previous) * 100);
-}
diff --git a/src/client/features/ai-search/components/BrandLookupResults.tsx b/src/client/features/ai-search/components/BrandLookupResults.tsx
index a46be57d..7424b737 100644
--- a/src/client/features/ai-search/components/BrandLookupResults.tsx
+++ b/src/client/features/ai-search/components/BrandLookupResults.tsx
@@ -1,3 +1,11 @@
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
import { Info, TriangleAlert } from "lucide-react";
import { Alert, AlertTitle } from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
@@ -24,9 +32,6 @@ type Props = {
projectId: string;
};
-type PlatformRow = BrandLookupResult["perPlatform"][number];
-type MetricKey = "mentions" | "aiSearchVolume";
-
const DOMAIN_LEVEL_TIP =
"AI search providers report mentions per domain, not per page. This number covers the whole domain — the cited pages below are limited to your scope.";
@@ -110,7 +115,7 @@ export function BrandLookupResults({ result, projectId }: Props) {
function BrandHeader({ result }: { result: BrandLookupResult }) {
return (
- <section className="px-4 pt-4 pb-3">
+ <section className="flex flex-wrap items-center justify-between gap-2 px-4 pt-4 pb-3">
<div className="flex flex-wrap items-center gap-2">
<h2 className="text-lg font-semibold break-all">
{result.resolvedTarget}
@@ -120,7 +125,7 @@ function BrandHeader({ result }: { result: BrandLookupResult }) {
<Badge variant="outline">{RESEARCH_SCOPE_LABELS[result.scope]}</Badge>
) : null}
</div>
- <p className="text-xs text-muted-foreground">
+ <p className="ml-auto text-xs text-muted-foreground">
Updated {formatRelative(result.fetchedAt)}
</p>
</section>
@@ -129,89 +134,68 @@ function BrandHeader({ result }: { result: BrandLookupResult }) {
function StatsCard({ result }: { result: BrandLookupResult }) {
return (
- <div className="rounded-lg border border-border">
- <div className="flex h-full flex-col divide-y divide-border">
- <StatBlock
- label="Mentions"
- tooltip="Estimated count of AI answers where the searched brand or domain appeared in the answer text or cited sources."
- value={result.totalMentions}
- perPlatform={result.perPlatform}
- metric="mentions"
- isDomainLevel={result.aggregatesAreDomainLevel}
- />
- <StatBlock
- label="AI search volume"
- tooltip="Estimated monthly search demand for prompts where the searched brand or domain appears in AI answers. This is prompt demand, not mention count."
- value={result.totalAiSearchVolume}
- perPlatform={result.perPlatform}
- metric="aiSearchVolume"
- isDomainLevel={result.aggregatesAreDomainLevel}
- />
- </div>
- </div>
- );
-}
-
-function StatBlock({
- label,
- tooltip,
- value,
- perPlatform,
- metric,
- isDomainLevel,
-}: {
- label: string;
- tooltip: string;
- value: number | null;
- perPlatform: PlatformRow[];
- metric: MetricKey;
- isDomainLevel: boolean;
-}) {
- return (
- <div className="flex flex-1 flex-col justify-center p-4">
- <div className="inline-flex items-center gap-1 text-xs font-medium tracking-wider text-muted-foreground uppercase">
- {label}
- <InfoTooltip text={tooltip} />
- {isDomainLevel ? <DomainLevelBadge tooltip={DOMAIN_LEVEL_TIP} /> : null}
- </div>
- <p className="mt-1 text-3xl font-semibold tabular-nums">
- {formatCount(value)}
- </p>
- <div className="mt-3 space-y-1 border-t border-border pt-2.5">
- {perPlatform.map((row) => (
- <PlatformStatRow key={row.platform} row={row} metric={metric} />
- ))}
- </div>
- </div>
- );
-}
-
-function PlatformStatRow({
- row,
- metric,
-}: {
- row: PlatformRow;
- metric: MetricKey;
-}) {
- const value = row.status === "error" ? null : row[metric];
-
- return (
- <div className="flex items-center justify-between text-xs">
- <span className="inline-flex items-center gap-1.5 text-muted-foreground">
- <span
- className={`size-1.5 rounded-full ${PLATFORM_DOT_CLASS[row.platform]}`}
- />
- {formatPlatformLabel(row.platform)}
- {row.platform === "chat_gpt" ? (
- <InfoTooltip text="DataForSEO indexes ChatGPT mentions for US English only — country selection is not available for this platform." />
- ) : null}
- {row.status === "error" ? (
- <span className="text-destructive">unavailable</span>
- ) : null}
- </span>
- <span className="font-medium text-foreground tabular-nums">
- {formatCount(value)}
- </span>
+ <div className="w-full max-w-xl rounded-lg border border-border p-3">
+ {result.aggregatesAreDomainLevel && (
+ <div className="mb-2">
+ <DomainLevelBadge tooltip={DOMAIN_LEVEL_TIP} />
+ </div>
+ )}
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Platform</TableHead>
+ <TableHead className="text-right">
+ <span className="inline-flex items-center gap-1">
+ Mentions
+ <InfoTooltip text="AI answers that mention your brand or cite your website." />
+ </span>
+ </TableHead>
+ <TableHead className="text-right">
+ <span className="inline-flex items-center gap-1">
+ AI search volume
+ <InfoTooltip text="Estimated monthly searches for prompts where your brand appears in AI answers." />
+ </span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ <TableRow className="font-medium">
+ <TableCell>Total</TableCell>
+ <TableCell className="text-right tabular-nums">
+ {formatCount(result.totalMentions)}
+ </TableCell>
+ <TableCell className="text-right tabular-nums">
+ {formatCount(result.totalAiSearchVolume)}
+ </TableCell>
+ </TableRow>
+ {result.perPlatform.map((row) => (
+ <TableRow key={row.platform}>
+ <TableCell>
+ <span className="inline-flex items-center gap-1.5">
+ <span
+ className={`size-1.5 rounded-full ${PLATFORM_DOT_CLASS[row.platform]}`}
+ />
+ {formatPlatformLabel(row.platform)}
+ {row.platform === "chat_gpt" && (
+ <InfoTooltip text="ChatGPT data covers US English only." />
+ )}
+ {row.status === "error" && (
+ <span className="text-destructive">Unavailable</span>
+ )}
+ </span>
+ </TableCell>
+ <TableCell className="text-right tabular-nums">
+ {formatCount(row.status === "error" ? null : row.mentions)}
+ </TableCell>
+ <TableCell className="text-right tabular-nums">
+ {formatCount(
+ row.status === "error" ? null : row.aiSearchVolume,
+ )}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</div>
);
}
diff --git a/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx b/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
index ef43fa78..838858bd 100644
--- a/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
+++ b/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
@@ -64,9 +64,8 @@ export function BrandLookupShareOfVoice({
{/* Captions only the platforms actually summed — when one platform's
cross_aggregated call failed, the leaderboard must not claim both. */}
<p className="border-t border-border px-4 py-2 text-[11px] text-muted-foreground">
- Mentions share across{" "}
- {shareOfVoice.platforms.map(formatPlatformLabel).join(" and ")} · bars
- relative to the leader.
+ Share of mentions on{" "}
+ {shareOfVoice.platforms.map(formatPlatformLabel).join(" and ")}
</p>
</div>
);
diff --git a/src/client/features/audit/AuditDetail.tsx b/src/client/features/audit/AuditDetail.tsx
index df7f5be1..76d96edc 100644
--- a/src/client/features/audit/AuditDetail.tsx
+++ b/src/client/features/audit/AuditDetail.tsx
@@ -13,7 +13,6 @@ import {
Card,
CardAction,
CardContent,
- CardDescription,
CardHeader,
CardTitle,
} from "@/client/components/ui/card";
@@ -295,9 +294,9 @@ function ProgressCard({
<CardTitle className="font-medium text-muted-foreground">
Crawled Pages ({crawledUrls.length})
</CardTitle>
- <CardDescription className="text-xs">
+ <CardAction className="text-xs text-muted-foreground">
Updated {new Date(crawledUrls[0].crawledAt).toLocaleTimeString()}
- </CardDescription>
+ </CardAction>
</CardHeader>
<CardContent className="max-h-[400px] overflow-y-auto">
{crawledUrls.map((entry, i) => (
diff --git a/src/client/features/audit/results/ResultsView.tsx b/src/client/features/audit/results/ResultsView.tsx
index 20b71916..c1a13af5 100644
--- a/src/client/features/audit/results/ResultsView.tsx
+++ b/src/client/features/audit/results/ResultsView.tsx
@@ -1,3 +1,4 @@
+import { MetricsTable } from "@/client/components/MetricsTable";
import { useMemo, type ReactNode } from "react";
import { ShieldAlert } from "lucide-react";
import {
@@ -305,6 +306,11 @@ function StatsStrip({
severity={severity}
title={severity}
>
+ {severity === "critical"
+ ? "Critical"
+ : severity === "warning"
+ ? "Warning"
+ : "Info"}{" "}
{severityCounts[severity]}
</SeverityBadge>
) : null,
@@ -312,14 +318,14 @@ function StatsStrip({
</span>
),
},
- { label: "Avg response", value: `${averageResponseMs}ms` },
+ { label: "Average response time", value: `${averageResponseMs}ms` },
];
if (totalLighthouse > 0) {
items.push(
{ label: "Lighthouse tests", value: String(totalLighthouse) },
{
- label: "Avg Lighthouse perf",
+ label: "Lighthouse performance",
value:
lighthouseSummary.avgPerformance == null
? "-"
@@ -327,7 +333,7 @@ function StatsStrip({
valueClass: scoreClass(lighthouseSummary.avgPerformance),
},
{
- label: "Avg Lighthouse SEO",
+ label: "Lighthouse SEO",
value:
lighthouseSummary.avgSeo == null
? "-"
@@ -335,7 +341,7 @@ function StatsStrip({
valueClass: scoreClass(lighthouseSummary.avgSeo),
},
{
- label: "Avg Lighthouse a11y",
+ label: "Lighthouse accessibility",
value:
lighthouseSummary.avgAccessibility == null
? "-"
@@ -351,30 +357,19 @@ function StatsStrip({
);
}
- const columnsClass =
- items.length === 3
- ? "grid-cols-1 sm:grid-cols-3"
- : "grid-cols-2 md:grid-cols-4";
-
return (
- <div
- className={`grid ${columnsClass} gap-px rounded-lg border border-border bg-border overflow-hidden`}
- >
- {items.map((item) => (
- <div key={item.label} className="bg-card px-4 py-3">
- <p className="text-[11px] uppercase tracking-wider text-muted-foreground">
- {item.label}
- </p>
- <p
- className={`text-xl font-semibold mt-0.5 tabular-nums ${item.valueClass ?? ""}`}
- >
- {item.value}
- </p>
- {item.sub && (
- <div className="text-xs text-muted-foreground mt-1">{item.sub}</div>
- )}
- </div>
- ))}
+ <div className="w-full max-w-xl rounded-lg border border-border bg-card p-3">
+ <MetricsTable
+ rows={items.map((item) => ({
+ label: (
+ <div className="flex flex-wrap items-center gap-2">
+ {item.label}
+ {item.sub || null}
+ </div>
+ ),
+ value: <span className={item.valueClass}>{item.value}</span>,
+ }))}
+ />
</div>
);
}
diff --git a/src/client/features/backlinks/BacklinksOverviewPanels.tsx b/src/client/features/backlinks/BacklinksOverviewPanels.tsx
index 9708a8bc..bda41db3 100644
--- a/src/client/features/backlinks/BacklinksOverviewPanels.tsx
+++ b/src/client/features/backlinks/BacklinksOverviewPanels.tsx
@@ -1,3 +1,4 @@
+import { MetricsTable } from "@/client/components/MetricsTable";
import { Info } from "lucide-react";
import { Alert, AlertDescription } from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
@@ -44,21 +45,15 @@ export function BacklinksOverviewPanels({
}) {
return (
<>
- <div className="px-4 pt-4 pb-3">
+ <div className="flex flex-wrap items-center justify-between gap-2 px-4 pt-4 pb-3">
<div className="flex flex-wrap items-center gap-2">
<h2 className="text-lg font-semibold break-all">
{data.displayTarget}
</h2>
<Badge variant="outline">{RESEARCH_SCOPE_LABELS[data.scope]}</Badge>
</div>
- <p className="text-xs text-muted-foreground">
- Updated {formatRelativeTimestamp(data.fetchedAt)} &middot; Overview
- metrics cover the full target, before table filters
- {/* history/live can't exclude subdomains, so say so rather than
- imply the charts match the domain-scoped totals. */}
- {data.scope === "domain" ? (
- <> &middot; Trends include subdomains</>
- ) : null}
+ <p className="ml-auto text-xs text-muted-foreground">
+ Updated {formatRelativeTimestamp(data.fetchedAt)}
</p>
</div>
<div className="px-4 pb-4">
@@ -83,26 +78,24 @@ function OverviewGrid({
className={`grid grid-cols-1 gap-3 ${domainScope ? "md:grid-cols-2 xl:grid-cols-3" : ""}`}
>
<div
- className={`rounded-lg border border-border p-3 ${domainScope ? "md:col-span-2 xl:col-span-1" : ""}`}
+ className={`w-full max-w-xl rounded-lg border border-border p-3 ${domainScope ? "md:col-span-2 xl:col-span-1" : ""}`}
>
- <div
- className={`grid grid-cols-2 gap-x-6 gap-y-5 xl:gap-y-6 ${domainScope ? "" : "md:grid-cols-4"}`}
- >
- {summaryStats.map((item) => (
- <div key={item.label}>
- <div className="text-xs tracking-wide text-muted-foreground uppercase">
- <HelpLabel label={item.label} helpText={item.description} />
- </div>
- <p className="text-2xl font-semibold">{item.value}</p>
- </div>
- ))}
- </div>
+ <MetricsTable
+ rows={summaryStats.map((item) => ({
+ label: <HelpLabel label={item.label} helpText={item.description} />,
+ value: item.value,
+ }))}
+ />
</div>
{domainScope ? (
<>
<TrendPanel
title="Backlink growth"
- description="Backlinks and referring domains over the last year"
+ description={
+ data.scope === "domain"
+ ? "Last year · Includes subdomains"
+ : "Backlinks and referring domains over the last year"
+ }
>
<BacklinksTrendChart data={data.trends} />
</TrendPanel>
diff --git a/src/client/features/backlinks/BacklinksPageStates.tsx b/src/client/features/backlinks/BacklinksPageStates.tsx
index 9b082b52..11db1f90 100644
--- a/src/client/features/backlinks/BacklinksPageStates.tsx
+++ b/src/client/features/backlinks/BacklinksPageStates.tsx
@@ -10,13 +10,8 @@ export function BacklinksLoadingState() {
<Skeleton className="h-3 w-80" />
</div>
<div className="grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2 xl:grid-cols-3">
- <div className="grid grid-cols-2 gap-x-6 gap-y-5 rounded-lg border border-border p-3 md:col-span-2 xl:col-span-1">
- {Array.from({ length: 8 }, (_, index) => (
- <div key={index} className="space-y-2">
- <Skeleton className="h-3 w-24" />
- <Skeleton className="h-7 w-16" />
- </div>
- ))}
+ <div className="rounded-lg border border-border p-3 md:col-span-2 xl:col-span-1">
+ <SkeletonTableRows rows={9} columns={2} />
</div>
{Array.from({ length: 2 }, (_, index) => (
<div
diff --git a/src/client/features/dashboard/DashboardBacklinks.tsx b/src/client/features/dashboard/DashboardBacklinks.tsx
new file mode 100644
index 00000000..82a01d6b
--- /dev/null
+++ b/src/client/features/dashboard/DashboardBacklinks.tsx
@@ -0,0 +1,187 @@
+import { useQuery } from "@tanstack/react-query";
+import { CardShell } from "@/client/components/CardShell";
+import { QueryState } from "@/client/components/QueryState";
+import type { ColumnDef } from "@tanstack/react-table";
+import { SortableHeader } from "@/client/components/table/SortableHeader";
+import { DashboardDataTable } from "./DashboardDataTable";
+import { useState } from "react";
+import { Tabs, TabsList, TabsTrigger } from "@/client/components/ui/tabs";
+import { getDashboardBacklinks } from "@/serverFunctions/dashboard";
+import { Freshness, ExternalPage, DashboardInfo } from "./siteTabParts";
+export function DashboardBacklinks({
+ projectId,
+ domain,
+}: {
+ projectId: string;
+ domain: string;
+}) {
+ const [kind, setKind] = useState<"new" | "lost" | "all">("new");
+ const query = useQuery({
+ queryKey: ["dashboardBacklinks", projectId, domain, kind],
+ queryFn: () => getDashboardBacklinks({ data: { projectId, kind } }),
+ staleTime: 86400_000,
+ retry: false,
+ });
+ return (
+ <div className="space-y-5">
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <div>
+ <h2 className="text-lg font-semibold">Your backlinks</h2>
+ </div>
+ <Tabs
+ value={kind}
+ onValueChange={(value) => {
+ if (value === "new" || value === "lost" || value === "all")
+ setKind(
+ value === "new" ? "new" : value === "lost" ? "lost" : "all",
+ );
+ }}
+ >
+ <TabsList>
+ <TabsTrigger value="new">New this week</TabsTrigger>
+ <TabsTrigger value="lost">Lost links</TabsTrigger>
+ <TabsTrigger value="all">Active links</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ </div>
+ <QueryState query={query} errorFallback="Could not load backlinks">
+ {(data) => (
+ <CardShell
+ title={
+ kind === "new"
+ ? "Recently discovered backlinks"
+ : kind === "lost"
+ ? "Lost backlinks"
+ : "Active backlinks"
+ }
+ titleInfo={
+ <DashboardInfo label="About backlink data">
+ <p>
+ {kind === "new"
+ ? "Links to your website found in the past week. A link may be older than the date it was found."
+ : kind === "lost"
+ ? "Links that were found before but are no longer there. Last checked is when we last checked the link, not when it disappeared."
+ : "Recently found links that still point to your website."}
+ </p>
+ <p className="mt-2">
+ Filters narrow the links shown in this table.
+ </p>
+ </DashboardInfo>
+ }
+ >
+ <Freshness {...data} />
+ {data.value.length ? (
+ <DashboardBacklinkTable
+ key={kind}
+ rows={data.value}
+ kind={kind}
+ />
+ ) : (
+ <p className="py-8 text-sm text-muted-foreground">
+ {kind === "new"
+ ? "No new backlinks this week."
+ : kind === "lost"
+ ? "No lost backlinks found."
+ : "No active backlinks found yet."}
+ </p>
+ )}
+ </CardShell>
+ )}
+ </QueryState>
+ </div>
+ );
+}
+
+type Backlink = Awaited<
+ ReturnType<typeof getDashboardBacklinks>
+>["value"][number];
+function DashboardBacklinkTable({
+ rows,
+ kind,
+}: {
+ rows: Backlink[];
+ kind: "new" | "lost" | "all";
+}) {
+ const columns: ColumnDef<Backlink>[] = [
+ {
+ id: "urlFrom",
+ accessorFn: (row) => `${row.domainFrom ?? ""} ${row.urlFrom ?? ""}`,
+ header: ({ column }) => (
+ <SortableHeader column={column} label="Referring page" />
+ ),
+ cell: ({ row }) => (
+ <ExternalPage
+ url={row.original.urlFrom}
+ label={row.original.domainFrom}
+ />
+ ),
+ filterFn: "includesString",
+ },
+ {
+ accessorKey: "anchor",
+ header: "Anchor",
+ cell: ({ row }) => (
+ <span
+ className="block max-w-48 truncate"
+ title={row.original.anchor ?? undefined}
+ >
+ {row.original.anchor || "—"}
+ </span>
+ ),
+ filterFn: "includesString",
+ },
+ {
+ accessorKey: "urlTo",
+ header: "Target page",
+ cell: ({ row }) => <ExternalPage url={row.original.urlTo} />,
+ filterFn: "includesString",
+ },
+ {
+ id: "follow",
+ accessorFn: (row) => (row.isDofollow ? "Follow" : "Nofollow"),
+ header: "Link type",
+ filterFn: "equalsString",
+ },
+ {
+ accessorKey: "domainFromRank",
+ header: ({ column }) => (
+ <SortableHeader column={column} label="Domain rank" />
+ ),
+ filterFn: "inNumberRange",
+ cell: ({ getValue }) => getValue() ?? "—",
+ },
+ {
+ accessorKey: "spamScore",
+ header: ({ column }) => (
+ <SortableHeader column={column} label="Spam score" />
+ ),
+ filterFn: "inNumberRange",
+ cell: ({ getValue }) => getValue() ?? "—",
+ },
+ {
+ id: "date",
+ accessorFn: (row) =>
+ (kind === "lost" ? row.lastSeen : row.firstSeen)?.slice(0, 10) ?? "—",
+ header: ({ column }) => (
+ <SortableHeader
+ column={column}
+ label={kind === "lost" ? "Last checked" : "First discovered"}
+ />
+ ),
+ },
+ ];
+ return (
+ <DashboardDataTable
+ rows={rows}
+ columns={columns}
+ filters={[
+ { id: "urlFrom", label: "Referring page", kind: "text" },
+ { id: "anchor", label: "Anchor text", kind: "text" },
+ { id: "urlTo", label: "Target page", kind: "text" },
+ { id: "follow", label: "Link type", kind: "follow" },
+ { id: "domainFromRank", label: "Domain rank", kind: "number" },
+ { id: "spamScore", label: "Spam score", kind: "number" },
+ ]}
+ />
+ );
+}
diff --git a/src/client/features/dashboard/DashboardCards.tsx b/src/client/features/dashboard/DashboardCards.tsx
index b665d715..c7a5117b 100644
--- a/src/client/features/dashboard/DashboardCards.tsx
+++ b/src/client/features/dashboard/DashboardCards.tsx
@@ -1,9 +1,14 @@
+import { GoogleSearchConsoleLogo } from "@/client/features/integrations/GoogleProductLogos";
+import { startAudit } from "@/serverFunctions/audit";
+import { QueryError } from "@/client/components/QueryState";
+import { LoaderCircle, ScanSearch } from "lucide-react";
import { CardShell } from "@/client/components/CardShell";
import { Button } from "@/client/components/ui/button";
import { Link } from "@tanstack/react-router";
-import { useQuery } from "@tanstack/react-query";
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Check } from "lucide-react";
import { GoogleConnectionCard } from "@/client/features/integrations/GoogleConnectionCard";
+import { SeverityBadge } from "@/client/features/audit/shared";
import { AUDIT_ISSUE_TYPES } from "@/shared/audit-issues";
import {
@@ -13,17 +18,20 @@ import {
} from "@/client/features/search-performance/SearchPerformanceColumns";
import { getSearchPerformanceReport } from "@/serverFunctions/searchPerformance";
import {
- EmptyCardBody,
formatDay,
moreDetailsClass,
- newLost,
- StatGridSkeleton,
+ MetricsTableSkeleton,
} from "@/client/features/dashboard/cardParts";
-import { StatTile } from "@/client/components/StatTile";
-import type {
- DashboardAuditSummary,
- DashboardBacklinkSummary,
-} from "@/server/features/dashboard/services/DashboardService";
+import { percentChange } from "@/client/components/MetricsTable";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
+import type { DashboardAuditSummary } from "@/server/features/dashboard/services/DashboardService";
// Plain string-keyed view of the registry: issue types from the DB are not
// statically guaranteed to be registry keys.
@@ -34,17 +42,20 @@ const issueTitles: Record<string, string | undefined> = Object.fromEntries(
export function GscCard({
projectId,
connected,
+ siteUrl,
}: {
projectId: string;
connected: boolean;
+ siteUrl: string | null;
}) {
const reportQuery = useQuery({
- queryKey: ["dashboardGscReport", projectId],
+ queryKey: ["dashboardGscReport", projectId, siteUrl],
queryFn: () =>
getSearchPerformanceReport({
data: { projectId, dateRange: "last_28_days" },
}),
enabled: connected,
+ staleTime: 10 * 60_000,
});
const report = reportQuery.data;
@@ -60,48 +71,81 @@ export function GscCard({
return (
<CardShell
- title="Search performance"
- stamp="Google Search Console · last 28 days"
+ title="Google Search Console Performance"
+ icon={<GoogleSearchConsoleLogo className="size-5" />}
action={
<Link
to="/p/$projectId/search-performance"
params={{ projectId }}
className={moreDetailsClass}
>
- More details
+ View GSC insights →
</Link>
}
>
+ <p className="mb-4 text-sm font-medium text-muted-foreground">
+ Last 28 days
+ </p>
{reportQuery.isError ? (
<p className="text-sm text-muted-foreground">
Couldn&rsquo;t load Search Console data. Try again shortly.
</p>
) : !report ? (
- <StatGridSkeleton />
+ <MetricsTableSkeleton />
) : (
- <div className="grid grid-cols-2 gap-3">
- <StatTile
- label="Clicks"
- value={formatCount(report.totals.clicks)}
- delta={{
- current: report.totals.clicks,
- previous: report.prevTotals.clicks,
- }}
- />
- <StatTile
- label="Impressions"
- value={formatCount(report.totals.impressions)}
- delta={{
- current: report.totals.impressions,
- previous: report.prevTotals.impressions,
- }}
- />
- <StatTile label="CTR" value={formatCtr(report.totals.ctr)} />
- <StatTile
- label="Avg position"
- value={formatPosition(report.totals.position)}
- />
- </div>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Metric</TableHead>
+ <TableHead className="text-right">Value</TableHead>
+ <TableHead className="text-right">Change</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {[
+ {
+ label: "Clicks",
+ value: formatCount(report.totals.clicks),
+ change: percentChange(
+ report.totals.clicks,
+ report.prevTotals.clicks,
+ ),
+ },
+ {
+ label: "Impressions",
+ value: formatCount(report.totals.impressions),
+ change: percentChange(
+ report.totals.impressions,
+ report.prevTotals.impressions,
+ ),
+ },
+ {
+ label: "Click-through rate",
+ value: formatCtr(report.totals.ctr),
+ change: null,
+ },
+ {
+ label: "Average position",
+ value: formatPosition(report.totals.position),
+ change: null,
+ },
+ ].map((metric) => (
+ <TableRow key={metric.label}>
+ <TableCell>{metric.label}</TableCell>
+ <TableCell className="text-right tabular-nums">
+ {metric.value}
+ </TableCell>
+ <TableCell
+ className={`text-right tabular-nums ${metric.change === null || metric.change === 0 ? "text-muted-foreground" : metric.change > 0 ? "text-success" : "text-destructive"}`}
+ >
+ {metric.change === null
+ ? "—"
+ : `${metric.change > 0 ? "+" : ""}${metric.change}%`}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
)}
</CardShell>
);
@@ -110,54 +154,93 @@ export function GscCard({
export function AuditHealthCard({
projectId,
audit,
+ domain,
}: {
projectId: string;
audit: DashboardAuditSummary | null;
+ domain: string | null;
}) {
- if (!audit) {
+ const queryClient = useQueryClient();
+ const scan = useMutation({
+ mutationFn: () =>
+ startAudit({
+ data: {
+ projectId,
+ startUrl: `https://${domain}`,
+ maxPages: 50,
+ renderJavaScript: true,
+ },
+ }),
+ onSuccess: () =>
+ void queryClient.invalidateQueries({
+ queryKey: ["dashboardOverview", projectId],
+ }),
+ meta: { errorToast: false },
+ });
+ if (!audit)
return (
- <CardShell title="Site audit">
- <EmptyCardBody
- message="Crawl your site for broken links, missing tags and indexability problems."
- cta={
+ <CardShell title="Site health">
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 py-6 text-center">
+ <ScanSearch className="size-7 text-muted-foreground" />
+ <h3 className="font-medium">Find what's holding your website back</h3>
+ <p className="max-w-sm text-sm text-muted-foreground">
+ Scan up to 50 pages for broken links, missing titles and pages
+ Google can't index.
+ </p>
+ {domain ? (
+ <Button disabled={scan.isPending} onClick={() => scan.mutate()}>
+ {scan.isPending ? "Starting scan…" : "Scan my website"}
+ </Button>
+ ) : (
<Button
- size="lg"
nativeButton={false}
- render={<Link to="/p/$projectId/audit" params={{ projectId }} />}
+ render={
+ <Link to="/p/$projectId/settings" params={{ projectId }} />
+ }
>
- Run an audit
+ Add your website
</Button>
- }
- />
+ )}
+ {scan.isError && (
+ <QueryError
+ error={scan.error}
+ fallback="Could not start your scan"
+ />
+ )}
+ </div>
</CardShell>
);
- }
return (
<CardShell
- title="Site audit"
- stamp={`Site audit · ${
- audit.status === "completed"
- ? `crawled ${audit.pagesCrawled} pages · ${formatDay(audit.startedAt)}`
- : audit.status === "running"
- ? "crawl in progress"
- : "last crawl failed"
- }`}
+ title="Site health"
action={
<Link
to="/p/$projectId/audit"
params={{ projectId }}
+ search={{ auditId: audit.id, tab: "issues" }}
className={moreDetailsClass}
>
- More details
+ Review issues
</Link>
}
>
+ {audit.status !== "completed" && audit.status !== "running" && (
+ <p className="mb-4 text-sm text-destructive">
+ The latest scan didn’t finish. Review the results or try again.
+ </p>
+ )}
+ {audit.status === "completed" && (
+ <p className="mb-4 text-sm text-muted-foreground">
+ {audit.pagesCrawled} pages checked · {formatDay(audit.startedAt)}
+ </p>
+ )}
{audit.status === "running" ? (
// A running crawl has at most a partial issue list, and an empty one
// is not the same as a healthy site.
<p className="text-sm text-muted-foreground">
- Issues appear here when the crawl finishes.
+ <LoaderCircle className="mb-3 size-6 animate-spin" />
+ Scanning your website… {audit.pagesCrawled} pages checked.
</p>
) : audit.topIssues.length === 0 ? (
audit.status === "completed" ? (
@@ -171,129 +254,37 @@ export function AuditHealthCard({
</p>
)
) : (
- <ul className="space-y-2">
- {audit.topIssues.map((issue) => (
- <li
- key={issue.issueType}
- className="flex items-center justify-between gap-2 text-sm"
- >
- <span className="flex min-w-0 items-center gap-2">
- <span
- className={`size-2 shrink-0 rounded-full ${
- issue.severity === "critical"
- ? "bg-destructive"
- : issue.severity === "warning"
- ? "bg-warning"
- : "bg-muted-foreground/30"
- }`}
- />
- <span className="truncate">
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Issue</TableHead>
+ <TableHead>Severity</TableHead>
+ <TableHead className="text-right">Pages affected</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {audit.topIssues.map((issue) => (
+ <TableRow key={issue.issueType}>
+ <TableCell>
{issueTitles[issue.issueType] ?? issue.issueType}
- </span>
- </span>
- <span className="shrink-0 tabular-nums text-muted-foreground">
- {issue.count} {issue.count === 1 ? "page" : "pages"}
- </span>
- </li>
- ))}
- {audit.totalIssueTypes > audit.topIssues.length ? (
- <li className="text-xs text-muted-foreground">
- + {audit.totalIssueTypes - audit.topIssues.length} more issue
- {audit.totalIssueTypes - audit.topIssues.length === 1 ? "" : "s"}
- </li>
- ) : null}
- {/* A failed crawl keeps what it found, as the audit page does. */}
- {audit.status !== "completed" ? (
- <li className="text-xs text-muted-foreground">
- From the pages crawled before the audit stopped.
- </li>
- ) : null}
- </ul>
+ </TableCell>
+ <TableCell>
+ <SeverityBadge severity={issue.severity}>
+ {issue.severity === "critical"
+ ? "Critical"
+ : issue.severity === "warning"
+ ? "Warning"
+ : "Info"}
+ </SeverityBadge>
+ </TableCell>
+ <TableCell className="text-right tabular-nums">
+ {issue.count}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
)}
</CardShell>
);
}
-
-export function BacklinkPulseCard({
- projectId,
- backlinks,
- refreshing,
-}: {
- projectId: string;
- backlinks: DashboardBacklinkSummary | null;
- refreshing: boolean;
-}) {
- if (!backlinks && refreshing) {
- return (
- <CardShell title="Backlink pulse" stamp="Taking your first snapshot…">
- <StatGridSkeleton />
- </CardShell>
- );
- }
-
- if (!backlinks) {
- return (
- <CardShell title="Backlink pulse">
- <p className="text-sm text-muted-foreground">
- We&rsquo;ll snapshot who links to your domain — nothing to set up.
- </p>
- </CardShell>
- );
- }
-
- return (
- <CardShell
- title="Backlink pulse"
- stamp={`Backlinks · snapshot ${formatDay(backlinks.capturedAt)}${
- refreshing ? " · refreshing…" : ""
- }`}
- action={
- <Link
- to="/p/$projectId/backlinks"
- params={{ projectId }}
- search={{ target: backlinks.domain, scope: "domain" }}
- className={moreDetailsClass}
- >
- More details
- </Link>
- }
- >
- <div className="grid grid-cols-2 gap-3">
- <StatTile
- label="Ref. domains"
- value={
- backlinks.referringDomains === null
- ? "—"
- : backlinks.referringDomains.toLocaleString()
- }
- />
- <StatTile
- label="Backlinks"
- value={
- backlinks.backlinks === null
- ? "—"
- : backlinks.backlinks.toLocaleString()
- }
- />
- <StatTile
- label="New links"
- value={`▲ ${newLost(backlinks.newBacklinks)}`}
- tone={
- backlinks.newBacklinks && backlinks.newBacklinks > 0
- ? "success"
- : undefined
- }
- />
- <StatTile
- label="Lost links"
- value={`▼ ${newLost(backlinks.lostBacklinks)}`}
- tone={
- backlinks.lostBacklinks && backlinks.lostBacklinks > 0
- ? "destructive"
- : undefined
- }
- />
- </div>
- </CardShell>
- );
-}
diff --git a/src/client/features/dashboard/DashboardDataTable.tsx b/src/client/features/dashboard/DashboardDataTable.tsx
new file mode 100644
index 00000000..495aa3fa
--- /dev/null
+++ b/src/client/features/dashboard/DashboardDataTable.tsx
@@ -0,0 +1,153 @@
+import {
+ getFilteredRowModel,
+ type SortingState,
+ type ColumnDef,
+} from "@tanstack/react-table";
+import { useState } from "react";
+import { DataTable, useDataTable } from "@/client/components/table/DataTable";
+import {
+ DataTableToolbar,
+ DataTableFilterToggle,
+ DataTableFilterPanel,
+ DataTableFilterGroup,
+ DataTableRangeFilter,
+} from "@/client/components/table/DataTableToolbar";
+import { TablePagination } from "@/client/components/table/TablePagination";
+import { Input } from "@/client/components/ui/input";
+import {
+ Select,
+ SelectTrigger,
+ SelectValue,
+ SelectContent,
+ SelectItem,
+} from "@/client/components/ui/select";
+
+type Filter = { id: string; label: string; kind: "text" | "number" | "follow" };
+export function DashboardDataTable<T>({
+ rows,
+ columns,
+ filters,
+ initialSorting,
+}: {
+ rows: T[];
+ columns: ColumnDef<T>[];
+ filters: Filter[];
+ initialSorting?: SortingState;
+}) {
+ const [open, setOpen] = useState(false);
+ const table = useDataTable({
+ data: rows,
+ columns,
+ withSorting: true,
+ withPagination: true,
+ getFilteredRowModel: getFilteredRowModel(),
+ initialState: {
+ pagination: { pageIndex: 0, pageSize: 25 },
+ sorting: initialSorting,
+ },
+ });
+ const count = table.getState().columnFilters.length;
+ const clear = () => table.resetColumnFilters();
+ return (
+ <DataTable
+ table={table}
+ isFiltered={count > 0}
+ onClearFilters={clear}
+ empty={{ title: "No results yet" }}
+ toolbar={
+ <>
+ <DataTableToolbar>
+ <DataTableFilterToggle
+ open={open}
+ activeCount={count}
+ onToggle={() => setOpen(!open)}
+ />
+ </DataTableToolbar>
+ {open && (
+ <DataTableFilterPanel activeCount={count} onReset={clear}>
+ <div className="grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
+ {filters.map((filter) => {
+ const column = table.getColumn(filter.id)!;
+ const value = column.getFilterValue();
+ if (filter.kind === "number") {
+ const range = Array.isArray(value)
+ ? value.map((item) =>
+ typeof item === "number" ? item : undefined,
+ )
+ : [undefined, undefined];
+ const change = (index: number, input: string) => {
+ const next = [...range];
+ next[index] = input === "" ? undefined : Number(input);
+ column.setFilterValue(next);
+ };
+ return (
+ <DataTableRangeFilter
+ key={filter.id}
+ label={filter.label}
+ min={{
+ step: "any",
+ value: range[0] ?? "",
+ onChange: (e) => change(0, e.target.value),
+ }}
+ max={{
+ step: "any",
+ value: range[1] ?? "",
+ onChange: (e) => change(1, e.target.value),
+ }}
+ />
+ );
+ }
+ return (
+ <DataTableFilterGroup key={filter.id} label={filter.label}>
+ {filter.kind === "follow" ? (
+ <Select
+ items={[
+ { value: "all", label: "All links" },
+ { value: "Follow", label: "Follow" },
+ { value: "Nofollow", label: "Nofollow" },
+ ]}
+ value={typeof value === "string" ? value : "all"}
+ onValueChange={(v) =>
+ column.setFilterValue(v === "all" ? undefined : v)
+ }
+ >
+ <SelectTrigger aria-label={filter.label}>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="all">All links</SelectItem>
+ <SelectItem value="Follow">Follow</SelectItem>
+ <SelectItem value="Nofollow">Nofollow</SelectItem>
+ </SelectContent>
+ </Select>
+ ) : (
+ <Input
+ aria-label={filter.label}
+ placeholder="Contains…"
+ value={typeof value === "string" ? value : ""}
+ onChange={(e) =>
+ column.setFilterValue(e.target.value)
+ }
+ />
+ )}
+ </DataTableFilterGroup>
+ );
+ })}
+ </div>
+ </DataTableFilterPanel>
+ )}
+ </>
+ }
+ footer={
+ table.getFilteredRowModel().rows.length > 25 ? (
+ <TablePagination
+ page={table.getState().pagination.pageIndex + 1}
+ pageSize={25}
+ totalCount={table.getFilteredRowModel().rows.length}
+ onPageChange={(page) => table.setPageIndex(page - 1)}
+ />
+ ) : undefined
+ }
+ />
+ );
+}
diff --git a/src/client/features/dashboard/DashboardKeywordTable.tsx b/src/client/features/dashboard/DashboardKeywordTable.tsx
new file mode 100644
index 00000000..78e88471
--- /dev/null
+++ b/src/client/features/dashboard/DashboardKeywordTable.tsx
@@ -0,0 +1,81 @@
+import { ExternalPage } from "./siteTabParts";
+import type { ColumnDef } from "@tanstack/react-table";
+import { SortableHeader } from "@/client/components/table/SortableHeader";
+import { DashboardDataTable } from "./DashboardDataTable";
+
+type Keyword = {
+ query: string;
+ page?: string;
+ clicks: number;
+ impressions: number;
+ position: number;
+};
+const columns: ColumnDef<Keyword>[] = [
+ {
+ accessorKey: "query",
+ header: ({ column }) => <SortableHeader column={column} label="Keyword" />,
+ filterFn: "includesString",
+ },
+ ...(["impressions", "clicks", "position"] as const).map(
+ (id) =>
+ ({
+ accessorKey: id,
+ header: ({ column }) => (
+ <SortableHeader
+ column={column}
+ label={
+ id === "position"
+ ? "Avg. position"
+ : id === "clicks"
+ ? "Clicks"
+ : "Impressions"
+ }
+ align="right"
+ />
+ ),
+ cell: ({ getValue }) =>
+ id === "position"
+ ? Number(getValue()).toFixed(1)
+ : Number(getValue()).toLocaleString(),
+ filterFn: "inNumberRange",
+ meta: {
+ headerClassName: "text-right",
+ cellClassName: "text-right tabular-nums",
+ },
+ }) satisfies ColumnDef<Keyword>,
+ ),
+];
+export function DashboardKeywordTable({
+ rows,
+ showPages = false,
+ sortBy = "impressions",
+}: {
+ rows: Keyword[];
+ showPages?: boolean;
+ sortBy?: "impressions" | "clicks";
+}) {
+ const pageColumn: ColumnDef<Keyword> = {
+ accessorKey: "page",
+ header: "Page",
+ filterFn: "includesString",
+ cell: ({ row }) => <ExternalPage url={row.original.page ?? null} />,
+ };
+ return (
+ <DashboardDataTable
+ rows={rows}
+ columns={
+ showPages ? [columns[0], pageColumn, ...columns.slice(1)] : columns
+ }
+ initialSorting={[{ id: sortBy, desc: true }]}
+ filters={[
+ { id: "query", label: "Keyword", kind: "text" },
+ ...(showPages
+ ? [{ id: "page", label: "Page", kind: "text" as const }]
+ : []),
+ { id: "impressions", label: "Impressions", kind: "number" },
+ { id: "clicks", label: "Clicks", kind: "number" },
+ { id: "position", label: "Average position", kind: "number" },
+ ]}
+ />
+ );
+}
diff --git a/src/client/features/dashboard/DashboardKeywords.tsx b/src/client/features/dashboard/DashboardKeywords.tsx
new file mode 100644
index 00000000..0343996a
--- /dev/null
+++ b/src/client/features/dashboard/DashboardKeywords.tsx
@@ -0,0 +1,167 @@
+import { Link } from "@tanstack/react-router";
+import { Button } from "@/client/components/ui/button";
+import { getSearchPerformanceReport } from "@/serverFunctions/searchPerformance";
+import { useState } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { Tabs, TabsList, TabsTrigger } from "@/client/components/ui/tabs";
+import { CardShell } from "@/client/components/CardShell";
+import { QueryState } from "@/client/components/QueryState";
+import { GoogleConnectionCard } from "@/client/features/integrations/GoogleConnectionCard";
+import { getDashboardKeywords } from "@/serverFunctions/dashboard";
+import { DashboardNewQueries } from "./DashboardNewQueries";
+import { DashboardKeywordTable } from "./DashboardKeywordTable";
+import { DashboardInfo, Freshness } from "./siteTabParts";
+
+export function DashboardKeywords({
+ projectId,
+ connected,
+ siteUrl,
+}: {
+ projectId: string;
+ connected: boolean;
+ siteUrl: string | null;
+}) {
+ const [source, setSource] = useState("new");
+ const keywords = useQuery({
+ queryKey: ["dashboardGscKeywords", projectId, siteUrl],
+ queryFn: () => getDashboardKeywords({ data: { projectId } }),
+ enabled: connected && source === "top",
+ staleTime: 10 * 60_000,
+ retry: false,
+ });
+ const striking = useQuery({
+ queryKey: ["dashboardGscReport", projectId, siteUrl],
+ queryFn: () =>
+ getSearchPerformanceReport({
+ data: { projectId, dateRange: "last_28_days" },
+ }),
+ enabled: connected && source === "striking",
+ staleTime: 10 * 60_000,
+ });
+ if (!connected)
+ return (
+ <GoogleConnectionCard provider="gsc" projectId={projectId} prominent />
+ );
+ return (
+ <div className="space-y-5">
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <h2 className="text-lg font-semibold">Your keywords</h2>
+ <Button
+ variant="outline"
+ nativeButton={false}
+ render={
+ <Link
+ to="/p/$projectId/search-performance"
+ params={{ projectId }}
+ />
+ }
+ >
+ View full GSC insights →
+ </Button>
+ </div>
+ <div className="overflow-x-auto">
+ <div className="flex w-max items-center gap-2">
+ <Tabs
+ value={source}
+ onValueChange={(value) => setSource(String(value))}
+ >
+ <TabsList>
+ <TabsTrigger value="new">New keywords</TabsTrigger>
+ <TabsTrigger value="top">Top keywords</TabsTrigger>
+ <TabsTrigger value="striking">Striking distance</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ <DashboardInfo label="About keyword views">
+ <p>
+ <strong>New keywords</strong> are searches we started seeing
+ recently.
+ </p>
+ <p className="mt-2">
+ <strong>Top keywords</strong> shows the searches bringing the most
+ clicks to your website.
+ </p>
+ <p className="mt-2">
+ <strong>Striking distance</strong> shows keywords where your site
+ appears at positions 5–20, with room to move higher.
+ </p>
+ </DashboardInfo>
+ </div>
+ </div>
+ {source === "new" ? (
+ <DashboardNewQueries
+ projectId={projectId}
+ connected={connected}
+ siteUrl={siteUrl}
+ />
+ ) : source === "striking" ? (
+ <QueryState query={striking} errorFallback="Could not load keywords">
+ {(report) =>
+ !report.connected ? (
+ <GoogleConnectionCard
+ provider="gsc"
+ projectId={projectId}
+ prominent
+ />
+ ) : (
+ <CardShell
+ title="Striking distance"
+ titleInfo={
+ <DashboardInfo label="About striking distance">
+ Keywords where your website appears at positions 5–20 on
+ Google. Improving the listed page could help it move higher.
+ </DashboardInfo>
+ }
+ >
+ <p className="mb-4 text-sm text-muted-foreground">
+ Last 28 days
+ </p>
+ {report.strikingDistance.length ? (
+ <DashboardKeywordTable
+ rows={report.strikingDistance}
+ showPages
+ />
+ ) : (
+ <p className="py-8 text-sm text-muted-foreground">
+ No keywords at positions 5–20 in this period.
+ </p>
+ )}
+ </CardShell>
+ )
+ }
+ </QueryState>
+ ) : (
+ <QueryState query={keywords} errorFallback="Could not load keywords">
+ {(data) =>
+ !data.value.connected ? (
+ <GoogleConnectionCard
+ provider="gsc"
+ projectId={projectId}
+ prominent
+ />
+ ) : (
+ <CardShell
+ title="Top keywords"
+ titleInfo={
+ <DashboardInfo label="About top keywords">
+ Searches bringing the most clicks to your website over the
+ last 28 days, from Google Search Console.
+ </DashboardInfo>
+ }
+ >
+ <p className="mb-4 text-sm text-muted-foreground">
+ Last 28 days
+ </p>
+ <Freshness {...data} />
+ <DashboardKeywordTable
+ key="top"
+ rows={data.value.rows}
+ sortBy="clicks"
+ />
+ </CardShell>
+ )
+ }
+ </QueryState>
+ )}
+ </div>
+ );
+}
diff --git a/src/client/features/dashboard/DashboardLinkActivity.tsx b/src/client/features/dashboard/DashboardLinkActivity.tsx
new file mode 100644
index 00000000..0c846d69
--- /dev/null
+++ b/src/client/features/dashboard/DashboardLinkActivity.tsx
@@ -0,0 +1,127 @@
+import {
+ Table,
+ TableHeader,
+ TableBody,
+ TableRow,
+ TableHead,
+ TableCell,
+} from "@/client/components/ui/table";
+import { Link } from "@tanstack/react-router";
+import { useQuery } from "@tanstack/react-query";
+import { Link2 } from "lucide-react";
+import { CardShell } from "@/client/components/CardShell";
+import { QueryState } from "@/client/components/QueryState";
+import { getDashboardLinkActivity } from "@/serverFunctions/dashboard";
+import { DashboardInfo, ExternalPage, Freshness } from "./siteTabParts";
+import { moreDetailsClass } from "./cardParts";
+export function DashboardLinkActivity({
+ projectId,
+ domain,
+}: {
+ projectId: string;
+ domain: string;
+}) {
+ const query = useQuery({
+ queryKey: ["dashboardLinkActivity", projectId, domain],
+ queryFn: () => getDashboardLinkActivity({ data: { projectId } }),
+ staleTime: 86400_000,
+ retry: false,
+ });
+ return (
+ <QueryState query={query} errorFallback="Could not load new links">
+ {(data) => (
+ <CardShell
+ title="New backlinks"
+ titleInfo={
+ <DashboardInfo label="About new links">
+ <p>
+ Links to your website found in the past week. We show new
+ linking sites first.
+ </p>
+ <p className="mt-2">
+ A link may be older than the date it was found.
+ </p>
+ </DashboardInfo>
+ }
+ action={
+ <Link
+ to="/p/$projectId"
+ params={{ projectId }}
+ search={{ tab: "backlinks" }}
+ className={moreDetailsClass}
+ >
+ View all →
+ </Link>
+ }
+ >
+ <Freshness {...data} />
+ {data.value.length ? (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Referring domain</TableHead>
+ <TableHead className="text-right">Backlinks</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {data.value.slice(0, 5).map((row, index) => (
+ <TableRow key={row.domain ?? index}>
+ <TableCell className="font-medium">
+ <ExternalPage
+ url={row.domain ? `https://${row.domain}` : null}
+ label={row.domain}
+ />
+ </TableCell>
+ <TableCell className="text-right tabular-nums">
+ {row.backlinks?.toLocaleString() ?? "—"}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ) : data.links.length ? (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Referring page</TableHead>
+ <TableHead>Anchor</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {data.links.slice(0, 5).map((row, index) => (
+ <TableRow key={`${row.urlFrom}:${index}`}>
+ <TableCell>
+ <ExternalPage url={row.urlFrom} label={row.domainFrom} />
+ </TableCell>
+ <TableCell
+ className="max-w-48 truncate"
+ title={row.anchor ?? undefined}
+ >
+ {row.anchor || "—"}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ ) : (
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 py-8 text-center">
+ <Link2 className="size-7 text-muted-foreground" />
+ <h3 className="font-medium">No new links this week</h3>
+ <p className="text-sm text-muted-foreground">
+ Explore the sites already linking to you.
+ </p>
+ <Link
+ to="/p/$projectId"
+ params={{ projectId }}
+ search={{ tab: "backlinks" }}
+ className="text-sm text-primary hover:underline"
+ >
+ View backlinks →
+ </Link>
+ </div>
+ )}
+ </CardShell>
+ )}
+ </QueryState>
+ );
+}
diff --git a/src/client/features/dashboard/DashboardNewQueries.tsx b/src/client/features/dashboard/DashboardNewQueries.tsx
new file mode 100644
index 00000000..ffb22b57
--- /dev/null
+++ b/src/client/features/dashboard/DashboardNewQueries.tsx
@@ -0,0 +1,131 @@
+import { DashboardKeywordTable } from "./DashboardKeywordTable";
+import { Link } from "@tanstack/react-router";
+import { useQuery } from "@tanstack/react-query";
+import { Search } from "lucide-react";
+import { CardShell } from "@/client/components/CardShell";
+import { QueryState } from "@/client/components/QueryState";
+import { GoogleConnectionCard } from "@/client/features/integrations/GoogleConnectionCard";
+import {
+ Table,
+ TableHeader,
+ TableBody,
+ TableRow,
+ TableHead,
+ TableCell,
+} from "@/client/components/ui/table";
+import { getDashboardEmergingQueries } from "@/serverFunctions/dashboard";
+import { Freshness, DashboardInfo } from "./siteTabParts";
+import { moreDetailsClass } from "./cardParts";
+
+export function DashboardNewQueries({
+ projectId,
+ connected,
+ siteUrl,
+ compact = false,
+}: {
+ projectId: string;
+ connected: boolean;
+ siteUrl: string | null;
+ compact?: boolean;
+}) {
+ const query = useQuery({
+ queryKey: ["dashboardEmergingQueries", projectId, siteUrl],
+ queryFn: () => getDashboardEmergingQueries({ data: { projectId } }),
+ enabled: connected,
+ staleTime: 10 * 60_000,
+ retry: false,
+ });
+ if (!connected)
+ return compact ? null : (
+ <GoogleConnectionCard provider="gsc" projectId={projectId} prominent />
+ );
+ return (
+ <QueryState query={query} errorFallback="Could not load new keywords">
+ {(data) =>
+ !data.value.connected ? (
+ <GoogleConnectionCard
+ provider="gsc"
+ projectId={projectId}
+ prominent
+ />
+ ) : (
+ <CardShell
+ title="New keywords"
+ titleInfo={
+ <DashboardInfo label="About new keywords">
+ <p>Searches where your website recently appeared on Google.</p>
+ <p className="mt-2">
+ We saw these in the latest week of Search Console data, but
+ not in the previous four weeks.
+ </p>
+ </DashboardInfo>
+ }
+ action={
+ compact ? (
+ <Link
+ to="/p/$projectId"
+ params={{ projectId }}
+ search={{ tab: "keywords" }}
+ className={moreDetailsClass}
+ >
+ View all →
+ </Link>
+ ) : undefined
+ }
+ >
+ <Freshness {...data} />
+ {data.value.rows.length ? (
+ !compact ? (
+ <DashboardKeywordTable rows={data.value.rows} />
+ ) : (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Keyword</TableHead>
+ <TableHead>Impressions</TableHead>
+ <TableHead>Clicks</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {data.value.rows.slice(0, compact ? 5 : 25).map((row) => (
+ <TableRow key={row.query}>
+ <TableCell className="font-medium">
+ {row.query}
+ </TableCell>
+ <TableCell>
+ {row.impressions.toLocaleString()}
+ </TableCell>
+ <TableCell>{row.clicks}</TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ )
+ ) : (
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 py-8 text-center">
+ <Search className="size-7 text-muted-foreground" />
+ <h3 className="font-medium">
+ {data.value.hasSearchData
+ ? "No new keywords this week"
+ : "No search data yet"}
+ </h3>
+ <p className="max-w-sm text-sm text-muted-foreground">
+ {data.value.hasSearchData
+ ? "Your existing queries can still be gaining clicks. See how they're performing."
+ : "Google hasn't reported searches for your website yet. Check your connected property in Search Console."}
+ </p>
+ <Link
+ to="/p/$projectId/search-performance"
+ params={{ projectId }}
+ className="text-sm text-primary hover:underline"
+ >
+ View full GSC insights →
+ </Link>
+ </div>
+ )}
+ </CardShell>
+ )
+ }
+ </QueryState>
+ );
+}
diff --git a/src/client/features/dashboard/DashboardPage.tsx b/src/client/features/dashboard/DashboardPage.tsx
index 3cd7bad2..eee6cd13 100644
--- a/src/client/features/dashboard/DashboardPage.tsx
+++ b/src/client/features/dashboard/DashboardPage.tsx
@@ -1,10 +1,22 @@
-import { Fragment, useEffect, useRef } from "react";
-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import { Link } from "@tanstack/react-router";
+import {
+ Tabs,
+ TabsList,
+ TabsTrigger,
+ TabsContent,
+} from "@/client/components/ui/tabs";
+import { DashboardKeywords } from "./DashboardKeywords";
+import { DashboardBacklinks } from "./DashboardBacklinks";
+import { DashboardNewQueries } from "./DashboardNewQueries";
+import { DashboardLinkActivity } from "./DashboardLinkActivity";
+import { dashboardSiteTabSchema } from "@/types/schemas/dashboard";
+import type { z } from "zod";
+import { Fragment } from "react";
+import { useQuery } from "@tanstack/react-query";
import { sort } from "remeda";
import { DashboardOnboarding } from "./DashboardOnboarding";
import {
AuditHealthCard,
- BacklinkPulseCard,
GscCard,
} from "@/client/features/dashboard/DashboardCards";
import { Ga4Card } from "@/client/features/dashboard/Ga4Card";
@@ -13,13 +25,18 @@ import { QueryError } from "@/client/components/QueryState";
import {
getDashboardActivation,
getDashboardOverview,
- refreshDashboardBacklinkSnapshot,
} from "@/serverFunctions/dashboard";
import { Skeleton } from "@/client/components/ui/skeleton";
-export function DashboardPage({ projectId }: { projectId: string }) {
- const queryClient = useQueryClient();
-
+export function DashboardPage({
+ projectId,
+ tab = "overview",
+ onTabChange,
+}: {
+ projectId: string;
+ tab?: z.infer<typeof dashboardSiteTabSchema>;
+ onTabChange: (tab: z.infer<typeof dashboardSiteTabSchema>) => void;
+}) {
const activationQuery = useQuery({
queryKey: ["dashboardActivation", projectId],
queryFn: () => getDashboardActivation({ data: { projectId } }),
@@ -34,27 +51,6 @@ export function DashboardPage({ projectId }: { projectId: string }) {
const activation = activationQuery.data;
const overview = overviewQuery.data;
- // Visit-triggered backlink snapshot: fire once per page view when the
- // overview reports a missing or stale snapshot for a project with a domain.
- // The server re-checks freshness, so a stray double-fire costs nothing.
- const refreshMutation = useMutation({
- mutationFn: () => refreshDashboardBacklinkSnapshot({ data: { projectId } }),
- onSuccess: () =>
- void queryClient.invalidateQueries({
- queryKey: ["dashboardOverview", projectId],
- }),
- });
- const refreshFiredRef = useRef(false);
- const needsSnapshot =
- activation?.domain != null &&
- overview !== undefined &&
- (overview.backlinks === null || overview.backlinks.stale);
- useEffect(() => {
- if (!needsSnapshot || refreshFiredRef.current) return;
- refreshFiredRef.current = true;
- refreshMutation.mutate();
- }, [needsSnapshot, refreshMutation]);
-
if (activationQuery.isError && !activation) {
return (
<div className="px-4 py-4 md:px-6 md:py-6">
@@ -71,7 +67,7 @@ export function DashboardPage({ projectId }: { projectId: string }) {
// Wait for the overview too: rendering cards from `overview === undefined`
// flashes their empty states (and reshuffles the data-first sort) once the
// real data lands. An overview error falls through so the page still loads,
- // with the error in place of the audit and backlink cards.
+ // with the error in place of the audit card.
if (!activation || overviewQuery.isPending) {
return (
<div className="px-4 py-4 md:px-6 md:py-6" aria-busy>
@@ -94,10 +90,28 @@ export function DashboardPage({ projectId }: { projectId: string }) {
// Search Console always renders: connected shows the report, otherwise the
// connect pitch. It sits ahead of the optional GA4 pitch.
const cards = [
+ {
+ key: "newQueries",
+ hasData: gscConnected,
+ node: (
+ <DashboardNewQueries
+ projectId={projectId}
+ connected={gscConnected}
+ siteUrl={activation.gsc.siteUrl}
+ compact
+ />
+ ),
+ },
{
key: "gsc",
hasData: gscConnected,
- node: <GscCard projectId={projectId} connected={gscConnected} />,
+ node: (
+ <GscCard
+ projectId={projectId}
+ connected={gscConnected}
+ siteUrl={activation.gsc.siteUrl}
+ />
+ ),
},
...(ga4Connected || !activation.ga4.cardDismissedAt
? [
@@ -114,21 +128,24 @@ export function DashboardPage({ projectId }: { projectId: string }) {
key: "audit",
hasData: overview.audit != null,
node: (
- <AuditHealthCard projectId={projectId} audit={overview.audit} />
+ <AuditHealthCard
+ projectId={projectId}
+ audit={overview.audit}
+ domain={activation.domain}
+ />
),
},
]
: []),
- ...(overview && showBacklinks
+ ...(showBacklinks
? [
{
key: "backlinks",
- hasData: overview.backlinks != null || refreshMutation.isPending,
+ hasData: true,
node: (
- <BacklinkPulseCard
+ <DashboardLinkActivity
projectId={projectId}
- backlinks={overview.backlinks}
- refreshing={refreshMutation.isPending}
+ domain={activation.domain!}
/>
),
},
@@ -139,16 +156,29 @@ export function DashboardPage({ projectId }: { projectId: string }) {
return (
<div className="px-4 py-4 pb-24 md:px-6 md:py-6 md:pb-8">
<div className="mx-auto flex max-w-7xl flex-col gap-5">
- <h1 className="text-2xl font-semibold">Dashboard</h1>
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <div>
+ <p className="mb-1 text-xs font-medium uppercase tracking-wider text-muted-foreground">
+ Your website
+ </p>
+ <h1 className="text-2xl font-semibold">
+ {activation.domain || "Dashboard"}
+ </h1>
+ <p className="mt-1 text-sm text-muted-foreground">
+ Search visibility, links and site health in one place.
+ </p>
+ </div>
+ <Link
+ to="/p/$projectId/settings"
+ params={{ projectId }}
+ className="text-sm text-muted-foreground hover:text-foreground"
+ >
+ Project settings →
+ </Link>
+ </div>
<WorkspaceMergeBanner />
- <DashboardOnboarding
- key={projectId}
- projectId={projectId}
- activation={activation}
- />
-
{activationQuery.isError ? (
<QueryError
error={activationQuery.error}
@@ -161,22 +191,82 @@ export function DashboardPage({ projectId }: { projectId: string }) {
{overviewQuery.isError ? (
<QueryError
error={overviewQuery.error}
- fallback="Failed to load site audit and backlink summaries"
+ fallback="Failed to load site health"
onRetry={() => void overviewQuery.refetch()}
isRetrying={overviewQuery.isFetching}
/>
) : null}
- {/* Every card is half width on large screens (only the checklist spans).
- Cards with data render before setup pitches and empty states. Cards in
- a row stretch to the same height. */}
- <div className="grid gap-5 lg:grid-cols-2">
- {sort(cards, (a, b) => Number(b.hasData) - Number(a.hasData)).map(
- (card) => (
- <Fragment key={card.key}>{card.node}</Fragment>
- ),
- )}
- </div>
+ <Tabs
+ value={tab}
+ onValueChange={(value) => {
+ const parsed = dashboardSiteTabSchema.safeParse(value);
+ if (parsed.success) onTabChange(parsed.data);
+ }}
+ >
+ <div className="overflow-x-auto border-b pb-2">
+ <TabsList
+ variant="line"
+ className="h-11 gap-4"
+ aria-label="Your website dashboard"
+ >
+ {(
+ [
+ ["overview", "Overview"],
+ ["keywords", "Keywords"],
+ ["backlinks", "Backlinks"],
+ ] as const
+ ).map(([value, label]) => (
+ <TabsTrigger key={value} value={value} className="px-2">
+ {label}
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </div>
+ {/* Base UI unmounts inactive panels, so paid detail queries load only on opening their tab. */}
+ <TabsContent
+ value="overview"
+ className="space-y-5 pt-4"
+ keepMounted={false}
+ >
+ <>
+ <DashboardOnboarding
+ key={projectId}
+ projectId={projectId}
+ activation={activation}
+ />
+
+ <div className="grid gap-5 lg:grid-cols-2">
+ {sort(
+ cards,
+ (a, b) => Number(b.hasData) - Number(a.hasData),
+ ).map((card) => (
+ <Fragment key={card.key}>{card.node}</Fragment>
+ ))}
+ </div>
+ </>
+ </TabsContent>
+
+ <TabsContent value="keywords" className="pt-4" keepMounted={false}>
+ <DashboardKeywords
+ key={`${projectId}:${activation.domain}`}
+ projectId={projectId}
+ connected={gscConnected}
+ siteUrl={activation.gsc.siteUrl}
+ />
+ </TabsContent>
+ <TabsContent value="backlinks" className="pt-4" keepMounted={false}>
+ {activation.domain ? (
+ <DashboardBacklinks
+ key={activation.domain}
+ projectId={projectId}
+ domain={activation.domain}
+ />
+ ) : (
+ <p>Add your website in project settings to see backlinks.</p>
+ )}
+ </TabsContent>
+ </Tabs>
</div>
</div>
);
diff --git a/src/client/features/dashboard/Ga4Card.tsx b/src/client/features/dashboard/Ga4Card.tsx
index b12090cd..99f1ed0b 100644
--- a/src/client/features/dashboard/Ga4Card.tsx
+++ b/src/client/features/dashboard/Ga4Card.tsx
@@ -1,12 +1,10 @@
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
import { CardShell } from "@/client/components/CardShell";
import { Link } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
import { Area, AreaChart, XAxis, YAxis } from "recharts";
-import {
- moreDetailsClass,
- StatGridSkeleton,
-} from "@/client/features/dashboard/cardParts";
-import { StatTile } from "@/client/components/StatTile";
+import { moreDetailsClass } from "@/client/features/dashboard/cardParts";
+import { MetricsTable, percentChange } from "@/client/components/MetricsTable";
import { Ga4ConnectCard } from "@/client/features/dashboard/Ga4ConnectCard";
import {
formatCount,
@@ -67,7 +65,6 @@ export function Ga4Card({
return (
<CardShell
title="Organic traffic"
- stamp="Google Analytics · last 28 days"
action={
<Link
to="/p/$projectId/settings"
@@ -79,13 +76,16 @@ export function Ga4Card({
</Link>
}
>
+ <p className="mb-4 text-sm text-muted-foreground">
+ Google Analytics · Last 28 days
+ </p>
{reportQuery.isError ? (
<p className="text-sm text-muted-foreground">
Couldn&rsquo;t load Google Analytics data. Try again shortly.
</p>
) : !report ? (
<div className="space-y-3" aria-busy>
- <StatGridSkeleton tileClassName="h-16" />
+ <SkeletonTableRows rows={5} columns={3} />
<Skeleton className="h-24" />
</div>
) : !report.totals.sessions ? (
@@ -94,36 +94,58 @@ export function Ga4Card({
</p>
) : (
<div className="space-y-4">
- <div className="grid grid-cols-2 gap-3">
- <StatTile
- label="Sessions"
- value={statValue(report.totals.sessions, formatCount)}
- delta={{
- current: report.totals.sessions,
- previous: report.prevTotals.sessions,
- }}
- />
- <StatTile
- label="Active users"
- value={statValue(report.totals.activeUsers, formatCount)}
- delta={{
- current: report.totals.activeUsers,
- previous: report.prevTotals.activeUsers,
- }}
- />
- <StatTile
- label="Engagement rate"
- value={statValue(report.totals.engagementRate, formatCtr)}
- />
- <StatTile
- label="Key events"
- value={statValue(report.totals.keyEvents, formatCount)}
- delta={{
- current: report.totals.keyEvents,
- previous: report.prevTotals.keyEvents,
- }}
- />
- </div>
+ <MetricsTable
+ showChange
+ rows={[
+ {
+ label: "Sessions",
+ value: statValue(report.totals.sessions, formatCount),
+ change: percentChange(
+ report.totals.sessions,
+ report.prevTotals.sessions,
+ ),
+ },
+ {
+ label: "Active users",
+ value: statValue(report.totals.activeUsers, formatCount),
+ change: percentChange(
+ report.totals.activeUsers,
+ report.prevTotals.activeUsers,
+ ),
+ },
+ {
+ label: "Engagement rate",
+ value: statValue(report.totals.engagementRate, formatCtr),
+ change: null,
+ },
+ {
+ label: "Key events",
+ value: statValue(report.totals.keyEvents, formatCount),
+ change: percentChange(
+ report.totals.keyEvents,
+ report.prevTotals.keyEvents,
+ ),
+ },
+ ].map((metric) => ({
+ label: metric.label,
+ value: metric.value,
+ change:
+ metric.change === null ? undefined : (
+ <span
+ className={
+ metric.change > 0
+ ? "text-success"
+ : metric.change < 0
+ ? "text-destructive"
+ : "text-muted-foreground"
+ }
+ >
+ {metric.change > 0 ? "+" : ""}
+ {metric.change}%
+ </span>
+ ),
+ }))}
+ />
<ChartContainer config={sessionsChartConfig} className="h-24">
<AreaChart
data={report.trend}
diff --git a/src/client/features/dashboard/Ga4ConnectCard.tsx b/src/client/features/dashboard/Ga4ConnectCard.tsx
index 847591ba..e9bccbae 100644
--- a/src/client/features/dashboard/Ga4ConnectCard.tsx
+++ b/src/client/features/dashboard/Ga4ConnectCard.tsx
@@ -1,3 +1,7 @@
+import { useState } from "react";
+import { toast } from "sonner";
+import { CardShell } from "@/client/components/CardShell";
+import { Button } from "@/client/components/ui/button";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { GoogleConnectionCard } from "@/client/features/integrations/GoogleConnectionCard";
import { captureClientEvent } from "@/client/lib/posthog";
@@ -11,14 +15,42 @@ export function Ga4ConnectCard({
connected: boolean;
}) {
const queryClient = useQueryClient();
+ const [usesGa4, setUsesGa4] = useState(false);
const dismissMutation = useMutation({
mutationFn: () => dismissDashboardGa4Card({ data: { projectId } }),
- onSuccess: () =>
+ onSuccess: () => {
+ toast.success("Use another analytics provider?", {
+ description:
+ "Connect its MCP server to your AI agent to work with your analytics data.",
+ duration: 10000,
+ });
void queryClient.invalidateQueries({
queryKey: ["dashboardActivation", projectId],
- }),
+ });
+ },
});
+ if (!connected && !usesGa4)
+ return (
+ <CardShell title="Do you use Google Analytics 4?">
+ <p className="text-sm text-muted-foreground">
+ Bring your organic traffic and conversions into your dashboard.
+ </p>
+ <div className="mt-6 flex flex-wrap gap-2">
+ <Button onClick={() => setUsesGa4(true)}>Yes, connect GA4</Button>
+ <Button
+ variant="outline"
+ disabled={dismissMutation.isPending}
+ onClick={() => {
+ captureClientEvent("dashboard:ga4_dismiss");
+ dismissMutation.mutate();
+ }}
+ >
+ No
+ </Button>
+ </div>
+ </CardShell>
+ );
return (
<GoogleConnectionCard
provider="ga4"
diff --git a/src/client/features/dashboard/cardParts.tsx b/src/client/features/dashboard/cardParts.tsx
index eff8dd91..38ba317a 100644
--- a/src/client/features/dashboard/cardParts.tsx
+++ b/src/client/features/dashboard/cardParts.tsx
@@ -1,34 +1,9 @@
import { buttonVariants } from "@/client/components/ui/button";
-import { Skeleton } from "@/client/components/ui/skeleton";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
// Shared building blocks for the dashboard cards.
-export function StatGridSkeleton({
- tileClassName = "h-20",
-}: {
- tileClassName?: string;
-}) {
- return (
- <div className="grid grid-cols-2 gap-3" aria-busy>
- {Array.from({ length: 4 }, (_, i) => (
- <Skeleton key={i} className={tileClassName} />
- ))}
- </div>
- );
-}
-
-export function EmptyCardBody({
- message,
- cta,
-}: {
- message: string;
- cta: React.ReactNode;
-}) {
- return (
- <div className="flex flex-1 flex-col gap-3">
- <p className="text-sm text-muted-foreground">{message}</p>
- <div className="mt-auto flex justify-end">{cta}</div>
- </div>
- );
+export function MetricsTableSkeleton() {
+ return <SkeletonTableRows rows={5} columns={3} />;
}
export const moreDetailsClass = buttonVariants({
@@ -36,10 +11,6 @@ export const moreDetailsClass = buttonVariants({
size: "xs",
});
-export function newLost(value: number | null): string {
- return value === null ? "—" : String(value);
-}
-
export function formatDay(timestamp: string): string {
const ms = Date.parse(
// SQLite's current_timestamp default has no timezone marker; treat it as
diff --git a/src/client/features/dashboard/siteTabParts.tsx b/src/client/features/dashboard/siteTabParts.tsx
new file mode 100644
index 00000000..35a337e3
--- /dev/null
+++ b/src/client/features/dashboard/siteTabParts.tsx
@@ -0,0 +1,78 @@
+import { Popover } from "@base-ui/react/popover";
+import { Info } from "lucide-react";
+import type { ReactNode } from "react";
+import { Link } from "@tanstack/react-router";
+import { getStandardErrorMessage } from "@/client/lib/error-messages";
+import { safeHttpUrl } from "@/shared/safe-url";
+export function Freshness({
+ stale,
+ refreshError,
+}: {
+ fetchedAt: string;
+ stale: boolean;
+ refreshError: string | null;
+}) {
+ if (!stale && !refreshError) return null;
+ return (
+ <p role="status" className="text-xs text-muted-foreground">
+ Showing saved results
+ {refreshError
+ ? ` · ${getStandardErrorMessage(new Error(refreshError), "Could not update. Showing saved results.")}`
+ : ""}
+ {refreshError === "INSUFFICIENT_CREDITS" ? (
+ <Link to="/billing" className="ml-2 text-primary underline">
+ Add credits
+ </Link>
+ ) : null}
+ </p>
+ );
+}
+
+export function ExternalPage({
+ url,
+ label,
+}: {
+ url: string | null;
+ label?: string | null;
+}) {
+ const href = safeHttpUrl(url);
+ return href ? (
+ <a
+ className="block max-w-80 truncate text-primary hover:underline"
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ title={url ?? undefined}
+ >
+ {label || url}
+ </a>
+ ) : (
+ <span>{label || "—"}</span>
+ );
+}
+
+export function DashboardInfo({
+ label,
+ children,
+}: {
+ label: string;
+ children: ReactNode;
+}) {
+ return (
+ <Popover.Root>
+ <Popover.Trigger
+ aria-label={label}
+ className="grid size-8 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
+ >
+ <Info className="size-4" />
+ </Popover.Trigger>
+ <Popover.Portal>
+ <Popover.Positioner sideOffset={8} className="z-50">
+ <Popover.Popup className="max-w-xs rounded-lg border bg-popover p-4 text-sm text-popover-foreground shadow-lg">
+ {children}
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ );
+}
diff --git a/src/client/features/domain/DomainOverviewPage.tsx b/src/client/features/domain/DomainOverviewPage.tsx
index 2481b569..122a8f52 100644
--- a/src/client/features/domain/DomainOverviewPage.tsx
+++ b/src/client/features/domain/DomainOverviewPage.tsx
@@ -29,7 +29,8 @@ import { QueryError } from "@/client/components/QueryState";
import { DomainSearchCard } from "@/client/features/domain/components/DomainSearchCard";
import { KeywordsTab } from "@/client/features/domain/components/KeywordsTab";
import { PagesTab } from "@/client/features/domain/components/PagesTab";
-import { StatTile } from "@/client/components/StatTile";
+import { HelpLabel } from "@/client/components/HelpLabel";
+import { MetricsTable } from "@/client/components/MetricsTable";
import { SearchTabStrip } from "@/client/features/search-tabs/SearchTabStrip";
import type { SearchTabInput } from "@/client/features/search-tabs/types";
import { useSearchTabNavigation } from "@/client/features/search-tabs/useSearchTabNavigation";
@@ -632,22 +633,38 @@ export function DomainOverviewPage({
</Badge>
</div>
<div className="px-4 pb-4">
- <div className="grid grid-cols-1 gap-3 rounded-lg border border-border p-3 md:grid-cols-2">
- <StatTile
- label="Estimated Organic Traffic"
- value={formatMetric(
- state.overview.organicTraffic,
- state.overview.hasData,
- )}
- hint={overviewMetricsHint}
- />
- <StatTile
- label="Organic Keywords"
- value={formatMetric(
- state.overview.organicKeywords,
- state.overview.hasData,
- )}
- hint={overviewMetricsHint}
+ <div className="w-full max-w-xl rounded-lg border border-border p-3">
+ <MetricsTable
+ rows={[
+ {
+ label: overviewMetricsHint ? (
+ <HelpLabel
+ label="Estimated organic traffic"
+ helpText={overviewMetricsHint}
+ />
+ ) : (
+ "Estimated organic traffic"
+ ),
+ value: formatMetric(
+ state.overview.organicTraffic,
+ state.overview.hasData,
+ ),
+ },
+ {
+ label: overviewMetricsHint ? (
+ <HelpLabel
+ label="Organic keywords"
+ helpText={overviewMetricsHint}
+ />
+ ) : (
+ "Organic keywords"
+ ),
+ value: formatMetric(
+ state.overview.organicKeywords,
+ state.overview.hasData,
+ ),
+ },
+ ]}
/>
</div>
</div>
diff --git a/src/client/features/domain/components/DomainOverviewLoadingState.tsx b/src/client/features/domain/components/DomainOverviewLoadingState.tsx
index e61beb81..dcaede7b 100644
--- a/src/client/features/domain/components/DomainOverviewLoadingState.tsx
+++ b/src/client/features/domain/components/DomainOverviewLoadingState.tsx
@@ -9,13 +9,8 @@ export function DomainOverviewLoadingState() {
<Skeleton className="h-6 w-48" />
</div>
<div className="px-4 pb-4">
- <div className="grid grid-cols-1 gap-3 rounded-lg border border-border p-3 md:grid-cols-2">
- {Array.from({ length: 2 }, (_, index) => (
- <div key={index} className="space-y-2">
- <Skeleton className="h-3 w-32" />
- <Skeleton className="h-7 w-24" />
- </div>
- ))}
+ <div className="w-full max-w-xl rounded-lg border border-border p-3">
+ <SkeletonTableRows rows={3} columns={2} />
</div>
</div>
<div className="px-4 pb-4">
diff --git a/src/client/features/projects/CreateProjectModal.tsx b/src/client/features/projects/CreateProjectModal.tsx
index aab9437d..1d186698 100644
--- a/src/client/features/projects/CreateProjectModal.tsx
+++ b/src/client/features/projects/CreateProjectModal.tsx
@@ -65,6 +65,14 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }) {
});
onClose();
toast.success("Project created");
+ if (created.initialAudit?.status === "unavailable")
+ toast.warning("Website saved. The first scan could not start.", {
+ description: getStandardErrorMessage(
+ new Error(created.initialAudit.code),
+ ),
+ });
+ else if (created.initialAudit?.status === "started")
+ toast.success("Your 50-page site scan is running");
// Continue setup through the new project’s dashboard.
void navigate({
to: "/p/$projectId",
@@ -123,6 +131,10 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }) {
)}
</form.AppField>
+ <p className="text-sm text-muted-foreground">
+ Adding your website starts a 50-page scan with JavaScript
+ rendering. Rendering uses your credits.
+ </p>
<form.AppField name="domain">
{(field) => (
<field.TextField
diff --git a/src/client/features/projects/ProjectGeneralSettings.tsx b/src/client/features/projects/ProjectGeneralSettings.tsx
index 2cb3f2f3..2eb6b9cf 100644
--- a/src/client/features/projects/ProjectGeneralSettings.tsx
+++ b/src/client/features/projects/ProjectGeneralSettings.tsx
@@ -1,3 +1,4 @@
+import { getStandardErrorMessage } from "@/client/lib/error-messages";
import { projectsQueryOptions } from "@/client/features/projects/projectQueries";
import { useNavigate } from "@tanstack/react-router";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
@@ -60,11 +61,25 @@ function GeneralSection({ project }: { project: ProjectSummary }) {
...values.market,
},
}),
- onSuccess: async () => {
+ onSuccess: async (saved) => {
await queryClient.invalidateQueries({
queryKey: projectsQueryOptions().queryKey,
});
+ await queryClient.invalidateQueries({
+ queryKey: ["dashboardActivation", project.id],
+ });
+ await queryClient.invalidateQueries({
+ queryKey: ["dashboardOverview", project.id],
+ });
toast.success("Project updated");
+ if (saved.initialAudit?.status === "unavailable")
+ toast.warning("Website saved. The first scan could not start.", {
+ description: getStandardErrorMessage(
+ new Error(saved.initialAudit.code),
+ ),
+ });
+ else if (saved.initialAudit?.status === "started")
+ toast.success("Your 50-page site scan is running");
},
});
@@ -99,6 +114,10 @@ function GeneralSection({ project }: { project: ProjectSummary }) {
)}
</form.AppField>
+ <p className="text-sm text-muted-foreground">
+ Adding your website starts a 50-page scan with JavaScript rendering.
+ Rendering uses your credits.
+ </p>
<form.AppField name="domain">
{(field) => (
<field.TextField
diff --git a/src/client/features/search-performance/SearchPerformanceLoadingState.tsx b/src/client/features/search-performance/SearchPerformanceLoadingState.tsx
index 469e9053..5f7a2de7 100644
--- a/src/client/features/search-performance/SearchPerformanceLoadingState.tsx
+++ b/src/client/features/search-performance/SearchPerformanceLoadingState.tsx
@@ -1,17 +1,16 @@
-import {
- SkeletonStatGrid,
- SkeletonTableRows,
-} from "@/client/components/SkeletonPresets";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
import { Skeleton } from "@/client/components/ui/skeleton";
// Skeleton loading state for the Search Performance (GSC) page. Mirrors the
-// loaded layout — four totals cards over a tabbed table panel — so the shell
+// loaded layout — a compact totals table over a tabbed table panel — so the shell
// stays put and only the data fills in, matching the other pages' loaders
// (e.g. DomainOverviewLoadingState, KeywordResearchLoadingState).
export function SearchPerformanceLoadingState() {
return (
<div className="space-y-4" aria-busy>
- <SkeletonStatGrid />
+ <div className="w-full max-w-xl rounded-xl border border-border bg-card p-4">
+ <SkeletonTableRows rows={5} columns={3} />
+ </div>
<div className="overflow-hidden rounded-xl border border-border bg-card">
<div className="flex flex-col gap-3 border-b border-border px-4 py-3 lg:flex-row lg:items-center lg:justify-between">
diff --git a/src/client/features/search-performance/SearchPerformancePage.tsx b/src/client/features/search-performance/SearchPerformancePage.tsx
index bf281480..ebe3768b 100644
--- a/src/client/features/search-performance/SearchPerformancePage.tsx
+++ b/src/client/features/search-performance/SearchPerformancePage.tsx
@@ -30,7 +30,7 @@ import {
exportDimensionRows,
exportStriking,
StrikingDistanceTable,
- TotalsCards,
+ TotalsTable,
type ExportTarget,
} from "@/client/features/search-performance/SearchPerformanceParts";
import { getStandardErrorMessage } from "@/client/lib/error-messages";
@@ -253,7 +253,7 @@ export function SearchPerformancePage({
{reportQuery.isPlaceholderData ? (
<SearchPerformanceLoadingState />
) : (
- <TotalsCards report={report} />
+ <TotalsTable report={report} />
)}
<div className="overflow-hidden rounded-xl border border-border bg-card">
<DataTableTabs
diff --git a/src/client/features/search-performance/SearchPerformanceParts.tsx b/src/client/features/search-performance/SearchPerformanceParts.tsx
index 09e24d73..722593e9 100644
--- a/src/client/features/search-performance/SearchPerformanceParts.tsx
+++ b/src/client/features/search-performance/SearchPerformanceParts.tsx
@@ -13,7 +13,14 @@ import {
} from "@/client/components/table/TableBulkActionBar";
import { TablePagination } from "@/client/components/table/TablePagination";
import { Button } from "@/client/components/ui/button";
-import { Card } from "@/client/components/ui/card";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@/client/components/ui/table";
import {
buildDimensionColumns,
buildStrikingColumns,
@@ -122,70 +129,62 @@ function positionDelta(current: number, previous: number): Delta {
};
}
-export function TotalsCards({ report }: { report: Report }) {
+export function TotalsTable({ report }: { report: Report }) {
const { totals, prevTotals, range } = report;
- const deltaTitle = `vs ${range.prevStartDate} to ${range.prevEndDate}`;
+ const deltaTitle = `Compared with ${range.prevStartDate} to ${range.prevEndDate}`;
+ const metrics = [
+ {
+ label: "Clicks",
+ value: formatCount(totals.clicks),
+ delta: percentDelta(totals.clicks, prevTotals.clicks),
+ },
+ {
+ label: "Impressions",
+ value: formatCount(totals.impressions),
+ delta: percentDelta(totals.impressions, prevTotals.impressions),
+ },
+ {
+ label: "Click-through rate",
+ value: formatCtr(totals.ctr),
+ delta: percentDelta(totals.ctr, prevTotals.ctr),
+ },
+ {
+ label: "Average position",
+ value: formatPosition(totals.position),
+ delta: positionDelta(totals.position, prevTotals.position),
+ },
+ ];
return (
- <div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
- <TotalCard
- label="Clicks"
- value={formatCount(totals.clicks)}
- delta={percentDelta(totals.clicks, prevTotals.clicks)}
- deltaTitle={deltaTitle}
- />
- <TotalCard
- label="Impressions"
- value={formatCount(totals.impressions)}
- delta={percentDelta(totals.impressions, prevTotals.impressions)}
- deltaTitle={deltaTitle}
- />
- <TotalCard
- label="CTR"
- value={formatCtr(totals.ctr)}
- delta={percentDelta(totals.ctr, prevTotals.ctr)}
- deltaTitle={deltaTitle}
- />
- <TotalCard
- label="Avg position"
- value={formatPosition(totals.position)}
- delta={positionDelta(totals.position, prevTotals.position)}
- deltaTitle={deltaTitle}
- />
+ <div className="w-full max-w-xl rounded-xl border border-border bg-card p-4">
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Metric</TableHead>
+ <TableHead className="text-right">Value</TableHead>
+ <TableHead className="text-right" title={deltaTitle}>
+ Change
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {metrics.map(({ label, value, delta }) => (
+ <TableRow key={label}>
+ <TableCell>{label}</TableCell>
+ <TableCell className="text-right tabular-nums">{value}</TableCell>
+ <TableCell
+ className={`text-right tabular-nums ${delta ? (delta.improved ? "text-success" : "text-destructive") : "text-muted-foreground"}`}
+ title={deltaTitle}
+ >
+ {delta?.text ?? "—"}
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</div>
);
}
-function TotalCard({
- label,
- value,
- delta,
- deltaTitle,
-}: {
- label: string;
- value: string;
- delta: Delta;
- deltaTitle: string;
-}) {
- return (
- <Card className="gap-0 p-4">
- <div className="text-xs uppercase tracking-wide text-muted-foreground">
- {label}
- </div>
- <div className="mt-1 flex items-baseline gap-2">
- <span className="text-2xl font-semibold">{value}</span>
- {delta ? (
- <span
- className={`text-xs ${delta.improved ? "text-success" : "text-destructive"}`}
- title={deltaTitle}
- >
- {delta.text}
- </span>
- ) : null}
- </div>
- </Card>
- );
-}
-
export function DimensionTable({
rows,
keyLabel,
diff --git a/src/client/lib/error-messages.ts b/src/client/lib/error-messages.ts
index b58264b1..940f8c1c 100644
--- a/src/client/lib/error-messages.ts
+++ b/src/client/lib/error-messages.ts
@@ -9,6 +9,8 @@ const STANDARD_MESSAGES: Record<ErrorCode, string> = {
"An active hosted subscription is required before you can use OpenSEO.",
INSUFFICIENT_CREDITS:
"You don't have enough credits for this. Upgrade your plan or buy more credits to keep going.",
+ AUDIT_RENDERING_UNAVAILABLE:
+ "JavaScript rendering is not configured on this deployment. Ask your administrator to enable a renderer.",
FORBIDDEN: "You do not have access to this resource.",
NOT_FOUND: "The requested resource was not found.",
AUDIT_CAPACITY_REACHED:
diff --git a/src/db/app.schema.ts b/src/db/app.schema.ts
index 9867d8a0..8a34d173 100644
--- a/src/db/app.schema.ts
+++ b/src/db/app.schema.ts
@@ -1,3 +1,4 @@
+/* eslint-disable max-lines -- application table declarations */
import {
sqliteTable,
text,
@@ -403,11 +404,8 @@ export const projectActivationState = sqliteTable("project_activation_state", {
.default(sql`(current_timestamp)`),
});
-// Point-in-time backlink profile summaries for the project's own domain,
-// written by the dashboard's visit-triggered refresh. DataForSEO's summary
-// already carries new/lost counts, so one snapshot renders a full card;
-// rows accumulate into history for future trend views. The domain is stored
-// per row so a later project-domain change doesn't rewrite history.
+// Retained backlink profile history. The dashboard no longer writes snapshots.
+// Each row keeps its original domain when the project website changes.
export const backlinkSnapshots = sqliteTable(
"backlink_snapshots",
{
@@ -486,3 +484,5 @@ export const crawlerCredentials = sqliteTable(
),
],
);
+
+export { dataRefreshClaims } from "./dashboard.schema";
diff --git a/src/db/dashboard.schema.ts b/src/db/dashboard.schema.ts
new file mode 100644
index 00000000..11cfc6f0
--- /dev/null
+++ b/src/db/dashboard.schema.ts
@@ -0,0 +1,11 @@
+import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
+import { organization } from "./better-auth-schema";
+
+export const dataRefreshClaims = sqliteTable("data_refresh_claims", {
+ key: text("key").primaryKey(),
+ organizationId: text("organization_id")
+ .notNull()
+ .references(() => organization.id, { onDelete: "cascade" }),
+ token: text("token").notNull(),
+ nextAttemptAt: integer("next_attempt_at").notNull(),
+});
diff --git a/src/db/pg/app.schema.ts b/src/db/pg/app.schema.ts
index 2073c97a..2f0b19a7 100644
--- a/src/db/pg/app.schema.ts
+++ b/src/db/pg/app.schema.ts
@@ -391,11 +391,8 @@ export const projectActivationState = pgTable("project_activation_state", {
updatedAt: timestampColumn("updated_at").notNull().default(isoNow),
});
-// Point-in-time backlink profile summaries for the project's own domain,
-// written by the dashboard's visit-triggered refresh. DataForSEO's summary
-// already carries new/lost counts, so one snapshot renders a full card;
-// rows accumulate into history for future trend views. The domain is stored
-// per row so a later project-domain change doesn't rewrite history.
+// Retained backlink profile history. The dashboard no longer writes snapshots.
+// Each row keeps its original domain when the project website changes.
export const backlinkSnapshots = pgTable(
"backlink_snapshots",
{
@@ -470,3 +467,6 @@ export const crawlerCredentials = pgTable(
),
],
);
+
+// Cross-request refresh claims survive Worker instances and prevent duplicate spend.
+export { dataRefreshClaims } from "./dashboard.schema";
diff --git a/src/db/pg/dashboard.schema.ts b/src/db/pg/dashboard.schema.ts
new file mode 100644
index 00000000..223ba0a5
--- /dev/null
+++ b/src/db/pg/dashboard.schema.ts
@@ -0,0 +1,11 @@
+import { pgTable, text, bigint } from "drizzle-orm/pg-core";
+import { organization } from "./better-auth-schema";
+
+export const dataRefreshClaims = pgTable("data_refresh_claims", {
+ key: text("key").primaryKey(),
+ organizationId: text("organization_id")
+ .notNull()
+ .references(() => organization.id, { onDelete: "cascade" }),
+ token: text("token").notNull(),
+ nextAttemptAt: bigint("next_attempt_at", { mode: "number" }).notNull(),
+});
diff --git a/src/db/schema.ts b/src/db/schema.ts
index 0507d2bf..f95a9d6d 100644
--- a/src/db/schema.ts
+++ b/src/db/schema.ts
@@ -96,6 +96,7 @@ export const {
projectActivationState,
dashboardStepDismissals,
backlinkSnapshots,
+ dataRefreshClaims,
crawlerCredentials,
projectContextSections,
projectCompetitors,
diff --git a/src/routes/_app/p/$projectId/index.tsx b/src/routes/_app/p/$projectId/index.tsx
index 8d9592bc..3fcc4b4f 100644
--- a/src/routes/_app/p/$projectId/index.tsx
+++ b/src/routes/_app/p/$projectId/index.tsx
@@ -1,11 +1,22 @@
+import { dashboardSearchSchema } from "@/types/schemas/dashboard";
import { createFileRoute } from "@tanstack/react-router";
import { DashboardPage } from "@/client/features/dashboard/DashboardPage";
export const Route = createFileRoute("/_app/p/$projectId/")({
+ validateSearch: dashboardSearchSchema,
component: DashboardRoute,
});
function DashboardRoute() {
const { projectId } = Route.useParams();
- return <DashboardPage projectId={projectId} />;
+ const search = Route.useSearch();
+ const navigate = Route.useNavigate();
+ return (
+ <DashboardPage
+ key={projectId}
+ projectId={projectId}
+ tab={search.tab}
+ onTabChange={(tab) => void navigate({ search: { tab } })}
+ />
+ );
}
diff --git a/src/server/billing/subscription.ts b/src/server/billing/subscription.ts
index f2fc6fda..43621f12 100644
--- a/src/server/billing/subscription.ts
+++ b/src/server/billing/subscription.ts
@@ -2,7 +2,6 @@
import { env } from "cloudflare:workers";
import type { EnsuredUserContext } from "@/middleware/ensure-user/types";
import {
- AUTUMN_MANAGED_ACCESS_FEATURE_ID,
AUTUMN_PAID_PLAN_FEATURE_ID,
AUTUMN_SEO_DATA_BALANCE_FEATURE_ID,
AUTUMN_SEO_DATA_TOPUP_BALANCE_FEATURE_ID,
@@ -88,15 +87,6 @@ export async function customerHasPaidPlan(
return retry.allowed;
}
-export async function customerHasManagedAccess(customerId: string) {
- const result = await autumn.check({
- customerId,
- featureId: AUTUMN_MANAGED_ACCESS_FEATURE_ID,
- });
-
- return result.allowed;
-}
-
// Remaining shared usage credits — the monthly `usage_credits` balance plus the
// rolled-over `topup_credits` balance. Both DataForSEO and LLM spend draw from
// these (the `seo_data_usage` and `llm_usage` features both map into them).
diff --git a/src/server/features/audit/services/AuditService.limitTier.test.ts b/src/server/features/audit/services/AuditService.limitTier.test.ts
index b678fa46..7b740bd4 100644
--- a/src/server/features/audit/services/AuditService.limitTier.test.ts
+++ b/src/server/features/audit/services/AuditService.limitTier.test.ts
@@ -1,23 +1,18 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
-const {
- isHostedMock,
- hasManagedAccessMock,
- hasPaidPlanMock,
- getOrCreateCustomerMock,
-} = vi.hoisted(() => ({
- isHostedMock: vi.fn(),
- hasManagedAccessMock: vi.fn(),
- hasPaidPlanMock: vi.fn(),
- getOrCreateCustomerMock: vi.fn(),
-}));
+const { isHostedMock, hasPaidPlanMock, getOrCreateCustomerMock } = vi.hoisted(
+ () => ({
+ isHostedMock: vi.fn(),
+ hasPaidPlanMock: vi.fn(),
+ getOrCreateCustomerMock: vi.fn(),
+ }),
+);
vi.mock("cloudflare:workers", () => ({ env: {} }));
vi.mock("@/server/lib/runtime-env", () => ({
isHostedServerAuthMode: isHostedMock,
}));
vi.mock("@/server/billing/subscription", () => ({
- customerHasManagedAccess: hasManagedAccessMock,
customerHasPaidPlan: hasPaidPlanMock,
getOrCreateOrganizationCustomer: getOrCreateCustomerMock,
}));
@@ -39,7 +34,6 @@ const customer = {
describe("resolveAuditLimitTier", () => {
beforeEach(() => {
- hasManagedAccessMock.mockResolvedValue(true);
hasPaidPlanMock.mockResolvedValue(true);
});
@@ -50,7 +44,6 @@ describe("resolveAuditLimitTier", () => {
"self_hosted",
);
expect(getOrCreateCustomerMock).not.toHaveBeenCalled();
- expect(hasManagedAccessMock).not.toHaveBeenCalled();
expect(hasPaidPlanMock).not.toHaveBeenCalled();
});
@@ -63,3 +56,11 @@ describe("resolveAuditLimitTier", () => {
expect(getOrCreateCustomerMock).toHaveBeenCalledWith(customer);
});
});
+
+it("allows a hosted account without a paid subscription through the free audit tier", async () => {
+ isHostedMock.mockResolvedValue(true);
+ hasPaidPlanMock.mockResolvedValue(false);
+ await expect(AuditService.resolveAuditLimitTier(customer)).resolves.toBe(
+ "free",
+ );
+});
diff --git a/src/server/features/audit/services/AuditService.rendering.test.ts b/src/server/features/audit/services/AuditService.rendering.test.ts
index 2a3e1cd2..2788017c 100644
--- a/src/server/features/audit/services/AuditService.rendering.test.ts
+++ b/src/server/features/audit/services/AuditService.rendering.test.ts
@@ -82,7 +82,7 @@ describe("rendered audit start", () => {
const error = await AuditService.startAudit(renderedAudit).catch(
(reason: unknown) => reason,
);
- expect(error).toMatchObject({ code: "FORBIDDEN" });
+ expect(error).toMatchObject({ code: "AUDIT_RENDERING_UNAVAILABLE" });
// MCP clients see this message as the tool's answer.
expect(String(error)).toContain("CONTEXT_API_KEY");
expect(mocks.lock).not.toHaveBeenCalled();
diff --git a/src/server/features/audit/services/AuditService.ts b/src/server/features/audit/services/AuditService.ts
index fa86e717..68ec6697 100644
--- a/src/server/features/audit/services/AuditService.ts
+++ b/src/server/features/audit/services/AuditService.ts
@@ -6,7 +6,6 @@ import {
} from "@/server/lib/audit/rendering-billing";
import { env } from "cloudflare:workers";
import {
- customerHasManagedAccess,
customerHasPaidPlan,
getOrCreateOrganizationCustomer,
type BillingCustomerContext,
@@ -34,25 +33,13 @@ import {
import { reconcileRunningAudit } from "@/server/features/audit/services/auditReconciler";
import { isHostedServerAuthMode } from "@/server/lib/runtime-env";
-// Plan-tier limits are the abuse bound in hosted mode: free accounts get small
-// audits with a bounded burst, paid keeps the full limits, and customers with
-// no Autumn product at all are turned away. Self-hosted isn't gated.
+// Free accounts keep bounded audit capacity; rendering reserves usage credits.
async function resolveAuditLimitTier(
customer: BillingCustomerContext,
): Promise<AuditLimitTier> {
if (!(await isHostedServerAuthMode())) return "self_hosted";
- // An org minted outside a billing path (better-auth hooks, MCP auth) has no
- // Autumn customer yet, and `check` 404s instead of reporting no access — a
- // brand-new MCP user's first audit failed with a raw billing error.
await getOrCreateOrganizationCustomer(customer);
- const [hasManagedAccess, hasPaidPlan] = await Promise.all([
- customerHasManagedAccess(customer.organizationId),
- customerHasPaidPlan(customer.organizationId),
- ]);
- if (!hasManagedAccess) {
- throw new AppError("PAYMENT_REQUIRED", "Subscribe to run site audits");
- }
- return hasPaidPlan ? "paid" : "free";
+ return (await customerHasPaidPlan(customer.organizationId)) ? "paid" : "free";
}
async function startAudit(input: {
@@ -68,7 +55,7 @@ async function startAudit(input: {
const renderJavaScript = input.renderJavaScript ?? false;
if (renderJavaScript && !(await isAuditRenderingAllowed())) {
throw new AppError(
- "FORBIDDEN",
+ "AUDIT_RENDERING_UNAVAILABLE",
"JavaScript rendering is not available on this deployment. It needs a Cloudflare deployment with Browser Run, or CONTEXT_API_KEY. Run the audit without rendering instead.",
);
}
diff --git a/src/server/features/backlinks/services/BacklinksService.billing.test.ts b/src/server/features/backlinks/services/BacklinksService.billing.test.ts
index 4842a58d..996ef7f0 100644
--- a/src/server/features/backlinks/services/BacklinksService.billing.test.ts
+++ b/src/server/features/backlinks/services/BacklinksService.billing.test.ts
@@ -241,3 +241,17 @@ it("builds subfolder overview totals from two filtered backlink counts", async (
}),
);
});
+
+it("shows the provider's last_seen timestamp in backlink results", async () => {
+ mockTarget();
+ backlinksRowsMock.mockResolvedValue({
+ items: [{ last_seen: "2026-10-06 10:00:00 +00:00" }],
+ totalCount: 1,
+ });
+ const result = await service.profileBacklinksPage(
+ { ...pageInputDefaults, target: "example.com", sortField: "rank" },
+ billingCustomer,
+ { hideSpam: false },
+ );
+ expect(result.rows[0]?.lastSeen).toBe("2026-10-06 10:00:00 +00:00");
+});
diff --git a/src/server/features/backlinks/services/backlinksRowMappers.ts b/src/server/features/backlinks/services/backlinksRowMappers.ts
index 15af56a4..055f7ce6 100644
--- a/src/server/features/backlinks/services/backlinksRowMappers.ts
+++ b/src/server/features/backlinks/services/backlinksRowMappers.ts
@@ -22,7 +22,7 @@ export function mapBacklinksRows(rows: BacklinksItem[]) {
pageFromRank: item.page_from_rank ?? null,
spamScore: item.backlink_spam_score ?? item.backlinks_spam_score ?? null,
firstSeen: item.first_seen ?? null,
- lastSeen: item.lost_date ?? item.last_visited ?? null,
+ lastSeen: item.lost_date ?? item.last_seen ?? item.last_visited ?? null,
isLost: item.is_lost ?? Boolean(item.lost_date),
isBroken: item.is_broken ?? false,
linksCount: item.links_count ?? null,
diff --git a/src/server/features/dashboard/repositories/BacklinkSnapshotRepository.ts b/src/server/features/dashboard/repositories/BacklinkSnapshotRepository.ts
deleted file mode 100644
index 977129e5..00000000
--- a/src/server/features/dashboard/repositories/BacklinkSnapshotRepository.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { desc, eq } from "drizzle-orm";
-import { db } from "@/db";
-import { backlinkSnapshots } from "@/db/schema";
-
-type BacklinkSnapshot = typeof backlinkSnapshots.$inferSelect;
-
-async function getLatestForProject(
- projectId: string,
-): Promise<BacklinkSnapshot | null> {
- const rows = await db
- .select()
- .from(backlinkSnapshots)
- .where(eq(backlinkSnapshots.projectId, projectId))
- // id, not capturedAt: autoincrement is monotonic and immune to the
- // sqlite-vs-pg timestamp text-format difference.
- .orderBy(desc(backlinkSnapshots.id))
- .limit(1);
- return rows[0] ?? null;
-}
-
-async function insert(
- values: typeof backlinkSnapshots.$inferInsert,
-): Promise<BacklinkSnapshot> {
- const [row] = await db.insert(backlinkSnapshots).values(values).returning();
- if (!row) {
- throw new Error("Failed to insert backlink_snapshot");
- }
- return row;
-}
-
-export const BacklinkSnapshotRepository = {
- getLatestForProject,
- insert,
-};
diff --git a/src/server/features/dashboard/repositories/DataRefreshClaimRepository.ts b/src/server/features/dashboard/repositories/DataRefreshClaimRepository.ts
new file mode 100644
index 00000000..6f5c9cae
--- /dev/null
+++ b/src/server/features/dashboard/repositories/DataRefreshClaimRepository.ts
@@ -0,0 +1,39 @@
+import { and, eq, lte } from "drizzle-orm";
+import { db } from "@/db";
+import { dataRefreshClaims } from "@/db/schema";
+
+// Longer than the provider's request timeout; failed requests back off rather
+// than spending again on every visit. The token fences an expired owner.
+async function claim(key: string, organizationId: string) {
+ const now = Date.now();
+ const token = crypto.randomUUID();
+ const [row] = await db
+ .insert(dataRefreshClaims)
+ .values({
+ key,
+ organizationId,
+ token,
+ nextAttemptAt: now + 180_000,
+ })
+ .onConflictDoUpdate({
+ target: dataRefreshClaims.key,
+ set: { token, nextAttemptAt: now + 180_000 },
+ setWhere: and(
+ eq(dataRefreshClaims.organizationId, organizationId),
+ lte(dataRefreshClaims.nextAttemptAt, now),
+ ),
+ })
+ .returning({ token: dataRefreshClaims.token });
+ return row?.token ?? null;
+}
+
+async function finish(key: string, token: string, delayMs: number) {
+ await db
+ .update(dataRefreshClaims)
+ .set({ nextAttemptAt: Date.now() + delayMs })
+ .where(
+ and(eq(dataRefreshClaims.key, key), eq(dataRefreshClaims.token, token)),
+ );
+}
+
+export const DataRefreshClaimRepository = { claim, finish };
diff --git a/src/server/features/dashboard/services/DashboardCacheService.test.ts b/src/server/features/dashboard/services/DashboardCacheService.test.ts
new file mode 100644
index 00000000..7794ba12
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardCacheService.test.ts
@@ -0,0 +1,190 @@
+import { DashboardFirstAuditService } from "./DashboardFirstAuditService";
+import { AppError } from "@/server/lib/errors";
+import { beforeEach, afterEach, afterAll, expect, it, vi } from "vitest";
+import { z } from "zod";
+import type * as R2Cache from "@/server/lib/r2-cache";
+import { DashboardCacheService } from "./DashboardCacheService";
+
+// Exercise the actual claim SQL: mocked ORM chains cannot prove that two
+// worker instances cannot both win the same paid refresh.
+const state = await vi.hoisted(async () => {
+ const { createClient } = await import("@libsql/client");
+ const { drizzle } = await import("drizzle-orm/libsql");
+ const client = createClient({ url: "file::memory:" });
+ await client.executeMultiple(`CREATE TABLE data_refresh_claims (
+ key TEXT PRIMARY KEY, organization_id TEXT NOT NULL,
+ token TEXT NOT NULL, next_attempt_at INTEGER NOT NULL
+ );`);
+ return {
+ client,
+ db: drizzle(client),
+ cache: new Map<string, unknown>(),
+ startAudit: vi.fn(),
+ latestAudit: vi.fn(),
+ };
+});
+vi.mock("@/server/features/audit/services/AuditService", () => ({
+ AuditService: {
+ resolveAuditLimitTier: async () => "free",
+ startAudit: state.startAudit,
+ },
+}));
+vi.mock("@/server/features/audit/repositories/AuditRepository", () => ({
+ AuditRepository: { getLatestAuditForProject: state.latestAudit },
+}));
+vi.mock("@/db", () => ({ db: state.db }));
+vi.mock("cloudflare:workers", () => ({ env: { DATABASE_PROVIDER: "d1" } }));
+vi.mock("@/server/lib/r2-cache", async (importOriginal) => ({
+ ...(await importOriginal<typeof R2Cache>()),
+ getCached: async (key: string) => state.cache.get(key) ?? null,
+ setCached: async (key: string, data: unknown) => {
+ state.cache.set(key, data);
+ },
+}));
+
+beforeEach(async () => {
+ state.cache.clear();
+ state.latestAudit.mockResolvedValue(null);
+ state.startAudit.mockResolvedValue({ auditId: "audit" });
+ await state.client.executeMultiple("DELETE FROM data_refresh_claims;");
+});
+afterEach(() => vi.useRealTimers());
+afterAll(() => state.client.close());
+
+function input(
+ load = vi.fn(async () => ["real response"]),
+ organizationId = "org-a",
+) {
+ return {
+ namespace: "dashboard:test",
+ organizationId,
+ params: { domain: "example.com" },
+ schema: z.array(z.string()),
+ maxAgeMs: 86400_000,
+ load,
+ };
+}
+
+it("allows only one paid load for simultaneous cold visits and reuses the winner's result", async () => {
+ let finish!: (value: string[]) => void;
+ let started!: () => void;
+ const loading = new Promise<void>((resolve) => {
+ started = resolve;
+ });
+ const load = vi.fn(() => {
+ started();
+ return new Promise<string[]>((resolve) => {
+ finish = resolve;
+ });
+ });
+ const first = DashboardCacheService.readThrough(input(load));
+ await loading;
+ await expect(DashboardCacheService.readThrough(input(load))).rejects.toThrow(
+ "already running",
+ );
+ finish(["result"]);
+ await first;
+ expect((await DashboardCacheService.readThrough(input(load))).value).toEqual([
+ "result",
+ ]);
+ expect(load).toHaveBeenCalledTimes(1);
+});
+
+it("caches empty results rather than billing again on every visit", async () => {
+ const load = vi.fn(async () => [] as string[]);
+ await DashboardCacheService.readThrough(input(load));
+ expect((await DashboardCacheService.readThrough(input(load))).value).toEqual(
+ [],
+ );
+ expect(load).toHaveBeenCalledTimes(1);
+});
+
+it("keeps stale results and backs off after a failed paid refresh", async () => {
+ const load = vi.fn(async () => ["saved"]);
+ await DashboardCacheService.readThrough(input(load));
+ for (const [key, value] of state.cache) {
+ const previous = z
+ .object({ value: z.array(z.string()), fetchedAt: z.string() })
+ .parse(value);
+ state.cache.set(key, {
+ ...previous,
+ fetchedAt: new Date(Date.now() - 2 * 86400_000).toISOString(),
+ });
+ }
+ load.mockRejectedValue(new Error("provider unavailable"));
+ const stale = await DashboardCacheService.readThrough(input(load));
+ expect(stale).toMatchObject({ value: ["saved"], stale: true });
+ await DashboardCacheService.readThrough(input(load));
+ expect(load).toHaveBeenCalledTimes(2);
+});
+
+it("does not share cached provider data between organizations", async () => {
+ const load = vi.fn(async () => ["a"]);
+ await DashboardCacheService.readThrough(input(load));
+ load.mockResolvedValue(["b"]);
+ expect(
+ (await DashboardCacheService.readThrough(input(load, "org-b"))).value,
+ ).toEqual(["b"]);
+ expect(load).toHaveBeenCalledTimes(2);
+});
+
+it("backs off cold failures without another provider charge", async () => {
+ const load = vi.fn(async () => {
+ throw new Error("out of credits");
+ });
+ await expect(DashboardCacheService.readThrough(input(load))).rejects.toThrow(
+ "out of credits",
+ );
+ await expect(DashboardCacheService.readThrough(input(load))).rejects.toThrow(
+ "temporarily paused",
+ );
+ expect(load).toHaveBeenCalledTimes(1);
+});
+
+const customer = {
+ organizationId: "org",
+ userId: "user",
+ userEmail: "[email protected]",
+};
+it("starts only one rendered 50-page audit for simultaneous website saves", async () => {
+ let finish!: () => void;
+ let started!: () => void;
+ const loading = new Promise<void>((resolve) => {
+ started = resolve;
+ });
+ state.startAudit.mockImplementation(() => {
+ started();
+ return new Promise<void>((resolve) => {
+ finish = resolve;
+ });
+ });
+ const first = DashboardFirstAuditService.start(
+ "project",
+ "example.com",
+ customer,
+ );
+ await loading;
+ expect(
+ await DashboardFirstAuditService.start("project", "example.com", customer),
+ ).toMatchObject({ status: "pending" });
+ finish();
+ expect(await first).toMatchObject({ status: "started" });
+ await DashboardFirstAuditService.start("project", "example.com", customer);
+ expect(state.startAudit).toHaveBeenCalledTimes(1);
+ expect(state.startAudit).toHaveBeenCalledWith(
+ expect.objectContaining({
+ projectId: "project",
+ maxPages: 50,
+ renderJavaScript: true,
+ billingCustomer: customer,
+ }),
+ );
+});
+it("returns a visible startup refusal and backs off instead of repeatedly attempting a billed scan", async () => {
+ state.startAudit.mockRejectedValue(new AppError("INSUFFICIENT_CREDITS"));
+ expect(
+ await DashboardFirstAuditService.start("project", "example.com", customer),
+ ).toMatchObject({ status: "unavailable", code: "INSUFFICIENT_CREDITS" });
+ await DashboardFirstAuditService.start("project", "example.com", customer);
+ expect(state.startAudit).toHaveBeenCalledTimes(1);
+});
diff --git a/src/server/features/dashboard/services/DashboardCacheService.ts b/src/server/features/dashboard/services/DashboardCacheService.ts
new file mode 100644
index 00000000..f14cfc68
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardCacheService.ts
@@ -0,0 +1,69 @@
+import { z } from "zod";
+import { buildCacheKey, getCached, setCached } from "@/server/lib/r2-cache";
+import { DataRefreshClaimRepository } from "@/server/features/dashboard/repositories/DataRefreshClaimRepository";
+import { AppError, asAppError } from "@/server/lib/errors";
+
+// Cached provider responses are disposable; keep them longer than their refresh
+// cadence so credit/provider failures can display the last successful result.
+async function readThrough<T>(input: {
+ namespace: string;
+ organizationId: string;
+ params: Record<string, unknown>;
+ schema: z.ZodType<T>;
+ maxAgeMs: number;
+ load: () => Promise<T>;
+}) {
+ const key = await buildCacheKey(input.namespace, {
+ ...input.params,
+ organizationId: input.organizationId,
+ });
+ const schema = z.object({ value: input.schema, fetchedAt: z.string() });
+ const parsed = schema.safeParse(await getCached(key));
+ const cached = parsed.success ? parsed.data : null;
+ if (cached && Date.now() - Date.parse(cached.fetchedAt) < input.maxAgeMs) {
+ return { ...cached, stale: false, refreshError: null };
+ }
+ const token = await DataRefreshClaimRepository.claim(
+ key,
+ input.organizationId,
+ );
+ if (!token) {
+ if (cached)
+ return {
+ ...cached,
+ stale: true,
+ refreshError: "Update already running or temporarily paused.",
+ };
+ throw new AppError(
+ "RATE_LIMITED",
+ "An update is already running or temporarily paused. Try again shortly.",
+ );
+ }
+ try {
+ // Recheck after winning the claim: a preceding request may have completed
+ // between the initial cache read and this database write.
+ const latest = schema.safeParse(await getCached(key));
+ if (
+ latest.success &&
+ Date.now() - Date.parse(latest.data.fetchedAt) < input.maxAgeMs
+ ) {
+ await DataRefreshClaimRepository.finish(key, token, 0);
+ return { ...latest.data, stale: false, refreshError: null };
+ }
+ const value = input.schema.parse(await input.load());
+ const result = { value, fetchedAt: new Date().toISOString() };
+ await setCached(key, result, 90 * 86400);
+ await DataRefreshClaimRepository.finish(key, token, 0);
+ return { ...result, stale: false, refreshError: null };
+ } catch (error) {
+ await DataRefreshClaimRepository.finish(key, token, 5 * 60_000);
+ if (!cached) throw error;
+ return {
+ ...cached,
+ stale: true,
+ refreshError: asAppError(error)?.code ?? "UPSTREAM_UNAVAILABLE",
+ };
+ }
+}
+
+export const DashboardCacheService = { readThrough };
diff --git a/src/server/features/dashboard/services/DashboardFirstAuditService.ts b/src/server/features/dashboard/services/DashboardFirstAuditService.ts
new file mode 100644
index 00000000..55bfd815
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardFirstAuditService.ts
@@ -0,0 +1,78 @@
+import { shouldCaptureAppErrorCode } from "@/shared/error-codes";
+import { AuditService } from "@/server/features/audit/services/AuditService";
+import { AuditRepository } from "@/server/features/audit/repositories/AuditRepository";
+import { DataRefreshClaimRepository } from "../repositories/DataRefreshClaimRepository";
+import { buildCacheKey } from "@/server/lib/r2-cache";
+import { asAppError } from "@/server/lib/errors";
+import type { BillingCustomerContext } from "@/server/billing/subscription";
+
+async function start(
+ projectId: string,
+ domain: string | null,
+ customer: BillingCustomerContext,
+) {
+ let key: string | null = null;
+ let token: string | null = null;
+ let auditStarted = false;
+ try {
+ if (!domain || (await AuditRepository.getLatestAuditForProject(projectId)))
+ return null;
+ key = await buildCacheKey("dashboard:first-audit", {
+ projectId,
+ organizationId: customer.organizationId,
+ });
+ token = await DataRefreshClaimRepository.claim(
+ key,
+ customer.organizationId,
+ );
+ if (!token) return { status: "pending" as const };
+ // Close the gap between the first read and the claim, including manual scans.
+ if (await AuditRepository.getLatestAuditForProject(projectId)) {
+ await DataRefreshClaimRepository.finish(
+ key,
+ token,
+ 100 * 365 * 86400_000,
+ );
+ return null;
+ }
+ const limitTier = await AuditService.resolveAuditLimitTier(customer);
+ await AuditService.startAudit({
+ actorUserId: customer.userId,
+ billingCustomer: customer,
+ projectId,
+ startUrl: `https://${domain}`,
+ maxPages: 50,
+ renderJavaScript: true,
+ lighthouseStrategy: "auto",
+ limitTier,
+ });
+ auditStarted = true;
+ await DataRefreshClaimRepository.finish(key, token, 100 * 365 * 86400_000);
+ return { status: "started" as const };
+ } catch (error) {
+ if (key && token)
+ await DataRefreshClaimRepository.finish(key, token, 5 * 60_000).catch(
+ (failure) =>
+ console.error(
+ "dashboard:first-audit claim release failed",
+ { projectId },
+ failure,
+ ),
+ );
+ const code = asAppError(error)?.code ?? "INTERNAL_ERROR";
+ if (shouldCaptureAppErrorCode(code))
+ console.error(
+ "dashboard:first-audit startup failed",
+ { projectId, code },
+ error,
+ );
+ else
+ console.info("dashboard:first-audit could not start", {
+ projectId,
+ code,
+ });
+ if (auditStarted) return { status: "started" as const };
+ return { status: "unavailable" as const, code };
+ }
+}
+export const DashboardFirstAuditService = { start };
diff --git a/src/server/features/dashboard/services/DashboardService.test.ts b/src/server/features/dashboard/services/DashboardService.test.ts
new file mode 100644
index 00000000..585ad049
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardService.test.ts
@@ -0,0 +1,67 @@
+import { beforeEach, expect, it, vi } from "vitest";
+import { DashboardService } from "./DashboardService";
+
+const repository = vi.hoisted(() => ({
+ audits: vi.fn(),
+ latestAudit: vi.fn(),
+ issues: vi.fn(),
+}));
+vi.mock("@/server/features/projects/repositories/ProjectRepository", () => ({
+ ProjectRepository: {},
+}));
+vi.mock(
+ "@/server/features/activation/repositories/ActivationRepository",
+ () => ({ ActivationRepository: {} }),
+);
+vi.mock("@/server/features/ga4/repositories/Ga4ConnectionRepository", () => ({
+ Ga4ConnectionRepository: {},
+}));
+vi.mock("@/server/features/gsc/repositories/GscConnectionRepository", () => ({
+ GscConnectionRepository: {},
+}));
+vi.mock("@/server/features/audit/repositories/AuditRepository", () => ({
+ AuditRepository: {
+ getAuditsByProject: repository.audits,
+ getLatestAuditForProject: repository.latestAudit,
+ },
+}));
+vi.mock("@/server/features/audit/repositories/auditSummaryQueries", () => ({
+ getIssueTypePageCountsForAudit: repository.issues,
+}));
+
+const ownAudit = {
+ id: "own-site",
+ startUrl: "https://www.example.com/about",
+ status: "completed",
+ pagesCrawled: 50,
+ startedAt: "2026-10-01T00:00:00Z",
+};
+const competitor = {
+ ...ownAudit,
+ id: "competitor",
+ startUrl: "https://example.com.other.net/",
+};
+
+beforeEach(() => {
+ repository.audits.mockResolvedValue([competitor, ownAudit]);
+ repository.latestAudit.mockResolvedValue(competitor);
+ repository.issues.mockResolvedValue([]);
+});
+
+it("shows the newest audit matching the saved website instead of a newer competitor audit", async () => {
+ const result = await DashboardService.getOverview({
+ projectId: "project",
+ domain: "example.com",
+ });
+ expect(result.audit?.id).toBe("own-site");
+});
+
+it.each([null, "other.example.com", "example.net"])(
+ "shows no audit when the saved website is %s",
+ async (domain) => {
+ expect(
+ await DashboardService.getOverview({ projectId: "project", domain }),
+ ).toEqual({ audit: null });
+ expect(repository.issues).not.toHaveBeenCalled();
+ },
+);
diff --git a/src/server/features/dashboard/services/DashboardService.ts b/src/server/features/dashboard/services/DashboardService.ts
index f7806d38..b6da79d9 100644
--- a/src/server/features/dashboard/services/DashboardService.ts
+++ b/src/server/features/dashboard/services/DashboardService.ts
@@ -1,22 +1,11 @@
import { ProjectRepository } from "@/server/features/projects/repositories/ProjectRepository";
import { sort } from "remeda";
-import type { BillingCustomerContext } from "@/server/billing/subscription";
+import { safeHostname } from "@/shared/safe-url";
import { ActivationRepository } from "@/server/features/activation/repositories/ActivationRepository";
import { AuditRepository } from "@/server/features/audit/repositories/AuditRepository";
import { getIssueTypePageCountsForAudit } from "@/server/features/audit/repositories/auditSummaryQueries";
-import { BacklinkSnapshotRepository } from "@/server/features/dashboard/repositories/BacklinkSnapshotRepository";
import { Ga4ConnectionRepository } from "@/server/features/ga4/repositories/Ga4ConnectionRepository";
import { GscConnectionRepository } from "@/server/features/gsc/repositories/GscConnectionRepository";
-import {
- createDataforseoClient,
- normalizeBacklinksTarget,
-} from "@/server/lib/dataforseo";
-import { asAppError } from "@/server/lib/errors";
-import { shouldCaptureAppErrorCode } from "@/shared/error-codes";
-
-// Daily cadence: fresh numbers each visit without per-visit spend; a dormant
-// project costs nothing because refreshes are visit-triggered.
-const SNAPSHOT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
export type DashboardActivation = {
domain: string | null;
@@ -40,6 +29,7 @@ export type DashboardActivation = {
};
export type DashboardAuditSummary = {
+ id: string;
status: "running" | "completed" | "failed";
pagesCrawled: number;
startedAt: string;
@@ -49,26 +39,9 @@ export type DashboardAuditSummary = {
severity: "critical" | "warning" | "info";
count: number;
}[];
- totalIssueTypes: number;
-};
-
-export type DashboardBacklinkSummary = {
- domain: string;
- rank: number | null;
- backlinks: number | null;
- referringDomains: number | null;
- newBacklinks: number | null;
- lostBacklinks: number | null;
- newReferringDomains: number | null;
- lostReferringDomains: number | null;
- capturedAt: string;
- stale: boolean;
};
-type DashboardOverview = {
- audit: DashboardAuditSummary | null;
- backlinks: DashboardBacklinkSummary | null;
-};
+type DashboardOverview = { audit: DashboardAuditSummary | null };
async function getActivation(input: {
userId: string;
@@ -122,17 +95,20 @@ async function getOverview(input: {
projectId: string;
domain: string | null;
}): Promise<DashboardOverview> {
- const [audit, backlinks] = await Promise.all([
- getAuditSummary(input.projectId),
- getBacklinkSummary(input.projectId, input.domain),
- ]);
- return { audit, backlinks };
+ return { audit: await getAuditSummary(input.projectId, input.domain) };
}
async function getAuditSummary(
projectId: string,
+ domain: string | null,
): Promise<DashboardAuditSummary | null> {
- const audit = await AuditRepository.getLatestAuditForProject(projectId);
+ const hostname = domain ? safeHostname(`https://${domain}`) : null;
+ if (!hostname) return null;
+
+ const audits = await AuditRepository.getAuditsByProject(projectId);
+ const audit = audits.find(
+ (candidate) => safeHostname(candidate.startUrl) === hostname,
+ );
if (!audit) return null;
const typeRows = await getIssueTypePageCountsForAudit(audit.id);
@@ -149,120 +125,16 @@ async function getAuditSummary(
);
return {
+ id: audit.id,
status: audit.status,
pagesCrawled: audit.pagesCrawled,
startedAt: audit.startedAt,
topIssues: sorted.slice(0, 3),
- totalIssueTypes: sorted.length,
- };
-}
-
-function isSnapshotFresh(capturedAt: string): boolean {
- const capturedMs = Date.parse(capturedAt);
- if (Number.isNaN(capturedMs)) return false;
- return Date.now() - capturedMs < SNAPSHOT_MAX_AGE_MS;
-}
-
-async function getBacklinkSummary(
- projectId: string,
- domain: string | null,
-): Promise<DashboardBacklinkSummary | null> {
- if (!domain) return null;
- const snapshot =
- await BacklinkSnapshotRepository.getLatestForProject(projectId);
- if (!snapshot || snapshot.domain !== domain) return null;
- return {
- domain: snapshot.domain,
- rank: snapshot.rank,
- backlinks: snapshot.backlinks,
- referringDomains: snapshot.referringDomains,
- newBacklinks: snapshot.newBacklinks,
- lostBacklinks: snapshot.lostBacklinks,
- newReferringDomains: snapshot.newReferringDomains,
- lostReferringDomains: snapshot.lostReferringDomains,
- capturedAt: snapshot.capturedAt,
- stale: !isSnapshotFresh(snapshot.capturedAt),
};
}
-/**
- * Visit-triggered snapshot refresh. Fetches only the DataForSEO backlinks
- * summary (not the history endpoint the backlinks page also pays for) and is
- * a no-op while the latest snapshot for the current domain is under a day
- * old. Concurrent loads racing the freshness check can each pay a metered
- * call — every call is metered, so the race duplicates customer spend on
- * identical data but never leaks revenue; accepted for now. On a fetch
- * failure with a stale snapshot in hand, the stale snapshot is returned
- * rather than surfacing an error card.
- */
-async function ensureBacklinkSnapshot(input: {
- projectId: string;
- domain: string | null;
- billingCustomer: BillingCustomerContext;
-}): Promise<DashboardBacklinkSummary | null> {
- const { projectId, domain } = input;
- if (!domain) return null;
-
- const latest =
- await BacklinkSnapshotRepository.getLatestForProject(projectId);
- const latestMatchesDomain = latest !== null && latest.domain === domain;
- if (latest && latestMatchesDomain && isSnapshotFresh(latest.capturedAt)) {
- return getBacklinkSummary(projectId, domain);
- }
-
- // Dashboard totals cover the whole site, subdomains included.
- const normalized = normalizeBacklinksTarget(domain, { scope: "subdomains" });
- const dataforseo = createDataforseoClient(input.billingCustomer);
-
- try {
- const summary = await dataforseo.backlinks.summary({
- target: normalized.apiTarget,
- includeSubdomains: normalized.includeSubdomains,
- });
- await BacklinkSnapshotRepository.insert({
- projectId,
- domain,
- rank: summary.rank ?? null,
- backlinks: summary.backlinks ?? null,
- referringDomains: summary.referring_domains ?? null,
- brokenBacklinks: summary.broken_backlinks ?? null,
- newBacklinks: summary.new_backlinks ?? null,
- lostBacklinks: summary.lost_backlinks ?? null,
- newReferringDomains:
- summary.new_referring_domains ?? summary.new_reffering_domains ?? null,
- lostReferringDomains:
- summary.lost_referring_domains ??
- summary.lost_reffering_domains ??
- null,
- capturedAt: new Date().toISOString(),
- });
- } catch (error) {
- if (!latestMatchesDomain) throw error;
- // Visit-triggered refresh, so an out-of-credits org re-hits this on every
- // dashboard load. Expected refusals are not failures: log them at info with
- // the code, and keep error for anything the taxonomy says is reportable.
- const code = asAppError(error)?.code;
- if (shouldCaptureAppErrorCode(code)) {
- console.error(
- "dashboard: backlink snapshot refresh failed",
- { projectId },
- error,
- );
- } else {
- console.info("dashboard: backlink snapshot refresh skipped", {
- projectId,
- code,
- });
- }
- return getBacklinkSummary(projectId, domain);
- }
-
- return getBacklinkSummary(projectId, domain);
-}
-
export const DashboardService = {
setStepDismissed: ActivationRepository.setStepDismissed,
getActivation,
getOverview,
- ensureBacklinkSnapshot,
};
diff --git a/src/server/features/dashboard/services/DashboardSiteService.test.ts b/src/server/features/dashboard/services/DashboardSiteService.test.ts
new file mode 100644
index 00000000..076744ec
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardSiteService.test.ts
@@ -0,0 +1,160 @@
+import { beforeEach, expect, it, vi } from "vitest";
+import { DashboardSiteService } from "./DashboardSiteService";
+import { GscService } from "@/server/features/gsc/services/GscService";
+import { GscConnectionRepository } from "@/server/features/gsc/repositories/GscConnectionRepository";
+
+const providers = vi.hoisted(() => ({ domains: vi.fn(), links: vi.fn() }));
+vi.mock("@/server/lib/dataforseo", async () => ({
+ ...(await import("@/server/lib/dataforseoBacklinksTarget")),
+ createDataforseoClient: () => ({
+ backlinks: { referringDomains: providers.domains, rows: providers.links },
+ }),
+}));
+vi.mock("@/server/features/gsc/repositories/GscConnectionRepository", () => ({
+ GscConnectionRepository: { getByProjectId: vi.fn() },
+}));
+vi.mock("@/server/features/gsc/services/GscService", async () => ({
+ ...(await import("@/server/lib/gscErrors")),
+ GscService: { getPerformance: vi.fn() },
+ isExpectedGrantFailure: () => false,
+}));
+vi.mock("./DashboardCacheService", () => ({
+ DashboardCacheService: {
+ readThrough: async (input: { load: () => Promise<unknown> }) => ({
+ value: await input.load(),
+ }),
+ },
+}));
+
+const performanceBase = {
+ siteUrl: "sc-domain:example.com",
+ connectedBy: null,
+ request: { startDate: "2026-09-01", endDate: "2026-10-01" },
+};
+
+beforeEach(() => {
+ providers.domains.mockResolvedValue({ items: [] });
+ providers.links.mockResolvedValue({ items: [] });
+ vi.mocked(GscConnectionRepository.getByProjectId).mockResolvedValue({
+ id: "connection",
+ projectId: "project",
+ organizationId: "org",
+ siteUrl: "sc-domain:example.com",
+ connectedByUserId: "user",
+ gscAccountId: "account",
+ connectedAccountEmail: null,
+ createdAt: "2026-10-01",
+ updatedAt: "2026-10-01",
+ });
+ vi.mocked(GscService.getPerformance).mockResolvedValue({
+ ...performanceBase,
+ rows: [],
+ });
+});
+const row = (query: string, impressions = 10) => ({
+ keys: [query],
+ clicks: 0,
+ impressions,
+ ctr: 0,
+ position: 12,
+});
+
+it("surfaces only queries above the threshold and absent from baseline data", async () => {
+ vi.mocked(GscService.getPerformance)
+ .mockResolvedValueOnce({
+ ...performanceBase,
+ rows: [row("new"), row("existing"), row("too small", 9)],
+ })
+ .mockResolvedValueOnce({ ...performanceBase, rows: [row("existing")] });
+ const result = await DashboardSiteService.getEmergingQueries(
+ "project",
+ "org",
+ );
+ expect(result.value.rows.map((item) => item.query)).toEqual(["new"]);
+});
+
+it("checks capped baseline candidates directly so omitted older queries are not called new", async () => {
+ vi.mocked(GscService.getPerformance)
+ .mockResolvedValueOnce({
+ ...performanceBase,
+ rows: [row("older low-click query"), row("new query")],
+ })
+ .mockResolvedValueOnce({
+ ...performanceBase,
+ rows: Array.from({ length: 25000 }, (_, index) =>
+ row(`baseline ${index}`),
+ ),
+ })
+ .mockResolvedValueOnce({
+ ...performanceBase,
+ rows: [row("older low-click query")],
+ })
+ .mockResolvedValueOnce({ ...performanceBase, rows: [] });
+ const result = await DashboardSiteService.getEmergingQueries(
+ "project",
+ "org",
+ );
+ expect(result.value.rows.map((item) => item.query)).toEqual(["new query"]);
+});
+
+const customer = {
+ organizationId: "org",
+ userId: "user",
+ userEmail: "[email protected]",
+};
+it("shows new referring domains without paying for a fallback backlink request", async () => {
+ providers.domains.mockResolvedValue({
+ items: [{ domain: "new.example", backlinks: 2 }],
+ });
+ const result = await DashboardSiteService.getLinkActivity(
+ "example.com",
+ customer,
+ );
+ expect(result).toMatchObject({
+ kind: "domains",
+ value: [{ domain: "new.example", backlinks: 2 }],
+ });
+ expect(providers.links).not.toHaveBeenCalled();
+});
+it("falls back to new backlinks when there are no new referring domains", async () => {
+ providers.links.mockResolvedValue({
+ items: [{ url_from: "https://existing.example/new-page" }],
+ });
+ const result = await DashboardSiteService.getLinkActivity(
+ "example.com",
+ customer,
+ );
+ expect(result).toMatchObject({
+ kind: "links",
+ links: [{ urlFrom: "https://existing.example/new-page" }],
+ });
+});
+
+it("finds new queries beyond Google's default first page", async () => {
+ vi.mocked(GscService.getPerformance).mockImplementationOnce(
+ async (input) => ({
+ ...performanceBase,
+ rows: input.rowLimit === 25000 ? [row("new zero-click query")] : [],
+ }),
+ );
+ const result = await DashboardSiteService.getEmergingQueries(
+ "project",
+ "org",
+ );
+ expect(result.value.rows.map((item) => item.query)).toEqual([
+ "new zero-click query",
+ ]);
+});
+
+it("lists the site's Search Console keywords with Google's position, without a provider request", async () => {
+ vi.mocked(GscService.getPerformance).mockResolvedValue({
+ ...performanceBase,
+ rows: [row("existing keyword", 123)],
+ });
+ const result = await DashboardSiteService.getKeywords("project", "org");
+ expect(result.value.rows).toEqual([
+ { query: "existing keyword", clicks: 0, impressions: 123, position: 12 },
+ ]);
+ expect(providers.domains).not.toHaveBeenCalled();
+ expect(providers.links).not.toHaveBeenCalled();
+});
diff --git a/src/server/features/dashboard/services/DashboardSiteService.ts b/src/server/features/dashboard/services/DashboardSiteService.ts
new file mode 100644
index 00000000..66a80b18
--- /dev/null
+++ b/src/server/features/dashboard/services/DashboardSiteService.ts
@@ -0,0 +1,332 @@
+import { sort } from "remeda";
+import { z } from "zod";
+import type { BillingCustomerContext } from "@/server/billing/subscription";
+import { DashboardCacheService } from "./DashboardCacheService";
+import {
+ createDataforseoClient,
+ normalizeBacklinksTarget,
+} from "@/server/lib/dataforseo";
+import { mapBacklinksRows } from "@/server/features/backlinks/services/backlinksRowMappers";
+import {
+ referringDomainItemSchema,
+ backlinksItemSchema,
+} from "@/server/lib/dataforseo/backlinks";
+import {
+ GscService,
+ isExpectedGrantFailure,
+ GscNotConnectedError,
+} from "@/server/features/gsc/services/GscService";
+import { GscConnectionRepository } from "@/server/features/gsc/repositories/GscConnectionRepository";
+import { resolveDateRange } from "@/server/features/gsc/searchAnalytics";
+
+const querySchema = z.object({
+ query: z.string(),
+ clicks: z.number(),
+ impressions: z.number(),
+ position: z.number(),
+});
+const queriesSchema = z.object({
+ connected: z.boolean(),
+ hasSearchData: z.boolean(),
+ rows: z.array(querySchema),
+ startDate: z.string(),
+ endDate: z.string(),
+ baselineStartDate: z.string(),
+});
+
+async function getBacklinks(
+ input: { domain: string; kind: "new" | "lost" | "all" },
+ billingCustomer: BillingCustomerContext,
+) {
+ const result = await DashboardCacheService.readThrough({
+ namespace: "dashboard:links",
+ organizationId: billingCustomer.organizationId,
+ params: input,
+ schema: z.array(backlinksItemSchema),
+ maxAgeMs: 86400_000,
+ load: async () => {
+ const target = normalizeBacklinksTarget(input.domain, {
+ scope: "subdomains",
+ });
+ const from = new Date(Date.now() - 7 * 86400_000)
+ .toISOString()
+ .slice(0, 10);
+ const response = await createDataforseoClient(
+ billingCustomer,
+ ).backlinks.rows({
+ target: target.apiTarget,
+ includeSubdomains: true,
+ limit: 25,
+ mode: "one_per_domain",
+ status: input.kind === "lost" ? "lost" : "live",
+ hideSpam: false,
+ orderBy: [input.kind === "lost" ? "last_seen,desc" : "first_seen,desc"],
+ filters:
+ input.kind === "all"
+ ? undefined
+ : [
+ [
+ input.kind === "lost" ? "last_seen" : "first_seen",
+ ">=",
+ `${from} 00:00:00 +00:00`,
+ ],
+ ],
+ });
+ return response.items;
+ },
+ });
+ return { ...result, value: mapBacklinksRows(result.value) };
+}
+
+async function getKeywords(projectId: string, organizationId: string) {
+ const { startDate, endDate } = resolveDateRange({
+ dateRange: "last_28_days",
+ });
+ const connection = await GscConnectionRepository.getByProjectId(projectId);
+ if (!connection)
+ return {
+ value: { connected: false, rows: [], startDate, endDate },
+ fetchedAt: new Date().toISOString(),
+ stale: false,
+ refreshError: null,
+ };
+ return DashboardCacheService.readThrough({
+ namespace: "dashboard:gsc-keywords-v2",
+ organizationId,
+ params: {
+ projectId,
+ siteUrl: connection.siteUrl,
+ accountId: connection.gscAccountId,
+ updatedAt: connection.updatedAt,
+ },
+ schema: z.object({
+ connected: z.boolean(),
+ rows: z.array(querySchema),
+ startDate: z.string(),
+ endDate: z.string(),
+ }),
+ maxAgeMs: 86400_000,
+ load: async () => {
+ try {
+ const result = await GscService.getPerformance({
+ projectId,
+ startDate,
+ endDate,
+ dimensions: ["query"],
+ rowLimit: 25000,
+ dataState: "final",
+ });
+ return {
+ connected: true,
+ rows: result.rows
+ .filter((row) => row.keys?.[0])
+ .map((row) => ({
+ query: row.keys![0],
+ clicks: row.clicks,
+ impressions: row.impressions,
+ position: row.position,
+ })),
+ startDate,
+ endDate,
+ };
+ } catch (error) {
+ if (
+ error instanceof GscNotConnectedError ||
+ isExpectedGrantFailure(error)
+ )
+ return { connected: false, rows: [], startDate, endDate };
+ throw error;
+ }
+ },
+ });
+}
+
+async function getEmergingQueries(projectId: string, organizationId: string) {
+ const { endDate } = resolveDateRange({ dateRange: "last_7_days" });
+ const startDate = new Date(Date.parse(endDate) - 6 * 86400_000)
+ .toISOString()
+ .slice(0, 10);
+ const baselineEndDate = new Date(Date.parse(startDate) - 86400_000)
+ .toISOString()
+ .slice(0, 10);
+ const baselineStartDate = new Date(Date.parse(startDate) - 28 * 86400_000)
+ .toISOString()
+ .slice(0, 10);
+ const connection = await GscConnectionRepository.getByProjectId(projectId);
+ if (!connection) {
+ return {
+ value: {
+ connected: false,
+ hasSearchData: false,
+ rows: [],
+ startDate,
+ endDate,
+ baselineStartDate,
+ },
+ fetchedAt: new Date().toISOString(),
+ stale: false,
+ refreshError: null,
+ };
+ }
+ return DashboardCacheService.readThrough({
+ namespace: "dashboard:emerging-queries",
+ organizationId,
+ params: {
+ projectId,
+ siteUrl: connection.siteUrl,
+ accountId: connection.gscAccountId,
+ updatedAt: connection.updatedAt,
+ comparison: "verified-v3",
+ },
+ schema: queriesSchema,
+ maxAgeMs: 86400_000,
+ load: async () => {
+ try {
+ const [recent, baseline] = await Promise.all([
+ GscService.getPerformance({
+ projectId,
+ startDate,
+ endDate,
+ dimensions: ["query"],
+ rowLimit: 25000,
+ dataState: "final",
+ }),
+ GscService.getPerformance({
+ projectId,
+ startDate: baselineStartDate,
+ endDate: baselineEndDate,
+ dimensions: ["query"],
+ rowLimit: 25000,
+ dataState: "final",
+ }),
+ ]);
+ const seen = new Set(baseline.rows.map((row) => row.keys?.[0]));
+ const observed = recent.rows
+ .filter(
+ (row) =>
+ row.keys?.[0] && row.impressions >= 10 && !seen.has(row.keys[0]),
+ )
+ .map((row) => ({
+ query: row.keys![0],
+ clicks: row.clicks,
+ impressions: row.impressions,
+ position: row.position,
+ }));
+ const rows = sort(
+ observed,
+ (a, b) => b.impressions - a.impressions,
+ ).slice(0, 25);
+ // A full baseline page may omit older low-click queries. Verify each
+ // candidate directly rather than presenting pagination gaps as growth.
+ const verified: typeof rows = [];
+ if (baseline.rows.length === 25000) {
+ for (let offset = 0; offset < rows.length; offset += 5) {
+ const batch = rows.slice(offset, offset + 5);
+ const history = await Promise.all(
+ batch.map((row) =>
+ GscService.getPerformance({
+ projectId,
+ startDate: baselineStartDate,
+ endDate: baselineEndDate,
+ dimensions: ["query"],
+ filters: [
+ {
+ dimension: "query",
+ operator: "equals",
+ expression: row.query,
+ },
+ ],
+ rowLimit: 1,
+ dataState: "final",
+ }),
+ ),
+ );
+ batch.forEach((row, index) => {
+ if (
+ !history[index].rows.some(
+ (previous) => previous.impressions > 0,
+ )
+ )
+ verified.push(row);
+ });
+ }
+ } else verified.push(...rows);
+ return {
+ connected: true,
+ hasSearchData: recent.rows.length > 0,
+ rows: verified,
+ startDate,
+ endDate,
+ baselineStartDate,
+ };
+ } catch (error) {
+ if (
+ error instanceof GscNotConnectedError ||
+ isExpectedGrantFailure(error)
+ )
+ return {
+ connected: false,
+ hasSearchData: false,
+ rows: [],
+ startDate,
+ endDate,
+ baselineStartDate,
+ };
+ throw error;
+ }
+ },
+ });
+}
+
+async function getLinkActivity(
+ domain: string,
+ billingCustomer: BillingCustomerContext,
+) {
+ const target = normalizeBacklinksTarget(domain, {
+ scope: "subdomains",
+ }).apiTarget;
+ const domains = await DashboardCacheService.readThrough({
+ namespace: "dashboard:new-domains",
+ organizationId: billingCustomer.organizationId,
+ params: { target },
+ schema: z.array(referringDomainItemSchema),
+ maxAgeMs: 86400_000,
+ load: async () => {
+ const from = new Date(Date.now() - 7 * 86400_000)
+ .toISOString()
+ .slice(0, 10);
+ const response = await createDataforseoClient(
+ billingCustomer,
+ ).backlinks.referringDomains({
+ target,
+ includeSubdomains: true,
+ limit: 25,
+ hideSpam: false,
+ orderBy: ["first_seen,desc"],
+ filters: [["first_seen", ">=", `${from} 00:00:00 +00:00`]],
+ });
+ return response.items;
+ },
+ });
+ // Stale domain results must not trigger a second charge or pretend the week is quiet.
+ if (domains.value.length || domains.stale)
+ return {
+ ...domains,
+ value: domains.value.map((row) => ({
+ domain: row.domain ?? null,
+ backlinks: row.backlinks ?? null,
+ firstSeen: row.first_seen ?? null,
+ })),
+ kind: "domains" as const,
+ links: [],
+ };
+ const links = await getBacklinks({ domain, kind: "new" }, billingCustomer);
+ return { ...links, value: [], kind: "links" as const, links: links.value };
+}
+
+export const DashboardSiteService = {
+ getKeywords,
+ getBacklinks,
+ getEmergingQueries,
+ getLinkActivity,
+};
diff --git a/src/server/features/gsc/services/GscService.test.ts b/src/server/features/gsc/services/GscService.test.ts
index 5c6b8721..78dad596 100644
--- a/src/server/features/gsc/services/GscService.test.ts
+++ b/src/server/features/gsc/services/GscService.test.ts
@@ -254,6 +254,12 @@ describe("GscService.listSitesForUserWithGrantStatus", () => {
describe("GscService.getPerformance", () => {
beforeEach(() => {
mocks.querySearchAnalytics.mockResolvedValue([]);
+ mocks.getByProjectId.mockResolvedValue({
+ connectedByUserId: "u1",
+ connectedAccountEmail: null,
+ gscAccountId: "sub-a",
+ siteUrl: "https://x/",
+ });
});
it.each([
@@ -281,4 +287,13 @@ describe("GscService.getPerformance", () => {
});
},
);
+ it("uses the API's full query page for internal dashboard requests", async () => {
+ const result = await GscService.getPerformance({
+ projectId: "p1",
+ startDate: "2026-01-01",
+ endDate: "2026-01-31",
+ rowLimit: 25000,
+ });
+ expect(result.request.rowLimit).toBe(25000);
+ });
});
diff --git a/src/server/features/gsc/services/GscService.ts b/src/server/features/gsc/services/GscService.ts
index b3bb47fe..32833c7c 100644
--- a/src/server/features/gsc/services/GscService.ts
+++ b/src/server/features/gsc/services/GscService.ts
@@ -203,6 +203,11 @@ async function getPerformance(
throw new GscNotConnectedError(input.projectId);
}
const request = buildSearchAnalyticsRequest(input);
+ // The MCP input schema caps tool responses at 1,000; app consumers may
+ // request Google's full page to compare low-click keywords accurately.
+ if (input.rowLimit !== undefined)
+ request.rowLimit = Math.max(1, Math.min(25000, input.rowLimit));
+
const client = createGscClient({
userId: connection.connectedByUserId,
gscAccountId: connection.gscAccountId ?? undefined,
diff --git a/src/server/lib/dataforseo/backlinks.ts b/src/server/lib/dataforseo/backlinks.ts
index d8adeebc..92f60f1f 100644
--- a/src/server/lib/dataforseo/backlinks.ts
+++ b/src/server/lib/dataforseo/backlinks.ts
@@ -33,6 +33,7 @@ type BacklinksListRequest = BacklinksRequest &
filters?: unknown[];
/** Result grouping (backlinks list only): "one_per_domain" | "as_is". */
mode?: string;
+ status?: "live" | "lost" | "all";
};
type BacklinksTimeseriesRequest = {
target: string;
@@ -87,6 +88,7 @@ export const backlinksItemSchema = z
backlinks_spam_score: z.number().nullable().optional(),
backlink_spam_score: z.number().nullable().optional(),
first_seen: z.string().nullable().optional(),
+ last_seen: z.string().nullable().optional(),
last_visited: z.string().nullable().optional(),
lost_date: z.string().nullable().optional(),
is_new: z.boolean().nullable().optional(),
@@ -223,6 +225,7 @@ export async function fetchBacklinksRows(input: BacklinksListRequest) {
[
{
...buildCommonPayload(input),
+ backlinks_status_type: input.status ?? "live",
limit: input.limit ?? BACKLINKS_DEFAULT_LIMIT,
offset: input.offset,
order_by: input.orderBy ?? ["rank,desc"],
diff --git a/src/serverFunctions/dashboard.ts b/src/serverFunctions/dashboard.ts
index 92c00252..53c24da1 100644
--- a/src/serverFunctions/dashboard.ts
+++ b/src/serverFunctions/dashboard.ts
@@ -1,9 +1,12 @@
+import { DashboardSiteService } from "@/server/features/dashboard/services/DashboardSiteService";
+import { AppError } from "@/server/lib/errors";
import { createServerFn } from "@tanstack/react-start";
import { ActivationRepository } from "@/server/features/activation/repositories/ActivationRepository";
import { DashboardService } from "@/server/features/dashboard/services/DashboardService";
import { requireProjectContext } from "@/serverFunctions/middleware";
import {
dashboardProjectInputSchema,
+ dashboardBacklinksInputSchema,
dashboardStepClickSchema,
dashboardStepDismissalSchema,
} from "@/types/schemas/dashboard";
@@ -30,22 +33,6 @@ export const getDashboardOverview = createServerFn({ method: "POST" })
}),
);
-// Visit-triggered: the client calls this when the overview reports a missing
-// or stale backlink snapshot. Metered against org credits at most once per
-// project per day (the service re-checks freshness server-side).
-export const refreshDashboardBacklinkSnapshot = createServerFn({
- method: "POST",
-})
- .middleware(requireProjectContext)
- .validator(dashboardProjectInputSchema)
- .handler(({ context }) =>
- DashboardService.ensureBacklinkSnapshot({
- projectId: context.projectId,
- domain: context.project.domain,
- billingCustomer: context,
- }),
- );
-
export const markDashboardStepClicked = createServerFn({ method: "POST" })
.middleware(requireProjectContext)
.validator(dashboardStepClickSchema)
@@ -77,3 +64,44 @@ export const setDashboardStepDismissed = createServerFn({ method: "POST" })
);
return { ok: true };
});
+
+export const getDashboardKeywords = createServerFn({ method: "POST" })
+ .middleware(requireProjectContext)
+ .validator(dashboardProjectInputSchema)
+ .handler(({ context }) =>
+ DashboardSiteService.getKeywords(context.projectId, context.organizationId),
+ );
+export const getDashboardBacklinks = createServerFn({ method: "POST" })
+ .middleware(requireProjectContext)
+ .validator(dashboardBacklinksInputSchema)
+ .handler(({ context, data }) => {
+ if (!context.project.domain)
+ throw new AppError(
+ "VALIDATION_ERROR",
+ "Add your website in project settings first.",
+ );
+ return DashboardSiteService.getBacklinks(
+ { domain: context.project.domain, kind: data.kind },
+ context,
+ );
+ });
+export const getDashboardEmergingQueries = createServerFn({ method: "POST" })
+ .middleware(requireProjectContext)
+ .validator(dashboardProjectInputSchema)
+ .handler(({ context }) =>
+ DashboardSiteService.getEmergingQueries(
+ context.projectId,
+ context.organizationId,
+ ),
+ );
+export const getDashboardLinkActivity = createServerFn({ method: "POST" })
+ .middleware(requireProjectContext)
+ .validator(dashboardProjectInputSchema)
+ .handler(({ context }) => {
+ if (!context.project.domain)
+ throw new AppError("VALIDATION_ERROR", "Add your website first.");
+ return DashboardSiteService.getLinkActivity(
+ context.project.domain,
+ context,
+ );
+ });
diff --git a/src/serverFunctions/projects.ts b/src/serverFunctions/projects.ts
index e85b8eec..cf506452 100644
--- a/src/serverFunctions/projects.ts
+++ b/src/serverFunctions/projects.ts
@@ -1,3 +1,4 @@
+import { DashboardFirstAuditService } from "@/server/features/dashboard/services/DashboardFirstAuditService";
import { createServerFn } from "@tanstack/react-start";
import { requireOrgPermission } from "@/server/auth/org-gate";
import { ProjectService } from "@/server/features/projects/services/ProjectService";
@@ -26,15 +27,36 @@ export const createProject = createServerFn({ method: "POST" })
.validator(createProjectSchema)
.handler(async ({ data, context }) => {
requireOrgPermission(context, { project: ["create"] });
- return ProjectService.createProject(context.organizationId, data);
+ const project = await ProjectService.createProject(
+ context.organizationId,
+ data,
+ );
+ const initialAudit = await DashboardFirstAuditService.start(
+ project.id,
+ project.domain,
+ { ...context, projectId: project.id },
+ );
+ return { ...project, initialAudit };
});
export const updateProject = createServerFn({ method: "POST" })
.middleware(requireProjectContext)
.validator(updateProjectSchema)
- .handler(async ({ data, context }) =>
- ProjectService.updateProject(context.organizationId, data),
- );
+ .handler(async ({ data, context }) => {
+ const project = await ProjectService.updateProject(
+ context.organizationId,
+ data,
+ );
+ const initialAudit =
+ project.domain !== context.project.domain
+ ? await DashboardFirstAuditService.start(
+ project.id,
+ project.domain,
+ context,
+ )
+ : null;
+ return { ...project, initialAudit };
+ });
export const archiveProject = createServerFn({ method: "POST" })
.middleware(requireProjectContext)
diff --git a/src/shared/error-codes.ts b/src/shared/error-codes.ts
index 8e4fdf33..daf6c252 100644
--- a/src/shared/error-codes.ts
+++ b/src/shared/error-codes.ts
@@ -10,6 +10,7 @@ const ERROR_CODES = [
"AUDIT_CAPACITY_REACHED",
"AUDIT_PAGE_LIMIT_EXCEEDED",
"AUDIT_ALREADY_RUNNING",
+ "AUDIT_RENDERING_UNAVAILABLE",
"VALIDATION_ERROR",
"UNKNOWN_LOCATION",
"CRAWL_TARGET_BLOCKED",
@@ -41,6 +42,7 @@ const NON_REPORTABLE_ERROR_CODES = new Set<ErrorCode>([
"AUDIT_CAPACITY_REACHED",
"AUDIT_PAGE_LIMIT_EXCEEDED",
"AUDIT_ALREADY_RUNNING",
+ "AUDIT_RENDERING_UNAVAILABLE",
// An external provider (DataForSEO) failing on its own side. Nothing in the
// app to fix, and it drowned real exceptions. Note the error handlers only
// log what they capture, so every throw site warns on its own line to keep
diff --git a/src/types/schemas/dashboard.ts b/src/types/schemas/dashboard.ts
index 009fde2c..61238cd8 100644
--- a/src/types/schemas/dashboard.ts
+++ b/src/types/schemas/dashboard.ts
@@ -23,3 +23,15 @@ export const dashboardStepDismissalSchema = dashboardProjectInputSchema.extend({
step: dashboardSetupStepSchema,
dismissed: z.boolean(),
});
+
+export const dashboardSiteTabSchema = z.enum([
+ "overview",
+ "keywords",
+ "backlinks",
+]);
+export const dashboardSearchSchema = z.object({
+ tab: dashboardSiteTabSchema.optional().catch(undefined),
+});
+export const dashboardBacklinksInputSchema = dashboardProjectInputSchema.extend(
+ { kind: z.enum(["new", "lost", "all"]).default("new") },
+);