Skip to content

pat-filemanger use @plone/client for standard restapi calls#1604

Draft
petschki wants to merge 1 commit into
masterfrom
filemanager-plone-client-integration
Draft

pat-filemanger use @plone/client for standard restapi calls#1604
petschki wants to merge 1 commit into
masterfrom
filemanager-plone-client-integration

Conversation

@petschki

Copy link
Copy Markdown
Member

hybrid implementation

Volto's aurora @plone/client (2.0.0-alpha.4) dropped the React/react-query dependency, so it is usable in this Svelte/Patternslib bundle. Route the standard restapi calls through the official client; keep the calls the alpha client can't yet express on the native-fetch request() layer. All calls already funnel through src/api/*, so this is a contained refactor of that layer.

  • api/ploneClient.js: shared client (initialize with apiPath=portalUrl, apiSuffix="" → no /++api++), client()/toPath()/unwrap(); unwrap returns the axios .data and maps the client's {status,data,location} rejection to a RestapiError so callers keep .message/.status/.body. App.svelte inits it before any store runs.
  • Migrated: fetchBreadcrumbs→getBreadcrumbs, pasteItems→move/copyContent, deleteItem→deleteContent, moveItem→updateContent{ordering}, createFolder→ createContent. Methods are called on the instance (services read this.config).
  • Kept custom (alpha client can't express yet): the sorted/batched listing, workflow transitions, rearrange/set-default-page, tags/properties/rename, link integrity, and tus upload. The two transports coexist by design.
  • docs/upstream-plone-client.md: ready-to-submit diffs+descriptions for the four wrapper gaps so the rest can migrate once released.
  • Tests mock ./ploneClient.js at the api boundary; a jest manual mock at src/mocks/@plone/client.js auto-stubs the package (its CJS build pulls in ESM-only query-string jest can't load). Suite green; dev build compiles. The pattern is dynamically imported, so axios/zod land in the lazy filemanager chunk — core bundle ~unchanged.

…hybrid)

Volto's aurora @plone/client (2.0.0-alpha.4) dropped the React/react-query
dependency, so it is usable in this Svelte/Patternslib bundle. Route the
standard restapi calls through the official client; keep the calls the alpha
client can't yet express on the native-fetch request() layer. All calls already
funnel through src/api/*, so this is a contained refactor of that layer.

- api/ploneClient.js: shared client (initialize with apiPath=portalUrl,
  apiSuffix="" → no /++api++), client()/toPath()/unwrap(); unwrap returns the
  axios .data and maps the client's {status,data,location} rejection to a
  RestapiError so callers keep .message/.status/.body. App.svelte inits it
  before any store runs.
- Migrated: fetchBreadcrumbs→getBreadcrumbs, pasteItems→move/copyContent,
  deleteItem→deleteContent, moveItem→updateContent{ordering}, createFolder→
  createContent. Methods are called on the instance (services read this.config).
- Kept custom (alpha client can't express yet): the sorted/batched listing,
  workflow transitions, rearrange/set-default-page, tags/properties/rename,
  link integrity, and tus upload. The two transports coexist by design.
- docs/upstream-plone-client.md: ready-to-submit diffs+descriptions for the four
  wrapper gaps so the rest can migrate once released.
- Tests mock ./ploneClient.js at the api boundary; a jest manual mock at
  src/__mocks__/@plone/client.js auto-stubs the package (its CJS build pulls in
  ESM-only query-string jest can't load). Suite green; dev build compiles. The
  pattern is dynamically imported, so axios/zod land in the lazy filemanager
  chunk — core bundle ~unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@petschki petschki requested review from MrTango and sneridagh June 12, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant