~ K A L I ~
UNAME : Linux web64.extendcp.co.uk 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64SERVER IP : 10.0.187.64 -________-
CLIENT IP : 216.73.216.230 MINI SHELL D ZAB '
Current File : //usr/share/maxscale/gui/js/app~be308985.cb51fc36.js |
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app~be308985"],{"1ee1":function(e,t,s){"use strict";var a=s("bfa9"),n=s("a002"),r=s.n(n);t["a"]=new a["a"]({key:"query-editor",storage:r.a,asyncStorage:!0,reducer:e=>({queryPersisted:e.queryPersisted,wke:{worksheets_arr:e.wke.worksheets_arr,active_wke_id:e.wke.active_wke_id},queryConn:{sql_conns:e.queryConn.sql_conns},querySession:{query_sessions:e.querySession.query_sessions,active_session_by_wke_id_map:e.querySession.active_session_by_wke_id_map}})}).plugin},3065:function(e,t,s){"use strict";var a={};s.r(a),s.d(a,"OS_KEY",(function(){return o})),s.d(a,"QUERY_CONN_BINDING_TYPES",(function(){return i})),s.d(a,"QUERY_SHORTCUT_KEYS",(function(){return c})),s.d(a,"CMPL_SNIPPET_KIND",(function(){return _})),s.d(a,"SQL_NODE_TYPES",(function(){return d})),s.d(a,"SQL_SYS_SCHEMAS",(function(){return l})),s.d(a,"SQL_NODE_CTX_OPT_TYPES",(function(){return u})),s.d(a,"SQL_RES_TBL_CTX_OPT_TYPES",(function(){return S})),s.d(a,"SQL_QUERY_MODES",(function(){return y})),s.d(a,"SQL_DDL_ALTER_SPECS",(function(){return E})),s.d(a,"SQL_EDITOR_MODES",(function(){return m})),s.d(a,"SQL_DEF_ROW_LIMIT_OPTS",(function(){return h})),s.d(a,"SQL_CHART_TYPES",(function(){return p})),s.d(a,"SQL_CHART_AXIS_TYPES",(function(){return T})),s.d(a,"QUERY_LOG_TYPES",(function(){return g})),s.d(a,"MARIADB_NET_ERRNO",(function(){return f})),s.d(a,"QUERY_CANCELED",(function(){return C}));s("d9e2");var n=s("4470"),r=(s("ddb0"),s("13d5"),s("caad"),s("0abc"));const o=Object(r["isMAC"])()?"CMD":"CTRL",i=Object.freeze({SESSION:"SESSION",WORKSHEET:"WORKSHEET"}),c=Object.freeze({"ctrl-d":["ctrl","d"],"mac-cmd-d":["meta","d"],"ctrl-enter":["ctrl","enter"],"mac-cmd-enter":["meta","enter"],"ctrl-shift-enter":["ctrl","shift","enter"],"mac-cmd-shift-enter":["meta","shift","enter"],"ctrl-o":["ctrl","o"],"mac-cmd-o":["meta","o"],"ctrl-s":["ctrl","s"],"mac-cmd-s":["meta","s"],"ctrl-shift-s":["ctrl","shift","s"],"mac-cmd-shift-s":["meta","shift","s"],"ctrl-shift-c":["ctrl","shift","c"],"mac-cmd-shift-c":["meta","shift","c"]}),_="CMPL_SNIPPET_KIND",d=Object.freeze({SCHEMA:"Schema",TABLES:"Tables",TABLE:"Table",COLS:"Columns",COL:"Column",TRIGGERS:"Triggers",TRIGGER:"Trigger",SPS:"Stored Procedures",SP:"Stored Procedure"}),l=["information_schema","performance_schema","mysql","sys"],u=Object.freeze({CLIPBOARD:"CLIPBOARD",TXT_EDITOR:{INSERT:"INSERT",QUERY:"QUERY"},DDL:{DD:"DD"},ADMIN:{USE:"USE"}}),S=Object.freeze({CLIPBOARD:"CLIPBOARD",TXT_EDITOR:{INSERT:"INSERT"}}),y=Object.freeze({PRVW_DATA:"PRVW_DATA",PRVW_DATA_DETAILS:"PRVW_DATA_DETAILS",QUERY_VIEW:"QUERY_VIEW",HISTORY:"HISTORY",SNIPPETS:"SNIPPETS"}),E=Object.freeze({COLUMNS:"COLUMNS"}),m=Object.freeze({TXT_EDITOR:"TXT_EDITOR",DDL_EDITOR:"DDL_EDITOR"}),h=[10,50,100,200,300,400,500,1e3,2e3,5e3,1e4,5e4],p=Object.freeze({LINE:"Line",SCATTER:"Scatter",BAR_VERT:"Bar - Vertical",BAR_HORIZ:"Bar - Horizontal"}),T=Object.freeze({CATEGORY:"category",LINEAR:"linear",TIME:"time"}),g=Object.freeze({USER_LOGS:"User query logs",ACTION_LOGS:"Action logs"}),f=[2001,2002,2003,2004,2006,2011,2013,1927],C="Query canceled",A=({dbName:e,db_tree:t})=>t.findIndex(t=>t.name===e),q=({dbIdx:e,db_tree:t,childType:s})=>t[e].children.findIndex(e=>e.type===s);function b({db_tree:e,dbName:t,childType:s,gch:a}){try{const n=A({dbName:t,db_tree:e}),o=q({dbIdx:n,db_tree:e,childType:s}),i=Object(r["immutableUpdate"])(e,{[n]:{children:{[o]:{children:{$set:a}}}}});return i}catch(n){return{}}}function v({db_tree:e,dbName:t,tblName:s,gch:a,childType:n}){try{const o=A({dbName:t,db_tree:e}),i=q({dbIdx:o,db_tree:e,childType:d.TABLES}),c=e[o].children[i].children.findIndex(e=>e.name===s),_=e[o].children,l=_[i].children[c],u=l.children.findIndex(e=>e.type===n),S=Object(r["immutableUpdate"])(e,{[o]:{children:{[i]:{children:{[c]:{children:{[u]:{children:{$set:a}}}}}}}}});return S}catch(o){return{}}}async function O({active_sql_conn:e,nodeId:t,vue:s,$queryHttp:a}){const n=t.split("."),r=n[0],o=n[1],i="table_name, ENGINE as table_engine, character_set_name as table_charset, table_collation, table_comment",c=`SELECT ${i} FROM information_schema.tables t\nJOIN information_schema.collations c ON t.table_collation = c.collation_name\nWHERE table_schema = "${r}" AND table_name = "${o}";`;let _=await a.post(`/sql/${e.id}/queries`,{sql:c});const d=s.$helpers.getObjectRows({columns:_.data.data.attributes.results[0].fields,rows:_.data.data.attributes.results[0].data});return d[0]}async function R({active_sql_conn:e,nodeId:t,$queryHttp:s}){const a=t.split("."),n=a[0],r=a[1],o="\n UUID() AS id,\n a.column_name,\n REGEXP_SUBSTR(UPPER(column_type), '[^)]*[)]?') AS column_type,\n IF(column_key LIKE '%PRI%', 'YES', 'NO') as PK,\n IF(is_nullable LIKE 'YES', 'NULL', 'NOT NULL') as NN,\n IF(column_type LIKE '%UNSIGNED%', 'UNSIGNED', '') as UN,\n IF(c.constraint_name IS NULL, '', c.constraint_name) as UQ,\n IF(column_type LIKE '%ZEROFILL%', 'ZEROFILL', '') as ZF,\n IF(extra LIKE '%AUTO_INCREMENT%', 'AUTO_INCREMENT', '') as AI,\n IF(\n UPPER(extra) REGEXP 'VIRTUAL|STORED',\n REGEXP_SUBSTR(UPPER(extra), 'VIRTUAL|STORED'),\n '(none)'\n ) AS generated,\n COALESCE(generation_expression, column_default, '') as 'default/expression',\n IF(character_set_name IS NULL, '', character_set_name) as charset,\n IF(collation_name IS NULL, '', collation_name) as collation,\n column_comment as comment\n ",i=await s.post(`/sql/${e.id}/queries`,{sql:`\n SELECT ${o} FROM information_schema.columns a\n LEFT JOIN information_schema.statistics b ON (\n a.table_schema = b.table_schema\n AND a.table_name = b.table_name\n AND a.column_name = b.column_name\n )\n LEFT JOIN (\n SELECT\n table_name, table_schema, constraint_name\n FROM\n information_schema.table_constraints\n WHERE\n constraint_type = 'UNIQUE'\n ) c ON (\n a.table_name = c.table_name\n AND a.table_schema = c.table_schema\n AND b.index_name = c.constraint_name\n )\n WHERE\n a.table_schema='${n}'\n AND a.table_name='${r}'\n GROUP BY a.column_name\n ORDER BY a.ordinal_position;`});return i.data.data.attributes.results[0]}function I({moduleState:e,data:t}){Object.keys(t).forEach(s=>e[s]=t[s])}function N({scope:e,data:t,id:s,persistedArrayPath:a}){const{state:n,vue:{$helpers:{lodash:{set:r},immutableUpdate:o},$typy:i}}=e,c=i(n,a).safeArray,_=c.findIndex(e=>e.id===s);r(n,a,o(c,{[_]:{$set:{...c[_],...t}}}))}function w(e){switch(e){case"editor":return{query_txt:"",curr_ddl_alter_spec:"",blob_file:{},curr_editor_mode:m.TXT_EDITOR,tbl_creation_info:{}};case"queryConn":return{active_sql_conn:{},active_db:""};case"queryResult":return{curr_query_mode:"QUERY_VIEW",show_vis_sidebar:!1};case"schemaSidebar":return{is_sidebar_collapsed:!1,search_schema:"",expanded_nodes:[]};default:return null}}function D({statesToBeSynced:e,persistedArrayPath:t}){return{...Object.keys(e).reduce((e,s)=>({...e,["SET_"+s.toUpperCase()]:function(e,{payload:a,id:n}){const r={[s]:a};I({moduleState:e,data:r}),N({scope:this,data:r,id:n,persistedArrayPath:t})}}),{}),SYNC_WITH_PERSISTED_OBJ:function(t,s){I({moduleState:t,data:this.vue.$helpers.lodash.pickBy(s,(t,s)=>Object.keys(e).includes(s))})}}}function L(e){switch(e){case"editor":return{};case"queryConn":return{is_conn_busy_map:{},lost_cnn_err_msg_obj_map:{}};case"queryResult":return{prvw_data_map:{},prvw_data_details_map:{},query_results_map:{},has_kill_flag_map:{}};case"schemaSidebar":return{db_tree_map:{},exe_stmt_result_map:{}};default:return null}}function $(e){return Object.keys(e).reduce((e,t)=>({...e,["PATCH_"+t.toUpperCase()]:function(e,{id:s,payload:a}){a?e[t]={...e[t],[s]:{...e[t][s],...a}}:this.vue.$delete(e[t],s)}}),{})}function k({namespace:e,commit:t,id:s,memStates:a}){Object.keys(a).forEach(a=>{t(`${e}/PATCH_${a.toUpperCase()}`,{id:s},{root:!0})})}function P({query_txt:e,blob_file:t}){const{txt:s="",file_handle:{name:a=""}={}}=t;return!(!e&&!a)&&s!==e}var M={updateDbChild:b,updateTblChild:v,queryTblOptsData:O,queryColsOptsData:R,syncStateCreator:w,syncedStateMutationsCreator:D,memStateCreator:L,memStatesMutationCreator:$,releaseMemory:k,syncToPersistedObj:N,detectUnsavedChanges:P};const H=["editor","queryConn","queryResult","schemaSidebar"];var B=H.reduce((e,t)=>(e[t]=M.memStateCreator(t),e),{});function U(){return{id:r["lodash"].uniqueId(`WORKSHEET_${(new Date).getUTCMilliseconds()}_`),name:"WORKSHEET",...M.syncStateCreator("schemaSidebar")}}function x(e){return{id:r["lodash"].uniqueId(`SESSION_${(new Date).getUTCMilliseconds()}_`),name:"Query Tab 1",wke_id_fk:e,count:1,...M.syncStateCreator("queryConn"),...M.syncStateCreator("editor"),...M.syncStateCreator("queryResult")}}const F=[U()],Q=[x(F[0].id)];var W={get_def_worksheets_arr:F,get_def_query_sessions:Q};const Y=W.get_def_worksheets_arr;var G={namespaced:!0,state:{is_fullscreen:!1,worksheets_arr:Y,active_wke_id:Y[0].id},mutations:{SET_FULLSCREEN(e,t){e.is_fullscreen=t},ADD_NEW_WKE(e){e.worksheets_arr.push(U())},DELETE_WKE(e,t){e.worksheets_arr=e.worksheets_arr.filter(e=>e.id!==t)},UPDATE_WKE(e,{idx:t,wke:s}){e.worksheets_arr=this.vue.$helpers.immutableUpdate(e.worksheets_arr,{[t]:{$set:s}})},SET_ACTIVE_WKE_ID(e,t){e.active_wke_id=t},REFRESH_WKE(e,t){const s=e.worksheets_arr.indexOf(t),a={...t,...M.syncStateCreator("schemaSidebar"),name:"WORKSHEET"};e.worksheets_arr=this.vue.$helpers.immutableUpdate(e.worksheets_arr,{[s]:{$set:a}})}},actions:{async handleInitialFetch({dispatch:e,rootState:t,rootGetters:s}){try{const{id:a,name:n}=t.queryConn.active_sql_conn||{},r=a,o=0===s["schemaSidebar/getDbTreeData"].length,i=this.vue.$typy(s["schemaSidebar/getCurrDbTree"],"data_of_conn").safeString===n;r&&(!o&&i||(await e("schemaSidebar/initialFetch",{},{root:!0}),e("changeWkeName",n)),s["editor/getIsDDLEditor"]&&await e("editor/queryAlterTblSuppData",{},{root:!0}))}catch(a){this.vue.$logger("store-wke-handleInitialFetch").error(a)}},async addNewWs({commit:e,state:t,dispatch:s}){try{e("ADD_NEW_WKE");const a=t.worksheets_arr[t.worksheets_arr.length-1].id;e("SET_ACTIVE_WKE_ID",a),await s("querySession/handleAddNewSession",{wke_id:a},{root:!0})}catch(a){this.vue.$logger("store-wke-addNewWs").error(a),e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("errors.persistentStorage")],type:"error"},{root:!0})}},async handleDeleteWke({commit:e,dispatch:t,rootGetters:s},a){try{t("releaseQueryModulesMem",a);const n=s["querySession/getSessionsByWkeId"](a),{id:r=""}=s["queryConn/getWkeConnByWkeId"](a);r&&await t("queryConn/disconnect",{id:r},{root:!0});for(const e of n)await t("querySession/handleDeleteSession",e,{root:!0});e("DELETE_WKE",a),e("querySession/SET_ACTIVE_SESSION_BY_WKE_ID_MAP",{id:a},{root:!0})}catch(n){this.vue.$logger("store-wke-handleDeleteWke").error(n)}},handleSyncWke({commit:e},t){e("schemaSidebar/SYNC_WITH_PERSISTED_OBJ",t,{root:!0})},releaseQueryModulesMem({commit:e},t){Object.keys(B).forEach(s=>{"schemaSidebar"===s&&M.releaseMemory({namespace:s,commit:e,id:t,memStates:B[s]})})},resetWkeStates({commit:e,rootState:t,dispatch:s,getters:a},n){const r=t.queryConn.sql_conns[n],o=a.getWkeById(r.wke_id_fk);if(o){s("releaseQueryModulesMem",o.id),e("REFRESH_WKE",o);const a=t.wke.worksheets_arr.find(e=>e.id===o.id);s("handleSyncWke",a)}},changeWkeName({commit:e,rootState:t,getters:s},a){let n=this.vue.$helpers.lodash.cloneDeep(s.getActiveWke);n.name=a,e("UPDATE_WKE",{idx:t.wke.worksheets_arr.indexOf(s.getActiveWke),wke:n})}},getters:{getActiveWke:e=>e.worksheets_arr.find(t=>t.id===e.active_wke_id)||{},getWkeById:e=>t=>e.worksheets_arr.find(e=>e.id===t)||{}}};s("4069");const j=M.syncStateCreator("queryConn"),K=M.memStateCreator("queryConn");var V={namespaced:!0,state:{sql_conns:{},is_validating_conn:!0,conn_err_state:!1,rc_target_names_map:{},pre_select_conn_rsrc:null,conn_status_data:{alive_conn_map:{},expired_conn_map:{},orphaned_conns:[]},...K,...j},mutations:{...M.memStatesMutationCreator(K),...M.syncedStateMutationsCreator({statesToBeSynced:j,persistedArrayPath:"querySession.query_sessions"}),SET_IS_VALIDATING_CONN(e,t){e.is_validating_conn=t},SET_CONN_ERR_STATE(e,t){e.conn_err_state=t},SET_SQL_CONNS(e,t){e.sql_conns=t},ADD_SQL_CONN(e,t){this.vue.$set(e.sql_conns,t.id,t)},UPDATE_SQL_CONN(e,t){e.sql_conns=this.vue.$helpers.immutableUpdate(e.sql_conns,{[t.id]:{$set:t}})},DELETE_SQL_CONN(e,t){this.vue.$delete(e.sql_conns,t.id)},SET_RC_TARGET_NAMES_MAP(e,t){e.rc_target_names_map=t},SET_PRE_SELECT_CONN_RSRC(e,t){e.pre_select_conn_rsrc=t},SET_CONN_STATUS_DATA(e,t){e.conn_status_data=t}},actions:{async fetchRcTargetNames({state:e,commit:t},s){try{const a=await this.vue.$queryHttp.get(`/${s}?fields[${s}]=id`);if(a.data.data){const n=a.data.data.map(({id:e,type:t})=>({id:e,type:t}));t("SET_RC_TARGET_NAMES_MAP",{...e.rc_target_names_map,[s]:n})}}catch(a){this.vue.$logger("store-queryConn-fetchRcTargetNames").error(a)}},async cleanUpOrphanedConns({commit:e,dispatch:t,rootState:s,rootGetters:a},n){try{let r=[];for(const e of n){await this.vue.$queryHttp.delete("/sql/"+e.id);const{wke_id_fk:s}=a["querySession/getSessionByConnId"](e.id);s&&!r.includes(s)&&r.push(s),t("querySession/resetSessionStates",{conn_id:e.id},{root:!0})}r.forEach(a=>{e("wke/REFRESH_WKE",s.wke.worksheets_arr.find(e=>e.id===a),{root:!0}),t("wke/releaseQueryModulesMem",a,{root:!0})})}catch(r){this.vue.$logger("store-queryConn-cleanUpOrphanedConns").error(r)}},updateAliveActiveConn({state:e,commit:t,rootGetters:s},a){const n=s["querySession/getActiveSessionId"];this.vue.$helpers.lodash.isEqual(a,e.active_sql_conn)||t("SET_ACTIVE_SQL_CONN",{payload:a,id:n})},async fetchConnStatus({commit:e},t){try{const s=await this.vue.$queryHttp.get("/sql/"),a=this.vue.$helpers.lodash.keyBy(s.data.data,"id");let n={},r={},o=[];this.vue.$typy(a).isEmptyObject||Object.values(t).forEach(e=>{const t=e.id;if(a[t]){const s=this.vue.$typy(e,"clone_of_conn_id").safeString;s&&!a[s]?o.push(e):n[t]={...e,attributes:a[t].attributes}}else r[t]=e}),e("SET_CONN_STATUS_DATA",{alive_conn_map:n,expired_conn_map:r,orphaned_conns:o})}catch(s){this.vue.$logger("store-queryConn-fetchConnStatus").error(s)}},async validateConns({state:e,commit:t,dispatch:s},{sqlConns:a,silentValidation:n=!1,customSetSqlConns:r}){let o={};n||t("SET_IS_VALIDATING_CONN",!0);try{if(await s("fetchConnStatus",a),this.vue.$typy(e.conn_status_data,"alive_conn_map").isEmptyObject)s("resetAllStates");else{const{alive_conn_map:t={},expired_conn_map:a={},orphaned_conns:n=[]}=e.conn_status_data;Object.keys(a).forEach(e=>{s("querySession/resetSessionStates",{conn_id:e},{root:!0})}),await s("cleanUpOrphanedConns",n);const r=t[e.active_sql_conn.id]||{};await s("updateAliveActiveConn",r),o=t}}catch(i){this.vue.$logger("store-queryConn-validateConns").error(i)}this.vue.$typy(r).isFunction?r(o):t("SET_SQL_CONNS",o),t("SET_IS_VALIDATING_CONN",!1)},unbindConn({commit:e,rootState:t,getters:s}){const a=s.getWkeConns.find(e=>e.wke_id_fk===t.wke.active_wke_id);a&&e("UPDATE_SQL_CONN",{...a,wke_id_fk:""})},bindConn({commit:e,rootState:t},s){e("UPDATE_SQL_CONN",{...s,wke_id_fk:t.wke.active_wke_id})},async onChangeConn({commit:e,getters:t,dispatch:s,rootGetters:a},n){try{s("unbindConn");let r={};const o=a["querySession/getActiveSessionId"],i=a["querySession/getSessionsOfActiveWke"];if(i.length){const a=t.getClonedConnsOfWkeConn(n.id),c=i.slice(0,a.length),_=i.slice(a.length);for(const[t,n]of c.entries())e("UPDATE_SQL_CONN",{...a[t],session_id_fk:n.id}),s("syncSqlConnToSess",{sess:n,sql_conn:a[t]}),o===n.id&&(r=a[t]);await s("cloneAndSyncConnToSessions",{sessions:_,conn_to_be_cloned:n,active_session_id:o,getActiveSessConn:e=>r=e})}e("SET_ACTIVE_SQL_CONN",{payload:r,id:o}),s("bindConn",n)}catch(r){this.vue.$logger("store-queryConn-onChangeConn").error(r)}},async openConnect({dispatch:e,commit:t,rootState:s,rootGetters:a},{body:n,resourceType:r,meta:o={}}){const i=a["querySession/getSessionsOfActiveWke"],c=a["querySession/getActiveSessionId"];try{const a=await this.vue.$queryHttp.post("/sql?persist=yes&max-age="+s.queryEditorConfig.auth_cookies_max_age,n);if(201===a.status){e("unbindConn"),t("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("info.connSuccessfully")],type:"success"},{root:!0});const _=a.data.data.id,d={id:_,attributes:a.data.data.attributes,name:n.target,type:r,binding_type:s.queryEditorConfig.config.QUERY_CONN_BINDING_TYPES.WORKSHEET,wke_id_fk:s.wke.active_wke_id,meta:o};t("ADD_SQL_CONN",d);let l=d;i.length&&await e("cloneAndSyncConnToSessions",{sessions:i,conn_to_be_cloned:d,active_session_id:c,getActiveSessConn:e=>l=e}),t("SET_ACTIVE_SQL_CONN",{id:c,payload:l}),n.db&&await e("useDb",n.db),t("SET_CONN_ERR_STATE",!1)}}catch(_){this.vue.$logger("store-queryConn-openConnect").error(_),t("SET_CONN_ERR_STATE",!0)}},syncSqlConnToSess(e,{sess:t,sql_conn:s}){M.syncToPersistedObj({scope:this,data:{active_sql_conn:s},id:t.id,persistedArrayPath:"querySession.query_sessions"})},async cloneAndSyncConnToSessions({dispatch:e,rootState:t},{sessions:s,conn_to_be_cloned:a,active_session_id:n,getActiveSessConn:r}){for(const o of s){let s;await e("cloneConn",{conn_to_be_cloned:a,binding_type:t.queryEditorConfig.config.QUERY_CONN_BINDING_TYPES.SESSION,session_id_fk:o.id,getCloneObjRes:e=>s=e}),o.id===n?r(s):e("syncSqlConnToSess",{sess:o,sql_conn:s})}},async cloneConn({commit:e,rootState:t},{conn_to_be_cloned:s,binding_type:a,session_id_fk:n,getCloneObjRes:r}){try{const o=t.queryEditorConfig.auth_cookies_max_age,i=await this.vue.$queryHttp.post(`/sql/${s.id}/clone?persist=yes&max-age=${o}`);if(201===i.status){const t=i.data.data.id,o={id:t,attributes:i.data.data.attributes,name:s.name,type:s.type,clone_of_conn_id:s.id,binding_type:a,session_id_fk:n,meta:this.vue.$typy(s,"meta").safeObjectOrEmpty};this.vue.$typy(r).safeFunction(o),e("ADD_SQL_CONN",o)}}catch(o){this.vue.$logger("store-queryConn-cloneConn").error(o)}},async disconnectClone({state:e,commit:t},{id:s}){try{const a=await this.vue.$queryHttp.delete("/sql/"+s);204===a.status&&t("DELETE_SQL_CONN",e.sql_conns[s])}catch(a){this.vue.$logger("store-queryConn-disconnectClone").error(a)}},async disconnect({state:e,commit:t,dispatch:s},{showSnackbar:a,id:n}){try{if(e.sql_conns[n]){const r=Object.values(e.sql_conns).filter(e=>e.clone_of_conn_id===n).map(e=>e.id),o=[n,...r];s("wke/resetWkeStates",n,{root:!0});const i=await Promise.all(o.map(a=>(t("DELETE_SQL_CONN",e.sql_conns[a]),s("querySession/resetSessionStates",{conn_id:a},{root:!0}),this.vue.$queryHttp.delete("/sql/"+a))));i.every(e=>204===e.status)&&a&&t("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("info.disconnSuccessfully")],type:"success"},{root:!0})}}catch(r){this.vue.$logger("store-queryConn-disconnect").error(r)}},async disconnectAll({getters:e,dispatch:t}){try{for(const{id:s=""}of e.getWkeConns)await t("disconnect",{showSnackbar:!1,id:s})}catch(s){this.vue.$logger("store-queryConn-disconnectAll").error(s)}},async reconnect({state:e,commit:t,dispatch:s,getters:a}){const n=e.active_sql_conn;try{let e=[];const r=this.vue.$typy(a.getCurrWkeConn,"id").safeString,o=this.vue.$typy(n,"id").safeString;r&&e.push(r),o&&e.push(o);const i=await Promise.all(e.map(e=>this.vue.$queryHttp.post(`/sql/${e}/reconnect`)));i.length&&i.every(e=>204===e.status)?(t("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("info.reconnSuccessfully")],type:"success"},{root:!0}),await s("schemaSidebar/initialFetch",{},{root:!0})):t("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("errors.reconnFailed")],type:"error"},{root:!0})}catch(r){this.vue.$logger("store-queryConn-reconnect").error(r)}},clearConn({commit:e,dispatch:t,state:s}){try{const a=s.active_sql_conn;t("querySession/resetSessionStates",{conn_id:a.id},{root:!0}),e("DELETE_SQL_CONN",a)}catch(a){this.vue.$logger("store-queryConn-clearConn").error(a)}},async updateActiveDb({state:e,commit:t,rootGetters:s}){const{active_sql_conn:a,active_db:n}=e,r=s["querySession/getActiveSessionId"];try{let e=await this.vue.$queryHttp.post(`/sql/${a.id}/queries`,{sql:"SELECT DATABASE()"});const s=this.vue.$typy(e,"data.data.attributes.results[0].data").safeArray.flat()[0];s?n!==s&&t("SET_ACTIVE_DB",{payload:s,id:r}):t("SET_ACTIVE_DB",{payload:"",id:r})}catch(o){this.vue.$logger("store-queryConn-updateActiveDb").error(o)}},async useDb({commit:e,dispatch:t,state:s,rootState:a,rootGetters:n},r){const o=s.active_sql_conn,i=n["querySession/getActiveSessionId"];try{const s=(new Date).valueOf(),n=this.vue.$helpers.escapeIdentifiers(r),c=`USE ${n};`;let _=await this.vue.$queryHttp.post(`/sql/${o.id}/queries`,{sql:c}),d="Change default database to "+n;if(_.data.data.attributes.results[0].errno){const t=_.data.data.attributes.results[0];e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:Object.keys(t).map(e=>`${e}: ${t[e]}`),type:"error"},{root:!0}),d="Failed to change default database to "+n}else e("SET_ACTIVE_DB",{payload:r,id:i});t("queryPersisted/pushQueryLog",{startTime:s,name:d,sql:c,res:_,connection_name:o.name,queryType:a.queryEditorConfig.config.QUERY_LOG_TYPES.ACTION_LOGS},{root:!0})}catch(c){this.vue.$logger("store-queryConn-useDb").error(c)}},resetAllStates({rootState:e,rootGetters:t,commit:s}){for(const a of e.wke.worksheets_arr){s("wke/REFRESH_WKE",a,{root:!0});const e=t["querySession/getSessionsByWkeId"](a.id);for(const t of e)s("querySession/REFRESH_SESSION_OF_A_WKE",t,{root:!0})}}},getters:{getIsConnBusy:(e,t,s,a)=>{const{value:n=!1}=e.is_conn_busy_map[a["querySession/getActiveSessionId"]]||{};return n},getIsConnBusyBySessionId:e=>t=>{const{value:s=!1}=e.is_conn_busy_map[t]||{};return s},getLostCnnErrMsgObj:(e,t,s,a)=>{const{value:n={}}=e.lost_cnn_err_msg_obj_map[a["querySession/getActiveSessionId"]]||{};return n},getWkeConns:(e,t,s)=>Object.values(e.sql_conns).filter(e=>e.binding_type===s.queryEditorConfig.config.QUERY_CONN_BINDING_TYPES.WORKSHEET)||[],getClonedConnsOfWkeConn:e=>t=>Object.values(e.sql_conns).filter(e=>e.clone_of_conn_id===t)||[],getCurrWkeConn:(e,t,s)=>t.getWkeConns.find(e=>e.wke_id_fk===s.wke.active_wke_id)||{},getWkeConnByWkeId:(e,t)=>e=>t.getWkeConns.find(t=>t.wke_id_fk===e)||{}}},X=s("9771");const z=M.syncStateCreator("editor"),J=M.memStateCreator("editor");var Z={namespaced:!0,state:{selected_query_txt:"",charset_collation_map:{},def_db_charset_map:{},engines:[],...J,...z,file_dlg_data:{is_opened:!1,title:"",confirm_msg:"",on_save:()=>null,dont_save:()=>null}},mutations:{...M.memStatesMutationCreator(J),...M.syncedStateMutationsCreator({statesToBeSynced:z,persistedArrayPath:"querySession.query_sessions"}),SET_SELECTED_QUERY_TXT(e,t){e.selected_query_txt=t},SET_CHARSET_COLLATION_MAP(e,t){e.charset_collation_map=t},SET_DEF_DB_CHARSET_MAP(e,t){e.def_db_charset_map=t},SET_ENGINES(e,t){e.engines=t},SET_FILE_DLG_DATA(e,t){e.file_dlg_data=t}},actions:{async queryCharsetCollationMap({rootState:e,commit:t}){const s=e.queryConn.active_sql_conn;try{const e="SELECT character_set_name, collation_name, is_default FROM information_schema.collations";let a=await this.vue.$queryHttp.post(`/sql/${s.id}/queries`,{sql:e}),n={};const r=this.vue.$typy(a,"data.data.attributes.results[0].data").safeArray;r.forEach(e=>{const t=e[0],s=e[1],a="Yes"===e[2];let r=n[""+t]||{collations:[]};a&&(r.defCollation=s),r.collations.push(s),n[t]=r}),t("SET_CHARSET_COLLATION_MAP",n)}catch(a){this.vue.$logger("store-editor-queryCharsetCollationMap").error(a)}},async queryDefDbCharsetMap({rootState:e,commit:t}){const s=e.queryConn.active_sql_conn;try{const e="SELECT schema_name, default_character_set_name FROM information_schema.schemata";let a=await this.vue.$queryHttp.post(`/sql/${s.id}/queries`,{sql:e}),n={};const r=this.vue.$typy(a,"data.data.attributes.results[0].data").safeArray;r.forEach(e=>{const t=e[0],s=e[1];n[t]=s}),t("SET_DEF_DB_CHARSET_MAP",n)}catch(a){this.vue.$logger("store-editor-queryDefDbCharsetMap").error(a)}},async queryEngines({rootState:e,commit:t}){const s=e.queryConn.active_sql_conn;try{let e=await this.vue.$queryHttp.post(`/sql/${s.id}/queries`,{sql:"SELECT engine FROM information_schema.ENGINES"});t("SET_ENGINES",e.data.data.attributes.results[0].data.flat())}catch(a){this.vue.$logger("store-editor-queryEngines").error(a)}},async queryAlterTblSuppData({state:e,dispatch:t}){this.vue.$typy(e.engines).isEmptyArray&&await t("queryEngines"),this.vue.$typy(e.charset_collation_map).isEmptyObject&&await t("queryCharsetCollationMap"),this.vue.$typy(e.def_db_charset_map).isEmptyObject&&await t("queryDefDbCharsetMap")},async queryTblCreationInfo({commit:e,state:t,rootState:s,rootGetters:a},n){const r=s.queryConn.active_sql_conn,o=a["querySession/getActiveSessionId"];try{e("SET_TBL_CREATION_INFO",{id:o,payload:{...t.tbl_creation_info,loading_tbl_creation_info:!0,altered_active_node:n}});const s=n.id.split("."),a=s[0],i=await M.queryTblOptsData({active_sql_conn:r,nodeId:n.id,vue:this.vue,$queryHttp:this.vue.$queryHttp}),c=await M.queryColsOptsData({active_sql_conn:r,nodeId:n.id,$queryHttp:this.vue.$queryHttp});e("SET_TBL_CREATION_INFO",{id:o,payload:{...t.tbl_creation_info,data:{table_opts_data:{dbName:a,...i},cols_opts_data:c},loading_tbl_creation_info:!1}})}catch(i){e("SET_TBL_CREATION_INFO",{id:o,payload:{...t.tbl_creation_info,loading_tbl_creation_info:!1}}),e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:this.vue.$helpers.getErrorsArr(i),type:"error"},{root:!0});const s=this.vue.$logger("store-query-queryTblCreationInfo");s.error(i)}}},getters:{getIsTxtEditor:(e,t,s)=>e.curr_editor_mode===s.queryEditorConfig.config.SQL_EDITOR_MODES.TXT_EDITOR,getIsDDLEditor:(e,t,s)=>e.curr_editor_mode===s.queryEditorConfig.config.SQL_EDITOR_MODES.DDL_EDITOR,getLoadingTblCreationInfo:e=>{const{loading_tbl_creation_info:t=!0}=e.tbl_creation_info;return t},getAlteredActiveNode:e=>{const{altered_active_node:t={}}=e.tbl_creation_info;return t},hasFileSystemReadOnlyAccess:()=>Boolean(X["b"]),hasFileSystemRWAccess:(e,t)=>t.hasFileSystemReadOnlyAccess&&window.location.protocol.includes("https"),getIsFileUnsavedBySessionId:(e,t,s,a)=>e=>{const t=a["querySession/getSessionById"](e),{blob_file:s={},query_txt:n=""}=t;return M.detectUnsavedChanges({query_txt:n,blob_file:s})},getSessFileHandle:()=>e=>{const{blob_file:{file_handle:t={}}={}}=e;return t},getSessFileHandleName:(e,t)=>e=>{const{name:s=""}=t.getSessFileHandle(e);return s},checkSessFileHandleValidity:(e,t)=>e=>Boolean(t.getSessFileHandleName(e))}};s("5319");const ee=M.syncStateCreator("schemaSidebar"),te=M.memStateCreator("schemaSidebar");function se(e){return e.vue.$helpers.lodash.uniqueId("node_key_")}var ae={namespaced:!0,state:{...te,...ee},mutations:{...M.memStatesMutationCreator(te),...M.syncedStateMutationsCreator({statesToBeSynced:ee,persistedArrayPath:"wke.worksheets_arr"})},actions:{async initialFetch({dispatch:e}){await e("fetchSchemas"),await e("queryConn/updateActiveDb",{},{root:!0})},async getDbs({rootState:e}){const t=e.queryConn.active_sql_conn;try{const{SQL_NODE_TYPES:{SCHEMA:s,TABLES:a,SPS:n},SQL_SYS_SCHEMAS:r}=e.queryEditorConfig.config;let o="SELECT * FROM information_schema.SCHEMATA";e.queryPersisted.query_show_sys_schemas_flag||(o+=` WHERE SCHEMA_NAME NOT IN(${r.map(e=>`'${e}'`).join(",")})`),o+=" ORDER BY SCHEMA_NAME;";const i=await this.vue.$queryHttp.post(`/sql/${t.id}/queries`,{sql:o});let c=[],_=[];if(i.data.data.attributes.results[0].data){const e=this.vue.$helpers.getObjectRows({columns:i.data.data.attributes.results[0].fields,rows:i.data.data.attributes.results[0].data});e.forEach(e=>{_.push({key:se(this),type:s,name:e.SCHEMA_NAME,id:e.SCHEMA_NAME,data:e,draggable:!0,level:0,isSys:r.includes(e.SCHEMA_NAME.toLowerCase()),children:[{key:se(this),type:a,name:a,id:`${e.SCHEMA_NAME}.${a}`,draggable:!1,level:1,children:[]},{key:se(this),type:n,name:n,id:`${e.SCHEMA_NAME}.${n}`,draggable:!1,level:1,children:[]}]}),c.push({label:e.SCHEMA_NAME,detail:"SCHEMA",insertText:`\`${e.SCHEMA_NAME}\``,type:s})})}return{db_tree:_,cmpList:c}}catch(s){this.vue.$logger("store-schemaSidebar-getDbs").error(s)}},async getDbGrandChild({rootState:e},t){const s=e.queryConn.active_sql_conn;try{let a,n,r,o;const{SQL_NODE_TYPES:{TABLES:i,TABLE:c,SPS:_,SP:d,COLS:l,TRIGGERS:u},SQL_SYS_SCHEMAS:S}=e.queryEditorConfig.config;let y=`\\b.${t.type}\\b`;switch(a=t.id.replace(new RegExp(y,"g"),""),t.type){case i:n=c,r="TABLE_NAME",o=`SELECT TABLE_NAME, CREATE_TIME, TABLE_TYPE, TABLE_ROWS, ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${a}'`;break;case _:n=d,r="ROUTINE_NAME",o=`SELECT ROUTINE_NAME, CREATED FROM information_schema.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_SCHEMA = '${a}'`;break}o+=` ORDER BY ${r};`;const E=await this.vue.$queryHttp.post(`/sql/${s.id}/queries`,{sql:o}),m=this.vue.$helpers.getObjectRows({columns:E.data.data.attributes.results[0].fields,rows:E.data.data.attributes.results[0].data});let h=[],p=[];return m.forEach(e=>{let s={key:se(this),type:n,name:e[r],id:`${a}.${e[r]}`,draggable:!0,data:e,level:2,isSys:S.includes(a.toLowerCase())};t.type===i&&(s.canBeHighlighted=!0,s.children=[{key:se(this),type:l,name:l,id:`${a}.${e[r]}.${l}`,draggable:!1,children:[],level:3},{key:se(this),type:u,name:u,id:`${a}.${e[r]}.${u}`,draggable:!1,children:[],level:3}]),h.push(s),p.push({label:e[r],detail:n.toUpperCase(),insertText:`\`${e[r]}\``,type:n})}),{dbName:a,gch:h,cmpList:p}}catch(a){this.vue.$logger("store-schemaSidebar-getDbGrandChild").error(a)}},async getTableGrandChild({rootState:e},t){const s=e.queryConn.active_sql_conn;try{const a=t.id.split(".")[0],n=t.id.split(".")[1],{SQL_NODE_TYPES:{COLS:r,COL:o,TRIGGERS:i,TRIGGER:c},SQL_SYS_SCHEMAS:_}=e.queryEditorConfig.config;let d,l,u;switch(t.type){case i:d=c,l="TRIGGER_NAME",u=`SELECT TRIGGER_NAME, CREATED, EVENT_MANIPULATION, ACTION_STATEMENT FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA='${a}' AND EVENT_OBJECT_TABLE = '${n}'`;break;case r:d=o,l="COLUMN_NAME",u=`SELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_KEY, PRIVILEGES FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = "${a}" AND TABLE_NAME = "${n}"`;break}u+=` ORDER BY ${l};`;const S=await this.vue.$queryHttp.post(`/sql/${s.id}/queries`,{sql:u}),y=this.vue.$helpers.getObjectRows({columns:S.data.data.attributes.results[0].fields,rows:S.data.data.attributes.results[0].data});let E=[],m=[];return y.forEach(e=>{E.push({key:se(this),type:d,name:e[l],id:`${n}.${e[l]}`,draggable:!0,data:e,level:4,isSys:_.includes(a.toLowerCase())}),m.push({label:e[l],detail:d.toUpperCase(),insertText:e[l],type:d})}),{dbName:a,tblName:n,gch:E,cmpList:m}}catch(a){this.vue.$logger("store-schemaSidebar-getTableGrandChild").error(a)}},async getTreeData({dispatch:e,rootState:t},{node:s,db_tree:a,cmpList:n}){try{const{TABLES:r,SPS:o,COLS:i,TRIGGERS:c}=t.queryEditorConfig.config.SQL_NODE_TYPES;switch(s.type){case r:case o:{const{gch:t,cmpList:r,dbName:o}=await e("getDbGrandChild",s),i=M.updateDbChild({db_tree:a,dbName:o,childType:s.type,gch:t});return{new_db_tree:i,new_cmp_list:[...n,...r]}}case i:case c:{const{gch:t,cmpList:r,dbName:o,tblName:i}=await e("getTableGrandChild",s),c=M.updateTblChild({db_tree:a,dbName:o,tblName:i,childType:s.type,gch:t});return{new_db_tree:c,new_cmp_list:[...n,...r]}}}}catch(r){return this.vue.$logger("store-schemaSidebar-getTreeData").error(r),{new_db_tree:{},new_cmp_list:[]}}},async updateTreeNodes({commit:e,dispatch:t,rootState:s,getters:a},n){const r=s.wke.active_wke_id;try{const{new_db_tree:s,new_cmp_list:o}=await t("getTreeData",{node:n,db_tree:a.getDbTreeData,cmpList:a.getDbCmplList});e("PATCH_DB_TREE_MAP",{id:r,payload:{data:s,db_completion_list:o}})}catch(o){this.vue.$logger("store-schemaSidebar-updateTreeNodes").error(o)}},async fetchSchemas({commit:e,dispatch:t,state:s,rootState:a}){const n=a.wke.active_wke_id,r=a.queryConn.active_sql_conn,o=this.vue.$helpers.lodash.cloneDeep(s.expanded_nodes);try{e("PATCH_DB_TREE_MAP",{id:n,payload:{loading_db_tree:!0}});const{db_tree:s,cmpList:i}=await t("getDbs");if(s.length){let c=s,_=i;const{TABLES:d,SPS:l,COLS:u,TRIGGERS:S}=a.queryEditorConfig.config.SQL_NODE_TYPES,y=[d,l,u,S];for(const e of o)if(y.includes(e.type)){const{new_db_tree:s,new_cmp_list:a}=await t("getTreeData",{node:e,db_tree:c,cmpList:_});this.vue.$typy(s).isEmptyObject||(c=s),_.length&&(_=a)}e("PATCH_DB_TREE_MAP",{id:n,payload:{loading_db_tree:!1,data:c,db_completion_list:_,data_of_conn:r.name}})}}catch(i){e("PATCH_DB_TREE_MAP",{id:n,payload:{loading_db_tree:!1}}),this.vue.$logger("store-schemaSidebar-fetchSchemas").error(i)}},async exeStmtAction({rootState:e,dispatch:t,commit:s},{sql:a,action:n,showSnackbar:r=!0}){const o=e.queryConn.active_sql_conn,i=e.wke.active_wke_id,c=(new Date).valueOf();try{let _={},d=await this.vue.$queryHttp.post(`/sql/${o.id}/queries`,{sql:a,max_rows:e.queryPersisted.query_row_limit});const l=this.vue.$typy(d,"data.data.attributes.results").safeArray,u=l.filter(e=>this.vue.$typy(e,"errno").isDefined);let S;u.length&&(_=u[0]),s("PATCH_EXE_STMT_RESULT_MAP",{id:i,payload:{data:d.data.data.attributes,stmt_err_msg_obj:_}}),this.vue.$typy(_).isEmptyObject?(S=this.vue.$mxs_t("info.exeActionSuccessfully",{action:n}),r&&s("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[S],type:"success"},{root:!0})):S=this.vue.$mxs_t("errors.failedToExeAction",{action:n}),t("queryPersisted/pushQueryLog",{startTime:c,name:S,sql:a,res:d,connection_name:o.name,queryType:e.queryEditorConfig.config.QUERY_LOG_TYPES.ACTION_LOGS},{root:!0})}catch(_){this.vue.$logger("store-schemaSidebar-exeStmtAction").error(_)}}},getters:{getCurrDbTree:(e,t,s)=>e.db_tree_map[s.wke.active_wke_id]||{},getActivePrvwTblNode:(e,t)=>t.getCurrDbTree.active_prvw_tbl_node||{},getDbTreeData:(e,t)=>t.getCurrDbTree.data||[],getLoadingDbTree:(e,t)=>t.getCurrDbTree.loading_db_tree||!1,getDbCmplList:(e,t)=>t.getCurrDbTree.db_completion_list?r["lodash"].uniqBy(t.getCurrDbTree.db_completion_list,"label"):[],getExeStmtResultMap:(e,t,s)=>e.exe_stmt_result_map[s.wke.active_wke_id]||{}}};const ne=M.syncStateCreator("queryResult"),re=M.memStateCreator("queryResult");var oe={namespaced:!0,state:{...re,...ne,is_max_rows_valid:!0},mutations:{...M.memStatesMutationCreator(re),...M.syncedStateMutationsCreator({statesToBeSynced:ne,persistedArrayPath:"querySession.query_sessions"}),SET_IS_MAX_ROWS_VALID(e,t){e.is_max_rows_valid=t}},actions:{async fetchPrvw({rootState:e,commit:t,dispatch:s,rootGetters:a},{tblId:n,prvwMode:r}){const o=e.queryConn.active_sql_conn,i=a["querySession/getActiveSessionId"],c=(new Date).valueOf();try{let a,_;t(`PATCH_${r}_MAP`,{id:i,payload:{request_sent_time:c,total_duration:0,is_loading:!0}});const d=this.vue.$helpers.escapeIdentifiers(n);switch(r){case e.queryEditorConfig.config.SQL_QUERY_MODES.PRVW_DATA:a=`SELECT * FROM ${d} LIMIT 1000;`,_=`Preview ${d} data`;break;case e.queryEditorConfig.config.SQL_QUERY_MODES.PRVW_DATA_DETAILS:a=`DESCRIBE ${d};`,_=`View ${d} details`;break}let l=await this.vue.$queryHttp.post(`/sql/${o.id}/queries`,{sql:a,max_rows:e.queryPersisted.query_row_limit});const u=(new Date).valueOf(),S=((u-c)/1e3).toFixed(4);t(`PATCH_${r}_MAP`,{id:i,payload:{data:Object.freeze(l.data.data),total_duration:parseFloat(S),is_loading:!1}}),s("queryPersisted/pushQueryLog",{startTime:u,name:_,sql:a,res:l,connection_name:o.name,queryType:e.queryEditorConfig.config.QUERY_LOG_TYPES.ACTION_LOGS},{root:!0})}catch(_){t(`PATCH_${r}_MAP`,{id:i,payload:{is_loading:!1}}),this.vue.$logger("store-queryResult-fetchPrvw").error(_)}},async fetchQueryResult({commit:e,dispatch:t,getters:s,rootState:a,rootGetters:n},r){const o=a.queryConn.active_sql_conn,i=(new Date).valueOf(),c=n["querySession/getActiveSessionId"],_=new AbortController,d=a.queryEditorConfig.config;try{e("PATCH_QUERY_RESULTS_MAP",{id:c,payload:{data:{},request_sent_time:i,total_duration:0,is_loading:!0,abort_controller:_}});let n=await this.vue.$queryHttp.post(`/sql/${o.id}/queries`,{sql:r,max_rows:a.queryPersisted.query_row_limit},{signal:_.signal});const l=(new Date).valueOf(),u=((l-i)/1e3).toFixed(4);if(s.getHasKillFlagMapBySessionId(c))e("PATCH_HAS_KILL_FLAG_MAP",{id:c,payload:{value:!1}}),n={data:{data:{attributes:{results:[{message:d.QUERY_CANCELED}],sql:r}}}},e("queryConn/PATCH_IS_CONN_BUSY_MAP",{id:c,payload:{value:!1}},{root:!0});else{const e=/(use|drop database)\s/i;r.match(e)&&await t("queryConn/updateActiveDb",{},{root:!0})}e("PATCH_QUERY_RESULTS_MAP",{id:c,payload:{data:Object.freeze(n.data.data),total_duration:parseFloat(u),is_loading:!1}}),t("queryPersisted/pushQueryLog",{startTime:l,sql:r,res:n,connection_name:o.name,queryType:a.queryEditorConfig.config.QUERY_LOG_TYPES.USER_LOGS},{root:!0})}catch(l){e("PATCH_QUERY_RESULTS_MAP",{id:c,payload:{is_loading:!1}}),this.vue.$logger("store-queryResult-fetchQueryResult").error(l)}},async stopQuery({commit:e,getters:t,rootGetters:s,rootState:a}){const n=a.queryConn.active_sql_conn,r=s["querySession/getActiveSessionId"];try{e("PATCH_HAS_KILL_FLAG_MAP",{id:r,payload:{value:!0}});const a=s["queryConn/getCurrWkeConn"],{data:{data:{attributes:{results:o=[]}={}}={}}={}}=await this.vue.$queryHttp.post(`/sql/${a.id}/queries`,{sql:"KILL QUERY "+n.attributes.thread_id});if(this.vue.$typy(o,"[0].errno").isDefined)e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:["Failed to stop the query",...Object.keys(o[0]).map(e=>`${e}: ${o[0][e]}`)],type:"error"},{root:!0});else{const e=t.getAbortControllerBySessId(r);e.abort()}}catch(o){this.vue.$logger("store-queryResult-stopQuery").error(o)}},clearDataPreview({commit:e,rootGetters:t}){const s=t["querySession/getActiveSessionId"];e("PATCH_PRVW_DATA_MAP",{id:s}),e("PATCH_PRVW_DATA_DETAILS_MAP",{id:s})}},getters:{getUserQueryRes:(e,t,s,a)=>e.query_results_map[a["querySession/getActiveSessionId"]]||{},getLoadingQueryResultBySessionId:e=>t=>{const{is_loading:s=!1}=e.query_results_map[t]||{};return s},getAbortControllerBySessId:e=>t=>{const{abort_controller:s={}}=e.query_results_map[t]||{};return s},isWkeLoadingQueryResult:(e,t,s,a)=>t=>{const s=a["querySession/getSessionsByWkeId"](t).map(e=>e.id);let n=!1;for(const a of Object.keys(e.query_results_map))if(s.includes(a)){const{is_loading:t=!1}=e.query_results_map[a]||{};if(t){n=!0;break}}return n},getHasKillFlagMapBySessionId:e=>t=>{const{value:s=!1}=e.has_kill_flag_map[t]||{};return s},getPrvwData:(e,t,s,a)=>t=>{let s=e[t.toLowerCase()+"_map"];return s&&s[a["querySession/getActiveSessionId"]]||{}},getIsRunBtnDisabledBySessionId:(e,t,s,a)=>e=>{const n=s.querySession.query_sessions.find(t=>t.id===e);return!n||(!n.query_txt||!n.active_sql_conn.id||a["queryConn/getIsConnBusyBySessionId"](n.id)||t.getLoadingQueryResultBySessionId(n.id))},getIsVisBtnDisabledBySessionId:(e,t,s,a)=>e=>{const n=s.querySession.query_sessions.find(t=>t.id===e);return!n||(!n.active_sql_conn.id||a["queryConn/getIsConnBusyBySessionId"](n.id)&&t.getLoadingQueryResultBySessionId(n.id))},getChartResultSets:(e,t,s,a)=>({scope:e})=>{let n=[];const r=e.$helpers.stringifyClone(e.$typy(t.getUserQueryRes,"data.attributes.results").safeArray);let o=0;for(const t of r)t.data&&(++o,n.push({id:"RESULT SET "+o,...t}));const{PRVW_DATA:i,PRVW_DATA_DETAILS:c}=s.queryEditorConfig.config.SQL_QUERY_MODES,_=[i,c];for(const s of _){const r=e.$helpers.stringifyClone(e.$typy(t.getPrvwData(s),"data.attributes.results[0]").safeObjectOrEmpty);if(!e.$typy(r).isEmptyObject){let t="";switch(s){case i:t=e.$mxs_t("previewData");break;case c:t=e.$mxs_t("viewDetails");break}n.push({id:`${t} of ${a["schemaSidebar/getActivePrvwTblNode"].id}`,...r})}}return n}}},ie={namespaced:!0,state:{query_sessions:W.get_def_query_sessions,active_session_by_wke_id_map:{}},mutations:{ADD_NEW_SESSION(e,{wke_id:t,name:s}){let a="Query Tab 1",n=1;const r=e.query_sessions.filter(e=>e.wke_id_fk===t);if(r.length){const e=r[r.length-1];n=e.count+1,a="Query Tab "+n}const o={...x(t),name:s||a,count:n};e.query_sessions.push(o)},DELETE_SESSION(e,t){e.query_sessions=e.query_sessions.filter(e=>e.id!==t)},UPDATE_SESSION(e,t){const s=e.query_sessions.findIndex(e=>e.id===t.id);e.query_sessions=this.vue.$helpers.immutableUpdate(e.query_sessions,{[s]:{$set:t}})},SET_ACTIVE_SESSION_BY_WKE_ID_MAP(e,{id:t,payload:s}){s?e.active_session_by_wke_id_map={...e.active_session_by_wke_id_map,[t]:s}:this.vue.$delete(e.active_session_by_wke_id_map,t)},REFRESH_SESSION_OF_A_WKE(e,t){const s=e.query_sessions.findIndex(e=>e.id===t.id);let a={...this.vue.$helpers.lodash.cloneDeep(t)};this.vue.$typy(a,"blob_file").isEmptyObject&&(a.name="Query Tab "+a.count);const n=["id","name","count","blob_file","query_txt"];e.query_sessions=this.vue.$helpers.immutableUpdate(e.query_sessions,{[s]:{$set:{...a,...this.vue.$helpers.lodash.pickBy(x(a.wke_id_fk),(e,t)=>!n.includes(t))}}})}},actions:{async handleAddNewSession({commit:e,state:t,dispatch:s,rootState:a,rootGetters:n},{wke_id:r,name:o}){try{e("ADD_NEW_SESSION",{wke_id:r,name:o});const i=t.query_sessions[t.query_sessions.length-1].id,c=n["queryConn/getWkeConnByWkeId"](r);let _;c.id&&await s("queryConn/cloneConn",{conn_to_be_cloned:c,binding_type:a.queryEditorConfig.config.QUERY_CONN_BINDING_TYPES.SESSION,session_id_fk:i,getCloneObjRes:e=>_=e},{root:!0}),e("SET_ACTIVE_SESSION_BY_WKE_ID_MAP",{id:r,payload:i}),_&&e("queryConn/SET_ACTIVE_SQL_CONN",{payload:_,id:i},{root:!0})}catch(i){this.vue.$logger("store-querySession-handleAddNewSession").error(i),e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("errors.persistentStorage")],type:"error"},{root:!0})}},async handleDeleteSession({commit:e,rootState:t,dispatch:s},a){const n=Object.values(t.queryConn.sql_conns).filter(e=>e.session_id_fk===a.id);for(const{id:r}of n)r&&await s("queryConn/disconnectClone",{id:r},{root:!0});s("releaseQueryModulesMem",a.id),e("DELETE_SESSION",a.id)},handleClearTheLastSession({commit:e,dispatch:t,getters:s},a){const n={...x(a.wke_id_fk),id:a.id,name:"Query Tab 1",count:1,active_sql_conn:a.active_sql_conn};e("UPDATE_SESSION",n),t("releaseQueryModulesMem",a.id),s.getActiveSessionId===a.id&&t("handleSyncSession",n)},handleSyncSession({commit:e},t){e("queryConn/SYNC_WITH_PERSISTED_OBJ",t,{root:!0}),e("queryResult/SYNC_WITH_PERSISTED_OBJ",t,{root:!0}),e("editor/SYNC_WITH_PERSISTED_OBJ",t,{root:!0})},releaseQueryModulesMem({commit:e},t){Object.keys(B).forEach(s=>{"schemaSidebar"!==s&&M.releaseMemory({namespace:s,commit:e,id:t,memStates:B[s]})})},resetSessionStates({state:e,rootState:t,commit:s,dispatch:a,getters:n},{conn_id:r,session_id:o}){const i=r?n.getSessionByConnId(r):e.query_sessions.find(e=>e.id===o);a("releaseQueryModulesMem",i.id),s("REFRESH_SESSION_OF_A_WKE",i);const c=t.querySession.query_sessions.find(e=>e.id===i.id);n.getActiveSessionId===o&&a("handleSyncSession",c)}},getters:{getActiveSessionId:(e,t,s)=>e.active_session_by_wke_id_map[s.wke.active_wke_id],getActiveSession:(e,t)=>e.query_sessions.find(e=>e.id===t.getActiveSessionId)||{},getSessionsOfActiveWke:(e,t,s)=>e.query_sessions.filter(e=>e.wke_id_fk===s.wke.active_wke_id),getSessionsByWkeId:e=>t=>e.query_sessions.filter(e=>e.wke_id_fk===t),getSessionByConnId:e=>t=>e.query_sessions.find(e=>e.active_sql_conn&&e.active_sql_conn.id===t)||{},getSessionById:e=>t=>e.query_sessions.find(e=>e.id===t)||{}}},ce=s("5395"),_e={namespaced:!0,state:{query_row_limit:1e4,query_confirm_flag:1,query_history:[],query_snippets:[],query_history_expired_time:Object(ce["addDaysToNow"])(30),query_show_sys_schemas_flag:1,tab_moves_focus:!1,max_statements:1e3},mutations:{SET_QUERY_ROW_LIMIT(e,t){e.query_row_limit=t},SET_QUERY_CONFIRM_FLAG(e,t){e.query_confirm_flag=t},SET_QUERY_HISTORY(e,t){e.query_history=t},UPDATE_QUERY_HISTORY(e,{idx:t,payload:s}){t?e.query_history.splice(t,1):e.query_history.unshift(s)},SET_QUERY_HISTORY_EXPIRED_TIME(e,t){e.query_history_expired_time=t},UPDATE_QUERY_SNIPPETS(e,{idx:t,payload:s}){t?e.query_snippets.splice(t,1):e.query_snippets.unshift(s)},SET_QUERY_SNIPPETS(e,t){e.query_snippets=t},SET_QUERY_SHOW_SYS_SCHEMAS_FLAG(e,t){e.query_show_sys_schemas_flag=t},SET_TAB_MOVES_FOCUS(e,t){e.tab_moves_focus=t},SET_MAX_STATEMENTS(e,t){e.max_statements=t}},actions:{pushQueryLog({commit:e,rootState:t},{startTime:s,connection_name:a,name:n,sql:r,res:o,queryType:i}){try{const c=this.vue.$helpers.maskQueryPwd(r),{capitalizeFirstLetter:_}=this.vue.$helpers,{execution_time:d,results:l}=this.vue.$typy(o,"data.data.attributes").safeObject;let u={},S=0,y=0;for(const e of l){const{data:s,message:a="",errno:n}=e,r=a===t.queryEditorConfig.config.QUERY_CANCELED;if(r)u["INTERRUPT"]=a;else if(s)++S,u["Result set "+S]=s.length+" rows in set.";else if(this.vue.$typy(n).isNumber){let t="";Object.keys(e).forEach(s=>t+=`${_(s)}: ${e[s]}. `),u["Error"]=t}else++y,u["Result "+y]=e.affected_rows+" rows affected."}let E="";Object.keys(u).forEach(e=>{E+=`${e}: ${u[e]} \n`});let m={name:c,response:E,type:i};this.vue.$typy(d).isNumber&&(m.execution_time=d.toFixed(4)),n&&(m.sql=c,m.name=n),e("UPDATE_QUERY_HISTORY",{payload:{date:s,connection_name:a,time:this.vue.$helpers.dateFormat({moment:this.vue.$moment,value:s,formatType:"HH:mm:ss"}),action:m}})}catch(c){const t=this.vue.$logger("store-queryPersisted-pushQueryLog");t.error(c),e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("errors.persistentStorage")],type:"error"},{root:!0})}},pushToQuerySnippets({commit:e},{date:t,name:s,sql:a}){try{e("UPDATE_QUERY_SNIPPETS",{payload:{date:t,time:this.vue.$helpers.dateFormat({moment:this.vue.$moment,value:t,formatType:"HH:mm:ss"}),name:s,sql:this.vue.$helpers.maskQueryPwd(a)}})}catch(n){const t=this.vue.$logger("store-queryPersisted-pushToQuerySnippets");t.error(n),e("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[this.vue.$mxs_t("errors.persistentStorage")],type:"error"},{root:!0})}},handleAutoClearQueryHistory({state:e,commit:t}){this.vue.$helpers.daysDiff({moment:this.vue.$moment,timestamp:e.query_history_expired_time})<=0&&(t("SET_QUERY_HISTORY",[]),t("SET_QUERY_HISTORY_EXPIRED_TIME",Object(ce["addDaysToNow"])(30)))}}},de={namespaced:!0,state:{config:a,hidden_comp:[""],axios_opts:{},auth_cookies_max_age:86400},mutations:{SET_HIDDEN_COMP(e,t){e.hidden_comp=t},SET_AXIOS_OPTS(e,t){e.axios_opts=t},SET_AUTH_COOKIES_MAX_AGE(e,t){e.auth_cookies_max_age=t}}},le=s("8002"),ue={mxsApp:le["a"],wke:G,queryConn:V,editor:Z,schemaSidebar:ae,queryResult:oe,querySession:ie,queryPersisted:_e,queryEditorConfig:de},Se=s("bc3a"),ye=s.n(Se),Ee=s("9a35");function me({store:e,value:t,sql_conn_id:s}){const{id:a}=e.getters["querySession/getSessionByConnId"](s)||{};a&&e.commit("queryConn/PATCH_IS_CONN_BUSY_MAP",{id:a,payload:{value:t}})}function he({res:e,store:t,sql_conn_id:s}){const a=t.vue.$typy(e,"data.data.attributes.results").safeArray,n=a.filter(e=>{const s=t.vue.$typy(e,"errno").safeNumber;return t.state.queryEditorConfig.config.MARIADB_NET_ERRNO.includes(s)});if(n.length){const{id:e}=t.getters["querySession/getSessionByConnId"](s)||{};t.commit("queryConn/PATCH_LOST_CNN_ERR_MSG_OBJ_MAP",{id:e,payload:{value:n[0]}})}}function pe(e){const t=/\/sql\/([a-zA-z0-9-]*?)\//g.exec(e)||[];return t.length>1?t[1]:null}function Te(e){let t=ye.a.create({baseURL:"/",headers:{"X-Requested-With":"XMLHttpRequest","Content-Type":"application/json","Cache-Control":"no-cache"}});return t.interceptors.request.use(t=>(t=e.vue.$helpers.lodash.merge(t,e.state.queryEditorConfig.axios_opts),me({store:e,value:!0,sql_conn_id:pe(t.url)}),{...t}),e=>Promise.reject(e)),t.interceptors.response.use(t=>(me({store:e,value:!1,sql_conn_id:pe(t.config.url)}),he({res:t,store:e,sql_conn_id:pe(t.config.url)}),t),async t=>{const{getErrorsArr:s}=e.vue.$helpers,{response:{status:a=null,config:{url:n=""}={}}={}}=t||{};switch(a){case null:Object(Ee["b"])({store:e,error:t});break;case 404:case 503:e.commit("mxsApp/SET_SNACK_BAR_MESSAGE",{text:[...s(t),"Please reconnect"],type:"error"},{root:!0});break;default:Object(Ee["a"])({store:e,error:t})}me({store:e,value:!1,sql_conn_id:pe(n)})}),t}var ge={install:(e,{store:t})=>{e.prototype.$queryHttp=Te(t)}};t["a"]={install:(e,{store:t})=>{if(!t)throw new Error("Please initialize plugin with a Vuex store.");e.component("query-editor",n["a"]),Object.keys(ue).forEach(e=>{"mxsApp"===e||t.registerModule(e,ue[e])}),e.use(ge,{store:t})}}},5395:function(e,t,s){"use strict";s.r(t),s.d(t,"deepDiff",(function(){return o})),s.d(t,"formatSQL",(function(){return i})),s.d(t,"splitQuery",(function(){return c})),s.d(t,"escapeIdentifiers",(function(){return _})),s.d(t,"getObjectRows",(function(){return d})),s.d(t,"pxToPct",(function(){return l})),s.d(t,"addDaysToNow",(function(){return u})),s.d(t,"daysDiff",(function(){return S})),s.d(t,"arrOfObjsDiff",(function(){return y})),s.d(t,"maskQueryPwd",(function(){return g}));s("ddb0"),s("caad"),s("5319");var a=s("0abc"),n=s("b5397"),r=s("962d");const o=s("6e8d");function i(e){return Object(n["a"])(e,{indent:" ",uppercase:!0,linesBetweenQueries:2})}function c(e){return Object(r["splitQuery"])(e,r["mysqlSplitterOptions"])}function _(e){return e.split(".").map(e=>`\`${e}\``).join(".")}function d({columns:e,rows:t}){return t.map(t=>{const s={};return e.forEach((e,a)=>{s[e]=t[a]}),s})}function l({px:e,containerPx:t}){return e/t*100}function u(e){let t=new Date;return t.setDate(t.getDate()+e)}function S({moment:e,timestamp:t}){const s=e().startOf("day"),a=e(t).startOf("day");return a.diff(s,"days")}function y({base:e,newArr:t,idField:s}){const n=[],r=[],i=new Map;e.forEach(e=>{n.push(e[s]),i.set(e[s],e)});const c=new Map;c.set("unchanged",[]),c.set("added",[]),c.set("removed",[]),c.set("updated",[]),t.forEach(e=>{r.push(e[s]);const t=i.get(e[s]);if(t)if(a["lodash"].isEqual(t,e))c.set("unchanged",[...c.get("unchanged"),e]);else{const s=o(t,e),a={oriObj:t,newObj:e,diff:s};c.set("updated",[...c.get("updated"),a])}else c.set("added",[...c.get("added"),e])});const _=n.filter(e=>!r.includes(e)),d=_.map(e=>i.get(e));return c.set("removed",d),c}const E=/IDENTIFIED\s*/gim,m=/['"][^'"]*['"]/,h=new RegExp("(\\b"+E.source+"BY(?:\\s*PASSWORD)?\\s*)"+m.source,"gim"),p=new RegExp("(\\b"+E.source+"(VIA|WITH)\\s*\\w+\\s*(USING|AS)\\s*)"+m.source,"gim"),T=new RegExp("PASSWORD\\s*\\("+m.source,"gim");function g(e){return e.match(E)||e.match(T)?e.replace(h,"$1'***'").replace(T,"PASSWORD('***'").replace(p,"$1'***'"):e}},cc451:function(e,t,s){},cd52:function(e,t,s){"use strict";var a=s("2f62");t["a"]={computed:{...Object(a["c"])({hasFileSystemRWAccess:"editor/hasFileSystemRWAccess",getSessFileHandle:"editor/getSessFileHandle",getSessFileHandleName:"editor/getSessFileHandleName",checkSessFileHandleValidity:"editor/checkSessFileHandleValidity"})},methods:{...Object(a["d"])({UPDATE_SESSION:"querySession/UPDATE_SESSION",SET_BLOB_FILE:"editor/SET_BLOB_FILE"}),async verifyWritePriv(e){const t={writable:!0,mode:"readwrite"};return"granted"===await e.queryPermission(t)||"granted"===await e.requestPermission(t)},async writeFile({fileHandle:e,contents:t}){if(e.createWriter){const s=await e.createWriter();return await s.write(0,t),void await s.close()}const s=await e.createWritable();await s.write(t),await s.close()},async getNewFileHandle(e){try{return"showSaveFilePicker"in window?await window.showSaveFilePicker({suggestedName:e}):await window.chooseFileSystemEntries({suggestedName:e,type:"save-file"})}catch(t){"AbortError"===!t.name&&this.$logger("mixins-saveFile-getNewFileHandle").error("An error occurred trying to open the file.")}},saveFileLegacy(e){const{id:t,query_txt:s,name:a}=e;let n=document.createElement("a");const r=this.getSessFileHandleName(e)||a+".sql";n.href="data:application/text;charset=utf-8,"+encodeURIComponent(s),n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n),this.SET_BLOB_FILE({payload:{...e.blob_file,txt:s},id:t})},async saveFileAs(e){let t=e.name;this.checkSessFileHandleValidity(e)||(t+=".sql");const s=await this.getNewFileHandle(t);try{await this.writeFile({fileHandle:s,contents:e.query_txt}),this.UPDATE_SESSION({...e,name:s.name}),this.SET_BLOB_FILE({payload:{file_handle:s,txt:e.query_txt},id:e.id})}catch(a){this.$logger("mixins-saveFile-saveFileAs").error("Unable to write file")}},async handleSaveFileAs(e){this.hasFileSystemRWAccess?await this.saveFileAs(e):this.saveFileLegacy(e)},async saveFileToDisk(e){try{const t=this.getSessFileHandle(e),s=await this.verifyWritePriv(t);s&&(await this.writeFile({fileHandle:t,contents:e.query_txt}),this.SET_BLOB_FILE({payload:{file_handle:t,txt:e.query_txt},id:e.id}))}catch(t){this.$logger("mixins-saveFile-saveFileToDisk").error(t)}},async handleSaveFile(e){this.hasFileSystemRWAccess&&this.checkSessFileHandleValidity(e)?await this.saveFileToDisk(e):await this.handleSaveFileAs(e)}}}}}]);
Coded by KALI :v Greetz to DR HARD ../ kali.zbi@hotmail.com