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(cms): mark a page published once its Wix post is live, read when the Library opens and daily (#1331) (#1750)
Cihan8039e0a07d44
diff --git a/server/src/lib/cms/wix-status.js b/server/src/lib/cms/wix-status.jsnew file mode 100644index 000000000..a3358e13b--- /dev/null+++ b/server/src/lib/cms/wix-status.js@@ -0,0 +1,184 @@+import supabaseAdmin from '../../config/supabase.js';+import { isSubscriptionActive } from '../../config/plans.js';+import { logger } from '../logger.js';+import { credentialsConfigured } from '../catalog/credentials.js';+import { markDeliveryPublished } from '../content-published.js';+import { readCmsCredentials } from './credentials.js';+import { WixError, readDraftPost, webAddress } from './wix.js';++/**+ * Pages sent to Wix, published there since (Send to CMS #1331, phase 2;+ * 00372): nothing calls back when a post goes live, so Ansvisor reads the+ * posts its sends made. A send writes a draft, or a live post's draft+ * version (cms/wix-delivery.js), so a post published with no changes left+ * unpublished was put live after the send: it is marked published at the+ * post's address. One still holding unpublished changes isn't yet; a post+ * deleted, or gone, closes its send. Read when the Library opens (a brand's+ * newest sends, throttled by its route) and once a day for all, as+ * WordPress's are (wordpress-status.js).+ */++/** Posts the Library's check reads: the newest sends. The daily sweep reads the rest. */+export const POSTS_ON_DEMAND = 10;+/** Posts the daily sweep reads a brand. */+export const POSTS_DAILY = 100;+/** Sends older than this aren't read again: a draft left that long stays one. */+const LOOK_BACK_MS = 60 * 24 * 60 * 60 * 1000;+/** Post reads that fail in a row before a check stops: the site is down. */+const FAILURES_IN_A_ROW = 3;+/** Connections the daily sweep reads, shuffled so a deadline doesn't leave the same brands out. */+const SWEEP_CONNECTIONS = 1000;+const SWEEP_DEADLINE_MS = 10 * 60 * 1000;++const none = { checked: 0, published: [] };++/** The API key was refused while reading: Settings asks for a new one (as the send read it). */+async function markRefused(connection) {+ const { error } = await supabaseAdmin+ .from('brand_cms_connections')+ .update({ status: 'auth_failed', updated_at: new Date().toISOString() })+ .eq('id', connection.id)+ .eq('provider', 'wix')+ .eq('updated_at', connection.updated_at);+ if (error) logger.warn({ err: error }, '[wix-status] refusal not kept');+}++/** A send whose post is gone from Wix: closed. The page's next send makes a new post. */+async function closeRemoved(send) {+ const { error } = await supabaseAdmin+ .from('content_draft_deliveries')+ .update({ status: 'failed', error: 'Removed in Wix' })+ .eq('id', send.id)+ .eq('status', 'sent');+ if (error) {+ logger.warn({ err: error, deliveryId: send.id }, '[wix-status] removal not kept');+ }+}++const logged = (err) => ({ name: err?.name, code: err?.code });++/** A post's address, when it's a web address; one Wix gives without its scheme gets https://. */+const linkOf = (post) => webAddress(post?.url);++/**+ * Reads the brand's pages sent to Wix and not yet seen live (each page's+ * latest such send to the connected site, newest first, up to `limit`), and+ * marks the published ones published. One post's failure doesn't stop the+ * others (three in a row do); a key refused stops the check and marks the+ * connection.+ *+ * @returns {Promise<{ checked: number, published: { draftId: string|null, url: string }[] }>}+ */+export async function checkWixPublished(brandId, { limit = POSTS_ON_DEMAND, request, base } = {}) {+ if (!credentialsConfigured()) return none;+ const { data: connection, error } = await supabaseAdmin+ .from('brand_cms_connections')+ .select('id, brand_id, status, site_id, updated_at')+ .eq('brand_id', brandId)+ .eq('provider', 'wix')+ .maybeSingle();+ if (error) throw new Error(error.message);+ if (!connection || connection.status !== 'connected' || !connection.site_id) return none;++ // The connected site's sends only: a post on a site connected before isn't read with this key.+ const { data: rows, error: rowsError } = await supabaseAdmin+ .from('content_draft_deliveries')+ .select('id, draft_id, status, published_url, external_id, target_collection, sent_at')+ .eq('brand_id', brandId)+ .eq('target', 'wix')+ .eq('target_collection', connection.site_id)+ .eq('status', 'sent')+ .not('external_id', 'is', null)+ .gte('sent_at', new Date(Date.now() - LOOK_BACK_MS).toISOString())+ .order('sent_at', { ascending: false })+ .limit(limit * 4);+ if (rowsError) throw new Error(rowsError.message);+ // A page's latest send: an earlier one made the same post, updated since, or one replaced.+ const seen = new Set();+ const sends = [];+ for (const row of rows ?? []) {+ const key = row.draft_id ?? row.id;+ if (seen.has(key)) continue;+ seen.add(key);+ sends.push(row);+ if (sends.length === limit) break;+ }+ if (!sends.length) return none;++ const credentials = await readCmsCredentials(connection.id);+ if (!credentials?.apiKey) {+ await markRefused(connection);+ return none;+ }+ const published = [];+ let checked = 0;+ let failures = 0;+ for (const send of sends) {+ let post;+ try {+ post = await readDraftPost(connection.site_id, credentials.apiKey, send.external_id, {+ request,+ base,+ });+ } catch (err) {+ if (err instanceof WixError && err.code === 'auth_failed') {+ await markRefused(connection);+ return { checked, published };+ }+ logger.warn({ err: logged(err), deliveryId: send.id }, '[wix-status] post not read');+ if (++failures === FAILURES_IN_A_ROW) break;+ continue;+ }+ failures = 0;+ checked++;+ if (!post || post.status === 'DELETED') {+ await closeRemoved(send);+ continue;+ }+ // Published, its changes too: a live post's draft version waits for the person.+ const url = post.status === 'PUBLISHED' && !post.pending ? linkOf(post) : null;+ if (!url) continue;+ await markDeliveryPublished(send, url);+ published.push({ draftId: send.draft_id, url });+ }+ return { checked, published };+}++/**+ * The daily check, for brands with Wix connected (on an active+ * subscription), in a shuffled order so the deadline leaves out different+ * brands each day; one brand's failure is logged and the next goes on.+ */+export async function sweepWixPublished() {+ if (!credentialsConfigured()) return { brands: 0, published: 0 };+ const started = Date.now();+ const { data, error } = await supabaseAdmin+ .from('brand_cms_connections')+ .select('brand_id, brands!inner(is_demo, organizations!inner(subscription_status))')+ // A demo brand (00380) never reaches Wix.+ .eq('brands.is_demo', false)+ .eq('provider', 'wix')+ .eq('status', 'connected')+ .limit(SWEEP_CONNECTIONS);+ if (error) throw new Error(`brand_cms_connections read: ${error.message}`);+ const due = (data ?? []).filter((row) =>+ isSubscriptionActive(row.brands?.organizations?.subscription_status),+ );+ for (let i = due.length - 1; i > 0; i--) {+ const j = Math.floor(Math.random() * (i + 1));+ [due[i], due[j]] = [due[j], due[i]];+ }+ let brands = 0;+ let published = 0;+ for (const row of due) {+ if (Date.now() - started > SWEEP_DEADLINE_MS) break;+ try {+ const result = await checkWixPublished(row.brand_id, { limit: POSTS_DAILY });+ brands++;+ published += result.published.length;+ } catch (err) {+ logger.error({ err: logged(err), brandId: row.brand_id }, '[wix-status] check failed');+ }+ }+ return { brands, published };+}diff --git a/server/src/lib/cms/wix-status.test.js b/server/src/lib/cms/wix-status.test.jsnew file mode 100644index 000000000..cee03cd60--- /dev/null+++ b/server/src/lib/cms/wix-status.test.js@@ -0,0 +1,196 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++/**+ * Pages sent to Wix, published there since (Send to CMS #1331, phase 2;+ * 00372): read from the posts the sends made, marked published at the+ * post's address once its changes are live too.+ */++const db = {+ connection: null,+ sends: [],+ brands: [],+ queries: [],+ updates: [],+ connectionReads: [],+};+vi.mock('../../config/supabase.js', () => ({+ default: {+ from: (table) => {+ const q = { table, filters: [] };+ const result = () => {+ if (q.update) {+ db.updates.push({ table, update: q.update, filters: q.filters });+ return { data: null, error: null };+ }+ if (table === 'brand_cms_connections') {+ if (!q.single) db.connectionReads.push(q.filters);+ return { data: q.single ? db.connection : db.brands, error: null };+ }+ db.queries.push(q);+ return { data: db.sends, error: null };+ };+ const chain = {+ select: () => chain,+ eq: (col, value) => (q.filters.push(['eq', col, value]), chain),+ not: (col, op, value) => (q.filters.push(['not', col, op, value]), chain),+ gte: (col, value) => (q.filters.push(['gte', col, value]), chain),+ order: () => chain,+ limit: () => chain,+ update: (row) => ((q.update = row), chain),+ maybeSingle: async () => ((q.single = true), result()),+ then: (resolve) => resolve(result()),+ };+ return chain;+ },+ },+}));+const configured = vi.hoisted(() => ({ on: true }));+vi.mock('../catalog/credentials.js', () => ({ credentialsConfigured: () => configured.on }));+let credentials;+vi.mock('./credentials.js', () => ({ readCmsCredentials: async () => credentials }));+const markDeliveryPublished = vi.fn();+vi.mock('../content-published.js', () => ({+ markDeliveryPublished: (...args) => markDeliveryPublished(...args),+}));+const readPost = vi.fn();+vi.mock('./wix.js', async (importOriginal) => ({+ ...(await importOriginal()),+ readDraftPost: (...args) => readPost(...args),+}));+const logged = [];+vi.mock('../logger.js', () => ({+ logger: { warn: () => {}, error: (...args) => logged.push(JSON.stringify(args)) },+}));++const { checkWixPublished, sweepWixPublished } = await import('./wix-status.js');+const { WixError } = await import('./wix.js');++const SITE = '2f8a1c3e-1111-4222-8333-944455556666';+const send = (id, draftId, over = {}) => ({+ id,+ draft_id: draftId,+ status: 'sent',+ published_url: null,+ external_id: `post-${id}`,+ target_collection: SITE,+ sent_at: '2026-10-28T10:00:00Z',+ ...over,+});+const post = (status, pending = false) => ({+ id: 'p',+ status,+ url: 'https://acme.example/post/cold-brew',+ pending,+});++beforeEach(() => {+ db.connection = {+ id: 'cn1',+ brand_id: 'b1',+ status: 'connected',+ site_id: SITE,+ updated_at: 'u1',+ };+ db.sends = [];+ db.brands = [];+ db.queries.length = 0;+ db.updates.length = 0;+ configured.on = true;+ credentials = { apiKey: 'IST.fake-key' };+ readPost.mockReset();+ markDeliveryPublished.mockReset();+ logged.length = 0;+});++describe('checkWixPublished', () => {+ it("marks a page published once its post is live with no changes left, at the post's address", async () => {+ db.sends = [send('d1', 'dr1'), send('d2', 'dr2'), send('d0', 'dr1')];+ readPost.mockResolvedValueOnce(post('PUBLISHED')).mockResolvedValueOnce(post('UNPUBLISHED'));++ expect(await checkWixPublished('b1')).toEqual({+ checked: 2,+ published: [{ draftId: 'dr1', url: 'https://acme.example/post/cold-brew' }],+ });+ // A page's latest send only; the connected site's, read with its key.+ expect(readPost.mock.calls.map((call) => call.slice(0, 3))).toEqual([+ [SITE, 'IST.fake-key', 'post-d1'],+ [SITE, 'IST.fake-key', 'post-d2'],+ ]);+ expect(db.queries[0].filters).toEqual(+ expect.arrayContaining([+ ['eq', 'target', 'wix'],+ ['eq', 'target_collection', SITE],+ ]),+ );+ expect(markDeliveryPublished).toHaveBeenCalledWith(+ db.sends[0],+ 'https://acme.example/post/cold-brew',+ );+ });++ it("waits while a live post's changes aren't published, and closes a send whose post is gone", async () => {+ db.sends = [send('d1', 'dr1'), send('d2', 'dr2'), send('d3', 'dr3')];+ readPost+ .mockResolvedValueOnce(post('PUBLISHED', true))+ .mockResolvedValueOnce(null)+ .mockResolvedValueOnce(post('DELETED'));++ expect(await checkWixPublished('b1')).toEqual({ checked: 3, published: [] });+ expect(markDeliveryPublished).not.toHaveBeenCalled();+ expect(db.updates.map((u) => u.update)).toEqual([+ { status: 'failed', error: 'Removed in Wix' },+ { status: 'failed', error: 'Removed in Wix' },+ ]);+ });++ it('marks a page published at https:// when Wix gives the post’s address without its scheme', async () => {+ db.sends = [send('d1', 'dr1'), send('d2', 'dr2')];+ readPost+ .mockResolvedValueOnce({+ ...post('PUBLISHED'),+ url: 'mysite.wixsite.com/mysite/post/cold-brew',+ })+ .mockResolvedValueOnce({ ...post('PUBLISHED'), url: '/post/no-host' });+ expect(await checkWixPublished('b1')).toEqual({+ checked: 2,+ published: [{ draftId: 'dr1', url: 'https://mysite.wixsite.com/mysite/post/cold-brew' }],+ });+ // An address with no host isn't one: that page waits.+ expect(markDeliveryPublished).toHaveBeenCalledTimes(1);+ });++ it('stops at a refused key and marks the connection, and reads nothing without one', async () => {+ db.sends = [send('d1', 'dr1'), send('d2', 'dr2')];+ readPost.mockRejectedValue(new WixError('auth_failed', 'Wix refused the API key.'));+ expect(await checkWixPublished('b1')).toEqual({ checked: 0, published: [] });+ expect(readPost).toHaveBeenCalledTimes(1);+ expect(db.updates[0].update).toMatchObject({ status: 'auth_failed' });++ db.connection = null;+ readPost.mockReset();+ expect(await checkWixPublished('b1')).toEqual({ checked: 0, published: [] });+ expect(readPost).not.toHaveBeenCalled();+ });+});++describe('sweepWixPublished', () => {+ it('reads the brands with Wix connected on an active plan', async () => {+ db.brands = [+ { brand_id: 'b1', brands: { organizations: { subscription_status: 'active' } } },+ { brand_id: 'b2', brands: { organizations: { subscription_status: 'canceled' } } },+ ];+ db.sends = [];+ // On the cloud, where subscriptions count.+ vi.stubEnv('IS_CLOUD', 'true');+ expect(await sweepWixPublished()).toEqual({ brands: 1, published: 0 });+ vi.unstubAllEnvs();+ // Never a demo brand's connection (00380).+ expect(db.connectionReads.at(-1)).toContainEqual(['eq', 'brands.is_demo', false]);+ });++ it('does nothing on a server that can’t keep an API key', async () => {+ configured.on = false;+ expect(await sweepWixPublished()).toEqual({ brands: 0, published: 0 });+ });+});diff --git a/server/src/lib/cms/wix.js b/server/src/lib/cms/wix.jsindex 603c6ccb8..dd699cd2a 100644--- a/server/src/lib/cms/wix.js+++ b/server/src/lib/cms/wix.js@@ -293,6 +293,8 @@ function draftOf(data) {id: typeof post.id === 'string' ? post.id : null,status: typeof post.status === 'string' ? post.status : null,url,+ // A published post's changes not published yet (its draft version written to).+ pending: post.hasUnpublishedChanges === true,};}diff --git a/server/src/lib/cms/wix.test.js b/server/src/lib/cms/wix.test.jsindex 7ccb3211c..8b05e1e40 100644--- a/server/src/lib/cms/wix.test.js+++ b/server/src/lib/cms/wix.test.js@@ -226,6 +226,7 @@ describe('draft posts', () => {id: POST,status: 'UNPUBLISHED',url: 'https://acme.example/post/x',+ pending: false,});expect(api.calls[0].body).toEqual({ draftPost: post, publish: false, fieldsets: ['URL'] });});@@ -246,6 +247,7 @@ describe('draft posts', () => {id: POST,status: 'PUBLISHED',url: 'https://acme.example/post/x',+ pending: false,});expect(await readDraftPost(SITE, KEY, 'f0000000-0000-4000-8000-000000000000', opts)).toBeNull();expect(await readDraftPost(SITE, KEY, 'not-an-id', opts)).toBeNull();diff --git a/server/src/middleware/demo-brand.js b/server/src/middleware/demo-brand.jsindex 9fa313a78..1aadc0b6f 100644--- a/server/src/middleware/demo-brand.js+++ b/server/src/middleware/demo-brand.js@@ -133,6 +133,7 @@ export const DEMO_GUARDED = [guard('POST /content-drafts/webflow-status', brandIn('body')),guard('POST /content-drafts/wordpress-status', brandIn('body')),guard('POST /content-drafts/framer-status', brandIn('body')),+ guard('POST /content-drafts/wix-status', brandIn('body')),guard('POST /content-drafts/:draftId/brief',brandIn('body'),diff --git a/server/src/middleware/rate-limiter.js b/server/src/middleware/rate-limiter.jsindex c8286a0a7..bd04023cb 100644--- a/server/src/middleware/rate-limiter.js+++ b/server/src/middleware/rate-limiter.js@@ -191,7 +191,7 @@ export const cmsLimiter = rateLimit({});// The Library's checks whether pages sent to a CMS were published there:-// three each time it opens, answered from a two-minute memory per brand. A+// four each time it opens, answered from a two-minute memory per brand. A// bucket of their own, so opening the Library never uses up a member's// cmsLimiter, and connecting a CMS stays open to them.export const cmsStatusLimiter = rateLimit({diff --git a/server/src/middleware/rate-limiter.test.js b/server/src/middleware/rate-limiter.test.jsindex ca3d8ec97..92d083485 100644--- a/server/src/middleware/rate-limiter.test.js+++ b/server/src/middleware/rate-limiter.test.js@@ -190,7 +190,7 @@ describe('rate-limiter – CMS buckets', () => {return out;};try {- // Opening the Library 60 times (3 checks each) uses up its own 180…+ // Opening the Library 45 times (4 checks each) uses up its own 180…const checks = await statuses('/webflow-status', 181);expect(new Set(checks.slice(0, 180))).toEqual(new Set([200]));expect(checks.at(-1)).toBe(429);diff --git a/server/src/routes/content-drafts-send.test.js b/server/src/routes/content-drafts-send.test.jsindex d2b57076e..5137a8923 100644--- a/server/src/routes/content-drafts-send.test.js+++ b/server/src/routes/content-drafts-send.test.js@@ -37,6 +37,10 @@ const checkFramerPublished = vi.fn();vi.mock('../lib/cms/framer-status.js', () => ({checkFramerPublished: (...args) => checkFramerPublished(...args),}));+const checkWixPublished = vi.fn();+vi.mock('../lib/cms/wix-status.js', () => ({+ checkWixPublished: (...args) => checkWixPublished(...args),+}));vi.mock('../lib/content-delivery.js', async (importOriginal) => ({...(await importOriginal()),sendContentPages: (...args) => sendContentPages(...args),@@ -280,3 +284,38 @@ describe('POST /api/content-drafts/framer-status (00295)', () => {expect(await failed.json()).toEqual({ error: 'Framer could not be read', code: 'failed' });});});++describe('POST /api/content-drafts/wix-status (00372)', () => {+ const check = (body) =>+ fetch(`${baseUrl}/wix-status`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(body),+ });++ it('reads the brand’s Wix posts for any member, a brand at most every two minutes', async () => {+ role = 'member';+ const brand = '66666666-6666-6666-6666-666666666666';+ checkWixPublished.mockReset().mockResolvedValue({+ checked: 1,+ published: [{ draftId: DRAFT, url: 'https://acme.example/post/cold-brew' }],+ });+ expect(await (await check({ brandId: brand })).json()).toEqual({+ checked: 1,+ published: [{ draftId: DRAFT, url: 'https://acme.example/post/cold-brew' }],+ });+ expect(await (await check({ brandId: brand })).json()).toEqual({+ checked: 0,+ published: [],+ recent: true,+ });+ expect(checkWixPublished).toHaveBeenCalledTimes(1);+ });++ it('names a failure in our words', async () => {+ checkWixPublished.mockReset().mockRejectedValue(new Error('down'));+ const failed = await check({ brandId: '55555555-5555-5555-5555-555555555555' });+ expect(failed.status).toBe(502);+ expect(await failed.json()).toEqual({ error: 'Wix could not be read', code: 'failed' });+ });+});diff --git a/server/src/routes/content-drafts.js b/server/src/routes/content-drafts.jsindex 518daea35..bfe861411 100644--- a/server/src/routes/content-drafts.js+++ b/server/src/routes/content-drafts.js@@ -10,6 +10,7 @@ import { DeliveryError, sendContentPages, sendInput } from '../lib/content-delivimport { checkFramerPublished } from '../lib/cms/framer-status.js';import { checkWebflowPublished } from '../lib/cms/webflow-status.js';import { checkWordPressPublished } from '../lib/cms/wordpress-status.js';+import { checkWixPublished } from '../lib/cms/wix-status.js';import { liveAddress, publishDraft } from '../lib/content-published.js';import { cmsStatusLimiter, shoppingPathLimiter } from '../middleware/rate-limiter.js';import { stopDraftRun } from '../lib/content-runs.js';@@ -239,6 +240,38 @@ router.post('/framer-status', cmsStatusLimiter, async (req, res) => {}});+/** A brand's Wix posts read at most this often on demand (the daily sweep reads them too). */+const wixChecked = new Map();++/**+ * POST /api/content-drafts/wix-status+ * Body: { brandId }. Pages the brand sent to Wix, published there since,+ * marked published at the post's address (cms/wix-status.js). As+ * /webflow-status: any member, a brand at most every two minutes.+ */+router.post('/wix-status', cmsStatusLimiter, async (req, res) => {+ const parsed = webflowStatusBody.safeParse(req.body ?? {});+ if (!parsed.success) return res.status(400).json({ error: 'Invalid request', code: 'invalid' });+ const { brandId } = parsed.data;+ try {+ await assertBrandAccess(brandId, req.user.id);+ const last = wixChecked.get(brandId) ?? 0;+ if (Date.now() - last < WEBFLOW_STATUS_EVERY_MS) {+ return res.json({ checked: 0, published: [], recent: true });+ }+ wixChecked.set(brandId, Date.now());+ return res.json(await checkWixPublished(brandId));+ } catch (err) {+ if (ERROR_CODES[err?.status]) {+ return res+ .status(err.status)+ .json({ error: err.message, code: err.code ?? ERROR_CODES[err.status] });+ }+ req.log.error({ err: { name: err?.name, code: err?.code } }, 'content draft wix status error');+ return res.status(502).json({ error: 'Wix could not be read', code: 'failed' });+ }+});+const rebuildBody = z.object({// guid, not uuid: brand ids aren't all RFC 4122 versions (seeded ones).brandId: z.guid(),diff --git a/server/src/server.js b/server/src/server.jsindex 2eb0eab21..e3747d774 100644--- a/server/src/server.js+++ b/server/src/server.js@@ -46,6 +46,7 @@ import { sweepShoppingCardMatches } from './lib/catalog/card-match.js';import { sweepFramerPublished } from './lib/cms/framer-status.js';import { sweepWebflowPublished } from './lib/cms/webflow-status.js';import { sweepWordPressPublished } from './lib/cms/wordpress-status.js';+import { sweepWixPublished } from './lib/cms/wix-status.js';import { generateBriefForOpportunity } from './routes/content.js';import webhookContentCallbackRoutes from './routes/webhook-content-callback.js';import webhookContentDraftCallbackRoutes from './routes/webhook-content-draft-callback.js';@@ -381,6 +382,10 @@ async function runDailyTracking() {sweepFramerPublished().catch((err) => {logger.error({ err: { name: err?.name } }, '[framer-status] daily sweep failed');});+ // And to Wix (00372), once a day too.+ sweepWixPublished().catch((err) => {+ logger.error({ err: { name: err?.name } }, '[wix-status] daily sweep failed');+ });// Google Analytics sync (#704) — same contract as the Search Console sync// above: independent, never blocks or fails the tracking run, no-ops whendiff --git a/web/messages/en.json b/web/messages/en.jsonindex fb8158849..53a233f3b 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -5817,7 +5817,7 @@},"send": {"button": "Send to CMS",- "hint": "Send the page to your CMS: Webflow, WordPress, Framer, or your workflow through the brand's webhook",+ "hint": "Send the page to your CMS: Webflow, WordPress, Framer, Wix, or your workflow through the brand's webhook","title": "Send to CMS","description": "The page goes to the brand's webhook, for your workflow tool (Zapier, Make, n8n) to publish it in your CMS.","descriptionWebflow": "The page goes to {collection} in Webflow as a draft item, with its slug and meta. You publish it in Webflow.",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsxindex 9bb9f40eb..ccdce2491 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx@@ -51,6 +51,7 @@ const sendPagesToCms = vi.hoisted(() => vi.fn());const refreshWebflowPublished = vi.hoisted(() => vi.fn());const refreshWordPressPublished = vi.hoisted(() => vi.fn());const refreshFramerPublished = vi.hoisted(() => vi.fn());+const refreshWixPublished = vi.hoisted(() => vi.fn());// Mark published (CE-013).const publishPage = vi.hoisted(() => vi.fn());const readPublishAddress = vi.hoisted(() => vi.fn());@@ -60,6 +61,7 @@ vi.mock('@/lib/content/cms-send-client', () => ({refreshWebflowPublished,refreshWordPressPublished,refreshFramerPublished,+ refreshWixPublished,readDraftCms,sendPagesToCms,readKeptFields: vi.fn(async () => new Map()),@@ -177,6 +179,7 @@ beforeEach(() => {refreshWebflowPublished.mockReset().mockResolvedValue([]);refreshWordPressPublished.mockReset().mockResolvedValue([]);refreshFramerPublished.mockReset().mockResolvedValue([]);+ refreshWixPublished.mockReset().mockResolvedValue([]);readPublishAddress.mockReset().mockResolvedValue('https://acme.example/pipeline-forecasting');publishPage.mockReset().mockResolvedValue({ok: true,@@ -620,6 +623,34 @@ describe('Send to CMS from a Library row (#1331)', () => {expect(refreshWebflowPublished).not.toHaveBeenCalled();expect(refreshWordPressPublished).not.toHaveBeenCalled();expect(refreshFramerPublished).not.toHaveBeenCalled();+ expect(refreshWixPublished).not.toHaveBeenCalled();+ });++ /** Wix (00372): its Blog's draft posts, asked once whether they went live. */+ it('says a page sent to Wix is a draft post there, and asks Wix once', async () => {+ getContentDrafts.mockResolvedValue([row({})]);+ readCmsStatuses.mockResolvedValue(+ new Map([+ [+ 'd1',+ {+ status: 'sent',+ target: 'wix',+ at: '2026-10-28T10:00:00Z',+ httpStatus: null,+ error: null,+ publishedUrl: null,+ },+ ],+ ]),+ );+ await renderPage();+ await act(async () => {});+ expect(+ container.querySelectorAll('[aria-label^="In Wix as a draft post since Oct 28, 2026"]'),+ ).toHaveLength(1);+ expect(refreshWixPublished).toHaveBeenCalledTimes(1);+ expect(refreshWixPublished).toHaveBeenCalledWith('brand-1');});it('says a page sent to WordPress is a draft post there, and asks WordPress once', async () => {diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsxindex d6c23393b..4ea751a09 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx@@ -41,6 +41,7 @@ import {readCmsStatuses,refreshFramerPublished,refreshWebflowPublished,+ refreshWixPublished,refreshWordPressPublished,type CmsStatus,} from '@/lib/content/cms-send-client';@@ -211,8 +212,8 @@ export default function ContentLibraryPage() {return () => clearTimeout(timer);}, [cmsGoing, cms]);- // Pages in Webflow or Framer as draft items, or in WordPress as draft- // posts: the CMS says when one goes live, so the API reads them once as+ // Pages in Webflow or Framer as draft items, or in WordPress or Wix as+ // draft posts: the CMS says when one goes live, so the API reads them once as// the Library opens for the brand (and daily); the list is read again when// it marked any published.const sentTo = (target: CmsStatus['target']) =>@@ -220,9 +221,11 @@ export default function ContentLibraryPage() {const inWebflow = sentTo('webflow');const inWordPress = sentTo('wordpress');const inFramer = sentTo('framer');+ const inWix = sentTo('wix');const webflowRead = useRef(new Set<string>());const wordpressRead = useRef(new Set<string>());const framerRead = useRef(new Set<string>());+ const wixRead = useRef(new Set<string>());useEffect(() => {if (isLocked || !inWebflow || !activeBrandId || webflowRead.current.has(activeBrandId)) return;webflowRead.current.add(activeBrandId);@@ -250,6 +253,14 @@ export default function ContentLibraryPage() {if (published.length) setAttempt((n) => n + 1);});}, [isLocked, inFramer, activeBrandId]);+ useEffect(() => {+ if (isLocked || !inWix || !activeBrandId || wixRead.current.has(activeBrandId)) return;+ wixRead.current.add(activeBrandId);+ // As Webflow's: not cancelled with the effect.+ void refreshWixPublished(activeBrandId).then((published) => {+ if (published.length) setAttempt((n) => n + 1);+ });+ }, [isLocked, inWix, activeBrandId]);const reload = () => setAttempt((n) => n + 1);const titleOf = (draft: ContentDraftListItem) => draft.title.trim() || t('untitled');diff --git a/web/src/lib/content/cms-send-client.ts b/web/src/lib/content/cms-send-client.tsindex 5a7a1a08b..3e9d03aea 100644--- a/web/src/lib/content/cms-send-client.ts+++ b/web/src/lib/content/cms-send-client.ts@@ -161,7 +161,7 @@ export async function sendPagesToCms(*/async function refreshPublished(brandId: string,- route: 'webflow-status' | 'wordpress-status' | 'framer-status',+ route: 'webflow-status' | 'wordpress-status' | 'framer-status' | 'wix-status',label: string,): Promise<string[]> {try {@@ -198,6 +198,11 @@ export function refreshWordPressPublished(brandId: string): Promise<string[]> {return refreshPublished(brandId, 'wordpress-status', 'WordPress');}+/** The brand's pages sent to Wix as draft posts, published there since (00372). */+export function refreshWixPublished(brandId: string): Promise<string[]> {+ return refreshPublished(brandId, 'wix-status', 'Wix');+}+/** The brand's pages sent to Framer as draft items, published there since (00295). */export function refreshFramerPublished(brandId: string): Promise<string[]> {return refreshPublished(brandId, 'framer-status', 'Framer');diff --git a/web/src/lib/wix-client.test.ts b/web/src/lib/wix-client.test.tsindex f40a43a71..12860e398 100644--- a/web/src/lib/wix-client.test.ts+++ b/web/src/lib/wix-client.test.ts@@ -25,7 +25,11 @@ describe('wix-client', () => {it('reads the connection, sends the key once in the body, and disconnects', async () => {answer(200, { configured: true, connection: null });expect(await readWix('b1')).toEqual({ ok: true, configured: true, connection: null });- expect(fetchMock.mock.calls[0]).toEqual([BASE, { headers: { Authorization: 'Bearer tok' } }]);+ const [url, init] = fetchMock.mock.calls[0];+ expect(url).toBe(BASE);+ expect(init.headers).toEqual({ Authorization: 'Bearer tok' });+ // The Wix card's read gives up in time, as the other integration cards' do.+ expect(init.signal).toBeInstanceOf(AbortSignal);answer(200, { connection: { status: 'connected' } });expect(await connectWix('b1', input)).toEqual({diff --git a/web/src/lib/wix-client.ts b/web/src/lib/wix-client.tsindex daf0c3593..7c7866671 100644--- a/web/src/lib/wix-client.ts+++ b/web/src/lib/wix-client.ts@@ -1,6 +1,7 @@import { BROWSER_API_BASE_URL } from '@/config/api';import { apiFailure } from '@/lib/api-failure';import { createClient } from '@/lib/supabase/client';+import { INTEGRATION_READ_TIMEOUT_MS } from '@/lib/integrations-client';/*** A brand's Wix connection for Send to CMS (#1331, phase 2; 00372), from the@@ -90,7 +91,9 @@ async function call<T>(brandId: string, init: RequestInit = {}): Promise<WixResu/** The brand's connection, and whether this server can keep a Wix API key. */export function readWix(brandId: string) {- return call<{ configured: boolean; connection: WixConnection | null }>(brandId);+ return call<{ configured: boolean; connection: WixConnection | null }>(brandId, {+ signal: AbortSignal.timeout(INTEGRATION_READ_TIMEOUT_MS),+ });}/** Connects the brand's site, or replaces its key: the API checks it with Wix first. */