102 lines
2.9 KiB
TypeScript
102 lines
2.9 KiB
TypeScript
export namespace backend {
|
|
|
|
export class DatabaseConfig {
|
|
name: string;
|
|
targetPath: string;
|
|
modelPackagePath: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new DatabaseConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.name = source["name"];
|
|
this.targetPath = source["targetPath"];
|
|
this.modelPackagePath = source["modelPackagePath"];
|
|
}
|
|
}
|
|
export class ProjectConfig {
|
|
name: string;
|
|
path: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ProjectConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.name = source["name"];
|
|
this.path = source["path"];
|
|
}
|
|
}
|
|
export class Settings {
|
|
theme: string;
|
|
language: string;
|
|
notifications: boolean;
|
|
autoStart: boolean;
|
|
mysqlModelPath: string;
|
|
defaultQueryPackagePath: string;
|
|
modelBasePath: string;
|
|
swaggerFilePath: string;
|
|
databases: DatabaseConfig[];
|
|
projects: ProjectConfig[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Settings(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.theme = source["theme"];
|
|
this.language = source["language"];
|
|
this.notifications = source["notifications"];
|
|
this.autoStart = source["autoStart"];
|
|
this.mysqlModelPath = source["mysqlModelPath"];
|
|
this.defaultQueryPackagePath = source["defaultQueryPackagePath"];
|
|
this.modelBasePath = source["modelBasePath"];
|
|
this.swaggerFilePath = source["swaggerFilePath"];
|
|
this.databases = this.convertValues(source["databases"], DatabaseConfig);
|
|
this.projects = this.convertValues(source["projects"], ProjectConfig);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
export class SwaggerFile {
|
|
name: string;
|
|
path: string;
|
|
size: number;
|
|
modifiedTime: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SwaggerFile(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.name = source["name"];
|
|
this.path = source["path"];
|
|
this.size = source["size"];
|
|
this.modifiedTime = source["modifiedTime"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|