Skip to content

refactor(headless-future): add api facades and contributors#7617

Open
fbeaudoincoveo wants to merge 13 commits into
add-conversational-supportfrom
add-api-facades-and-contributors
Open

refactor(headless-future): add api facades and contributors#7617
fbeaudoincoveo wants to merge 13 commits into
add-conversational-supportfrom
add-api-facades-and-contributors

Conversation

@fbeaudoincoveo
Copy link
Copy Markdown
Contributor

@fbeaudoincoveo fbeaudoincoveo commented May 21, 2026

Introduces the concepts of API endpoint clients, facades, request contributors, and response handlers.

Proposal

Clients

API endpoint clients are defined under api/interface/<endpoint>-endpoint/<endpoint>-endpoint-client.ts (e.g., api/interface/search-endpoint/search-endpoint-client.ts)

A client is entirely unaware of the core and public layers. It defines and exports its own types, which are tied to the underlying Coveo API specification.

It receives its request body and configuration from its caller (which outside of unit tests is going to be the corresponding API endpoint facade). Its reponsibility is straightforward: execute the request and return the response. It does not transform the requests or the responses, but merely transports them.

Facades

API endpoint facades are defined under core/interface/api/<endpoint>-endpoint/<endpoint>-endpoint-facade.ts(e.g., core/interface/api/search-endpoint/search-endpoint-facade.ts).

A facade is aware of the api layer, and is responsible for:

  • Assembling all of its registered request middlewares into a coherent request body
  • Gathering the necessary configuration settings from the state
  • Initializing and calling its client
  • Updating its own representation in the engine's state (i.e., status, error)
  • Executing all of its registered response handlers when the client returns a successful response

Facades are used by feature actions and controllers to call endpoints.

Contributors and Handlers (Middlewares)

Request contributors and response handlers (i.e., middlewares) are defined in core/interface/<feature>/<feature>-loader (e.g., core/interface/search-box/search-box-loader.ts).

Rather than having a single centralized request builder per endpoint with lots of complex logic, features individually "contribute" to various endpoint request bodies by registering request middlewares.

For instance, the query feature might contribute to search-endpoint request bodies by registering a middleware that sets the q property of the request to the value of query in its slice.

Facades then simply assemble the full request body from their registered middlewares, without applying any further logic.

A similar principle applies to response: each feature that should modify its state when a given endpoint response comes in registers its own response middleware. The response object itself is readonly, and the feature may only modify its own state.

The proposal here is to register request and response middlewares in the "loader" function of each feature, so that we don't have to repeat the same middleware logic in controllers and actions. The loader ensures that the correct feature slice is loaded, and registers all request / response middlewares on the necessary facades.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 479f0f5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svcsnykcoveo
Copy link
Copy Markdown

svcsnykcoveo commented May 21, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

@coveo/atomic

npm i https://pkg.pr.new/@coveo/atomic@7617

@coveo/atomic-hosted-page

npm i https://pkg.pr.new/@coveo/atomic-hosted-page@7617

@coveo/atomic-legacy

npm i https://pkg.pr.new/@coveo/atomic-legacy@7617

@coveo/atomic-react

npm i https://pkg.pr.new/@coveo/atomic-react@7617

@coveo/auth

npm i https://pkg.pr.new/@coveo/auth@7617

@coveo/bueno

npm i https://pkg.pr.new/@coveo/bueno@7617

@coveo/create-atomic

npm i https://pkg.pr.new/@coveo/create-atomic@7617

@coveo/create-atomic-component

npm i https://pkg.pr.new/@coveo/create-atomic-component@7617

@coveo/create-atomic-component-project

npm i https://pkg.pr.new/@coveo/create-atomic-component-project@7617

@coveo/create-atomic-result-component

npm i https://pkg.pr.new/@coveo/create-atomic-result-component@7617

@coveo/create-atomic-rollup-plugin

npm i https://pkg.pr.new/@coveo/create-atomic-rollup-plugin@7617

@coveo/headless

npm i https://pkg.pr.new/@coveo/headless@7617

@coveo/headless-react

npm i https://pkg.pr.new/@coveo/headless-react@7617

@coveo/shopify

npm i https://pkg.pr.new/@coveo/shopify@7617

commit: 479f0f5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants