Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
feat: add personal access tokens (#159)
Ben Senescu6231424e88a4
diff --git a/cli-auth.ts b/cli-auth.tsindex 5b69641a..9948c921 100644--- a/cli-auth.ts+++ b/cli-auth.ts@@ -1,11 +1,12 @@import { randomUUID } from "node:crypto";import { betterAuth } from "better-auth";-import { baseAuthConfig } from "./src/lib/auth-config";+import { createBaseAuthConfig } from "./src/lib/auth-config";const CLI_DEV_BASE_URL = "http://localhost:3000";+const baseUrl = process.env.BETTER_AUTH_URL ?? CLI_DEV_BASE_URL;export const auth = betterAuth({- baseURL: process.env.BETTER_AUTH_URL ?? CLI_DEV_BASE_URL,+ baseURL: baseUrl,secret: process.env.BETTER_AUTH_SECRET ?? randomUUID(),- ...baseAuthConfig,+ ...createBaseAuthConfig(baseUrl),});diff --git a/drizzle/0012_closed_impossible_man.sql b/drizzle/0012_closed_impossible_man.sqlnew file mode 100644index 00000000..a76573b3--- /dev/null+++ b/drizzle/0012_closed_impossible_man.sql@@ -0,0 +1,89 @@+CREATE TABLE `jwks` (+ `id` text PRIMARY KEY NOT NULL,+ `public_key` text NOT NULL,+ `private_key` text NOT NULL,+ `created_at` integer NOT NULL,+ `expires_at` integer+);+--> statement-breakpoint+CREATE TABLE `oauth_access_token` (+ `id` text PRIMARY KEY NOT NULL,+ `token` text NOT NULL,+ `client_id` text NOT NULL,+ `session_id` text,+ `user_id` text,+ `reference_id` text,+ `refresh_id` text,+ `expires_at` integer NOT NULL,+ `created_at` integer NOT NULL,+ `scopes` text NOT NULL,+ FOREIGN KEY (`client_id`) REFERENCES `oauth_client`(`client_id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON UPDATE no action ON DELETE set null,+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`refresh_id`) REFERENCES `oauth_refresh_token`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE UNIQUE INDEX `oauth_access_token_token_unique` ON `oauth_access_token` (`token`);--> statement-breakpoint+CREATE TABLE `oauth_client` (+ `id` text PRIMARY KEY NOT NULL,+ `client_id` text NOT NULL,+ `client_secret` text,+ `disabled` integer DEFAULT false,+ `skip_consent` integer,+ `enable_end_session` integer,+ `subject_type` text,+ `scopes` text,+ `user_id` text,+ `created_at` integer,+ `updated_at` integer,+ `name` text,+ `uri` text,+ `icon` text,+ `contacts` text,+ `tos` text,+ `policy` text,+ `software_id` text,+ `software_version` text,+ `software_statement` text,+ `redirect_uris` text NOT NULL,+ `post_logout_redirect_uris` text,+ `token_endpoint_auth_method` text,+ `grant_types` text,+ `response_types` text,+ `public` integer,+ `type` text,+ `require_pkce` integer,+ `reference_id` text,+ `metadata` text,+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE UNIQUE INDEX `oauth_client_client_id_unique` ON `oauth_client` (`client_id`);--> statement-breakpoint+CREATE TABLE `oauth_consent` (+ `id` text PRIMARY KEY NOT NULL,+ `client_id` text NOT NULL,+ `user_id` text,+ `reference_id` text,+ `scopes` text NOT NULL,+ `created_at` integer NOT NULL,+ `updated_at` integer NOT NULL,+ FOREIGN KEY (`client_id`) REFERENCES `oauth_client`(`client_id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE TABLE `oauth_refresh_token` (+ `id` text PRIMARY KEY NOT NULL,+ `token` text NOT NULL,+ `client_id` text NOT NULL,+ `session_id` text,+ `user_id` text NOT NULL,+ `reference_id` text,+ `expires_at` integer NOT NULL,+ `created_at` integer NOT NULL,+ `revoked` integer,+ `auth_time` integer,+ `scopes` text NOT NULL,+ FOREIGN KEY (`client_id`) REFERENCES `oauth_client`(`client_id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON UPDATE no action ON DELETE set null,+ FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade+);diff --git a/drizzle/meta/0012_snapshot.json b/drizzle/meta/0012_snapshot.jsonnew file mode 100644index 00000000..79080ecd--- /dev/null+++ b/drizzle/meta/0012_snapshot.json@@ -0,0 +1,2634 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "4aecfb5a-9351-40f4-b306-4e65e5d29fe7",+ "prevId": "23436739-8687-4515-96f9-26c79db71c35",+ "tables": {+ "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+ }+ },+ "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+ },+ "response_time_ms": {+ "name": "response_time_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "audit_pages_audit_id_idx": {+ "name": "audit_pages_audit_id_idx",+ "columns": [+ "audit_id"+ ],+ "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'"+ },+ "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": {}+ },+ "delegated_users": {+ "name": "delegated_users",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "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": {+ "delegated_users_email_unique": {+ "name": "delegated_users_email_unique",+ "columns": [+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "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": {}+ },+ "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+ },+ "created_at": {+ "name": "created_at",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(current_timestamp)"+ }+ },+ "indexes": {},+ "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_run_idx": {+ "name": "rank_snapshots_run_idx",+ "columns": [+ "run_id"+ ],+ "isUnique": false+ },+ "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'"+ },+ "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_domain_location_idx": {+ "name": "rank_tracking_configs_project_domain_location_idx",+ "columns": [+ "project_id",+ "domain",+ "location_code"+ ],+ "isUnique": true+ }+ },+ "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+ },+ "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+ },+ "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_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": {}+ },+ "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+ }+ },+ "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": {}+ },+ "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": {}+ },+ "jwks": {+ "name": "jwks",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "private_key": {+ "name": "private_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "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+ }+ },+ "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": {}+ },+ "oauth_access_token": {+ "name": "oauth_access_token",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_id": {+ "name": "refresh_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "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+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "oauth_access_token_token_unique": {+ "name": "oauth_access_token_token_unique",+ "columns": [+ "token"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "oauth_access_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_session_id_session_id_fk": {+ "name": "oauth_access_token_session_id_session_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_access_token_user_id_user_id_fk": {+ "name": "oauth_access_token_user_id_user_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_refresh_token",+ "columnsFrom": [+ "refresh_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "oauth_client": {+ "name": "oauth_client",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "client_secret": {+ "name": "client_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "disabled": {+ "name": "disabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "skip_consent": {+ "name": "skip_consent",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enable_end_session": {+ "name": "enable_end_session",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "subject_type": {+ "name": "subject_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "uri": {+ "name": "uri",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "contacts": {+ "name": "contacts",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tos": {+ "name": "tos",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "policy": {+ "name": "policy",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "software_id": {+ "name": "software_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "software_version": {+ "name": "software_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "software_statement": {+ "name": "software_statement",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "redirect_uris": {+ "name": "redirect_uris",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "post_logout_redirect_uris": {+ "name": "post_logout_redirect_uris",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_endpoint_auth_method": {+ "name": "token_endpoint_auth_method",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "grant_types": {+ "name": "grant_types",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "response_types": {+ "name": "response_types",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "public": {+ "name": "public",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "require_pkce": {+ "name": "require_pkce",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "oauth_client_client_id_unique": {+ "name": "oauth_client_client_id_unique",+ "columns": [+ "client_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "oauth_client_user_id_user_id_fk": {+ "name": "oauth_client_user_id_user_id_fk",+ "tableFrom": "oauth_client",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "oauth_consent": {+ "name": "oauth_consent",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "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+ }+ },+ "indexes": {},+ "foreignKeys": {+ "oauth_consent_client_id_oauth_client_client_id_fk": {+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_consent_user_id_user_id_fk": {+ "name": "oauth_consent_user_id_user_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "oauth_refresh_token": {+ "name": "oauth_refresh_token",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "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+ },+ "revoked": {+ "name": "revoked",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "auth_time": {+ "name": "auth_time",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "oauth_client",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_session_id_session_id_fk": {+ "name": "oauth_refresh_token_session_id_session_id_fk",+ "tableFrom": "oauth_refresh_token",+ "tableTo": "session",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "oauth_refresh_token_user_id_user_id_fk": {+ "name": "oauth_refresh_token_user_id_user_id_fk",+ "tableFrom": "oauth_refresh_token",+ "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+ }+ },+ "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+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex 6c442baa..9b1b6f83 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -85,6 +85,13 @@"when": 1778031161783,"tag": "0011_colorful_dark_beast","breakpoints": true+ },+ {+ "idx": 12,+ "version": "6",+ "when": 1778113978173,+ "tag": "0012_closed_impossible_man",+ "breakpoints": true}]}\ No newline at end of filediff --git a/knip.jsonc b/knip.jsoncindex c4f00af2..57533b7d 100644--- a/knip.jsonc+++ b/knip.jsonc@@ -11,6 +11,7 @@"drizzle.config.ts",// DB schema — exports consumed via `import * as schema` / drizzle()"src/db/index.ts",+ "src/db/app.schema.ts","src/db/better-auth-schema.ts",],"project": ["**/*.{js,mjs,ts,tsx}", "!src/routeTree.gen.ts", "!web/**"],diff --git a/package.json b/package.jsonindex 597e1f9c..9918d1f0 100644--- a/package.json+++ b/package.json@@ -49,6 +49,7 @@}},"dependencies": {+ "@better-auth/oauth-provider": "^1.5.5","@every-app/sdk": "^0.1.14","@tanstack/query-core": "^5.90.9","@tanstack/react-form": "^1.25.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a91b456c..50e8c385 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -8,6 +8,9 @@ importers:.:dependencies:+ '@better-auth/oauth-provider':+ specifier: ^1.5.5+ version: 1.5.5(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])([email protected](@cloudflare/[email protected])(@tanstack/[email protected]([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected](@cloudflare/[email protected])(@libsql/[email protected])(@opentelemetry/[email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])))([email protected]([email protected]))'@every-app/sdk':specifier: ^0.1.14version: 0.1.14(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@tanstack/[email protected]([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected])@@ -325,6 +328,15 @@ packages:'@better-auth/utils': ^0.3.0mongodb: ^6.0.0 || ^7.0.0+ '@better-auth/[email protected]':+ resolution: {integrity: sha512-zH2uKtvd6406MysWCTBldPHTKCXEK8caMrNId03bh4ej4f2vU8+GfNGE+IyxARucHGI1T+Og7QrUgKAeA2jQUQ==}+ peerDependencies:+ '@better-auth/core': 1.5.5+ '@better-auth/utils': 0.3.1+ '@better-fetch/fetch': 1.1.21+ better-auth: 1.5.5+ better-call: 1.3.2+'@better-auth/[email protected]':resolution: {integrity: sha512-CliDd78CXHzzwQIXhCdwGr5Ml53i6JdCHWV7PYwTIJz9EAm6qb2RVBdpP3nqEfNjINGM22A6gfleCgCdZkTIZg==}peerDependencies:@@ -4216,6 +4228,16 @@ snapshots:'@better-auth/utils': 0.3.1mongodb: 7.1.0+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])([email protected](@cloudflare/[email protected])(@tanstack/[email protected]([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected](@cloudflare/[email protected])(@libsql/[email protected])(@opentelemetry/[email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])))([email protected]([email protected]))':+ dependencies:+ '@better-auth/core': 1.5.5(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/utils': 0.3.1+ '@better-fetch/fetch': 1.1.21+ better-auth: 1.5.5(@cloudflare/[email protected])(@tanstack/[email protected]([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected](@cloudflare/[email protected])(@libsql/[email protected])(@opentelemetry/[email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected])([email protected]))+ better-call: 1.3.2([email protected])+ jose: 6.1.3+ zod: 4.3.6+'@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':dependencies:'@better-auth/core': 1.5.5(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])diff --git a/src/db/better-auth-schema.ts b/src/db/better-auth-schema.tsindex 60e84538..82070422 100644--- a/src/db/better-auth-schema.ts+++ b/src/db/better-auth-schema.ts@@ -151,18 +151,116 @@ export const invitation = sqliteTable(],);+export const jwks = sqliteTable("jwks", {+ id: text("id").primaryKey(),+ publicKey: text("public_key").notNull(),+ privateKey: text("private_key").notNull(),+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),+ expiresAt: integer("expires_at", { mode: "timestamp_ms" }),+});++export const oauthClient = sqliteTable("oauth_client", {+ id: text("id").primaryKey(),+ clientId: text("client_id").notNull().unique(),+ clientSecret: text("client_secret"),+ disabled: integer("disabled", { mode: "boolean" }).default(false),+ skipConsent: integer("skip_consent", { mode: "boolean" }),+ enableEndSession: integer("enable_end_session", { mode: "boolean" }),+ subjectType: text("subject_type"),+ scopes: text("scopes", { mode: "json" }),+ userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),+ createdAt: integer("created_at", { mode: "timestamp_ms" }),+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }),+ name: text("name"),+ uri: text("uri"),+ icon: text("icon"),+ contacts: text("contacts", { mode: "json" }),+ tos: text("tos"),+ policy: text("policy"),+ softwareId: text("software_id"),+ softwareVersion: text("software_version"),+ softwareStatement: text("software_statement"),+ redirectUris: text("redirect_uris", { mode: "json" }).notNull(),+ postLogoutRedirectUris: text("post_logout_redirect_uris", { mode: "json" }),+ tokenEndpointAuthMethod: text("token_endpoint_auth_method"),+ grantTypes: text("grant_types", { mode: "json" }),+ responseTypes: text("response_types", { mode: "json" }),+ public: integer("public", { mode: "boolean" }),+ type: text("type"),+ requirePKCE: integer("require_pkce", { mode: "boolean" }),+ referenceId: text("reference_id"),+ metadata: text("metadata", { mode: "json" }),+});++export const oauthRefreshToken = sqliteTable("oauth_refresh_token", {+ id: text("id").primaryKey(),+ token: text("token").notNull(),+ clientId: text("client_id")+ .notNull()+ .references(() => oauthClient.clientId, { onDelete: "cascade" }),+ sessionId: text("session_id").references(() => session.id, {+ onDelete: "set null",+ }),+ userId: text("user_id")+ .notNull()+ .references(() => user.id, { onDelete: "cascade" }),+ referenceId: text("reference_id"),+ expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),+ revoked: integer("revoked", { mode: "timestamp_ms" }),+ authTime: integer("auth_time", { mode: "timestamp_ms" }),+ scopes: text("scopes", { mode: "json" }).notNull(),+});++export const oauthAccessToken = sqliteTable("oauth_access_token", {+ id: text("id").primaryKey(),+ token: text("token").notNull().unique(),+ clientId: text("client_id")+ .notNull()+ .references(() => oauthClient.clientId, { onDelete: "cascade" }),+ sessionId: text("session_id").references(() => session.id, {+ onDelete: "set null",+ }),+ userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),+ referenceId: text("reference_id"),+ refreshId: text("refresh_id").references(() => oauthRefreshToken.id, {+ onDelete: "cascade",+ }),+ expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull(),+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),+ scopes: text("scopes", { mode: "json" }).notNull(),+});++export const oauthConsent = sqliteTable("oauth_consent", {+ id: text("id").primaryKey(),+ clientId: text("client_id")+ .notNull()+ .references(() => oauthClient.clientId, { onDelete: "cascade" }),+ userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),+ referenceId: text("reference_id"),+ scopes: text("scopes", { mode: "json" }).notNull(),+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull(),+});+export const userRelations = relations(user, ({ many }) => ({sessions: many(session),accounts: many(account),members: many(member),invitations: many(invitation),+ oauthClients: many(oauthClient),+ oauthRefreshTokens: many(oauthRefreshToken),+ oauthAccessTokens: many(oauthAccessToken),+ oauthConsents: many(oauthConsent),}));-export const sessionRelations = relations(session, ({ one }) => ({+export const sessionRelations = relations(session, ({ one, many }) => ({user: one(user, {fields: [session.userId],references: [user.id],}),+ oauthRefreshTokens: many(oauthRefreshToken),+ oauthAccessTokens: many(oauthAccessToken),}));export const accountRelations = relations(account, ({ one }) => ({@@ -198,3 +296,65 @@ export const invitationRelations = relations(invitation, ({ one }) => ({references: [user.id],}),}));++export const oauthClientRelations = relations(oauthClient, ({ one, many }) => ({+ user: one(user, {+ fields: [oauthClient.userId],+ references: [user.id],+ }),+ oauthRefreshTokens: many(oauthRefreshToken),+ oauthAccessTokens: many(oauthAccessToken),+ oauthConsents: many(oauthConsent),+}));++export const oauthRefreshTokenRelations = relations(+ oauthRefreshToken,+ ({ one, many }) => ({+ oauthClient: one(oauthClient, {+ fields: [oauthRefreshToken.clientId],+ references: [oauthClient.clientId],+ }),+ session: one(session, {+ fields: [oauthRefreshToken.sessionId],+ references: [session.id],+ }),+ user: one(user, {+ fields: [oauthRefreshToken.userId],+ references: [user.id],+ }),+ oauthAccessTokens: many(oauthAccessToken),+ }),+);++export const oauthAccessTokenRelations = relations(+ oauthAccessToken,+ ({ one }) => ({+ oauthClient: one(oauthClient, {+ fields: [oauthAccessToken.clientId],+ references: [oauthClient.clientId],+ }),+ session: one(session, {+ fields: [oauthAccessToken.sessionId],+ references: [session.id],+ }),+ user: one(user, {+ fields: [oauthAccessToken.userId],+ references: [user.id],+ }),+ oauthRefreshToken: one(oauthRefreshToken, {+ fields: [oauthAccessToken.refreshId],+ references: [oauthRefreshToken.id],+ }),+ }),+);++export const oauthConsentRelations = relations(oauthConsent, ({ one }) => ({+ oauthClient: one(oauthClient, {+ fields: [oauthConsent.clientId],+ references: [oauthClient.clientId],+ }),+ user: one(user, {+ fields: [oauthConsent.userId],+ references: [user.id],+ }),+}));diff --git a/src/lib/auth-client.ts b/src/lib/auth-client.tsindex f30dfb1d..c3be5cfe 100644--- a/src/lib/auth-client.ts+++ b/src/lib/auth-client.ts@@ -3,6 +3,7 @@ import {inferAdditionalFields,organizationClient,} from "better-auth/client/plugins";+import { oauthProviderClient } from "@better-auth/oauth-provider/client";import { captureClientEvent, resetAnalyticsUser } from "@/client/lib/posthog";import { userAdditionalFields } from "@/lib/auth-options";import { getSignInHrefForLocation } from "@/lib/auth-redirect";@@ -11,6 +12,7 @@ export const authClient = createAuthClient({baseURL: typeof window !== "undefined" ? window.location.origin : "",plugins: [organizationClient(),+ oauthProviderClient(),inferAdditionalFields({ user: userAdditionalFields }),],});diff --git a/src/lib/auth-config.ts b/src/lib/auth-config.tsindex 68deac07..357fe1b0 100644--- a/src/lib/auth-config.ts+++ b/src/lib/auth-config.ts@@ -1,7 +1,29 @@-import { organization } from "better-auth/plugins";+import { oauthProvider } from "@better-auth/oauth-provider";+import { jwt, organization } from "better-auth/plugins";import { baseAuthOptions } from "@/lib/auth-options";+import { getMcpResource, MCP_SCOPE } from "@/lib/oauth-resource";-export const baseAuthConfig = {- ...baseAuthOptions,- plugins: [organization()],-};+export function createBaseAuthConfig(baseUrl: string) {+ const mcpResource = getMcpResource(baseUrl);++ return {+ ...baseAuthOptions,+ plugins: [+ organization(),+ jwt(),+ oauthProvider({+ loginPage: "/sign-in",+ consentPage: "/oauth-consent",+ signup: {+ page: "/sign-up",+ },+ scopes: ["offline_access", MCP_SCOPE],+ allowDynamicClientRegistration: true,+ // TODO: drop once the MCP spec settles on a replacement for+ // unauthenticated DCR — better-auth has flagged this option for removal.+ allowUnauthenticatedClientRegistration: true,+ validAudiences: [mcpResource],+ }),+ ],+ };+}diff --git a/src/lib/auth.ts b/src/lib/auth.tsindex d60e42b4..afecac5f 100644--- a/src/lib/auth.ts+++ b/src/lib/auth.ts@@ -4,7 +4,7 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle";import { tanstackStartCookies } from "better-auth/tanstack-start";import { db } from "@/db";import { z } from "zod";-import { baseAuthConfig } from "@/lib/auth-config";+import { createBaseAuthConfig } from "@/lib/auth-config";import { getOrCreateDefaultHostedOrganization } from "@/server/auth/default-hosted-organization";import {sendHostedPasswordResetEmail,@@ -25,6 +25,7 @@ const hostedBaseUrlSchema = zfunction createAuth() {const baseUrl = getHostedBaseUrl();const bypassEmail = Reflect.get(env, "BYPASS_EMAIL_VERIFICATION") === "true";+ const baseAuthConfig = createBaseAuthConfig(baseUrl);const auth = betterAuth({baseURL: baseUrl,@@ -102,7 +103,7 @@ function getTrustedOrigins(baseUrl: string) {return trustedOrigins;}-function getHostedBaseUrl() {+export function getHostedBaseUrl() {const baseUrl = env.BETTER_AUTH_URL?.trim();if (!baseUrl) {diff --git a/src/lib/oauth-resource.ts b/src/lib/oauth-resource.tsnew file mode 100644index 00000000..deeea4c3--- /dev/null+++ b/src/lib/oauth-resource.ts@@ -0,0 +1,6 @@+const MCP_RESOURCE_PATH = "/mcp";+export const MCP_SCOPE = "mcp";++export function getMcpResource(baseUrl: string) {+ return new URL(MCP_RESOURCE_PATH, baseUrl).toString();+}diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.tsindex 4d960814..169bbfd6 100644--- a/src/routeTree.gen.ts+++ b/src/routeTree.gen.ts@@ -18,14 +18,17 @@ import { Route as ProjectRouteRouteImport } from './routes/_project/route'import { Route as AppRouteRouteImport } from './routes/_app/route'import { Route as AppIndexRouteImport } from './routes/_app/index'import { Route as AuthenticatedSubscribeRouteImport } from './routes/_authenticated.subscribe'+import { Route as AuthenticatedOauthConsentRouteImport } from './routes/_authenticated.oauth-consent'import { Route as AuthSignUpRouteImport } from './routes/_auth.sign-up'import { Route as AuthSignInRouteImport } from './routes/_auth.sign-in'import { Route as AppSupportRouteImport } from './routes/_app/support'import { Route as AppSettingsRouteImport } from './routes/_app/settings'import { Route as AppBillingRouteImport } from './routes/_app/billing'+import { Route as DotwellKnownOauthAuthorizationServerRouteImport } from './routes/[.]well-known/oauth-authorization-server'import { Route as ApiAutumnSplatRouteImport } from './routes/api/autumn/$'import { Route as ApiAuthSplatRouteImport } from './routes/api/auth/$'import { Route as AppHelpDataforseoApiKeyRouteImport } from './routes/_app/help/dataforseo-api-key'+import { Route as DotwellKnownOauthProtectedResourceMcpRouteImport } from './routes/[.]well-known/oauth-protected-resource/mcp'import { Route as ProjectPProjectIdRouteRouteImport } from './routes/_project/p/$projectId/route'import { Route as ProjectPProjectIdIndexRouteImport } from './routes/_project/p/$projectId/index'import { Route as ProjectPProjectIdSavedRouteImport } from './routes/_project/p/$projectId/saved'@@ -83,6 +86,12 @@ const AuthenticatedSubscribeRoute = AuthenticatedSubscribeRouteImport.update({path: '/subscribe',getParentRoute: () => AuthenticatedRoute,} as any)+const AuthenticatedOauthConsentRoute =+ AuthenticatedOauthConsentRouteImport.update({+ id: '/oauth-consent',+ path: '/oauth-consent',+ getParentRoute: () => AuthenticatedRoute,+ } as any)const AuthSignUpRoute = AuthSignUpRouteImport.update({id: '/sign-up',path: '/sign-up',@@ -108,6 +117,12 @@ const AppBillingRoute = AppBillingRouteImport.update({path: '/billing',getParentRoute: () => AppRouteRoute,} as any)+const DotwellKnownOauthAuthorizationServerRoute =+ DotwellKnownOauthAuthorizationServerRouteImport.update({+ id: '/.well-known/oauth-authorization-server',+ path: '/.well-known/oauth-authorization-server',+ getParentRoute: () => rootRouteImport,+ } as any)const ApiAutumnSplatRoute = ApiAutumnSplatRouteImport.update({id: '/api/autumn/$',path: '/api/autumn/$',@@ -123,6 +138,12 @@ const AppHelpDataforseoApiKeyRoute = AppHelpDataforseoApiKeyRouteImport.update({path: '/help/dataforseo-api-key',getParentRoute: () => AppRouteRoute,} as any)+const DotwellKnownOauthProtectedResourceMcpRoute =+ DotwellKnownOauthProtectedResourceMcpRouteImport.update({+ id: '/.well-known/oauth-protected-resource/mcp',+ path: '/.well-known/oauth-protected-resource/mcp',+ getParentRoute: () => rootRouteImport,+ } as any)const ProjectPProjectIdRouteRoute = ProjectPProjectIdRouteRouteImport.update({id: '/p/$projectId',path: '/p/$projectId',@@ -213,13 +234,16 @@ export interface FileRoutesByFullPath {'/forgot-password': typeof ForgotPasswordRoute'/reset-password': typeof ResetPasswordRoute'/verify-email': typeof VerifyEmailRoute+ '/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRoute'/billing': typeof AppBillingRoute'/settings': typeof AppSettingsRoute'/support': typeof AppSupportRoute'/sign-in': typeof AuthSignInRoute'/sign-up': typeof AuthSignUpRoute+ '/oauth-consent': typeof AuthenticatedOauthConsentRoute'/subscribe': typeof AuthenticatedSubscribeRoute'/p/$projectId': typeof ProjectPProjectIdRouteRouteWithChildren+ '/.well-known/oauth-protected-resource/mcp': typeof DotwellKnownOauthProtectedResourceMcpRoute'/help/dataforseo-api-key': typeof AppHelpDataforseoApiKeyRoute'/api/auth/$': typeof ApiAuthSplatRoute'/api/autumn/$': typeof ApiAutumnSplatRoute@@ -243,12 +267,15 @@ export interface FileRoutesByTo {'/forgot-password': typeof ForgotPasswordRoute'/reset-password': typeof ResetPasswordRoute'/verify-email': typeof VerifyEmailRoute+ '/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRoute'/billing': typeof AppBillingRoute'/settings': typeof AppSettingsRoute'/support': typeof AppSupportRoute'/sign-in': typeof AuthSignInRoute'/sign-up': typeof AuthSignUpRoute+ '/oauth-consent': typeof AuthenticatedOauthConsentRoute'/subscribe': typeof AuthenticatedSubscribeRoute+ '/.well-known/oauth-protected-resource/mcp': typeof DotwellKnownOauthProtectedResourceMcpRoute'/help/dataforseo-api-key': typeof AppHelpDataforseoApiKeyRoute'/api/auth/$': typeof ApiAuthSplatRoute'/api/autumn/$': typeof ApiAutumnSplatRoute@@ -274,14 +301,17 @@ export interface FileRoutesById {'/forgot-password': typeof ForgotPasswordRoute'/reset-password': typeof ResetPasswordRoute'/verify-email': typeof VerifyEmailRoute+ '/.well-known/oauth-authorization-server': typeof DotwellKnownOauthAuthorizationServerRoute'/_app/billing': typeof AppBillingRoute'/_app/settings': typeof AppSettingsRoute'/_app/support': typeof AppSupportRoute'/_auth/sign-in': typeof AuthSignInRoute'/_auth/sign-up': typeof AuthSignUpRoute+ '/_authenticated/oauth-consent': typeof AuthenticatedOauthConsentRoute'/_authenticated/subscribe': typeof AuthenticatedSubscribeRoute'/_app/': typeof AppIndexRoute'/_project/p/$projectId': typeof ProjectPProjectIdRouteRouteWithChildren+ '/.well-known/oauth-protected-resource/mcp': typeof DotwellKnownOauthProtectedResourceMcpRoute'/_app/help/dataforseo-api-key': typeof AppHelpDataforseoApiKeyRoute'/api/auth/$': typeof ApiAuthSplatRoute'/api/autumn/$': typeof ApiAutumnSplatRoute@@ -307,13 +337,16 @@ export interface FileRouteTypes {| '/forgot-password'| '/reset-password'| '/verify-email'+ | '/.well-known/oauth-authorization-server'| '/billing'| '/settings'| '/support'| '/sign-in'| '/sign-up'+ | '/oauth-consent'| '/subscribe'| '/p/$projectId'+ | '/.well-known/oauth-protected-resource/mcp'| '/help/dataforseo-api-key'| '/api/auth/$'| '/api/autumn/$'@@ -337,12 +370,15 @@ export interface FileRouteTypes {| '/forgot-password'| '/reset-password'| '/verify-email'+ | '/.well-known/oauth-authorization-server'| '/billing'| '/settings'| '/support'| '/sign-in'| '/sign-up'+ | '/oauth-consent'| '/subscribe'+ | '/.well-known/oauth-protected-resource/mcp'| '/help/dataforseo-api-key'| '/api/auth/$'| '/api/autumn/$'@@ -367,14 +403,17 @@ export interface FileRouteTypes {| '/forgot-password'| '/reset-password'| '/verify-email'+ | '/.well-known/oauth-authorization-server'| '/_app/billing'| '/_app/settings'| '/_app/support'| '/_auth/sign-in'| '/_auth/sign-up'+ | '/_authenticated/oauth-consent'| '/_authenticated/subscribe'| '/_app/'| '/_project/p/$projectId'+ | '/.well-known/oauth-protected-resource/mcp'| '/_app/help/dataforseo-api-key'| '/api/auth/$'| '/api/autumn/$'@@ -402,6 +441,8 @@ export interface RootRouteChildren {ForgotPasswordRoute: typeof ForgotPasswordRouteResetPasswordRoute: typeof ResetPasswordRouteVerifyEmailRoute: typeof VerifyEmailRoute+ DotwellKnownOauthAuthorizationServerRoute: typeof DotwellKnownOauthAuthorizationServerRoute+ DotwellKnownOauthProtectedResourceMcpRoute: typeof DotwellKnownOauthProtectedResourceMcpRouteApiAuthSplatRoute: typeof ApiAuthSplatRouteApiAutumnSplatRoute: typeof ApiAutumnSplatRoute}@@ -471,6 +512,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedSubscribeRouteImportparentRoute: typeof AuthenticatedRoute}+ '/_authenticated/oauth-consent': {+ id: '/_authenticated/oauth-consent'+ path: '/oauth-consent'+ fullPath: '/oauth-consent'+ preLoaderRoute: typeof AuthenticatedOauthConsentRouteImport+ parentRoute: typeof AuthenticatedRoute+ }'/_auth/sign-up': {id: '/_auth/sign-up'path: '/sign-up'@@ -506,6 +554,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AppBillingRouteImportparentRoute: typeof AppRouteRoute}+ '/.well-known/oauth-authorization-server': {+ id: '/.well-known/oauth-authorization-server'+ path: '/.well-known/oauth-authorization-server'+ fullPath: '/.well-known/oauth-authorization-server'+ preLoaderRoute: typeof DotwellKnownOauthAuthorizationServerRouteImport+ parentRoute: typeof rootRouteImport+ }'/api/autumn/$': {id: '/api/autumn/$'path: '/api/autumn/$'@@ -527,6 +582,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AppHelpDataforseoApiKeyRouteImportparentRoute: typeof AppRouteRoute}+ '/.well-known/oauth-protected-resource/mcp': {+ id: '/.well-known/oauth-protected-resource/mcp'+ path: '/.well-known/oauth-protected-resource/mcp'+ fullPath: '/.well-known/oauth-protected-resource/mcp'+ preLoaderRoute: typeof DotwellKnownOauthProtectedResourceMcpRouteImport+ parentRoute: typeof rootRouteImport+ }'/_project/p/$projectId': {id: '/_project/p/$projectId'path: '/p/$projectId'@@ -748,10 +810,12 @@ const AuthRouteChildren: AuthRouteChildren = {const AuthRouteWithChildren = AuthRoute._addFileChildren(AuthRouteChildren)interface AuthenticatedRouteChildren {+ AuthenticatedOauthConsentRoute: typeof AuthenticatedOauthConsentRouteAuthenticatedSubscribeRoute: typeof AuthenticatedSubscribeRoute}const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {+ AuthenticatedOauthConsentRoute: AuthenticatedOauthConsentRoute,AuthenticatedSubscribeRoute: AuthenticatedSubscribeRoute,}@@ -767,6 +831,10 @@ const rootRouteChildren: RootRouteChildren = {ForgotPasswordRoute: ForgotPasswordRoute,ResetPasswordRoute: ResetPasswordRoute,VerifyEmailRoute: VerifyEmailRoute,+ DotwellKnownOauthAuthorizationServerRoute:+ DotwellKnownOauthAuthorizationServerRoute,+ DotwellKnownOauthProtectedResourceMcpRoute:+ DotwellKnownOauthProtectedResourceMcpRoute,ApiAuthSplatRoute: ApiAuthSplatRoute,ApiAutumnSplatRoute: ApiAutumnSplatRoute,}diff --git a/src/routes/[.]well-known/oauth-authorization-server.ts b/src/routes/[.]well-known/oauth-authorization-server.tsnew file mode 100644index 00000000..5d9acd16--- /dev/null+++ b/src/routes/[.]well-known/oauth-authorization-server.ts@@ -0,0 +1,31 @@+import { oauthProviderAuthServerMetadata } from "@better-auth/oauth-provider";+import { createFileRoute } from "@tanstack/react-router";+import { env } from "cloudflare:workers";+import { getAuth, hasHostedAuthConfig } from "@/lib/auth";+import { isHostedAuthMode } from "@/lib/auth-mode";++function unavailableMetadataResponse() {+ if (!isHostedAuthMode(env.AUTH_MODE)) {+ return new Response("Not found", { status: 404 });+ }++ return new Response("Missing Better Auth hosted configuration", {+ status: 500,+ });+}++export const Route = createFileRoute("/.well-known/oauth-authorization-server")(+ {+ server: {+ handlers: {+ GET: async ({ request }: { request: Request }) => {+ if (!isHostedAuthMode(env.AUTH_MODE) || !hasHostedAuthConfig()) {+ return unavailableMetadataResponse();+ }++ return oauthProviderAuthServerMetadata(getAuth())(request);+ },+ },+ },+ },+);diff --git a/src/routes/[.]well-known/oauth-protected-resource/mcp.ts b/src/routes/[.]well-known/oauth-protected-resource/mcp.tsnew file mode 100644index 00000000..aa3e60b4--- /dev/null+++ b/src/routes/[.]well-known/oauth-protected-resource/mcp.ts@@ -0,0 +1,46 @@+import { createFileRoute } from "@tanstack/react-router";+import { env } from "cloudflare:workers";+import { getAuth, getHostedBaseUrl, hasHostedAuthConfig } from "@/lib/auth";+import { isHostedAuthMode } from "@/lib/auth-mode";+import { getMcpResource, MCP_SCOPE } from "@/lib/oauth-resource";++function unavailableMetadataResponse() {+ if (!isHostedAuthMode(env.AUTH_MODE)) {+ return new Response("Not found", { status: 404 });+ }++ return new Response("Missing Better Auth hosted configuration", {+ status: 500,+ });+}++export const Route = createFileRoute(+ "/.well-known/oauth-protected-resource/mcp",+)({+ server: {+ handlers: {+ GET: async () => {+ if (!isHostedAuthMode(env.AUTH_MODE) || !hasHostedAuthConfig()) {+ return unavailableMetadataResponse();+ }++ const baseUrl = getHostedBaseUrl();+ const authServerMetadata = await getAuth().api.getOAuthServerConfig();+ const metadata = {+ resource: getMcpResource(baseUrl),+ authorization_servers: [authServerMetadata.issuer],+ scopes_supported: [MCP_SCOPE],+ resource_name: "OpenSEO MCP",+ };++ return new Response(JSON.stringify(metadata), {+ headers: {+ "Cache-Control":+ "public, max-age=15, stale-while-revalidate=15, stale-if-error=86400",+ "Content-Type": "application/json",+ },+ });+ },+ },+ },+});diff --git a/src/routes/_authenticated.oauth-consent.tsx b/src/routes/_authenticated.oauth-consent.tsxnew file mode 100644index 00000000..c62c8b36--- /dev/null+++ b/src/routes/_authenticated.oauth-consent.tsx@@ -0,0 +1,73 @@+import { createFileRoute } from "@tanstack/react-router";+import { ShieldCheck } from "lucide-react";+import { useState } from "react";+import { authClient } from "@/lib/auth-client";++export const Route = createFileRoute("/_authenticated/oauth-consent")({+ component: OAuthConsentPage,+});++function OAuthConsentPage() {+ const [isSubmitting, setIsSubmitting] = useState(false);+ const [error, setError] = useState<string | null>(null);++ async function respond(accept: boolean) {+ setError(null);+ setIsSubmitting(true);++ const { data, error: consentError } = await authClient.oauth2.consent({+ accept,+ });++ if (consentError) {+ setError(consentError.message ?? "Unable to complete authorization.");+ setIsSubmitting(false);+ return;+ }++ if (data?.redirect && data.url) {+ window.location.assign(data.url);+ return;+ }++ setError("Authorization response did not include a redirect URL.");+ setIsSubmitting(false);+ }++ return (+ <div className="w-full max-w-sm space-y-5">+ <div className="text-center space-y-3">+ <div className="mx-auto flex size-12 items-center justify-center rounded-lg bg-base-200">+ <ShieldCheck className="size-6" />+ </div>+ <div>+ <h1 className="text-xl font-semibold">Authorize MCP access</h1>+ <p className="mt-2 text-sm text-base-content/70">+ Allow this MCP client to access your OpenSEO workspace.+ </p>+ </div>+ </div>++ {error ? <p className="text-sm text-error">{error}</p> : null}++ <div className="flex gap-2">+ <button+ type="button"+ className="btn btn-ghost flex-1"+ disabled={isSubmitting}+ onClick={() => void respond(false)}+ >+ Deny+ </button>+ <button+ type="button"+ className="btn btn-primary flex-1"+ disabled={isSubmitting}+ onClick={() => void respond(true)}+ >+ {isSubmitting ? "Authorizing..." : "Authorize"}+ </button>+ </div>+ </div>+ );+}diff --git a/src/routes/_authenticated.tsx b/src/routes/_authenticated.tsxindex caf92b4b..503f6e76 100644--- a/src/routes/_authenticated.tsx+++ b/src/routes/_authenticated.tsx@@ -18,7 +18,9 @@ function AuthenticatedShellLayout() {if (!session?.user?.id) {void navigate({to: "/sign-in",- search: { redirect: window.location.pathname },+ search: {+ redirect: `${window.location.pathname}${window.location.search}`,+ },});}}, [isPending, isHostedMode, session?.user?.id, navigate]);