Skip to content

refactor: migrate to use "plain client" CMA. [AIS-188] - #2341

Draft
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
mainfrom
cma-plain-client
Draft

refactor: migrate to use "plain client" CMA. [AIS-188]#2341
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
mainfrom
cma-plain-client

Conversation

@ethan-ozelius-contentful

@ethan-ozelius-contentful ethan ozelius (ethan-ozelius-contentful) commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactor to use "plain" client of CMA

Plain Client Migration — Coverage Review


  ┌───────────────────┬────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────┬────────┐
  │     Resource      │            Old (legacy) pattern            │                          New (plain client)                           │ Status │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Space             │ client.getSpace(id)                        │ client.space.get({ spaceId })                                         │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Environment       │ space.getEnvironment(id)                   │ client.environment.get({ spaceId, environmentId })                    │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Content types     │ env.getContentTypes(query)                 │ client.contentType.getMany({ spaceId, environmentId, query })         │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Tags              │ env.getTags(query)                         │ client.tag.getMany({ spaceId, environmentId, query })                 │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Editor interfaces │ env.getEditorInterfaceForContentType(ctId) │ client.editorInterface.get({ spaceId, environmentId, contentTypeId }) │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Entries           │ env.getEntries(query)                      │ client.entry.getMany({ spaceId, environmentId, query })               │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Assets            │ env.getAssets(query)                       │ client.asset.getMany({ spaceId, environmentId, query })               │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Locales           │ env.getLocales(query)                      │ client.locale.getMany({ spaceId, environmentId, query })              │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Webhooks          │ space.getWebhooks()                        │ client.webhook.getMany({ spaceId, query }) + strip order              │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ Roles             │ space.getRoles()                           │ client.role.getMany({ spaceId, query }) + strip order                 │ ✅     │
  ├───────────────────┼────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────┼────────┤
  │ createClient      │ createClient(config, { type: 'legacy' })   │ createClient(config) (plain is default in v12+)                       │ ✅     │
  └───────────────────┴────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────┴────────┘

Description

  • lib/tasks/init-client.js: Dropped the { type: 'legacy' } second argument from createClient — plain client is now the default.
  • lib/tasks/get-space-data.js: Rewrote all CMA calls to use the flat plain client API:
    • client.getSpace() + space.getEnvironment() → client.space.get() + client.environment.get()
    • environment.getContentTypes(query) → client.contentType.getMany({ spaceId, environmentId, query })
    • Same pattern for tag, entry, asset, locale, webhook, role
    • contentType.getEditorInterface() → client.editorInterface.get({ spaceId, environmentId, contentTypeId })
    • pagedGet refactored to take a fetchFn(query) lambda instead of { source, method } — query params are now passed under the query key as the plain client expects
  • test/unit/tasks/get-space-data.test.js: Mocks updated to reflect the flat client.entity.method() structure.

@ethan-ozelius-contentful ethan ozelius (ethan-ozelius-contentful) changed the title refactor: migrate to use "plain client" CMA. refactor: migrate to use "plain client" CMA. [AIS-188] Jul 9, 2026
Ethan Ozelius (eozelius) and others added 2 commits July 13, 2026 15:24
…IS-188]

The plain client's webhook.getMany and role.getMany pass query params directly
to the API, unlike the legacy space.getWebhooks() which silently dropped all
arguments. The webhook and roles endpoints reject 'order' with a 400 Bad Request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants