RI-7682 Consume auto-generated apiClient types in the UI#5885
Open
KrumTy wants to merge 5 commits into
Open
Conversation
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>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
Code Coverage - Backend unit tests
Test suite run success3357 tests passing in 305 suites. Report generated by 🧪jest coverage report action from 6e6588a |
Contributor
Code Coverage - Integration Tests
|
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>
Contributor
Code Coverage - Frontend unit tests
Test suite run success6775 tests passing in 786 suites. Report generated by 🧪jest coverage report action from 6e6588a |
valkirilov
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Phase 2 of RI-7682 — replace every UI import from
apiSrc/*/src/*(BE) with the auto-generatedapiClienttypes produced by the postinstall script that landed in #5863. Flip theno-restricted-importslint rule for those patterns fromwarntoerrorso new BE -> FE coupling fails CI.Where the OpenAPI surface doesn't cover the type — socket.io payloads (
IMonitorData,PubSubMessage,SubscriptionDto), theIBulkActionOverviewfamily that the bulk-import controller declares astype: Objectin swagger, and the Azure OAuth callback values that ship vialocalStoragerather than HTTP — define FE-local equivalents in their existingslices/interfaces/*files (orconstants/azure.tsfor the Azure pair). Two stale imports that pointed at BE paths that no longer exist got fixed in passing:AddSentinelMasterResponse→CreateSentinelDatabaseResponse,GetCloudAccountShortInfoResponse→CloudAccountInfo.Three of the FE-local enum mirrors are on the REST surface and were straightforward to promote —
ListElementDestination,NodeRole,HealthStatusnow come fromapiClient. To make that work, addedenumName: 'X'on those 4@ApiProperty({ enum })decorator sites (Nest emits the enum as acomponents/schemas/Xreference instead of inlining the union) and configured@hey-api/typescriptto emitenums: 'typescript'withcase: 'PascalCase', so call sites keep readingNodeRole.Primaryrather than the defaultSCREAMING_SNAKE_CASE.A follow-up PR will continue the same pattern for the remaining ~30
@ApiProperty({ enum })decorators that still lackenumName, plus tighten optionality (@ApiProperty→@ApiPropertyOptionalwhere the field is TS-optional) and add@ApiPropertyfor runtime-present fields that the spec currently omits.Testing
grepconfirms zero remainingapiSrc/*/src/*imports underredisinsight/ui. A probe import errors out, confirming the guard at error level.yarn lintpasses.tscon the UI (verified —lint.ymlruns eslint only; tests usebabel-jestwhich strips types; thetype-check:uiscript is never invoked from a workflow). Build/test behavior is unchanged.tsc -p tsconfig.jsonfor context:mainhas 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.lastConnectionis required in swagger but optional in BE class;CommandExecutionResult.sizeLimitExceededsimilar;GetUserAgreementsResponseis missing fields that exist at runtime; factories usefaker.date.past()where the wire format isstring). 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 generatedapiClienttypes, 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-importsfor UI files to error onapiSrc/*andsrc/*imports, adjusts OpenAPI client generation to emit named TS enums (PascalCase) and updates a few BE Swagger decorators withenumNameso enums likeListElementDestination,NodeRole, andHealthStatuscan be consumed fromapiClient.CI reliability update. Extends the shared GitHub Action to generate
redisinsight/api-client/when caches restorenode_modulesandpostinstalldoesn’t run, preventing UI builds from failing to resolveapiClient.Reviewed by Cursor Bugbot for commit 6e6588a. Bugbot is set up for automated code reviews on this repo. Configure here.