feat(Headless): #3591861 Use the new Canvas content API endpoint in the headless SDK

#3591861

  • Switches the headless SDK's draft-aware fetchPage() client from /ce-api/{path} to /canvas/content-api.
  • Adopts the Canvas endpoint's content, document-head, route, and redirect response contract.
  • Removes the now obsolete Lupus endpoint dependencies and the /ce-api auto-save controller override.

SDK response handling

fetchPage(requestUri) now returns:

  • Page, containing Canvas-rendered content when available, document-head data, and normalized route information. route.managedByCanvas indicates whether Canvas manages the route's complete component tree.
    • route.managedByCanvas is used to distinguish an empty Canvas-managed page from a route Canvas does not render, because both return content: null.
  • PageRedirect, containing the redirect URL, status code, and external-URL flag.
  • null when Drupal returns a non-success response.

isPageRedirect() distinguishes redirect results before page fields are read. Live draft requests continue to carry the preview bearer token. Empty draft content receives an editor-only structural root so the frontend can render an editable content-region placeholder.

Component-tree bindings now consume one structured root or null instead of the former structured-or-markup response.

Lupus removal

The SDK no longer calls /ce-api, so this MR removes:

  • The drupal/lupus_decoupled development dependency.
  • The lupus_ce_renderer and lupus_decoupled_ce_api module dependencies.
  • The Lupus-specific auto-save preview controller, controller subscriber, services, and kernel test.

Testing

  • build ui and packages and enable canvas_headless
    • npm run build
    • npm run packages:build
    • ddev drush cr
    • npm link -ws
    • ddev drush en canvas_headless
  • create a headless app: npx @drupal-canvas/create@latest --experimental-headless --template nextjs
  • start headless app
    • npm link @drupal-canvas/headless @drupal-canvas/headless-next @drupal-canvas/headless-react (if using a template other than the nextjs, link @drupal-canvas/headless and framework adapter matching the template)
    • npm run dev
  • configure frontend in canvas
  • verify that headless preview in canvas works and uses auto-save data
  • verify that the headless app can display published canvas pages outside preview context

AI-Generated: Yes (Used AI coding agent to work on implementation).

Edited by wotnak

Merge request reports

Loading