Skip to content

Conversation

@ArtemHoruzhenko
Copy link
Contributor

@ArtemHoruzhenko ArtemHoruzhenko commented Dec 11, 2025

What

This PR implements the initial support for RDI API v2 client with automatic version detection and graceful fallback to v1.

Changes

New Features

1. ApiV2RdiClient - New client implementation for RDI API v2

  • Extends ApiRdiClient (v1) to inherit existing functionality
  • Implements getInfo() method to retrieve RDI instance information
  • Implements selectPipeline() method to automatically select the first available pipeline
  • Adds support for v2-specific endpoints (/api/v2/info, /api/v2/pipelines)

2. Smart Client Factory - Enhanced RdiClientFactory with version detection

  • Attempts to create v2 client first by calling getInfo() endpoint
  • If v2 API is available: initializes v2 client with connect() and selectPipeline()
  • If v2 API is unavailable: gracefully falls back to v1 client
  • Ensures backward compatibility with existing RDI instances

New Models & Types

  • RdiInfo - Model for RDI instance information (version)
  • GetInfoResponse - Response type for /api/v2/info endpoint
  • GetPipelinesResponse - Response type for /api/v2/pipelines endpoint
  • PipelineResponses - Interface for pipeline data structure
  • RdiUrlV2 - Constants for v2 API endpoints

Documentation

  • Added comprehensive JSDoc comments for getInfo() and selectPipeline() methods
  • Documented parameters, return types, exceptions, and usage examples

Tests

1. ApiV2RdiClient Tests (api.v2.rdi.client.spec.ts)

  • 10 tests covering getInfo() and selectPipeline() methods
  • Tests for success cases, error handling, and edge cases (null/undefined/empty data)
  • Validates proper transformation of API responses to model instances

2. RdiClientFactory Tests (enhanced rdi.client.factory.spec.ts)

  • 5 tests covering v2 client creation and v1 fallback scenarios
  • Tests for version detection logic
  • Tests for graceful degradation when v2 is unavailable
  • Tests for error handling in both v2 and v1 flows

Testing

Unit Tests

# Run all RDI tests
yarn test:api --testPathPattern=rdi

# Results: 176 tests passed ✓

@github-actions
Copy link
Contributor

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 92.33% 13983/15144
🟡 Branches 74.08% 4212/5686
🟢 Functions 85.89% 2149/2502
🟢 Lines 92.14% 13370/14510

Test suite run success

3003 tests passing in 288 suites.

Report generated by 🧪jest coverage report action from 27fd46a

@github-actions
Copy link
Contributor

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 77% 15450/20063
🟡 Branches 58.4% 6673/11426
🟡 Functions 63.71% 2072/3252
🟡 Lines 76.47% 14501/18962

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