Repository navigation
feat(cms): connect a brand's Wix site with its owner's API key and send pages to its Blog as draft posts (#1331) - #1721
Conversation
…ord and send pages to it as draft posts (ansvisor#1331) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… read when the Library opens and daily (ansvisor#1331) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ons (ansvisor#1331) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ss-server # Conflicts: # server/src/lib/content-delivery.test.js # supabase/schema.sql
The Send dialog (editor, Library row, bulk) offers the brand's WordPress site beside Webflow and the webhook. A remembered CMS that isn't ready goes to the webhook, never the other CMS. The toast says when a live post got a new draft and when JSON-LD was left out. The Library marks rows sent to WordPress and asks /wordpress-status once per brand per visit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Node 20 is end of life since 2026-04-30, and Framer's official Server API package (framer-api, for Send to CMS ansvisor#1331) needs Node 22 or later for its global WebSocket. Node 24 is LTS until April 2028. The Dockerfile, CI's server job and the server README move to 24; the web job stays on 20. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re/cms-framer-server
…#1331) Framer's official Server API (framer-api, needs Node 22+): a brand's project connects with an API key made in it, sealed as WordPress's sign-in is. 00295 adds provider 'framer' (site_id = project id) and the 'framer' delivery target, and reserve_content_deliveries keeps one queued send per page for it too. Routes check the project, list the user's own collections with their fields, save the collection and field map (title to text, page to formatted text, required fields refused as for Webflow) and disconnect (Framer has no API to revoke a key). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…feature/cms-framer-settings
…ons (ansvisor#1331) The Framer card connects the brand's project with an API key made in it, lists the project's own collections with their fields, suggests and saves which field takes the title, the page, meta and JSON-LD (required fields it can't fill and missing title or page fields marked), replaces the key, shows a refused key, and disconnects with a reminder to delete the key in Framer, which has no API to revoke it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Send dialog (editor, Library row, bulk) offers the brand's Framer collection beside Webflow, WordPress and the webhook, in a 2x2 grid when all four are there. Framer is ready with a collection and its title and page fields; a remembered CMS that isn't ready goes to the webhook. The toast says made or updated, images left out, and that a non-draft item's change waits for the site's next publish. The Library marks rows sent to Framer and asks /framer-status once per brand per visit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… has ended Since ansvisor#1589 a workspace whose plan has ended can't write, but taking back an outside account's access stays open (COST_STOPPING), as Webflow's disconnect does. WordPress's disconnect revokes the Application Password where the site allows, so it joins the list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s-published Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ress-web Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-server Co-Authored-By: Claude Opus 5.5 <[email protected]>
… has ended Since ansvisor#1589 a workspace whose plan has ended can't write, but taking back an outside account's access stays open (COST_STOPPING), as Webflow's and WordPress's disconnects do. Framer's disconnect deletes the project's API key, so it joins the list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ings Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tings Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd-target Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd pages to its Blog as draft posts (ansvisor#1331) Send to CMS, Wix (phase 2), server. After Webflow, WordPress and Framer, a brand connects its Wix site: the site's id (or its dashboard's address) and an API key its owner makes in Wix's API Keys Manager with the Wix Blog permissions. Pages go to the site's Blog as draft posts; nothing publishes. - 00372: brand_cms_connections and content_draft_deliveries take 'wix' (site_id and the posts' owner member in `account`); the key is sealed in brand_cms_credentials as WordPress's sign-in is; reserve_content_deliveries keeps a page from being sent to Wix twice at once. Applied on the dev DB. - lib/cms/wix.js: Authorization: <key> with wix-site-id; checkSite (the Blog answers, a member owns the posts: its newest post's, else its first member; the site's name when the key may read it); the page's HTML turned into Wix's rich content by Wix's converter in pieces of 10,000 characters; draft posts created, read and updated, a live post as its draft version (UPDATE_PUBLICATION), never the post people read. - lib/cms/wix-delivery.js: a page updates the post its last send made on that site, else makes one; title, meta description and JSON-LD go as the post's SEO tags; images stay out and are counted; a refused key marks the connection for a new one. - routes/cms-wix.js: GET / POST { siteId, apiKey } / DELETE, admins and managers to write; the key is never logged or sent back. Disconnecting works after a plan ends. content-delivery.js sends target 'wix'. Real Wix keys are tried by the maintainer; tests run against a fake of the API (its answers as Wix's reference shows them). Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/src/components/content/send-to-cms-dialog.tsx
# Conflicts: # supabase/schema.sql
Main now has Framer's send (ansvisor#1576) and published check (ansvisor#1579): Wix is added beside Framer as a delivery target in content-delivery.js (its connection, the NATIVE entry, the codes) and in its tests.
# Conflicts: # supabase/schema.sql
|
Merged main forward (conflict in |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups
At merge time: main's demo brand guard now covers Wix's connect and disconnect routes (DEMO_GUARDED), like WordPress and Framer.
Reviewed this PR's own change (main → 22a2176), read as merged on main 3b7611c. It merges on main with one conflict, in supabase/schema.sql only (regenerated with build-schema.sh; nothing else to resolve). The Wix stack is this PR → #1749 (Settings card and Send target) → #1750 (published check), each containing the one before; #1722 (docs) sits apart on the docs chain. No PR in the set supersedes another, and none should be closed.
What I checked
- Outbound requests. Every call goes to the fixed
https://www.wixapis.comthrough the connectors' client (connectors/http.js): https only, no redirect followed, 30 s per attempt, a body cap, and a POST never sent twice. Nothing the person types becomes a host. The site id is taken out of what they paste as a GUID only, and post ids are GUID-checked before they go into a path; the member id kept at connect is GUID-checked too. - The API key. Checked with Wix first (Blog read, one converter call that Wix doesn't keep, a member to own the posts), then sealed under
CONNECTOR_CREDENTIALS_KEYinbrand_cms_credentials, bound to the connection, as WordPress's and Framer's are. The GET answer (shape) never carries it, errors are logged by name only, and nothing the API sends back quotes it. If sealing fails after the row is written, the row is marked refused, so a send can't use an older key on the new site. - Who can do what. Connect and disconnect go through
assertWriter(admins and managers of the brand's organization) on the server; the GET isassertBrandAccess. Every query runs on the brand id after that check, so another organization's connection can't be read or changed. Connect sits behindcmsLimiter. - Read-only workspace. Connect is refused with the 402 body (not in
COST_STOPPING); disconnect is open there, as WordPress's and Framer's are, andsubscription.test.jscovers it.subscription-guard-coverage.test.tspasses on the stack merged with main. - Sending.
wixForrefuses a refused key before anything is reserved. A refused key during a send marks only the connection the send read (updated_atmatch), so one connected again meanwhile keeps its new key. A page updates the post its last Wix send made on the same site; a published post gets its draft version written (UPDATE_PUBLICATION), so the live post doesn't change. Scripts are taken out before the converter; JSON-LD goes as an SEO tag with every<escaped. Images are left out and counted. - Wiring. Matches WordPress/Framer: the
NATIVEentry,DELIVERY_TARGETS, the error codes, the router,.env.example. - Migration 00372 read in full (notes below).
- Embeds: none added in this part.
- Tests: full server suite on the stack merged with main (#1750's tip + main): 298 files, 4,164 passed; one known timing test (
content-people) failed under load and passes alone. eslint and prettier are clean on every touched file.
Migration 00372
- The number is free: main has 00371 and 00373–00376, and no open PR uses 00372.
- It differs from 00295 only by adding
wix: to the provider check, toprovider_fields(a Wix row needssite_idandaccount), to the deliverytargetcheck, and to the CMSs thatreserve_content_deliveriesrefuses to send a page to twice at once. It also updates the comments. reserve_content_deliverieskeeps its signature,security definerwithsearch_path = public, and execute forservice_roleonly.- Nothing later on main redefines these objects, so applying it after 00379/00400–00404 is fine.
- Re-adding the two check constraints scans
brand_cms_connectionsandcontent_draft_deliveriesonce, under a short exclusive lock. Both tables are small. It is idempotent (drop constraint if exists,create or replace).
Before merging
- Order: apply 00372, deploy the API, then merge the web parts (#1749, #1750). Without the migration, a Wix connect fails at the row's check (500) and a send to Wix fails at the reserve. Without this API, the web's Wix card says it can't read the connection, and the Send dialog leaves Wix out.
CONNECTOR_CREDENTIALS_KEYmust be set on the API (it already is wherever WordPress works).
Follow-ups
nodePiecesbuilds each piece's empty tag with$(node).clone().empty(), which copies the whole block before emptying it. On a deeply nested page that makes the split work grow with size × depth, and on a very deep one it runs out of stack (the send then fails with "Wix could not be reached"). A shallow copy (node.cloneNode(false)) gives the same tag without the copy.- A long page goes to Wix's converter in up to ~35 calls, one after another, and none is retried. One 429 in the middle fails the page. A short wait-and-retry on 429 for the converter, or one call per page where it fits, would make long pages more reliable.
- The member who owns new posts is the author of the newest published post, else the first member Wix returns (as the description says). On a site with a members area, that can be someone other than the owner. Worth a line in the card after connect ("Posts are written as …").
Summary
Send to CMS, Wix (#1331 phase 2), server part. After Webflow, WordPress and Framer, a brand connects its Wix site. It gives the site's id (or its dashboard's address) and an API key that the site's owner makes in Wix's API Keys Manager. Pages go to the site's Blog as draft posts. Nothing is published.
00372_cms_wix.sql:brand_cms_connectionsandcontent_draft_deliveries.targettakewix. A Wix row needssite_id, andaccount: the member who owns the posts, since Wix's Blog needs an owner.brand_cms_credentials, as WordPress's sign-in and Framer's key are.reserve_content_deliveriesis 00295's, withwixadded to the CMSs a page can't be sent to twice at once.lib/cms/wix.js:Authorization: <key>andwix-site-id, tohttps://www.wixapis.comonly, throughconnectors/http.js(https only, no redirects). The site and post ids are GUID-checked before they go into a header or a path.checkSitechecks before anything is kept:UPDATE_PUBLICATION), so the post people read stays as it was until it's published in Wix. A scheduled post is written as a draft.lib/cms/wix-delivery.js:<escaped in the JSON-LD).routes/cms-wix.js:GET /api/cms/brands/:id/wixis for any member.POST({ siteId, apiKey }) andDELETEare for admins and managers only, behindcmsLimiter.COST_STOPPING).content-delivery.jssends targetwix. Main now has Framer's send (feat(cms): send pages to a brand's Framer collection as draft items (#1331) #1576), so the merge puts Wix beside Framer: the connection, theNATIVEentry, the error codes and their tests. I resolved that conflict by hand.What follows: the Settings card and the Send target (
feature/cms-wix-web), the published check (feature/cms-wix-published), and docs (docs/cms-wix).Migration:
00372. It is numbered below00374(menu access, already on main) and depends only on00295(on main). Per the branch's commit, it was applied on the dev DB.schema.sqlwas rebuilt withbash supabase/build-schema.sh.Not stacked: #1580, which it was built on, is on main.
Related issue
Part of #1331 (Send to CMS).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/cms/wix.test.js src/lib/cms/wix-delivery.test.js src/routes/cms-wix.test.js src/lib/content-delivery.test.js src/middleware/subscription.test.js. Wix's answers are faked from its API reference.CONNECTOR_CREDENTIALS_KEY. In Wix, the site's owner makes a key in Account Settings › API Keys Manager with Manage Blog (Wix Blog) and Manage Ricos Document (Ricos), with the site picked. As an admin:POST /api/cms/brands/<id>/wixwith{ "siteId": "<site id or dashboard address>", "apiKey": "<key>" }: the connection comes back with the site's name. The key isn't in the answer or in the logs.POST /api/content-drafts/sendwith"target": "wix": a draft post appears on the Blog, with its SEO title, description and JSON-LD, and without images. Send it again: the same post is updated.no_ricos_permission.For your review: with no post on the Blog, the member who owns the posts is the first one Wix's Members query returns. On a site with a members area, that could be a member who isn't the owner. The person sees the writer on the draft in Wix and can change it there.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Server only. What ran on this head (after merging main ce9a3dc):
npm run lintinserver/;--checkon the changed server files;bash supabase/build-schema.sh;fix/ambiguous-embed-guard, on the top of the Wix chain.The full
npm testwasn't run this round. Before main's Framer merges, the branch's full test run passed, except files that timed out under machine load; run alone, those passed.🤖 Generated with Claude Code