refactor: unproxify ipc params

This commit is contained in:
Fabio Di Stasio 2022-04-22 12:17:27 +02:00
parent afa23f3ef1
commit e60789f320
11 changed files with 83 additions and 60 deletions

View File

@ -0,0 +1,14 @@
/**
* @param {*} val
* @param {Boolean} json converts the value in JSON object (default true)
*/
export function unproxify (val, json = true) {
if (json)// JSON conversion
return JSON.parse(JSON.stringify(val));
else if (!(Symbol.iterator in Object(val)))// If not iterable
return val;
else if (Array.isArray(val))// If array
return [...val];
else // If object
return { ...val };
}

View File

@ -1,13 +1,14 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getKey (params) {
return ipcRenderer.sendSync('get-key', params);
return ipcRenderer.sendSync('get-key', unproxify(params));
}
static showOpenDialog (options) {
return ipcRenderer.invoke('showOpenDialog', options);
return ipcRenderer.invoke('show-open-dialog', unproxify(options));
}
static getDownloadPathDirectory () {

View File

@ -1,17 +1,17 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
import connStringConstruct from '../libs/connStringDecode';
export default class {
static makeTest (params) {
params = connStringConstruct(params);
return ipcRenderer.invoke('test-connection', { ...params });
return ipcRenderer.invoke('test-connection', unproxify(params));
}
static connect (params) {
params = connStringConstruct(params);
return ipcRenderer.invoke('connect', { ...params });
return ipcRenderer.invoke('connect', unproxify(params));
}
static checkConnection (uid) {

View File

@ -1,28 +1,29 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getFunctionInformations (params) {
return ipcRenderer.invoke('get-function-informations', params);
return ipcRenderer.invoke('get-function-informations', unproxify(params));
}
static dropFunction (params) {
return ipcRenderer.invoke('drop-function', params);
return ipcRenderer.invoke('drop-function', unproxify(params));
}
static alterFunction (params) {
return ipcRenderer.invoke('alter-function', params);
return ipcRenderer.invoke('alter-function', unproxify(params));
}
static alterTriggerFunction (params) {
return ipcRenderer.invoke('alter-trigger-function', params);
return ipcRenderer.invoke('alter-trigger-function', unproxify(params));
}
static createFunction (params) {
return ipcRenderer.invoke('create-function', params);
return ipcRenderer.invoke('create-function', unproxify(params));
}
static createTriggerFunction (params) {
return ipcRenderer.invoke('create-trigger-function', params);
return ipcRenderer.invoke('create-trigger-function', unproxify(params));
}
}

View File

@ -1,20 +1,21 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getRoutineInformations (params) {
return ipcRenderer.invoke('get-routine-informations', params);
return ipcRenderer.invoke('get-routine-informations', unproxify(params));
}
static dropRoutine (params) {
return ipcRenderer.invoke('drop-routine', params);
return ipcRenderer.invoke('drop-routine', unproxify(params));
}
static alterRoutine (params) {
return ipcRenderer.invoke('alter-routine', params);
return ipcRenderer.invoke('alter-routine', unproxify(params));
}
static createRoutine (params) {
return ipcRenderer.invoke('create-routine', params);
return ipcRenderer.invoke('create-routine', unproxify(params));
}
}

View File

@ -1,24 +1,25 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getSchedulerInformations (params) {
return ipcRenderer.invoke('get-scheduler-informations', params);
return ipcRenderer.invoke('get-scheduler-informations', unproxify(params));
}
static dropScheduler (params) {
return ipcRenderer.invoke('drop-scheduler', params);
return ipcRenderer.invoke('drop-scheduler', unproxify(params));
}
static alterScheduler (params) {
return ipcRenderer.invoke('alter-scheduler', params);
return ipcRenderer.invoke('alter-scheduler', unproxify(params));
}
static createScheduler (params) {
return ipcRenderer.invoke('create-scheduler', params);
return ipcRenderer.invoke('create-scheduler', unproxify(params));
}
static toggleScheduler (params) {
return ipcRenderer.invoke('toggle-scheduler', params);
return ipcRenderer.invoke('toggle-scheduler', unproxify(params));
}
}

View File

@ -1,25 +1,26 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static createSchema (params) {
return ipcRenderer.invoke('create-schema', { ...params });
return ipcRenderer.invoke('create-schema', unproxify(params));
}
static updateSchema (params) {
return ipcRenderer.invoke('update-schema', { ...params });
return ipcRenderer.invoke('update-schema', unproxify(params));
}
static getDatabaseCollation (params) {
return ipcRenderer.invoke('get-schema-collation', { ...params });
return ipcRenderer.invoke('get-schema-collation', unproxify(params));
}
static deleteSchema (params) {
return ipcRenderer.invoke('delete-schema', { ...params });
return ipcRenderer.invoke('delete-schema', unproxify(params));
}
static getStructure (params) {
return ipcRenderer.invoke('get-structure', { ...params });
return ipcRenderer.invoke('get-structure', unproxify(params, false));
}
static getCollations (uid) {
@ -43,35 +44,35 @@ export default class {
}
static killProcess (params) {
return ipcRenderer.invoke('kill-process', { ...params });
return ipcRenderer.invoke('kill-process', unproxify(params));
}
static killTabQuery (params) {
return ipcRenderer.invoke('kill-tab-query', { ...params });
return ipcRenderer.invoke('kill-tab-query', unproxify(params));
}
static commitTab (params) {
return ipcRenderer.invoke('commit-tab', { ...params });
return ipcRenderer.invoke('commit-tab', unproxify(params));
}
static rollbackTab (params) {
return ipcRenderer.invoke('rollback-tab', { ...params });
return ipcRenderer.invoke('rollback-tab', unproxify(params));
}
static destroyConnectionToCommit (params) {
return ipcRenderer.invoke('destroy-connection-to-commit', { ...params });
return ipcRenderer.invoke('destroy-connection-to-commit', unproxify(params));
}
static useSchema (params) {
return ipcRenderer.invoke('use-schema', { ...params });
return ipcRenderer.invoke('use-schema', unproxify(params));
}
static rawQuery (params) {
return ipcRenderer.invoke('raw-query', { ...params });
return ipcRenderer.invoke('raw-query', unproxify(params));
}
static export (params) {
return ipcRenderer.invoke('export', { ...params });
return ipcRenderer.invoke('export', unproxify(params));
}
static abortExport () {
@ -79,7 +80,7 @@ export default class {
}
static import (params) {
return ipcRenderer.invoke('import-sql', { ...params });
return ipcRenderer.invoke('import-sql', unproxify(params));
}
static abortImport () {

View File

@ -1,68 +1,69 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getTableColumns (params) {
return ipcRenderer.invoke('get-table-columns', { ...params });
return ipcRenderer.invoke('get-table-columns', unproxify(params));
}
static getTableData (params) {
return ipcRenderer.invoke('get-table-data', { ...params });
return ipcRenderer.invoke('get-table-data', unproxify(params));
}
static getTableApproximateCount (params) {
return ipcRenderer.invoke('get-table-count', { ...params });
return ipcRenderer.invoke('get-table-count', unproxify(params));
}
static getTableOptions (params) {
return ipcRenderer.invoke('get-table-options', { ...params });
return ipcRenderer.invoke('get-table-options', unproxify(params));
}
static getTableIndexes (params) {
return ipcRenderer.invoke('get-table-indexes', { ...params });
return ipcRenderer.invoke('get-table-indexes', unproxify(params));
}
static getKeyUsage (params) {
return ipcRenderer.invoke('get-key-usage', { ...params });
return ipcRenderer.invoke('get-key-usage', unproxify(params));
}
static updateTableCell (params) {
return ipcRenderer.invoke('update-table-cell', { ...params });
return ipcRenderer.invoke('update-table-cell', unproxify(params));
}
static deleteTableRows (params) {
return ipcRenderer.invoke('delete-table-rows', { ...params });
return ipcRenderer.invoke('delete-table-rows', unproxify(params));
}
static insertTableRows (params) {
return ipcRenderer.invoke('insert-table-rows', { ...params });
return ipcRenderer.invoke('insert-table-rows', unproxify(params));
}
static insertTableFakeRows (params) {
return ipcRenderer.invoke('insert-table-fake-rows', { ...params });
return ipcRenderer.invoke('insert-table-fake-rows', unproxify(params));
}
static getForeignList (params) {
return ipcRenderer.invoke('get-foreign-list', { ...params });
return ipcRenderer.invoke('get-foreign-list', unproxify(params));
}
static createTable (params) {
return ipcRenderer.invoke('create-table', { ...params });
return ipcRenderer.invoke('create-table', unproxify(params));
}
static alterTable (params) {
return ipcRenderer.invoke('alter-table', { ...params });
return ipcRenderer.invoke('alter-table', unproxify(params));
}
static duplicateTable (params) {
return ipcRenderer.invoke('duplicate-table', { ...params });
return ipcRenderer.invoke('duplicate-table', unproxify(params));
}
static truncateTable (params) {
return ipcRenderer.invoke('truncate-table', { ...params });
return ipcRenderer.invoke('truncate-table', unproxify(params));
}
static dropTable (params) {
return ipcRenderer.invoke('drop-table', { ...params });
return ipcRenderer.invoke('drop-table', unproxify(params));
}
}

View File

@ -1,24 +1,25 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getTriggerInformations (params) {
return ipcRenderer.invoke('get-trigger-informations', params);
return ipcRenderer.invoke('get-trigger-informations', unproxify(params));
}
static dropTrigger (params) {
return ipcRenderer.invoke('drop-trigger', params);
return ipcRenderer.invoke('drop-trigger', unproxify(params));
}
static alterTrigger (params) {
return ipcRenderer.invoke('alter-trigger', params);
return ipcRenderer.invoke('alter-trigger', unproxify(params));
}
static createTrigger (params) {
return ipcRenderer.invoke('create-trigger', params);
return ipcRenderer.invoke('create-trigger', unproxify(params));
}
static toggleTrigger (params) {
return ipcRenderer.invoke('toggle-trigger', params);
return ipcRenderer.invoke('toggle-trigger', unproxify(params));
}
}

View File

@ -1,8 +1,9 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getUsers (params) {
return ipcRenderer.invoke('get-users', params);
return ipcRenderer.invoke('get-users', unproxify(params));
}
}

View File

@ -1,20 +1,21 @@
'use strict';
import { ipcRenderer } from 'electron';
import { unproxify } from 'common/libs/unproxify';
export default class {
static getViewInformations (params) {
return ipcRenderer.invoke('get-view-informations', params);
return ipcRenderer.invoke('get-view-informations', unproxify(params));
}
static dropView (params) {
return ipcRenderer.invoke('drop-view', params);
return ipcRenderer.invoke('drop-view', unproxify(params));
}
static alterView (params) {
return ipcRenderer.invoke('alter-view', params);
return ipcRenderer.invoke('alter-view', unproxify(params));
}
static createView (params) {
return ipcRenderer.invoke('create-view', params);
return ipcRenderer.invoke('create-view', unproxify(params));
}
}