Skip to content

RI-7682 Consume auto-generated apiClient types in the UI#5885

Open
KrumTy wants to merge 5 commits into
mainfrom
feature/RI-7682/consume-apiclient-types
Open

RI-7682 Consume auto-generated apiClient types in the UI#5885
KrumTy wants to merge 5 commits into
mainfrom
feature/RI-7682/consume-apiclient-types

Conversation

@KrumTy
Copy link
Copy Markdown
Contributor

@KrumTy KrumTy commented May 11, 2026

What

Phase 2 of RI-7682 — replace every UI import from apiSrc/* / src/* (BE) with the auto-generated apiClient types produced by the postinstall script that landed in #5863. Flip the no-restricted-imports lint rule for those patterns from warn to error so new BE -> FE coupling fails CI.

Where the OpenAPI surface doesn't cover the type — socket.io payloads (IMonitorData, PubSubMessage, SubscriptionDto), the IBulkActionOverview family that the bulk-import controller declares as type: Object in swagger, and the Azure OAuth callback values that ship via localStorage rather than HTTP — define FE-local equivalents in their existing slices/interfaces/* files (or constants/azure.ts for the Azure pair). Two stale imports that pointed at BE paths that no longer exist got fixed in passing: AddSentinelMasterResponseCreateSentinelDatabaseResponse, GetCloudAccountShortInfoResponseCloudAccountInfo.

Three of the FE-local enum mirrors are on the REST surface and were straightforward to promote — ListElementDestination, NodeRole, HealthStatus now come from apiClient. To make that work, added enumName: 'X' on those 4 @ApiProperty({ enum }) decorator sites (Nest emits the enum as a components/schemas/X reference instead of inlining the union) and configured @hey-api/typescript to emit enums: 'typescript' with case: 'PascalCase', so call sites keep reading NodeRole.Primary rather than the default SCREAMING_SNAKE_CASE.

A follow-up PR will continue the same pattern for the remaining ~30 @ApiProperty({ enum }) decorators that still lack enumName, plus tighten optionality (@ApiProperty@ApiPropertyOptional where the field is TS-optional) and add @ApiProperty for runtime-present fields that the spec currently omits.

Testing

  • grep confirms zero remaining apiSrc/* / src/* imports under redisinsight/ui. A probe import errors out, confirming the guard at error level.
  • yarn lint passes.
  • No CI gate runs tsc on the UI (verified — lint.yml runs eslint only; tests use babel-jest which strips types; the type-check:ui script is never invoked from a workflow). Build/test behavior is unchanged.
  • tsc -p tsconfig.json for context: main has 2498 errors, this branch has 2160 (−338 net). Of those, 795 main-only errors went away, 457 are new. The 457 are real BE↔FE shape-drift findings now visible after the type swap (e.g. RdiInstance.lastConnection is required in swagger but optional in BE class; CommandExecutionResult.sizeLimitExceeded similar; GetUserAgreementsResponse is missing fields that exist at runtime; factories use faker.date.past() where the wire format is string). None of these is a functional regression — type-only — and the follow-up PR addresses them at the source.

Refs RI-7682


Note

Medium Risk
Medium risk because it touches a large number of UI files and type definitions and tightens linting to fail CI, but changes are largely type/import rewiring with minimal runtime behavior impact (aside from new CI generation step).

Overview
Migrates the UI off backend-internal type imports. Replaces apiSrc/*/src/* imports across the UI with the generated apiClient types, and adds FE-local equivalents where the API surface doesn’t cover the shapes (e.g. bulkActions, monitor, pubsub, and Azure OAuth callback constants).

Hardens the boundary between BE and FE. Updates ESLint no-restricted-imports for UI files to error on apiSrc/* and src/* imports, adjusts OpenAPI client generation to emit named TS enums (PascalCase) and updates a few BE Swagger decorators with enumName so enums like ListElementDestination, NodeRole, and HealthStatus can be consumed from apiClient.

CI reliability update. Extends the shared GitHub Action to generate redisinsight/api-client/ when caches restore node_modules and postinstall doesn’t run, preventing UI builds from failing to resolve apiClient.

Reviewed by Cursor Bugbot for commit 6e6588a. Bugbot is set up for automated code reviews on this repo. Configure here.

KrumTy and others added 4 commits May 8, 2026 17:50
Replace all FE imports from `apiSrc/*` and `src/*` with the auto-generated
`apiClient` types (or FE-local replacements where the OpenAPI generator
inlines enums as string-literal unions and for socket.io shapes that aren't
part of the REST API). Flip the lint guard from warn to error so new
BE -> FE coupling fails CI.

Refs RI-7682

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Re-export pub-sub interfaces from slices/interfaces/index.ts so the
  FE-local PubSubMessage is reachable via uiSrc/slices/interfaces.
- Add MessagesResponse to the FE pub-sub interfaces (socket.io payload,
  not part of the REST surface, so the api-client does not generate it).
- Swap the stale RedisCloudDatabase and GetCloudAccountShortInfoResponse
  test annotations to the canonical CloudDatabase and CloudAccountInfo
  types from apiClient.

Refs RI-7682

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…lient

Adopt `enumName` on the three @ApiProperty({ enum, ... }) sites for
the enums currently mirrored in apiEnums.ts, so Nest emits each as a
referenced #/components/schemas/<Name> in openapi.json instead of an
inlined union literal. Flip @hey-api/typescript to emit named TS enums
with PascalCase member names (matching the BE source) so call sites
can use `NodeRole.Primary` as before.

Drop those three enums from apiEnums.ts and retarget UI consumers to
`apiClient`. Also consolidate the duplicate ListElementDestination
enum that lived in AddListElements.tsx onto the apiClient definition.

apiEnums.ts now only contains values that are NOT on the REST surface
(AzureAuthStatus and AZURE_OAUTH_STORAGE_KEY) — the Azure OAuth
callback ships its result FE-side via localStorage, so both sides
need the same constants without an HTTP contract.

Refs RI-7682

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop the temporary apiEnums.ts file now that all the REST-surface
enums it mirrored come from apiClient. AzureAuthStatus and
AZURE_OAUTH_STORAGE_KEY are FE/BE-shared values transmitted via the
OAuth callback HTML + localStorage rather than HTTP, so they live in
a dedicated constants/azure.ts.

Refs RI-7682

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@KrumTy KrumTy added the AI-Made label May 11, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 11, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 92.57% 15404/16641
🟡 Branches 74.48% 4813/6462
🟢 Functions 86.54% 2391/2763
🟢 Lines 92.39% 14720/15933

Test suite run success

3357 tests passing in 305 suites.

Report generated by 🧪jest coverage report action from 6e6588a

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 79.81% 17433/21843
🟡 Branches 62.26% 7970/12801
🟡 Functions 68.55% 2418/3527
🟡 Lines 79.37% 16390/20649

The `redisinsight/api-client/` directory is gitignored and produced by
the `postinstall` hook in `redisinsight/api/package.json`. When the
`actions/cache@v4` step restores the node_modules cache, install runs
are skipped and postinstall never fires, leaving the directory absent
on the runner.

This was harmless before because nothing in the UI imported from
`apiClient`. With the import migration in this PR, jest now resolves
those imports through its `moduleNameMapper` and fails with
"Could not locate module apiClient" on the cached install path.

Add an unconditional step at the end of the install action that
generates the client only if it isn't already present, so both fresh
installs (postinstall) and cached installs (this step) produce it.

Refs RI-7682

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.64% 24205/29289
🟡 Branches 67.83% 10188/15020
🟡 Functions 77.76% 6530/8398
🟢 Lines 83.11% 23659/28466

Test suite run success

6775 tests passing in 786 suites.

Report generated by 🧪jest coverage report action from 6e6588a

@KrumTy KrumTy marked this pull request as ready for review May 11, 2026 08:09
@KrumTy KrumTy requested a review from a team as a code owner May 11, 2026 08:09
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