Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content): add Settings › Authors, the real people a page is by (CE-037) (#1412)

Cihand695287a6fe6
diff --git a/supabase/migrations/00256_content_authors.sql b/supabase/migrations/00256_content_authors.sql
new file mode 100644
index 000000000..ff4194179
--- /dev/null
+++ b/supabase/migrations/00256_content_authors.sql
@@ -0,0 +1,204 @@
+-- ============================================================================
+-- 00256: the workspace's authors (Content Editor Quality, CE-037)
+-- ============================================================================
+-- Settings › Authors (Quality spec §9): the real people a page is by. A
+-- page's author is its metadata, never its content: the editor shows it as
+-- a byline outside the page, Ansvisor sets the CMS author field on publish,
+-- and Person schema names it. "Real people only. Content Agent can't add,
+-- edit or invent authors": the server has no path that writes these.
+--
+-- * content_authors: one row per person, in an organization: name, title,
+-- a short bio, profile links (sameAs), a photo. user_id is the member
+-- the author is, when they are one: only that member links or unlinks
+-- themself, and each member is one author at most.
+-- * Anyone in the workspace adds authors; whoever added one, the author
+-- themself or an admin edits and deletes it. Its organization, who
+-- added it and when stay as they were.
+-- * content_author_defaults: one default author per brand, which every
+-- new page of the brand gets; admins and managers set it, as the
+-- workspace's other settings. With none, a page is by the organization
+-- ("{Brand} Team").
+
+-- Profile links feed Person schema's sameAs and Site trust, and members
+-- write the table from their own sessions, so the table holds the rule the
+-- action checks: each link https, at most 300 characters.
+create or replace function public.content_author_links_ok(links text[])
+returns boolean
+language sql
+immutable
+set search_path = ''
+as $$
+ select coalesce(bool_and(l ~ '^https://\S+$' and char_length(l) <= 300), true)
+ from unnest(links) as l
+$$;
+
+create table if not exists public.content_authors (
+ id uuid primary key default gen_random_uuid(),
+ organization_id uuid not null references public.organizations(id) on delete cascade,
+ user_id uuid references public.profiles(id) on delete set null,
+ name text not null check (char_length(btrim(name)) between 1 and 120),
+ title text check (title is null or char_length(title) <= 120),
+ bio text check (bio is null or char_length(bio) <= 400),
+ photo_url text check (
+ photo_url is null or (photo_url ~ '^https://' and char_length(photo_url) <= 2048)
+ ),
+ same_as text[] not null default '{}' check (
+ cardinality(same_as) <= 10 and public.content_author_links_ok(same_as)
+ ),
+ created_by uuid references public.profiles(id) on delete set null,
+ created_at timestamptz not null default now(),
+ updated_at timestamptz not null default now()
+);
+
+create index if not exists content_authors_organization
+ on public.content_authors (organization_id, name);
+
+-- A member is one author of their organization at most.
+create unique index if not exists content_authors_member
+ on public.content_authors (organization_id, user_id)
+ where user_id is not null;
+
+create or replace trigger content_authors_updated_at
+ before update on public.content_authors
+ for each row execute function public.handle_updated_at();
+
+-- What RLS can't say: an author's organization, who added it and when never
+-- change, and user_id changes only as its member linking or unlinking
+-- themself.
+create or replace function public.guard_content_author_columns()
+returns trigger
+language plpgsql
+set search_path = ''
+as $$
+begin
+ -- A role that bypasses RLS is server-side (service role, migrations).
+ if (select rolbypassrls from pg_catalog.pg_roles where rolname = current_user) then
+ return new;
+ end if;
+ if new.organization_id is distinct from old.organization_id
+ or new.created_by is distinct from old.created_by
+ or new.created_at is distinct from old.created_at
+ then
+ raise exception 'content author column can''t change'
+ using errcode = '42501';
+ end if;
+ if new.user_id is distinct from old.user_id
+ and not (old.user_id is null and new.user_id = auth.uid())
+ and not (old.user_id = auth.uid() and new.user_id is null)
+ then
+ raise exception 'only a member links or unlinks themself as an author'
+ using errcode = '42501';
+ end if;
+ return new;
+end;
+$$;
+
+create or replace trigger content_authors_guard
+ before update on public.content_authors
+ for each row execute function public.guard_content_author_columns();
+
+alter table public.content_authors enable row level security;
+
+create policy "content_authors: member select"
+ on public.content_authors
+ for select
+ using (organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid()));
+
+-- Added by the member, as no one or as themself.
+create policy "content_authors: member insert"
+ on public.content_authors
+ for insert
+ with check (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and created_by = auth.uid()
+ and (user_id is null or user_id = auth.uid())
+ );
+
+-- Whoever added it, the author themself, or an admin of the organization.
+create policy "content_authors: owner or admin update"
+ on public.content_authors
+ for update
+ using (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and (
+ created_by = auth.uid()
+ or user_id = auth.uid()
+ or exists (select 1 from public.profiles p where p.id = auth.uid() and p.role = 'admin')
+ )
+ )
+ with check (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ );
+
+create policy "content_authors: owner or admin delete"
+ on public.content_authors
+ for delete
+ using (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and (
+ created_by = auth.uid()
+ or user_id = auth.uid()
+ or exists (select 1 from public.profiles p where p.id = auth.uid() and p.role = 'admin')
+ )
+ );
+
+-- Every policy needs auth.uid(); revoking anon keeps it so if one is loosened.
+revoke all on table public.content_authors from anon;
+grant select, insert, update, delete on public.content_authors to authenticated;
+
+comment on table public.content_authors is
+ 'Content Editor Quality (CE-037): the workspace''s authors — real people a page is by (page metadata, never content). Anyone adds; whoever added it, the author themself or an admin edits. The server never writes them.';
+
+create table if not exists public.content_author_defaults (
+ brand_id uuid primary key references public.brands(id) on delete cascade,
+ author_id uuid not null references public.content_authors(id) on delete cascade,
+ updated_by uuid references public.profiles(id) on delete set null,
+ updated_at timestamptz not null default now()
+);
+
+create index if not exists content_author_defaults_author
+ on public.content_author_defaults (author_id);
+
+alter table public.content_author_defaults enable row level security;
+
+create policy "content_author_defaults: member select"
+ on public.content_author_defaults
+ for select
+ using (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid()
+ )
+ );
+
+-- Admins and managers of the brand's organization, with an author of it.
+create policy "content_author_defaults: manager write"
+ on public.content_author_defaults
+ for all
+ using (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid() and p.role in ('admin', 'manager')
+ )
+ )
+ with check (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid() and p.role in ('admin', 'manager')
+ )
+ and author_id in (
+ select a.id from public.content_authors a
+ join public.brands b on b.organization_id = a.organization_id
+ where b.id = content_author_defaults.brand_id
+ )
+ and updated_by = auth.uid()
+ );
+
+revoke all on table public.content_author_defaults from anon;
+grant select, insert, update, delete on public.content_author_defaults to authenticated;
+
+comment on table public.content_author_defaults is
+ 'Content Editor Quality (CE-037): the author every new page of a brand gets; none means the organization byline. Admins and managers set it.';
diff --git a/supabase/schema.sql b/supabase/schema.sql
index 06a47f138..b21146ce3 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -37612,3 +37612,211 @@ comment on function public.ga_platform_value(uuid, date, date) is
notify pgrst, 'reload schema';
+-- ─────────────────────────────────────────────────────────────────────────
+-- migrations/00256_content_authors.sql
+-- ─────────────────────────────────────────────────────────────────────────
+-- ============================================================================
+-- 00256: the workspace's authors (Content Editor Quality, CE-037)
+-- ============================================================================
+-- Settings › Authors (Quality spec §9): the real people a page is by. A
+-- page's author is its metadata, never its content: the editor shows it as
+-- a byline outside the page, Ansvisor sets the CMS author field on publish,
+-- and Person schema names it. "Real people only. Content Agent can't add,
+-- edit or invent authors": the server has no path that writes these.
+--
+-- * content_authors: one row per person, in an organization: name, title,
+-- a short bio, profile links (sameAs), a photo. user_id is the member
+-- the author is, when they are one: only that member links or unlinks
+-- themself, and each member is one author at most.
+-- * Anyone in the workspace adds authors; whoever added one, the author
+-- themself or an admin edits and deletes it. Its organization, who
+-- added it and when stay as they were.
+-- * content_author_defaults: one default author per brand, which every
+-- new page of the brand gets; admins and managers set it, as the
+-- workspace's other settings. With none, a page is by the organization
+-- ("{Brand} Team").
+
+-- Profile links feed Person schema's sameAs and Site trust, and members
+-- write the table from their own sessions, so the table holds the rule the
+-- action checks: each link https, at most 300 characters.
+create or replace function public.content_author_links_ok(links text[])
+returns boolean
+language sql
+immutable
+set search_path = ''
+as $$
+ select coalesce(bool_and(l ~ '^https://\S+$' and char_length(l) <= 300), true)
+ from unnest(links) as l
+$$;
+
+create table if not exists public.content_authors (
+ id uuid primary key default gen_random_uuid(),
+ organization_id uuid not null references public.organizations(id) on delete cascade,
+ user_id uuid references public.profiles(id) on delete set null,
+ name text not null check (char_length(btrim(name)) between 1 and 120),
+ title text check (title is null or char_length(title) <= 120),
+ bio text check (bio is null or char_length(bio) <= 400),
+ photo_url text check (
+ photo_url is null or (photo_url ~ '^https://' and char_length(photo_url) <= 2048)
+ ),
+ same_as text[] not null default '{}' check (
+ cardinality(same_as) <= 10 and public.content_author_links_ok(same_as)
+ ),
+ created_by uuid references public.profiles(id) on delete set null,
+ created_at timestamptz not null default now(),
+ updated_at timestamptz not null default now()
+);
+
+create index if not exists content_authors_organization
+ on public.content_authors (organization_id, name);
+
+-- A member is one author of their organization at most.
+create unique index if not exists content_authors_member
+ on public.content_authors (organization_id, user_id)
+ where user_id is not null;
+
+create or replace trigger content_authors_updated_at
+ before update on public.content_authors
+ for each row execute function public.handle_updated_at();
+
+-- What RLS can't say: an author's organization, who added it and when never
+-- change, and user_id changes only as its member linking or unlinking
+-- themself.
+create or replace function public.guard_content_author_columns()
+returns trigger
+language plpgsql
+set search_path = ''
+as $$
+begin
+ -- A role that bypasses RLS is server-side (service role, migrations).
+ if (select rolbypassrls from pg_catalog.pg_roles where rolname = current_user) then
+ return new;
+ end if;
+ if new.organization_id is distinct from old.organization_id
+ or new.created_by is distinct from old.created_by
+ or new.created_at is distinct from old.created_at
+ then
+ raise exception 'content author column can''t change'
+ using errcode = '42501';
+ end if;
+ if new.user_id is distinct from old.user_id
+ and not (old.user_id is null and new.user_id = auth.uid())
+ and not (old.user_id = auth.uid() and new.user_id is null)
+ then
+ raise exception 'only a member links or unlinks themself as an author'
+ using errcode = '42501';
+ end if;
+ return new;
+end;
+$$;
+
+create or replace trigger content_authors_guard
+ before update on public.content_authors
+ for each row execute function public.guard_content_author_columns();
+
+alter table public.content_authors enable row level security;
+
+create policy "content_authors: member select"
+ on public.content_authors
+ for select
+ using (organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid()));
+
+-- Added by the member, as no one or as themself.
+create policy "content_authors: member insert"
+ on public.content_authors
+ for insert
+ with check (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and created_by = auth.uid()
+ and (user_id is null or user_id = auth.uid())
+ );
+
+-- Whoever added it, the author themself, or an admin of the organization.
+create policy "content_authors: owner or admin update"
+ on public.content_authors
+ for update
+ using (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and (
+ created_by = auth.uid()
+ or user_id = auth.uid()
+ or exists (select 1 from public.profiles p where p.id = auth.uid() and p.role = 'admin')
+ )
+ )
+ with check (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ );
+
+create policy "content_authors: owner or admin delete"
+ on public.content_authors
+ for delete
+ using (
+ organization_id in (select p.organization_id from public.profiles p where p.id = auth.uid())
+ and (
+ created_by = auth.uid()
+ or user_id = auth.uid()
+ or exists (select 1 from public.profiles p where p.id = auth.uid() and p.role = 'admin')
+ )
+ );
+
+-- Every policy needs auth.uid(); revoking anon keeps it so if one is loosened.
+revoke all on table public.content_authors from anon;
+grant select, insert, update, delete on public.content_authors to authenticated;
+
+comment on table public.content_authors is
+ 'Content Editor Quality (CE-037): the workspace''s authors — real people a page is by (page metadata, never content). Anyone adds; whoever added it, the author themself or an admin edits. The server never writes them.';
+
+create table if not exists public.content_author_defaults (
+ brand_id uuid primary key references public.brands(id) on delete cascade,
+ author_id uuid not null references public.content_authors(id) on delete cascade,
+ updated_by uuid references public.profiles(id) on delete set null,
+ updated_at timestamptz not null default now()
+);
+
+create index if not exists content_author_defaults_author
+ on public.content_author_defaults (author_id);
+
+alter table public.content_author_defaults enable row level security;
+
+create policy "content_author_defaults: member select"
+ on public.content_author_defaults
+ for select
+ using (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid()
+ )
+ );
+
+-- Admins and managers of the brand's organization, with an author of it.
+create policy "content_author_defaults: manager write"
+ on public.content_author_defaults
+ for all
+ using (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid() and p.role in ('admin', 'manager')
+ )
+ )
+ with check (
+ brand_id in (
+ select b.id from public.brands b
+ join public.profiles p on p.organization_id = b.organization_id
+ where p.id = auth.uid() and p.role in ('admin', 'manager')
+ )
+ and author_id in (
+ select a.id from public.content_authors a
+ join public.brands b on b.organization_id = a.organization_id
+ where b.id = content_author_defaults.brand_id
+ )
+ and updated_by = auth.uid()
+ );
+
+revoke all on table public.content_author_defaults from anon;
+grant select, insert, update, delete on public.content_author_defaults to authenticated;
+
+comment on table public.content_author_defaults is
+ 'Content Editor Quality (CE-037): the author every new page of a brand gets; none means the organization byline. Admins and managers set it.';
+
diff --git a/web/messages/en.json b/web/messages/en.json
index 3c20c5d79..fa6568ba5 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -6241,6 +6241,49 @@
"general": "General",
"apiKeys": "API Keys",
"team": "Team",
+ "authors": {
+ "title": "Authors",
+ "description": "The people your pages are by. Each page names one as its author: your CMS shows the byline, and Person schema names them for search engines and AI answers.",
+ "realPeople": "Real people only. Content Agent can't add, edit or invent authors.",
+ "loading": "Loading the authors",
+ "loadFailed": "Couldn't load the authors.",
+ "empty": "No authors yet. Until you add one, pages are by your brand's team.",
+ "you": "(you)",
+ "profiles": "{count, plural, =0 {No profile links} one {# profile link} other {# profile links}}",
+ "defaultFor": "Default for {brands}",
+ "edit": "Edit",
+ "remove": "Remove",
+ "removeTitle": "Remove {name}?",
+ "removeDescription": "They leave the authors list and any brand's default. Nothing on the pages themselves changes.",
+ "removed": "{name} removed.",
+ "removeFailed": "Couldn't remove the author.",
+ "add": "Add author",
+ "addTitle": "Add an author",
+ "editTitle": "Edit author",
+ "save": "Save author",
+ "saved": "{name} saved.",
+ "saveFailed": "Couldn't save the author.",
+ "alreadyAuthor": "You're another author already. Untick \"This author is me\" or edit your own author.",
+ "defaultsTitle": "Default author per brand",
+ "defaultsHint": "Every new page of the brand gets this author. You can pick another on any page.",
+ "defaultsManagers": "Admins and managers set the defaults.",
+ "defaultFailed": "Couldn't set the default author.",
+ "organizationByline": "{brand} Team",
+ "fields": {
+ "name": "Full name",
+ "title": "Title",
+ "titleHint": "Head of Content",
+ "bio": "Short bio",
+ "bioHint": "Two sentences on what they know and do.",
+ "links": "Profile links",
+ "linksHint": "One https link per line: LinkedIn, X, GitHub… Up to {max}.",
+ "linkInvalid": "{link} isn't an https link of up to {max} characters.",
+ "photo": "Photo link",
+ "isMe": "This author is me",
+ "isSomeoneElse": "Another member is this author. Only they can unlink themself.",
+ "isMeTaken": "You're another author already."
+ }
+ },
"notifications": "Notifications",
"notificationsDescription": "Daily Pulse — a short digest per brand after each tracking run, with highlights and warnings.",
"pulseFrequency_daily": "Daily",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts
index 7bf6b7d80..fc1426453 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts
+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.test.ts
@@ -1,5 +1,5 @@
-import { describe, expect, it } from 'vitest';
-import { resolveSettingsSection, settingsSectionPath } from './_sections';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { hasSettingsSection, resolveSettingsSection, settingsSectionPath } from './_sections';
const cloud = { isCloud: true };
const selfHost = { isCloud: false };
@@ -23,6 +23,22 @@ describe('resolveSettingsSection', () => {
});
});
+describe('Authors (CE-037)', () => {
+ afterEach(() => vi.unstubAllEnvs());
+
+ it("isn't there until Content Editor Quality's first phase is live", () => {
+ vi.stubEnv('NEXT_PUBLIC_CONTENT_QUALITY_PHASE', '');
+ expect(hasSettingsSection('authors', selfHost)).toBe(false);
+ expect(resolveSettingsSection('authors', cloud)).toBe('account');
+ });
+
+ it('opens on its own address once it is', () => {
+ vi.stubEnv('NEXT_PUBLIC_CONTENT_QUALITY_PHASE', '1');
+ expect(hasSettingsSection('authors', selfHost)).toBe(true);
+ expect(resolveSettingsSection('authors', selfHost)).toBe('authors');
+ });
+});
+
describe('settingsSectionPath', () => {
it('keeps the locale prefix and replaces the section', () => {
expect(settingsSectionPath('/dashboard/settings', 'team')).toBe('/dashboard/settings/team');
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts
index 4041b3e2e..03f12deb2 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts
+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_sections.ts
@@ -1,3 +1,5 @@
+import { qualityPhase } from '@/lib/content/quality';
+
/**
* Settings' sections, each with its own address (/dashboard/settings/<id>),
* so a page or an e-mail can link straight to one: the Chat page links to AI
@@ -7,6 +9,7 @@ export const SETTINGS_SECTIONS = [
'account',
'organization',
'team',
+ 'authors',
'notifications',
'integrations',
'api-keys',
@@ -19,6 +22,9 @@ export type SettingsSection = (typeof SETTINGS_SECTIONS)[number];
/** Sections only Ansvisor Cloud has: self-host sets its AI key in env, and has no billing. */
const CLOUD_ONLY: readonly SettingsSection[] = ['ai-providers', 'billing'];
+/** Content Editor Quality's Authors (CE-037): only while its phase is live. */
+const hasAuthors = () => qualityPhase() >= 1;
+
/** Older names an address may still carry: ?tab=project, ?tab=agent. */
const RENAMED: Record<string, SettingsSection> = {
project: 'organization',
@@ -35,12 +41,13 @@ export function resolveSettingsSection(
): SettingsSection {
const name = value ? (RENAMED[value] ?? value) : null;
const section = SETTINGS_SECTIONS.find((s) => s === name);
- if (!section || (!isCloud && CLOUD_ONLY.includes(section))) return 'account';
+ if (!section || !hasSettingsSection(section, { isCloud })) return 'account';
return section;
}
/** Whether this install shows the section. */
export function hasSettingsSection(section: SettingsSection, { isCloud }: { isCloud: boolean }) {
+ if (section === 'authors' && !hasAuthors()) return false;
return isCloud || !CLOUD_ONLY.includes(section);
}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx b/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx
index d0bc166da..9d407affe 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/settings/_settings-view.tsx
@@ -13,6 +13,7 @@ import { cn } from '@/lib/utils';
import { usePlanContext } from '@/components/providers/plan-provider';
import { BillingSection } from '@/components/settings/billing-section';
import { TeamSection } from '@/components/settings/team-section';
+import { AuthorsSection } from '@/components/settings/authors-section';
import { ApiKeysSection } from '@/components/settings/api-keys-section';
import { AiProvidersSection } from '@/components/settings/ai-providers-section';
import { NotificationsSection } from '@/components/settings/notifications-section';
@@ -79,6 +80,7 @@ export function SettingsView({ section }: { section: SettingsSection }) {
account: t('account'),
organization: t('organization'),
team: t('team'),
+ authors: t('authors.title'),
notifications: t('notifications'),
integrations: t('integrations'),
'api-keys': t('apiKeys'),
@@ -171,6 +173,8 @@ export function SettingsView({ section }: { section: SettingsSection }) {
{/* Team */}
{active === 'team' && <TeamSection />}
+ {active === 'authors' && hasSettingsSection('authors', { isCloud }) && <AuthorsSection />}
+
{active === 'notifications' && <NotificationsSection />}
{active === 'integrations' && <IntegrationsSection />}
diff --git a/web/src/components/settings/authors-section.test.tsx b/web/src/components/settings/authors-section.test.tsx
new file mode 100644
index 000000000..c392f5850
--- /dev/null
+++ b/web/src/components/settings/authors-section.test.tsx
@@ -0,0 +1,271 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { NextIntlClientProvider } from 'next-intl';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import messages from '../../../messages/en.json';
+import type { AuthorsRead } from '@/lib/content/authors';
+
+/**
+ * Settings › Authors (CE-037): the workspace's real authors; whoever added
+ * one, the author themself or an admin edits it; admins and managers pick
+ * each brand's default, or the "{Brand} Team" byline.
+ */
+
+const actions = vi.hoisted(() => ({
+ getContentAuthors: vi.fn(),
+ saveContentAuthor: vi.fn(),
+ deleteContentAuthor: vi.fn(),
+ setDefaultAuthor: vi.fn(),
+}));
+vi.mock('@/lib/actions/content-authors', () => actions);
+const toast = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn() }));
+vi.mock('sonner', () => ({ toast }));
+
+const { AuthorsSection } = await import('./authors-section');
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+const ME = '11111111-1111-4111-8111-111111111111';
+const OTHER = '22222222-2222-4222-8222-222222222222';
+const ADA = 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa';
+const BOB = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb';
+const CAL = 'dddddddd-dddd-4ddd-8ddd-dddddddddddd';
+const ACME = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc';
+
+function workspace(role: string): AuthorsRead {
+ return {
+ authors: [
+ {
+ id: ADA,
+ name: 'Ada Lovelace',
+ title: 'Head of Content',
+ bio: null,
+ photoUrl: null,
+ sameAs: ['https://www.linkedin.com/in/ada'],
+ userId: ME,
+ createdBy: OTHER,
+ defaultFor: [ACME],
+ },
+ {
+ id: BOB,
+ name: 'Bob Stone',
+ title: null,
+ bio: null,
+ photoUrl: null,
+ sameAs: [],
+ userId: OTHER,
+ createdBy: OTHER,
+ defaultFor: [],
+ },
+ {
+ id: CAL,
+ name: 'Cal Freelance',
+ title: null,
+ bio: null,
+ photoUrl: null,
+ sameAs: [],
+ userId: null,
+ createdBy: ME,
+ defaultFor: [],
+ },
+ ],
+ brands: [{ id: ACME, name: 'Acme' }],
+ me: { id: ME, role },
+ };
+}
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ for (const fn of [...Object.values(actions), toast.success, toast.error]) fn.mockReset();
+ actions.getContentAuthors.mockResolvedValue(workspace('analyst'));
+ actions.saveContentAuthor.mockResolvedValue({ id: BOB });
+ actions.deleteContentAuthor.mockResolvedValue(undefined);
+ actions.setDefaultAuthor.mockResolvedValue(undefined);
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => root.unmount());
+ container.remove();
+ document.body.replaceChildren();
+});
+
+async function render() {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">
+ <AuthorsSection />
+ </NextIntlClientProvider>,
+ );
+ });
+}
+
+const buttons = (name: string) =>
+ [...document.body.querySelectorAll('button')].filter((b) => b.textContent === name);
+const row = (name: string) =>
+ [...container.querySelectorAll('li')].find((li) => li.textContent?.includes(name))!;
+const trigger = () => container.querySelector<HTMLElement>(`[aria-labelledby="default-${ACME}"]`)!;
+const isMe = () =>
+ [...document.querySelectorAll<HTMLElement>('[role="checkbox"]')].find((c) =>
+ c.closest('label')?.textContent?.includes('This author is me'),
+ )!;
+
+async function click(el: Element | undefined) {
+ await act(async () => {
+ (el as HTMLElement).click();
+ });
+}
+
+function type(input: HTMLInputElement | HTMLTextAreaElement, value: string) {
+ const proto = Object.getPrototypeOf(input) as object;
+ Object.getOwnPropertyDescriptor(proto, 'value')!.set!.call(input, value);
+ input.dispatchEvent(new Event('input', { bubbles: true }));
+}
+
+describe('AuthorsSection', () => {
+ it('lists the authors with their profiles and brand defaults, and the real-people note', async () => {
+ await render();
+ expect(container.textContent).toContain(
+ "Real people only. Content Agent can't add, edit or invent authors.",
+ );
+ expect(row('Ada Lovelace').textContent).toContain('(you)');
+ expect(row('Ada Lovelace').textContent).toContain('1 profile link · Default for Acme');
+ expect(row('Bob Stone').textContent).toContain('No profile links');
+ expect(trigger().querySelector('[data-slot="select-value"]')!.textContent).toBe('Ada Lovelace');
+ });
+
+ it('lets a member edit the author they are and the ones they added, not the defaults', async () => {
+ await render();
+ expect(row('Ada Lovelace').querySelectorAll('button')).toHaveLength(2);
+ expect(row('Cal Freelance').querySelectorAll('button')).toHaveLength(2);
+ expect(row('Bob Stone').querySelectorAll('button')).toHaveLength(0);
+ expect(trigger().hasAttribute('data-disabled')).toBe(true);
+ expect(container.textContent).toContain('Admins and managers set the defaults.');
+ });
+
+ it("lets a manager pick a brand's default author, or its team byline", async () => {
+ actions.getContentAuthors.mockResolvedValue(workspace('manager'));
+ await render();
+ expect(trigger().hasAttribute('data-disabled')).toBe(false);
+
+ await click(trigger());
+ const options = [...document.querySelectorAll<HTMLElement>('[role="option"]')];
+ expect(options.map((o) => o.textContent)).toEqual([
+ 'Acme Team',
+ 'Ada Lovelace',
+ 'Bob Stone',
+ 'Cal Freelance',
+ ]);
+ // Base UI picks the highlighted option: the pointer moves onto it first.
+ const team = options.find((o) => o.textContent === 'Acme Team')!;
+ await act(async () => {
+ team.dispatchEvent(new MouseEvent('mousemove', { bubbles: true }));
+ });
+ await click(team);
+ expect(actions.setDefaultAuthor).toHaveBeenCalledWith(ACME, null);
+ });
+
+ it('adds an author, one profile link per line, and holds a link that is not https', async () => {
+ actions.getContentAuthors.mockResolvedValue({
+ ...workspace('analyst'),
+ authors: workspace('analyst').authors.filter((a) => a.id !== ADA),
+ });
+ await render();
+ await click(buttons('Add author')[0]);
+ const name = document.querySelector<HTMLInputElement>('#author-name')!;
+ const links = document.querySelector<HTMLTextAreaElement>('#author-links')!;
+ const save = () => buttons('Save author')[0];
+
+ expect(save().disabled).toBe(true);
+ await act(async () => type(name, 'Grace Hopper'));
+ await act(async () => type(links, 'https://github.com/grace\nhttp://example.com'));
+ expect(save().disabled).toBe(true);
+ expect(links.getAttribute('aria-invalid')).toBe('true');
+ expect(document.body.textContent).toContain(
+ "http://example.com isn't an https link of up to 300 characters.",
+ );
+
+ await act(async () => type(links, 'https://github.com/grace\n\n https://x.com/grace '));
+ expect(save().disabled).toBe(false);
+ await click(isMe());
+ await click(save());
+ expect(actions.saveContentAuthor).toHaveBeenCalledWith({
+ name: 'Grace Hopper',
+ title: '',
+ bio: '',
+ photoUrl: '',
+ sameAs: ['https://github.com/grace', 'https://x.com/grace'],
+ isMe: true,
+ });
+ expect(actions.getContentAuthors).toHaveBeenCalledTimes(2);
+ });
+
+ it("can't make the member a second author", async () => {
+ await render();
+ await click(buttons('Add author')[0]);
+ expect(isMe().hasAttribute('data-disabled')).toBe(true);
+ expect(document.body.textContent).toContain("You're another author already.");
+ });
+
+ it('says so when the server finds the member is another author already', async () => {
+ actions.saveContentAuthor.mockResolvedValue({ error: 'already_author' });
+ await render();
+ await click(row('Cal Freelance').querySelector('button')!);
+ await click(buttons('Save author')[0]);
+ expect(toast.error).toHaveBeenCalledWith(
+ 'You\'re another author already. Untick "This author is me" or edit your own author.',
+ );
+ expect(actions.getContentAuthors).toHaveBeenCalledTimes(1);
+ });
+
+ it('edits an author with its id, and keeps it as the member', async () => {
+ await render();
+ await click(row('Ada Lovelace').querySelector('button')!);
+ expect(document.querySelector<HTMLInputElement>('#author-name')!.value).toBe('Ada Lovelace');
+ await click(buttons('Save author')[0]);
+ expect(actions.saveContentAuthor).toHaveBeenCalledWith(
+ expect.objectContaining({ id: ADA, name: 'Ada Lovelace', isMe: true }),
+ );
+ });
+
+ it("lets an admin edit a colleague's author without taking it over", async () => {
+ actions.getContentAuthors.mockResolvedValue(workspace('admin'));
+ await render();
+ await click(row('Bob Stone').querySelector('button')!);
+ expect(isMe().hasAttribute('data-disabled')).toBe(true);
+ expect(document.body.textContent).toContain('Another member is this author.');
+ await click(buttons('Save author')[0]);
+ expect(actions.saveContentAuthor).toHaveBeenCalledWith(
+ expect.objectContaining({ id: BOB, isMe: false }),
+ );
+ });
+
+ it('says so when a save fails', async () => {
+ actions.saveContentAuthor.mockRejectedValue(new Error('forbidden'));
+ await render();
+ await click(row('Cal Freelance').querySelector('button')!);
+ await click(buttons('Save author')[0]);
+ expect(toast.error).toHaveBeenCalledWith("Couldn't save the author.");
+ });
+
+ it('asks before removing an author', async () => {
+ await render();
+ await click(row('Cal Freelance').querySelectorAll('button')[1]);
+ expect(document.body.textContent).toContain('Remove Cal Freelance?');
+ expect(actions.deleteContentAuthor).not.toHaveBeenCalled();
+
+ await click(buttons('Remove').find((b) => !container.contains(b)));
+ expect(actions.deleteContentAuthor).toHaveBeenCalledWith(CAL);
+ });
+
+ it("says so when the authors can't be read", async () => {
+ actions.getContentAuthors.mockResolvedValue(null);
+ await render();
+ expect(container.textContent).toContain("Couldn't load the authors.");
+ });
+});
diff --git a/web/src/components/settings/authors-section.tsx b/web/src/components/settings/authors-section.tsx
new file mode 100644
index 000000000..36968419c
--- /dev/null
+++ b/web/src/components/settings/authors-section.tsx
@@ -0,0 +1,512 @@
+'use client';
+
+import { useCallback, useEffect, useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { toast } from 'sonner';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
+import { Checkbox } from '@/components/ui/checkbox';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { LoadingDots } from '@/components/ui/loading-dots';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { Textarea } from '@/components/ui/textarea';
+import {
+ deleteContentAuthor,
+ getContentAuthors,
+ saveContentAuthor,
+ setDefaultAuthor,
+} from '@/lib/actions/content-authors';
+import {
+ MAX_LINK_LENGTH,
+ MAX_PROFILES,
+ type AuthorInput,
+ type AuthorsRead,
+ type ContentAuthor,
+} from '@/lib/content/authors';
+import { cn } from '@/lib/utils';
+
+/** The organization byline in a brand's default select: no author. */
+const ORGANIZATION = 'organization';
+
+const isHttps = (value: string) => /^https:\/\/\S+$/.test(value);
+
+/**
+ * Settings › Authors (Content Editor Quality spec §9, CE-037): the real
+ * people the workspace's pages are by. Anyone adds one; whoever added it,
+ * the author themself or an admin edits or deletes it; admins and managers
+ * pick each brand's default. "Real people only. Content Agent can't add,
+ * edit or invent authors."
+ */
+export function AuthorsSection() {
+ const t = useTranslations('settings.authors');
+ const tCommon = useTranslations('common');
+ const [read, setRead] = useState<AuthorsRead | null>(null);
+ const [failed, setFailed] = useState(false);
+ const [editing, setEditing] = useState<ContentAuthor | 'new' | null>(null);
+ const [removing, setRemoving] = useState<ContentAuthor | null>(null);
+ const [removeOpen, setRemoveOpen] = useState(false);
+ const [busy, setBusy] = useState(false);
+ /** A brand's default being saved: shown at once, the select held until it lands. */
+ const [picking, setPicking] = useState<Record<string, string>>({});
+
+ const load = useCallback(async () => {
+ try {
+ const next = await getContentAuthors();
+ setRead(next);
+ setFailed(!next);
+ } catch {
+ setFailed(true);
+ }
+ }, []);
+ useEffect(() => {
+ void load();
+ }, [load]);
+
+ const me = read?.me.id;
+ const canEdit = (author: ContentAuthor) =>
+ !!read && (author.userId === me || author.createdBy === me || read.me.role === 'admin');
+ const canSetDefaults = read?.me.role === 'admin' || read?.me.role === 'manager';
+ const defaultOf = (brandId: string) =>
+ picking[brandId] ??
+ read?.authors.find((a) => a.defaultFor.includes(brandId))?.id ??
+ ORGANIZATION;
+
+ const remove = async (author: ContentAuthor) => {
+ setBusy(true);
+ try {
+ await deleteContentAuthor(author.id);
+ toast.success(t('removed', { name: author.name }));
+ setRemoveOpen(false);
+ await load();
+ } catch {
+ toast.error(t('removeFailed'));
+ } finally {
+ setBusy(false);
+ }
+ };
+ const pickDefault = async (brandId: string, value: string) => {
+ setPicking((prev) => ({ ...prev, [brandId]: value }));
+ try {
+ await setDefaultAuthor(brandId, value === ORGANIZATION ? null : value);
+ await load();
+ } catch {
+ toast.error(t('defaultFailed'));
+ } finally {
+ setPicking((prev) => {
+ const next = { ...prev };
+ delete next[brandId];
+ return next;
+ });
+ }
+ };
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('title')}</CardTitle>
+ <CardDescription>{t('description')}</CardDescription>
+ </CardHeader>
+ <CardContent className="space-y-5">
+ <p className="rounded-lg border border-dashed px-3 py-2 text-xs text-muted-foreground">
+ {t('realPeople')}
+ </p>
+
+ {!read && !failed && (
+ <p className="text-sm text-muted-foreground" aria-busy="true">
+ <LoadingDots />
+ <span className="sr-only">{t('loading')}</span>
+ </p>
+ )}
+ {failed && (
+ <p className="text-sm text-destructive">
+ {t('loadFailed')}{' '}
+ <button type="button" className="underline" onClick={() => void load()}>
+ {tCommon('retry')}
+ </button>
+ </p>
+ )}
+
+ {read && (
+ <>
+ {read.authors.length === 0 ? (
+ <p className="text-sm text-muted-foreground">{t('empty')}</p>
+ ) : (
+ <ul className="divide-y rounded-xl border">
+ {read.authors.map((author) => (
+ <li key={author.id} className="flex items-start gap-3 px-3 py-2.5">
+ <AuthorPhoto author={author} />
+ <div className="min-w-0 flex-1">
+ <p className="text-sm font-medium [overflow-wrap:anywhere]">
+ {author.name}
+ {author.userId === me && (
+ <span className="ml-1.5 text-xs font-normal text-muted-foreground">
+ {t('you')}
+ </span>
+ )}
+ </p>
+ {author.title && (
+ <p className="text-xs text-muted-foreground [overflow-wrap:anywhere]">
+ {author.title}
+ </p>
+ )}
+ <p className="mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]">
+ {t('profiles', { count: author.sameAs.length })}
+ {author.defaultFor.length > 0 && (
+ <>
+ {' · '}
+ {t('defaultFor', {
+ brands: read.brands
+ .filter((b) => author.defaultFor.includes(b.id))
+ .map((b) => b.name)
+ .join(', '),
+ })}
+ </>
+ )}
+ </p>
+ </div>
+ {canEdit(author) && (
+ <span className="flex shrink-0 gap-1">
+ <Button variant="ghost" size="sm" onClick={() => setEditing(author)}>
+ {t('edit')}
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-destructive hover:text-destructive"
+ onClick={() => {
+ setRemoving(author);
+ setRemoveOpen(true);
+ }}
+ >
+ {t('remove')}
+ </Button>
+ </span>
+ )}
+ </li>
+ ))}
+ </ul>
+ )}
+ <Button size="sm" onClick={() => setEditing('new')}>
+ {t('add')}
+ </Button>
+
+ {read.brands.length > 0 && (
+ <section className="space-y-2" aria-label={t('defaultsTitle')}>
+ <h3 className="text-sm font-medium">{t('defaultsTitle')}</h3>
+ <p className="text-xs text-muted-foreground">{t('defaultsHint')}</p>
+ <ul className="space-y-2">
+ {read.brands.map((brand) => {
+ const items = [
+ {
+ value: ORGANIZATION,
+ label: t('organizationByline', { brand: brand.name }),
+ },
+ ...read.authors.map((a) => ({ value: a.id, label: a.name })),
+ ];
+ return (
+ <li key={brand.id} className="flex flex-wrap items-center gap-x-3 gap-y-1">
+ <span
+ id={`default-${brand.id}`}
+ className="min-w-32 text-sm [overflow-wrap:anywhere]"
+ >
+ {brand.name}
+ </span>
+ <Select
+ items={items}
+ value={defaultOf(brand.id)}
+ disabled={!canSetDefaults || brand.id in picking}
+ onValueChange={(value) => {
+ if (value && value !== defaultOf(brand.id)) {
+ void pickDefault(brand.id, value);
+ }
+ }}
+ >
+ <SelectTrigger
+ size="sm"
+ className="w-60 max-w-full"
+ aria-labelledby={`default-${brand.id}`}
+ >
+ <SelectValue className="truncate" />
+ </SelectTrigger>
+ <SelectContent>
+ {items.map((item) => (
+ <SelectItem key={item.value} value={item.value}>
+ {item.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ {brand.id in picking && <LoadingDots className="text-muted-foreground" />}
+ </li>
+ );
+ })}
+ </ul>
+ {!canSetDefaults && (
+ <p className="text-xs text-muted-foreground">{t('defaultsManagers')}</p>
+ )}
+ </section>
+ )}
+ </>
+ )}
+ </CardContent>
+
+ <Dialog open={removeOpen} onOpenChange={(next) => !next && !busy && setRemoveOpen(false)}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{t('removeTitle', { name: removing?.name ?? '' })}</DialogTitle>
+ <DialogDescription>{t('removeDescription')}</DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" disabled={busy} />}>
+ {tCommon('cancel')}
+ </DialogClose>
+ <Button
+ variant="destructive"
+ disabled={busy}
+ onClick={() => removing && void remove(removing)}
+ >
+ {busy && <LoadingDots className="mr-1.5" />}
+ {t('remove')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ <AuthorDialog
+ author={editing === 'new' ? null : editing}
+ open={editing !== null}
+ me={me ?? null}
+ meTaken={
+ !!read?.authors.some(
+ (a) => a.userId === me && (editing === 'new' || a.id !== editing?.id),
+ )
+ }
+ onClose={() => setEditing(null)}
+ onSaved={async () => {
+ setEditing(null);
+ await load();
+ }}
+ />
+ </Card>
+ );
+}
+
+/** The author's photo, or their initials. */
+function AuthorPhoto({ author }: { author: ContentAuthor }) {
+ const initials = author.name
+ .split(/\s+/)
+ .slice(0, 2)
+ .map((part) => part[0]?.toUpperCase() ?? '')
+ .join('');
+ return author.photoUrl ? (
+ // eslint-disable-next-line @next/next/no-img-element -- any https host the person names
+ <img
+ src={author.photoUrl}
+ alt=""
+ className="h-8 w-8 shrink-0 rounded-full object-cover"
+ referrerPolicy="no-referrer"
+ />
+ ) : (
+ <span
+ aria-hidden
+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-muted-foreground"
+ >
+ {initials}
+ </span>
+ );
+}
+
+/** Add or edit an author: name, title, a short bio, profile links, a photo. */
+function AuthorDialog({
+ author,
+ open,
+ me,
+ meTaken,
+ onClose,
+ onSaved,
+}: {
+ author: ContentAuthor | null;
+ open: boolean;
+ me: string | null;
+ /** The member is another author already: they can't be this one too. */
+ meTaken: boolean;
+ onClose: () => void;
+ onSaved: () => Promise<void>;
+}) {
+ const t = useTranslations('settings.authors');
+ const tCommon = useTranslations('common');
+ const [form, setForm] = useState<{
+ name: string;
+ title: string;
+ bio: string;
+ photoUrl: string;
+ links: string;
+ isMe: boolean;
+ }>({ name: '', title: '', bio: '', photoUrl: '', links: '', isMe: false });
+ const [saving, setSaving] = useState(false);
+ useEffect(() => {
+ if (!open) return;
+ setForm({
+ name: author?.name ?? '',
+ title: author?.title ?? '',
+ bio: author?.bio ?? '',
+ photoUrl: author?.photoUrl ?? '',
+ links: author?.sameAs.join('\n') ?? '',
+ isMe: !!author && author.userId === me,
+ });
+ }, [open, author, me]);
+
+ // Another member's author stays theirs; only they unlink it.
+ const someoneElse = !!author?.userId && author.userId !== me;
+ const links = form.links
+ .split('\n')
+ .map((l) => l.trim())
+ .filter(Boolean);
+ const badLink = links.find((l) => !isHttps(l) || l.length > MAX_LINK_LENGTH);
+ const linksInvalid = !!badLink || links.length > MAX_PROFILES;
+ const photo = form.photoUrl.trim();
+ const badPhoto = photo !== '' && !isHttps(photo);
+ const invalid = !form.name.trim() || linksInvalid || badPhoto || saving;
+
+ const save = async () => {
+ setSaving(true);
+ try {
+ const input: AuthorInput = {
+ ...(author ? { id: author.id } : {}),
+ name: form.name,
+ title: form.title,
+ bio: form.bio,
+ photoUrl: form.photoUrl,
+ sameAs: links,
+ isMe: form.isMe,
+ };
+ const saved = await saveContentAuthor(input);
+ if ('error' in saved) {
+ toast.error(t('alreadyAuthor'));
+ return;
+ }
+ toast.success(t('saved', { name: form.name.trim() }));
+ await onSaved();
+ } catch {
+ toast.error(t('saveFailed'));
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={(next) => !next && !saving && onClose()}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{author ? t('editTitle') : t('addTitle')}</DialogTitle>
+ <DialogDescription>{t('realPeople')}</DialogDescription>
+ </DialogHeader>
+ <div className="space-y-3 py-1">
+ <div className="space-y-1.5">
+ <Label htmlFor="author-name">{t('fields.name')}</Label>
+ <Input
+ id="author-name"
+ value={form.name}
+ maxLength={120}
+ onChange={(e) => setForm({ ...form, name: e.target.value })}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="author-title">{t('fields.title')}</Label>
+ <Input
+ id="author-title"
+ value={form.title}
+ maxLength={120}
+ placeholder={t('fields.titleHint')}
+ onChange={(e) => setForm({ ...form, title: e.target.value })}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="author-bio">{t('fields.bio')}</Label>
+ <Textarea
+ id="author-bio"
+ value={form.bio}
+ maxLength={400}
+ rows={3}
+ placeholder={t('fields.bioHint')}
+ onChange={(e) => setForm({ ...form, bio: e.target.value })}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="author-links">{t('fields.links')}</Label>
+ <Textarea
+ id="author-links"
+ value={form.links}
+ rows={3}
+ placeholder="https://www.linkedin.com/in/…"
+ aria-invalid={linksInvalid}
+ aria-describedby="author-links-hint"
+ onChange={(e) => setForm({ ...form, links: e.target.value })}
+ />
+ <p
+ id="author-links-hint"
+ className={cn(
+ 'text-xs [overflow-wrap:anywhere]',
+ linksInvalid ? 'text-destructive' : 'text-muted-foreground',
+ )}
+ >
+ {badLink
+ ? t('fields.linkInvalid', { link: badLink, max: MAX_LINK_LENGTH })
+ : t('fields.linksHint', { max: MAX_PROFILES })}
+ </p>
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="author-photo">{t('fields.photo')}</Label>
+ <Input
+ id="author-photo"
+ value={form.photoUrl}
+ placeholder="https://"
+ aria-invalid={badPhoto}
+ onChange={(e) => setForm({ ...form, photoUrl: e.target.value })}
+ />
+ </div>
+ <div className="space-y-1">
+ <label className="flex items-center gap-2 text-sm">
+ <Checkbox
+ checked={form.isMe}
+ disabled={someoneElse || (meTaken && !form.isMe)}
+ onCheckedChange={(checked) => setForm({ ...form, isMe: checked === true })}
+ />
+ {t('fields.isMe')}
+ </label>
+ {(someoneElse || meTaken) && (
+ <p className="pl-6 text-xs text-muted-foreground">
+ {someoneElse ? t('fields.isSomeoneElse') : t('fields.isMeTaken')}
+ </p>
+ )}
+ </div>
+ </div>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" disabled={saving} />}>
+ {tCommon('cancel')}
+ </DialogClose>
+ <Button onClick={() => void save()} disabled={invalid}>
+ {saving && <LoadingDots className="mr-1.5" />}
+ {t('save')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/web/src/lib/actions/content-authors.test.ts b/web/src/lib/actions/content-authors.test.ts
new file mode 100644
index 000000000..f434ac718
--- /dev/null
+++ b/web/src/lib/actions/content-authors.test.ts
@@ -0,0 +1,234 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * Settings › Authors (CE-037): what the actions write. RLS decides who may
+ * change an author or a brand's default; no row back is a refusal.
+ */
+
+const ME = '11111111-1111-4111-8111-111111111111';
+const ORG = '22222222-2222-4222-8222-222222222222';
+const ADA = 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa';
+const ACME = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc';
+const OTHER = '33333333-3333-4333-8333-333333333333';
+
+interface Call {
+ table: string;
+ op: string;
+ row?: unknown;
+ filters: [string, unknown][];
+}
+let calls: Call[] = [];
+/** What a write or read of each table answers. */
+let answers: Record<string, { data: unknown; error: null | { message: string; code?: string } }> =
+ {};
+
+function builder(table: string) {
+ const call: Call = { table, op: 'select', filters: [] };
+ calls.push(call);
+ const answer = () => answers[`${table}.${call.op}`] ?? { data: null, error: null };
+ const chain = {
+ select: () => chain,
+ insert: (row: unknown) => Object.assign(call, { op: 'insert', row }) && chain,
+ update: (row: unknown) => Object.assign(call, { op: 'update', row }) && chain,
+ upsert: (row: unknown) => Object.assign(call, { op: 'upsert', row }) && chain,
+ delete: () => Object.assign(call, { op: 'delete' }) && chain,
+ eq: (column: string, value: unknown) => {
+ call.filters.push([column, value]);
+ return chain;
+ },
+ order: () => chain,
+ single: async () => answer(),
+ maybeSingle: async () => answer(),
+ then: (resolve: (value: unknown) => unknown) => Promise.resolve(answer()).then(resolve),
+ };
+ return chain;
+}
+
+vi.mock('@/lib/supabase/server', () => ({
+ createClient: vi.fn(async () => ({
+ auth: { getUser: async () => ({ data: { user: { id: ME } } }) },
+ from: builder,
+ })),
+}));
+
+const { deleteContentAuthor, getContentAuthors, saveContentAuthor, setDefaultAuthor } =
+ await import('./content-authors');
+
+const writes = () => calls.filter((c) => c.op !== 'select');
+
+beforeEach(() => {
+ calls = [];
+ answers = {
+ 'profiles.select': { data: { organization_id: ORG, role: 'analyst' }, error: null },
+ 'content_authors.insert': { data: { id: ADA }, error: null },
+ 'content_authors.update': { data: { id: ADA }, error: null },
+ 'content_authors.delete': { data: [{ id: ADA }], error: null },
+ };
+});
+
+describe('getContentAuthors', () => {
+ it("reads the workspace's authors with the brands each is the default for", async () => {
+ answers['content_authors.select'] = {
+ data: [
+ {
+ id: ADA,
+ name: 'Ada',
+ title: null,
+ bio: null,
+ photo_url: null,
+ same_as: null,
+ user_id: ME,
+ created_by: OTHER,
+ },
+ ],
+ error: null,
+ };
+ answers['brands.select'] = { data: [{ id: ACME, name: 'Acme' }], error: null };
+ answers['content_author_defaults.select'] = {
+ data: [{ brand_id: ACME, author_id: ADA }],
+ error: null,
+ };
+ const read = await getContentAuthors();
+ expect(read).toEqual({
+ authors: [
+ {
+ id: ADA,
+ name: 'Ada',
+ title: null,
+ bio: null,
+ photoUrl: null,
+ sameAs: [],
+ userId: ME,
+ createdBy: OTHER,
+ defaultFor: [ACME],
+ },
+ ],
+ brands: [{ id: ACME, name: 'Acme' }],
+ me: { id: ME, role: 'analyst' },
+ });
+ });
+
+ it('reads nothing for a member without an organization', async () => {
+ answers['profiles.select'] = { data: { organization_id: null, role: 'admin' }, error: null };
+ expect(await getContentAuthors()).toBeNull();
+ });
+});
+
+describe('saveContentAuthor', () => {
+ it('adds an author to the workspace, as the member when it is them', async () => {
+ await saveContentAuthor({
+ name: ' Ada Lovelace ',
+ title: '',
+ sameAs: ['https://x.com/ada', 'https://x.com/ada'],
+ isMe: true,
+ });
+ expect(writes()).toEqual([
+ {
+ table: 'content_authors',
+ op: 'insert',
+ row: {
+ name: 'Ada Lovelace',
+ title: null,
+ bio: null,
+ photo_url: null,
+ same_as: ['https://x.com/ada'],
+ user_id: ME,
+ organization_id: ORG,
+ created_by: ME,
+ },
+ filters: [],
+ },
+ ]);
+ });
+
+ it('adds someone who is no member without a link', async () => {
+ await saveContentAuthor({ name: 'Grace' });
+ expect(writes()[0].row).not.toHaveProperty('user_id');
+ });
+
+ it('says so when the member is another author already', async () => {
+ answers['content_authors.insert'] = {
+ data: null,
+ error: { message: 'duplicate key', code: '23505' },
+ };
+ expect(await saveContentAuthor({ name: 'Ada', isMe: true })).toEqual({
+ error: 'already_author',
+ });
+ });
+
+ it('refuses a link that is not https, writing nothing', async () => {
+ await expect(saveContentAuthor({ name: 'Ada', sameAs: ['http://x.com/ada'] })).rejects.toThrow(
+ 'invalid',
+ );
+ await expect(
+ saveContentAuthor({ name: 'Ada', photoUrl: 'javascript:alert(1)' }),
+ ).rejects.toThrow('invalid');
+ expect(writes()).toEqual([]);
+ });
+
+ it("unlinks the member's own author in the same save when they untick it", async () => {
+ answers['content_authors.select'] = { data: { user_id: ME }, error: null };
+ await saveContentAuthor({ id: ADA, name: 'Ada', isMe: false });
+ expect(writes()).toEqual([
+ {
+ table: 'content_authors',
+ op: 'update',
+ row: { name: 'Ada', title: null, bio: null, photo_url: null, same_as: [], user_id: null },
+ filters: [['id', ADA]],
+ },
+ ]);
+ });
+
+ it("keeps another member's link when an admin saves their author", async () => {
+ answers['content_authors.select'] = { data: { user_id: OTHER }, error: null };
+ await saveContentAuthor({ id: ADA, name: 'Ada', isMe: false });
+ expect(writes()).toHaveLength(1);
+ expect(writes()[0].row).not.toHaveProperty('user_id');
+ });
+
+ it('fails when RLS lets no row through', async () => {
+ answers['content_authors.select'] = { data: { user_id: null }, error: null };
+ answers['content_authors.update'] = { data: null, error: null };
+ await expect(saveContentAuthor({ id: ADA, name: 'Ada' })).rejects.toThrow('forbidden');
+ answers['content_authors.select'] = { data: null, error: null };
+ await expect(saveContentAuthor({ id: ADA, name: 'Ada' })).rejects.toThrow('not_found');
+ });
+});
+
+describe('deleteContentAuthor', () => {
+ it('deletes by id, and fails when nothing was deleted', async () => {
+ await deleteContentAuthor(ADA);
+ expect(writes()).toEqual([{ table: 'content_authors', op: 'delete', filters: [['id', ADA]] }]);
+ answers['content_authors.delete'] = { data: [], error: null };
+ await expect(deleteContentAuthor(ADA)).rejects.toThrow('forbidden');
+ await expect(deleteContentAuthor('nope')).rejects.toThrow('invalid');
+ });
+});
+
+describe('setDefaultAuthor', () => {
+ it("sets a brand's default as the member, or clears it for the team byline", async () => {
+ await setDefaultAuthor(ACME, ADA);
+ expect(writes()[0]).toMatchObject({
+ table: 'content_author_defaults',
+ op: 'upsert',
+ row: { brand_id: ACME, author_id: ADA, updated_by: ME },
+ });
+ await setDefaultAuthor(ACME, null);
+ expect(writes()[1]).toEqual({
+ table: 'content_author_defaults',
+ op: 'delete',
+ filters: [['brand_id', ACME]],
+ });
+ });
+
+ it('refuses an id that is not one, and passes a refusal on', async () => {
+ await expect(setDefaultAuthor('acme', ADA)).rejects.toThrow('invalid');
+ await expect(setDefaultAuthor(ACME, 'ada')).rejects.toThrow('invalid');
+ expect(writes()).toEqual([]);
+ answers['content_author_defaults.upsert'] = {
+ data: null,
+ error: { message: 'new row violates row-level security policy' },
+ };
+ await expect(setDefaultAuthor(ACME, ADA)).rejects.toThrow(/row-level security/);
+ });
+});
diff --git a/web/src/lib/actions/content-authors.ts b/web/src/lib/actions/content-authors.ts
new file mode 100644
index 000000000..c5dd1487e
--- /dev/null
+++ b/web/src/lib/actions/content-authors.ts
@@ -0,0 +1,164 @@
+'use server';
+
+import { z } from 'zod';
+import { authorInput, type AuthorInput, type AuthorsRead } from '@/lib/content/authors';
+import { createClient } from '@/lib/supabase/server';
+
+/**
+ * Settings › Authors (Content Editor Quality spec §9, CE-037): the real
+ * people a page is by, in the workspace (content_authors, 00256). Anyone
+ * adds one; whoever added it, the author themself or an admin edits or
+ * deletes it (RLS); only a member links or unlinks themself; admins and
+ * managers set each brand's default. The Content Agent never writes them.
+ */
+
+/** The member is another author already (content_authors_member, a unique violation). */
+const ALREADY_AUTHOR = '23505';
+
+const AUTHOR_COLUMNS = 'id, name, title, bio, photo_url, same_as, user_id, created_by';
+
+/** The workspace's authors, its brands and the member reading; null when signed out. */
+export async function getContentAuthors(): Promise<AuthorsRead | null> {
+ const supabase = await createClient();
+ const { data: auth } = await supabase.auth.getUser();
+ if (!auth.user) return null;
+ const { data: profile, error: profileError } = await supabase
+ .from('profiles')
+ .select('organization_id, role')
+ .eq('id', auth.user.id)
+ .maybeSingle();
+ if (profileError) throw new Error(profileError.message);
+ if (!profile?.organization_id) return null;
+
+ const [authorsRes, brandsRes, defaultsRes] = await Promise.all([
+ supabase
+ .from('content_authors')
+ .select(AUTHOR_COLUMNS)
+ .eq('organization_id', profile.organization_id)
+ .order('name'),
+ supabase
+ .from('brands')
+ .select('id, name')
+ .eq('organization_id', profile.organization_id)
+ .order('name'),
+ supabase.from('content_author_defaults').select('brand_id, author_id'),
+ ]);
+ for (const res of [authorsRes, brandsRes, defaultsRes]) {
+ if (res.error) throw new Error(res.error.message);
+ }
+ const defaults = (defaultsRes.data ?? []) as { brand_id: string; author_id: string }[];
+ return {
+ authors: (authorsRes.data ?? []).map((row) => ({
+ id: row.id,
+ name: row.name,
+ title: row.title,
+ bio: row.bio,
+ photoUrl: row.photo_url,
+ sameAs: row.same_as ?? [],
+ userId: row.user_id,
+ createdBy: row.created_by,
+ defaultFor: defaults.filter((d) => d.author_id === row.id).map((d) => d.brand_id),
+ })),
+ brands: (brandsRes.data ?? []).map((b) => ({ id: b.id, name: b.name })),
+ me: { id: auth.user.id, role: profile.role ?? 'analyst' },
+ };
+}
+
+/**
+ * Adds an author, or saves one the member may edit; its id. `isMe` links the
+ * author to the member, and unticked unlinks it when it was them; another
+ * member's link stays.
+ */
+export async function saveContentAuthor(
+ input: AuthorInput,
+): Promise<{ id: string } | { error: 'already_author' }> {
+ const parsed = authorInput.safeParse(input);
+ if (!parsed.success) throw new Error('invalid');
+ const { id, name, title, bio, photoUrl, sameAs, isMe } = parsed.data;
+ const supabase = await createClient();
+ const { data: auth } = await supabase.auth.getUser();
+ if (!auth.user) throw new Error('not_found');
+ const values = {
+ name,
+ title: title || null,
+ bio: bio || null,
+ photo_url: photoUrl || null,
+ same_as: [...new Set(sameAs)],
+ };
+ if (id) {
+ const { data: current, error: readError } = await supabase
+ .from('content_authors')
+ .select('user_id')
+ .eq('id', id)
+ .maybeSingle();
+ if (readError) throw new Error(readError.message);
+ if (!current) throw new Error('not_found');
+ const link = isMe
+ ? { user_id: auth.user.id }
+ : current.user_id === auth.user.id
+ ? { user_id: null }
+ : {};
+ // RLS lets whoever added it, the author or an admin through; no row back is a refusal.
+ const { data, error } = await supabase
+ .from('content_authors')
+ .update({ ...values, ...link })
+ .eq('id', id)
+ .select('id')
+ .maybeSingle();
+ if (error?.code === ALREADY_AUTHOR) return { error: 'already_author' };
+ if (error) throw new Error(error.message);
+ if (!data) throw new Error('forbidden');
+ return { id: data.id };
+ }
+ const { data: profile, error: profileError } = await supabase
+ .from('profiles')
+ .select('organization_id')
+ .eq('id', auth.user.id)
+ .maybeSingle();
+ if (profileError) throw new Error(profileError.message);
+ if (!profile?.organization_id) throw new Error('not_found');
+ const { data, error } = await supabase
+ .from('content_authors')
+ .insert({
+ ...values,
+ ...(isMe ? { user_id: auth.user.id } : {}),
+ organization_id: profile.organization_id,
+ created_by: auth.user.id,
+ })
+ .select('id')
+ .single();
+ if (error?.code === ALREADY_AUTHOR) return { error: 'already_author' };
+ if (error) throw new Error(error.message);
+ return { id: data.id };
+}
+
+/** Deletes an author the member may delete: one they added or are, or any as an admin. */
+export async function deleteContentAuthor(id: string): Promise<void> {
+ if (!z.guid().safeParse(id).success) throw new Error('invalid');
+ const supabase = await createClient();
+ const { data, error } = await supabase.from('content_authors').delete().eq('id', id).select('id');
+ if (error) throw new Error(error.message);
+ if (!data?.length) throw new Error('forbidden');
+}
+
+/** A brand's default author, or none (the organization byline): admins and managers. */
+export async function setDefaultAuthor(brandId: string, authorId: string | null): Promise<void> {
+ if (!z.guid().safeParse(brandId).success || (authorId && !z.guid().safeParse(authorId).success)) {
+ throw new Error('invalid');
+ }
+ const supabase = await createClient();
+ const { data: auth } = await supabase.auth.getUser();
+ if (!auth.user) throw new Error('not_found');
+ const { error } = authorId
+ ? await supabase.from('content_author_defaults').upsert(
+ {
+ brand_id: brandId,
+ author_id: authorId,
+ updated_by: auth.user.id,
+ updated_at: new Date().toISOString(),
+ },
+ { onConflict: 'brand_id' },
+ )
+ : await supabase.from('content_author_defaults').delete().eq('brand_id', brandId);
+ if (error) throw new Error(error.message);
+}
diff --git a/web/src/lib/actions/team.test.ts b/web/src/lib/actions/team.test.ts
new file mode 100644
index 000000000..cfc788a22
--- /dev/null
+++ b/web/src/lib/actions/team.test.ts
@@ -0,0 +1,115 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * Removing a member: their profile leaves the organization, and the author
+ * they were (Settings › Authors) is no longer linked to them, since only they
+ * could unlink themself from a session.
+ */
+
+const ADMIN = '11111111-1111-4111-8111-111111111111';
+const ORG = '22222222-2222-4222-8222-222222222222';
+const MEMBER = '33333333-3333-4333-8333-333333333333';
+
+interface Call {
+ table: string;
+ op: string;
+ row?: unknown;
+ filters: [string, unknown][];
+}
+const sessionCalls: Call[] = [];
+let adminCalls: Call[] = [];
+/** What a write of each table answers through the service client. */
+let adminAnswers: Record<string, { data: unknown; error: null | { message: string } }> = {};
+
+function builder(calls: Call[], answerOf: (call: Call) => unknown) {
+ return (table: string) => {
+ const call: Call = { table, op: 'select', filters: [] };
+ calls.push(call);
+ const chain = {
+ select: () => chain,
+ update: (row: unknown) => Object.assign(call, { op: 'update', row }) && chain,
+ eq: (column: string, value: unknown) => {
+ call.filters.push([column, value]);
+ return chain;
+ },
+ single: async () => answerOf(call),
+ then: (resolve: (value: unknown) => unknown) => Promise.resolve(answerOf(call)).then(resolve),
+ };
+ return chain;
+ };
+}
+
+vi.mock('next/cache', () => ({ revalidatePath: vi.fn() }));
+vi.mock('@/lib/member-emails', () => ({ readMemberEmails: vi.fn() }));
+vi.mock('@/lib/guards/plan-guard', () => ({ enforceLimit: vi.fn(), getOrgPlan: vi.fn() }));
+vi.mock('@/lib/supabase/server', () => ({
+ createClient: vi.fn(async () => ({
+ auth: { getUser: async () => ({ data: { user: { id: ADMIN } } }) },
+ from: builder(sessionCalls, () => ({
+ data: { id: ADMIN, role: 'admin', organization_id: ORG },
+ error: null,
+ })),
+ })),
+}));
+vi.mock('@/lib/supabase/admin', () => ({
+ supabaseAdmin: {
+ from: (table: string) =>
+ builder(
+ adminCalls,
+ (call) => adminAnswers[`${call.table}.${call.op}`] ?? { data: null, error: null },
+ )(table),
+ },
+}));
+
+const { removeMember } = await import('./team');
+
+beforeEach(() => {
+ sessionCalls.length = 0;
+ adminCalls = [];
+ adminAnswers = {};
+});
+
+describe('removeMember', () => {
+ it('takes the member out of the organization and unlinks the author they were', async () => {
+ await removeMember(MEMBER);
+
+ expect(adminCalls).toEqual([
+ {
+ table: 'profiles',
+ op: 'update',
+ row: { organization_id: null },
+ filters: [
+ ['id', MEMBER],
+ ['organization_id', ORG],
+ ],
+ },
+ {
+ table: 'content_authors',
+ op: 'update',
+ row: { user_id: null },
+ filters: [
+ ['organization_id', ORG],
+ ['user_id', MEMBER],
+ ],
+ },
+ ]);
+ });
+
+ it('leaves the author linked when the member could not be removed', async () => {
+ adminAnswers['profiles.update'] = { data: null, error: { message: 'boom' } };
+
+ await expect(removeMember(MEMBER)).rejects.toThrow('boom');
+ expect(adminCalls.map((c) => c.table)).toEqual(['profiles']);
+ });
+
+ it('says so when the author link could not be cleared', async () => {
+ adminAnswers['content_authors.update'] = { data: null, error: { message: 'denied' } };
+
+ await expect(removeMember(MEMBER)).rejects.toThrow('denied');
+ });
+
+ it('refuses to remove yourself', async () => {
+ await expect(removeMember(ADMIN)).rejects.toThrow('You cannot remove yourself');
+ expect(adminCalls).toEqual([]);
+ });
+});
diff --git a/web/src/lib/actions/team.ts b/web/src/lib/actions/team.ts
index c0b74fc78..0f7d71315 100644
--- a/web/src/lib/actions/team.ts
+++ b/web/src/lib/actions/team.ts
@@ -355,6 +355,18 @@ export async function removeMember(userId: string) {
.eq('organization_id', profile.organization_id);
if (error) throw new Error(error.message);
+
+ // The member's author stays, but no longer as them: only they may unlink
+ // themself from a session, so once they're gone only the service client
+ // can, and the author would read "Another member is this author" forever.
+ // A retry finds the profile already out and clears the link then.
+ const { error: authorError } = await supabaseAdmin
+ .from('content_authors')
+ .update({ user_id: null })
+ .eq('organization_id', profile.organization_id)
+ .eq('user_id', userId);
+
+ if (authorError) throw new Error(authorError.message);
revalidatePath('/dashboard/settings');
}
diff --git a/web/src/lib/content/authors.ts b/web/src/lib/content/authors.ts
new file mode 100644
index 000000000..957faf40b
--- /dev/null
+++ b/web/src/lib/content/authors.ts
@@ -0,0 +1,58 @@
+import { z } from 'zod';
+
+/**
+ * The workspace's authors (Content Editor Quality spec §9, CE-037,
+ * content_authors 00256): what Settings › Authors reads and saves.
+ */
+
+export interface ContentAuthor {
+ id: string;
+ name: string;
+ title: string | null;
+ bio: string | null;
+ photoUrl: string | null;
+ /** Profile links (LinkedIn, X, GitHub…): Person schema's sameAs. */
+ sameAs: string[];
+ /** The member the author is, when they are one. */
+ userId: string | null;
+ /** The member who added it: they may edit it, as the author and admins may. */
+ createdBy: string | null;
+ /** The brands whose pages it is by when nobody picks another. */
+ defaultFor: string[];
+}
+
+export interface AuthorsRead {
+ authors: ContentAuthor[];
+ brands: { id: string; name: string }[];
+ /** The member reading: what they may change. */
+ me: { id: string; role: string };
+}
+
+/** The most profile links an author keeps (00256). */
+export const MAX_PROFILES = 10;
+/** The longest profile link; the table checks it too, with https (content_author_links_ok). */
+export const MAX_LINK_LENGTH = 300;
+
+const profileLink = z
+ .string()
+ .trim()
+ .max(MAX_LINK_LENGTH)
+ .refine((value) => /^https:\/\/[^\s]+$/.test(value), 'https');
+
+export const authorInput = z.object({
+ id: z.guid().optional(),
+ name: z.string().trim().min(1).max(120),
+ title: z.string().trim().max(120).optional().default(''),
+ bio: z.string().trim().max(400).optional().default(''),
+ photoUrl: z
+ .string()
+ .trim()
+ .max(2048)
+ .refine((value) => value === '' || /^https:\/\/[^\s]+$/.test(value), 'https')
+ .optional()
+ .default(''),
+ sameAs: z.array(profileLink).max(MAX_PROFILES).optional().default([]),
+ /** The author is the member saving it. */
+ isMe: z.boolean().optional().default(false),
+});
+export type AuthorInput = z.input<typeof authorInput>;
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index 69946caee..0e750ddb2 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -1083,6 +1083,92 @@ export type Database = {
},
]
}
+ content_author_defaults: {
+ Row: {
+ author_id: string
+ brand_id: string
+ updated_at: string
+ updated_by: string | null
+ }
+ Insert: {
+ author_id: string
+ brand_id: string
+ updated_at?: string
+ updated_by?: string | null
+ }
+ Update: {
+ author_id?: string
+ brand_id?: string
+ updated_at?: string
+ updated_by?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "content_author_defaults_author_id_fkey"
+ columns: ["author_id"]
+ isOneToOne: false
+ referencedRelation: "content_authors"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "content_author_defaults_brand_id_fkey"
+ columns: ["brand_id"]
+ isOneToOne: true
+ referencedRelation: "brands"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
+ content_authors: {
+ Row: {
+ bio: string | null
+ created_at: string
+ created_by: string | null
+ id: string
+ name: string
+ organization_id: string
+ photo_url: string | null
+ same_as: string[]
+ title: string | null
+ updated_at: string
+ user_id: string | null
+ }
+ Insert: {
+ bio?: string | null
+ created_at?: string
+ created_by?: string | null
+ id?: string
+ name: string
+ organization_id: string
+ photo_url?: string | null
+ same_as?: string[]
+ title?: string | null
+ updated_at?: string
+ user_id?: string | null
+ }
+ Update: {
+ bio?: string | null
+ created_at?: string
+ created_by?: string | null
+ id?: string
+ name?: string
+ organization_id?: string
+ photo_url?: string | null
+ same_as?: string[]
+ title?: string | null
+ updated_at?: string
+ user_id?: string | null
+ }
+ Relationships: [
+ {
+ foreignKeyName: "content_authors_organization_id_fkey"
+ columns: ["organization_id"]
+ isOneToOne: false
+ referencedRelation: "organizations"
+ referencedColumns: ["id"]
+ },
+ ]
+ }
content_agent_runs: {
Row: {
claimed_at: string | null