mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-06 06:29:35 +08:00
* feat(http-tunnel): 支持独立 HTTP 隧道连接并覆盖多数据源 refs #168 * fix(kingbase-data-grid): 修复金仓打开表卡顿并降低对象渲染开销 refs #178 * fix(kingbase-transaction): 修复金仓事务提交重复引号导致语法错误 refs #176 * fix(driver-agent): 修复老版本 Win10 升级后金仓驱动代理启动失败 refs #177 * chore(ci): 新增手动触发的 macOS 测试构建工作流 * chore(ci): 允许测试工作流在当前分支自动触发 * fix(query-editor): 修复 SQL 编辑中光标随机跳到末尾 refs #185 * feat(data-sync): 增加差异 SQL 预览能力便于审核 refs #174 * fix(clickhouse-connect): 自动识别并回退 HTTP/Native 协议连接 refs #181 * fix(oracle-metadata): 修复视图与函数加载按 schema 过滤异常 refs #155 * fix(dameng-databases): 修复显示全部库时数据库列表不完整 refs #154 * fix(connection,db-list): 统一处理空列表返回并修复达梦连接测试报错 refs #157 Co-authored-by: 辣条 <69459608+tianqijiuyun-latiao@users.noreply.github.com>
343 lines
9.9 KiB
TypeScript
Executable File
343 lines
9.9 KiB
TypeScript
Executable File
export namespace connection {
|
|
|
|
export class UpdateRow {
|
|
keys: Record<string, any>;
|
|
values: Record<string, any>;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new UpdateRow(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.keys = source["keys"];
|
|
this.values = source["values"];
|
|
}
|
|
}
|
|
export class ChangeSet {
|
|
inserts: any[];
|
|
updates: UpdateRow[];
|
|
deletes: any[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ChangeSet(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.inserts = source["inserts"];
|
|
this.updates = this.convertValues(source["updates"], UpdateRow);
|
|
this.deletes = source["deletes"];
|
|
}
|
|
|
|
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 HTTPTunnelConfig {
|
|
host: string;
|
|
port: number;
|
|
user?: string;
|
|
password?: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new HTTPTunnelConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
}
|
|
}
|
|
export class ProxyConfig {
|
|
type: string;
|
|
host: string;
|
|
port: number;
|
|
user?: string;
|
|
password?: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ProxyConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.type = source["type"];
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
}
|
|
}
|
|
export class SSHConfig {
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
password: string;
|
|
keyPath: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SSHConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
this.keyPath = source["keyPath"];
|
|
}
|
|
}
|
|
export class ConnectionConfig {
|
|
type: string;
|
|
host: string;
|
|
port: number;
|
|
user: string;
|
|
password: string;
|
|
savePassword?: boolean;
|
|
database: string;
|
|
useSSL?: boolean;
|
|
sslMode?: string;
|
|
sslCertPath?: string;
|
|
sslKeyPath?: string;
|
|
useSSH: boolean;
|
|
ssh: SSHConfig;
|
|
useProxy?: boolean;
|
|
proxy?: ProxyConfig;
|
|
useHttpTunnel?: boolean;
|
|
httpTunnel?: HTTPTunnelConfig;
|
|
driver?: string;
|
|
dsn?: string;
|
|
timeout?: number;
|
|
redisDB?: number;
|
|
uri?: string;
|
|
hosts?: string[];
|
|
topology?: string;
|
|
mysqlReplicaUser?: string;
|
|
mysqlReplicaPassword?: string;
|
|
replicaSet?: string;
|
|
authSource?: string;
|
|
readPreference?: string;
|
|
mongoSrv?: boolean;
|
|
mongoAuthMechanism?: string;
|
|
mongoReplicaUser?: string;
|
|
mongoReplicaPassword?: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ConnectionConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.type = source["type"];
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.user = source["user"];
|
|
this.password = source["password"];
|
|
this.savePassword = source["savePassword"];
|
|
this.database = source["database"];
|
|
this.useSSL = source["useSSL"];
|
|
this.sslMode = source["sslMode"];
|
|
this.sslCertPath = source["sslCertPath"];
|
|
this.sslKeyPath = source["sslKeyPath"];
|
|
this.useSSH = source["useSSH"];
|
|
this.ssh = this.convertValues(source["ssh"], SSHConfig);
|
|
this.useProxy = source["useProxy"];
|
|
this.proxy = this.convertValues(source["proxy"], ProxyConfig);
|
|
this.useHttpTunnel = source["useHttpTunnel"];
|
|
this.httpTunnel = this.convertValues(source["httpTunnel"], HTTPTunnelConfig);
|
|
this.driver = source["driver"];
|
|
this.dsn = source["dsn"];
|
|
this.timeout = source["timeout"];
|
|
this.redisDB = source["redisDB"];
|
|
this.uri = source["uri"];
|
|
this.hosts = source["hosts"];
|
|
this.topology = source["topology"];
|
|
this.mysqlReplicaUser = source["mysqlReplicaUser"];
|
|
this.mysqlReplicaPassword = source["mysqlReplicaPassword"];
|
|
this.replicaSet = source["replicaSet"];
|
|
this.authSource = source["authSource"];
|
|
this.readPreference = source["readPreference"];
|
|
this.mongoSrv = source["mongoSrv"];
|
|
this.mongoAuthMechanism = source["mongoAuthMechanism"];
|
|
this.mongoReplicaUser = source["mongoReplicaUser"];
|
|
this.mongoReplicaPassword = source["mongoReplicaPassword"];
|
|
}
|
|
|
|
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 QueryResult {
|
|
success: boolean;
|
|
message: string;
|
|
data: any;
|
|
fields?: string[];
|
|
queryId?: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new QueryResult(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.success = source["success"];
|
|
this.message = source["message"];
|
|
this.data = source["data"];
|
|
this.fields = source["fields"];
|
|
this.queryId = source["queryId"];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
export namespace redis {
|
|
|
|
export class ZSetMember {
|
|
member: string;
|
|
score: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ZSetMember(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.member = source["member"];
|
|
this.score = source["score"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace sync {
|
|
|
|
export class TableOptions {
|
|
insert?: boolean;
|
|
update?: boolean;
|
|
delete?: boolean;
|
|
selectedInsertPks?: string[];
|
|
selectedUpdatePks?: string[];
|
|
selectedDeletePks?: string[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new TableOptions(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.insert = source["insert"];
|
|
this.update = source["update"];
|
|
this.delete = source["delete"];
|
|
this.selectedInsertPks = source["selectedInsertPks"];
|
|
this.selectedUpdatePks = source["selectedUpdatePks"];
|
|
this.selectedDeletePks = source["selectedDeletePks"];
|
|
}
|
|
}
|
|
export class SyncConfig {
|
|
sourceConfig: connection.ConnectionConfig;
|
|
targetConfig: connection.ConnectionConfig;
|
|
tables: string[];
|
|
content?: string;
|
|
mode: string;
|
|
jobId?: string;
|
|
autoAddColumns?: boolean;
|
|
tableOptions?: Record<string, TableOptions>;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SyncConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.sourceConfig = this.convertValues(source["sourceConfig"], connection.ConnectionConfig);
|
|
this.targetConfig = this.convertValues(source["targetConfig"], connection.ConnectionConfig);
|
|
this.tables = source["tables"];
|
|
this.content = source["content"];
|
|
this.mode = source["mode"];
|
|
this.jobId = source["jobId"];
|
|
this.autoAddColumns = source["autoAddColumns"];
|
|
this.tableOptions = this.convertValues(source["tableOptions"], TableOptions, 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 SyncResult {
|
|
success: boolean;
|
|
message: string;
|
|
logs: string[];
|
|
tablesSynced: number;
|
|
rowsInserted: number;
|
|
rowsUpdated: number;
|
|
rowsDeleted: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SyncResult(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.success = source["success"];
|
|
this.message = source["message"];
|
|
this.logs = source["logs"];
|
|
this.tablesSynced = source["tablesSynced"];
|
|
this.rowsInserted = source["rowsInserted"];
|
|
this.rowsUpdated = source["rowsUpdated"];
|
|
this.rowsDeleted = source["rowsDeleted"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|