Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions autoadmin-ws-server/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "rocketadmin-ws-server",
"version": "1.0.0",
"type": "module",
"license": "UNLICENSED",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"lint": "biome check src/",
"lint:fix": "biome check --write src/"
},
"dependencies": {
"@hono/node-server": "^1.19.9",
"hono": "^4.11.7",
"jsonwebtoken": "^9.0.3",
"lru-cache": "^11.2.5",
"nanoid": "^5.1.6",
"pino": "^10.3.0",
"ws": "^8.19.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.3.13",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.10.2",
"@types/ws": "^8.18.1",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
}
"name": "rocketadmin-ws-server",
"version": "1.0.0",
"type": "module",
"license": "UNLICENSED",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"lint": "biome check src/",
"lint:fix": "biome check --write src/"
},
"dependencies": {
"@hono/node-server": "^1.19.9",
"hono": "^4.11.7",
"jsonwebtoken": "^9.0.3",
"lru-cache": "^11.2.5",
"nanoid": "^5.1.6",
"pino": "^10.3.0",
"ws": "^8.19.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.3.13",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^22.10.2",
"@types/ws": "^8.18.1",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
}
}
3 changes: 1 addition & 2 deletions autoadmin-ws-server/src/utils/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export function signToken(connectionToken: string): Promise<string> {
if (err) {
return reject(err);
}
if (!token) {

if (!token) {
return reject(new Error('Failed to sign token'));
}
return resolve(token);
Expand Down
44 changes: 22 additions & 22 deletions autoadmin-ws-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
14 changes: 7 additions & 7 deletions backend/src/authorization/auth-with-api.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import {
UnauthorizedException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { UserEntity } from '../entities/user/user.entity.js';
import { Repository } from 'typeorm';
import Sentry from '@sentry/minimal';
import { Request, Response } from 'express';
import { Constants } from '../helpers/constants/constants.js';
import { isObjectEmpty } from '../helpers/is-object-empty.js';
import jwt from 'jsonwebtoken';
import { Repository } from 'typeorm';
import { JwtScopesEnum } from '../entities/user/enums/jwt-scopes.enum.js';
import { UserEntity } from '../entities/user/user.entity.js';
import { EncryptionAlgorithmEnum } from '../enums/encryption-algorithm.enum.js';
import { Messages } from '../exceptions/text/messages.js';
import jwt from 'jsonwebtoken';
import Sentry from '@sentry/minimal';
import { Constants } from '../helpers/constants/constants.js';
import { Encryptor } from '../helpers/encryption/encryptor.js';
import { EncryptionAlgorithmEnum } from '../enums/encryption-algorithm.enum.js';
import { isObjectEmpty } from '../helpers/is-object-empty.js';
import { IRequestWithCognitoInfo } from './cognito-decoded.interface.js';

@Injectable()
Expand Down
6 changes: 3 additions & 3 deletions backend/src/authorization/auth.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import {
UnauthorizedException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import Sentry from '@sentry/minimal';
import { Response } from 'express';
import jwt from 'jsonwebtoken';
import { Repository } from 'typeorm';
import { LogOutEntity } from '../entities/log-out/log-out.entity.js';
import { JwtScopesEnum } from '../entities/user/enums/jwt-scopes.enum.js';
import { UserEntity } from '../entities/user/user.entity.js';
import { Messages } from '../exceptions/text/messages.js';
import { isObjectEmpty } from '../helpers/index.js';
import { Constants } from '../helpers/constants/constants.js';
import Sentry from '@sentry/minimal';
import { JwtScopesEnum } from '../entities/user/enums/jwt-scopes.enum.js';
import { isObjectEmpty } from '../helpers/index.js';
import { IRequestWithCognitoInfo } from './cognito-decoded.interface.js';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
import { ConnectionTypeTestEnum } from '@rocketadmin/shared-code/dist/src/shared/enums/connection-types-enum.js';
import { nanoid } from 'nanoid';
import { ConnectionEntity } from '../../connection/connection.entity.js';
import { AgentEntity } from '../agent.entity.js';
import { ConnectionTypeTestEnum } from '@rocketadmin/shared-code/dist/src/shared/enums/connection-types-enum.js';

export const customAgentRepositoryExtension = {
async saveNewAgent(agent: AgentEntity): Promise<AgentEntity> {
return await this.save(agent);
},
async saveNewAgent(agent: AgentEntity): Promise<AgentEntity> {
return await this.save(agent);
},

async createNewAgentForConnectionAndReturnToken(connection: ConnectionEntity): Promise<string> {
const newAgent = await this.createNewAgentForConnection(connection);
return newAgent.token;
},
async createNewAgentForConnectionAndReturnToken(connection: ConnectionEntity): Promise<string> {
const newAgent = await this.createNewAgentForConnection(connection);
return newAgent.token;
},

async createNewAgentForConnection(connection: ConnectionEntity): Promise<AgentEntity> {
const agent = new AgentEntity();
let token = nanoid(64);
if (process.env.NODE_ENV !== 'test') {
agent.token = token;
} else {
token = this.getTestAgentToken(connection.type);
agent.token = token;
}
agent.connection = connection;
const savedAgent = await this.save(agent);
savedAgent.token = token;
return savedAgent;
},
async createNewAgentForConnection(connection: ConnectionEntity): Promise<AgentEntity> {
const agent = new AgentEntity();
let token = nanoid(64);
if (process.env.NODE_ENV !== 'test') {
agent.token = token;
} else {
token = this.getTestAgentToken(connection.type);
agent.token = token;
}
agent.connection = connection;
const savedAgent = await this.save(agent);
savedAgent.token = token;
return savedAgent;
},

async renewOrCreateConnectionToken(connectionId: string): Promise<string> {
const agentQb = this.createQueryBuilder('agent')
.leftJoinAndSelect('agent.connection', 'connection')
.andWhere('connection.id = :connectionId', { connectionId: connectionId });
const foundAgent = await agentQb.getOne();
if (!foundAgent) {
const connectionQb = this.manager
.getRepository(ConnectionEntity)
.createQueryBuilder('connection')
.andWhere('connection.id = :connectionId', { connectionId: connectionId });
const foundConnection = await connectionQb.getOne();
return await this.createNewAgentForConnectionAndReturnToken(foundConnection);
} else {
const newToken = nanoid(64);
foundAgent.token = newToken;
await this.save(foundAgent);
return newToken;
}
},
async renewOrCreateConnectionToken(connectionId: string): Promise<string> {
const agentQb = this.createQueryBuilder('agent')
.leftJoinAndSelect('agent.connection', 'connection')
.andWhere('connection.id = :connectionId', { connectionId: connectionId });
const foundAgent = await agentQb.getOne();
if (!foundAgent) {
const connectionQb = this.manager
.getRepository(ConnectionEntity)
.createQueryBuilder('connection')
.andWhere('connection.id = :connectionId', { connectionId: connectionId });
const foundConnection = await connectionQb.getOne();
return await this.createNewAgentForConnectionAndReturnToken(foundConnection);
} else {
const newToken = nanoid(64);
foundAgent.token = newToken;
await this.save(foundAgent);
return newToken;
}
},

getTestAgentToken(connectionType: ConnectionTypeTestEnum): string {
if (process.env.NODE_ENV !== 'test') throw new Error('Test agent token can only be used in test environment');
switch (connectionType) {
case ConnectionTypeTestEnum.agent_oracledb:
return 'ORACLE-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mssql:
return 'MSSQL-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mysql:
return 'MYSQL-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_postgres:
return 'POSTGRES-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_ibmdb2:
return 'IBMDB2-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mongodb:
return 'MONGODB-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_redis:
return 'REDIS-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_cassandra:
return 'CASSANDRA-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_clickhouse:
return 'CLICKHOUSE-TEST-AGENT-TOKEN';
default:
throw new Error(`Unsupported connection type for test agent token: ${connectionType}`);
}
},
getTestAgentToken(connectionType: ConnectionTypeTestEnum): string {
if (process.env.NODE_ENV !== 'test') throw new Error('Test agent token can only be used in test environment');
switch (connectionType) {
case ConnectionTypeTestEnum.agent_oracledb:
return 'ORACLE-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mssql:
return 'MSSQL-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mysql:
return 'MYSQL-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_postgres:
return 'POSTGRES-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_ibmdb2:
return 'IBMDB2-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_mongodb:
return 'MONGODB-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_redis:
return 'REDIS-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_cassandra:
return 'CASSANDRA-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_clickhouse:
return 'CLICKHOUSE-TEST-AGENT-TOKEN';
default:
throw new Error(`Unsupported connection type for test agent token: ${connectionType}`);
}
},
};
6 changes: 3 additions & 3 deletions backend/src/entities/ai/ai.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common';
import { WidgetTypeEnum } from '../../enums/widget-type.enum.js';
import { AICoreService, AIProviderType, cleanAIJsonResponse } from '../../ai-core/index.js';
import { QueryOrderingEnum } from '../../enums/query-ordering.enum.js';
import { WidgetTypeEnum } from '../../enums/widget-type.enum.js';
import { checkFieldAutoincrement } from '../../helpers/check-field-autoincrement.js';
import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js';
import { TableWidgetEntity } from '../widget/table-widget.entity.js';
import { TableInformation } from './ai-data-entities/types/ai-module-types.js';
import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js';
import { AICoreService, AIProviderType, cleanAIJsonResponse } from '../../ai-core/index.js';

interface AIGeneratedTableSettings {
table_name: string;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/entities/shared-jobs/shared-jobs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { isTest } from '../../helpers/app/is-test.js';
import { ValidationHelper } from '../../helpers/validators/validation-helper.js';
import { AiService } from '../ai/ai.service.js';
import { ConnectionEntity } from '../connection/connection.entity.js';
import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js';
import { buildEmptyTableSettings } from '../table-settings/common-table-settings/utils/build-empty-table-settings.js';
import { buildNewTableSettingsEntity } from '../table-settings/common-table-settings/utils/build-new-table-settings-entity.js';
import { TableWidgetEntity } from '../widget/table-widget.entity.js';
import { TableSettingsEntity } from '../table-settings/common-table-settings/table-settings.entity.js';

@Injectable()
export class SharedJobsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {
Unique,
UpdateDateColumn,
} from 'typeorm';
import { QueryOrderingEnum } from '../../../enums/query-ordering.enum.js';
import { ConnectionEntity } from '../../connection/connection.entity.js';
import { CustomFieldsEntity } from '../../custom-field/custom-fields.entity.js';
import { TableActionEntity } from '../../table-actions/table-actions-module/table-action.entity.js';
import { TableWidgetEntity } from '../../widget/table-widget.entity.js';
import { QueryOrderingEnum } from '../../../enums/query-ordering.enum.js';

@Entity('tableSettings')
@Unique(['connection_id', 'table_name'])
Expand Down
Loading
Loading