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.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(catalog): cap a workspace's catalog products by plan, 5,000 on Starter and 50,000 on Growth (Product Visibility, part 12) (#1647)
Cihan78a04e214afc
diff --git a/server/src/config/plans.js b/server/src/config/plans.jsindex 36138c19c..1f3be9ccd 100644--- a/server/src/config/plans.js+++ b/server/src/config/plans.js@@ -22,6 +22,7 @@ export const PLANS = {maxSiteAudits: -1,maxBotEventsPerMonth: -1,maxBotRawRecordsPerMonth: -1,+ maxCatalogProducts: -1,maxDailyOnDemand: -1,onDemandCooldownMinutes: 0,features: [@@ -70,6 +71,11 @@ export const PLANS = {// Raw log records a month a Vercel drain or Logpush job may send// (AT-010, spec §6.3): Growth 20M, Enterprise 200M.maxBotRawRecordsPerMonth: 0,+ // Live catalog products a workspace's brands may have across their+ // sources (ECOM-019): Starter 5,000, Growth 50,000, Enterprise per+ // customer through plan_overrides; -1 = no cap. Products past it aren't+ // synced. Decided 2026-10-28.+ maxCatalogProducts: 5_000,maxDailyOnDemand: 3,onDemandCooldownMinutes: 15,allowedScrapers: ['chatgpt-web', 'copilot-web'],@@ -110,6 +116,7 @@ export const PLANS = {maxSiteAudits: 500,maxBotEventsPerMonth: 2_000_000,maxBotRawRecordsPerMonth: 20_000_000,+ maxCatalogProducts: 50_000,maxDailyOnDemand: 10,onDemandCooldownMinutes: 5,// API-model tracking (Claude) is not part of Growth — scraper engines@@ -156,6 +163,7 @@ export const PLANS = {maxSiteAudits: -1,maxBotEventsPerMonth: 20_000_000,maxBotRawRecordsPerMonth: 200_000_000,+ maxCatalogProducts: -1,maxDailyOnDemand: -1,onDemandCooldownMinutes: 0,// API-model tracking (Claude) is a per-customer opt-in on Enterprise:diff --git a/server/src/lib/catalog/__fixtures__/fake-db.js b/server/src/lib/catalog/__fixtures__/fake-db.jsindex adf75ad8c..6016943cc 100644--- a/server/src/lib/catalog/__fixtures__/fake-db.js+++ b/server/src/lib/catalog/__fixtures__/fake-db.js@@ -67,6 +67,7 @@ export function fakeDb({ maxRows = Infinity } = {}) {payload: null,returning: null,one: null,+ count: null,order: [],};const run = () => {@@ -84,6 +85,8 @@ export function fakeDb({ maxRows = Infinity } = {}) {});if (state.op === 'select') {const found = all.filter(match).sort(compareBy([...state.order, { column: 'id' }]));+ // A count only, as `select(…, { count: 'exact', head: true })` asks.+ if (state.count === 'head') return { data: null, count: found.length, error: null };const [start, end] = state.range ?? [0, found.length];const data = found.slice(start, end + 1).slice(0, state.one ? undefined : maxRows);if (state.one) return { data: data[0] ?? null, error: null };@@ -137,9 +140,11 @@ export function fakeDb({ maxRows = Infinity } = {}) {throw new Error(`unexpected ${state.op}`);};const builder = {- // After a write, the rows it wrote, as PostgREST returns them.- select: () => {+ // After a write, the rows it wrote, as PostgREST returns them. A+ // `{ head: true }` select asks for the count only.+ select: (_columns, options) => {if (state.op !== 'select') state.returning = true;+ if (options?.head) state.count = 'head';return builder;},eq: (column, value) => {diff --git a/server/src/lib/catalog/sources.js b/server/src/lib/catalog/sources.jsindex 0c4a2548c..1d547ec45 100644--- a/server/src/lib/catalog/sources.js+++ b/server/src/lib/catalog/sources.js@@ -1,11 +1,12 @@import supabaseAdmin from '../../config/supabase.js';-import { isSubscriptionActive } from '../../config/plans.js';+import { isCloud, isSubscriptionActive } from '../../config/plans.js';import { connectorFor, isSignIn, isStore } from '../../connectors/index.js';import { ConnectorHttpError, requestJson } from '../../connectors/http.js';import { FeedFormatError, parseFeed } from '../feeds/index.js';import { isComposioConfigured } from '../composio.js';import { PageFetchError } from '../safe-fetch.js';import { logger } from '../logger.js';+import { PlanLimitError, getCatalogProductCap } from '../plan-guard.js';import { queueShoppingCheck } from '../shopping-check.js';import { CredentialsKeyError, readCredentials } from './credentials.js';import { saveItemIssues } from './issues.js';@@ -20,6 +21,9 @@ import { syncCatalog } from './sync.js';* shows. A store is read with its saved sign-in (credentials.js); a* platform like Google Merchant Center with the workspace's own sign-in* (sign-in.js), and the issues it reports per item are kept (issues.js).+ * On the managed cloud, the plan caps the workspace's live products+ * (ECOM-019): a source keeps what's left of it, and records how many it+ * couldn't.*//** Feeds and stores read again after this long, by the daily run. */@@ -55,6 +59,7 @@ const STORE_WORDS = {/** Why a sync failed, in words a person can act on. No page, feed or store text. */export function failureOf(err, connector = null) {if (err instanceof FeedFormatError) return { status: 'format_error', error: err.message };+ if (err instanceof PlanLimitError) return { status: 'failed', error: err.message };if (err instanceof ConnectorHttpError && isSignIn(connector)) {// The workspace's sign-in, not the source's: it's reconnected in Settings › Integrations.if (err.code === 'auth') {@@ -129,6 +134,44 @@ export function redact(message, credentials) {return text;}+/**+ * The live products a source may keep (ECOM-019): its workspace's cap less+ * the live products of the workspace's other sources, on any of its brands.+ * `room` is Infinity (and `cap` -1) on a self-hosted server, or for a plan+ * without a cap.+ */+export async function productRoom(+ source,+ { db = supabaseAdmin, capOf = getCatalogProductCap } = {},+) {+ const none = { room: Infinity, cap: -1 };+ if (!isCloud()) return none;+ const { data: brand, error } = await db+ .from('brands')+ .select('organization_id')+ .eq('id', source.brand_id)+ .maybeSingle();+ if (error) throw new Error(`brands read: ${error.message}`);+ const cap = await capOf(brand?.organization_id ?? null);+ if (cap < 0) return none;+ const { data: brands, error: brandsError } = await db+ .from('brands')+ .select('id')+ .eq('organization_id', brand.organization_id);+ if (brandsError) throw new Error(`brands read: ${brandsError.message}`);+ const { count, error: countError } = await db+ .from('catalog_products')+ .select('id', { count: 'exact', head: true })+ .in(+ 'brand_id',+ (brands ?? []).map((b) => b.id),+ )+ .neq('source', sourceKey(source.id))+ .is('removed_at', null);+ if (countError) throw new Error(`catalog_products count: ${countError.message}`);+ return { room: Math.max(0, cap - (count ?? 0)), cap };+}+async function record(db, id, at, outcome) {const { error } = await db.from('catalog_sources')@@ -155,10 +198,11 @@ async function record(db, id, at, outcome) {* checked against it (shopping-check.js), behind the answer.** @param {{ id: string, brand_id: string, kind: string, format: string, url?: string|null, account?: string|null }} source- * @param {{ text?: string, db?: object, now?: Date, fetch?: Function, request?: Function, signInRequest?: Function, connectors?: object, readMs?: number, afterSync?: Function }} [options]+ * @param {{ text?: string, db?: object, now?: Date, fetch?: Function, request?: Function, signInRequest?: Function, connectors?: object, readMs?: number, capOf?: Function, afterSync?: Function }} [options]* `fetch` (a feed's), `request` (a store's HTTP client), `signInRequest`- * (the workspace sign-in's, sign-in.js), `connectors`, `readMs` and- * `afterSync` (the shopping check's queue) are the tests' stand-ins+ * (the workspace sign-in's, sign-in.js), `connectors`, `readMs`, `capOf`+ * (the plan's product cap, by organization) and `afterSync` (the shopping+ * check's queue) are the tests' stand-ins*/export async function syncSource(source, { afterSync = queueShoppingCheck, ...options } = {}) {if (reading.has(source.id)) {@@ -189,6 +233,7 @@ async function syncOnce(signInRequest = workspaceSignIn,connectors,readMs = STORE_READ_MS,+ capOf,},) {const at = now.toISOString();@@ -232,9 +277,11 @@ async function syncOnce(}}if (!outcome) {+ const { room, cap } = await productRoom(source, { db, capOf });const counts = await syncCatalog(source.brand_id, sourceKey(source.id), parsed.items, {db,now,+ room,});outcome = {status: 'ok',@@ -245,6 +292,8 @@ async function syncOnce(errors: parsed.errors.slice(0, ERRORS_KEPT).map((e) => e.message),products: counts.products,variants: counts.variants,+ // Products past the plan's cap, not kept (ECOM-019), and the cap.+ ...(counts.overLimit ? { overLimit: counts.overLimit, limit: cap } : {}),},};// An item listed again (another language or feed label), kept once: not skipped.diff --git a/server/src/lib/catalog/sources.test.js b/server/src/lib/catalog/sources.test.jsindex 92fdfa47c..b5389e3bb 100644--- a/server/src/lib/catalog/sources.test.js+++ b/server/src/lib/catalog/sources.test.js@@ -5,6 +5,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';// The module reaches the supabase admin client at import time, whose config// hard-exits when SUPABASE_* env is absent (as in CI).vi.mock('../../config/supabase.js', () => ({ default: {} }));+// The plan's product cap (ECOM-019): none unless a test sets one.+const getCatalogProductCap = vi.hoisted(() => vi.fn(async () => -1));+vi.mock('../plan-guard.js', async (importOriginal) => ({+ ...(await importOriginal()),+ getCatalogProductCap,+}));import { ConnectorHttpError } from '../../connectors/http.js';import { logger } from '../logger.js';@@ -12,7 +18,15 @@ import { PageFetchError } from '../safe-fetch.js';import { fakeDb } from './__fixtures__/fake-db.js';import { saveCredentials } from './credentials.js';import feedUrl, { FEED_MAX_BYTES, FEED_TYPES } from '../../connectors/feed-url/index.js';-import { failureOf, redact, sourceKey, sweepCatalogSources, syncSource } from './sources.js';+import { PlanLimitError } from '../plan-guard.js';+import {+ failureOf,+ productRoom,+ redact,+ sourceKey,+ sweepCatalogSources,+ syncSource,+} from './sources.js';const fixture = (name) =>readFileSync(new URL(`../feeds/__fixtures__/${name}`, import.meta.url), 'utf8');@@ -541,3 +555,102 @@ describe('sweepCatalogSources', () => {]);});});++describe("the plan's product cap (ECOM-019)", () => {+ const OTHER = sourceKey('9b8d6a1e-2a3c-4d5e-8f90-123456789abc');+ beforeEach(() => {+ getCatalogProductCap.mockReset().mockResolvedValue(3);+ fake+ .rows('brands')+ .push(+ { id: 'brand-1', organization_id: 'org-1' },+ { id: 'brand-2', organization_id: 'org-1' },+ { id: 'brand-x', organization_id: 'org-2' },+ );+ fake.rows('catalog_products').push(+ // The workspace's other brand: one live, one removed.+ { id: 'p1', brand_id: 'brand-2', source: OTHER, external_id: 'X1', removed_at: null },+ { id: 'p2', brand_id: 'brand-2', source: OTHER, external_id: 'X2', removed_at: NOW },+ // Another workspace's, and this source's own: neither counts.+ { id: 'p3', brand_id: 'brand-x', source: OTHER, external_id: 'X3', removed_at: null },+ {+ id: 'p4',+ brand_id: 'brand-1',+ source: sourceKey(SOURCE_ID),+ external_id: 'OLD',+ removed_at: null,+ },+ );+ });++ it("leaves a source the workspace's cap less its other live products, on the cloud only", async () => {+ expect(await productRoom(source, { db: fake.db })).toEqual({ room: Infinity, cap: -1 });+ process.env.IS_CLOUD = 'true';+ expect(await productRoom(source, { db: fake.db })).toEqual({ room: 2, cap: 3 });+ expect(getCatalogProductCap).toHaveBeenCalledWith('org-1');+ getCatalogProductCap.mockResolvedValue(-1);+ expect(await productRoom(source, { db: fake.db })).toEqual({ room: Infinity, cap: -1 });+ });++ it('keeps what there is room for, and records how many it could not, with the cap', async () => {+ process.env.IS_CLOUD = 'true';+ getCatalogProductCap.mockResolvedValue(2);+ const fetch = vi.fn().mockResolvedValue({ html: fixture('google-feed.xml') });+ const outcome = await syncSource(source, { db: fake.db, now: NOW, fetch });+ expect(outcome).toMatchObject({+ status: 'ok',+ counts: { products: { added: 1 }, overLimit: 1, limit: 2 },+ });+ expect(kept().last_counts).toMatchObject({ overLimit: 1, limit: 2 });+ });++ it("caps a Google Merchant Center account's products too, read with the workspace sign-in", async () => {+ process.env.IS_CLOUD = 'true';+ vi.stubEnv('COMPOSIO_API_KEY', 'test-composio-key');+ vi.stubEnv('COMPOSIO_GMC_AUTH_CONFIG_ID', 'ac_gmc');+ try {+ const gmcSource = {+ id: '3c8d6a1e-2a3c-4d5e-8f90-123456789abc',+ brand_id: 'brand-1',+ kind: 'merchant_center',+ format: 'auto',+ url: null,+ account: '123',+ };+ fake.rows('catalog_sources').push({ ...gmcSource, last_synced_at: null });+ // The feed fixture's two products, as the account's.+ const gmc = {+ kind: 'merchant_center',+ label: 'Google Merchant Center',+ signIn: 'google-merchant-center',+ hosts: ['merchantapi.googleapis.com'],+ readCatalog: vi.fn(async (_source, { request }) => {+ await request('https://merchantapi.googleapis.com/products/v1/accounts/123/products');+ return feedUrl.readCatalog(source, {+ fetch: vi.fn().mockResolvedValue({ html: fixture('google-feed.xml') }),+ });+ }),+ };+ const outcome = await syncSource(gmcSource, {+ db: fake.db,+ now: NOW,+ signInRequest: () => vi.fn(async () => ({ status: 200, headers: {}, data: null })),+ connectors: { merchant_center: gmc },+ });+ // A cap of 3, less the workspace's two other live products (p1, p4).+ expect(outcome).toMatchObject({+ status: 'ok',+ counts: { products: { added: 1 }, overLimit: 1, limit: 3 },+ });+ } finally {+ vi.unstubAllEnvs();+ }+ });++ it("records a workspace without an active subscription in the plan's words", () => {+ expect(failureOf(new PlanLimitError('An active subscription is required.', 402))).toEqual({+ status: 'failed',+ error: 'An active subscription is required.',+ });+ });+});diff --git a/server/src/lib/catalog/sync.js b/server/src/lib/catalog/sync.jsindex 6fa2ab516..d9c62452f 100644--- a/server/src/lib/catalog/sync.js+++ b/server/src/lib/catalog/sync.js@@ -20,6 +20,11 @@ import { chunkIds } from '../chunked-in.js';** Values are clipped to the columns' limits, and an address that isn't* http(s) is left out, so one odd product doesn't fail the sync.+ *+ * The plan caps a workspace's live products (ECOM-019): a source keeps+ * `room` of them at most (keptWithin), the rest aren't written, and one in+ * the catalog already is marked removed, as if gone from the source, until+ * there's room again.*/const PAGE = 1000;@@ -120,6 +125,29 @@ export function catalogRecords(items) {return { products, variants };}+/**+ * The products a source keeps within `room` (ECOM-019): those live in the+ * catalog already first, so a product tracked stays tracked, then the new+ * ones in the source's order. In the source's order, with how many are over.+ *+ * @param {{ external_id: string }[]} products+ * @param {{ external_id: string, removed_at: string|null }[]} kept the source's rows+ * @param {number} room Infinity for no cap+ */+export function keptWithin(products, kept, room) {+ if (products.length <= room) return { products, overLimit: 0 };+ const live = new Set(kept.filter((row) => !row.removed_at).map((row) => row.external_id));+ const first = [+ ...products.filter((p) => live.has(p.external_id)),+ ...products.filter((p) => !live.has(p.external_id)),+ ].slice(0, Math.max(0, room));+ const keep = new Set(first.map((p) => p.external_id));+ return {+ products: products.filter((p) => keep.has(p.external_id)),+ overLimit: products.length - keep.size,+ };+}+async function readAll(db, table, columns, brandId, source) {const rows = [];for (let start = 0; ; start += PAGE) {@@ -185,22 +213,23 @@ async function replaceIn(db, table, productIds, rows) {* @param {string} brandId* @param {string} source e.g. 'feed', 'csv', 'shopify'* @param {import('../feeds/item.js').FeedItem[]} items- * @param {{ db?: object, now?: Date }} [options]+ * @param {{ db?: object, now?: Date, room?: number }} [options] `room`: the live+ * products the source may keep (ECOM-019), Infinity for no cap*/export async function syncCatalog(brandId,source,items,- { db = supabaseAdmin, now = new Date() } = {},+ { db = supabaseAdmin, now = new Date(), room = Infinity } = {},) {const at = now.toISOString();- const { products, variants } = catalogRecords(items);+ const records = catalogRecords(items);const counts = {products: { added: 0, changed: 0, removed: 0, unchanged: 0 },variants: { added: 0, changed: 0, removed: 0, unchanged: 0 },};- // Products: write the new, the changed and the returned.+ // Products: write the new, the changed and the returned, within the plan's cap.const keptProducts = await readAll(db,'catalog_products',@@ -208,6 +237,10 @@ export async function syncCatalog(brandId,source,);+ const { products, overLimit } = keptWithin(records.products, keptProducts, room);+ if (overLimit) counts.overLimit = overLimit;+ const within = new Set(products.map((p) => p.external_id));+ const variants = records.variants.filter((v) => within.has(v.product_external_id));const productBy = new Map(keptProducts.map((row) => [row.external_id, row]));const productIds = new Map(keptProducts.map((row) => [row.external_id, row.id]));const productWrites = [];diff --git a/server/src/lib/catalog/sync.test.js b/server/src/lib/catalog/sync.test.jsindex db825f818..075a7653d 100644--- a/server/src/lib/catalog/sync.test.js+++ b/server/src/lib/catalog/sync.test.js@@ -7,7 +7,7 @@ vi.mock('../../config/supabase.js', () => ({ default: {} }));import { parseCsvFeed, parseGoogleFeedXml } from '../feeds/index.js';import { fakeDb } from './__fixtures__/fake-db.js';-import { catalogRecords, groupTitle, syncCatalog } from './sync.js';+import { catalogRecords, groupTitle, keptWithin, syncCatalog } from './sync.js';const BRAND = 'brand-1';const feed = () =>@@ -229,3 +229,60 @@ describe('syncCatalog', () => {expect(fake.writes).toEqual([]);});});++describe('keptWithin', () => {+ const products = ['A', 'B', 'C', 'D'].map((external_id) => ({ external_id }));++ it('keeps the products live in the catalog first, then the new ones in order', () => {+ const kept = [+ { external_id: 'C', removed_at: null },+ { external_id: 'A', removed_at: '2026-10-01T00:00:00Z' },+ ];+ expect(keptWithin(products, kept, 2)).toEqual({+ products: [{ external_id: 'A' }, { external_id: 'C' }],+ overLimit: 2,+ });+ expect(keptWithin(products, kept, 0)).toEqual({ products: [], overLimit: 4 });+ expect(keptWithin(products, kept, Infinity)).toEqual({ products, overLimit: 0 });+ });+});++describe("syncCatalog within the plan's product cap (ECOM-019)", () => {+ it("writes the products there's room for, and none of the rest's variants", async () => {+ const counts = await syncCatalog(BRAND, 'feed', feed(), { db: fake.db, room: 1 });+ expect(counts).toEqual({+ products: { added: 1, changed: 0, removed: 0, unchanged: 0 },+ variants: { added: 3, changed: 0, removed: 0, unchanged: 0 },+ overLimit: 1,+ });+ expect(fake.rows('catalog_products').map((p) => p.external_id)).toEqual(['TR-100']);+ expect(fake.rows('catalog_variants').every((v) => v.external_id.startsWith('TR-100'))).toBe(+ true,+ );+ });++ it('keeps a tracked product tracked when the source lists another first', async () => {+ await syncCatalog(BRAND, 'feed', feed(), { db: fake.db, room: 1 });+ const counts = await syncCatalog(BRAND, 'feed', [...feed()].reverse(), {+ db: fake.db,+ room: 1,+ });+ expect(counts.overLimit).toBe(1);+ expect(counts.products).toMatchObject({ added: 0, removed: 0 });+ expect(fake.rows('catalog_products').map((p) => p.external_id)).toEqual(['TR-100']);+ });++ it('marks the products past a smaller cap removed, and brings them back with room', async () => {+ await syncCatalog(BRAND, 'feed', feed(), { db: fake.db });+ const at = new Date('2026-10-28T00:00:00Z');+ const counts = await syncCatalog(BRAND, 'feed', feed(), { db: fake.db, now: at, room: 0 });+ expect(counts.overLimit).toBe(2);+ expect(counts.products.removed).toBe(2);+ expect(fake.rows('catalog_products').every((p) => p.removed_at === at.toISOString())).toBe(+ true,+ );+ const back = await syncCatalog(BRAND, 'feed', feed(), { db: fake.db });+ expect(back.overLimit).toBeUndefined();+ expect(fake.rows('catalog_products').every((p) => p.removed_at === null)).toBe(true);+ });+});diff --git a/server/src/lib/plan-guard.js b/server/src/lib/plan-guard.jsindex 77f5a0927..2a6f4c172 100644--- a/server/src/lib/plan-guard.js+++ b/server/src/lib/plan-guard.js@@ -1030,6 +1030,16 @@ export async function getBotCaps(orgId, { readOnly = false } = {}) {};}+/**+ * Live catalog products an organization's brands may have across their+ * sources (ECOM-019): -1 = no cap. Throws PlanLimitError (402) without an+ * active subscription, like every billed feature.+ */+export async function getCatalogProductCap(orgId) {+ const plan = await resolveOrgPlanByOrgId(orgId);+ return plan.limits.maxCatalogProducts ?? -1;+}+/*** Express middleware that attaches req.plan from the authenticated user.* Must run after auth middleware (req.user must exist).diff --git a/server/src/lib/plan-guard.test.js b/server/src/lib/plan-guard.test.jsindex 66bf027ed..c04bfe2d9 100644--- a/server/src/lib/plan-guard.test.js+++ b/server/src/lib/plan-guard.test.js@@ -125,3 +125,19 @@ describe('relevance allowance per plan', () => {expect(PLANS.self_hosted.limits.relevanceMonthlyBudgetUsd).toBe(-1);});});++describe('catalog products per plan (ECOM-019)', () => {+ it('is 5,000 / 50,000, set per Enterprise customer, uncapped on self-hosted', async () => {+ const { PLANS } = await import('../config/plans.js');+ expect(PLANS.starter.limits.maxCatalogProducts).toBe(5_000);+ expect(PLANS.growth.limits.maxCatalogProducts).toBe(50_000);+ expect(PLANS.enterprise.limits.maxCatalogProducts).toBe(-1);+ expect(PLANS.self_hosted.limits.maxCatalogProducts).toBe(-1);+ expect(+ applyPlanOverrides(PLANS.enterprise, {+ plan: 'enterprise',+ plan_overrides: { maxCatalogProducts: 250_000 },+ }).limits.maxCatalogProducts,+ ).toBe(250_000);+ });+});diff --git a/web/messages/en.json b/web/messages/en.jsonindex 1e8186d51..8262a8c1b 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -8993,6 +8993,8 @@"issues": "{count, plural, one {# with an issue} other {# with issues}}","repeated": "{count, plural, one {# listed again, kept once} other {# listed again, kept once}}","skipped": "{count, plural, one {# product was skipped} other {# products were skipped}}",+ "overLimit": "{count, plural, one {# product isn't} other {# products aren't}} in the catalog: your plan tracks up to {limit, plural, one {# product} other {# products}} across your brands.",+ "upgrade": "Upgrade","syncNow": "Sync now","remove": "Remove","removeConfirm": "Remove this source? Its products leave the catalog.",diff --git a/web/src/components/settings/catalog-sources-card.test.tsx b/web/src/components/settings/catalog-sources-card.test.tsxindex 2a95a0321..e6a36b192 100644--- a/web/src/components/settings/catalog-sources-card.test.tsx+++ b/web/src/components/settings/catalog-sources-card.test.tsx@@ -36,6 +36,13 @@ vi.mock('@/stores/use-brand-store', () => ({}));const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() }));vi.mock('sonner', () => ({ toast }));+vi.mock('@/i18n/navigation', () => ({+ Link: ({ href, children, ...rest }: { href: string; children: React.ReactNode }) => (+ <a href={href} {...rest}>+ {children}+ </a>+ ),+}));const { CatalogSourcesCard } = await import('./catalog-sources-card');@@ -304,6 +311,25 @@ describe('CatalogSourcesCard', () => {);});+ it("says how many products the plan's cap left out, with Upgrade for managers (ECOM-019)", async () => {+ // Starter's cap (5,000).+ const capped = { ...FEED, lastCounts: { ...FEED.lastCounts!, overLimit: 1240, limit: 5000 } };+ listCatalogSources.mockResolvedValue([capped]);+ await render();+ expect(container.textContent).toContain(+ "1,240 products aren't in the catalog: your plan tracks up to 5,000 products across your brands. Upgrade",+ );+ expect(container.querySelector('a[href="/dashboard/settings/billing"]')?.textContent).toBe(+ 'Upgrade',+ );+ act(() => root.unmount());+ root = createRoot(container);+ role.canManage = false;+ await render();+ expect(container.textContent).toContain("1,240 products aren't in the catalog");+ expect(container.querySelector('a[href="/dashboard/settings/billing"]')).toBeNull();+ });+it("shows the sources, not to change, to members who aren't admins or managers", async () => {role.canManage = false;await render();diff --git a/web/src/components/settings/catalog-sources-card.tsx b/web/src/components/settings/catalog-sources-card.tsxindex 63ea83a27..5d61b94bd 100644--- a/web/src/components/settings/catalog-sources-card.tsx+++ b/web/src/components/settings/catalog-sources-card.tsx@@ -8,6 +8,7 @@ import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { Skeleton } from '@/components/ui/skeleton';+import { Link } from '@/i18n/navigation';import { useUserRole } from '@/hooks/use-user-role';import { useUpgradeGate } from '@/components/providers/upgrade-gate';import { addFeedSource, listCatalogSources, removeCatalogSource } from '@/lib/actions/catalog';@@ -40,7 +41,8 @@ export interface CatalogSourcesRead {* A Google Merchant Center account (#1270) is added above, under its* Integrations card, and listed here with how many of its products* Merchant Center reports issues for. Admins and managers add, sync and- * remove; members see the sources and how they went.+ * remove; members see the sources and how they went, and the products past+ * the plan's cap left out (ECOM-019).** `refreshKey`: changed by the page to read the sources again (an account* added elsewhere). `onSources` hears each read, for the Merchant Center@@ -343,6 +345,25 @@ export function CatalogSourcesCard({</ul></details>)}+ {source.lastStatus === 'ok' && (source.lastCounts?.overLimit ?? 0) > 0 && (+ <p className="text-xs text-amber-700 dark:text-amber-400">+ {t('overLimit', {+ count: source.lastCounts!.overLimit!,+ limit: source.lastCounts!.limit ?? 0,+ })}+ {canManage && (+ <>+ {' '}+ <Link+ href="/dashboard/settings/billing"+ className="font-medium underline underline-offset-2"+ >+ {t('upgrade')}+ </Link>+ </>+ )}+ </p>+ )}{signingIn === source.id && connectorOf(source.kind) && (<StoreSignInFormconnector={connectorOf(source.kind)!}diff --git a/web/src/config/plans.ts b/web/src/config/plans.tsindex 997e0d245..48f1d4277 100644--- a/web/src/config/plans.ts+++ b/web/src/config/plans.ts@@ -87,6 +87,13 @@ export interface PlanLimits {* Enterprise 200M; 0 = locked, -1 = no cap.*/maxBotRawRecordsPerMonth: number;+ /**+ * Live catalog products a workspace's brands may have across their sources+ * (ECOM-019). Starter 5,000, Growth 50,000, Enterprise set per customer+ * via organizations.plan_overrides; -1 = no cap. The API's catalog sync+ * stops adding products past it.+ */+ maxCatalogProducts: number;maxDailyOnDemand: number;onDemandCooldownMinutes: number;features: readonly Feature[];@@ -135,6 +142,7 @@ export const PLANS: Record<PlanId, Plan> = {maxSiteAudits: -1,maxBotEventsPerMonth: -1,maxBotRawRecordsPerMonth: -1,+ maxCatalogProducts: -1,maxDailyOnDemand: -1,onDemandCooldownMinutes: 0,features: [@@ -180,6 +188,7 @@ export const PLANS: Record<PlanId, Plan> = {maxSiteAudits: 100,maxBotEventsPerMonth: 0,maxBotRawRecordsPerMonth: 0,+ maxCatalogProducts: 5_000,maxDailyOnDemand: 3,onDemandCooldownMinutes: 15,allowedScrapers: ['chatgpt-web', 'copilot-web'],@@ -228,6 +237,7 @@ export const PLANS: Record<PlanId, Plan> = {maxSiteAudits: 500,maxBotEventsPerMonth: 2_000_000,maxBotRawRecordsPerMonth: 20_000_000,+ maxCatalogProducts: 50_000,maxDailyOnDemand: 10,onDemandCooldownMinutes: 5,// API-model tracking (Claude) is not part of Growth — scraper engines@@ -276,6 +286,7 @@ export const PLANS: Record<PlanId, Plan> = {maxSiteAudits: -1,maxBotEventsPerMonth: 20_000_000,maxBotRawRecordsPerMonth: 200_000_000,+ maxCatalogProducts: -1,maxDailyOnDemand: -1,onDemandCooldownMinutes: 0,// API-model tracking (Claude) is a per-customer opt-in on Enterprise:diff --git a/web/src/lib/catalog.ts b/web/src/lib/catalog.tsindex c6aeae189..a2bc5db58 100644--- a/web/src/lib/catalog.ts+++ b/web/src/lib/catalog.ts@@ -47,6 +47,10 @@ export interface CatalogCounts {* syncs before it was counted.*/repeated?: number;+ /** Products past the plan's cap, not in the catalog (ECOM-019); absent when none. */+ overLimit?: number;+ /** The plan's cap on the workspace's products, when some were past it. */+ limit?: number;}export interface CatalogSource {