@wdslib/go-utils 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"axios";import t from"lodash";import r from"crypto-js";var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((n=n.apply(e,t||[])).next())}))}function a(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var s=3e4,c=3e4,u=function(t,r){void 0===t&&(t="");var n=e.create({baseURL:t,timeout:s,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return n.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),n.interceptors.response.use((function(e){return 200===e.status||e.data.code,r&&r(e),e.data}),(function(e){return r&&r(null==e?void 0:e.response),Promise.reject(e.response)})),n};var d=function(e){if("string"==typeof e)try{var t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},l=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];n.code&&(n.code=n.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))}},v=function(e,t){e instanceof Map?e.forEach((function(e){t([e])})):Array.isArray(e)&&e.forEach((function(e){t(e.children)}))},f=function(e,t){var r=function(e){var n,o,a;if(e)for(var i=0,s=e;i<s.length;i++){var c=s[i],u=null===(a=null===(o=null===(n=null==c?void 0:c.tmpData)||void 0===n?void 0:n.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==u?void 0:u.length)&&l(u),t(c),c.children?r(c.children):c.dynamicChildren?v(c.dynamicChildren,r):c.stateChildren&&r(c.stateChildren)}};r(e)},p=function(e,t,r){if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!r)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(r)||e[t].push(r)},h=function(e,t,r){var n,o=!1,a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(var i=0,s=a.data;i<s.length;i++){var c=s[i];if((null==c?void 0:c.dependVars)&&c.dependVars.includes(e))return!0}var u=null==t?void 0:t[null==t?void 0:t.type];return((null==u?void 0:u.inputSql)||(null==u?void 0:u.url)||(null==u?void 0:u.headers)||(null==u?void 0:u.params))&&(o=function(e,t,r,n){var o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o)for(var a=function(e){return!e||!t||t.findIndex((function(t){return t.mapField===e}))<0?"continue":(r&&n&&p(n,e,r.cid),{value:!0})},i=0,s=o.map((function(e){return e.replace(/{{|}}|@/gm,"")}));i<s.length;i++){var c=a(s[i]);if("object"==typeof c)return c.value}return!1}(u.inputSql||u.url||(null===(n=u.headers)||void 0===n?void 0:n.value)||u.params,r)),o},m="anov@2019:helloX",y="anov@2020:helloX";function g(e){var t=r.enc.Utf8.parse(m),n=r.enc.Utf8.parse(y);return r.AES.encrypt(e,t,{iv:n,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}var w,b,S,E=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),D=URL.createObjectURL(E);function T(e,t){return void 0===t&&(t=5e3),o(this,void 0,void 0,(function(){var r;return a(this,(function(n){return r=new Worker(D),[2,new Promise((function(n,o){var a=function(){clearTimeout(s),r.removeEventListener("message",i),r.terminate(),r=null},i=function(e){var t=e.data,r=t.code,i=t.result,s=t.err;a(),1===r?n(i):o(s)};r.postMessage({code:e}),r.addEventListener("message",i);var s=setTimeout((function(){a(),o("timeout")}),t)}))]}))}))}function k(e,t,r,n){return void 0===r&&(r={}),void 0===n&&(n="worker"),o(this,void 0,void 0,(function(){var o,s,c,u,d,l,v,f,p;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),"window"!=n?[3,1]:(s=(o=[["data"],[t]])[0],c=o[1],"object"==typeof r&&Object.keys(r).forEach((function(e){s.push(e),c.push(r[e])})),u=new(Function.bind.apply(Function,i(i([void 0],s,!1),[e],!1))),[2,{success:!0,data:u.apply(void 0,c)}]);case 1:return v=(d=[t,r,""])[1],f=d[2],"object"==typeof(l=d[0])&&(l=JSON.stringify(t)),"object"==typeof r&&(v=JSON.stringify(r)),Object.keys(r).forEach((function(e){return f+="".concat(e,",")})),p="let data=eval(".concat(l,"); \n             let app=").concat(JSON.stringify({}),";"),p+=f?"let {".concat(f,"} = eval(").concat(v,"); "):"",[4,T(p+="".concat(e))];case 2:return[2,{success:!0,data:a.sent()}];case 3:return[3,5];case 4:return[2,{success:!1,error:a.sent(),data:t}];case 5:return[2]}}))}))}!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(w||(w={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(b||(b={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(S||(S={}));var O=function(e,t){return"string"!=typeof e?Promise.reject(new Error("URL should be a string")):u(e,t)},j=u(),N=u();function C(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,j(e)];case 1:return[2,{code:2e4,data:r.sent().data}];case 2:throw t=r.sent(),console.error("请求数据发生错误-Error:",t),t;case 3:return[2]}}))}))}function P(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,j({method:"get",url:e})];case 1:return[2,r.sent().data];case 2:throw t=r.sent(),console.error("JSON 数据请求:",t),t;case 3:return[2]}}))}))}function q(e,r,n,i){return void 0===r&&(r="get"),void 0===n&&(n={}),void 0===i&&(i={}),o(this,void 0,void 0,(function(){var o;return a(this,(function(a){try{return o={method:S[r],url:e,headers:i,timeout:c},["post","put"].includes(r.toLowerCase())?o.data=t.cloneDeep(n):o.params=t.cloneDeep(n),[2,/.json$/.test(e)?P(e):C(o)]}catch(e){throw console.error("获取数据:Error:",e),e}return[2]}))}))}function I(e,t,r,n){return o(this,void 0,void 0,(function(){var o,i,s,c,u;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),o=window.anUrl||"",i=window.agentPath||"/ds/v1/api-proxy/v1/query",s=o+i,l=r,void 0===(v=!0)&&(v=!1),c=v?d(l)?l:JSON.stringify(l):d(l)?JSON.parse(l):l,[4,j({url:s,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?c:void 0,headers:d(n)?JSON.parse(n):n,method:e,url:t}})];case 1:return[2,a.sent()];case 2:throw u=a.sent(),console.error("代理请求数据:Error:",u),u;case 3:return[2]}var l,v}))}))}function x(e,t,r,n,i){return o(this,void 0,void 0,(function(){return a(this,(function(o){return[2,i?I(t,e,r,n):q(e,t,r,n)]}))}))}function F(e,t,r){var n,o,a;void 0===t&&(t="");var i=null!==(o=null===(n=null===window||void 0===window?void 0:window.BaseUrl)||void 0===n?void 0:n.replace("/management",""))&&void 0!==o?o:"",c=X("YZH_EXCHANGE_TOKEN")||(null===(a=null===window||void 0===window?void 0:window.yzhAuth)||void 0===a?void 0:a.getToken()),u=null===window||void 0===window?void 0:window.gdPassid,d=null===window||void 0===window?void 0:window.BASE_RELEASE,l="token=".concat(c,"&passid=").concat(u),v=d?"&preview=1":"",f="".concat(i,"/ds/data-engine/v1/").concat(e,"/zb-query?").concat(l).concat(v),p={};try{p=t?JSON.parse(t):{}}catch(e){p=t||{}}return j({method:"POST",url:f,data:{headers:r,param:p},timeout:s})}var U=function(e,t){return o(void 0,void 0,void 0,(function(){var r,n,o,i,c,u,d,l,v,f;return a(this,(function(a){return r=window.BaseUrl,n=t.dateType,o=void 0===n?"":n,i=t.endPeriod,c=void 0===i?"":i,u=t.metricsName,d=void 0===u?e:u,l=t.startPeriod,v=void 0===l?"":l,f="".concat(r,"ds/v1/metrics/v1/data-alarm?dateType=").concat(o,"&endPeriod=").concat(c,"&metricsName=").concat(d,"&startPeriod=").concat(v),[2,N({method:"GET",url:f,timeout:s})]}))}))},A=function(e,t,r){return o(void 0,void 0,void 0,(function(){var o,i,c,u;return a(this,(function(a){if(o=(null===(u=window.BaseUrl)||void 0===u?void 0:u.replace("/management",""))||"",t.newEncryption=!0,i={staticFile:{method:"get",params:t,url:"".concat(o,"/ds/v1/file/v1/").concat(e,"/query")},datasource:{method:"post",url:"".concat(o,"/ds/v1/database/v1/").concat(e,"/query"),data:n({},t)}},!(c=i[r]))throw new Error("Invalid data type provided");return[2,j(n({timeout:s},c))]}))}))},z=function(e){return new Promise((function(t,r){var n;void 0!==(n=e.originData&&Object.keys(e.originData).length?e.originData:e.data)?t({data:n}):r("Failed to retrieve cdata")}))},J=function(e,t,r){try{switch(t){case"api":var n=G(e,r);return{requestType:n.requestType,url:n.url,params:n.params,headers:n.headers,agency:n.agency};case"static":return{data:e};case"datasource":var o=Q(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:g(o),filter:e.sqlFilter};case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:e.params,headers:e.headers};case"indicatorCQ":return{zbName:e.zbName,params:e.params};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},L=function(e,t){return o(void 0,void 0,void 0,(function(){var r,n;return a(this,(function(o){switch(o.label){case 0:switch(o.trys.push([0,16,,18]),t){case"api":return[3,1];case"static":return[3,3];case"datasource":return[3,5];case"staticFile":return[3,7];case"indicator":return[3,9];case"indicatorCQ":return[3,11];case"packData":return[3,13]}return[3,14];case 1:return[4,x(e.url,e.requestType,e.params,e.headers,e.agency)];case 2:case 4:case 6:case 8:case 10:case 17:return[2,o.sent()];case 3:return[4,z(e.data)];case 5:return[4,A(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource")];case 7:return[4,A(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile")];case 9:return[4,F(e.zbId,e.params,e.headers)];case 11:return[4,U(e.zbName,e.params)];case 12:return r=o.sent(),console.log(r,12222),[2,r];case 13:return[2,{}];case 14:throw new Error("Invalid type");case 15:return[3,18];case 16:return n=o.sent(),console.warn(n,"执行请求并获取数据发生错误","requestData:"+e),[4,new Promise((function(e,t){e({error:!0})}))];case 18:return[2]}}))}))},R=function(e,t,r,n,i){return void 0===n&&(n=[]),void 0===i&&(i=!1),o(void 0,void 0,void 0,(function(){var o,s,c,u,d,l,v,f;return a(this,(function(a){switch(a.label){case 0:return o=t||e.tmpData.source.dataType,s=e.tmpData.source["indicatorCQ"==o?"indicator":o],"globalData"!==o?[3,3]:(c=n.find((function(e){return e.key===s.id||e.key===s.key})),u=function(e){var t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error("Error parsing session data for key ".concat(e,":"),t)}return null}(s.id),u&&!i?[2,u.data]:c?[4,_(c,r)]:[3,2]);case 1:return d=a.sent(),l={key:s.id,data:d},function(e,t){try{var r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error("Error setting session data for key ".concat(e,":"),t)}}(s.id,l),[2,d];case 2:return[2];case 3:return v=J(s,o,r),[4,L(v,o)];case 4:return[2,(null==(f=a.sent())?void 0:f.data)?f.data:f]}}))}))},_=function(e,t){return o(void 0,void 0,void 0,(function(){var r,n,o,i,s;return a(this,(function(a){switch(a.label){case 0:return r=Object.assign({},{tmpData:{source:e.value}}),n=r.tmpData.source.type,o=r.tmpData.source[n],i=J(o,n,t),[4,L(i,n)];case 1:return s=a.sent(),[4,B(s.data,r,!0,t)];case 2:return[2,a.sent()]}}))}))},B=function(e,r,n,i){return void 0===n&&(n=!0),o(void 0,void 0,void 0,(function(){var s,c,u;return a(this,(function(d){switch(d.label){case 0:return d.trys.push([0,5,,7]),s=r.tmpData.source,c=s.converse,s.mapFields,c&&c.use&&n?[4,new Promise((function(r,n){var s=function(e,r,n,i,s){return o(this,void 0,void 0,(function(){var n,o,s,c,u,d,l;return a(this,(function(v){switch(v.label){case 0:if(n=e,o=t.cloneDeep(r),s=o.use,c=o.data,!s)return[3,4];d=function(e){var r,o;return a(this,(function(a){switch(a.label){case 0:return c[e].use?(r=c[e].dependVars,o={},i&&o&&r&&r.length&&r.map((function(e){var r=t.cloneDeep(i).filter((function(t){var r=t.mapField==e;return r&&(o[e]=t.value),r}));r&&0!=r.length||(o[e]="")})),[4,k(c[e].code,n,o,c[e].mode?c[e].mode:"worker")]):[3,2];case 1:u=a.sent(),n=u.data,a.label=2;case 2:return[2]}}))},l=0,v.label=1;case 1:return l<c.length?[5,d(l)]:[3,4];case 2:v.sent(),v.label=3;case 3:return l++,[3,1];case 4:return[2,n]}}))}))}(e,c,0,i);r(s)}))]:[3,2];case 1:case 3:case 6:return[2,d.sent()];case 2:return[4,new Promise((function(t,r){t(e)}))];case 4:return[3,7];case 5:return u=d.sent(),console.error("执行过滤器发生错误:"+u),[4,new Promise((function(t,r){t(e)}))];case 7:return[2]}}))}))},M=function(e,t,r){var n=e.tmpData.source,o=n.type;r?("static"===o&&n[o]&&(n[o].originData=r),"indicatorCQ"===o?n.indicator.data=t:n[o].data=t):"indicatorCQ"===o?n.indicator.data=t:n[o].data=t,e.source=t},V=function(e,t,r,n,i,s){return void 0===r&&(r=[]),o(void 0,void 0,void 0,(function(){var o,c,u,d;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),o=e.tmpData.source.type,[4,R(e,o,r,n,s||!1)];case 1:return null!=(c=a.sent())&&c?[4,B(c,e,t,r)]:(i&&i({error:!0}),[2,Promise.resolve({error:!0})]);case 2:return u=a.sent(),M(e,u),i&&i(u),[2,Promise.resolve(u)];case 3:return d=a.sent(),i&&i(d),console.error("Error in updateComData:",d),[2,Promise.reject(d)];case 4:return[2]}}))}))},X=function(e){var t={};if(e&&e.includes("?"))for(var r=0,n=e.split("?")[1].split("&");r<n.length;r++){var o=n[r].split("=").map(decodeURIComponent),a=o[0],i=o[1];t[a]=i}return t},Q=function(e,t){if(!t)return e;if("string"==typeof e)return""===e.trim()?"":e.replace(/@(\w+)|{{(\w+)}}/g,(function(e,r,n){var o=r||n,a=t.find((function(e){return e.mapField===o}));return a?a.value||a.originalValue||"":e}));if(Array.isArray(e))return e.map((function(e){return Q(e,t)}));if("object"==typeof e&&null!==e){var r={};for(var n in e)r[n]=Q(e[n],t);return r}return e},G=function(e,t){var r=e.agency,n=e,o=n.url,a=void 0===o?null:o,i=n.headers,s=n.params,c=n.requestType,u=a?Q(a,t):void 0,d=i&&i.use?Q(i.value,t):{};return{url:u,requestType:c,params:s?Q(s,t):{},headers:d,agency:r}},H=function(e,t,r,n,i){return o(void 0,void 0,void 0,(function(){var o,s,c,u;return a(this,(function(d){switch(d.label){case 0:if(!e||!e.length)return[2];o=function(o){return a(this,(function(a){switch(a.label){case 0:return h(t,o.value,r)?[4,V({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,r,e,(function(e){console.log("数据更新成功-变量改变全局数据跟新")}),!0)]:[3,2];case 1:a.sent(),f(n,(function(t){var n,a,s;"globalData"===(null===(a=null===(n=null==t?void 0:t.tmpData)||void 0===n?void 0:n.source)||void 0===a?void 0:a.type)&&((null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===o.key&&V(t,!0,r,e,(function(e){i(t,e)}),!1))})),a.label=2;case 2:return[2]}}))},s=0,c=e,d.label=1;case 1:return s<c.length?(u=c[s],[5,o(u)]):[3,4];case 2:d.sent(),d.label=3;case 3:return s++,[3,1];case 4:return[2]}}))}))},K=function(e,t,r,n,i){return o(void 0,void 0,void 0,(function(){return a(this,(function(o){switch(o.label){case 0:return e?[4,V({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,r,(function(e){console.log("数据更新成功-数据源编辑")}),!0)]:[2];case 1:return o.sent(),f(n,(function(n){var o,a,s;"globalData"===(null===(a=null===(o=null==n?void 0:n.tmpData)||void 0===o?void 0:o.source)||void 0===a?void 0:a.type)&&((null===(s=null==n?void 0:n.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&V(n,!0,t,r,(function(e){i(n,e)}),!1))})),[2]}}))}))};export{O as Http,I as agentData,M as editItem,_ as fetchDataByGlobal,R as fetchDataByType,B as filterData,q as getData,x as getDataForApi,A as getDataForSource,z as getDataForStatic,F as getDataForZb,U as getDataForZbCQ,H as updataGlobalDataSourceForVar,V as updateComData,K as updateGlobalDataSource};
1
+ import e from"axios";import t from"lodash";import r from"crypto-js";var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,c)}s((n=n.apply(e,t||[])).next())}))}function a(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function i(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var c=5e3,s=5e3,u=function(t,r){void 0===t&&(t="");var n=e.create({baseURL:t,timeout:c,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return n.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),n.interceptors.response.use((function(e){return 200===e.status||e.data.code,r&&r(e),e.data}),(function(e){return r&&r(null==e?void 0:e.response),Promise.reject(e.response)})),n};function l(e,t){return void 0===t&&(t=!1),t?d(e)?e:JSON.stringify(e):d(e)?JSON.parse(e):e}var d=function(e){if("string"==typeof e)try{var t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},f=function(e,t){try{var r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error("Error setting session data for key ".concat(e,":"),t)}},v=function(e){var t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error("Error parsing session data for key ".concat(e,":"),t)}return null},p=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];n.code&&(n.code=n.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))}},h=function(e,t){e instanceof Map?e.forEach((function(e){t([e])})):Array.isArray(e)&&e.forEach((function(e){t(e.children)}))},m=function(e,t){var r=function(e){var n,o,a;if(e)for(var i=0,c=e;i<c.length;i++){var s=c[i],u=null===(a=null===(o=null===(n=null==s?void 0:s.tmpData)||void 0===n?void 0:n.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==u?void 0:u.length)&&p(u),t(s),s.children?r(s.children):s.dynamicChildren?h(s.dynamicChildren,r):s.stateChildren&&r(s.stateChildren)}};r(e)},g=function(e,t,r,n){var o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o)for(var a=function(e){return!e||!t||t.findIndex((function(t){return t.mapField===e}))<0?"continue":(r&&n&&y(n,e,r.cid),{value:!0})},i=0,c=o.map((function(e){return e.replace(/{{|}}|@/gm,"")}));i<c.length;i++){var s=a(c[i]);if("object"==typeof s)return s.value}return!1},y=function(e,t,r){if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!r)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(r)||e[t].push(r)},b=function(e,t,r){var n,o=!1,a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(var i=0,c=a.data;i<c.length;i++){var s=c[i];if((null==s?void 0:s.dependVars)&&s.dependVars.includes(e))return!0}var u=null==t?void 0:t[null==t?void 0:t.type];return((null==u?void 0:u.inputSql)||(null==u?void 0:u.url)||(null==u?void 0:u.headers)||(null==u?void 0:u.params))&&(o=g(u.inputSql||u.url||(null===(n=u.headers)||void 0===n?void 0:n.value)||u.params,r)),o},w=function(e,r,n){void 0===n&&(n=!1);var o=null,a=function(e){for(var i=0,c=e;i<c.length;i++){var s=c[i];if(s.cid===r){o=s,n&&t.remove(e,(function(e){return e.cid===r}));break}if(s.children&&a(s.children),s.dynamicChildren&&Array.isArray(s.dynamicChildren))for(var u=0,l=Array.from(s.dynamicChildren);u<l.length;u++){var d=l[u][1];a(d)}s.stateChildren&&a(s.stateChildren)}};return a(e),o},k=function(e,r,n){var o=!1,a=function(e){for(var i=0;i<e.length;i++){if(e[i].cid==r){o=e[i],n&&t.remove(e,(function(e){return e.cid==r}));break}if(e[i].children)a(e[i].children);else if(e[i].dynamicChildren){if(e[i].dynamicChildren instanceof Map){for(var c=Array.from(e[i].dynamicChildren),s=0;s<c.length;s++)if(c[s]instanceof Array){var u=c[s][1];a(u)}}else if(e[i].dynamicChildren instanceof Array)for(c=e[i].dynamicChildren,s=0;s<c.length;s++)if(c[s]instanceof Array){u=c[s][1];a(u)}}else e[i].stateChildren&&a(e[i].stateChildren)}};return a(e),o||!1};function V(e,t,r){var n={};r&&r.forEach((function(e){(null==e?void 0:e.name)&&(n[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,n)}catch(e){return console.error(e),t}}function E(e,t){try{return console.log(e,t,"1222"),new Function("data",e)(t)}catch(e){return console.error(e),t}}var F="anov@2019:helloX",N="anov@2020:helloX";function C(e){var t=r.enc.Utf8.parse(F),n=r.enc.Utf8.parse(N);return r.AES.encrypt(e,t,{iv:n,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}var O,A,D,S=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),I=URL.createObjectURL(S);function T(e,t){return void 0===t&&(t=5e3),o(this,void 0,void 0,(function(){var r;return a(this,(function(n){return r=new Worker(I),[2,new Promise((function(n,o){var a=function(){clearTimeout(c),r.removeEventListener("message",i),r.terminate(),r=null},i=function(e){var t=e.data,r=t.code,i=t.result,c=t.err;a(),1===r?n(i):o(c)};r.postMessage({code:e}),r.addEventListener("message",i);var c=setTimeout((function(){a(),o("timeout")}),t)}))]}))}))}function j(e,t,r,n){return void 0===r&&(r={}),void 0===n&&(n="worker"),o(this,void 0,void 0,(function(){var o,c,s,u,l,d,f,v,p;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),"window"!=n?[3,1]:(c=(o=[["data"],[t]])[0],s=o[1],"object"==typeof r&&Object.keys(r).forEach((function(e){c.push(e),s.push(r[e])})),u=new(Function.bind.apply(Function,i(i([void 0],c,!1),[e],!1))),[2,{success:!0,data:u.apply(void 0,s)}]);case 1:return f=(l=[t,r,""])[1],v=l[2],"object"==typeof(d=l[0])&&(d=JSON.stringify(t)),"object"==typeof r&&(f=JSON.stringify(r)),Object.keys(r).forEach((function(e){return v+="".concat(e,",")})),p="let data=eval(".concat(d,"); \n             let app=").concat(JSON.stringify({}),";"),p+=v?"let {".concat(v,"} = eval(").concat(f,"); "):"",[4,T(p+="".concat(e))];case 2:return[2,{success:!0,data:a.sent()}];case 3:return[3,5];case 4:return[2,{success:!1,error:a.sent(),data:t}];case 5:return[2]}}))}))}!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(O||(O={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(A||(A={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(D||(D={}));var P,x=function(){function e(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}return e.getInstance=function(t){return e.instance||(e.instance=new e(t)),e.instance},e.prototype.init=function(){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(t){return[2,new Promise((function(t,r){var n=indexedDB.open(e.dbName,1);n.onerror=function(e){r(e.target.error)},n.onupgradeneeded=function(t){e.db=t.target.result,e.db.objectStoreNames.contains(e.tableName)||e.db.createObjectStore(e.tableName,{keyPath:e.keyPath})},n.onsuccess=function(r){e.db=r.target.result,t()}}))]}))}))},e.prototype.addRecord=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(r){if(!this.db)throw new Error("数据库未初始化。");return[2,new Promise((function(r,n){var o=t.db.transaction([t.tableName],"readwrite").objectStore(t.tableName).add(e);o.onsuccess=function(){r()},o.onerror=function(e){n(e.target.error)}}))]}))}))},e.prototype.deleteRecord=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(r){if(!this.db)throw new Error("数据库未初始化。");return[2,new Promise((function(r,n){var o=t.db.transaction([t.tableName],"readwrite").objectStore(t.tableName).delete(e);o.onsuccess=function(){r()},o.onerror=function(e){n(e.target.error)}}))]}))}))},e.prototype.updateRecord=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(r){if(!this.db)throw new Error("数据库未初始化。");return[2,new Promise((function(r,n){var o=t.db.transaction([t.tableName],"readwrite").objectStore(t.tableName).put(e);o.onsuccess=function(){r()},o.onerror=function(e){n(e.target.error)}}))]}))}))},e.prototype.getRecord=function(e){return o(this,void 0,void 0,(function(){var t=this;return a(this,(function(r){if(!this.db)throw new Error("数据库未初始化。");return[2,new Promise((function(r,n){var o=t.db.transaction([t.tableName],"readonly").objectStore(t.tableName).get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e.target.error)}}))]}))}))},e.prototype.getAllRecords=function(){return o(this,void 0,void 0,(function(){var e=this;return a(this,(function(t){if(!this.db)throw new Error("数据库未初始化。");return[2,new Promise((function(t,r){var n=e.db.transaction([e.tableName],"readonly").objectStore(e.tableName).getAll();n.onsuccess=function(){t(n.result)},n.onerror=function(e){r(e.target.error)}}))]}))}))},e.instance=null,e}();!function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(P||(P={}));var R={databaseName:"GODB",tableName:"go-log",keyPath:"time"},q=function(){function e(){this.logLevel=P.INFO,this.indexedDBInstance=x.getInstance(R);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.setLogLevel=function(e){this.logLevel=e},e.prototype.getColor=function(e){switch(e){case P.FATAL:return"";case P.ERROR:return"";case P.WARN:return"";case P.INFO:return"";case P.DEBUG:return"";case P.TRACE:return"";default:return""}},e.prototype.log=function(e,t){if(t<=this.logLevel){var r=(new Date).toISOString(),n="[".concat(r,"] [").concat(P[t],"]"),o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log("".concat(o).concat(n," ").concat(e,""));else{var a=v("anov-go-userInfo"),i=v("anov-go-proid"),c=" [操作人:".concat(null==a?void 0:a.userName," 项目ID:").concat(i,"] "),s={time:r,value:"".concat(e)};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log("".concat(o).concat(n," ").concat(c," ").concat(e,""))}}},e.prototype.fatal=function(e){this.log(e,P.FATAL)},e.prototype.error=function(e){this.log(e,P.ERROR)},e.prototype.warn=function(e){this.log(e,P.WARN)},e.prototype.info=function(e){this.log(e,P.INFO)},e.prototype.debug=function(e){this.log(e,P.DEBUG)},e.prototype.trace=function(e){this.log(e,P.TRACE)},e}().getInstance(),U=function(e,t){return"string"!=typeof e?Promise.reject(new Error("URL should be a string")):u(e,t)},L=u(),B=u();function G(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,L(e)];case 1:return[2,{code:2e4,data:r.sent().data}];case 2:throw t=r.sent(),console.error("请求数据发生错误-Error:",t),t;case 3:return[2]}}))}))}function z(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,L({method:"get",url:e})];case 1:return[2,r.sent().data];case 2:throw t=r.sent(),console.error("JSON 数据请求:",t),t;case 3:return[2]}}))}))}function J(e,r,n,i){return void 0===r&&(r="get"),void 0===n&&(n={}),void 0===i&&(i={}),o(this,void 0,void 0,(function(){var o;return a(this,(function(a){try{return o={method:D[r],url:e,headers:i,timeout:s},["post","put"].includes(r.toLowerCase())?o.data=t.cloneDeep(n):o.params=t.cloneDeep(n),[2,/.json$/.test(e)?z(e):G(o)]}catch(e){throw console.error("获取数据:Error:",e),e}return[2]}))}))}function M(e,t,r,n){return o(this,void 0,void 0,(function(){var o,i,c,s,u;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),o=window.anUrl||"",i=window.agentPath||"/ds/v1/api-proxy/v1/query",c=o+i,s=l(r,!0),[4,L({url:c,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?s:void 0,headers:d(n)?JSON.parse(n):n,method:e,url:t}})];case 1:return[2,a.sent()];case 2:throw u=a.sent(),console.error("代理请求数据:Error:",u),u;case 3:return[2]}}))}))}function _(e,t,r,n,i){return o(this,void 0,void 0,(function(){return a(this,(function(o){return[2,i?M(t,e,r,n):J(e,t,r,n)]}))}))}function X(e,t,r){var n,o,a;void 0===t&&(t="");var i=null!==(o=null===(n=null===window||void 0===window?void 0:window.BaseUrl)||void 0===n?void 0:n.replace("/management",""))&&void 0!==o?o:"",s=ne("YZH_EXCHANGE_TOKEN")||(null===(a=null===window||void 0===window?void 0:window.yzhAuth)||void 0===a?void 0:a.getToken()),u=null===window||void 0===window?void 0:window.gdPassid,l=null===window||void 0===window?void 0:window.BASE_RELEASE,d="token=".concat(s,"&passid=").concat(u),f=l?"&preview=1":"",v="".concat(i,"/ds/data-engine/v1/").concat(e,"/zb-query?").concat(d).concat(f),p={};try{p=t?JSON.parse(t):{}}catch(e){p=t||{}}return L({method:"POST",url:v,data:{headers:r,param:p},timeout:c})}var Q=function(e,t){return o(void 0,void 0,void 0,(function(){var r,n,o,i,s,u,l,d,f,v;return a(this,(function(a){return r=window.BaseUrl,n=t.dateType,o=void 0===n?"":n,i=t.endPeriod,s=void 0===i?"":i,u=t.metricsName,l=void 0===u?e:u,d=t.startPeriod,f=void 0===d?"":d,v="".concat(r,"ds/v1/metrics/v1/data-alarm?dateType=").concat(o,"&endPeriod=").concat(s,"&metricsName=").concat(l,"&startPeriod=").concat(f),[2,B({method:"GET",url:v,timeout:c})]}))}))},W=function(e,t,r){return o(void 0,void 0,void 0,(function(){var o,i,s,u;return a(this,(function(a){if(o=(null===(u=window.BaseUrl)||void 0===u?void 0:u.replace("/management",""))||"",t.newEncryption=!0,i={staticFile:{method:"get",params:t,url:"".concat(o,"/ds/v1/file/v1/").concat(e,"/query")},datasource:{method:"post",url:"".concat(o,"/ds/v1/database/v1/").concat(e,"/query"),data:n({},t)}},!(s=i[r]))throw new Error("Invalid data type provided");return[2,L(n({timeout:c},s))]}))}))},H=function(e){return new Promise((function(t,r){var n;void 0!==(n=e.originData&&Object.keys(e.originData).length?e.originData:e.data)?t({data:n}):r("Failed to retrieve cdata")}))},K=function(e,t,r){try{switch(t){case"api":var n=ae(e,r);return{requestType:n.requestType,url:n.url,params:n.params,headers:n.headers,agency:n.agency};case"static":return{data:e};case"datasource":var o=oe(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:C(o),filter:e.sqlFilter};case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:e.params,headers:e.headers};case"indicatorCQ":return{zbName:e.zbName,params:e.params};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},Y=function(e,t){return o(void 0,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:switch(n.trys.push([0,16,,18]),t){case"api":return[3,1];case"static":return[3,3];case"datasource":return[3,5];case"staticFile":return[3,7];case"indicator":return[3,9];case"indicatorCQ":return[3,11];case"packData":return[3,13]}return[3,14];case 1:return[4,_(e.url,e.requestType,e.params,e.headers,e.agency)];case 2:case 4:case 6:case 8:case 10:case 17:return[2,n.sent()];case 3:return[4,H(e.data)];case 5:return[4,W(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource")];case 7:return[4,W(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile")];case 9:return[4,X(e.zbId,e.params,e.headers)];case 11:return[4,Q(e.zbName,e.params)];case 12:return[2,n.sent()];case 13:return[2,{}];case 14:throw new Error("Invalid type");case 15:return[3,18];case 16:return r=n.sent(),console.warn(r,"执行请求并获取数据发生错误"),[4,new Promise((function(e,t){e({error:!0})}))];case 18:return[2]}}))}))},Z=function(e,t,r,n,i){return void 0===n&&(n=[]),void 0===i&&(i=!1),o(void 0,void 0,void 0,(function(){var o,c,s,u,l,d,p,h;return a(this,(function(a){switch(a.label){case 0:return o=t||e.tmpData.source.dataType,c=e.tmpData.source["indicatorCQ"==o?"indicator":o],"globalData"!==o?[3,3]:(s=n.find((function(e){return e.key===c.id||e.key===c.key})),(u=v(c.id))&&!i?[2,u.data]:s?[4,$(s,r)]:[3,2]);case 1:return l=a.sent(),d={key:c.id,data:l},f(c.id,d),[2,l];case 2:return[2];case 3:return p=K(c,o,r),[4,Y(p,o)];case 4:return[2,(null==(h=a.sent())?void 0:h.data)?h.data:h]}}))}))},$=function(e,t){return o(void 0,void 0,void 0,(function(){var r,n,o,i,c;return a(this,(function(a){switch(a.label){case 0:return r=Object.assign({},{tmpData:{source:e.value}}),n=r.tmpData.source.type,o=r.tmpData.source[n],i=K(o,n,t),[4,Y(i,n)];case 1:return c=a.sent(),[4,ee(c.data,r,!0,t)];case 2:return[2,a.sent()]}}))}))},ee=function(e,r,n,i){return void 0===n&&(n=!0),o(void 0,void 0,void 0,(function(){var c,s,u;return a(this,(function(l){switch(l.label){case 0:return l.trys.push([0,5,,7]),c=r.tmpData.source,s=c.converse,c.mapFields,s&&s.use&&n?[4,new Promise((function(r,n){var c=function(e,r,n,i,c){return o(this,void 0,void 0,(function(){var n,o,c,s,u,l,d;return a(this,(function(f){switch(f.label){case 0:if(n=e,o=t.cloneDeep(r),c=o.use,s=o.data,!c)return[3,4];l=function(e){var r,o;return a(this,(function(a){switch(a.label){case 0:return s[e].use?(r=s[e].dependVars,o={},i&&o&&r&&r.length&&r.map((function(e){var r=t.cloneDeep(i).filter((function(t){var r=t.mapField==e;return r&&(o[e]=t.value),r}));r&&0!=r.length||(o[e]="")})),[4,j(s[e].code,n,o,s[e].mode?s[e].mode:"worker")]):[3,2];case 1:u=a.sent(),n=u.data,a.label=2;case 2:return[2]}}))},d=0,f.label=1;case 1:return d<s.length?[5,l(d)]:[3,4];case 2:f.sent(),f.label=3;case 3:return d++,[3,1];case 4:return[2,n]}}))}))}(e,s,0,i);r(c)}))]:[3,2];case 1:case 3:case 6:return[2,l.sent()];case 2:return[4,new Promise((function(t,r){t(e)}))];case 4:return[3,7];case 5:return u=l.sent(),console.error("执行过滤器发生错误:"+u),[4,new Promise((function(t,r){t(e)}))];case 7:return[2]}}))}))},te=function(e,t,r){var n=e.tmpData.source,o=n.type;r?("static"===o&&n[o]&&(n[o].originData=r),"indicatorCQ"===o?n.indicator.data=t:n[o].data=t):"indicatorCQ"===o?n.indicator.data=t:n[o].data=t,e.source=t},re=function(e,t,r,n,i,c){return void 0===r&&(r=[]),o(void 0,void 0,void 0,(function(){var o,s,u,l;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),o=e.tmpData.source.type,[4,Z(e,o,r,n,c||!1)];case 1:return null!=(s=a.sent())&&s?[4,ee(s,e,t,r)]:(i&&i({error:!0}),[2,Promise.resolve({error:!0})]);case 2:return u=a.sent(),te(e,u),i&&i(u),[2,Promise.resolve(u)];case 3:return l=a.sent(),i&&i(l),q.error("Error in updateComData"),console.error("Error in updateComData:",l),[2,Promise.reject(l)];case 4:return[2]}}))}))},ne=function(e){var t={};if(e&&e.includes("?"))for(var r=0,n=e.split("?")[1].split("&");r<n.length;r++){var o=n[r].split("=").map(decodeURIComponent),a=o[0],i=o[1];t[a]=i}return t},oe=function(e,t){if(!t)return e;if("string"==typeof e)return""===e.trim()?"":e.replace(/@(\w+)|{{(\w+)}}/g,(function(e,r,n){var o=r||n,a=t.find((function(e){return e.mapField===o}));return a?a.value||a.originalValue||"":e}));if(Array.isArray(e))return e.map((function(e){return oe(e,t)}));if("object"==typeof e&&null!==e){var r={};for(var n in e)r[n]=oe(e[n],t);return r}return e},ae=function(e,t){var r=e.agency,n=e,o=n.url,a=void 0===o?null:o,i=n.headers,c=n.params,s=n.requestType,u=a?oe(a,t):void 0,l=i&&i.use?oe(i.value,t):{};return{url:u,requestType:s,params:c?oe(c,t):{},headers:l,agency:r}},ie=function(e,t,r,n,i){return o(void 0,void 0,void 0,(function(){var o,c,s,u;return a(this,(function(l){switch(l.label){case 0:if(!e||!e.length)return[2];o=function(o){return a(this,(function(a){switch(a.label){case 0:return b(t,o.value,r)?[4,re({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,r,e,(function(e){console.log("数据更新成功-变量改变全局数据跟新")}),!0)]:[3,2];case 1:a.sent(),m(n,(function(t){var n,a,c;"globalData"===(null===(a=null===(n=null==t?void 0:t.tmpData)||void 0===n?void 0:n.source)||void 0===a?void 0:a.type)&&((null===(c=null==t?void 0:t.tmpData)||void 0===c?void 0:c.source.globalData).id===o.key&&re(t,!0,r,e,(function(e){i(t,e)}),!1))})),a.label=2;case 2:return[2]}}))},c=0,s=e,l.label=1;case 1:return c<s.length?(u=s[c],[5,o(u)]):[3,4];case 2:l.sent(),l.label=3;case 3:return c++,[3,1];case 4:return[2]}}))}))},ce=function(e,t,r,n,i){return o(void 0,void 0,void 0,(function(){return a(this,(function(o){switch(o.label){case 0:return e?[4,re({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,r,(function(e){console.log("数据更新成功-数据源编辑")}),!0)]:[2];case 1:return o.sent(),m(n,(function(n){var o,a,c;"globalData"===(null===(a=null===(o=null==n?void 0:n.tmpData)||void 0===o?void 0:o.source)||void 0===a?void 0:a.type)&&((null===(c=null==n?void 0:n.tmpData)||void 0===c?void 0:c.source.globalData).id===e.key&&re(n,!0,t,r,(function(e){i(n,e)}),!1))})),[2]}}))}))},se=function(e,t){return e.id===t&&!(null==e?void 0:e.forkValue)},ue=function(e,t){return Array.isArray(t)?t.some((function(t){return e&&(void 0!==e[t]||e.hasOwnProperty(t))})):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t)))},le=function(e,t,r,n){var o,a;if(ue(e,null==t?void 0:t.field)||ue(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(ue(e.data,null==t?void 0:t.field)||ue(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else for(var i=w(r,n),c=0,s=(null===(o=null==i?void 0:i.tmpData)||void 0===o?void 0:o.actions)||[];c<s.length;c++){var u=s[c].vars.find((function(e){return(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)}));if(u){a=u.value;break}}return a},de=function(e,t,r){e.value=t,e.converter&&e.converterCode?(e.originalValue=t,e.value=V(e.converterCode,t,r)):(e.originalValue=t,e.value=t)},fe=function(e,t,r,n,o,a,i,c,s){switch(e.type){case"link":window.open(e.link,e.target);break;case"page":s&&s(e);break;case"dynamic":!function(e,t,r,n,o){for(var a=0,i=e.dynamic||[];a<i.length;a++){var c=i[a];if(e.id===t.cid){var s=w(r,c.pid);s&&(s.activeDynamic=c.name,s.isShow=c.visible||!n||e.index===t.index-1,o({cid:s.cid,flag:c.visible}))}}}(e,t,r,n,o);break;case"toggle":!function(e,t,r,n,o){for(var a=0,i=e.children||[];a<i.length;a++){var c=i[a],s=c.visible&&(!n||e.index===t.index-1);o({cid:c.cid,flag:s})}}(e,t,0,n,o);break;case"update":!function(e,t,r,n,o){for(var a=function(e){var a=w(t,e.cid);a&&re(a,!0,r,n,(function(e){o({cid:a.cid,data:e})}))},i=0,c=e.children||[];i<c.length;i++)a(c[i])}(e,r,a,i,c)}},ve=function(e,r,n,o,a,i,c,s,u,l){var d=a.cid,f=a.actions,v=a.index,p=f.eventName,h=2===f.mode;!function(e,r,n,o,a,i,c,s){for(var u=[],l=0,d=e;l<d.length;l++){var f=d[l];if(se(f,a)&&f.type==r){var v=le(n,f,o,a),p=void 0!==v?v:f.value;de(f,p,e);for(var h=0,m=e;h<m.length;h++){var g=m[h];if(g.id!=a&&!(null==f?void 0:f.forkValue)&&g.mapField==f.mapField){var y=void 0!==v?v:g.value;de(g,y,e)}}u.push(f)}}for(var b=e.filter((function(e){return u&&(u.find((function(t){return t.mapField==e.mapField}))||u.find((function(t){return t.mapField==e.forkValue}))||u.find((function(t){return Array.isArray(e.forkValue)&&e.forkValue.includes(t.mapField)})))})),w=function(t){if(!i)return"break";var r=i[t.mapField]||[];if(t.fork)if(Array.isArray(t.forkValue))t.originalValue=t.forkValue.map((function(t){var r=e.find((function(e){return e.mapField==t}));if(r)return r.value}));else{var n=e.find((function(e){return e.mapField==t.forkValue}));n&&(t.originalValue=n.value)}t.converter&&t.converterCode?t.value=V(t.converterCode,t.originalValue,e):t.value=t.originalValue;var o=c.find((function(e){return e.mapField==t.mapField}));console.log(c,"gcItemgcItem"),o&&(t.converter&&t.converterCode?o.value=V(t.converterCode,t.originalValue,e):o.value=t.originalValue),s&&s(t,r)},k=0,E=b=t.uniqBy(b,"mapField");k<E.length&&"break"!==w(f=E[k]);k++);}(r,p,a,o,d,n,l,(function(e,t){if(ie(u,e.mapFile,r,o,(function(e,t){c({cid:e.cid,data:t})})),null==t?void 0:t.length)for(var n=function(t){e.eventSourceId=t;var n=w(o,t);!(null==e?void 0:e.delayUpdate)&&n&&re(n,!0,r,u,(function(e){c({cid:n.cid,data:e})}))},a=0,i=t;a<i.length;a++){n(i[a])}}));for(var m=function(e,t,r,n,o){return e.filter((function(e){return e.id===t&&e.eventType===r&&(!o||parseInt(e.index||"0")+1===parseInt(n||"0"))}))}(e,d,p,v,h),g=0,y=m;g<y.length;g++){var b=y[g];fe(b,a,o,h,i,r,u,c,s)}},pe=function(){function e(e,t){this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=e.model,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,t&&(this.globalVariables=t),e.fork&&(this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}return Object.defineProperty(e.prototype,"value",{get:function(){return this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode?E(this.converterCode,this.originalValue):this.originalValue},set:function(e){this.value=e},enumerable:!1,configurable:!0}),e.prototype.getForkedValue=function(){var e=this;if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((function(t){var r=e.globalVariables.get(t);return r?r.value:null}));if(this.forkValue){var t=this.globalVariables.get(this.forkValue);return t?t.value:null}return null},e.prototype.renew=function(e){e&&e(this)},e.prototype.updateValue=function(e,t){var r,n,o,a,i,c,s,u,l;this.des=null!==(r=e.des)&&void 0!==r?r:this.des,this.field=null!==(n=e.field)&&void 0!==n?n:this.field,this.mapping=null!==(o=e.mapping)&&void 0!==o?o:this.mapping,this.type=null!==(a=e.type)&&void 0!==a?a:this.type,this.originalValue=null!==(i=e.originalValue)&&void 0!==i?i:this.originalValue,this.converter=null!==(c=e.converter)&&void 0!==c?c:this.converter,this.converterCode=null!==(s=e.converterCode)&&void 0!==s?s:this.converterCode,this.fork=null!==(u=e.fork)&&void 0!==u?u:this.fork,e.fork&&(this.forkValue=null!==(l=e.forkValue)&&void 0!==l?l:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)},e.create=function(t,r){return new e(t,r)},e}(),he=function(){function e(){this.variables=new Map,this.globalObservers=[]}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.addVariables=function(e){var t=this;return Array.isArray(e)?e.map((function(e){return t.addVariable(e)})):[this.addVariable(e)]},e.prototype.addVariable=function(e,t){if(this.isVariableNameExist(e.mapField))throw new Error("Variable with key '".concat(e.mapField,"' already exists."));var r=pe.create(e,this.variables);return this.variables.set(r.mapField,r),t&&t(r),this.notifyGlobalObservers(r),r},e.prototype.editVariable=function(e,t){var r=this,n=this.getVariable(e.mapField);n?n.updateValue(e,(function(e){r.notifyGlobalObservers(e);var n=r.isMapFieldInForkValues(e.mapField);if(null==n?void 0:n.length)for(var o=0,a=n;o<a.length;o++){a[o].renew((function(e){r.notifyGlobalObservers(e)}))}t&&t(e)})):this.addVariable(e,t)},e.prototype.isMapFieldInForkValues=function(e){var t=this.getAllVariables();return console.log(t,"999999"),t.filter((function(e){return e.fork&&e.forkValue})).filter((function(t){return t.forkValue==e||Array.from(t.forkValue).includes(e)}))},e.prototype.isVariableNameExist=function(e){return this.variables.has(e)},e.prototype.getVariable=function(e){return this.variables.get(e)},e.prototype.getAllVariables=function(){return t.cloneDeep(Array.from(this.variables.values()))},e.prototype.restoreVariables=function(e){var t=this;e.forEach((function(e){t.addVariable(e)}))},e.prototype.registerGlobalObserver=function(e){this.globalObservers.push(e)},e.prototype.notifyGlobalObservers=function(e){this.globalObservers.forEach((function(t){t.update(e)}))},e.instance=null,e}(),me=he.getInstance();export{he as GlobalVariables,U as Http,q as Log,M as agentData,te as editItem,ve as emitEvent,$ as fetchDataByGlobal,Z as fetchDataByType,ee as filterData,w as findItemDeep,k as findItemDeep2,J as getData,_ as getDataForApi,W as getDataForSource,H as getDataForStatic,X as getDataForZb,Q as getDataForZbCQ,v as getSessionData,l as getStandardData,g as getStringVars,me as globalVars,b as hasVar,d as isJSON,m as recursion,V as safeEval,E as safeEvalForCode,f as setSessionData,ie as updataGlobalDataSourceForVar,re as updateComData,ce as updateGlobalDataSource};
@@ -1,4 +1,4 @@
1
- import { IndexedDBConfig, Record } from './type';
1
+ import { IndexedDBConfig, Record } from "./type";
2
2
  /**
3
3
  * IndexedDB 封装类,实现了初始化表、增加记录、删除记录、更新记录和查询记录的功能。
4
4
  * 采用单例模式确保全局只有一个实例。
@@ -0,0 +1 @@
1
+ export declare const changeVar: (globalVars: any, eventName: string, element: any, list: any, cid: string, shareVariableTree: any, globalConstant: any, callback: (mapFild: string, ids: any[]) => void) => void;
@@ -0,0 +1,52 @@
1
+ import { GlobalEvent, GlobalVar } from './type';
2
+ import { GlobalDataSourceItem, GoComponent } from '../fetchUtils/type';
3
+ export declare const filterCurrentEvent: (globalEvents: GlobalEvent[], cid: string, eventName: string, index: any, isMode2: boolean) => GlobalEvent[];
4
+ /**
5
+ * 处理 dynamic 类型事件
6
+ * @param {Object} item - dynamic 类型事件
7
+ * @param {GoComponent} element - 当前组件
8
+ * @param {Object} list - 组件列表
9
+ * @param {boolean} isMode2 - 是否为模式2
10
+ * @param {Function} changeShow - 更新组件显示状态的函数
11
+ */
12
+ export declare const handleDynamicEvent: (item: any, element: GoComponent, list: any, isMode2: boolean, changeShow: (props: {
13
+ cid: string;
14
+ flag: boolean;
15
+ }) => void) => void;
16
+ /**
17
+ * 处理 toggle 类型事件
18
+ * @param {Object} item - toggle 类型事件
19
+ * @param {GoComponent} element - 当前组件
20
+ * @param {Object} list - 组件列表
21
+ * @param {boolean} isMode2 - 是否为模式2
22
+ * @param {Function} changeShow - 更新组件显示状态的函数
23
+ */
24
+ export declare const handleToggleEvent: (item: any, element: GoComponent, list: any, isMode2: boolean, changeShow: (props: {
25
+ cid: string;
26
+ flag: boolean;
27
+ }) => void) => void;
28
+ /**
29
+ * 处理 update 类型事件
30
+ * @param {Object} item - update 类型事件
31
+ * @param {Object} list - 组件列表
32
+ * @param {GlobalVar[]} globalVars - 全局变量列表
33
+ * @param {GlobalDataSourceItem[]} globalSource - 全局数据源列表
34
+ * @param {Function} updataSourceForComponent - 更新组件数据的函数
35
+ */
36
+ export declare const handleUpdateEvent: (item: any, list: any, globalVars: GlobalVar[], globalSource?: GlobalDataSourceItem[], updataSourceForComponent?: any) => void;
37
+ /**
38
+ * 处理不同类型的事件
39
+ * @param {Object} item - 当前事件
40
+ * @param {GoComponent} element - 当前组件
41
+ * @param {Object} list - 组件列表
42
+ * @param {boolean} isMode2 - 是否为模式2
43
+ * @param {Function} changeShow - 更新组件显示状态的函数
44
+ * @param {Function} callback - 回调函数
45
+ * @param {GlobalVar[]} globalVars - 全局变量列表
46
+ * @param {GlobalDataSourceItem[]} globalSource - 全局数据源列表
47
+ * @param {Function} updataSourceForComponent - 更新组件数据的函数
48
+ */
49
+ export declare const handleEventType: (item: any, element: GoComponent, list: any, isMode2: boolean, changeShow: (props: {
50
+ cid: string;
51
+ flag: boolean;
52
+ }) => void, globalVars: GlobalVar[], globalSource?: GlobalDataSourceItem[], updataSourceForComponent?: any, callback?: any) => void;
@@ -0,0 +1,18 @@
1
+ import { GlobalEvent, GlobalVar } from './type';
2
+ import { GlobalDataSourceItem, GoComponent } from '../fetchUtils/type';
3
+ /**
4
+ * 触发并处理组件事件
5
+ * @param {GlobalEvent[]} globalEvents - 全局事件列表
6
+ * @param {GlobalVar[]} globalVars - 全局变量列表
7
+ * @param {Object} shareVariableTree - 共享变量树
8
+ * @param {Object} list - 组件列表
9
+ * @param {GoComponent} element - 当前组件
10
+ * @param {Function} changeShow - 更新组件显示状态的函数
11
+ * @param {Function} updataSourceForComponent - 更新组件数据的函数
12
+ * @param {Function} [callback] - 回调函数
13
+ * @param {GlobalDataSourceItem[]} [globalSource] - 全局数据源列表
14
+ */
15
+ export declare const emitEvent: (globalEvents: GlobalEvent[], globalVars: GlobalVar[], shareVariableTree: any, list: any, element: GoComponent, changeShow: (props: {
16
+ cid: string;
17
+ flag: boolean;
18
+ }) => void, updataSourceForComponent: any, callback?: any, globalSource?: GlobalDataSourceItem[], globalConstant?: any[]) => void;
@@ -0,0 +1,48 @@
1
+ export interface GlobalVar {
2
+ des: string;
3
+ key: number;
4
+ mapField: string;
5
+ mapping: string;
6
+ model: 2;
7
+ name: string;
8
+ value: any;
9
+ originalValue: any;
10
+ [prop: string]: any;
11
+ }
12
+ export interface EventData {
13
+ cid: string;
14
+ element: any;
15
+ globalVars: GlobalVar[];
16
+ list: any;
17
+ }
18
+ export interface EventHandler {
19
+ execute(): void;
20
+ }
21
+ interface EventChildren {
22
+ cid: string;
23
+ visible: boolean;
24
+ }
25
+ interface EventDynamic {
26
+ visible: true;
27
+ pid: string;
28
+ pname: string;
29
+ cid: string;
30
+ name: string;
31
+ }
32
+ interface EventParams {
33
+ field: string;
34
+ mapField: string;
35
+ value: any;
36
+ }
37
+ export interface GlobalEvent {
38
+ index: number;
39
+ eventType: string;
40
+ type: string;
41
+ id: string;
42
+ target?: string;
43
+ children?: EventChildren[];
44
+ dynamic?: EventDynamic[];
45
+ params?: EventParams[];
46
+ [prop: string]: any;
47
+ }
48
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare const ERR_OK = 200;
2
2
  export declare const ERR_OK2 = 20000;
3
- export declare const TIMEOUT = 30000;
4
- export declare const TIMEOUT2 = 30000;
3
+ export declare const TIMEOUT = 5000;
4
+ export declare const TIMEOUT2 = 5000;
5
5
  export declare const STATUS = "status";
@@ -116,7 +116,7 @@ export declare const updateComData: (element: GoComponent, filterFlag: boolean,
116
116
  * @param list - 待处理的组件列表
117
117
  * @param callback - 回调函数
118
118
  */
119
- export declare const updataGlobalDataSourceForVar: (globalSource: GlobalDataSourceItem[], mapField: string, globalVars: any[], list: any[], callback: CallbackFunction) => Promise<void>;
119
+ export declare const updataGlobalDataSourceForVar: (globalSource: GlobalDataSourceItem[] | undefined, mapField: string, globalVars: any[], list: any[], callback: CallbackFunction) => Promise<void>;
120
120
  /**
121
121
  * 更新全局数据源并更新引用该数据源的组件
122
122
  * @param {GlobalDataSourceItem} globalSourceItem - 全局数据源项
@@ -1,4 +1,4 @@
1
- import { CallbackFunction } from './type';
1
+ import { CallbackFunction } from "./type";
2
2
  /**
3
3
  * 数据引擎
4
4
  * @param baseURL 基础路径
@@ -0,0 +1,44 @@
1
+ type GlobalVariables = any;
2
+ type CallbackFunction = (result?: any) => void;
3
+ declare class BasicVariable {
4
+ des: string;
5
+ field: string;
6
+ id?: string;
7
+ key: string;
8
+ mapping?: string;
9
+ mapField: string;
10
+ type?: string;
11
+ originalValue: any;
12
+ model?: any;
13
+ converter?: boolean;
14
+ converterCode?: (data: any) => any;
15
+ fork?: boolean;
16
+ forkValue?: string | string[];
17
+ update?: boolean;
18
+ globalVariables: GlobalVariables;
19
+ constructor(params: BasicVariableParams, globalVariables: GlobalVariables);
20
+ get value(): any;
21
+ set value(val: any);
22
+ private getForkedValue;
23
+ renew(calback?: CallbackFunction): void;
24
+ updateValue(params: BasicVariableParams, callback?: (value: any) => void): void;
25
+ static create(params: BasicVariableParams, globalVariables: GlobalVariables): BasicVariable;
26
+ }
27
+ interface BasicVariableParams {
28
+ des: string;
29
+ field: string;
30
+ id?: string;
31
+ key: string;
32
+ mapping?: string;
33
+ mapField: string;
34
+ type?: string;
35
+ value: string;
36
+ originalValue: any;
37
+ model?: any;
38
+ converter?: boolean;
39
+ converterCode?: (data: any) => any | any;
40
+ fork?: boolean;
41
+ forkValue?: string | string[];
42
+ update?: boolean;
43
+ }
44
+ export { BasicVariable, BasicVariableParams };
@@ -0,0 +1,24 @@
1
+ import { BasicVariable, BasicVariableParams } from './BasicVariable';
2
+ type CallbackFunction = (result?: any) => void;
3
+ interface GlobalObserver {
4
+ update(variable: BasicVariable): void;
5
+ }
6
+ declare class GlobalVariables {
7
+ private static instance;
8
+ private variables;
9
+ private globalObservers;
10
+ private constructor();
11
+ static getInstance(): GlobalVariables;
12
+ addVariables(variablesData: BasicVariableParams[] | BasicVariableParams): BasicVariable[];
13
+ addVariable(variableData: BasicVariableParams, callback?: CallbackFunction): BasicVariable;
14
+ editVariable(variableData: BasicVariableParams, callback?: CallbackFunction): void;
15
+ isMapFieldInForkValues(mapField: string): BasicVariable[];
16
+ private isVariableNameExist;
17
+ getVariable(key: string): BasicVariable | undefined;
18
+ getAllVariables(): BasicVariable[];
19
+ restoreVariables(variablesData: BasicVariableParams[]): void;
20
+ registerGlobalObserver(observer: GlobalObserver): void;
21
+ private notifyGlobalObservers;
22
+ }
23
+ declare const globalVars: GlobalVariables;
24
+ export { GlobalVariables, GlobalObserver, globalVars };
@@ -1 +1,5 @@
1
- export * from './fetchUtils';
1
+ export * from "./fetchUtils";
2
+ export * from "./log";
3
+ export * from "./event";
4
+ export * from './tool';
5
+ export * from './globalVars';
@@ -0,0 +1,2 @@
1
+ import Logger from "./log";
2
+ export declare const Log: Logger;
@@ -1 +1,25 @@
1
- export {};
1
+ declare enum LogLevel {
2
+ FATAL = 0,
3
+ ERROR = 1,
4
+ WARN = 2,
5
+ INFO = 3,
6
+ DEBUG = 4,
7
+ TRACE = 5
8
+ }
9
+ declare class Logger {
10
+ private static instance;
11
+ private logLevel;
12
+ indexedDBInstance: any;
13
+ private constructor();
14
+ static getInstance(): Logger;
15
+ setLogLevel(level: LogLevel): void;
16
+ private getColor;
17
+ private log;
18
+ fatal(message: string): void;
19
+ error(message: string): void;
20
+ warn(message: string): void;
21
+ info(message: string): void;
22
+ debug(message: string): void;
23
+ trace(message: string): void;
24
+ }
25
+ export default Logger;
@@ -32,19 +32,44 @@ export declare const getSessionData: (key: string) => any;
32
32
  */
33
33
  export declare const recursion: (array: GoComponent[], callback: (args: any) => void) => void;
34
34
  /**
35
- * 处理字符串中的变量
36
- * @param url - 包含变量的字符串
37
- * @param globalVars - 全局变量
38
- * @param item - 可选项,用于特定情况下的处理
39
- * @param shareVariableTree - 可选项,用于特定情况下的处理
40
- * @returns 是否包含变量
41
- */
35
+ * 处理字符串中的变量
36
+ * @param url - 包含变量的字符串
37
+ * @param globalVars - 全局变量
38
+ * @param item - 可选项,用于特定情况下的处理
39
+ * @param shareVariableTree - 可选项,用于特定情况下的处理
40
+ * @returns 是否包含变量
41
+ */
42
42
  export declare const getStringVars: (url: string, globalVars: any, item?: any, shareVariableTree?: any) => boolean;
43
43
  /**
44
- * 判断数据源是否包含该变量
45
- * @param _varName - 变量名称
46
- * @param data - 数据
47
- * @param globalVars - 全局变量
48
- * @returns 是否包含变量
49
- */
44
+ * 判断数据源是否包含该变量
45
+ * @param _varName - 变量名称
46
+ * @param data - 数据
47
+ * @param globalVars - 全局变量
48
+ * @returns 是否包含变量
49
+ */
50
50
  export declare const hasVar: (_varName: string, data: any, globalVars: any) => boolean;
51
+ /**
52
+ * 查找组件树中某一个元素(递归)
53
+ * @param {Array<GoComponent>} array - 组件树
54
+ * @param {string | number} cid - 组件ID
55
+ * @param {boolean} del - 是否删除找到的元素
56
+ * @return {GoComponent | null} 返回选中的组件实例对象或者 null
57
+ */
58
+ export declare const findItemDeep: (array: GoComponent[], cid: string, del?: boolean) => GoComponent | null;
59
+ export declare const findItemDeep2: (array: GoComponent[], cid: string, del?: boolean) => any;
60
+ /**
61
+ * 安全执行 JavaScript 代码的函数
62
+ * @param {string} code - 待执行的 JavaScript 代码
63
+ * @param {any} params - 执行代码时的参数
64
+ * @param {any} globalVars - 执行代码时的变量
65
+ * @returns {any} - 执行结果或默认参数值
66
+ */
67
+ export declare function safeEval(code: string, params: any, globalVars?: any): any;
68
+ /**
69
+ * 安全执行 JavaScript 代码的函数
70
+ * @param {string} code - 待执行的 JavaScript 代码
71
+ * @param {any} params - 执行代码时的参数
72
+ * @param {any} globalVars - 执行代码时的变量
73
+ * @returns {any} - 执行结果或默认参数值
74
+ */
75
+ export declare function safeEvalForCode(code: string, params: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdslib/go-utils",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "go-core utils",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/types/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "serve": "rimraf dist && rollup -c -w",
15
15
  "lint": "eslint .",
16
16
  "format": "prettier --write .",
17
- "docs": "typedoc --out docs --theme default src"
17
+ "docs": "typedoc --out docs --theme default --tsconfig ./tsconfig.json src"
18
18
  },
19
19
  "keywords": [],
20
20
  "author": "ws880321",
@@ -42,6 +42,8 @@
42
42
  "@rollup/plugin-json": "^6.1.0",
43
43
  "@rollup/plugin-node-resolve": "^15.2.3",
44
44
  "axios": "^1.6.2",
45
+ "bunyan": "^1.8.15",
46
+ "chalk": "^5.3.0",
45
47
  "crypto-js": "^4.1.1",
46
48
  "lodash": "^4.17.21",
47
49
  "rollup-plugin-typescript": "^1.0.1",
@@ -1,8 +0,0 @@
1
- /**
2
- * 数据引擎
3
- * @param baseURL 基础路径
4
- * @param callback 回掉函数
5
- * @returns
6
- */
7
- declare const xhr: (baseURL?: string, callback?: Function) => import("axios").AxiosInstance;
8
- export default xhr;