Skip to content

Commit 4f79ec8

Browse files
feat: add schema import functionality and description field for columns
1 parent 431fa37 commit 4f79ec8

5 files changed

Lines changed: 52 additions & 17 deletions

File tree

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,47 @@ src/
7777
└── styles/
7878
```
7979

80+
## Schema Import
81+
82+
The application supports importing database schemas to automatically generate entity configurations.
83+
84+
### JSON Schema Format
85+
86+
```json
87+
{
88+
"tables": [
89+
{
90+
"name": "Users",
91+
"schema": "dbo",
92+
"columns": [
93+
{
94+
"name": "Id",
95+
"type": "int",
96+
"nullable": false,
97+
"isPrimaryKey": true
98+
},
99+
{
100+
"name": "Email",
101+
"type": "string",
102+
"nullable": false,
103+
"isPrimaryKey": false,
104+
"description": "User's email address"
105+
},
106+
{
107+
"name": "CreatedAt",
108+
"type": "datetime",
109+
"nullable": false,
110+
"isPrimaryKey": false,
111+
"description": "Account creation timestamp"
112+
}
113+
]
114+
}
115+
]
116+
}
117+
```
118+
119+
**Field Descriptions**: Optional descriptions can be added to individual columns for documentation purposes. These descriptions help document the schema and are visible in the entity editor for reference.
120+
80121
## Testing
81122

82123
```bash

src/app/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export interface IColumnInfo {
286286
isPrimaryKey: boolean;
287287
maxLength?: number;
288288
defaultValue?: string;
289+
description?: string;
289290
}
290291

291292
/**

src/app/pages/config-wizard/tabs/entities-tab/entities-tab.component.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ import { SchemaImporterService } from '../../../../services/schema-importer.serv
791791
<th>Type</th>
792792
<th>Nullable</th>
793793
<th>Primary Key</th>
794-
<th>Alias</th>
794+
<th>Description</th>
795795
</tr>
796796
</thead>
797797
<tbody>
@@ -815,9 +815,9 @@ import { SchemaImporterService } from '../../../../services/schema-importer.serv
815815
<input
816816
type="text"
817817
class="form-control form-control-sm"
818-
[ngModel]="entity.mappings[col.name] || ''"
819-
(ngModelChange)="updateMapping(col.name, $event)"
820-
placeholder="(no alias)"
818+
[ngModel]="col.description || ''"
819+
(ngModelChange)="updateColumnDescription(col.name, $event)"
820+
placeholder="(no description)"
821821
/>
822822
</td>
823823
</tr>
@@ -1179,17 +1179,14 @@ export class EntitiesTabComponent {
11791179
this.configBuilder.updateEntity(entity.id, { mcp: updatedMcp });
11801180
}
11811181

1182-
updateMapping(columnName: string, alias: string): void {
1182+
updateColumnDescription(columnName: string, description: string): void {
11831183
const entity = this.selectedEntity();
11841184
if (!entity) return;
11851185

1186-
const updatedMappings = { ...entity.mappings };
1187-
if (alias.trim()) {
1188-
updatedMappings[columnName] = alias;
1189-
} else {
1190-
delete updatedMappings[columnName];
1191-
}
1192-
this.configBuilder.updateEntity(entity.id, { mappings: updatedMappings });
1186+
const updatedColumns = entity.columns.map((col) =>
1187+
col.name === columnName ? { ...col, description: description.trim() || undefined } : col,
1188+
);
1189+
this.configBuilder.updateEntity(entity.id, { columns: updatedColumns });
11931190
}
11941191

11951192
/** Check if a REST method is enabled */

src/app/services/config-builder.service.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,6 @@ export class ConfigBuilderService {
227227
config.mcp = entity.mcp;
228228
}
229229

230-
// Add mappings if present
231-
if (entity.mappings && Object.keys(entity.mappings).length > 0) {
232-
config.mappings = entity.mappings;
233-
}
234-
235230
return config;
236231
}
237232

src/app/services/schema-importer.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export class SchemaImporterService {
243243
obj['PRIMARY_KEY'] === true,
244244
maxLength: typeof obj['maxLength'] === 'number' ? obj['maxLength'] : undefined,
245245
defaultValue: typeof obj['defaultValue'] === 'string' ? obj['defaultValue'] : undefined,
246+
description: typeof obj['description'] === 'string' ? obj['description'] : undefined,
246247
};
247248
}
248249

0 commit comments

Comments
 (0)