Skip to content

EPMRPP-89496 || Migrate client-javascript to TypeScript#271

Open
maria-hambardzumian wants to merge 3 commits into
developfrom
feature/EPMRPP-89496-migrate-to-typescript
Open

EPMRPP-89496 || Migrate client-javascript to TypeScript#271
maria-hambardzumian wants to merge 3 commits into
developfrom
feature/EPMRPP-89496-migrate-to-typescript

Conversation

@maria-hambardzumian

@maria-hambardzumian maria-hambardzumian commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added public import paths for constants, helpers, and models.
    • Introduced shared, typed definitions for statuses, launch modes, event identifiers, and request/response shapes.
  • Improvements
    • Enhanced proxy behavior with safer URL redaction in logs.
    • Improved request timeout/retry, OAuth error handling, and more resilient logging.
  • Build & Publishing
    • Added an extra build step before publishing; refined npm-published artifacts and typings entry.
  • Testing
    • Expanded Jest TypeScript support and adjusted coverage to focus on source modules.
  • Breaking Changes
    • Removed legacy/public type declarations and older compiled public modules.

@maria-hambardzumian

maria-hambardzumian commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

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

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

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The pull request migrates the client from CommonJS JavaScript to typed TypeScript, adds public models and constants, updates REST/OAuth/proxy/reporting modules, and changes Jest, compiler, npm packaging, and publishing configuration to build from src.

Changes

TypeScript migration and public contracts

Layer / File(s) Summary
Public contracts and build layout
src/lib/models/*, src/lib/constants/*, src/types/vendor.d.ts, tsconfig.json, jest.config.js, package.json, src/models.ts, src/helpers.ts, src/constants.ts
Adds typed request, response, configuration, model, constant, vendor declarations, public entrypoints, and source-based build/test packaging.
Client and REST request flow
src/lib/report-portal-client.ts, src/lib/rest.ts
Types lifecycle operations, logging, multipart uploads, retries, headers, REST responses, and error handling.
Configuration, helpers, authentication, and proxy runtime
src/lib/commons/*, src/lib/helpers.ts, src/lib/logger.ts, src/lib/oauth.ts, src/lib/proxyHelper.ts, src/lib/pjson.ts
Converts runtime utilities to typed modules, normalizes configuration, and types OAuth, proxy, logging, and package metadata handling.
Reporting events and statistics
src/lib/publicReportingAPI.ts, src/statistics/*
Adds typed reporting event emission, statistics collection, client identification, and related constants.
Source-based tests and publishing checks
__tests__/*, .github/workflows/publish.yml, .gitignore, .eslintrc
Updates tests to load source modules, adds OAuth and REST coverage, adjusts lint rules, ignores emitted files, and builds before publication.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: amsterget

Poem

A rabbit typed each launch with care,
OAuth hopped through proxy air.
Tests now follow source paths bright,
Builds prepare the package right.
Carrots compile, then publish cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating client-javascript to TypeScript.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/EPMRPP-89496-migrate-to-typescript

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/oauth.ts (1)

52-60: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Honor the supplied OAuth debug option.

RestClient passes debug into this constructor, but Line 60 ignores it and reads only restClientConfig.debug. Client-level OAuth diagnostics are therefore disabled unless the nested REST option is also set.

Proposed fix
-    this.debug = this.restClientConfig.debug || false;
+    this.debug = config.debug ?? this.restClientConfig.debug ?? false;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/oauth.ts` around lines 52 - 60, Update the OAuthInterceptor
constructor’s debug assignment to honor the supplied OAuth-level config.debug
value passed by RestClient, while preserving the existing restClientConfig.debug
fallback when the OAuth option is absent.
🧹 Nitpick comments (2)
jest.config.js (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid disabling TypeScript diagnostics without a required CI typecheck.

diagnostics: false lets Jest execute code with broken TypeScript contracts, weakening the migration’s validation. Keep diagnostics enabled or ensure CI runs tsc --noEmit as a required check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@jest.config.js` at line 3, Update the ts-jest configuration in the TypeScript
transform entry to remove diagnostics: false so Jest performs TypeScript
diagnostics, or alternatively add a required CI tsc --noEmit check. Preserve the
existing tsconfig.json configuration.
.eslintrc (1)

24-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Scope the disabled import rules instead of disabling them globally.

Turning off import/no-unresolved and import/extensions for the entire repository can hide broken imports outside the TypeScript source. Prefer configuring the TypeScript resolver or applying overrides only to the affected files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.eslintrc around lines 24 - 27, Update the ESLint configuration entries for
import/no-unresolved and import/extensions to apply only through a
TypeScript-specific resolver or targeted file overrides, rather than disabling
them repository-wide. Preserve the existing camelcase and valid-jsdoc settings,
and ensure unaffected JavaScript files continue receiving import validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@__tests__/oauth.spec.js`:
- Around line 5-7: The axios mock’s isAxiosError implementation in the
jest.mock('axios', ...) block incorrectly identifies errors by response
presence; match real Axios by requiring error.isAxiosError === true, and update
the test’s rejected error value to include isAxiosError: true when it represents
an AxiosError.

In `@src/lib/rest.ts`:
- Around line 53-59: Export the RestClientOptions interface so the
ConstructorParameters<typeof RestClient>[0] type used by helpers.getServerResult
remains publicly nameable during declaration emit. Change only the interface’s
visibility and preserve its existing fields and types.

---

Outside diff comments:
In `@src/lib/oauth.ts`:
- Around line 52-60: Update the OAuthInterceptor constructor’s debug assignment
to honor the supplied OAuth-level config.debug value passed by RestClient, while
preserving the existing restClientConfig.debug fallback when the OAuth option is
absent.

---

Nitpick comments:
In @.eslintrc:
- Around line 24-27: Update the ESLint configuration entries for
import/no-unresolved and import/extensions to apply only through a
TypeScript-specific resolver or targeted file overrides, rather than disabling
them repository-wide. Preserve the existing camelcase and valid-jsdoc settings,
and ensure unaffected JavaScript files continue receiving import validation.

In `@jest.config.js`:
- Line 3: Update the ts-jest configuration in the TypeScript transform entry to
remove diagnostics: false so Jest performs TypeScript diagnostics, or
alternatively add a required CI tsc --noEmit check. Preserve the existing
tsconfig.json configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fffa4a88-0e2d-4af0-a88e-987e39f808e7

📥 Commits

Reviewing files that changed from the base of the PR and between 97b9c82 and e383ed9.

📒 Files selected for processing (49)
  • .eslintrc
  • .github/workflows/publish.yml
  • .gitignore
  • __tests__/client-id.spec.js
  • __tests__/config.spec.js
  • __tests__/helpers.spec.js
  • __tests__/oauth.spec.js
  • __tests__/proxyHelper.spec.js
  • __tests__/publicReportingAPI.spec.js
  • __tests__/report-portal-client.spec.js
  • __tests__/rest.spec.js
  • __tests__/statistics.spec.js
  • index.d.ts
  • jest.config.js
  • lib/constants/events.js
  • lib/constants/statuses.js
  • lib/publicReportingAPI.js
  • package.json
  • src/constants.ts
  • src/helpers.ts
  • src/lib/commons/config.ts
  • src/lib/commons/errors.ts
  • src/lib/constants/events.ts
  • src/lib/constants/index.ts
  • src/lib/constants/launchModes.ts
  • src/lib/constants/logLevels.ts
  • src/lib/constants/outputs.ts
  • src/lib/constants/statuses.ts
  • src/lib/constants/testItemTypes.ts
  • src/lib/helpers.ts
  • src/lib/logger.ts
  • src/lib/models/common.ts
  • src/lib/models/config.ts
  • src/lib/models/index.ts
  • src/lib/models/requests.ts
  • src/lib/models/responses.ts
  • src/lib/oauth.ts
  • src/lib/pjson.ts
  • src/lib/proxyHelper.ts
  • src/lib/publicReportingAPI.ts
  • src/lib/report-portal-client.ts
  • src/lib/rest.ts
  • src/models.ts
  • src/statistics/client-id.ts
  • src/statistics/constants.ts
  • src/statistics/statistics.ts
  • src/types/vendor.d.ts
  • statistics/constants.js
  • tsconfig.json
💤 Files with no reviewable changes (5)
  • lib/publicReportingAPI.js
  • lib/constants/statuses.js
  • statistics/constants.js
  • lib/constants/events.js
  • index.d.ts

Comment thread __tests__/oauth.spec.js Outdated
Comment thread src/lib/rest.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
__tests__/oauth.spec.js (1)

403-433: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the proxy wiring, not only the log.

This test proves that the proxy branch is entered, but not that axios.post receives the appropriate agent and proxy: false. Capture the request config and assert those fields to protect the actual proxy contract.

Suggested assertion
     expect(consoleSpy).toHaveBeenCalledWith(
       `[OAuth] Making token request to ${baseConfig.tokenEndpoint} with proxy agent`,
       '',
     );
+    const requestConfig = axios.post.mock.calls[0][2];
+    expect(requestConfig.proxy).toBe(false);
+    expect(requestConfig.httpsAgent ?? requestConfig.httpAgent).toBeDefined();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@__tests__/oauth.spec.js` around lines 403 - 433, Update the test “logs the
proxied token request when debug and proxy are both enabled” to capture the
config passed to axios.post and assert that the request uses the configured
proxy agent and sets proxy to false, while preserving the existing token and log
assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@__tests__/oauth.spec.js`:
- Around line 403-433: Update the test “logs the proxied token request when
debug and proxy are both enabled” to capture the config passed to axios.post and
assert that the request uses the configured proxy agent and sets proxy to false,
while preserving the existing token and log assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fcf07188-9241-4267-a4c8-e47ac9002ea1

📥 Commits

Reviewing files that changed from the base of the PR and between e383ed9 and 8a069ec.

📒 Files selected for processing (7)
  • .eslintrc
  • __tests__/oauth.spec.js
  • __tests__/rest.spec.js
  • src/helpers.ts
  • src/lib/commons/config.ts
  • src/lib/models/config.ts
  • src/lib/rest.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/helpers.ts
  • tests/rest.spec.js
  • .eslintrc
  • src/lib/models/config.ts
  • src/lib/commons/config.ts
  • src/lib/rest.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/report-portal-client.ts (1)

375-385: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Propagate REST failures instead of converting them to success.

mergeLaunches continues with launch/merge after a search failure, using an empty launch list, and both merge and file-upload catches resolve normally. This can issue invalid merge requests and make failed log uploads appear successful.

Proposed fix
-          (error): Array<string | number> => {
+          (error) => {
             this.logDebug(`Error during launches search with UUIDs: ${launchUUIds}`, error);
             console.dir(error);
-            return [];
+            throw error;
           },
...
         .catch((error) => {
           this.logDebug(`Error merging launches with UUIDs: ${launchUUIds}`, error);
           console.dir(error);
+          throw error;
         });
...
       .catch((error) => {
         this.logDebug(`Error save log with file: ${fileObj.name}`, error);
         console.dir(error);
+        throw error;
       });

Also applies to: 393-396, 721-734

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/report-portal-client.ts` around lines 375 - 385, Update mergeLaunches
and the related file-upload error handlers to rethrow or reject REST failures
after logging instead of returning successful fallback values. In the launch
UUID search catch, do not continue to getMergeLaunchesRequest or call
launch/merge with an empty list; ensure the promise remains rejected. Apply the
same failure propagation to the catches around the upload flow at the referenced
symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/lib/report-portal-client.ts`:
- Around line 375-385: Update mergeLaunches and the related file-upload error
handlers to rethrow or reject REST failures after logging instead of returning
successful fallback values. In the launch UUID search catch, do not continue to
getMergeLaunchesRequest or call launch/merge with an empty list; ensure the
promise remains rejected. Apply the same failure propagation to the catches
around the upload flow at the referenced symbols.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a827787d-3d6f-46f4-8b06-1698f26f436c

📥 Commits

Reviewing files that changed from the base of the PR and between 8a069ec and af4ffe1.

📒 Files selected for processing (3)
  • __tests__/report-portal-client.spec.js
  • src/lib/models/requests.ts
  • src/lib/report-portal-client.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/report-portal-client.spec.js
  • src/lib/models/requests.ts

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.

1 participant