Repository navigation
feat(cms): send pages to a brand's Framer collection as draft items (#1331) - #1576
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]>
…ss-server # Conflicts: # server/src/lib/content-delivery.test.js # supabase/schema.sql
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]>
…nsvisor#1331) writeItem adds a draft item (draft: true) or updates the one the page's last Framer send made in that collection, keeping its state; the new id is read back by slug among new items, a clashing slug stops the send, and a draft with the page's slug and title left by a send that broke halfway is taken back. framer-items.js keeps tables (Framer's rich text has them), leaves media out and counts it, and maps title, page, meta and JSON-LD to the brand's fields. content-delivery.js gains the 'framer' target. 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]>
…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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's product blocks (ansvisor#1607) are a grid of linked cards; Framer's formatted text has no grid, so the cards ran together in one paragraph. They now go as Webflow's do (productsAsList): a list, a product an item, its name linked and its price after it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged #1575's new head in (1ea6030). |
* fix(cms): give a Webflow item sent again a date when it has none Follow-up from #1600 (item 1). Only a new item was given the day it's sent; an item sent again kept its date. So a brand that maps an optional date later, or makes its date required in Webflow, kept an empty date on every item sent before, and a send again left it empty. When the field map gives a date, sendToWebflow now reads the item before updating it (getItem, which says which fields hold a value) and, when its date is empty, sends today's with the update. An item that can't be read is updated without a date, as before; without a date field nothing is read. The Send to CMS guide's field table lists the Date field (#1507's follow-up) and says an item sent again keeps its date, or gets one. fieldDataFor (webflow-items.js) is unchanged, so this doesn't meet the Framer PRs' edit at its end (#1576, #1579). Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(cms): say which Webflow items are given the day they're sent Review follow-up. The comment above createItem still said only a new item is given the day it's sent, but an item sent again with an empty date now gets it too. It names both now. Comment only; webflow-items.js untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(cms): keep a Webflow item's date when the read didn't see its fields --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups
Reviewed this PR's own change: #1575's head a5e9577 → 1ea6030, 10 server files. It merges clean on main (cfd8a35).
What I checked
- The send.
framerForrefuses before anything is reserved when: there's no key store (503), nothing is connected, the key was refused, or there's no collection with title and body fields. That's the same rule as the web's "ready". The page goes through #1569's reservation (00295 adds'framer'to the "not twice at once" list), the daily cap and batches, as Webflow's do. - Which item is written. The page's last Framer send in this collection is updated while that item is still there, and its draft state stays as it is. A slug held by another item stops the send before anything is written. A draft holding the page's slug and its exact title is taken over as a half-done send, and the docs say so. After
addItems, the new item is the single new one with the slug; anything else fails, so no wrong id is kept. Each send is one connection with the 30 s timeout from #1575. - The HTML sent.
toFramerHtmldrops scripts, styles, forms, embeds, iframes, media and comments. Every other element is either on a short allow-list or gives way to its content. Attributes go except a link'shref/targetand a cell'scolspan/rowspan(whole numbers 1–1000 only). JSON-LD has its own text field, with<escaped. - Webflow refactor.
toWebflowRichTextis split into exported steps, in the same order as before. Webflow's item tests pass unchanged, and on adversarial input it times the same as main's. - Errors. Framer's refusals use our words. A refused key marks the connection only if it's still the one the send read. Any other error is logged by name and recorded as "Framer could not be reached".
- Speed. New loops over page text (tables, spans, slug) are linear on 100 KB inputs. Slug: 4 ms. Plain text: 30 ms.
- Tests: CMS, delivery and send route tests on the stack: 16 files, 275 passed. Full server suite: 3,809 passed. eslint and prettier are clean.
Follow-ups
- Reading every item.
writeItemreads the whole collection with every item's fields, twice for a new item, to find one item and one slug. That's fine for blogs of a few hundred items, but it grows with the collection. Ifframer-apican read one item by id (or filter by slug), use that. - "Images aren't sent yet" is in the toast and the docs. Worth one tracking issue so it isn't lost behind CHAT-06.
Summary
Send to CMS, phase 2 (#1331): Framer, part 2: pages go to the brand's Framer collection as draft items. Server only.
Stacked on #1575 (connect). This PR's own change is its last commit.
Writing an item (
lib/cms/framer.jswriteItem, one connection per page):draft: true, so it stays out of the site until someone publishes it in Framer. Framer'saddItemsdoesn't return the new id. So the collection is read again, and the id is the one item holding the page's slug among ids that weren't there before. None, or more than one, fails: "Framer didn't say which item it made."target_collection).draftisn't sent, so the item keeps its state.slug_taken). The check runs on both paths.addItemscan succeed and the read after it fail (a drop, the 30 s timeout). The item then exists, but its id isn't kept.addItemsis tried once more.What goes (
lib/cms/framer-items.js, by the brand's field map):contentType: 'html'), as Export makes it ready.colspanandrowspanstay when they're whole numbers from 1 to 1000.changed.images), as for Webflow. Framer takes images as its own assets.webflow-items.jsand reused. Webflow's output is unchanged, and its tests pass as they were._turned into-), else the title's, elsepage-<draft id>.lib/cms/framer-delivery.jssendToFramerfollowswebflow-delivery.js:brand_cms_credentials.auth_failed(conditional onupdated_at) and stops a bulk send, as for WordPress.externalIdandcollectionId;updated;live: the updated item isn't a draft, so the change waits for the site's next publish. That's not WordPress's meaning oflive; the web says it per target;changed: { images }.lib/content-delivery.js:'framer'joins the targets, withframerFor. Its codes follow Webflow's and WordPress's:framer_not_configured(503);no_framer(409);framer_refused(409);framer_not_ready(409): no collection, or no title or page field.Not here: images (Framer assets), the published check (part 3), and the web (parts 4 and 5).
A busy Framer in a bulk send (
TOKEN_SESSION_LIMITorPOOL_EXHAUSTED) fails that page, and the batch goes on, as for Webflow and WordPress. Stopping the batch would save nothing, since its rows are reserved up front, and the pool error is retryable. A short wait and one retry insidesendToFramercould be a small follow-up.Related issue
Part of #1331 (phase 2, Framer). Stacked on #1575.
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 src/lib/content-delivery.test.jsPOST /api/content-drafts/sendwithtarget: 'framer'for a ready page.h2–h6, lists, quotes and code.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Server only:
npm run format,npm run lintandnpm test(3,087 tests) pass inserver/.A pre-push review's findings are folded in: the send that broke halfway (read retried, own draft taken back), the new id looked for among new items only,
colspanandrowspan, a mixed first row, and the JSON-LD comment. Each new case fails with its fix reverted; I checked that by reverting the new-id filter and the title match one at a time.🤖 Generated with Claude Code