Skip to content

Commit a968777

Browse files
Kristiyan Ivanovrsergeenkovlad-dargelArtemHoruzhenkomariasergeenko
authored
Be/feature/ri 5876 fix start electron dev mode (#4021)
* Change the wording on the native browser authentication page * RI-5876-Fix start electron dev mode Initial working POC - to be cleaned * RI-5876 Fix start electron dev mode - cleanup * RI-5876 Fix Electron in dev mode -> fix for window validation in dev (POC) * RI-5876 Fix start electron dev mode - clean up and hardcoded values * RI-5876 fix start electron dev mode - fixed auth flow for dev with tcp * RI-5876 Fix start electron dev mode - cleanup * RI-5876 fix start electron dev - cleanup * RI-5876 fix electron dev mode - further cleanup and removal of * RI-5876 * RI-5876 Fix start electron dev mode * RI-5876 fix electron dev mode - removed hardcoded if statement * RI-5876 fix electron dev mode - removed unused dependency * RI-5876 cleanup * RI-5876 cleanup * RI-5876 cleanup * RI-5876 cleanup * RI-5876 - cleaned up console.logs * RI-5876 fixed eslint errors * RI-6876 fixed api test (#4022) * Ri 5876 fix start electron dev mode (#4023) * refactoring * #RI-6061 - fix overflow * #RI-6062 - add initial commands json * changes from main * #RI-6026 - support apply functions, filter expressions, reducer functions * #RI-6026 - add tests, fix tests * #RI-6026 - remove console.log * #RI-6027 - add completion types for query fields * #RI-6027 - remove commented code * add profile and explain tests * fixes * add waiter because of slow work of suggestions * add env variable for local * add env * add method for selecting query * #RI-6091 - fix highlighting #RI-6093 - fix expression suggestions * init implementation * #RI-6079 - update colors * test for APPLY, FILTER and REDUCE * fix tests + small rework * fix tests * fix tests * test for suggestions for fields * add migrations * #RI-5992 - update search and query history * #RI-6079 - update colors #RI-6099 - highlight fields * #RI-6108 - fix clear results #RI-6109 - fix history #RI-6110 - fix profile/explain * add tests for search history * remove unused meta * #RI-6086 - fix number of args next to count #RI-6088 - fix multiple arguments * revert theme * Dynamically show multiple byte formats * #RI-6100 - merge colors * #RI-6111 - fix suggestions * fix vector * #RI-6119 - move browser pages from tabs to menu * #RI-6119 - add tests, fix test * Add support for 1000 base which is used for network metrics * Remove console log * refactoring * fix some issues * #RI-6085 - fix sending query * #RI-6089 - add support ft commands * #RI-6089 - fix suggestions * #RI-6137 - update quotes and colors * #RI-6135 - cover no indexes case * fix last page context * #RI-6135 - update link * #RI-6135 - fix tests * add test when there is no index * RI-6089_support-ft-commands * RI-6141 update rdi last connection on each connect * #RI-6151 - initial implementation of search suggestions in the workbench * RI-6191 fixed text * RI-6153 renamed and added tooltips to dry-run panel tabs * #RI-6151 - search suggestions in the workbench, refactoring * #RI-6151 - fix pr comments * Fixed tests flagged by Maria * remove separate tab * RI-6141 await rdiClient before updating * Update README.md * fix part of tests * temp fix * recommendation fix * fix for tutorials * fix for tutorials#2 * #RI-6173, #RI-6177, #RI-6178, #RI-6182, #RI-6183 - fix bugs * Update README.md * #RI-6158 - Migrate build workflows from CircleCI to Github Actions * fix monitor typo * #RI-6158 - Migrate build workflows from CircleCI to Github Actions * #RI-6158 - Migrate build workflows from CircleCI to Github Actions * #RI-6158 - Migrate build workflows from CircleCI to Github Actions * #RI-6158 - Migrate build workflows from CircleCI to Github Actions * update response * #RI-6203 - fix suggestions * unskip * #RI-6158 - Turn off auto run Unit tests * #RI-6158 - Turn off auto run Unit tests * #RI-6158 - Add $ENV to docker build * add fix for headers * comment check * #RI-6132 - update sanitizer * Delete .github/README.md * remove brocken commands * #RI-6217 - fix suggestions #RI-6218 - fix cypher editor * small refactoring * update existing tests * Fix zero byte case * update root dependencies * update * remove opening by keyboard * move to newest class-transformer and class-validator * #RI-6221 - fix arguments in details * update jest * update root dependencies * fix tests * fix unit tests * upgrade nest packages * the rest of nestjs libraries * fix the rest of the modules + electron * setup codeql to ignore test files/folders * exclude api/test folder from codeql analysis * upgrade all the packages * upgrade all the packages * #RI-6222 - fix auto-suggest at first column * start refactoring * bump ip * fix pr comments * bump ts-node * fix minifying * ts fixes * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * test * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6228 - fix load all, composite args * add ui tests * fix * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * #RRI-6172 - remove search page * fix2 * rollback class-transform to 0.3.x (0.3.1) * upgrade nestjs + okta packages. cleanup resolutions * degrade nest-form-data * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * test * #RI-6213 - Migrate release workflows from CircleCI to Github Actions * RI-6220 removed rdi pipeline template * upgrade webpack * upgrade msw/cookie * RI-6225 social button fix * e2e/feature/RI-6220_remove-rdi-pipeline-template * RI-6240 fix tooltip style * #RI-6234 - fix error showing when no indexes * RI-6171 User cannot create vector index using form * e2e/bugfix/tsconfig-fix * RI-6171 User cannot create vector index using form - updated tests * Simplified check based on suggestion from Roman * e2e/bugfix/fir-delete-all-keys-redis * #RI-6208 - improve switch between redis and search syntax, add command scope #RI-6211 - fix highlighting when there are several the same args * #RI-6226 - add sorting for list of commands #RI-6244 - fix finding of command * e2e/feature/RI-6226_change_sorting_for_ft * fix ts issue * fix ITests * fix detail token * fix ITests * Fix Dockerfile * RI-6876 fixed api test --------- Co-authored-by: Roman Sergeenko <[email protected]> Co-authored-by: vlad-dargel <[email protected]> Co-authored-by: Vlad <[email protected]> Co-authored-by: ArtemHoruzhenko <[email protected]> Co-authored-by: mariasergeenko <[email protected]> Co-authored-by: Gnanesh <[email protected]> Co-authored-by: kchepikava <[email protected]> Co-authored-by: ViktarStarastsenka <[email protected]> Co-authored-by: zalenskiSofteq <[email protected]> Co-authored-by: yangw <[email protected]> * RI-5876 removed the custom-tutorials submitted from testin * RI-5876 yarn.lock updates * added a command to run api, ui and desktop at the same time * RI-5876 Renamed new command * RI-5876 updated postinstall scripts * RI-5876 fixes around the build flow * fixes around the build * RI-5876 WIP (build works without window ids - bug) * RI-5876 WIP build updates * RI-5876 WIP builds * RI-5876 rollback on some changes * RI-5876 clean up * RI-5876 cleanup * RI-5876 cleanup * RI-5876 cleanup * RI-5876 cleanup * RI-5876 cleanup * RI-5876 circular dependency solved * RI-5876 resolved dependency and all changes * RI-5876 clean up * RI-5876 fixed wrong enum import * RI-5876 cleaning up the PR * removed unused file * RI-5876 cleanup unused variables * RI-5876 cleanedup electron-dev conig * RI-5876 simplified electron-builder.dev * RI-5876 removed unused properties * RI-5876 removed unecesary differences * RI-5876 cleared up feedback (process.env.development checks and unused files) * RI-5876 Cleared up PR feedback * RI-5876 removed unused file * RI-5876 - PR feedback from Artem * RI-6876 cleared up prettier issue * RI-5876 - feedback from Artem - abstraction for the TCP approach on desktop side * RI-5876 - further PR improvements and cleanup * reverted yarn.lock to main's * rollback to main --------- Co-authored-by: Roman Sergeenko <[email protected]> Co-authored-by: vlad-dargel <[email protected]> Co-authored-by: Vlad <[email protected]> Co-authored-by: ArtemHoruzhenko <[email protected]> Co-authored-by: mariasergeenko <[email protected]> Co-authored-by: Gnanesh <[email protected]> Co-authored-by: kchepikava <[email protected]> Co-authored-by: ViktarStarastsenka <[email protected]> Co-authored-by: zalenskiSofteq <[email protected]> Co-authored-by: yangw <[email protected]>
1 parent a001f0c commit a968777

35 files changed

+526
-104
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
root: true,
33
env: {
44
node: true,
5+
browser: true,
56
},
67
extends: ['airbnb-typescript'],
78
plugins: ['@typescript-eslint'],

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"license": "SSPL",
66
"private": true,
77
"scripts": {
8-
"dev:ui": "yarn --cwd redisinsight/ui dev",
8+
"dev:ui": "cross-env yarn --cwd redisinsight/ui dev",
9+
"dev:api": "cross-env yarn --cwd redisinsight/api start:dev",
10+
"dev:electron:ui": "cross-env RI_APP_PORT=8080 RI_APP_TYPE=electron NODE_ENV=development yarn --cwd redisinsight/ui dev",
11+
"dev:electron:api": "cross-env RI_APP_PORT=5540 RI_APP_TYPE=electron NODE_ENV=development USE_TCP_CLOUD_AUTH=true yarn --cwd redisinsight/api start:dev",
12+
"dev:electron": "cross-env RI_APP_TYPE=electron RI_AUTO_BOOTSTRAP=false NODE_ENV=development USE_TCP_CLOUD_AUTH=true yarn --cwd redisinsight/desktop dev",
13+
"dev:desktop": "concurrently \"yarn dev:electron:api\" \"yarn dev:electron:ui\" \"yarn dev:electron\"",
914
"build:ui": "cross-env NODE_ENV=production RI_APP_TYPE=web yarn --cwd redisinsight/ui build",
1015
"build:renderer": "cross-env NODE_ENV=production RI_APP_TYPE=electron yarn --cwd redisinsight/ui build --emptyOutDir && copyfiles ./redisinsight/desktop/splash.html ./redisinsight/dist/renderer -f",
1116
"stats:ui": "yarn --cwd redisinsight/ui stats",
@@ -23,6 +28,7 @@
2328
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
2429
"lint:ui": "eslint ./redisinsight/ui --ext .js,.jsx,.ts,.tsx",
2530
"lint:api": "yarn --cwd redisinsight/api lint",
31+
"lint:desktop": "eslint ./redisinsight/desktop",
2632
"lint:e2e": "yarn --cwd tests/e2e lint",
2733
"package": "yarn package:dev",
2834
"package:prod": "ts-node ./scripts/prebuild.js dist && yarn build:prod && electron-builder build -p never",
@@ -34,8 +40,10 @@
3440
"package:mac": "yarn build:prod && electron-builder build --mac -p never",
3541
"package:mac:arm": "yarn build:prod && electron-builder build --mac --arm64 -p never",
3642
"package:linux": "yarn build:prod && electron-builder build --linux -p never",
37-
"postinstall": "patch-package && vite optimize && skip-postinstall || (electron-builder install-app-deps && yarn-deduplicate yarn.lock)",
43+
"postinstall": "patch-package && vite optimize -c ./redisinsight/ui/vite.config.mjs && skip-postinstall || (electron-builder install-app-deps && yarn-deduplicate yarn.lock)",
3844
"test": "jest ./redisinsight/ui -w 1",
45+
"test:api": "yarn --cwd redisinsight/api test",
46+
"test:api:integration": "yarn --cwd redisinsight/api test:api",
3947
"test:watch": "jest ./redisinsight/ui --watch -w 1",
4048
"test:cov": "cross-env NODE_OPTIONS='' jest ./redisinsight/ui --silent --coverage --no-cache --forceExit -w 3",
4149
"test:cov:unit": "jest ./redisinsight/ui --group=-component --coverage -w 1",
@@ -244,6 +252,7 @@
244252
"monaco-editor": "^0.48.0",
245253
"monaco-yaml": "^5.1.1",
246254
"msgpackr": "^1.10.1",
255+
"node-abi": "^3.71.0",
247256
"pako": "^2.1.0",
248257
"php-serialize": "^4.0.2",
249258
"pickleparser": "^0.2.1",
@@ -280,4 +289,4 @@
280289
"browser": {
281290
"uuid": "./node_modules/uuid/dist/esm-browser/index.js"
282291
}
283-
}
292+
}

redisinsight/api/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function bootstrap(apiPort?: number): Promise<IApp> {
4949
app.use(bodyParser.urlencoded({ limit: '512mb', extended: true }));
5050
app.enableCors();
5151

52-
if (process.env.RI_APP_TYPE !== 'electron') {
52+
if (process.env.RI_APP_TYPE !== 'electron' || process.env.NODE_ENV === 'development') {
5353
let prefix = serverConfig.globalPrefix;
5454
if (serverConfig.proxyPath) {
5555
prefix = posix.join(serverConfig.proxyPath, prefix);

redisinsight/api/src/modules/auth/window-auth/middleware/window.auth.middleware.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import ERROR_MESSAGES from 'src/constants/error-messages';
44
import { API_HEADER_WINDOW_ID } from 'src/common/constants';
55
import { WindowAuthService } from '../window-auth.service';
66
import { WindowUnauthorizedException } from '../constants/exceptions';
7+
import config from 'src/utils/config';
78

89
@Injectable()
910
export class WindowAuthMiddleware implements NestMiddleware {
1011
private logger = new Logger('WindowAuthMiddleware');
11-
1212
constructor(private windowAuthService: WindowAuthService) {}
1313

1414
async use(req: Request, res: Response, next: NextFunction): Promise<any> {
1515
const { windowId } = WindowAuthMiddleware.getWindowIdFromReq(req);
16+
1617
const isAuthorized = await this.windowAuthService.isAuthorized(windowId);
1718

1819
if (!isAuthorized) {

redisinsight/api/src/modules/auth/window-auth/window-auth.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export class WindowAuthModule implements NestModule {
1515
.exclude(...SERVER_CONFIG.excludeAuthRoutes)
1616
.forRoutes('*');
1717
}
18-
}
18+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { Injectable, Logger } from '@nestjs/common';
2+
import { createServer, Server } from 'net';
3+
import { CloudAuthStrategy } from './cloud-auth.strategy';
4+
import { CloudAuthService } from '../cloud-auth.service';
5+
6+
@Injectable()
7+
export class TcpCloudAuthStrategy extends CloudAuthStrategy {
8+
private authPort = process.env.TCP_LOCAL_CLOUD_AUTH_PORT ? parseInt(process.env.TCP_LOCAL_CLOUD_AUTH_PORT) : 5542;
9+
private server: Server;
10+
private readonly logger = new Logger('TcpCloudAuthStrategy');
11+
12+
constructor(private readonly cloudAuthService: CloudAuthService) {
13+
super();
14+
15+
this.initServer();
16+
}
17+
18+
private initServer() {
19+
this.server = createServer((socket) => {
20+
socket.setEncoding('utf8');
21+
22+
socket.on('data', async (data) => {
23+
try {
24+
this.logger.debug(`Received raw data: ${data.toString()}`);
25+
const { action, options } = JSON.parse(data.toString());
26+
this.logger.debug('Parsed request:', { action, options });
27+
28+
if (action === 'getAuthUrl') {
29+
try {
30+
const url = await this.cloudAuthService.getAuthorizationUrl(
31+
options.sessionMetadata,
32+
options.authOptions
33+
);
34+
this.logger.debug('Generated URL:', url);
35+
socket.write(JSON.stringify({ success: true, url }));
36+
} catch (err) {
37+
this.logger.error('Error getting authorization URL:', err);
38+
socket.write(JSON.stringify({
39+
success: false,
40+
error: err.message,
41+
details: err.stack,
42+
context: { action, options } // Add the context to help debug
43+
}));
44+
}
45+
} else if (action === 'handleCallback') {
46+
try {
47+
this.logger.debug('Handling callback with query:', options.query);
48+
const result = await this.cloudAuthService.handleCallback(options.query);
49+
socket.write(JSON.stringify({ success: true, result }));
50+
} catch (err) {
51+
this.logger.error('Error handling callback:', err);
52+
socket.write(JSON.stringify({
53+
success: false,
54+
error: err.message,
55+
details: err.stack
56+
}));
57+
}
58+
}
59+
} catch (err) {
60+
this.logger.error('Error processing request:', err);
61+
socket.write(JSON.stringify({
62+
success: false,
63+
error: err.message,
64+
details: err.stack
65+
}));
66+
}
67+
socket.end();
68+
});
69+
70+
socket.on('end', () => {
71+
this.logger.debug('Client connection ended');
72+
});
73+
74+
socket.on('error', (err) => {
75+
this.logger.error('Socket error:', err);
76+
});
77+
});
78+
79+
this.server.listen(this.authPort, () => {
80+
this.logger.log(`TCP server listening on port ${this.authPort}`);
81+
});
82+
83+
this.server.on('error', (err) => {
84+
this.logger.error('Server error:', err);
85+
});
86+
}
87+
}

redisinsight/api/src/modules/cloud/auth/cloud-auth.module.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SsoIdpCloudAuthStrategy } from 'src/modules/cloud/auth/auth-strategy/ss
66
import { CloudAuthService } from 'src/modules/cloud/auth/cloud-auth.service';
77
import { CloudAuthController } from 'src/modules/cloud/auth/cloud-auth.controller';
88
import { CloudAuthAnalytics } from 'src/modules/cloud/auth/cloud-auth.analytics';
9+
import { TcpCloudAuthStrategy } from './auth-strategy/tcp-cloud.auth.strategy';
910

1011
@Module({
1112
imports: [CloudSessionModule],
@@ -15,8 +16,12 @@ import { CloudAuthAnalytics } from 'src/modules/cloud/auth/cloud-auth.analytics'
1516
SsoIdpCloudAuthStrategy,
1617
CloudAuthService,
1718
CloudAuthAnalytics,
19+
...(process.env.USE_TCP_CLOUD_AUTH === 'true' ? [TcpCloudAuthStrategy] : [])
1820
],
1921
controllers: [CloudAuthController],
20-
exports: [CloudAuthService],
22+
exports: [
23+
CloudAuthService,
24+
...(process.env.USE_TCP_CLOUD_AUTH === 'true' ? [TcpCloudAuthStrategy] : [])
25+
],
2126
})
22-
export class CloudAuthModule {}
27+
export class CloudAuthModule { }

redisinsight/api/src/modules/cloud/auth/cloud-auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class CloudAuthService {
4444
private readonly ssoIdpCloudAuthStrategy: SsoIdpCloudAuthStrategy,
4545
private readonly analytics: CloudAuthAnalytics,
4646
private readonly eventEmitter: EventEmitter2,
47-
) {}
47+
) { }
4848

4949
static getOAuthHttpRequestHeaders() {
5050
return {
@@ -69,7 +69,7 @@ export class CloudAuthService {
6969
) {
7070
return (
7171
authRequest?.idpType === CloudAuthIdpType.GitHub
72-
&& query?.error_description?.indexOf('email') > -1
72+
&& query?.error_description?.indexOf('email') > -1
7373
)
7474
? new CloudOauthGithubEmailPermissionException(query.error_description)
7575
: new CloudOauthMissedRequiredDataException(query.error_description, {

redisinsight/api/src/modules/database-recommendation/models/database-recommendation-params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export class DatabaseRecommendationParams {
55
@IsRedisString({ each: true })
66
@RedisStringType({ each: true })
77
keys?: RedisString[];
8-
}
8+
}

redisinsight/api/src/modules/database/entities/database.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,4 @@ export class DatabaseEntity {
231231
@Expose()
232232
@Column({ nullable: true })
233233
version: string;
234-
}
234+
}

0 commit comments

Comments
 (0)