axios-annotations 1.1.7 → 1.1.8

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.
@@ -1 +1 @@
1
- "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ConfigMapping=void 0;var _common=require("./common"),_parser=_interopRequireDefault(require("./parser")),_config=_interopRequireWildcard(require("./config"));function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};t=_getRequireWildcardCache(t);if(t&&t.has(e))return t.get(e);var r,n,i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((n=o?Object.getOwnPropertyDescriptor(e,r):null)&&(n.get||n.set)?Object.defineProperty(i,r,n):i[r]=e[r]);return i.default=e,t&&t.set(e,i),i}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _createForOfIteratorHelper(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),r=0,{s:t=function(){},n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ConfigMapping={requestHeaders:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],r={};if(e)for(var n in e){var i=e[n];r[n]="function"==typeof i?i.apply(void 0,t):i}return r},axiosConfig:function(e,t){var r={};return(e||[]).forEach(function(e){"function"==typeof e?Object.assign(r,e.apply(void 0,t)):Object.assign(r,e)}),r},querystring:function(e,t){if(!t)return"";if(e){var r,n=_parser.default.decode(t);for(r in t){var i=t[r],o=e[r];!o||o.body?_parser.default.delete(n,r):o.required?(0,_common.isNullOrEmpty)(i)&&!_parser.default.has(n,r)&&_parser.default.append(n,r,""):(0,_common.isNullOrEmpty)(i)&&_parser.default.has(n,r)&&_parser.default.delete(n,r)}return _parser.default.encode(n)}return""},body:function(e,t){if(e)for(var r in e)if(!0===e[r].body)return(0,_common.isNullOrEmpty)(t)?void 0:t[r];return null}},Service=(exports.ConfigMapping=ConfigMapping,function(){function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(_classCallCheck(this,n),_defineProperty(this,"_path",""),_defineProperty(this,"_config",_config.config),_defineProperty(this,"_headers",{}),_defineProperty(this,"_params",{}),_defineProperty(this,"_configs",{}),_defineProperty(this,"_for",{}),!this._path&&e&&(this._path=e),"function"==typeof Object.getPrototypeOf?(Object.getPrototypeOf(this)._path&&(this._path=Object.getPrototypeOf(this)._path),Object.getPrototypeOf(this)._config&&(this._config=Object.getPrototypeOf(this)._config)):(this.__proto__._path&&(this._path=this.__proto__._path),this.__proto__._config&&(this._config=this.__proto__._config)),this.config&&this.config.plugins&&this.config.plugins.length){var t,r=_createForOfIteratorHelper(this.config.plugins);try{for(r.s();!(t=r.n()).done;)(0,t.value)(this.config)}catch(e){r.e(e)}finally{r.f()}}}return _createClass(n,[{key:"config",get:function(){return this._config},set:function(e){this._config=e}},{key:"path",get:function(){return this._path},set:function(e){this._path=e}},{key:"params",value:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{required:!1};if(!this._params||!this._params[e]||!Object.hasOwnProperty.call(this._params[e],t)){var r=Object.assign({required:!1,body:!1},r),n=this._params||{},i=this._params&&this._params[e]||{},o=i[t]||{};if(!0===r.body)for(var a in i)i[a].body=!1;this._params=Object.assign(n,_defineProperty({},e,Object.assign(i,_defineProperty({},t,Object.assign(o,r)))))}}},{key:"headers",value:function(e,t,r){var n=this._headers||{};Object.assign(n,_defineProperty({},e,Object.assign(n[e]||{},_defineProperty({},t,r))))}},{key:"for",value:function(e,t){if(void 0===t)return this._for[e];Object.assign(this._for,_defineProperty({},e,t))}},{key:"configs",value:function(e,t){var r=this._configs||{};Object.assign(r,_defineProperty({},e,(r[e]||[]).concat(t)))}},{key:"pathVariable",value:function(e,t){var r=e||"",e=r.match(/{\w+}/g);return Array.isArray(e)&&e.forEach(function(e){e=e.substring(1,e.length-1);r=r.replaceAll("{".concat(e,"}"),t[e])}),r}},{key:"createRequestConfig",value:function(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],o=ConfigMapping.querystring(this._params[e],r),r=ConfigMapping.body(this._params[e],r),n=ConfigMapping.requestHeaders(this._headers[e],n),e=ConfigMapping.axiosConfig(this._configs[e],i),i="".concat(t).concat(o?(0<=t.lastIndexOf("?")?"&":"?")+o:"");return Object.assign(e,{headers:Object.assign(n,e.headers||null)}),{path:i,body:r,config:e,query:o}}},{key:"request",value:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},t=0<=t.indexOf("http")?t:this.config.baseURL+(0,_common.normalizePath)("/".concat(this.path||"","/").concat(t));return this.config.axios.request(Object.assign({method:e,url:t,data:r},n))}},{key:"requestWith",value:function(o){var a=this,f=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",s={},c=[],u={},p=this,n={with:function(e){e=_config.default.forName(e);return e&&(p=e),n},param:function(e){return Object.assign(s,_defineProperty({},e,Object.assign(s[e]||{},{required:1<arguments.length&&void 0!==arguments[1]&&arguments[1],body:!1}))),n},header:function(e,t){return Object.assign(u,_defineProperty({},e,t)),n},body:function(e){var t,r=s[e]||{};for(t in s)s[t].body=!1;return Object.assign(s,_defineProperty({},e,Object.assign(r,{required:!1,body:!0}))),n},config:function(e){return c.push(e),n},send:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=ConfigMapping.querystring(s,e),r=ConfigMapping.body(s,e),n=ConfigMapping.requestHeaders(u,[e]),i=ConfigMapping.axiosConfig(c,[e]);return Object.assign(i,{headers:Object.assign(n,i.headers||null)}),p?(0,_common.forward)(p.axios,p.origin,p.prefix,a.path,f,o,t,r,i):(n="".concat(a.pathVariable(f||"",e)).concat(t?(0<=f.lastIndexOf("?")?"&":"?")+t:""),a.request(o,n,r,i))}};return n}}]),n}());exports.default=Service;
1
+ "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ConfigMapping=void 0;var _common=require("./common"),_parser=_interopRequireDefault(require("./parser")),_config=_interopRequireWildcard(require("./config"));function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};t=_getRequireWildcardCache(t);if(t&&t.has(e))return t.get(e);var r,n,i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((n=o?Object.getOwnPropertyDescriptor(e,r):null)&&(n.get||n.set)?Object.defineProperty(i,r,n):i[r]=e[r]);return i.default=e,t&&t.set(e,i),i}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _createForOfIteratorHelper(e,t){var r,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),r=0,{s:t=function(){},n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ConfigMapping={requestHeaders:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],r={};if(e)for(var n in e){var i=e[n];r[n]="function"==typeof i?i.apply(void 0,t):i}return r},axiosConfig:function(e,t){var r={};return(e||[]).forEach(function(e){"function"==typeof e?Object.assign(r,e.apply(void 0,t)):Object.assign(r,e)}),r},querystring:function(e,t){if(!t)return"";if(e){var r,n=_parser.default.decode(t);for(r in t){var i=t[r],o=e[r];!o||o.body?_parser.default.delete(n,r):o.required?(0,_common.isNullOrEmpty)(i)&&!_parser.default.has(n,r)&&_parser.default.append(n,r,""):(0,_common.isNullOrEmpty)(i)&&_parser.default.has(n,r)&&_parser.default.delete(n,r)}return _parser.default.encode(n)}return""},body:function(e,t){if(e)for(var r in e)if(!0===e[r].body)return(0,_common.isNullOrEmpty)(t)?void 0:t[r];return null}},Service=(exports.ConfigMapping=ConfigMapping,function(){function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;if(_classCallCheck(this,n),_defineProperty(this,"_path",""),_defineProperty(this,"_config",_config.config),_defineProperty(this,"_headers",{}),_defineProperty(this,"_params",{}),_defineProperty(this,"_configs",{}),_defineProperty(this,"_for",{}),!this._path&&e&&(this._path=e),"function"==typeof Object.getPrototypeOf?(Object.getPrototypeOf(this)._path&&(this._path=Object.getPrototypeOf(this)._path),Object.getPrototypeOf(this)._config&&(this._config=Object.getPrototypeOf(this)._config)):(this.__proto__._path&&(this._path=this.__proto__._path),this.__proto__._config&&(this._config=this.__proto__._config)),this.config&&this.config.plugins&&this.config.plugins.length){var t,r=_createForOfIteratorHelper(this.config.plugins);try{for(r.s();!(t=r.n()).done;)(0,t.value)(this.config)}catch(e){r.e(e)}finally{r.f()}}}return _createClass(n,[{key:"config",get:function(){return this._config},set:function(e){this._config=e}},{key:"path",get:function(){return this._path},set:function(e){this._path=e}},{key:"params",value:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{required:!1};if(!this._params||!this._params[e]||!Object.hasOwnProperty.call(this._params[e],t)){var r=Object.assign({required:!1,body:!1},r),n=this._params||{},i=this._params&&this._params[e]||{},o=i[t]||{};if(!0===r.body)for(var a in i)i[a].body=!1;this._params=Object.assign(n,_defineProperty({},e,Object.assign(i,_defineProperty({},t,Object.assign(o,r)))))}}},{key:"headers",value:function(e,t,r){var n=this._headers||{};Object.assign(n,_defineProperty({},e,Object.assign(n[e]||{},_defineProperty({},t,r))))}},{key:"for",value:function(e,t){if(void 0===t)return this._for[e];Object.assign(this._for,_defineProperty({},e,t))}},{key:"configs",value:function(e,t){var r=this._configs||{};Object.assign(r,_defineProperty({},e,(r[e]||[]).concat(t)))}},{key:"pathVariable",value:function(e,t){var r=e||"",e=r.match(/{\w+}/g);return Array.isArray(e)&&e.forEach(function(e){e=e.substring(1,e.length-1);r=r.replaceAll("{".concat(e,"}"),t[e])}),r}},{key:"createRequestConfig",value:function(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[],i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],o=ConfigMapping.querystring(this._params[e],r),r=ConfigMapping.body(this._params[e],r),n=ConfigMapping.requestHeaders(this._headers[e],n),e=ConfigMapping.axiosConfig(this._configs[e],i),i="".concat(t).concat(o?(0<=t.lastIndexOf("?")?"&":"?")+o:"");return Object.assign(e,{headers:Object.assign(n,e.headers||null)}),{path:i,body:r,config:e,query:o}}},{key:"request",value:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},t=0<=t.indexOf("http")?t:this.config.baseURL+(0,_common.normalizePath)("/".concat(this.path||"","/").concat(t));return this.config.axios.request(Object.assign({method:e,url:t,data:r},n))}},{key:"requestWith",value:function(o){var a=this,f=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",s={},c=[],u={},p=this.config,n={with:function(e){e=_config.default.forName(e);return e&&(p=e),n},param:function(e){return Object.assign(s,_defineProperty({},e,Object.assign(s[e]||{},{required:1<arguments.length&&void 0!==arguments[1]&&arguments[1],body:!1}))),n},header:function(e,t){return Object.assign(u,_defineProperty({},e,t)),n},body:function(e){var t,r=s[e]||{};for(t in s)s[t].body=!1;return Object.assign(s,_defineProperty({},e,Object.assign(r,{required:!1,body:!0}))),n},config:function(e){return c.push(e),n},send:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=ConfigMapping.querystring(s,e),r=ConfigMapping.body(s,e),n=ConfigMapping.requestHeaders(u,[e]),i=ConfigMapping.axiosConfig(c,[e]);return Object.assign(i,{headers:Object.assign(n,i.headers||null)}),p?(0,_common.forward)(p.axios,p.origin,p.prefix,a.path,f,o,t,r,i):(n="".concat(a.pathVariable(f||"",e)).concat(t?(0<=f.lastIndexOf("?")?"&":"?")+t:""),a.request(o,n,r,i))}};return n}}]),n}());exports.default=Service;
@@ -0,0 +1 @@
1
+ "use strict";function CachePlugin(){return function(e){var t=e.axios.defaults.adapter;e.axios.defaults.adapter=function(e){return t(e)}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=CachePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios-annotations",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@github.com/sitorhy/axios-annotations.git"
@@ -1 +0,0 @@
1
- module.exports = require("../../lib/plugins/cache/index");