axios-annotations 1.1.10 → 1.2.0

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/README.md CHANGED
@@ -109,6 +109,7 @@ import RequestParam from "axios-annotations/decorator/request-param";
109
109
  import RequestMapping from "axios-annotations/decorator/request-mapping";
110
110
  import RequestBody from "axios-annotations/decorator/request-body";
111
111
  import RequestHeader from "axios-annotations/decorator/request-header";
112
+ import IgnoreResidualParams from "axios-annotations/decorator/ignore-residual-params";
112
113
 
113
114
  @RequestMapping("/api")
114
115
  export default class TestService extends Service {
@@ -123,11 +124,21 @@ export default class TestService extends Service {
123
124
  @RequestMapping("/path2", "POST")
124
125
  @RequestParam("p1", true)
125
126
  @RequestBody("p2")
126
- @RequestHeader("Content-Type", "text/plain")
127
+ @RequestHeader("Content-Type", "text/plain")
127
128
  post(p1, str2) {
128
129
  const defaultValue = {p1: "0x123456"};
129
130
  return Object.assign(defaultValue, {p1, p2: str2});
130
131
  }
132
+
133
+ @RequestMapping("/path", "GET")
134
+ @IgnoreResidualParams()
135
+ getDefault() {
136
+ return {
137
+ p1: "p1",
138
+ p2: "p2",
139
+ p3: "p3"
140
+ }
141
+ }
131
142
  }
132
143
  ```
133
144
 
@@ -525,6 +536,41 @@ import {authorizer} from "/path/config.js";
525
536
 
526
537
  + name : string `方法返回值属性,默认为 body`
527
538
 
539
+ #### IgnoreResidualParams(ignore?)
540
+ + ignore : boolean `拼接 QueryString 时是否忽略没有声明的参数`
541
+
542
+ ```javascript
543
+ // GET /foo?p1=p1&p2=p2&p3=p3
544
+ class TestService extends Service {
545
+ @RequestMapping("/foo", "GET")
546
+ @RequestParam("p1", true)
547
+ foo(token) {
548
+ return {
549
+ p1: "p1",
550
+ p2: "p2",
551
+ p3: "p3"
552
+ };
553
+ }
554
+ }
555
+ ```
556
+ 该注解对请求体没有影响。
557
+ ```javascript
558
+ // GET /foo?p1=p1
559
+ class TestService extends Service {
560
+ @RequestMapping("/foo", "GET")
561
+ @RequestParam("p1", true)
562
+ @IgnoreResidualParams()
563
+ foo(token) {
564
+ return {
565
+ p1: "p1",
566
+ p2: "p2",
567
+ p3: "p3"
568
+ };
569
+ }
570
+ }
571
+ ```
572
+
573
+
528
574
  ### Authorizer (Optional Plugin)
529
575
 
530
576
  + sessionKey : string `键值名称`
@@ -585,6 +631,7 @@ import "axios-annotations/decorator/request-body";
585
631
  import "axios-annotations/decorator/request-header";
586
632
  import "axios-annotations/decorator/request-config";
587
633
  import "axios-annotations/decorator/request-with";
634
+ import "axios-annotations/decorator/ignore-residual-params";
588
635
  ```
589
636
 
590
637
  + 更新开发工具以支持装饰器语法。
@@ -0,0 +1 @@
1
+ module.exports = require("../lib/decorator/ignore-residual-params");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.config=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var _global_configs=[],Config=function(){function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;_classCallCheck(this,r),_defineProperty(this,"_host","localhost"),_defineProperty(this,"_port",8080),_defineProperty(this,"_protocol","http"),_defineProperty(this,"_prefix",""),_defineProperty(this,"_axios",_axios.default.create()),_defineProperty(this,"_plugins",[]),this.init(t,e,n,i,o)}return _createClass(r,[{key:"init",value:function(t,e,n,i,o){this.port=n,t&&(this.protocol=t),e&&(this.host=e),i&&(this.prefix=i),Array.isArray(o)&&(this.plugins=o)}},{key:"host",get:function(){return this._host},set:function(t){this._host=t}},{key:"port",get:function(){return this._port},set:function(t){this._port=t}},{key:"protocol",get:function(){return this._protocol},set:function(t){this._protocol=t}},{key:"prefix",get:function(){return this._prefix},set:function(t){this._prefix=t}},{key:"origin",get:function(){return"".concat(this.protocol,"://").concat(this.host).concat(this.port?":"+this.port:"")}},{key:"baseURL",get:function(){return"".concat(this.origin).concat(this.prefix)}},{key:"axios",get:function(){return this._axios},set:function(t){this._axios=t}},{key:"plugins",get:function(){return this._plugins},set:function(t){this._plugins=t}},{key:"register",value:function(t){var e=this,n=_global_configs.find(function(t){return t.config===e});return n?n.name=t:_global_configs.push({name:t,config:this}),this}},{key:"unregister",value:function(){var e=this,t=_global_configs.findIndex(function(t){return t.config===e});return 0<=t&&_global_configs.splice(t,1),this}}],[{key:"forName",value:function(e){var t=_global_configs.find(function(t){return t.name===e});return t?t.config:null}}]),r}(),config=new(exports.default=Config);exports.config=config;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.config=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,o){return e&&_defineProperties(t.prototype,e),o&&_defineProperties(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}var _global_configs=[],Config=function(){function r(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:null;_classCallCheck(this,r),_defineProperty(this,"_host","localhost"),_defineProperty(this,"_port",8080),_defineProperty(this,"_protocol","http"),_defineProperty(this,"_prefix",""),_defineProperty(this,"_axios",_axios.default.create()),_defineProperty(this,"_plugins",[]),this.init(t,e,o,n,i)}return _createClass(r,[{key:"init",value:function(t,e,o,n,i){this.port=o,t&&(this.protocol=t),e&&(this.host=e),n&&(this.prefix=n),Array.isArray(i)&&(this.plugins=i)}},{key:"host",get:function(){return this._host},set:function(t){this._host=t}},{key:"port",get:function(){return this._port},set:function(t){this._port=t}},{key:"protocol",get:function(){return this._protocol},set:function(t){this._protocol=t}},{key:"prefix",get:function(){return this._prefix},set:function(t){this._prefix=t}},{key:"origin",get:function(){return"".concat(this.protocol,"://").concat(this.host).concat(this.port?":"+this.port:"")}},{key:"baseURL",get:function(){return"".concat(this.origin).concat(this.prefix)}},{key:"axios",get:function(){return this._axios},set:function(t){this._axios=t}},{key:"plugins",get:function(){return this._plugins},set:function(t){this._plugins=t}},{key:"register",value:function(t){var e=this,o=_global_configs.find(function(t){return t.config===e});return o?o.name=t:_global_configs.push({name:t,config:this}),this}},{key:"unregister",value:function(){var e=this,t=_global_configs.findIndex(function(t){return t.config===e});return 0<=t&&_global_configs.splice(t,1),this}}],[{key:"forName",value:function(e){var t=_global_configs.find(function(t){return t.name===e});return t?t.config:null}}]),r}(),config=new(exports.default=Config);exports.config=config;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _common=require("./common");function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,e){if(r){if("string"==typeof r)return _arrayLikeToArray(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,e):void 0}}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function _iterableToArrayLimit(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,a,o=[],i=!0,u=!1;try{for(t=t.call(r);!(i=(n=t.next()).done)&&(o.push(n.value),!e||o.length!==e);i=!0);}catch(r){u=!0,a=r}finally{try{i||null==t.return||t.return()}finally{if(u)throw a}}return o}}function _arrayWithHoles(r){if(Array.isArray(r))return r}var URLSearchParamsParser={encode:function(r){return"undefined"==typeof URLSearchParams?Object.entries(r).reduce(function(e,r){var r=_slicedToArray(r,2),t=r[0],r=r[1],r=void 0===r?void 0:r;return Array.isArray(r)?r.forEach(function(r){e.push("".concat(t,"=").concat(encodeURIComponent(null===r?"null":void 0===r?"":r)))}):e.push("".concat(t,"=").concat(encodeURIComponent(null===r?"null":void 0===r?"":r))),e},[]).join("&"):r.toString()},decode:function(r){return"undefined"==typeof URLSearchParams?Object.assign({},r):new URLSearchParams(r)},has:function(r,e){return"undefined"==typeof URLSearchParams?Object.hasOwnProperty.call(r,e):r.has(e)},delete:function(r,e){"undefined"==typeof URLSearchParams?r&&delete r[e]:r.delete(e)},get:function(r,e){return"undefined"==typeof URLSearchParams?r?r[e]:void 0:r.get(e)},append:function(r,e,t){var n;"undefined"==typeof URLSearchParams?r&&(n=r[e],(0,_common.isNullOrEmpty)(n)?r[e]=t:r[e]=[].concat(n).concat(t)):r.append(e,t)}},_default=URLSearchParamsParser;exports.default=_default;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _common=require("./common");function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,a,o,i,c=[],u=!0,l=!1;try{if(o=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(e){l=!0,a=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw a}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}var URLSearchParamsParser={encode:function(e){return"undefined"==typeof URLSearchParams?Object.entries(e).reduce(function(r,e){var e=_slicedToArray(e,2),t=e[0],e=e[1],e=void 0===e?void 0:e;return Array.isArray(e)?e.forEach(function(e){r.push("".concat(t,"=").concat(encodeURIComponent(null===e?"null":void 0===e?"":e)))}):r.push("".concat(t,"=").concat(encodeURIComponent(null===e?"null":void 0===e?"":e))),r},[]).join("&"):e.toString()},decode:function(e){return"undefined"==typeof URLSearchParams?Object.assign({},e):new URLSearchParams(e)},has:function(e,r){return"undefined"==typeof URLSearchParams?Object.hasOwnProperty.call(e,r):e.has(r)},delete:function(e,r){"undefined"==typeof URLSearchParams?e&&delete e[r]:e.delete(r)},get:function(e,r){return"undefined"==typeof URLSearchParams?e?e[r]:void 0:e.get(r)},append:function(e,r,t){var n;"undefined"==typeof URLSearchParams?e&&(n=e[r],(0,_common.isNullOrEmpty)(n)?e[r]=t:e[r]=[].concat(n).concat(t)):e.append(r,t)}},_default=URLSearchParamsParser;exports.default=_default;
@@ -2,6 +2,8 @@ import Config from "./config";
2
2
  import {AxiosPromise, AxiosRequestConfig} from "axios";
3
3
 
4
4
  export interface RequestController {
5
+ ignoreResidualParams: (ignore?: boolean) => RequestController;
6
+
5
7
  param: (key: string, required?: boolean) => RequestController;
6
8
 
7
9
  header: (header: string, value: string | ((...args: any[]) => string)) => RequestController;
@@ -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.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;
1
+ "use strict";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){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(_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 _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)}function _createForOfIteratorHelper(e,t){var r,n,i,o,a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(a)return n=!(r=!0),{s:function(){a=a.call(e)},n:function(){var e=a.next();return r=e.done,e},e:function(e){n=!0,i=e},f:function(){try{r||null==a.return||a.return()}finally{if(n)throw i}}};if(Array.isArray(e)||(a=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length)return a&&(e=a),o=0,{s:t=function(){},n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},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.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&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,_toPropertyKey(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=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}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,r){if(!r)return"";var n;if(t){var i,o=_parser.default.decode(r);for(i in r){var a=r[i],s=t[i];s?s.body?_parser.default.delete(o,i):s.required?(0,_common.isNullOrEmpty)(a)&&!_parser.default.has(o,i)&&_parser.default.append(o,i,""):(0,_common.isNullOrEmpty)(a)&&_parser.default.has(o,i)&&_parser.default.delete(o,i):e&&!0===e.ignoreResidualParams&&_parser.default.delete(o,i)}return _parser.default.encode(o)}return e&&!0===e.ignoreResidualParams?"":(n=_parser.default.decode(r),_parser.default.encode(n))},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",{}),_defineProperty(this,"_features",{}),!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(1===arguments.length)return this._for[e];Object.assign(this._for,_defineProperty({},e,t))}},{key:"features",value:function(e,t){if(1===arguments.length)return this._features[e];Object.assign(this._features,_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._features[e],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,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",f={},u=[],c={},p={},l=this.config,n={with:function(e){e=_config.default.forName(e);return e&&(l=e),n},param:function(e){return Object.assign(f,_defineProperty({},e,Object.assign(f[e]||{},{required:1<arguments.length&&void 0!==arguments[1]&&arguments[1],body:!1}))),n},ignoreResidualParams:function(){return Object.assign(p,{ignoreResidualParams:!0===(!(0<arguments.length&&void 0!==arguments[0])||arguments[0])}),n},header:function(e,t){return Object.assign(c,_defineProperty({},e,t)),n},body:function(e){var t,r=f[e]||{};for(t in f)f[t].body=!1;return Object.assign(f,_defineProperty({},e,Object.assign(r,{required:!1,body:!0}))),n},config:function(e){return u.push(e),n},send:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=ConfigMapping.querystring(p,f,e),r=ConfigMapping.body(f,e),n=ConfigMapping.requestHeaders(c,[e]),i=ConfigMapping.axiosConfig(u,[e]);return Object.assign(i,{headers:Object.assign(n,i.headers||null)}),l?(0,_common.forward)(l.axios,l.origin,l.prefix,a.path,s,o,t,r,i):(n="".concat(a.pathVariable(s||"",e)).concat(t?(0<=s.lastIndexOf("?")?"&":"?")+t:""),a.request(o,n,r,i))}};return n}}]),n}());exports.default=Service;
@@ -0,0 +1,3 @@
1
+ import {AxiosPromise} from "axios";
2
+
3
+ export default function IgnoreResidualParams(ignore?: boolean): (() => AxiosPromise<any>);
@@ -0,0 +1 @@
1
+ "use strict";function IgnoreResidualParams(){var s=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];return function(e,a,r){var t;r&&(t=r.value,r.value=function(){var e=Object.assign(this.features(a)||{},{ignoreResidualParams:!0===s});return this.features(a,e),t.apply(this,arguments)})}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=IgnoreResidualParams;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _storage=_interopRequireDefault(require("./storage")),_history=_interopRequireDefault(require("./history"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function asyncGeneratorStep(e,t,n,r,s,o,i){try{var a=e[o](i),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,s)}function _asyncToGenerator(a){return function(){var e=this,i=arguments;return new Promise(function(t,n){var r=a.apply(e,i);function s(e){asyncGeneratorStep(r,t,n,s,o,"next",e)}function o(e){asyncGeneratorStep(r,t,n,s,o,"throw",e)}s(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Authorizer=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_sessionKey","$_SESSION"),_defineProperty(this,"_sessionStorage",new _storage.default),_defineProperty(this,"_sessionHistory",new _history.default)}var t,n,r,s,o;return _createClass(e,[{key:"sessionKey",get:function(){return this._sessionKey},set:function(e){this._sessionKey=e}},{key:"sessionStorage",get:function(){return this._sessionStorage},set:function(e){this._sessionStorage=e}},{key:"sessionHistory",get:function(){return this._sessionHistory},set:function(e){this._sessionHistory=e}},{key:"getSession",value:(o=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionStorage.get(this.sessionKey);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)})),function(){return o.apply(this,arguments)})},{key:"storageSession",value:(s=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionStorage.set(this.sessionKey,t);case 2:case"end":return e.stop()}},e,this)})),function(e){return s.apply(this,arguments)})},{key:"refreshSession",value:(r=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}},e)})),function(e){return r.apply(this,arguments)})},{key:"withAuthentication",value:function(e,t){var n,r;t&&(n=t.access_token,r=t.accessToken,t=t.token,(n||r||t)&&(e.headers.Authorization="Bearer "+(n||r||t)))}},{key:"checkSession",value:function(e,t){e=e.headers.Authorization||e.headers.authorization,e=e&&e.split(" ")[1]||"";return(t.access_token||t.accessToken||t.token)!==e&&(!this.sessionHistory.size||!this.sessionHistory.check(e))}},{key:"checkResponse",value:function(e){return 401!==(e||{status:0}).status}},{key:"onAuthorizedDenied",value:(n=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:throw t;case 1:case"end":return e.stop()}},e)})),function(e){return n.apply(this,arguments)})},{key:"onSessionInvalidated",value:function(){}},{key:"invalidateSession",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionStorage.remove(this.sessionKey);case 2:this.onSessionInvalidated();case 3:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})}]),e}();exports.default=Authorizer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _storage=_interopRequireDefault(require("./storage")),_history=_interopRequireDefault(require("./history"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,u=t.hasOwnProperty,c=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o,i,a,s,e=e&&e.prototype instanceof h?e:h,e=Object.create(e.prototype),n=new b(n||[]);return c(e,"_invoke",{value:(o=t,i=r,a=n,s="suspendedStart",function(t,e){if("executing"===s)throw new Error("Generator is already running");if("completed"===s){if("throw"===t)throw e;return k()}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=void 0,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;n=f(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}(r,a);if(r){if(r===l)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===s)throw s="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);s="executing";r=f(o,i,a);if("normal"===r.type){if(s=a.done?"completed":"suspendedYield",r.arg===l)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(s="completed",a.method="throw",a.arg=r.arg)}})}),e}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=s;var l={};function h(){}function y(){}function p(){}var e={},v=(i(e,n,function(){return this}),Object.getPrototypeOf),v=v&&v(v(x([]))),d=(v&&v!==t&&u.call(v,n)&&(e=v),p.prototype=h.prototype=Object.create(e));function g(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function m(a,s){var e;c(this,"_invoke",{value:function(r,n){function t(){return new s(function(t,e){!function e(t,r,n,o){var i,t=f(a[t],a,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?s.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):s.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function x(e){if(e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(u.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t}).next=t}return{next:k}}function k(){return{value:void 0,done:!0}}return c(d,"constructor",{value:y.prototype=p,configurable:!0}),c(p,"constructor",{value:y,configurable:!0}),y.displayName=i(p,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,i(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t},a.awrap=function(t){return{__await:t}},g(m.prototype),i(m.prototype,r,function(){return this}),a.AsyncIterator=m,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new m(s(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},g(d),i(d,o,"Generator"),i(d,n,function(){return this}),i(d,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=x,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&u.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=void 0),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),s=u.call(o,"finallyLoc");if(a&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),w(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,w(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(s){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=s.apply(t,a);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var Authorizer=function(){function t(){_classCallCheck(this,t),_defineProperty(this,"_sessionKey","$_SESSION"),_defineProperty(this,"_sessionStorage",new _storage.default),_defineProperty(this,"_sessionHistory",new _history.default)}var e,r,n,o,i;return _createClass(t,[{key:"sessionKey",get:function(){return this._sessionKey},set:function(t){this._sessionKey=t}},{key:"sessionStorage",get:function(){return this._sessionStorage},set:function(t){this._sessionStorage=t}},{key:"sessionHistory",get:function(){return this._sessionHistory},set:function(t){this._sessionHistory=t}},{key:"getSession",value:(i=_asyncToGenerator(_regeneratorRuntime().mark(function t(){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sessionStorage.get(this.sessionKey);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)})),function(){return i.apply(this,arguments)})},{key:"storageSession",value:(o=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sessionStorage.set(this.sessionKey,e);case 2:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"refreshSession",value:(n=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null);case 1:case"end":return t.stop()}},t)})),function(t){return n.apply(this,arguments)})},{key:"withAuthentication",value:function(t,e){var r,n;e&&(r=e.access_token,n=e.accessToken,e=e.token,r||n||e)&&(t.headers.Authorization="Bearer "+(r||n||e))}},{key:"checkSession",value:function(t,e){t=t.headers.Authorization||t.headers.authorization,t=t&&t.split(" ")[1]||"";return!((e.access_token||e.accessToken||e.token)===t||this.sessionHistory.size&&this.sessionHistory.check(t))}},{key:"checkResponse",value:function(t){return 401!==(t||{status:0}).status}},{key:"onAuthorizedDenied",value:(r=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:throw e;case 1:case"end":return t.stop()}},t)})),function(t){return r.apply(this,arguments)})},{key:"onSessionInvalidated",value:function(){}},{key:"invalidateSession",value:(e=_asyncToGenerator(_regeneratorRuntime().mark(function t(){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.sessionStorage.remove(this.sessionKey);case 2:this.onSessionInvalidated();case 3:case"end":return t.stop()}},t,this)})),function(){return e.apply(this,arguments)})}]),t}();exports.default=Authorizer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _common=require("../../core/common");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 i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}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 SessionHistory=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_history",new Array(10)),_defineProperty(this,"_position",0),_defineProperty(this,"_size",0)}return _createClass(e,[{key:"size",get:function(){return this._size}},{key:"add",value:function(t){var e,r,i,n,s;Object.keys(t).every(function(e){return(0,_common.isNullOrEmpty)(t[e])})||(e=t.access_token,r=t.accessToken,i=t.token,n=t.refresh_token,s=t.refreshToken,this._history[this._position]=Object.assign({},t,{access_token:e||r||i,refresh_token:n||s,invalid:!1}),this._position++,this._position%=this._history.length,this._size=this._history.reduce(function(e,t){return t?e+1:e},0))}},{key:"check",value:function(i){return this._history.some(function(e){var t,r;return!!e&&(t=e.access_token,r=e.accessToken,e=e.token,(t||r||e)===i)})}},{key:"deprecate",value:function(e){var r=0,i=e.refresh_token,n=e.refreshToken,e=this._history.find(function(e,t){return r=t,!!e&&(e.refresh_token||e.refreshToken)===(i||n)});e&&(e.invalid=!0,e=this._history[0],this._history[0]=this._history[r],this._history[r]=e)}},{key:"clean",value:function(){for(var e=0;e<this._history.length;++e){var t=this._history[e];t&&t.invalid&&(this._history[e]=null)}this._size=this._history.reduce(function(e,t){return t?e+1:e},0)}},{key:"isDeprecated",value:function(i){return this._history.some(function(e){if(e){var t=i.refresh_token,r=i.refreshToken;if(t||r)return(e.refresh_token||e.refreshToken)===(t||r)&&e.invalid}return!1})}}]),e}();exports.default=SessionHistory;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _common=require("../../core/common");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)}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 o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}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=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}var SessionHistory=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_history",new Array(10)),_defineProperty(this,"_position",0),_defineProperty(this,"_size",0)}return _createClass(e,[{key:"size",get:function(){return this._size}},{key:"add",value:function(t){var e,r,o,i,n;Object.keys(t).every(function(e){return(0,_common.isNullOrEmpty)(t[e])})||(e=t.access_token,r=t.accessToken,o=t.token,i=t.refresh_token,n=t.refreshToken,this._history[this._position]=Object.assign({},t,{access_token:e||r||o,refresh_token:i||n,invalid:!1}),this._position++,this._position%=this._history.length,this._size=this._history.reduce(function(e,t){return t?e+1:e},0))}},{key:"check",value:function(o){return this._history.some(function(e){var t,r;return!!e&&(t=e.access_token,r=e.accessToken,e=e.token,(t||r||e)===o)})}},{key:"deprecate",value:function(e){var r=0,o=e.refresh_token,i=e.refreshToken,e=this._history.find(function(e,t){return r=t,!!e&&(e.refresh_token||e.refreshToken)===(o||i)});e&&(e.invalid=!0,e=this._history[0],this._history[0]=this._history[r],this._history[r]=e)}},{key:"clean",value:function(){for(var e=0;e<this._history.length;++e){var t=this._history[e];t&&t.invalid&&(this._history[e]=null)}this._size=this._history.reduce(function(e,t){return t?e+1:e},0)}},{key:"isDeprecated",value:function(o){return this._history.some(function(e){if(e){var t=o.refresh_token,r=o.refreshToken;if(t||r)return(e.refresh_token||e.refreshToken)===(t||r)&&e.invalid}return!1})}}]),e}();exports.default=SessionHistory;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=AuthorizationPlugin;var _queue=_interopRequireDefault(require("./queue"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function asyncGeneratorStep(e,r,t,n,s,a,o){try{var u=e[a](o),i=u.value}catch(e){return void t(e)}u.done?r(i):Promise.resolve(i).then(n,s)}function _asyncToGenerator(u){return function(){var e=this,o=arguments;return new Promise(function(r,t){var n=u.apply(e,o);function s(e){asyncGeneratorStep(n,r,t,s,a,"next",e)}function a(e){asyncGeneratorStep(n,r,t,s,a,"throw",e)}s(void 0)})}}function AuthorizationPlugin(u){return function(e){var r,t,s=!1,a=null,o=new _queue.default(u);e.axios.interceptors.response.use(function(e){return a&&(u.sessionHistory.add(a),a=null),e},(r=_asyncToGenerator(regeneratorRuntime.mark(function e(r){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.response,u.checkResponse(t)){e.next=66;break}if(s){e.next=61;break}return s=!0,e.next=6,u.getSession();case 6:if(n=e.sent,u.sessionHistory.isDeprecated(n))return e.prev=8,e.next=11,u.onAuthorizedDenied(r);e.next=21;break;case 11:u.sessionHistory.clean(),e.next=17;break;case 14:throw e.prev=14,e.t0=e.catch(8),r;case 17:return e.prev=17,s=!1,o.clear(),e.finish(17);case 21:if(a=n,u.checkSession(r.config,n)){e.next=48;break}return e.prev=23,e.t1=u,e.next=27,u.refreshSession(n);case 27:return e.t2=e.sent,e.next=30,e.t1.storageSession.call(e.t1,e.t2);case 30:e.next=48;break;case 32:return e.prev=32,e.t3=e.catch(23),u.sessionHistory.deprecate(n),e.prev=35,e.next=38,u.onAuthorizedDenied(e.t3);case 38:u.sessionHistory.clean(),e.next=44;break;case 41:throw e.prev=41,e.t4=e.catch(35),r;case 44:return e.prev=44,s=!1,o.clear(),e.finish(44);case 48:for(s=!1;o.size;)o.pop();return e.prev=50,e.next=53,o.resend(r);case 53:return e.abrupt("return",e.sent);case 56:throw e.prev=56,e.t5=e.catch(50),e.t5;case 59:e.next=64;break;case 61:return e.next=63,o.push(r);case 63:return e.abrupt("return",e.sent);case 64:e.next=67;break;case 66:throw r;case 67:case"end":return e.stop()}},e,null,[[8,14,17,21],[23,32],[35,41,44,48],[50,56]])})),function(e){return r.apply(this,arguments)})),e.axios.interceptors.request.use((t=_asyncToGenerator(regeneratorRuntime.mark(function e(r){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.getSession();case 2:return t=e.sent,u.withAuthentication(r,t),e.abrupt("return",r);case 5:case"end":return e.stop()}},e)})),function(e){return t.apply(this,arguments)}))}}
1
+ "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=AuthorizationPlugin;var _queue=_interopRequireDefault(require("./queue"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,u=t.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o,i,a,c,e=e&&e.prototype instanceof h?e:h,e=Object.create(e.prototype),n=new b(n||[]);return s(e,"_invoke",{value:(o=t,i=r,a=n,c="suspendedStart",function(t,e){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===t)throw e;return L()}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=void 0,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;n=f(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}(r,a);if(r){if(r===l)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";r=f(o,i,a);if("normal"===r.type){if(c=a.done?"completed":"suspendedYield",r.arg===l)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c="completed",a.method="throw",a.arg=r.arg)}})}),e}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var l={};function h(){}function p(){}function y(){}var e={},v=(i(e,n,function(){return this}),Object.getPrototypeOf),v=v&&v(v(_([]))),d=(v&&v!==t&&u.call(v,n)&&(e=v),y.prototype=h.prototype=Object.create(e));function g(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function m(a,c){var e;s(this,"_invoke",{value:function(r,n){function t(){return new c(function(t,e){!function e(t,r,n,o){var i,t=f(a[t],a,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?c.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):c.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function _(e){if(e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(u.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t}).next=t}return{next:L}}function L(){return{value:void 0,done:!0}}return s(d,"constructor",{value:p.prototype=y,configurable:!0}),s(y,"constructor",{value:p,configurable:!0}),p.displayName=i(y,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,i(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t},a.awrap=function(t){return{__await:t}},g(m.prototype),i(m.prototype,r,function(){return this}),a.AsyncIterator=m,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new m(c(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},g(d),i(d,o,"Generator"),i(d,n,function(){return this}),i(d,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=_,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&u.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=void 0),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,x(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=c.apply(t,a);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}function AuthorizationPlugin(c){return function(t){var e,r,o=!1,i=null,a=new _queue.default(c);t.axios.interceptors.response.use(function(t){return i&&(c.sessionHistory.add(i),i=null),t},(e=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){var r,n;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.response,c.checkResponse(r)){t.next=66;break}if(o){t.next=61;break}return o=!0,t.next=6,c.getSession();case 6:if(n=t.sent,c.sessionHistory.isDeprecated(n))return t.prev=8,t.next=11,c.onAuthorizedDenied(e);t.next=21;break;case 11:c.sessionHistory.clean(),t.next=17;break;case 14:throw t.prev=14,t.t0=t.catch(8),e;case 17:return t.prev=17,o=!1,a.clear(),t.finish(17);case 21:if(i=n,c.checkSession(e.config,n)){t.next=48;break}return t.prev=23,t.t1=c,t.next=27,c.refreshSession(n);case 27:return t.t2=t.sent,t.next=30,t.t1.storageSession.call(t.t1,t.t2);case 30:t.next=48;break;case 32:return t.prev=32,t.t3=t.catch(23),c.sessionHistory.deprecate(n),t.prev=35,t.next=38,c.onAuthorizedDenied(t.t3);case 38:c.sessionHistory.clean(),t.next=44;break;case 41:throw t.prev=41,t.t4=t.catch(35),e;case 44:return t.prev=44,o=!1,a.clear(),t.finish(44);case 48:for(o=!1;a.size;)a.pop();return t.prev=50,t.next=53,a.resend(e);case 53:return t.abrupt("return",t.sent);case 56:throw t.prev=56,t.t5=t.catch(50),t.t5;case 59:t.next=64;break;case 61:return t.next=63,a.push(e);case 63:return t.abrupt("return",t.sent);case 64:t.next=67;break;case 66:throw e;case 67:case"end":return t.stop()}},t,null,[[8,14,17,21],[23,32],[35,41,44,48],[50,56]])})),function(t){return e.apply(this,arguments)})),t.axios.interceptors.request.use((r=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){var r;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.getSession();case 2:return r=t.sent,c.withAuthentication(e,r),t.abrupt("return",e);case 5:case"end":return t.stop()}},t)})),function(t){return r.apply(this,arguments)}))}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function asyncGeneratorStep(e,r,t,n,i,o,a){try{var u=e[o](a),s=u.value}catch(e){return void t(e)}u.done?r(s):Promise.resolve(s).then(n,i)}function _asyncToGenerator(u){return function(){var e=this,a=arguments;return new Promise(function(r,t){var n=u.apply(e,a);function i(e){asyncGeneratorStep(n,r,t,i,o,"next",e)}function o(e){asyncGeneratorStep(n,r,t,i,o,"throw",e)}i(void 0)})}}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function random(e,r){return(Math.random()*(r-e+1)|0)+e}function sleep(t){return new Promise(function(e){var r=setTimeout(function(){clearTimeout(r),r=void 0,e()},t)})}var PendingQueue=function(){function r(e){_classCallCheck(this,r),_defineProperty(this,"_queue",[]),_defineProperty(this,"_authorizer",null),_defineProperty(this,"_axios",_axios.default.create()),this._authorizer=e}var t;return _createClass(r,[{key:"resend",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(r){var t,n,i,o=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=1<o.length&&void 0!==o[1]?o[1]:3,n=0;case 2:if(!(n<t)){e.next=25;break}if(0<n)return e.next=6,sleep(random(3e3,5e3));e.next=6;break;case 6:return e.next=8,this._authorizer.getSession();case 8:if(i=e.sent,this._authorizer.sessionHistory.isDeprecated(i))throw r;e.next=11;break;case 11:return e.prev=11,this._authorizer.withAuthentication(r.config,i),e.next=15,this._axios.request(r.config);case 15:return e.abrupt("return",e.sent);case 18:if(e.prev=18,e.t0=e.catch(11),t-1<=n)throw e.t0;e.next=22;break;case 22:++n,e.next=2;break;case 25:case"end":return e.stop()}},e,this,[[11,18]])})),function(e){return t.apply(this,arguments)})},{key:"push",value:function(t){var n=this;return new Promise(function(e,r){n._queue.push({error:t,resolve:e,reject:r})})}},{key:"pop",value:function(){var e=this._queue.shift(),r=e.error,t=e.resolve,e=e.reject;this.resend(r).then(t).catch(e)}},{key:"clear",value:function(){this._queue.splice(0).forEach(function(e){var r=e.error;(0,e.reject)(r)})}},{key:"size",get:function(){return this._queue.length}}]),r}();exports.default=PendingQueue;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _axios=_interopRequireDefault(require("axios"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,c=t.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o,i,a,u,e=e&&e.prototype instanceof h?e:h,e=Object.create(e.prototype),n=new b(n||[]);return s(e,"_invoke",{value:(o=t,i=r,a=n,u="suspendedStart",function(t,e){if("executing"===u)throw new Error("Generator is already running");if("completed"===u){if("throw"===t)throw e;return P()}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=void 0,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;n=f(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}(r,a);if(r){if(r===l)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===u)throw u="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u="executing";r=f(o,i,a);if("normal"===r.type){if(u=a.done?"completed":"suspendedYield",r.arg===l)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(u="completed",a.method="throw",a.arg=r.arg)}})}),e}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=u;var l={};function h(){}function p(){}function y(){}var e={},v=(i(e,n,function(){return this}),Object.getPrototypeOf),v=v&&v(v(x([]))),d=(v&&v!==t&&c.call(v,n)&&(e=v),y.prototype=h.prototype=Object.create(e));function m(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function g(a,u){var e;s(this,"_invoke",{value:function(r,n){function t(){return new u(function(t,e){!function e(t,r,n,o){var i,t=f(a[t],a,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&c.call(r,"__await")?u.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):u.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function w(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function x(e){if(e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(c.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t}).next=t}return{next:P}}function P(){return{value:void 0,done:!0}}return s(d,"constructor",{value:p.prototype=y,configurable:!0}),s(y,"constructor",{value:p,configurable:!0}),p.displayName=i(y,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,i(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t},a.awrap=function(t){return{__await:t}},m(g.prototype),i(g.prototype,r,function(){return this}),a.AsyncIterator=g,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new g(u(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},m(d),i(d,o,"Generator"),i(d,n,function(){return this}),i(d,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=x,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!t)for(var e in this)"t"===e.charAt(0)&&c.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=void 0),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=c.call(o,"catchLoc"),u=c.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&c.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),w(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,w(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(u){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=u.apply(t,a);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}function random(t,e){return(Math.random()*(e-t+1)|0)+t}function sleep(r){return new Promise(function(t){var e=setTimeout(function(){clearTimeout(e),e=void 0,t()},r)})}var PendingQueue=function(){function e(t){_classCallCheck(this,e),_defineProperty(this,"_queue",[]),_defineProperty(this,"_authorizer",null),_defineProperty(this,"_axios",_axios.default.create()),this._authorizer=t}var r;return _createClass(e,[{key:"resend",value:(r=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){var r,n,o,i=arguments;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=1<i.length&&void 0!==i[1]?i[1]:3,n=0;case 2:if(n<r){if(0<n)return t.next=6,sleep(random(3e3,5e3));t.next=6}else t.next=25;break;case 6:return t.next=8,this._authorizer.getSession();case 8:if(o=t.sent,this._authorizer.sessionHistory.isDeprecated(o))throw e;t.next=11;break;case 11:return t.prev=11,this._authorizer.withAuthentication(e.config,o),t.next=15,this._axios.request(e.config);case 15:return t.abrupt("return",t.sent);case 18:if(t.prev=18,t.t0=t.catch(11),r-1<=n)throw t.t0;t.next=22;break;case 22:++n,t.next=2;break;case 25:case"end":return t.stop()}},t,this,[[11,18]])})),function(t){return r.apply(this,arguments)})},{key:"push",value:function(r){var n=this;return new Promise(function(t,e){n._queue.push({error:r,resolve:t,reject:e})})}},{key:"pop",value:function(){var t=this._queue.shift(),e=t.error,r=t.resolve,t=t.reject;this.resend(e).then(r).catch(t)}},{key:"clear",value:function(){this._queue.splice(0).forEach(function(t){var e=t.error;(0,t.reject)(e)})}},{key:"size",get:function(){return this._queue.length}}]),e}();exports.default=PendingQueue;
@@ -1 +1 @@
1
- "use strict";function asyncGeneratorStep(e,t,r,n,o,a,i){try{var s=e[a](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(s){return function(){var e=this,i=arguments;return new Promise(function(t,r){var n=s.apply(e,i);function o(e){asyncGeneratorStep(n,t,r,o,a,"next",e)}function a(e){asyncGeneratorStep(n,t,r,o,a,"throw",e)}o(void 0)})}}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}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var SessionStorage=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"_inMemoryStorage",{})}var t,r,n;return _createClass(e,[{key:"set",value:(n=_asyncToGenerator(regeneratorRuntime.mark(function e(t,r){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:window&&window.sessionStorage?window.sessionStorage.setItem(t,JSON.stringify(r)):wx&&wx.setStorageSync?wx.setStorageSync(t,r):my&&my.setStorageSync?my.setStorageSync(t,r):tt&&tt.setStorageSync?tt.setStorageSync(t,r):this._inMemoryStorage[t]=r;case 1:case"end":return e.stop()}},e,this)})),function(e,t){return n.apply(this,arguments)})},{key:"get",value:(r=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(window&&window.sessionStorage)return r=window.sessionStorage.getItem(t),e.abrupt("return",JSON.parse(r));e.next=5;break;case 5:if(wx&&wx.getStorageSync)return e.abrupt("return",wx.getStorageSync(t));e.next=9;break;case 9:if(my&&my.getStorageSync)return e.abrupt("return",my.getStorageSync(t));e.next=13;break;case 13:if(tt&&tt.getStorageSync)return e.abrupt("return",tt.getStorageSync(t));e.next=17;break;case 17:return e.abrupt("return",this._inMemoryStorage[t]);case 18:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"remove",value:(t=_asyncToGenerator(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:window&&window.sessionStorage?window.sessionStorage.removeItem(t):wx&&wx.removeStorageSync?wx.removeStorageSync(t):my&&my.removeStorageSync?my.removeStorageSync(t):tt&&tt.removeStorageSync?tt.removeStorageSync(t):delete this._inMemoryStorage[t];case 1:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})}]),e}();exports.default=SessionStorage;
1
+ "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,u=t.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",r=e.asyncIterator||"@@asyncIterator",o=e.toStringTag||"@@toStringTag";function i(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o,i,a,c,e=e&&e.prototype instanceof y?e:y,e=Object.create(e.prototype),n=new b(n||[]);return s(e,"_invoke",{value:(o=t,i=r,a=n,c="suspendedStart",function(t,e){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===t)throw e;return x()}for(a.method=t,a.arg=e;;){var r=a.delegate;if(r){r=function t(e,r){var n=r.method,o=e.iterator[n];if(void 0===o)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=void 0,t(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;n=f(o,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,l;o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}(r,a);if(r){if(r===l)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";r=f(o,i,a);if("normal"===r.type){if(c=a.done?"completed":"suspendedYield",r.arg===l)continue;return{value:r.arg,done:a.done}}"throw"===r.type&&(c="completed",a.method="throw",a.arg=r.arg)}})}),e}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var l={};function y(){}function h(){}function p(){}var e={},g=(i(e,n,function(){return this}),Object.getPrototypeOf),g=g&&g(g(_([]))),v=(g&&g!==t&&u.call(g,n)&&(e=g),p.prototype=y.prototype=Object.create(e));function d(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function m(a,c){var e;s(this,"_invoke",{value:function(r,n){function t(){return new c(function(t,e){!function e(t,r,n,o){var i,t=f(a[t],a,r);if("throw"!==t.type)return(r=(i=t.arg).value)&&"object"==_typeof(r)&&u.call(r,"__await")?c.resolve(r.__await).then(function(t){e("next",t,n,o)},function(t){e("throw",t,n,o)}):c.resolve(r).then(function(t){i.value=t,n(i)},function(t){return e("throw",t,n,o)});o(t.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}})}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function b(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function _(e){if(e){var r,t=e[n];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return r=-1,(t=function t(){for(;++r<e.length;)if(u.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t}).next=t}return{next:x}}function x(){return{value:void 0,done:!0}}return s(v,"constructor",{value:h.prototype=p,configurable:!0}),s(p,"constructor",{value:h,configurable:!0}),h.displayName=i(p,o,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,i(t,o,"GeneratorFunction")),t.prototype=Object.create(v),t},a.awrap=function(t){return{__await:t}},d(m.prototype),i(m.prototype,r,function(){return this}),a.AsyncIterator=m,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new m(c(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},d(v),i(v,o,"Generator"),i(v,n,function(){return this}),i(v,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,r=Object(t),n=[];for(e in r)n.push(e);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=_,b.prototype={constructor:b,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&u.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type="throw",i.arg=r,n.next=t,e&&(n.method="next",n.arg=void 0),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=u.call(o,"catchLoc"),c=u.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}var i=(o=o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc?null:o)?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r,n,o=this.tryEntries[e];if(o.tryLoc===t)return"throw"===(r=o.completion).type&&(n=r.arg,S(o)),n}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(c){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=c.apply(t,a);function o(t){asyncGeneratorStep(n,e,r,o,i,"next",t)}function i(t){asyncGeneratorStep(n,e,r,o,i,"throw",t)}o(void 0)})}}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var SessionStorage=function(){function t(){_classCallCheck(this,t),_defineProperty(this,"_inMemoryStorage",{})}var e,r,n;return _createClass(t,[{key:"set",value:(n=_asyncToGenerator(_regeneratorRuntime().mark(function t(e,r){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:window&&window.sessionStorage?window.sessionStorage.setItem(e,JSON.stringify(r)):wx&&wx.setStorageSync?wx.setStorageSync(e,r):my&&my.setStorageSync?my.setStorageSync(e,r):tt&&tt.setStorageSync?tt.setStorageSync(e,r):this._inMemoryStorage[e]=r;case 1:case"end":return t.stop()}},t,this)})),function(t,e){return n.apply(this,arguments)})},{key:"get",value:(r=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){var r;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(window&&window.sessionStorage)return r=window.sessionStorage.getItem(e),t.abrupt("return",JSON.parse(r));t.next=5;break;case 5:if(wx&&wx.getStorageSync)return t.abrupt("return",wx.getStorageSync(e));t.next=9;break;case 9:if(my&&my.getStorageSync)return t.abrupt("return",my.getStorageSync(e));t.next=13;break;case 13:if(tt&&tt.getStorageSync)return t.abrupt("return",tt.getStorageSync(e));t.next=17;break;case 17:return t.abrupt("return",this._inMemoryStorage[e]);case 18:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"remove",value:(e=_asyncToGenerator(_regeneratorRuntime().mark(function t(e){return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:window&&window.sessionStorage?window.sessionStorage.removeItem(e):wx&&wx.removeStorageSync?wx.removeStorageSync(e):my&&my.removeStorageSync?my.removeStorageSync(e):tt&&tt.removeStorageSync?tt.removeStorageSync(e):delete this._inMemoryStorage[e];case 1:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})}]),t}();exports.default=SessionStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios-annotations",
3
- "version": "1.1.10",
3
+ "version": "1.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@github.com/sitorhy/axios-annotations.git"