219 lines
6.2 KiB
TypeScript
219 lines
6.2 KiB
TypeScript
export namespace domain {
|
|
|
|
export class UpdateConfig {
|
|
autoUpdate: boolean;
|
|
checkOnStartup: boolean;
|
|
intervalMinutes: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new UpdateConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.autoUpdate = source["autoUpdate"];
|
|
this.checkOnStartup = source["checkOnStartup"];
|
|
this.intervalMinutes = source["intervalMinutes"];
|
|
}
|
|
}
|
|
export class GiteaConfig {
|
|
baseURL: string;
|
|
org: string;
|
|
authType: string;
|
|
username: string;
|
|
credentialKey: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new GiteaConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.baseURL = source["baseURL"];
|
|
this.org = source["org"];
|
|
this.authType = source["authType"];
|
|
this.username = source["username"];
|
|
this.credentialKey = source["credentialKey"];
|
|
}
|
|
}
|
|
export class Config {
|
|
gitea: GiteaConfig;
|
|
update: UpdateConfig;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Config(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.gitea = this.convertValues(source["gitea"], GiteaConfig);
|
|
this.update = this.convertValues(source["update"], UpdateConfig);
|
|
}
|
|
|
|
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 InstalledTarget {
|
|
path: string;
|
|
linkType: string;
|
|
targetPath: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new InstalledTarget(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.path = source["path"];
|
|
this.linkType = source["linkType"];
|
|
this.targetPath = source["targetPath"];
|
|
}
|
|
}
|
|
export class RemoteSkill {
|
|
name: string;
|
|
fullName: string;
|
|
description: string;
|
|
cloneURL: string;
|
|
sshURL: string;
|
|
defaultBranch: string;
|
|
updatedAt: string;
|
|
isDownloaded: boolean;
|
|
status: string;
|
|
error: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new RemoteSkill(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.name = source["name"];
|
|
this.fullName = source["fullName"];
|
|
this.description = source["description"];
|
|
this.cloneURL = source["cloneURL"];
|
|
this.sshURL = source["sshURL"];
|
|
this.defaultBranch = source["defaultBranch"];
|
|
this.updatedAt = source["updatedAt"];
|
|
this.isDownloaded = source["isDownloaded"];
|
|
this.status = source["status"];
|
|
this.error = source["error"];
|
|
}
|
|
}
|
|
export class SaveConfigRequest {
|
|
config: Config;
|
|
password: string;
|
|
token: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SaveConfigRequest(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.config = this.convertValues(source["config"], Config);
|
|
this.password = source["password"];
|
|
this.token = source["token"];
|
|
}
|
|
|
|
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 SkillState {
|
|
org: string;
|
|
repo: string;
|
|
localPath: string;
|
|
remoteURL: string;
|
|
defaultBranch: string;
|
|
currentCommit: string;
|
|
lastCheckedAt: string;
|
|
lastError: string;
|
|
installedTargets: Record<string, InstalledTarget>;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SkillState(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.org = source["org"];
|
|
this.repo = source["repo"];
|
|
this.localPath = source["localPath"];
|
|
this.remoteURL = source["remoteURL"];
|
|
this.defaultBranch = source["defaultBranch"];
|
|
this.currentCommit = source["currentCommit"];
|
|
this.lastCheckedAt = source["lastCheckedAt"];
|
|
this.lastError = source["lastError"];
|
|
this.installedTargets = this.convertValues(source["installedTargets"], InstalledTarget, true);
|
|
}
|
|
|
|
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 TestConnectionResult {
|
|
ok: boolean;
|
|
message: string;
|
|
username: string;
|
|
org: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new TestConnectionResult(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.ok = source["ok"];
|
|
this.message = source["message"];
|
|
this.username = source["username"];
|
|
this.org = source["org"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|