@wdslib/go-utils 0.1.1
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 +1 -0
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/fetchUtils/config.d.ts +5 -0
- package/dist/types/fetchUtils/evaluator.d.ts +34 -0
- package/dist/types/fetchUtils/index.d.ts +110 -0
- package/dist/types/fetchUtils/type.d.ts +171 -0
- package/dist/types/fetchUtils/xhr.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/tool/index.d.ts +26 -0
- package/package.json +51 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"axios";import t from"lodash";import r from"crypto-js";function o(e,t,r,o){return new(r||(r=Promise))((function(n,a){function i(e){try{d(o.next(e))}catch(e){a(e)}}function s(e){try{d(o.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}d((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=200,a=2e4,i=3e4,s=3e4,d=t=>{const r=e.create({baseURL:t,timeout:i,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((e=>{var t;return["anov-go-token","unify-access-token","dgcc_authorization"].forEach((t=>{const r=sessionStorage.getItem(t);r&&"null"!==r&&(e.headers["dgcc_authorization"===t?"dgcc_authorization":`X-${t.toUpperCase()}`]=r)})),"post"===e.method&&(e.headers["Content-Type"]="application/json;"),["get","put","delete"].includes(e.method)&&(e.params=(t=e.params,Object.fromEntries(Object.entries(t).map((([e,t])=>[e,encodeURIComponent(t)]))))),"put"===e.method&&(e.headers["Content-Type"]="application/json; charset=UTF-8"),e}),(e=>Promise.reject(e))),r.interceptors.response.use((e=>o(void 0,void 0,void 0,(function*(){if([n,a].includes(e.status)||e.data.code===a)return e.data;{const t={201:"201 error: Missing parameter",202:"202 error: Parameter is malformed",500:"500 error: Background error",501:"501 error: No data",502:"502 error: Session expired"}[e.status]||"Unknown error";return console.log("请求失败:"+t),Promise.reject(e.data)}}))),(e=>o(void 0,void 0,void 0,(function*(){return Promise.reject(e.response)})))),r},c=(e="",t)=>{const r=d(e);return t&&r.interceptors.response.use((e=>o(void 0,void 0,void 0,(function*(){return yield t(e),e.data}))),(e=>o(void 0,void 0,void 0,(function*(){return yield t(null==e?void 0:e.response),Promise.reject(e.response)})))),r};const u=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},l="anov@2019:helloX",p="anov@2020:helloX";function m(e){let t=r.enc.Utf8.parse(l),o=r.enc.Utf8.parse(p);return r.AES.encrypt(e,t,{iv:o,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}const y=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"]),v=URL.createObjectURL(y);function f(e,t,r={},n="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==n){let[o,n]=[["data"],[t]];"object"==typeof r&&Object.keys(r).forEach((e=>{o.push(e),n.push(r[e])}));const a=new Function(...o,e);return{success:!0,data:a(...n)}}{let[n,a,i]=[t,r,""];"object"==typeof n&&(n=JSON.stringify(t)),"object"==typeof r&&(a=JSON.stringify(r)),Object.keys(r).forEach((e=>i+=`${e},`));let s=`let data=eval(${n}); \n let app=${JSON.stringify({})};`;s+=i?`let {${i}} = eval(${a}); `:"",s+=`${e}`;let d=yield function(e,t=5e3){return o(this,void 0,void 0,(function*(){let r=new Worker(v);return new Promise(((o,n)=>{const a=()=>{clearTimeout(s),r.removeEventListener("message",i),r.terminate(),r=null},i=e=>{let{code:t,result:r,err:i}=e.data;a(),1===t?o(r):n(i)};r.postMessage({code:e}),r.addEventListener("message",i);let s=setTimeout((()=>{a(),n("timeout")}),t)}))}))}(s);return{success:!0,data:d}}}catch(e){return{success:!1,error:e,data:t}}}))}var h,w,g;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(h||(h={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(w||(w={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(g||(g={}));const T=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):c(e,t),b=c();function j(e,r="get",n={},a={}){return o(this,void 0,void 0,(function*(){const i={method:g[r],url:e,headers:a,timeout:s};["post","put"].includes(r.toLowerCase())?i.data=t.cloneDeep(n):i.params=t.cloneDeep(n);try{return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield b({method:"get",url:e})).data}catch(e){throw console.error("Error:",e.message),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield b(e)).data}}catch(e){throw console.error("Error:",e.message),e}}))}(i)}catch(e){throw console.error("Error:",e.message),e}}))}function E(e,t,r,n){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),i=function(e,t=!1){return t?u(e)?e:JSON.stringify(e):u(e)?JSON.parse(e):e}(r,!0);return yield b({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?i:void 0,headers:n,method:e,url:t}})}catch(e){throw console.error("Error:",e.message),e}}))}function O(e,t,r,n,a){return o(this,void 0,void 0,(function*(){return a?E(t,e,r,n):j(e,t,r,n)}))}function P(e,t="",r){var o,n,a;const s=`${null!==(n=null===(o=null===window||void 0===window?void 0:window.BaseUrl)||void 0===o?void 0:o.replace("/management",""))&&void 0!==n?n:""}/ds/data-engine/v1/${e}/zb-query?${`token=${I("YZH_EXCHANGE_TOKEN")||(null===(a=null===window||void 0===window?void 0:window.yzhAuth)||void 0===a?void 0:a.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=t?JSON.parse(t):{}}catch(e){d=t||{}}return b({method:"POST",url:s,data:{headers:r,param:d},timeout:i})}const $=(e,t)=>o(void 0,void 0,void 0,(function*(){const r=window.BaseUrl,{dateType:o="",endPeriod:n="",metricsName:a=e,startPeriod:s=""}=t;return b({method:"GET",url:`${r}ds/v1/metrics/v1/data-alarm?dateType=${o}&endPeriod=${n}&metricsName=${a}&startPeriod=${s}`,timeout:i})})),k=(e,t,r)=>o(void 0,void 0,void 0,(function*(){var o;const n=(null===(o=window.BaseUrl)||void 0===o?void 0:o.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${n}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${n}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[r];if(!a)throw new Error("Invalid data type provided");return b(Object.assign({timeout:i},a))})),S=e=>new Promise(((t,r)=>{let o;o=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==o?t({data:o}):r("Failed to retrieve cdata")})),D=(e,t,r)=>{switch(t){case"api":return{requestType:e.requestType,url:e.url,params:e.params,headers:e.headers,agency:e.agency};case"static":return{data:e};case"datasource":{const t=z(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:m(t),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")}},N=(e,t,r,n,a,i,s)=>o(void 0,void 0,void 0,(function*(){switch(t){case"api":return yield O(r,e.requestType,e.params,e.headers,e.agency);case"static":return yield S(e.data);case"datasource":return yield k(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield k(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield P(e.zbId,e.params,e.headers);case"indicatorCQ":return yield $(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}})),q=(e,t,r,n,a=!1)=>o(void 0,void 0,void 0,(function*(){const o=L(e,r),{url:i,requestType:s,params:d,headers:c,agency:u}=o,l=t||e.tmpData.source.dataType,p=e.tmpData.source[l];if("globalData"===l){const e=n.find((e=>e.key===p.id)),t=(e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null})(p.id);if(t&&!a)return t.data;if(e){let t=yield U(e,r),o={key:p.id,data:t};return((e,t)=>{try{const r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}})(p.id,o),t}return}const m=D(p,l,r);return(yield N(m,l,i)).data})),U=(e,t)=>o(void 0,void 0,void 0,(function*(){let r=Object.assign({},{tmpData:{source:e.value}});const o=L(r,t),{url:n,requestType:a,params:i,headers:s,agency:d}=o,c=r.tmpData.source.type,u=r.tmpData.source[c],l=D(u,c,t),p=yield N(l,c,n);return yield C(p.data,r,!0,t)})),C=(e,r,n=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:i,mapFields:s}=r.tmpData.source;return i&&i.use&&n?yield new Promise(((r,n)=>{const s=function(e,r,n,a,i){return o(this,void 0,void 0,(function*(){let o,n=e,{use:i,data:s}=t.cloneDeep(r);if(i)for(let e=0;e<s.length;e++)if(s[e].use){let r=s[e].dependVars,i={};a&&i&&r&&r.length&&r.map((e=>{let r=t.cloneDeep(a).filter((t=>{let r=t.mapField==e;return r&&(i[e]=t.value),r}));r&&0!=r.length||(i[e]="")})),o=yield f(s[e].code,n,i,s[e].mode?s[e].mode:"worker"),n=o.data}return n}))}(e,i,0,a);r(s)})):yield new Promise(((t,r)=>{t(e)}))}catch(e){throw console.error(e),e}})),x=(e,t,r)=>{const{source:o}=e.tmpData,n=o.type;r?("static"===n&&o[n]&&(o[n].originData=r),"indicatorCQ"===n?o.indicator.data=t:o[n].data=t):"indicatorCQ"===n?o.indicator.data=t:o[n].data=t,e.source=t},F=(e,t,r,n,a,i)=>o(void 0,void 0,void 0,(function*(){try{let o=e.tmpData.source.type,s=yield q(e,o,r,n,i||!1),d=yield C(s,e,t,r);return x(e,d),a&&a(d),Promise.resolve(d)}catch(e){return console.error("Error in updateComData:",e),Promise.reject(e)}})),I=e=>{const t={};if(e&&e.includes("?")){const r=e.split("?")[1].split("&");for(let e of r){const[r,o]=e.split("=").map(decodeURIComponent);t[r]=o}}return t},z=(e,t)=>{if("string"==typeof e)return""===e.trim()?"":e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,o)=>{const n=r||o,a=t.find((e=>e.mapField===n));return a?a.value||a.originalValue||"":e}));if(Array.isArray(e))return e.map((e=>z(e,t)));if("object"==typeof e&&null!==e){const r={};for(let o in e)r[o]=z(e[o],t);return r}return e},L=(e,t,r)=>{var o;const n=e.tmpData.source,a=r?r.value.api.agency:null===(o=null==n?void 0:n.api)||void 0===o?void 0:o.agency,i=n.type;if("static"!==i){const e=r?r.value.api:n[i],{url:o=null,headers:s,params:d,requestType:c}=e,u=o?z(o,t):void 0,l=s?z(s.value,t):{};return{url:u,requestType:c,params:d?z(d,t):{},headers:l,agency:a}}return{url:void 0,requestType:void 0,params:void 0,headers:void 0,agency:void 0}};export{T as Http,E as agentData,x as editItem,U as fetchDataByGlobal,q as fetchDataByType,C as filterData,j as getData,O as getDataForApi,k as getDataForSource,S as getDataForStatic,P as getDataForZb,$ as getDataForZbCQ,F as updateComData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decrypAES(data: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取代码处理后的数据,用于数据面板数据过滤器
|
|
3
|
+
* @param {object} source 源数据
|
|
4
|
+
* @param {object} converse 转换数据
|
|
5
|
+
* @param {array} sourcemapFields 源字段映射
|
|
6
|
+
* @param {object} globalVars 全局变量
|
|
7
|
+
* @param {object} cmp
|
|
8
|
+
* @returns {Promise<any>} 处理后的数据
|
|
9
|
+
*/
|
|
10
|
+
export declare function getDataForEvaluator(source: any, converse: any, sourcemapFields: any, globalVars?: any, cmp?: any): Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 执行代码并处理数据
|
|
13
|
+
* @param {string} code 源码
|
|
14
|
+
* @param {object} data 数据
|
|
15
|
+
* @param {object} params 参数
|
|
16
|
+
* @param {string} mode 执行模式
|
|
17
|
+
* @returns {Promise<object>} 处理结果
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluator(code: any, data: any, params?: any, mode?: string): Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
data: any;
|
|
22
|
+
error?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
success: boolean;
|
|
25
|
+
error: unknown;
|
|
26
|
+
data: any;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* 对映射字段进行处理
|
|
30
|
+
* @param {array} mapFields 映射字段
|
|
31
|
+
* @param {any} data 数据
|
|
32
|
+
* @returns {any} 转换后的数据
|
|
33
|
+
*/
|
|
34
|
+
export declare function evalMapFields(mapFields: any, data: any): any;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { PreviewBean, GlobalDataSourceItem, CallbackFunction, GoComponent } from "./type";
|
|
2
|
+
/**
|
|
3
|
+
* 发起 HTTP 请求
|
|
4
|
+
* @param url 请求路径
|
|
5
|
+
* @param callback 回调函数
|
|
6
|
+
* @returns Promise<any> 请求的 Promise
|
|
7
|
+
*/
|
|
8
|
+
export declare const Http: (url?: string, callback?: CallbackFunction) => import("axios").AxiosInstance | Promise<never>;
|
|
9
|
+
/**
|
|
10
|
+
* 获取数据
|
|
11
|
+
* @param {string} url 请求地址
|
|
12
|
+
* @param {string} type 请求类型('get' | 'post' | 'put' | 'delete')
|
|
13
|
+
* @param {*} params 请求参数
|
|
14
|
+
* @param {*} headers 请求头参数
|
|
15
|
+
* @returns {Promise<any>} 返回请求获取的数据
|
|
16
|
+
*/
|
|
17
|
+
export declare function getData(url: string, type?: "get" | "post" | "put" | "delete", params?: any, headers?: any): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* 代理请求数据
|
|
20
|
+
* @param {string} method - 代理方法
|
|
21
|
+
* @param {string} url - 代理请求地址
|
|
22
|
+
* @param {Object} params - 代理请求参数
|
|
23
|
+
* @param {Object} headers - 代理请求头参数
|
|
24
|
+
* @returns {Promise<any>} 返回 Promise 对象
|
|
25
|
+
*/
|
|
26
|
+
export declare function agentData(method: string, url: string, params: any, headers: any): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* 获取特定类型的数据,可以选择使用代理或直接请求。
|
|
29
|
+
* @param url 请求路径
|
|
30
|
+
* @param type 请求类型
|
|
31
|
+
* @param params 请求参数
|
|
32
|
+
* @param headers 请求头信息
|
|
33
|
+
* @param agent 是否使用代理
|
|
34
|
+
* @returns Promise<any> 包含请求数据的 Promise 对象
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDataForApi(url: string, type: string, params: any, headers: any, agent: boolean): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取 yhz Zb 数据
|
|
39
|
+
* @param {any} id ID
|
|
40
|
+
* @param {any} params 请求参数
|
|
41
|
+
* @param {any[]} headers 请求头参数
|
|
42
|
+
* @returns {Promise<any>} 包装了 Axios 请求结果的 Promise 对象
|
|
43
|
+
*/
|
|
44
|
+
export declare function getDataForZb(id: any, params: any, headers: any): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取 ZB CQ 数据
|
|
47
|
+
* @param {String} zbName 指标名称
|
|
48
|
+
* @param {any} params 参数对象
|
|
49
|
+
* @returns {Promise<any>} 包装了 Axios 请求结果的 Promise 对象
|
|
50
|
+
*/
|
|
51
|
+
export declare const getDataForZbCQ: (zbName: string, params: any) => Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* 获取 文件/数据库,数据源信息
|
|
54
|
+
* @param {any} id 数据源 ID
|
|
55
|
+
* @param {PreviewBean} params 数据源预览信息
|
|
56
|
+
* @param {DataType} dataType 数据源类型
|
|
57
|
+
* @returns {Promise<any>} 返回数据源请求的 Promise 对象
|
|
58
|
+
*/
|
|
59
|
+
export declare const getDataForSource: (id: any, params: PreviewBean, dataType: "staticFile" | "datasource") => Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* 异步函数,根据提供的数据返回 cdata
|
|
62
|
+
* @param {any} data 传入的数据对象
|
|
63
|
+
* @returns {Promise<any>} 返回包含 cdata 的 Promise 对象
|
|
64
|
+
*/
|
|
65
|
+
export declare const getDataForStatic: (data: any) => Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* 根据数据类型和元素信息,获取数据
|
|
68
|
+
* @param element - 元素信息
|
|
69
|
+
* @param type - 数据类型
|
|
70
|
+
* @param globalVars - 全局变量
|
|
71
|
+
* @param globalSource - 全局数据源
|
|
72
|
+
* @param forceRefresh - 强制刷新开关
|
|
73
|
+
* @returns Promise<any>
|
|
74
|
+
*/
|
|
75
|
+
export declare const fetchDataByType: (element: any, type: string, globalVars: any[], globalSource: GlobalDataSourceItem[], forceRefresh?: boolean) => Promise<any>;
|
|
76
|
+
/**
|
|
77
|
+
* 处理 'globalData' 类型的数据请求
|
|
78
|
+
* @param source - 数据源
|
|
79
|
+
* @param globalVars - 全局变量
|
|
80
|
+
* @returns Promise<any>
|
|
81
|
+
*/
|
|
82
|
+
export declare const fetchDataByGlobal: (source: GlobalDataSourceItem, globalVars: any[]) => Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* 处理 数据并且执行过滤器
|
|
85
|
+
* @param data - 数据源
|
|
86
|
+
* @param item - 组件实例
|
|
87
|
+
* @param edit - 外部控制是否执行过滤器
|
|
88
|
+
* @param globalVars - 全局变量
|
|
89
|
+
* @returns Promise<any>
|
|
90
|
+
*/
|
|
91
|
+
export declare const filterData: (data: any, item: GoComponent, edit?: boolean, globalVars?: any) => Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
* 修改实例数据
|
|
94
|
+
* @param {GoComponent} item 组件实例
|
|
95
|
+
* @param {any} data 数据
|
|
96
|
+
* @param {Function} callback 回调函数
|
|
97
|
+
* @param {any} metadata 元数据
|
|
98
|
+
* @returns {void}
|
|
99
|
+
*/
|
|
100
|
+
export declare const editItem: (item: GoComponent, data: any, metadata?: any) => void;
|
|
101
|
+
/**
|
|
102
|
+
* 更新组件数据
|
|
103
|
+
* @param {GoComponent} element - 组件实例
|
|
104
|
+
* @param {boolean} filterFlag - 是否进行数据过滤的标志
|
|
105
|
+
* @param {any} globalVars - 全局变量
|
|
106
|
+
* @param {GlobalDataSourceItem[]} globalSource - 全局数据源数组
|
|
107
|
+
* @param {Function} [callback] - 回调函数
|
|
108
|
+
* @returns {Promise<any>} - 返回一个 Promise,在成功时返回更新后的数据,失败时返回错误对象
|
|
109
|
+
*/
|
|
110
|
+
export declare const updateComData: (element: GoComponent, filterFlag: boolean, globalVars: any, globalSource: GlobalDataSourceItem[], callback?: CallbackFunction, forceRefresh?: boolean) => Promise<any>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export interface DataSource {
|
|
2
|
+
type: string;
|
|
3
|
+
converse: {
|
|
4
|
+
use: boolean;
|
|
5
|
+
data: any[];
|
|
6
|
+
};
|
|
7
|
+
static: {
|
|
8
|
+
data: any;
|
|
9
|
+
originData: string;
|
|
10
|
+
[prop: string]: any;
|
|
11
|
+
};
|
|
12
|
+
api: {
|
|
13
|
+
requestType: string;
|
|
14
|
+
url: string;
|
|
15
|
+
[prop: string]: any;
|
|
16
|
+
headers: {
|
|
17
|
+
use: boolean;
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
params: string;
|
|
21
|
+
agency: boolean;
|
|
22
|
+
cookie: boolean;
|
|
23
|
+
autoUpdate: {
|
|
24
|
+
open: boolean;
|
|
25
|
+
time: number;
|
|
26
|
+
};
|
|
27
|
+
data: any;
|
|
28
|
+
};
|
|
29
|
+
datasource: {
|
|
30
|
+
data: any;
|
|
31
|
+
inputSql: string;
|
|
32
|
+
dsName: string;
|
|
33
|
+
dsType: number;
|
|
34
|
+
[prop: string]: any;
|
|
35
|
+
autoUpdate: {
|
|
36
|
+
open: boolean;
|
|
37
|
+
time: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
indicator: {
|
|
41
|
+
zbId: string;
|
|
42
|
+
zbName: string;
|
|
43
|
+
params: string;
|
|
44
|
+
data: any;
|
|
45
|
+
[prop: string]: any;
|
|
46
|
+
autoUpdate: {
|
|
47
|
+
open: boolean;
|
|
48
|
+
time: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
staticFile: {
|
|
52
|
+
data: any;
|
|
53
|
+
dsName: string;
|
|
54
|
+
dsType: number;
|
|
55
|
+
[prop: string]: any;
|
|
56
|
+
};
|
|
57
|
+
globalData: {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
data: any;
|
|
61
|
+
[prop: string]: any;
|
|
62
|
+
};
|
|
63
|
+
[prop: string]: any;
|
|
64
|
+
packData: {
|
|
65
|
+
[prop: string]: any;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export type CallbackFunction = (...args: any[]) => any;
|
|
69
|
+
export interface GlobalDataSourceItem {
|
|
70
|
+
key: string;
|
|
71
|
+
name: string;
|
|
72
|
+
value: DataSource;
|
|
73
|
+
}
|
|
74
|
+
export interface BaseData {
|
|
75
|
+
left: number;
|
|
76
|
+
top: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
angle?: number;
|
|
80
|
+
penetrate?: number;
|
|
81
|
+
opacity?: number;
|
|
82
|
+
perspective?: number;
|
|
83
|
+
rotateX?: number;
|
|
84
|
+
rotateY?: number;
|
|
85
|
+
rotateZ?: number;
|
|
86
|
+
transformOriginX?: string;
|
|
87
|
+
transformOriginY?: string;
|
|
88
|
+
transformSwitch?: boolean;
|
|
89
|
+
[prop: string]: any;
|
|
90
|
+
}
|
|
91
|
+
export interface SessionData {
|
|
92
|
+
key: string;
|
|
93
|
+
name?: string;
|
|
94
|
+
data: any;
|
|
95
|
+
}
|
|
96
|
+
export interface GoComponent {
|
|
97
|
+
isLock: boolean;
|
|
98
|
+
isShow: boolean;
|
|
99
|
+
baseData: BaseData;
|
|
100
|
+
componentType: string;
|
|
101
|
+
cid: string;
|
|
102
|
+
source: any;
|
|
103
|
+
comData?: any;
|
|
104
|
+
tmpData: {
|
|
105
|
+
source: DataSource;
|
|
106
|
+
option: any;
|
|
107
|
+
actions: any[];
|
|
108
|
+
};
|
|
109
|
+
dynamic?: number;
|
|
110
|
+
filePath?: string;
|
|
111
|
+
origin?: string;
|
|
112
|
+
name: string;
|
|
113
|
+
path?: string;
|
|
114
|
+
viewComName: string;
|
|
115
|
+
optionComName?: string;
|
|
116
|
+
dataComName?: string;
|
|
117
|
+
eventComName?: string;
|
|
118
|
+
assemblyDeveloper?: string;
|
|
119
|
+
devEmail?: string | null;
|
|
120
|
+
version?: string | null;
|
|
121
|
+
devDept?: string;
|
|
122
|
+
z?: number;
|
|
123
|
+
toggle?: boolean;
|
|
124
|
+
[prop: string]: any;
|
|
125
|
+
}
|
|
126
|
+
export interface PreviewBean {
|
|
127
|
+
dsType: number | string;
|
|
128
|
+
sql: any;
|
|
129
|
+
newEncryption?: boolean;
|
|
130
|
+
sqlFilter?: boolean;
|
|
131
|
+
[index: string]: any;
|
|
132
|
+
}
|
|
133
|
+
export interface RequestOptions {
|
|
134
|
+
method: string;
|
|
135
|
+
url: string;
|
|
136
|
+
params?: any;
|
|
137
|
+
data?: any;
|
|
138
|
+
headers?: any;
|
|
139
|
+
timeout?: number;
|
|
140
|
+
}
|
|
141
|
+
export declare enum DataType {
|
|
142
|
+
StaticFile = "staticFile",
|
|
143
|
+
DataSource = "datasource"
|
|
144
|
+
}
|
|
145
|
+
export declare enum ContentType {
|
|
146
|
+
json = "application/json;charset=UTF-8",
|
|
147
|
+
form = "application/x-www-form-urlencoded; charset=UTF-8"
|
|
148
|
+
}
|
|
149
|
+
export declare enum HttpMethod {
|
|
150
|
+
get = "GET",
|
|
151
|
+
post = "POST",
|
|
152
|
+
put = "PUT",
|
|
153
|
+
patch = "PATCH",
|
|
154
|
+
delete = "DELETE"
|
|
155
|
+
}
|
|
156
|
+
export interface IReqConfig {
|
|
157
|
+
body?: any;
|
|
158
|
+
method?: string;
|
|
159
|
+
headers?: IHeader;
|
|
160
|
+
token?: string;
|
|
161
|
+
"Content-Type"?: string;
|
|
162
|
+
}
|
|
163
|
+
export interface IHeader {
|
|
164
|
+
"Content-Type": string;
|
|
165
|
+
"X-Requested-With": string;
|
|
166
|
+
token: string;
|
|
167
|
+
[propName: string]: any;
|
|
168
|
+
}
|
|
169
|
+
export interface HttpMethodIndexable {
|
|
170
|
+
[key: string]: HttpMethod | undefined;
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fetchUtils';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取标准数据格式方法,兼容处理 JSON 格式数据
|
|
3
|
+
* @param {string} args - 传入数据参数
|
|
4
|
+
* @param {boolean} [toJSON=false] - 是否转成 JSON 格式,默认为 false
|
|
5
|
+
* @returns {T} 返回标准数据格式
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStandardData<T>(args: string, toJSON?: boolean): T;
|
|
8
|
+
/**
|
|
9
|
+
* 判断是否为标准 JSON 格式
|
|
10
|
+
* @param {any} param - 传参参数
|
|
11
|
+
* @returns {boolean} 返回布尔值
|
|
12
|
+
*/
|
|
13
|
+
export declare const isJSON: (param: any) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 将数据存储到 Session Storage
|
|
16
|
+
* @param key - 存储数据的键名
|
|
17
|
+
* @param value - 要存储的值
|
|
18
|
+
* @returns 无返回值
|
|
19
|
+
*/
|
|
20
|
+
export declare const setSessionData: (key: string, value: any) => void;
|
|
21
|
+
/**
|
|
22
|
+
* 从 Session Storage 获取数据
|
|
23
|
+
* @param key - 要获取数据的键名
|
|
24
|
+
* @returns 如果找到匹配键的数据,返回解析后的泛型类型数据,否则返回 null
|
|
25
|
+
*/
|
|
26
|
+
export declare const getSessionData: (key: string) => any;
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wdslib/go-utils",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "go-core utils",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/code.umd.js",
|
|
9
|
+
"dist/code.es5.js",
|
|
10
|
+
"dist/types"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rimraf dist && rollup -c",
|
|
14
|
+
"serve": "rimraf dist && rollup -c -w",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"docs": "typedoc --out docs --theme default src"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "ws880321",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org/"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
28
|
+
"@types/crypto-js": "^4.1.1",
|
|
29
|
+
"@types/lodash": "^4.14.186",
|
|
30
|
+
"eslint": "^8.55.0",
|
|
31
|
+
"prettier": "^3.1.1",
|
|
32
|
+
"rimraf": "^2.6.2",
|
|
33
|
+
"rollup": "^2.79.1",
|
|
34
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
35
|
+
"rollup-plugin-typedoc": "^0.1.2",
|
|
36
|
+
"typedoc-theme": "^0.1.4",
|
|
37
|
+
"typescript": "^5.3.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
41
|
+
"@rollup/plugin-eslint": "^9.0.5",
|
|
42
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
44
|
+
"axios": "^1.6.2",
|
|
45
|
+
"crypto-js": "^4.1.1",
|
|
46
|
+
"lodash": "^4.17.21",
|
|
47
|
+
"rollup-plugin-typescript": "^1.0.1",
|
|
48
|
+
"tslib": "^2.6.2",
|
|
49
|
+
"typedoc": "^0.25.4"
|
|
50
|
+
}
|
|
51
|
+
}
|