cool-common-utils 1.0.0 → 1.0.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/request.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./commons/tslib.es6-DVnGIs25.js"),t=require("./commons/axios-DsdlaZnY.js"),r=require("./commons/socket_io-Bw6JUjpU.js"),n=require("./commons/qs-yb498JEx.js"),o=require("./message.js");require("./commons/crypto-CT1W49ET.js"),require("./commons/sweetalert-B1ksMzDj.js");var s=n.requireLib(),i=r.getDefaultExportFromCjs(s),a=new Map([["form","application/x-www-form-urlencoded;charset=UTF-8"],["upload","multipart/form-data"]]),c=function(){function r(r,n){var o;this.config=e.__assign(e.__assign({},{type:"",timeout:0,responseType:"json",withCredentials:!1,proxy:!1,ERROR_CODES:["1005","1006","1008","1009"]}),n||{}),this.postType=this.config.type,this.instance=t.axios.create({baseURL:r,headers:{"Content-Type":null!==(o=a.get(this.config.type))&&void 0!==o?o:"application/json;charset=UTF-8"},timeout:this.config.timeout,responseType:this.config.responseType,withCredentials:this.config.withCredentials,proxy:this.config.proxy}),this.setupInterceptors()}return r.prototype.setupInterceptors=function(){var e=this;this.instance.interceptors.request.use(function(r){var n,o,s=null===(o=(n=e.config).getAuthorization)||void 0===o?void 0:o.call(n);return s&&r.headers&&r.headers.set("Authorization",s),r.cancelToken=new t.axios.CancelToken(function(t){var n,o;null===(o=(n=e.config).cancelCallback)||void 0===o||o.call(n,{cancelToken:{name:r.url,cancel:t}})}),r},this.handleError),this.instance.interceptors.response.use(function(t){var r;return(null===(r=e.config.ERROR_CODES)||void 0===r?void 0:r.includes(String(t.data.code)))?(o.SweetError(t.data.msg).then(function(){var t,r;null===(r=(t=e.config).errorCallback)||void 0===r||r.call(t)}),Promise.reject(t.data.msg)):t.data},this.handleError)},r.prototype.handleError=function(e){return Promise.reject(e.message)},r.prototype.get=function(e,t){return this.instance.get(e,{params:t})},r.prototype.post=function(e,t){var r="form"===this.postType?i.stringify(t):t;return this.instance.post(e,r)},r.prototype.put=function(e,t){var r="form"===this.postType?i.stringify(t):t;return this.instance.put(e,r)},r.prototype.delete=function(e,t){return this.instance.delete(e,{params:{id:t}})},r}();exports.CreateRequest=c;
1
+ "use strict";var e=require("./commons/tslib.es6-DVnGIs25.js"),t=require("./commons/axios-DsdlaZnY.js"),r=require("./commons/socket_io-Bw6JUjpU.js"),o=require("./commons/qs-yb498JEx.js"),n=require("./message.js");require("./commons/crypto-CT1W49ET.js"),require("./commons/sweetalert-B1ksMzDj.js");var s=o.requireLib(),i=r.getDefaultExportFromCjs(s),a=new Map([["form","application/x-www-form-urlencoded;charset=UTF-8"],["upload","multipart/form-data"]]),c=function(){function r(r,o){var n;this.config=e.__assign(e.__assign({},{type:"",timeout:0,responseType:"json",withCredentials:!1,proxy:!1,ERROR_CODES:["1005","1006","1008","1009"]}),o||{}),this.postType=this.config.type,this.instance=t.axios.create({baseURL:r,headers:{"Content-Type":null!==(n=a.get(this.config.type))&&void 0!==n?n:"application/json;charset=UTF-8"},timeout:this.config.timeout,responseType:this.config.responseType,withCredentials:this.config.withCredentials,proxy:this.config.proxy}),this.setupInterceptors()}return r.prototype.setupInterceptors=function(){var e=this;this.instance.interceptors.request.use(function(r){var o,n,s=null===(n=(o=e.config).getAuthorization)||void 0===n?void 0:n.call(o);return console.log("AUTH_TOKEN",s),s&&r.headers&&r.headers.set("Authorization",s),r.cancelToken=new t.axios.CancelToken(function(t){var o,n;null===(n=(o=e.config).cancelCallback)||void 0===n||n.call(o,{cancelToken:{name:r.url,cancel:t}})}),r},this.handleError),this.instance.interceptors.response.use(function(t){var r;return(null===(r=e.config.ERROR_CODES)||void 0===r?void 0:r.includes(String(t.data.code)))?(n.SweetError(t.data.msg).then(function(){var t,r;null===(r=(t=e.config).errorCallback)||void 0===r||r.call(t)}),Promise.reject(t.data.msg)):t.data},this.handleError)},r.prototype.handleError=function(e){return Promise.reject(e.message)},r.prototype.get=function(e,t){return this.instance.get(e,{params:t})},r.prototype.post=function(e,t){var r="form"===this.postType?i.stringify(t):t;return this.instance.post(e,r)},r.prototype.put=function(e,t){var r="form"===this.postType?i.stringify(t):t;return this.instance.put(e,r)},r.prototype.delete=function(e,t){return this.instance.delete(e,{params:{id:t}})},r}();exports.CreateRequest=c;
package/dist/request.mjs CHANGED
@@ -1 +1 @@
1
- import{_ as t}from"./commons/tslib.es6-BjAlDJRq.js";import{a as e}from"./commons/axios-DxFWCEd0.js";import{a as o}from"./commons/socket_io-CSNhVzSE.js";import{r as n}from"./commons/qs-D46UmmL2.js";import{SweetError as r}from"./message.mjs";import"./commons/crypto-DuLLVHQr.js";import"./commons/sweetalert-DMYmZawW.js";var s=o(n()),i=new Map([["form","application/x-www-form-urlencoded;charset=UTF-8"],["upload","multipart/form-data"]]),a=function(){function o(o,n){var r;this.config=t(t({},{type:"",timeout:0,responseType:"json",withCredentials:!1,proxy:!1,ERROR_CODES:["1005","1006","1008","1009"]}),n||{}),this.postType=this.config.type,this.instance=e.create({baseURL:o,headers:{"Content-Type":null!==(r=i.get(this.config.type))&&void 0!==r?r:"application/json;charset=UTF-8"},timeout:this.config.timeout,responseType:this.config.responseType,withCredentials:this.config.withCredentials,proxy:this.config.proxy}),this.setupInterceptors()}return o.prototype.setupInterceptors=function(){var t=this;this.instance.interceptors.request.use(function(o){var n,r,s=null===(r=(n=t.config).getAuthorization)||void 0===r?void 0:r.call(n);return s&&o.headers&&o.headers.set("Authorization",s),o.cancelToken=new e.CancelToken(function(e){var n,r;null===(r=(n=t.config).cancelCallback)||void 0===r||r.call(n,{cancelToken:{name:o.url,cancel:e}})}),o},this.handleError),this.instance.interceptors.response.use(function(e){var o;return(null===(o=t.config.ERROR_CODES)||void 0===o?void 0:o.includes(String(e.data.code)))?(r(e.data.msg).then(function(){var e,o;null===(o=(e=t.config).errorCallback)||void 0===o||o.call(e)}),Promise.reject(e.data.msg)):e.data},this.handleError)},o.prototype.handleError=function(t){return Promise.reject(t.message)},o.prototype.get=function(t,e){return this.instance.get(t,{params:e})},o.prototype.post=function(t,e){var o="form"===this.postType?s.stringify(e):e;return this.instance.post(t,o)},o.prototype.put=function(t,e){var o="form"===this.postType?s.stringify(e):e;return this.instance.put(t,o)},o.prototype.delete=function(t,e){return this.instance.delete(t,{params:{id:e}})},o}();export{a as CreateRequest};
1
+ import{_ as t}from"./commons/tslib.es6-BjAlDJRq.js";import{a as e}from"./commons/axios-DxFWCEd0.js";import{a as o}from"./commons/socket_io-CSNhVzSE.js";import{r as n}from"./commons/qs-D46UmmL2.js";import{SweetError as r}from"./message.mjs";import"./commons/crypto-DuLLVHQr.js";import"./commons/sweetalert-DMYmZawW.js";var s=o(n()),i=new Map([["form","application/x-www-form-urlencoded;charset=UTF-8"],["upload","multipart/form-data"]]),a=function(){function o(o,n){var r;this.config=t(t({},{type:"",timeout:0,responseType:"json",withCredentials:!1,proxy:!1,ERROR_CODES:["1005","1006","1008","1009"]}),n||{}),this.postType=this.config.type,this.instance=e.create({baseURL:o,headers:{"Content-Type":null!==(r=i.get(this.config.type))&&void 0!==r?r:"application/json;charset=UTF-8"},timeout:this.config.timeout,responseType:this.config.responseType,withCredentials:this.config.withCredentials,proxy:this.config.proxy}),this.setupInterceptors()}return o.prototype.setupInterceptors=function(){var t=this;this.instance.interceptors.request.use(function(o){var n,r,s=null===(r=(n=t.config).getAuthorization)||void 0===r?void 0:r.call(n);return console.log("AUTH_TOKEN",s),s&&o.headers&&o.headers.set("Authorization",s),o.cancelToken=new e.CancelToken(function(e){var n,r;null===(r=(n=t.config).cancelCallback)||void 0===r||r.call(n,{cancelToken:{name:o.url,cancel:e}})}),o},this.handleError),this.instance.interceptors.response.use(function(e){var o;return(null===(o=t.config.ERROR_CODES)||void 0===o?void 0:o.includes(String(e.data.code)))?(r(e.data.msg).then(function(){var e,o;null===(o=(e=t.config).errorCallback)||void 0===o||o.call(e)}),Promise.reject(e.data.msg)):e.data},this.handleError)},o.prototype.handleError=function(t){return Promise.reject(t.message)},o.prototype.get=function(t,e){return this.instance.get(t,{params:e})},o.prototype.post=function(t,e){var o="form"===this.postType?s.stringify(e):e;return this.instance.post(t,o)},o.prototype.put=function(t,e){var o="form"===this.postType?s.stringify(e):e;return this.instance.put(t,o)},o.prototype.delete=function(t,e){return this.instance.delete(t,{params:{id:e}})},o}();export{a as CreateRequest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cool-common-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "cool工具函数库",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",