Skip to content

Conversation

@Paveltarno
Copy link
Collaborator

@Paveltarno Paveltarno commented Feb 9, 2026

Note

Description

This PR refactors the OAuth authorization prompt logic into a reusable module and enhances connector deployment messaging. The new oauth-prompt.ts module provides generic OAuth flow utilities that are shared between connectors push and deploy commands. The refactoring improves the user experience by providing clearer messages about pending OAuth authorizations and offering multiple ways to complete authorization (re-run command or manually open links).

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Created src/cli/commands/connectors/oauth-prompt.ts module with reusable OAuth flow utilities:
    • filterPendingOAuth() - Type-safe filtering of connector results that need OAuth
    • promptOAuthFlows() - Interactive OAuth authorization prompts with skipPrompt option
    • PendingOAuthResult type for type-safe OAuth handling
  • Refactored src/cli/commands/connectors/push.ts to use the new OAuth prompt module:
    • Simplified OAuth handling by delegating to promptOAuthFlows()
    • Passes skipPrompt: true when process.env.CI is detected
    • Updated skip messages to mention manual link authorization
  • Updated src/cli/commands/project/deploy.ts to handle connector OAuth flows:
    • Calls promptOAuthFlows() after deployment when connectors need authorization
    • Respects -y flag and CI environment to skip interactive prompts
    • Displays helpful message with authorization instructions when OAuth is skipped
  • Enhanced src/core/project/deploy.ts:
    • Returns connectorResults in DeployAllResult interface for OAuth handling
  • Added test coverage in tests/cli/deploy.spec.ts:
    • Test for connectors in deploy command with OAuth already authorized
    • Test for connectors needing OAuth with -y flag (verifies skip message)
    • Updated all existing deploy tests to mock connectorsList endpoint

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (bun test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated AGENTS.md if I made architectural changes

Additional Notes

This PR builds on the connector infrastructure added in the target branch (pavelta-connectors-1). Key design decisions:

  • Environment-agnostic helper: The oauth-prompt module doesn't check process.env.CI directly. Instead, callers pass skipPrompt: true based on their context, making the helper more testable and reusable across different commands.
  • Improved user messaging: When OAuth is skipped (via -y flag or CI environment), users now see clearer messages with both the authorization URLs and instructions for multiple authorization methods (re-run command or manually open links).
  • Type safety: Uses type guards (filterPendingOAuth) to ensure type-safe handling of OAuth results throughout the flow.

🤖 Generated by Claude | 2026-02-11 20:15 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.30-pr.211.475080d

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.30-pr.211.475080d"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.30-pr.211.475080d"
  }
}

Preview published to npm registry — try new features instantly!

@Paveltarno Paveltarno changed the base branch from main to pavelta-connectors-1 February 9, 2026 12:14
@claude
Copy link

claude bot commented Feb 9, 2026

Code Review

Found 1 issue that needs attention:

Missing API mock in test

File: tests/cli/deploy.spec.ts
Lines: 124-137 (new test "deploys connectors successfully with -y flag")
Issue: Missing mockConnectorSet() calls for the 3 connectors in the test fixture

When deployAll() calls connectorResource.push(connectors), it executes pushConnectors() which calls setConnector() for each connector. Without mocking these API calls, the test will fail because MSW doesn't have a handler for the unmocked requests.

Fix: Add mockConnectorSet() call after line 130 (after mockConnectorsList) and before the t.run() call:

t.api.mockConnectorSet({
  redirect_url: null,
  connection_id: null,
  already_authorized: true,
});

See:

connection_id: null,
already_authorized: true,
});
const result = await t.run("connectors", "push");


All other changes look good:

  • ✅ Import statement follows existing patterns
  • ✅ Resource integration matches entity/function/agent patterns
  • ✅ Test fixture exists with correct data (3 connectors)
  • ✅ AGENTS.md update is appropriate

@dor-chaouat dor-chaouat moved this from Backlog to In progress in CLI Development Feb 9, 2026
Paveltarno and others added 7 commits February 10, 2026 13:59
Add connector resource module supporting 12 OAuth providers:
googlecalendar, googledrive, gmail, googlesheets, googledocs,
googleslides, slack, notion, salesforce, hubspot, linkedin, tiktok.

- Zod discriminated union schema with type discriminator per provider
- JSDoc links to official OAuth scope documentation for each provider
- JSONC file reading with validation (filename must match type field)
- API response schemas for upstream connector state
- Unit tests with fixtures for valid, invalid, and mismatched connectors

Part of: #184

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add API client methods for OAuth connector operations:
- listConnectors: list all connectors for current app
- syncConnector: sync connector with exact scope matching
- getOAuthStatus: poll OAuth authorization status
- removeConnector: remove a connector integration

Also update response schemas and clean up verbose comments.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat(connectors): implement push logic for syncing connectors

Add pushConnectors function that:
- Syncs all local connectors via /sync endpoint
- Removes upstream-only connectors not in local config
- Returns typed results (synced, removed, needs_oauth, error)

Includes unit tests covering all scenarios.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(connectors): add OAuth flow handling with browser redirect and polling (#192)

* feat(connectors): add OAuth flow handling with browser redirect and polling

Add runOAuthFlow function that:
- Opens OAuth redirect URL in browser
- Polls getOAuthStatus until ACTIVE or FAILED
- Returns PENDING on timeout (5 minutes)

Uses p-wait-for TimeoutError for robust timeout detection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* connectors: base44 connectors push (#194)

* final connector work sofi 1

* scopes

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Change provider field from closed enum to flexible union that accepts both
known providers (googlecalendar, notion, slack, etc.) and any arbitrary
provider string. This enables users to configure custom OAuth providers
without waiting for first-class Base44 support.

Schema changes:
- Add GenericConnectorSchema for arbitrary provider types
- Update ConnectorResourceSchema to union of specific + generic schemas
- Update IntegrationTypeSchema to accept known enum OR any non-empty string
- Only reject empty strings

Test coverage:
- Verify known providers continue to work
- Verify arbitrary providers are accepted
- Verify empty strings are rejected
- All 137 tests passing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Paveltarno and others added 7 commits February 10, 2026 14:05
- Update deployAll() to push connectors alongside entities, functions, and agents
- Update hasResourcesToDeploy() to check for connectors
- Display connector count in deployment summary
- Add test for connector deployment

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Paveltarno Paveltarno force-pushed the task-2-publish-connectors branch from 68ece4e to 11d6ca5 Compare February 10, 2026 15:28
Paveltarno and others added 3 commits February 11, 2026 10:09
Extract the OAuth prompt flow from connectors/push.ts into a shared
helper (oauth-prompt.ts) so both `connectors push` and `deploy` can
reuse it. The deploy command now surfaces connector results from
deployAll() and prompts the user to authorize when not in -y/CI mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The oauth-prompt helper should not know about process.env.CI — callers
pass skipPrompt: true when they detect CI, keeping the helper generic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Feb 11, 2026

Code review

Found 1 issue that needs attention:

Unused variable in OAuth handling (src/cli/commands/project/deploy.ts:98)
The variable pending is assigned but never used in the log message on lines 99-101. Users won't be informed which connectors need authorization.

Compare with the analogous code in src/cli/commands/connectors/push.ts lines 91-96 where pending is correctly interpolated into the message to show users which connectors are pending (e.g., "Pending: google_calendar, slack").

Suggested fix:
Change line 99-101 from:

log.info(
  `To authorize, run 'base44 connectors push' or open the links above in your browser.`
);

To:

log.info(
  `Pending: ${pending}. To authorize, run 'base44 connectors push' or open the links above in your browser.`
);

This will provide users with actionable information about which specific connectors require their attention.


Checked for bugs and CLAUDE.md compliance. All other changes follow the established patterns correctly.

@Paveltarno
Copy link
Collaborator Author

Re: comment

Fixed in f4d2ac1 - Added mockConnectorSet() to the deploy connector test.

Paveltarno and others added 2 commits February 11, 2026 10:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The connector names are already shown in the authorization URLs above,
so repeating them in the skip message is unnecessary.

Co-Authored-By: Claude Opus 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

Status: In progress

Development

Successfully merging this pull request may close these issues.

1 participant