Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 0 additions & 24 deletions backend/src/ai-core/tools/database-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,3 @@ export function createDashboardGenerationTools(): AIToolDefinition[] {
},
];
}

export function createTableAnalysisTools(): AIToolDefinition[] {
return [
{
name: 'analyzeTableSchema',
description: 'Analyzes a table schema and returns recommendations for display settings and widgets.',
parameters: {
type: 'object',
properties: {
tableName: {
type: 'string',
description: 'The name of the table to analyze.',
},
columns: {
type: 'array',
description: 'Array of column definitions with name, type, and constraints.',
},
},
required: ['tableName', 'columns'],
additionalProperties: false,
},
},
];
}
57 changes: 0 additions & 57 deletions backend/src/ai-core/tools/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,6 @@ IMPORTANT:
Remember that all responses should be clear and user-friendly, explaining technical details when necessary.`;
}

export function createTableSettingsSystemPrompt(widgetTypes: string[]): string {
return `You are a database administration assistant. Analyze the following database tables and generate optimal settings for displaying and managing them in a web admin panel.

For each table, provide:
1. display_name: A human-readable name for the table
2. search_fields: Columns that should be searchable (text fields like name, email, title)
3. readonly_fields: Columns that should not be editable (like auto_increment, timestamps)
4. columns_view: All columns in preferred display order
5. widgets: For each column, suggest the best widget type from: ${widgetTypes.join(', ')}

Available widget types and when to use them:
- Password: for password fields
- Boolean: for boolean/bit columns
- Date: for date columns
- Time: for time-only columns
- DateTime: for datetime/timestamp columns
- JSON: for JSON/JSONB columns
- Textarea: for long text fields (description, content, etc.)
- String: for short text fields (name, title, etc.)
- Readonly: for auto-generated fields
- Number: for numeric columns
- Select: for columns with limited options
- UUID: for UUID columns
- Enum: for enum columns
- Foreign_key: for foreign key columns
- File: for file path columns
- Image: for image URL columns
- URL: for URL columns
- Code: for code snippets
- Phone: for phone number columns
- Country: for country columns
- Color: for color columns (hex values)
- Range: for range values
- Timezone: for timezone columns

Respond ONLY with valid JSON in this exact format (no markdown, no explanations):
{
"tables": [
{
"table_name": "table_name",
"display_name": "Human Readable Name",
"search_fields": ["name", "email"],
"readonly_fields": ["id", "created_at"],
"columns_view": ["id", "name", "email", "created_at"],
"widgets": [
{
"field_name": "column_name",
"widget_type": "String",
"name": "Column Display Name",
"description": "Description of what this column contains"
}
]
}
]
}`;
}

export function convertDbTypeToReadableString(dataType: ConnectionTypesEnum): string {
switch (dataType) {
case ConnectionTypesEnum.postgres:
Expand Down
30 changes: 0 additions & 30 deletions backend/src/ai-core/tools/query-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,6 @@ export function wrapQueryWithLimit(query: string, databaseType: ConnectionTypesE
}
}

export function sanitizeJsonString(jsonStr: string): string {
try {
JSON.parse(jsonStr);
return jsonStr;
} catch (_e) {
const startBrace = jsonStr.indexOf('{');
if (startBrace === -1) {
return '{}';
}

const endBrace = jsonStr.lastIndexOf('}');
if (endBrace === -1 || endBrace <= startBrace) {
return '{}';
}

let possibleJson = jsonStr.substring(startBrace, endBrace + 1);

possibleJson = possibleJson.replace(/,\s*}/g, '}');
possibleJson = possibleJson.replace(/,\s*]/g, ']');

try {
JSON.parse(possibleJson);
return possibleJson;
} catch (_parseErr) {
console.error('Could not sanitize JSON, returning empty object');
return '{}';
}
}
}

export function cleanAIJsonResponse(response: string): string {
let cleanedResponse = response.trim();
if (cleanedResponse.startsWith('```json')) {
Expand Down
4 changes: 0 additions & 4 deletions backend/src/ai-core/utils/message-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,4 @@ export class MessageBuilder {
}
}

export function createSimpleMessages(systemPrompt: string, userMessage: string): BaseMessage[] {
return new MessageBuilder().system(systemPrompt).human(userMessage).build();
}

export { HumanMessage, SystemMessage, AIMessage, ToolMessage, BaseMessage };
1 change: 0 additions & 1 deletion backend/src/common/data-injection.tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export enum UseCaseType {

FIND_PERSONAL_TABLE_SETTINGS = 'FIND_PERSONAL_TABLE_SETTINGS',
CREATE_UPDATE_PERSONAL_TABLE_SETTINGS = 'CREATE_UPDATE_PERSONAL_TABLE_SETTINGS',
DELETE_PERSONAL_TABLE_SETTINGS = 'DELETE_PERSONAL_TABLE_SETTINGS',

GET_HELLO = 'GET_HELLO',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { CreatePersonalTableSettingsDto } from './dto/create-personal-table-sett
import { FoundPersonalTableSettingsDto } from './dto/found-personal-table-settings.dto.js';
import {
ICreateUpdatePersonalTableSettings,
IDeletePersonalTableSettings,
IFindPersonalTableSettings,
} from './use-cases/personal-table-settings.use-cases.interface.js';
Comment on lines 29 to 32
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

After removing the DELETE endpoint/use case, the NestJS Delete decorator import at the top of this controller is now unused (no @Delete usage). Please remove it to keep imports accurate and avoid unused-import lint/knip noise.

Copilot uses AI. Check for mistakes.

Expand All @@ -44,8 +43,6 @@ export class PersonalTableSettingsController {
private readonly findPersonalTableSettingsUseCase: IFindPersonalTableSettings,
@Inject(UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS)
private readonly createUpdatePersonalTableSettingsUseCase: ICreateUpdatePersonalTableSettings,
@Inject(UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS)
private readonly deletePersonalTableSettingsUseCase: IDeletePersonalTableSettings,
) {}

@ApiOperation({ summary: 'Find user personal table settings' })
Expand Down Expand Up @@ -125,37 +122,4 @@ export class PersonalTableSettingsController {
};
return await this.createUpdatePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
}

@ApiOperation({ summary: 'Clear user personal table settings' })
@ApiResponse({
status: 200,
description: 'Table settings removed.',
type: FoundPersonalTableSettingsDto,
})
@ApiParam({ name: 'connectionId', required: true })
@ApiQuery({ name: 'tableName', required: true })
@UseGuards(TableReadGuard)
@Delete('/settings/personal/:connectionId')
async clearTableSettings(
@SlugUuid('connectionId') connectionId: string,
@QueryTableName() tableName: string,
@MasterPassword() masterPwd: string,
@UserId() userId: string,
): Promise<FoundPersonalTableSettingsDto> {
if (!connectionId) {
throw new HttpException(
{
message: Messages.CONNECTION_ID_MISSING,
},
HttpStatus.BAD_REQUEST,
);
}
const inputData: FindPersonalTableSettingsDs = {
connectionId,
tableName,
userId,
masterPassword: masterPwd,
};
return await this.deletePersonalTableSettingsUseCase.execute(inputData, InTransactionEnum.OFF);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import { FindPersonalTableSettingsUseCase } from './use-cases/find-personal-tabl
provide: UseCaseType.CREATE_UPDATE_PERSONAL_TABLE_SETTINGS,
useClass: CreateUpdatePersonalTableSettingsUseCase,
},
{
provide: UseCaseType.DELETE_PERSONAL_TABLE_SETTINGS,
useClass: CreateUpdatePersonalTableSettingsUseCase,
},
],
controllers: [PersonalTableSettingsController],
exports: [],
Expand All @@ -39,7 +35,6 @@ export class PersonalTableSettingsModule {
.forRoutes(
{ path: '/settings/personal/:connectionId', method: RequestMethod.GET },
{ path: '/settings/personal/:connectionId', method: RequestMethod.PUT },
{ path: '/settings/personal/:connectionId', method: RequestMethod.DELETE },
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,3 @@ export interface ICreateUpdatePersonalTableSettings {
inTransaction: InTransactionEnum,
): Promise<FoundPersonalTableSettingsDto>;
}

export interface IDeletePersonalTableSettings {
execute(
inputData: FindPersonalTableSettingsDs,
inTransaction: InTransactionEnum,
): Promise<FoundPersonalTableSettingsDto>;
}
5 changes: 0 additions & 5 deletions backend/src/helpers/app/get-requeired-env-variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@ export function getRequiredEnvVariable(variableName: string): string {
}
return variableValue;
}

export function getOptionalEnvVariable(variableName: string): string | undefined {
// eslint-disable-next-line security/detect-object-injection
return process.env[variableName];
}
6 changes: 0 additions & 6 deletions backend/src/helpers/get-master-password.ts

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { binaryToHex, isBinary } from './binary-to-hex.js';
export { checkFieldAutoincrement } from './check-field-autoincrement.js';
export { compareArrayElements } from './compare-array-elements.js';
export { getMasterPwd } from './get-master-password.js';
export { getPropertyValueByDescriptor } from './get-property-value-by-descriptor.js';
export { getUniqArrayStrings } from './get-uniq-array-strings.js';
export { isConnectionEntityAgent, isConnectionTypeAgent } from './is-connection-entity-agent.js';
Expand Down
Loading