Skip to content

Conversation

@fern-api
Copy link
Contributor

@fern-api fern-api bot commented Nov 26, 2025

This PR regenerates code to match the latest API Definition.

@jackfischer jackfischer merged commit c952d4d into main Nov 26, 2025
3 checks passed
@greptile-apps
Copy link

greptile-apps bot commented Nov 26, 2025

Greptile Overview

Greptile Summary

This PR regenerates the TypeScript SDK using Fern generator v3.34.0 (from v3.31.1), introducing centralized authentication handling through a new BearerAuthProvider class and bumping the SDK version to 0.1.13.

Key Changes

  • Introduced centralized BearerAuthProvider class that implements the AuthProvider interface, consolidating authentication logic previously duplicated across all client classes
  • Removed duplicate _getAuthorizationHeader() methods from all resource clients (copilots, documentCatalog, documentCollections, search, users)
  • All resource clients now obtain auth headers via authProvider.getAuthRequest() before making API calls
  • Added maxRetries: 0 to all test clients for improved test performance
  • Updated SDK version headers and package version to 0.1.13

Impact

This is a standard Fern regeneration that improves code maintainability by eliminating code duplication and centralizing authentication logic. The authentication behavior remains functionally equivalent—the SDK still supports passing apiKey explicitly or falling back to the CREDAL_API_KEY environment variable.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • This is an automated Fern SDK regeneration that refactors authentication handling into a cleaner, centralized pattern. All changes are mechanical refactorings with no logical modifications. The authentication behavior is preserved (same token resolution logic), tests are updated appropriately, and the code quality is improved through eliminating duplication.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/BaseClient.ts 5/5 Refactored auth handling: added BearerAuthProvider import, new typed normalization functions, updated SDK version to 0.1.13
src/Client.ts 5/5 Updated to use normalizeClientOptionsWithAuth and NormalizedClientOptionsWithAuth type
src/auth/BearerAuthProvider.ts 5/5 New file implementing centralized BearerAuthProvider class with getAuthRequest method and CREDAL_API_KEY environment fallback
src/api/resources/copilots/client/Client.ts 5/5 Replaced inline _getAuthorizationHeader method with centralized authProvider.getAuthRequest() pattern across all endpoints
src/api/resources/documentCatalog/client/Client.ts 5/5 Replaced inline _getAuthorizationHeader method with centralized authProvider.getAuthRequest() pattern across all endpoints
src/api/resources/documentCollections/client/Client.ts 5/5 Replaced inline _getAuthorizationHeader method with centralized authProvider.getAuthRequest() pattern across all endpoints
src/api/resources/search/client/Client.ts 5/5 Replaced inline _getAuthorizationHeader method with centralized authProvider.getAuthRequest() pattern
src/api/resources/users/client/Client.ts 5/5 Replaced inline _getAuthorizationHeader method with centralized authProvider.getAuthRequest() pattern

Sequence Diagram

sequenceDiagram
    participant User
    participant CredalClient
    participant BaseClient
    participant BearerAuthProvider
    participant ResourceClient
    participant API

    User->>CredalClient: new CredalClient({apiKey})
    CredalClient->>BaseClient: normalizeClientOptionsWithAuth(options)
    BaseClient->>BearerAuthProvider: new BearerAuthProvider(options)
    BearerAuthProvider-->>BaseClient: authProvider instance
    BaseClient-->>CredalClient: normalized options with authProvider

    User->>CredalClient: copilots.sendMessage(request)
    CredalClient->>ResourceClient: sendMessage(request)
    ResourceClient->>BearerAuthProvider: getAuthRequest()
    BearerAuthProvider->>BearerAuthProvider: Get token from options.apiKey or CREDAL_API_KEY env
    alt Token found
        BearerAuthProvider-->>ResourceClient: {headers: {Authorization: "Bearer <token>"}}
        ResourceClient->>ResourceClient: mergeHeaders(authHeaders, options.headers, request.headers)
        ResourceClient->>API: HTTP Request with Authorization header
        API-->>ResourceClient: Response
        ResourceClient-->>User: Result
    else Token not found
        BearerAuthProvider-->>ResourceClient: throw CredalError
        ResourceClient-->>User: Error: apiKey required
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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