Skip to content

Decouple ui/* from api/* via openapi types #4725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: fe/feature/RI-7039-replace-eui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bf14313
add openapi-generator-cli
KrumTy Jul 14, 2025
c7e81a8
run generate-client
KrumTy Jul 14, 2025
c14b283
update swagger fields
KrumTy Jul 14, 2025
4e88dce
use swagger generated dtos/models for some ui components
KrumTy Jul 14, 2025
08f82aa
update swagger docs
KrumTy Jul 14, 2025
6f14c82
update api documentation/swagger types
KrumTy Jul 15, 2025
f5aae22
decouple api src/* from ui
KrumTy Jul 15, 2025
bc2b1bc
decouple a lot of apiSrc/ references from ui
KrumTy Jul 15, 2025
b44b204
decouple more apiSrc/ from ui
KrumTy Jul 15, 2025
ca69d01
update api types
KrumTy Jul 15, 2025
0f214d6
update api types
KrumTy Jul 15, 2025
d7b481b
update api types
KrumTy Jul 15, 2025
6b01e88
use api types
KrumTy Jul 15, 2025
69d9b76
use api types
KrumTy Jul 16, 2025
9109723
update api types
KrumTy Jul 16, 2025
8cda749
fix types
KrumTy Jul 16, 2025
a138eca
update types
KrumTy Jul 16, 2025
6d40ba7
update types
KrumTy Jul 16, 2025
82c56a5
fix more type imports
KrumTy Jul 16, 2025
6645547
use more api types
KrumTy Jul 16, 2025
4ca94a9
decouple final apiSrc ui components
KrumTy Jul 16, 2025
12079de
remove apiSrc alias configs
KrumTy Jul 16, 2025
87a4e31
Merge remote-tracking branch 'origin/fe/feature/RI-7039-replace-eui' …
KrumTy Jul 16, 2025
2ed73d6
use single file for api-client
KrumTy Jul 16, 2025
5f4a9ae
update eslint configs
KrumTy Jul 16, 2025
3fbc9d7
revert service change
KrumTy Jul 16, 2025
7e45f36
fix ui issue
KrumTy Jul 16, 2025
07b800a
ignore api-client for jest coverage
KrumTy Jul 16, 2025
5c05cfb
Merge remote-tracking branch 'origin/fe/feature/RI-7039-replace-eui' …
KrumTy Jul 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ module.exports = {
group: 'internal',
position: 'after',
},
{
pattern: 'apiSrc/**',
group: 'internal',
position: 'after',
},
],
warnOnUnassignedImports: true,
pathGroupsExcludedImportTypes: ['builtin'],
Expand Down
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
'/node_modules/',
'<rootDir>/redisinsight/api',
'<rootDir>/redisinsight/ui/src/packages',
'<rootDir>/redisinsight/ui/src/api-client',
],
resolver: '<rootDir>/jest-resolver.js',
reporters: [
Expand Down
7 changes: 7 additions & 0 deletions redisinsight/api/openapitools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.14.0"
}
}
3 changes: 2 additions & 1 deletion redisinsight/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"format": "prettier --write \"src/**/*.ts\"",
"minify:prod": "node ./esbuild.js --production",
"minify:dev": "node ./esbuild.js --watch",
"generate-client": "openapi-generator-cli generate -i http://localhost:5540/api/docs-json -g typescript-axios -o ../ui/src/api-client",
"lint": "eslint --ext .ts .",
"start": "nest start",
"start:dev": "cross-env NODE_ENV=development nest start --watch",
Expand Down Expand Up @@ -106,6 +107,7 @@
"@nestjs/cli": "^11.0.6",
"@nestjs/schematics": "^11.0.5",
"@nestjs/testing": "^11.0.20",
"@openapitools/openapi-generator-cli": "^2.21.0",
"@types/adm-zip": "^0.5.0",
"@types/express": "^5.0.0",
"@types/ioredis-mock": "^8",
Expand Down Expand Up @@ -172,7 +174,6 @@
],
"moduleNameMapper": {
"src/(.*)": "<rootDir>/$1",
"apiSrc/(.*)": "<rootDir>/$1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so

"tests/(.*)": "<rootDir>/__tests__/$1"
},
"reporters": [
Expand Down
1 change: 0 additions & 1 deletion redisinsight/api/package.tmp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"testEnvironment": "node",
"moduleNameMapper": {
"src/(.*)": "<rootDir>/$1",
"apiSrc/(.*)": "<rootDir>/$1",
"tests/(.*)": "<rootDir>/__tests__/$1"
},
"setupFilesAfterEnv": ["../test/jest.setup.ts"]
Expand Down
1 change: 1 addition & 0 deletions redisinsight/api/src/common/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './is-bigger-than.decorator';
export * from './is-github-link.decorator';
export * from './database-management.decorator';
export * from './no-duplicates.decorator';
export * from './redis-string-schema.decorator';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ApiProperty } from '@nestjs/swagger';

export const REDIS_STRING_SCHEMA = {
type: String,
oneOf: [
{ type: 'string' },
{
type: 'object',
properties: {
type: { type: 'string', enum: ['Buffer'], example: 'Buffer' },
data: {
type: 'array',
items: { type: 'number' },
example: [61, 101, 49],
},
},
required: ['type', 'data'],
},
],
};

export const ApiRedisString = (
description: string = undefined,
isArray = false,
required = true,
) =>
ApiProperty({
description,
isArray,
required,
...REDIS_STRING_SCHEMA,
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { KeyDto } from 'src/modules/browser/keys/dto';
import { ApiProperty } from '@nestjs/swagger';
import { ArrayNotEmpty, IsArray, IsDefined } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class DeleteFieldsFromHashDto extends KeyDto {
@ApiProperty({
description: 'Hash fields',
type: String,
isArray: true,
})
@ApiRedisString('Hash fields', true)
@IsDefined()
@IsArray()
@ArrayNotEmpty()
Expand Down
18 changes: 8 additions & 10 deletions redisinsight/api/src/modules/browser/hash/dto/hash-field.dto.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsDefined, IsInt, IsOptional, Max, Min } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';
import { MAX_TTL_NUMBER } from 'src/constants';

export class HashFieldDto {
@ApiProperty({
description: 'Field',
type: String,
})
@ApiRedisString('Field')
@IsDefined()
@IsRedisString()
@RedisStringType()
field: RedisString;

@ApiProperty({
description: 'Field',
type: String,
})
@ApiRedisString('Field')
@IsDefined()
@IsRedisString()
@RedisStringType()
Expand Down
13 changes: 13 additions & 0 deletions redisinsight/api/src/modules/browser/hash/hash.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class HashController extends BrowserBaseController {
@ApiOperation({ description: 'Set key to hold Hash data type' })
@ApiRedisParams()
@ApiBody({ type: CreateHashWithExpireDto })
@ApiOkResponse({
description: 'Hash key created successfully',
})
@ApiQueryRedisStringEncoding()
async createHash(
@BrowserClientMetadata() clientMetadata: ClientMetadata,
Expand Down Expand Up @@ -75,6 +78,9 @@ export class HashController extends BrowserBaseController {
})
@ApiRedisParams()
@ApiBody({ type: AddFieldsToHashDto })
@ApiOkResponse({
description: 'Fields added to hash successfully',
})
@ApiQueryRedisStringEncoding()
async addMember(
@BrowserClientMetadata() clientMetadata: ClientMetadata,
Expand All @@ -89,6 +95,9 @@ export class HashController extends BrowserBaseController {
})
@ApiRedisParams()
@ApiBody({ type: UpdateHashFieldsTtlDto })
@ApiOkResponse({
description: 'Hash fields TTL updated successfully',
})
@ApiQueryRedisStringEncoding()
async updateTtl(
@BrowserClientMetadata() clientMetadata: ClientMetadata,
Expand All @@ -103,6 +112,10 @@ export class HashController extends BrowserBaseController {
})
@ApiRedisParams()
@ApiBody({ type: DeleteFieldsFromHashDto })
@ApiOkResponse({
description: 'Fields removed from hash',
type: DeleteFieldsFromHashResponse,
})
@ApiQueryRedisStringEncoding()
async deleteFields(
@BrowserClientMetadata() clientMetadata: ClientMetadata,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import { ArrayNotEmpty, IsArray, IsDefined } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class DeleteKeysDto {
@ApiProperty({
description: 'Key name',
type: String,
isArray: true,
})
@ApiRedisString('Key name', true)
@IsDefined()
@IsArray()
@ArrayNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsDefined, IsEnum, IsOptional } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';
import { KeyDto, RedisDataType } from './key.dto';

Expand All @@ -16,12 +20,7 @@ export class GetKeyInfoDto extends KeyDto {
}

export class GetKeysInfoDto {
@ApiProperty({
description: 'List of keys',
type: String,
isArray: true,
example: ['keys', 'key2'],
})
@ApiRedisString('List of keys', true)
@IsDefined()
@IsRedisString({ each: true })
@RedisStringType({ each: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { RedisStringType } from 'src/common/decorators';
import { RedisStringType, ApiRedisString } from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class GetKeyInfoResponse {
@ApiProperty({
type: String,
})
@ApiRedisString()
@RedisStringType()
name: RedisString;

Expand Down
12 changes: 6 additions & 6 deletions redisinsight/api/src/modules/browser/keys/dto/key.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDefined } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export enum RedisDataType {
Expand All @@ -16,10 +19,7 @@ export enum RedisDataType {
}

export class KeyDto {
@ApiProperty({
description: 'Key Name',
type: String,
})
@ApiRedisString('Key Name')
@IsDefined()
@IsRedisString()
@RedisStringType()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDefined } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';
import { KeyDto } from './key.dto';

export class RenameKeyDto extends KeyDto {
@ApiProperty({
description: 'New key name',
type: String,
})
@ApiRedisString('New key name')
@IsDefined()
@IsRedisString()
@RedisStringType()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDefined } from 'class-validator';
import { IsRedisString, RedisStringType } from 'src/common/decorators';
import {
ApiRedisString,
IsRedisString,
RedisStringType,
} from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class KeyResponse {
@ApiProperty({
description: 'Key Name',
type: String,
})
@ApiRedisString('keyName')
@IsDefined()
@IsRedisString()
@RedisStringType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class KeysController {
@ApiOkResponse({
description: 'Keys list',
type: GetKeysWithDetailsResponse,
isArray: true,
})
@ApiQueryRedisStringEncoding()
async getKeys(
Expand All @@ -60,7 +61,8 @@ export class KeysController {
@ApiRedisParams()
@ApiOkResponse({
description: 'Info for multiple keys',
type: GetKeysWithDetailsResponse,
type: GetKeyInfoResponse,
isArray: true,
})
@ApiQueryRedisStringEncoding()
async getKeysInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { ApiProperty } from '@nestjs/swagger';
import { RedisStringType } from 'src/common/decorators';
import { ApiRedisString, RedisStringType } from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class DeleteListElementsResponse {
@ApiProperty({
type: String,
isArray: true,
description: 'Removed elements from list',
})
@ApiRedisString('Removed elements from list', true)
@RedisStringType({ each: true })
elements: RedisString[];
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { KeyResponse } from 'src/modules/browser/keys/dto';
import { ApiProperty } from '@nestjs/swagger';
import { RedisStringType } from 'src/common/decorators';
import { ApiRedisString, RedisStringType } from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class GetListElementResponse extends KeyResponse {
@ApiProperty({
type: () => String,
description: 'Element value',
})
@ApiRedisString('Element value')
@RedisStringType()
value: RedisString;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KeyResponse } from 'src/modules/browser/keys/dto';
import { ApiProperty } from '@nestjs/swagger';
import { RedisStringType } from 'src/common/decorators';
import { ApiRedisString, RedisStringType } from 'src/common/decorators';
import { RedisString } from 'src/common/constants';

export class GetListElementsResponse extends KeyResponse {
Expand All @@ -10,11 +10,7 @@ export class GetListElementsResponse extends KeyResponse {
})
total: number;

@ApiProperty({
type: () => String,
description: 'Array of elements.',
isArray: true,
})
@ApiRedisString('Elements', true)
@RedisStringType({ each: true })
elements: RedisString[];
}
Loading
Loading