Skip to content

refactor(plugin-flow-builder): standardize the services clients that make calls to the backend - #3305

Open
Iru89 wants to merge 9 commits into
masterfrom
refactor-services
Open

Iru89 wants to merge 9 commits into
masterfrom
refactor-services

Conversation

@Iru89

@Iru89 Iru89 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Refactors @botonic/plugin-flow-builder so Hubtype and Flow Builder HTTP calls live in small service client classes instead of ad hoc requests spread across the package. FlowBuilderApi now delegates flow loading (and dev-only session user info) to FlowBuilderClient, while campaigns, queues, contact-info fields, smart intents, and capture-user-input each use dedicated *Client modules sharing HubtypeClientBase for auth and API URL. Resolvers and tests are updated to match the new structure, with a shared service-client-test-context helper for client unit tests.

Context

This keeps API surface behavior the same for typical bot code but makes HTTP boundaries explicit, easier to mock in tests, and consistent (token + HUBTYPE_API_URL / legacy serve). It also removes the old *-api naming in favor of *-client alongside the new FlowBuilderClient.

Approach taken / Explain the design

  • HubtypeClientBase — reads the Flow Builder plugin access token and resolves hubtypeApiUrl (plugin setting or HUBTYPE_API_URL fallback).
  • FlowBuilderClient — extends the base; implements getFlow() and updateSessionWithUserInfo() used by FlowBuilderApi.create() (including draft vs published JSON version from session/plugin).
  • Domain *Client classes replace the previous contact-info-fields-api and hubtype-queues-api files and align campaigns, capture-user-input, smart-intent, etc. with the same pattern.
  • FlowBuilderApi stays the high-level flow/graph API; network I/O for bootstrapping the flow moves into FlowBuilderClient.
  • Resolver files renamed/updated (capture-user-input-resolver, smart-intent-resolver) to work with the new clients.

To document / Usage example

No change required for bots that only use FlowBuilderApi and existing plugin setup. Internally, new HTTP entry points are the *Client classes under packages/botonic-plugin-flow-builder/src/services/; import paths and mock paths in tests follow the same *-client naming.

Testing

The pull request...

  • has unit tests
  • doesn't need integration tests because the change is a straight refactor of HTTP boundaries and FlowBuilderApi wiring; behavior is covered by updated/added client tests and existing plugin tests that still exercise flows.

Iru89 added 2 commits November 6, 2026 18:02
…lient implementations for campaigns, user input, and queues
… refactor existing tests to use shared context
@Iru89
Iru89 requested a review from vanbasten17 November 6, 2026 17:10
@Iru89 Iru89 self-assigned this Nov 6, 2026
@Iru89
Iru89 marked this pull request as ready for review November 6, 2026 17:10
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T17:10:18.217104Z
We couldn’t complete this review. Comment @codex review to try again.
6840063 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@Iru89 Iru89 changed the title Refactor services refactor(plugin-flow-builder): standardize the services clients that make calls to the backend Nov 6, 2026
@Iru89
Iru89 requested a review from Davidhidalgo November 9, 2026 08:25
@github-actions

Copy link
Copy Markdown

Test Results

46 tests   46 ✅  1m 13s ⏱️
 6 suites   0 💤
 1 files     0 ❌

Results for commit 6717fd4.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant