diff --git a/packages/errors/src/final-catch.js b/packages/errors/src/final-catch.js index b6908f10e39a00d6369addb5a84c708f9217e74a..0c849324540eec909630e8d3a061a70e315d68d7 100644 --- a/packages/errors/src/final-catch.js +++ b/packages/errors/src/final-catch.js @@ -16,6 +16,20 @@ import JsonqlServerError from './server-error'; import { NO_ERROR_MSG } from 'jsonql-constants'; +/** + * If using the instance of could not find the actual error then + * we need to use a different way to analysis the error object to find the exact + * Error type + * @param {object} e error + * @param {*} msg message + * @param {*} detail the full detail + * @return {boolean} if this is false then not found + */ +function getErrorByObject(e, msg, detail) { + +} + + /** * this will put into generator call at the very end and catch * the error throw from inside then throw again @@ -34,6 +48,8 @@ export default function finalCatch(e) { } const msg = e.message || NO_ERROR_MSG; const detail = e.detail || e; + // @BUG the instance of not always work for some reason! + // need to figure out a better way to find out the type of the error switch (true) { case e instanceof Jsonql406Error: throw new Jsonql406Error(msg, detail) diff --git a/packages/http-client/core.js b/packages/http-client/core.js index f9e10ff89e3328245e587ecb38431ba3f4d59b0c..1e62e9a5f4b02b8e886cca9b9b23a4c2344cf0f2 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b=Array.isArray,_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m="object"==typeof _&&_&&_.Object===Object&&_,w="object"==typeof self&&self&&self.Object===Object&&self,j=m||w||Function("return this")(),S=j.Symbol,O=Object.prototype,A=O.hasOwnProperty,k=O.toString,E=S?S.toStringTag:void 0;var T=Object.prototype.toString;var x="[object Null]",q="[object Undefined]",P=S?S.toStringTag:void 0;function C(t){return null==t?void 0===t?q:x:P&&P in Object(t)?function(t){var e=A.call(t,E),r=t[E];try{t[E]=void 0;var n=!0}catch(t){}var o=k.call(t);return n&&(e?t[E]=r:delete t[E]),o}(t):function(t){return T.call(t)}(t)}function $(t,e){return function(r){return t(e(r))}}var z=$(Object.getPrototypeOf,Object);function N(t){return null!=t&&"object"==typeof t}var M="[object Object]",R=Function.prototype,F=Object.prototype,J=R.toString,I=F.hasOwnProperty,U=J.call(Object);function D(t){if(!N(t)||C(t)!=M)return!1;var e=z(t);if(null===e)return!0;var r=I.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&J.call(r)==U}var H=function(t){return b(t)?t:[t]},L=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},K=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),B=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),V=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),G=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),W=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),nt=Object.freeze({__proto__:null,Jsonql406Error:K,Jsonql500Error:B,JsonqlAuthorisationError:V,JsonqlContractAuthError:G,JsonqlResolverAppError:W,JsonqlResolverNotFoundError:Y,JsonqlEnumError:Q,JsonqlTypeError:X,JsonqlCheckerError:Z,JsonqlValidationError:tt,JsonqlError:et,JsonqlServerError:rt}),ot=et,it=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function at(t){if(it(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&nt[o])throw new nt[r](i,a);throw new ot(i,a)}return t}function ut(t){if(Array.isArray(t))throw new tt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof K:throw new K(e,r);case t instanceof B:throw new B(e,r);case t instanceof V:throw new V(e,r);case t instanceof G:throw new G(e,r);case t instanceof W:throw new W(e,r);case t instanceof Y:throw new Y(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof rt:throw new rt(e,r);default:throw new et(e,r)}}function ct(t){return!!function(t){return D(t)&&(L(t,r)||L(t,n)||L(t,o))}(t)&&t}function st(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ft=function(t,e){return void 0===e&&(e={}),ct(e)?Promise.resolve(e):t.getContract()},lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function pt(t){this.message=t}pt.prototype=new Error,pt.prototype.name="InvalidCharacterError";var ht="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new pt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=lt.indexOf(n);return a};var dt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ht(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ht(e)}};function vt(t){this.message=t}vt.prototype=new Error,vt.prototype.name="InvalidTokenError";var gt=function(t,e){if("string"!=typeof t)throw new vt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(dt(t.split(".")[r]))}catch(t){throw new vt("Invalid token specified: "+t.message)}},yt=vt;function bt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&Et(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Ht="[object String]";function Lt(t){return"string"==typeof t||!b(t)&&N(t)&&C(t)==Ht}var Kt=function(t){return""!==Dt(t)&&Lt(t)},Bt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Vt(t){if(Kt(t))return function(t){var e=t.iat||Bt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new et("Token has expired on "+r,t)}return t}(gt(t));throw new et("Token must be a string!")}var Gt=function(t){return!!b(t)||null!=t&&""!==Dt(t)},Wt="[object Number]";function Yt(t){return function(t){return"number"==typeof t||N(t)&&C(t)==Wt}(t)&&t!=+t}var Qt=function(t){return!Lt(t)&&!Yt(parseFloat(t))},Xt=function(t){return null!=t&&"boolean"==typeof t},Zt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Dt(t)&&(!1===e||!0===e&&null!==t)},te=s,ee=f,re=l,ne=p,oe=h,ie=d,ae="continue",ue=function(t){switch(t){case"number":return Qt;case"string":return Kt;case"boolean":return Xt;default:return Zt}},ce=function(t,e){return void 0===e&&(e=""),!!b(t)&&(""===e||""===Dt(e)||!(t.filter((function(t){return!ue(e)(t)})).length>0))},se=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},fe=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ue(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ce(r,t)})).length};var le,pe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[le?a:++n];if(!1===e(o[u],u,o))break}return t};var he="[object Arguments]";function de(t){return N(t)&&C(t)==he}var ve=Object.prototype,ge=ve.hasOwnProperty,ye=ve.propertyIsEnumerable,be=de(function(){return arguments}())?de:function(t){return N(t)&&ge.call(t,"callee")&&!ye.call(t,"callee")};var _e="object"==typeof exports&&exports&&!exports.nodeType&&exports,me=_e&&"object"==typeof module&&module&&!module.nodeType&&module,we=me&&me.exports===_e?j.Buffer:void 0,je=(we?we.isBuffer:void 0)||function(){return!1},Se=9007199254740991,Oe=/^(?:0|[1-9]\d*)$/;function Ae(t,e){var r=typeof t;return!!(e=null==e?Se:e)&&("number"==r||"symbol"!=r&&Oe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ke}var Te={};Te["[object Float32Array]"]=Te["[object Float64Array]"]=Te["[object Int8Array]"]=Te["[object Int16Array]"]=Te["[object Int32Array]"]=Te["[object Uint8Array]"]=Te["[object Uint8ClampedArray]"]=Te["[object Uint16Array]"]=Te["[object Uint32Array]"]=!0,Te["[object Arguments]"]=Te["[object Array]"]=Te["[object ArrayBuffer]"]=Te["[object Boolean]"]=Te["[object DataView]"]=Te["[object Date]"]=Te["[object Error]"]=Te["[object Function]"]=Te["[object Map]"]=Te["[object Number]"]=Te["[object Object]"]=Te["[object RegExp]"]=Te["[object Set]"]=Te["[object String]"]=Te["[object WeakMap]"]=!1;var xe,qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pe=qe&&"object"==typeof module&&module&&!module.nodeType&&module,Ce=Pe&&Pe.exports===qe&&m.process,$e=function(){try{var t=Pe&&Pe.require&&Pe.require("util").types;return t||Ce&&Ce.binding&&Ce.binding("util")}catch(t){}}(),ze=$e&&$e.isTypedArray,Ne=ze?(xe=ze,function(t){return xe(t)}):function(t){return N(t)&&Ee(t.length)&&!!Te[C(t)]},Me=Object.prototype.hasOwnProperty;function Re(t,e){var r=b(t),n=!r&&be(t),o=!r&&!n&&je(t),i=!r&&!n&&!o&&Ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},tr.prototype.set=function(t,e){var r=this.__data__,n=Xe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var er,rr=j["__core-js_shared__"],nr=(er=/[^.]+$/.exec(rr&&rr.keys&&rr.keys.IE_PROTO||""))?"Symbol(src)_1."+er:"";var or=Function.prototype.toString;function ir(t){if(null!=t){try{return or.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ar=/^\[object .+?Constructor\]$/,ur=Function.prototype,cr=Object.prototype,sr=ur.toString,fr=cr.hasOwnProperty,lr=RegExp("^"+sr.call(fr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pr(t){return!(!De(t)||function(t){return!!nr&&nr in t}(t))&&(Ve(t)?lr:ar).test(ir(t))}function hr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return pr(r)?r:void 0}var dr=hr(j,"Map"),vr=hr(Object,"create");var gr="__lodash_hash_undefined__",yr=Object.prototype.hasOwnProperty;var br=Object.prototype.hasOwnProperty;var _r="__lodash_hash_undefined__";function mr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&xr?new kr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=se(t))?!fe({arg:r},e):!ue(t)(r))})).length)})).length}return!1},Yn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Wn,null,a);case"array"===t:return!ce(e.arg);case!1!==(r=se(t)):return!fe(e,r);default:return!ue(t)(e.arg)}},Qn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Xn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ce(e))throw new et("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ce(t))throw new et("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Qn(t,a):t,index:r,param:a,optional:i}}));default:throw new et("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Gt(e)&&!(r.type.length>r.type.filter((function(e){return Yn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Yn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Zn=function(){try{var t=hr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function to(t,e,r){"__proto__"==e&&Zn?Zn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function eo(t,e,r){(void 0===r||Qe(t[e],r))&&(void 0!==r||e in t)||to(t,e,r)}var ro="object"==typeof exports&&exports&&!exports.nodeType&&exports,no=ro&&"object"==typeof module&&module&&!module.nodeType&&module,oo=no&&no.exports===ro?j.Buffer:void 0,io=oo?oo.allocUnsafe:void 0;function ao(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pr(n).set(new Pr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var uo=Object.create,co=function(){function t(){}return function(e){if(!De(e))return{};if(uo)return uo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function so(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var fo=Object.prototype.hasOwnProperty;function lo(t,e,r){var n=t[e];fo.call(t,e)&&Qe(n,r)&&(void 0!==r||e in t)||to(t,e,r)}var po=Object.prototype.hasOwnProperty;function ho(t){if(!De(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Je(t),r=[];for(var n in t)("constructor"!=n||!e&&po.call(t,n))&&r.push(n);return r}function vo(t){return Ge(t)?Re(t,!0):ho(t)}function go(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=jo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(wo);function ko(t,e){return Ao(function(t,e,r){return e=mo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=mo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Eo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!De(r))return!1;var n=typeof e;return!!("number"==n?Ge(r)&&Ae(e,r.length):"string"==n&&e in r)&&Qe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=qi().key(e);t(Pi(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}};function qi(){return Ti.localStorage}function Pi(t){return qi().getItem(t)}var Ci=pi.trim,$i={name:"cookieStorage",read:function(t){if(!t||!Ri(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(zi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;zi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ni,remove:Mi,clearAll:function(){Ni((function(t,e){Mi(e)}))}},zi=pi.Global.document;function Ni(t){for(var e=zi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Ci(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Mi(t){t&&Ri(t)&&(zi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Ri(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(zi.cookie)}var Fi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Ji="expire_mixin",Ii=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+Ji);return{set:function(e,r,n,o){this.hasNamespace(Ji)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(Ji)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(Ji)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Gi=[xi,$i],Wi=[Fi,Ii,Ki,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Vi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Vi.compress(this._serialize(r));t(e,n)}}}],Yi=Ai.createStore(Gi,Wi),Qi=pi.Global;function Xi(){return Qi.sessionStorage}function Zi(t){return Xi().getItem(t)}var ta=[{name:"sessionStorage",read:Zi,write:function(t,e){return Xi().setItem(t,e)},each:function(t){for(var e=Xi().length-1;e>=0;e--){var r=Xi().key(e);t(Zi(r),r)}},remove:function(t){return Xi().removeItem(t)},clearAll:function(){return Xi().clear()}},$i],ea=[Fi,Ii],ra=Ai.createStore(ta,ea),na=Yi,oa=ra,ia=function(t){var e;return(e={}).args=t,e};function aa(t,e){var r;return(r={})[t]=e,r[u]=[ai()],r}var ua=function(t){return L(t,"data")&&!L(t,"error")?t.data:t},ca=function(t){this.opts=t,this.instanceKey=st(this.opts.hostname)+"",this.localStore=na,this.sessionStore=oa},sa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ca.prototype.__setMethod=function(t,e){var r,n=this[t],o=(this.__getMethod(t),this.opts.storageKey),i=this.instanceKey;n.set(o,((r={})[i]=n?To({},n,e):e,r))},ca.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ca.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ca.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},sa.lset.set=function(t){return this.__setMethod("localStore",t)},sa.lget.get=function(){return this.__getMethod("localStore")},ca.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ca.prototype.lclear=function(){return this.__clearMethod("localStore")},sa.sset.set=function(t){return this.__setMethod("sessionStore",t)},sa.sget.get=function(){return this.__getMethod("sessionStore")},ca.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ca.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ca.prototype,sa);var fa=c[0],la=c[1],pa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},r.jsonqlToken.set=function(t){var e;this.sset=((e={}).jsonqlcredential=t,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlToken.get=function(){var t=this.sget;return!!t&&t.jsonqlcredential},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Vt)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ct(t))throw new tt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ct(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=To({},{_cb:ai()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=To({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=To({},{method:fa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ua(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ri(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ua(o)}),(function(t){throw e.cleanUp(),console.error(t),new rt("Server side error",t)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?To({},e,this.getAuthHeader(),this.extraHeader):To({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=To({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(at).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new rt("getRemoteContract",t)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Lt(t)&&b(e)){var n=ia(e);return!0===r?n:aa(t,n)}throw new tt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(at)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Lt(t))return aa(t,o);throw new tt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:la}).then(at)},Object.defineProperties(r.prototype,n),r}(ca)))),ha=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,H(t))}),Reflect.apply(t,null,r))}};function da(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function va(t,e,r,n){void 0===n&&(n=!1);var o=da(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var ga=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ni(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ut)}},ya=function(t,e,r,n,o){var i={},a=function(t){i=va(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ni(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ut)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},ba=function(t,e,r,n,o){var i={},a=function(t){i=va(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return ni(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ut)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},_a=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ga(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ga(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var ma=function(t,e,r,n){var o=function(t,e,r,n){return ha(ya,ba,_a)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata},o.getToken=function(){return t.rawAuthToken}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.5.0",o},wa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ja={hostname:oi(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:oi("jsonql",["string"]),loginHandlerName:oi("login",["string"]),logoutHandlerName:oi("logout",["string"]),enableJsonp:oi(!1,["boolean"]),enableAuth:oi(!1,["boolean"]),useJwt:oi(!0,["boolean"]),persistToken:oi(!1,["boolean","number"]),useLocalstorage:oi(!0,["boolean"]),storageKey:oi("jsonqlstore",["string"]),authKey:oi("jsonqlauthkey",["string"]),contractExpired:oi(0,["number"]),keepContract:oi(!0,["boolean"]),exposeContract:oi(!1,["boolean"]),showContractDesc:oi(!1,["boolean"]),contractKey:oi(!1,["boolean"]),contractKeyName:oi("X-JSONQL-CV-KEY",["string"]),enableTimeout:oi(!1,["boolean"]),timeout:oi(5e3,["number"]),returnInstance:oi(!1,["boolean"]),allowReturnRawToken:oi(!1,["boolean"]),debugOn:oi(!1,["boolean"])};function Sa(t){return da(t,v)?Promise.resolve(t):function(t){var e=t.contract;return ii(t,ja,wa).then((function(t){return t.contract=e,t}))}(t)}var Oa=new WeakMap,Aa=new WeakMap,ka=function(){this.__suspend__=null,this.queueStore=new Set},Ea={$suspend:{configurable:!0},$queues:{configurable:!0}};Ea.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},ka.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ea.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ka.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(ka.prototype,Ea);var Ta=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Oa.set(this,t)},r.normalStore.get=function(){return Oa.get(this)},r.lazyStore.set=function(t){Aa.set(this,t)},r.lazyStore.get=function(){return Aa.get(this)},e.prototype.hashFnToKey=function(t){return st(t.toString())+""},Object.defineProperties(e.prototype,r),e}(ka));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Sa(e).then((function(t){return{baseClient:new pa(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ft(r,n.contract).then((function(e){return ma(r,n,e,t)}))}))}((r=e.debugOn,new Ta({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b=Array.isArray,_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m="object"==typeof _&&_&&_.Object===Object&&_,w="object"==typeof self&&self&&self.Object===Object&&self,j=m||w||Function("return this")(),S=j.Symbol,O=Object.prototype,k=O.hasOwnProperty,A=O.toString,E=S?S.toStringTag:void 0;var T=Object.prototype.toString;var x="[object Null]",P="[object Undefined]",q=S?S.toStringTag:void 0;function C(t){return null==t?void 0===t?P:x:q&&q in Object(t)?function(t){var e=k.call(t,E),r=t[E];try{t[E]=void 0;var n=!0}catch(t){}var o=A.call(t);return n&&(e?t[E]=r:delete t[E]),o}(t):function(t){return T.call(t)}(t)}function $(t,e){return function(r){return t(e(r))}}var z=$(Object.getPrototypeOf,Object);function N(t){return null!=t&&"object"==typeof t}var M="[object Object]",I=Function.prototype,R=Object.prototype,F=I.toString,J=R.hasOwnProperty,U=F.call(Object);function D(t){if(!N(t)||C(t)!=M)return!1;var e=z(t);if(null===e)return!0;var r=J.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&F.call(r)==U}var H=function(t){return b(t)?t:[t]},L=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},B=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),K=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),G=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),V=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),W=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),nt=Object.freeze({__proto__:null,Jsonql406Error:B,Jsonql500Error:K,JsonqlAuthorisationError:G,JsonqlContractAuthError:V,JsonqlResolverAppError:W,JsonqlResolverNotFoundError:Y,JsonqlEnumError:Q,JsonqlTypeError:X,JsonqlCheckerError:Z,JsonqlValidationError:tt,JsonqlError:et,JsonqlServerError:rt}),ot=et,it=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function at(t){if(it(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&nt[o])throw new nt[r](i,a);throw new ot(i,a)}return t}function ut(t){if(Array.isArray(t))throw new tt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof B:throw new B(e,r);case t instanceof K:throw new K(e,r);case t instanceof G:throw new G(e,r);case t instanceof V:throw new V(e,r);case t instanceof W:throw new W(e,r);case t instanceof Y:throw new Y(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof rt:throw new rt(e,r);default:throw new et(e,r)}}function ct(t){return!!function(t){return D(t)&&(L(t,r)||L(t,n)||L(t,o))}(t)&&t}function st(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ft=function(t,e){return void 0===e&&(e={}),ct(e)?Promise.resolve(e):t.getContract()},lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function pt(t){this.message=t}pt.prototype=new Error,pt.prototype.name="InvalidCharacterError";var ht="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new pt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=lt.indexOf(n);return a};var dt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ht(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ht(e)}};function vt(t){this.message=t}vt.prototype=new Error,vt.prototype.name="InvalidTokenError";var gt=function(t,e){if("string"!=typeof t)throw new vt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(dt(t.split(".")[r]))}catch(t){throw new vt("Invalid token specified: "+t.message)}},yt=vt;function bt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&Et(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Ht="[object String]";function Lt(t){return"string"==typeof t||!b(t)&&N(t)&&C(t)==Ht}var Bt=function(t){return""!==Dt(t)&&Lt(t)},Kt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Gt(t){if(Bt(t))return function(t){var e=t.iat||Kt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new et("Token has expired on "+r,t)}return t}(gt(t));throw new et("Token must be a string!")}var Vt=function(t){return!!b(t)||null!=t&&""!==Dt(t)},Wt="[object Number]";function Yt(t){return function(t){return"number"==typeof t||N(t)&&C(t)==Wt}(t)&&t!=+t}var Qt=function(t){return!Lt(t)&&!Yt(parseFloat(t))},Xt=function(t){return null!=t&&"boolean"==typeof t},Zt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Dt(t)&&(!1===e||!0===e&&null!==t)},te=s,ee=f,re=l,ne=p,oe=h,ie=d,ae="continue",ue=function(t){switch(t){case"number":return Qt;case"string":return Bt;case"boolean":return Xt;default:return Zt}},ce=function(t,e){return void 0===e&&(e=""),!!b(t)&&(""===e||""===Dt(e)||!(t.filter((function(t){return!ue(e)(t)})).length>0))},se=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},fe=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ue(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ce(r,t)})).length};var le,pe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[le?a:++n];if(!1===e(o[u],u,o))break}return t};var he="[object Arguments]";function de(t){return N(t)&&C(t)==he}var ve=Object.prototype,ge=ve.hasOwnProperty,ye=ve.propertyIsEnumerable,be=de(function(){return arguments}())?de:function(t){return N(t)&&ge.call(t,"callee")&&!ye.call(t,"callee")};var _e="object"==typeof exports&&exports&&!exports.nodeType&&exports,me=_e&&"object"==typeof module&&module&&!module.nodeType&&module,we=me&&me.exports===_e?j.Buffer:void 0,je=(we?we.isBuffer:void 0)||function(){return!1},Se=9007199254740991,Oe=/^(?:0|[1-9]\d*)$/;function ke(t,e){var r=typeof t;return!!(e=null==e?Se:e)&&("number"==r||"symbol"!=r&&Oe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ae}var Te={};Te["[object Float32Array]"]=Te["[object Float64Array]"]=Te["[object Int8Array]"]=Te["[object Int16Array]"]=Te["[object Int32Array]"]=Te["[object Uint8Array]"]=Te["[object Uint8ClampedArray]"]=Te["[object Uint16Array]"]=Te["[object Uint32Array]"]=!0,Te["[object Arguments]"]=Te["[object Array]"]=Te["[object ArrayBuffer]"]=Te["[object Boolean]"]=Te["[object DataView]"]=Te["[object Date]"]=Te["[object Error]"]=Te["[object Function]"]=Te["[object Map]"]=Te["[object Number]"]=Te["[object Object]"]=Te["[object RegExp]"]=Te["[object Set]"]=Te["[object String]"]=Te["[object WeakMap]"]=!1;var xe,Pe="object"==typeof exports&&exports&&!exports.nodeType&&exports,qe=Pe&&"object"==typeof module&&module&&!module.nodeType&&module,Ce=qe&&qe.exports===Pe&&m.process,$e=function(){try{var t=qe&&qe.require&&qe.require("util").types;return t||Ce&&Ce.binding&&Ce.binding("util")}catch(t){}}(),ze=$e&&$e.isTypedArray,Ne=ze?(xe=ze,function(t){return xe(t)}):function(t){return N(t)&&Ee(t.length)&&!!Te[C(t)]},Me=Object.prototype.hasOwnProperty;function Ie(t,e){var r=b(t),n=!r&&be(t),o=!r&&!n&&je(t),i=!r&&!n&&!o&&Ne(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},tr.prototype.set=function(t,e){var r=this.__data__,n=Xe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var er,rr=j["__core-js_shared__"],nr=(er=/[^.]+$/.exec(rr&&rr.keys&&rr.keys.IE_PROTO||""))?"Symbol(src)_1."+er:"";var or=Function.prototype.toString;function ir(t){if(null!=t){try{return or.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ar=/^\[object .+?Constructor\]$/,ur=Function.prototype,cr=Object.prototype,sr=ur.toString,fr=cr.hasOwnProperty,lr=RegExp("^"+sr.call(fr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pr(t){return!(!De(t)||function(t){return!!nr&&nr in t}(t))&&(Ge(t)?lr:ar).test(ir(t))}function hr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return pr(r)?r:void 0}var dr=hr(j,"Map"),vr=hr(Object,"create");var gr="__lodash_hash_undefined__",yr=Object.prototype.hasOwnProperty;var br=Object.prototype.hasOwnProperty;var _r="__lodash_hash_undefined__";function mr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&xr?new Ar:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=se(t))?!fe({arg:r},e):!ue(t)(r))})).length)})).length}return!1},Yn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Wn,null,a);case"array"===t:return!ce(e.arg);case!1!==(r=se(t)):return!fe(e,r);default:return!ue(t)(e.arg)}},Qn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Xn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ce(e))throw new et("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ce(t))throw new et("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Qn(t,a):t,index:r,param:a,optional:i}}));default:throw new et("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Vt(e)&&!(r.type.length>r.type.filter((function(e){return Yn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Yn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Zn=function(){try{var t=hr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function to(t,e,r){"__proto__"==e&&Zn?Zn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function eo(t,e,r){(void 0===r||Qe(t[e],r))&&(void 0!==r||e in t)||to(t,e,r)}var ro="object"==typeof exports&&exports&&!exports.nodeType&&exports,no=ro&&"object"==typeof module&&module&&!module.nodeType&&module,oo=no&&no.exports===ro?j.Buffer:void 0,io=oo?oo.allocUnsafe:void 0;function ao(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new qr(n).set(new qr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var uo=Object.create,co=function(){function t(){}return function(e){if(!De(e))return{};if(uo)return uo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function so(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var fo=Object.prototype.hasOwnProperty;function lo(t,e,r){var n=t[e];fo.call(t,e)&&Qe(n,r)&&(void 0!==r||e in t)||to(t,e,r)}var po=Object.prototype.hasOwnProperty;function ho(t){if(!De(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Fe(t),r=[];for(var n in t)("constructor"!=n||!e&&po.call(t,n))&&r.push(n);return r}function vo(t){return Ve(t)?Ie(t,!0):ho(t)}function go(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=jo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(wo);function Ao(t,e){return ko(function(t,e,r){return e=mo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=mo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Eo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!De(r))return!1;var n=typeof e;return!!("number"==n?Ve(r)&&ke(e,r.length):"string"==n&&e in r)&&Qe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=qi().key(e);t(Ci(r),r)}},remove:function(t){return qi().removeItem(t)},clearAll:function(){return qi().clear()}};function qi(){return xi.localStorage}function Ci(t){return qi().getItem(t)}var $i=hi.trim,zi={name:"cookieStorage",read:function(t){if(!t||!Ri(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ni.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ni.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Mi,remove:Ii,clearAll:function(){Mi((function(t,e){Ii(e)}))}},Ni=hi.Global.document;function Mi(t){for(var e=Ni.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if($i(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ii(t){t&&Ri(t)&&(Ni.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Ri(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ni.cookie)}var Fi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Ji=hi.bind,Ui=hi.each,Di=hi.create,Hi=hi.slice,Li=function(){var t=Di(Bi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Ji(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Ji(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Ui(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Bi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Ji(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Hi(arguments,1);Ui(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Ki=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Gi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ki.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ki.compress(this._serialize(r));t(e,n)}}};var Vi=[Pi,zi],Wi=[Fi,Li,Gi],Yi=Ai.createStore(Vi,Wi),Qi=hi.Global;function Xi(){return Qi.sessionStorage}function Zi(t){return Xi().getItem(t)}var ta=[{name:"sessionStorage",read:Zi,write:function(t,e){return Xi().setItem(t,e)},each:function(t){for(var e=Xi().length-1;e>=0;e--){var r=Xi().key(e);t(Zi(r),r)}},remove:function(t){return Xi().removeItem(t)},clearAll:function(){return Xi().clear()}},zi],ea=[Fi,Gi],ra=Ai.createStore(ta,ea),na=Yi,oa=ra,ia=function(t){var e;return(e={}).args=t,e};function aa(t,e){var r;return(r={})[t]=e,r[u]=[ui()],r}var ua=function(t){return L(t,"data")&&!L(t,"error")?t.data:t},ca=function(t){this.opts=t,this.instanceKey=st(this.opts.hostname)+"",this.localStore=na,this.sessionStore=oa},sa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ca.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?To({},o,e):e,r))},ca.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ca.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ca.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},sa.lset.set=function(t){return this.__setMethod("localStore",t)},sa.lget.get=function(){return this.__getMethod("localStore")},ca.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ca.prototype.lclear=function(){return this.__clearMethod("localStore")},sa.sset.set=function(t){return this.__setMethod("sessionStore",t)},sa.sget.get=function(){return this.__getMethod("sessionStore")},ca.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ca.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ca.prototype,sa);var fa=c[0],la=c[1],pa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Gt)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(ni(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new tt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&ni(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,t},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ct(t))throw new tt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ct(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=To({},{_cb:ui()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=To({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=To({},{method:fa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ua(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ri(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ua(o)}),(function(t){throw e.cleanUp(),console.error(t),new rt("Server side error",t)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?To({},e,this.getAuthHeader(),this.extraHeader):To({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=To({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(at).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new rt("getRemoteContract",t)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Lt(t)&&b(e)){var n=ia(e);return!0===r?n:aa(t,n)}throw new tt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(at)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Lt(t))return aa(t,o);throw new tt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:la}).then(at)},Object.defineProperties(r.prototype,n),r}(ca)))),ha=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,H(t))}),Reflect.apply(t,null,r))}};function da(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function va(t,e,r,n){void 0===n&&(n=!1);var o=da(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var ga=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return oi(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ut)}},ya=function(t,e,r,n,o){var i={},a=function(t){i=va(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return oi(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ut)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},ba=function(t,e,r,n,o){var i={},a=function(t){i=va(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return oi(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ut)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},_a=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ga(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ga(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var ma=function(t,e,r,n){var o=function(t,e,r,n){return ha(ya,ba,_a)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.1",o.log=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,["[DEV DEBUG]"].concat(e))},o},wa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ja={hostname:ii(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:ii("jsonql",["string"]),loginHandlerName:ii("login",["string"]),logoutHandlerName:ii("logout",["string"]),enableJsonp:ii(!1,["boolean"]),enableAuth:ii(!1,["boolean"]),useJwt:ii(!0,["boolean"]),persistToken:ii(!1,["boolean","number"]),useLocalstorage:ii(!0,["boolean"]),storageKey:ii("jsonqlstore",["string"]),authKey:ii("jsonqlauthkey",["string"]),contractExpired:ii(0,["number"]),keepContract:ii(!0,["boolean"]),exposeContract:ii(!1,["boolean"]),exposeStore:ii(!1,["boolean"]),showContractDesc:ii(!1,["boolean"]),contractKey:ii(!1,["boolean"]),contractKeyName:ii("X-JSONQL-CV-KEY",["string"]),enableTimeout:ii(!1,["boolean"]),timeout:ii(5e3,["number"]),returnInstance:ii(!1,["boolean"]),allowReturnRawToken:ii(!1,["boolean"]),debugOn:ii(!1,["boolean"])};function Sa(t){return da(t,v)?Promise.resolve(t):function(t){var e=t.contract;return ai(t,ja,wa).then((function(t){return t.contract=e,t}))}(t)}var Oa=new WeakMap,ka=new WeakMap,Aa=function(){this.__suspend__=null,this.queueStore=new Set},Ea={$suspend:{configurable:!0},$queues:{configurable:!0}};Ea.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Aa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ea.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Aa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Aa.prototype,Ea);var Ta=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Oa.set(this,t)},r.normalStore.get=function(){return Oa.get(this)},r.lazyStore.set=function(t){ka.set(this,t)},r.lazyStore.get=function(){return ka.get(this)},e.prototype.hashFnToKey=function(t){return st(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Aa));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Sa(e).then((function(t){return{baseClient:new pa(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return ft(r,n.contract).then((function(e){return ma(r,n,e,t)}))}))}((r=e.debugOn,new Ta({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/core.js.map b/packages/http-client/core.js.map index 11a0e6273099f5d17d76a1b1603386086a39ced8..04ea2db523ea42b53f9ecdbe36ee58d9a9e83697 100644 --- a/packages/http-client/core.js.map +++ b/packages/http-client/core.js.map @@ -1 +1 @@ -{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.js","node_modules/store/plugins/expire.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function E(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function k(t){t.engine=a,E(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,E(l.handler,s,0);else{var f=new A(c,i);f.response=s,k(f)}}catch(f){k(new A(f.msg,a.status))}},a.onerror=function(t){k(new A(t.msg||"Network Error",0))},a.ontimeout=function(){k(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",O="onResult",S="onError",E=Array.isArray,k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A="object"==typeof k&&k&&k.Object===Object&&k,T="object"==typeof self&&self&&self.Object===Object&&self,x=A||T||Function("return this")(),P=x.Symbol,q=Object.prototype,C=q.hasOwnProperty,$=q.toString,N=P?P.toStringTag:void 0;var z=Object.prototype.toString;var R="[object Null]",M="[object Undefined]",F=P?P.toStringTag:void 0;function J(t){return null==t?void 0===t?M:R:F&&F in Object(t)?function(t){var e=C.call(t,N),r=t[N];try{t[N]=void 0;var n=!0}catch(t){}var o=$.call(t);return n&&(e?t[N]=r:delete t[N]),o}(t):function(t){return z.call(t)}(t)}function I(t,e){return function(r){return t(e(r))}}var U=I(Object.getPrototypeOf,Object);function D(t){return null!=t&&"object"==typeof t}var H="[object Object]",L=Function.prototype,B=Object.prototype,K=L.toString,G=B.hasOwnProperty,V=K.call(Object);function W(t){if(!D(t)||J(t)!=H)return!1;var e=U(t);if(null===e)return!0;var r=G.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&K.call(r)==V}var Y=function(t){return E(t)?t:[t]},X=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},Q=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),st=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ft=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),lt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlAuthorisationError:et,JsonqlContractAuthError:rt,JsonqlResolverAppError:nt,JsonqlResolverNotFoundError:ot,JsonqlEnumError:it,JsonqlTypeError:at,JsonqlCheckerError:ut,JsonqlValidationError:ct,JsonqlError:st,JsonqlServerError:ft}),pt=st,ht=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function dt(t){if(ht(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&<[o])throw new lt[r](i,a);throw new pt(i,a)}return t}function vt(t){if(Array.isArray(t))throw new ct("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof ft:throw new ft(e,r);default:throw new st(e,r)}}function gt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&Et(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Ut=function(t){return!!E(t)||null!=t&&""!==It(t)},Dt="[object Number]";function Ht(t){return function(t){return"number"==typeof t||D(t)&&J(t)==Dt}(t)&&t!=+t}var Lt="[object String]";function Bt(t){return"string"==typeof t||!E(t)&&D(t)&&J(t)==Lt}var Kt=function(t){return!Bt(t)&&!Ht(parseFloat(t))},Gt=function(t){return""!==It(t)&&Bt(t)},Vt=function(t){return null!=t&&"boolean"==typeof t},Wt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==It(t)&&(!1===e||!0===e&&null!==t)},Yt=d,Xt=v,Qt=g,Zt=y,te=b,ee=m,re="continue",ne=function(t){switch(t){case"number":return Kt;case"string":return Gt;case"boolean":return Vt;default:return Wt}},oe=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===It(e)||!(t.filter((function(t){return!ne(e)(t)})).length>0))},ie=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ae=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ne(e)(t)})).length)})).length:e.length>e.filter((function(t){return!oe(r,t)})).length};var ue,ce=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ue?a:++n];if(!1===e(o[u],u,o))break}return t};var se="[object Arguments]";function fe(t){return D(t)&&J(t)==se}var le=Object.prototype,pe=le.hasOwnProperty,he=le.propertyIsEnumerable,de=fe(function(){return arguments}())?fe:function(t){return D(t)&&pe.call(t,"callee")&&!he.call(t,"callee")};var ve="object"==typeof exports&&exports&&!exports.nodeType&&exports,ge=ve&&"object"==typeof module&&module&&!module.nodeType&&module,ye=ge&&ge.exports===ve?x.Buffer:void 0,be=(ye?ye.isBuffer:void 0)||function(){return!1},me=9007199254740991,_e=/^(?:0|[1-9]\d*)$/;function we(t,e){var r=typeof t;return!!(e=null==e?me:e)&&("number"==r||"symbol"!=r&&_e.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=je}var Se={};Se["[object Float32Array]"]=Se["[object Float64Array]"]=Se["[object Int8Array]"]=Se["[object Int16Array]"]=Se["[object Int32Array]"]=Se["[object Uint8Array]"]=Se["[object Uint8ClampedArray]"]=Se["[object Uint16Array]"]=Se["[object Uint32Array]"]=!0,Se["[object Arguments]"]=Se["[object Array]"]=Se["[object ArrayBuffer]"]=Se["[object Boolean]"]=Se["[object DataView]"]=Se["[object Date]"]=Se["[object Error]"]=Se["[object Function]"]=Se["[object Map]"]=Se["[object Number]"]=Se["[object Object]"]=Se["[object RegExp]"]=Se["[object Set]"]=Se["[object String]"]=Se["[object WeakMap]"]=!1;var Ee,ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ae=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Te=Ae&&Ae.exports===ke&&A.process,xe=function(){try{var t=Ae&&Ae.require&&Ae.require("util").types;return t||Te&&Te.binding&&Te.binding("util")}catch(t){}}(),Pe=xe&&xe.isTypedArray,qe=Pe?(Ee=Pe,function(t){return Ee(t)}):function(t){return D(t)&&Oe(t.length)&&!!Se[J(t)]},Ce=Object.prototype.hasOwnProperty;function $e(t,e){var r=E(t),n=!r&&de(t),o=!r&&!n&&be(t),i=!r&&!n&&!o&&qe(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ye.prototype.set=function(t,e){var r=this.__data__,n=Ve(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Xe,Qe=x["__core-js_shared__"],Ze=(Xe=/[^.]+$/.exec(Qe&&Qe.keys&&Qe.keys.IE_PROTO||""))?"Symbol(src)_1."+Xe:"";var tr=Function.prototype.toString;function er(t){if(null!=t){try{return tr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var rr=/^\[object .+?Constructor\]$/,nr=Function.prototype,or=Object.prototype,ir=nr.toString,ar=or.hasOwnProperty,ur=RegExp("^"+ir.call(ar).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cr(t){return!(!Fe(t)||function(t){return!!Ze&&Ze in t}(t))&&(He(t)?ur:rr).test(er(t))}function sr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return cr(r)?r:void 0}var fr=sr(x,"Map"),lr=sr(Object,"create");var pr="__lodash_hash_undefined__",hr=Object.prototype.hasOwnProperty;var dr=Object.prototype.hasOwnProperty;var vr="__lodash_hash_undefined__";function gr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Er?new jr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ie(t))?!ae({arg:r},e):!ne(t)(r))})).length)})).length}return!1},Kn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Bn,null,a);case"array"===t:return!oe(e.arg);case!1!==(r=ie(t)):return!ae(e,r);default:return!ne(t)(e.arg)}},Gn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Vn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!oe(e))throw new st("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!oe(t))throw new st("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Gn(t,a):t,index:r,param:a,optional:i}}));default:throw new st("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Ut(e)&&!(r.type.length>r.type.filter((function(e){return Kn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Kn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Wn=function(){try{var t=sr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Yn(t,e,r){"__proto__"==e&&Wn?Wn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Xn(t,e,r){(void 0===r||Ge(t[e],r))&&(void 0!==r||e in t)||Yn(t,e,r)}var Qn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zn=Qn&&"object"==typeof module&&module&&!module.nodeType&&module,to=Zn&&Zn.exports===Qn?x.Buffer:void 0,eo=to?to.allocUnsafe:void 0;function ro(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ar(n).set(new Ar(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var no=Object.create,oo=function(){function t(){}return function(e){if(!Fe(e))return{};if(no)return no(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function io(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ao=Object.prototype.hasOwnProperty;function uo(t,e,r){var n=t[e];ao.call(t,e)&&Ge(n,r)&&(void 0!==r||e in t)||Yn(t,e,r)}var co=Object.prototype.hasOwnProperty;function so(t){if(!Fe(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ze(t),r=[];for(var n in t)("constructor"!=n||!e&&co.call(t,n))&&r.push(n);return r}function fo(t){return Le(t)?$e(t,!0):so(t)}function lo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=bo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(yo);function jo(t,e){return wo(function(t,e,r){return e=go(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=go(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Oo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Fe(r))return!1;var n=typeof e;return!!("number"==n?Le(r)&&we(e,r.length):"string"==n&&e in r)&&Ge(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Y(t))}),Reflect.apply(t,null,r))}};function Go(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Vo(t,e,r,n){void 0===n&&(n=!1);var o=Go(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Wo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Ho(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},Yo=function(t,e,r,n,o){var i={},a=function(t){i=Vo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Ho(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Vo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Ho(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Qo=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Wo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Wo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Zo=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(Q(e,r,O),o),t.$only(Q(e,r,S),i),t.$trigger(e,{resolverName:r,args:n})}))}},ti=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function ei(t,e,r,n){var o=function(t,e,r,n){return Ko(Yo,Xo,Qo)({},t,e,r,n)}(t,e,r,n);ti(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(Q(t,n,O),r)})).catch((function(r){e.$trigger(Q(t,n,S),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var ri=function(t,e,r,n){n.$suspend=!0,r.then((function(r){ei(t,n,e,r)}));var o={query:Zo(n,"query"),mutation:Zo(n,"mutation"),auth:Zo(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.0",o};function ni(t){return!!function(t){return W(t)&&(X(t,u)||X(t,c)||X(t,s))}(t)&&t}function oi(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ii=function(t,e){return void 0===e&&(e={}),ni(e)?Promise.resolve(e):t.getContract()},ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function ui(t){this.message=t}ui.prototype=new Error,ui.prototype.name="InvalidCharacterError";var ci="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ui("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ai.indexOf(n);return a};var si=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ci(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ci(e)}};function fi(t){this.message=t}fi.prototype=new Error,fi.prototype.name="InvalidTokenError";var li=function(t,e){if("string"!=typeof t)throw new fi("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(si(t.split(".")[r]))}catch(t){throw new fi("Invalid token specified: "+t.message)}},pi=fi;li.InvalidTokenError=pi;var hi,di,vi,gi,yi,bi,mi,_i,wi,ji=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Oi(t){if(Gt(t))return function(t){var e=t.iat||ji(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new st("Token has expired on "+r,t)}return t}(li(t));throw new st("Token must be a string!")}Lo("HS256",["string"]),Lo(!1,["boolean","number","string"],((hi={})[m]="exp",hi[v]=!0,hi)),Lo(!1,["boolean","number","string"],((di={})[m]="nbf",di[v]=!0,di)),Lo(!1,["boolean","string"],((vi={})[m]="iss",vi[v]=!0,vi)),Lo(!1,["boolean","string"],((gi={})[m]="sub",gi[v]=!0,gi)),Lo(!1,["boolean","string"],((yi={})[m]="iss",yi[v]=!0,yi)),Lo(!1,["boolean"],((bi={})[v]=!0,bi)),Lo(!1,["boolean","string"],((mi={})[v]=!0,mi)),Lo(!1,["boolean","string"],((_i={})[v]=!0,_i)),Lo(!1,["boolean"],((wi={})[v]=!0,wi));var Si=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Ei=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Gi().key(e);t(Vi(r),r)}},remove:function(t){return Gi().removeItem(t)},clearAll:function(){return Gi().clear()}};function Gi(){return Bi.localStorage}function Vi(t){return Gi().getItem(t)}var Wi=xi.trim,Yi={name:"cookieStorage",read:function(t){if(!t||!ta(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Xi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Xi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Qi,remove:Zi,clearAll:function(){Qi((function(t,e){Zi(e)}))}},Xi=xi.Global.document;function Qi(t){for(var e=Xi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Wi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Zi(t){t&&ta(t)&&(Xi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ta(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Xi.cookie)}var ea=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ra="expire_mixin",na=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+ra);return{set:function(e,r,n,o){this.hasNamespace(ra)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(ra)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(ra)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var la=[Ki,Yi],pa=[ea,na,ca,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=fa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=fa.compress(this._serialize(r));t(e,n)}}}],ha=Di.createStore(la,pa),da=xi.Global;function va(){return da.sessionStorage}function ga(t){return va().getItem(t)}var ya=[{name:"sessionStorage",read:ga,write:function(t,e){return va().setItem(t,e)},each:function(t){for(var e=va().length-1;e>=0;e--){var r=va().key(e);t(ga(r),r)}},remove:function(t){return va().removeItem(t)},clearAll:function(){return va().clear()}},Yi],ba=[ea,na],ma=Di.createStore(ya,ba),_a=ha,wa=ma,ja=function(t){var e;return(e={}).args=t,e};function Oa(t,e){var r;return(r={})[t]=e,r[p]=[Si()],r}var Sa=function(t){return X(t,"data")&&!X(t,"error")?t.data:t},Ea=function(t){this.opts=t,this.instanceKey=oi(this.opts.hostname)+"",this.localStore=_a,this.sessionStore=wa},ka={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Ea.prototype.__setMethod=function(t,e){var r,n=this[t],o=(this.__getMethod(t),this.opts.storageKey),i=this.instanceKey;n.set(o,((r={})[i]=n?So({},n,e):e,r))},Ea.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Ea.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Ea.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},ka.lset.set=function(t){return this.__setMethod("localStore",t)},ka.lget.get=function(){return this.__getMethod("localStore")},Ea.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Ea.prototype.lclear=function(){return this.__clearMethod("localStore")},ka.sset.set=function(t){return this.__setMethod("sessionStore",t)},ka.sget.get=function(){return this.__getMethod("sessionStore")},Ea.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Ea.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Ea.prototype,ka);var Aa=h[0],Ta=h[1],xa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},r.jsonqlToken.set=function(t){var e;this.sset=((e={}).jsonqlcredential=t,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlToken.get=function(){var t=this.sget;return!!t&&t.jsonqlcredential},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Oi)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ni(t))throw new ct("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ni(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=So({},{_cb:Si()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=So({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=So({},{method:Aa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Sa(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Do(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Sa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ft("Server side error",t)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?So({},a,this.getAuthHeader(),this.extraHeader):So({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=So({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(dt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new ft("getRemoteContract",t)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Bt(t)&&E(e)){var n=ja(e);return!0===r?n:Oa(t,n)}throw new ct("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Bt(t))return Oa(t,o);throw new ct("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ta}).then(dt)},Object.defineProperties(e.prototype,r),e}(Ea)))),Pa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},qa={hostname:Lo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Lo("jsonql",["string"]),loginHandlerName:Lo("login",["string"]),logoutHandlerName:Lo("logout",["string"]),enableJsonp:Lo(!1,["boolean"]),enableAuth:Lo(!1,["boolean"]),useJwt:Lo(!0,["boolean"]),persistToken:Lo(!1,["boolean","number"]),useLocalstorage:Lo(!0,["boolean"]),storageKey:Lo("jsonqlstore",["string"]),authKey:Lo("jsonqlauthkey",["string"]),contractExpired:Lo(0,["number"]),keepContract:Lo(!0,["boolean"]),exposeContract:Lo(!1,["boolean"]),showContractDesc:Lo(!1,["boolean"]),contractKey:Lo(!1,["boolean"]),contractKeyName:Lo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Lo(!1,["boolean"]),timeout:Lo(5e3,["number"]),returnInstance:Lo(!1,["boolean"]),allowReturnRawToken:Lo(!1,["boolean"]),debugOn:Lo(!1,["boolean"])};function Ca(t){return Go(t,_)?t:function(t){return Bo(t,qa,Pa)}(t)}var $a=new WeakMap,Na=new WeakMap,za=function(){this.__suspend__=null,this.queueStore=new Set},Ra={$suspend:{configurable:!0},$queues:{configurable:!0}};Ra.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},za.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ra.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},za.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(za.prototype,Ra);var Ma=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){$a.set(this,t)},r.normalStore.get=function(){return $a.get(this)},r.lazyStore.set=function(t){Na.set(this,t)},r.lazyStore.get=function(){return Na.get(this)},e.prototype.hashFnToKey=function(t){return oi(t.toString())+""},Object.defineProperties(e.prototype,r),e}(za));function Fa(t,e){void 0===e&&(e={});var r,n=e.contract,o=Ca(e),i=new xa(t,o),a=ii(i,n),u=(r=o.debugOn,new Ma({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=ri(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),Fa(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="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.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",O="onResult",S="onError",k=Array.isArray,E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A="object"==typeof E&&E&&E.Object===Object&&E,T="object"==typeof self&&self&&self.Object===Object&&self,x=A||T||Function("return this")(),P=x.Symbol,q=Object.prototype,C=q.hasOwnProperty,$=q.toString,z=P?P.toStringTag:void 0;var N=Object.prototype.toString;var R="[object Null]",M="[object Undefined]",F=P?P.toStringTag:void 0;function J(t){return null==t?void 0===t?M:R:F&&F in Object(t)?function(t){var e=C.call(t,z),r=t[z];try{t[z]=void 0;var n=!0}catch(t){}var o=$.call(t);return n&&(e?t[z]=r:delete t[z]),o}(t):function(t){return N.call(t)}(t)}function I(t,e){return function(r){return t(e(r))}}var U=I(Object.getPrototypeOf,Object);function D(t){return null!=t&&"object"==typeof t}var H="[object Object]",L=Function.prototype,B=Object.prototype,K=L.toString,G=B.hasOwnProperty,V=K.call(Object);function W(t){if(!D(t)||J(t)!=H)return!1;var e=U(t);if(null===e)return!0;var r=G.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&K.call(r)==V}var Y=function(t){return k(t)?t:[t]},Q=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),st=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ft=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),lt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlAuthorisationError:et,JsonqlContractAuthError:rt,JsonqlResolverAppError:nt,JsonqlResolverNotFoundError:ot,JsonqlEnumError:it,JsonqlTypeError:at,JsonqlCheckerError:ut,JsonqlValidationError:ct,JsonqlError:st,JsonqlServerError:ft}),pt=st,ht=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function dt(t){if(ht(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&<[o])throw new lt[r](i,a);throw new pt(i,a)}return t}function vt(t){if(Array.isArray(t))throw new ct("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof ft:throw new ft(e,r);default:throw new st(e,r)}}function gt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&kt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Ut=function(t){return!!k(t)||null!=t&&""!==It(t)},Dt="[object Number]";function Ht(t){return function(t){return"number"==typeof t||D(t)&&J(t)==Dt}(t)&&t!=+t}var Lt="[object String]";function Bt(t){return"string"==typeof t||!k(t)&&D(t)&&J(t)==Lt}var Kt=function(t){return!Bt(t)&&!Ht(parseFloat(t))},Gt=function(t){return""!==It(t)&&Bt(t)},Vt=function(t){return null!=t&&"boolean"==typeof t},Wt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==It(t)&&(!1===e||!0===e&&null!==t)},Yt=d,Qt=v,Xt=g,Zt=y,te=b,ee=m,re="continue",ne=function(t){switch(t){case"number":return Kt;case"string":return Gt;case"boolean":return Vt;default:return Wt}},oe=function(t,e){return void 0===e&&(e=""),!!k(t)&&(""===e||""===It(e)||!(t.filter((function(t){return!ne(e)(t)})).length>0))},ie=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ae=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ne(e)(t)})).length)})).length:e.length>e.filter((function(t){return!oe(r,t)})).length};var ue,ce=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ue?a:++n];if(!1===e(o[u],u,o))break}return t};var se="[object Arguments]";function fe(t){return D(t)&&J(t)==se}var le=Object.prototype,pe=le.hasOwnProperty,he=le.propertyIsEnumerable,de=fe(function(){return arguments}())?fe:function(t){return D(t)&&pe.call(t,"callee")&&!he.call(t,"callee")};var ve="object"==typeof exports&&exports&&!exports.nodeType&&exports,ge=ve&&"object"==typeof module&&module&&!module.nodeType&&module,ye=ge&&ge.exports===ve?x.Buffer:void 0,be=(ye?ye.isBuffer:void 0)||function(){return!1},me=9007199254740991,_e=/^(?:0|[1-9]\d*)$/;function we(t,e){var r=typeof t;return!!(e=null==e?me:e)&&("number"==r||"symbol"!=r&&_e.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=je}var Se={};Se["[object Float32Array]"]=Se["[object Float64Array]"]=Se["[object Int8Array]"]=Se["[object Int16Array]"]=Se["[object Int32Array]"]=Se["[object Uint8Array]"]=Se["[object Uint8ClampedArray]"]=Se["[object Uint16Array]"]=Se["[object Uint32Array]"]=!0,Se["[object Arguments]"]=Se["[object Array]"]=Se["[object ArrayBuffer]"]=Se["[object Boolean]"]=Se["[object DataView]"]=Se["[object Date]"]=Se["[object Error]"]=Se["[object Function]"]=Se["[object Map]"]=Se["[object Number]"]=Se["[object Object]"]=Se["[object RegExp]"]=Se["[object Set]"]=Se["[object String]"]=Se["[object WeakMap]"]=!1;var ke,Ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ae=Ee&&"object"==typeof module&&module&&!module.nodeType&&module,Te=Ae&&Ae.exports===Ee&&A.process,xe=function(){try{var t=Ae&&Ae.require&&Ae.require("util").types;return t||Te&&Te.binding&&Te.binding("util")}catch(t){}}(),Pe=xe&&xe.isTypedArray,qe=Pe?(ke=Pe,function(t){return ke(t)}):function(t){return D(t)&&Oe(t.length)&&!!Se[J(t)]},Ce=Object.prototype.hasOwnProperty;function $e(t,e){var r=k(t),n=!r&&de(t),o=!r&&!n&&be(t),i=!r&&!n&&!o&&qe(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ye.prototype.set=function(t,e){var r=this.__data__,n=Ve(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Qe,Xe=x["__core-js_shared__"],Ze=(Qe=/[^.]+$/.exec(Xe&&Xe.keys&&Xe.keys.IE_PROTO||""))?"Symbol(src)_1."+Qe:"";var tr=Function.prototype.toString;function er(t){if(null!=t){try{return tr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var rr=/^\[object .+?Constructor\]$/,nr=Function.prototype,or=Object.prototype,ir=nr.toString,ar=or.hasOwnProperty,ur=RegExp("^"+ir.call(ar).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cr(t){return!(!Fe(t)||function(t){return!!Ze&&Ze in t}(t))&&(He(t)?ur:rr).test(er(t))}function sr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return cr(r)?r:void 0}var fr=sr(x,"Map"),lr=sr(Object,"create");var pr="__lodash_hash_undefined__",hr=Object.prototype.hasOwnProperty;var dr=Object.prototype.hasOwnProperty;var vr="__lodash_hash_undefined__";function gr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&kr?new jr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ie(t))?!ae({arg:r},e):!ne(t)(r))})).length)})).length}return!1},Kn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Bn,null,a);case"array"===t:return!oe(e.arg);case!1!==(r=ie(t)):return!ae(e,r);default:return!ne(t)(e.arg)}},Gn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Vn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!oe(e))throw new st("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!oe(t))throw new st("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Gn(t,a):t,index:r,param:a,optional:i}}));default:throw new st("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Ut(e)&&!(r.type.length>r.type.filter((function(e){return Kn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Kn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Wn=function(){try{var t=sr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Yn(t,e,r){"__proto__"==e&&Wn?Wn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Qn(t,e,r){(void 0===r||Ge(t[e],r))&&(void 0!==r||e in t)||Yn(t,e,r)}var Xn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zn=Xn&&"object"==typeof module&&module&&!module.nodeType&&module,to=Zn&&Zn.exports===Xn?x.Buffer:void 0,eo=to?to.allocUnsafe:void 0;function ro(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ar(n).set(new Ar(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var no=Object.create,oo=function(){function t(){}return function(e){if(!Fe(e))return{};if(no)return no(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function io(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ao=Object.prototype.hasOwnProperty;function uo(t,e,r){var n=t[e];ao.call(t,e)&&Ge(n,r)&&(void 0!==r||e in t)||Yn(t,e,r)}var co=Object.prototype.hasOwnProperty;function so(t){if(!Fe(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Ne(t),r=[];for(var n in t)("constructor"!=n||!e&&co.call(t,n))&&r.push(n);return r}function fo(t){return Le(t)?$e(t,!0):so(t)}function lo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=bo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(yo);function jo(t,e){return wo(function(t,e,r){return e=go(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=go(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Oo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Fe(r))return!1;var n=typeof e;return!!("number"==n?Le(r)&&we(e,r.length):"string"==n&&e in r)&&Ge(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,Y(t))}),Reflect.apply(t,null,r))}};function Vo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Wo(t,e,r,n){void 0===n&&(n=!1);var o=Vo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Yo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Lo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},Qo=function(t,e,r,n,o){var i={},a=function(t){i=Wo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Lo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Wo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Lo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Zo=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Yo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Yo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var ti=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(X(e,r,O),o),t.$only(X(e,r,S),i),t.$trigger(e,{resolverName:r,args:n})}))}},ei=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function ri(t,e,r,n){var o=function(t,e,r,n){return Go(Qo,Xo,Zo)({},t,e,r,n)}(t,e,r,n);ei(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(X(t,n,O),r)})).catch((function(r){e.$trigger(X(t,n,S),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var ni=function(t,e,r,n){n.$suspend=!0,r.then((function(r){ri(t,n,e,r)}));var o={query:ti(n,"query"),mutation:ti(n,"mutation"),auth:ti(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.1",o};function oi(t){return!!function(t){return W(t)&&(Q(t,u)||Q(t,c)||Q(t,s))}(t)&&t}function ii(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ai=function(t,e){return void 0===e&&(e={}),oi(e)?Promise.resolve(e):t.getContract()},ui="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function ci(t){this.message=t}ci.prototype=new Error,ci.prototype.name="InvalidCharacterError";var si="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ci("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ui.indexOf(n);return a};var fi=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(si(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return si(e)}};function li(t){this.message=t}li.prototype=new Error,li.prototype.name="InvalidTokenError";var pi=function(t,e){if("string"!=typeof t)throw new li("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(fi(t.split(".")[r]))}catch(t){throw new li("Invalid token specified: "+t.message)}},hi=li;pi.InvalidTokenError=hi;var di,vi,gi,yi,bi,mi,_i,wi,ji,Oi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Si(t){if(Gt(t))return function(t){var e=t.iat||Oi(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new st("Token has expired on "+r,t)}return t}(pi(t));throw new st("Token must be a string!")}Bo("HS256",["string"]),Bo(!1,["boolean","number","string"],((di={})[m]="exp",di[v]=!0,di)),Bo(!1,["boolean","number","string"],((vi={})[m]="nbf",vi[v]=!0,vi)),Bo(!1,["boolean","string"],((gi={})[m]="iss",gi[v]=!0,gi)),Bo(!1,["boolean","string"],((yi={})[m]="sub",yi[v]=!0,yi)),Bo(!1,["boolean","string"],((bi={})[m]="iss",bi[v]=!0,bi)),Bo(!1,["boolean"],((mi={})[v]=!0,mi)),Bo(!1,["boolean","string"],((_i={})[v]=!0,_i)),Bo(!1,["boolean","string"],((wi={})[v]=!0,wi)),Bo(!1,["boolean"],((ji={})[v]=!0,ji));var ki=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Ei=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Vi().key(e);t(Wi(r),r)}},remove:function(t){return Vi().removeItem(t)},clearAll:function(){return Vi().clear()}};function Vi(){return Ki.localStorage}function Wi(t){return Vi().getItem(t)}var Yi=Pi.trim,Qi={name:"cookieStorage",read:function(t){if(!t||!ea(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Xi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Xi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Zi,remove:ta,clearAll:function(){Zi((function(t,e){ta(e)}))}},Xi=Pi.Global.document;function Zi(t){for(var e=Xi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Yi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ta(t){t&&ea(t)&&(Xi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ea(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Xi.cookie)}var ra=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var na=Pi.bind,oa=Pi.each,ia=Pi.create,aa=Pi.slice,ua=function(){var t=ia(ca,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,na(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,na(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),oa(r,(function(e,r){t.fire(r,void 0,e)}))}}};var ca={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,na(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=aa(arguments,1);oa(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},sa=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),fa=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=sa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=sa.compress(this._serialize(r));t(e,n)}}};var la=[Gi,Qi],pa=[ra,ua,fa],ha=Hi.createStore(la,pa),da=Pi.Global;function va(){return da.sessionStorage}function ga(t){return va().getItem(t)}var ya=[{name:"sessionStorage",read:ga,write:function(t,e){return va().setItem(t,e)},each:function(t){for(var e=va().length-1;e>=0;e--){var r=va().key(e);t(ga(r),r)}},remove:function(t){return va().removeItem(t)},clearAll:function(){return va().clear()}},Qi],ba=[ra,fa],ma=Hi.createStore(ya,ba),_a=ha,wa=ma,ja=function(t){var e;return(e={}).args=t,e};function Oa(t,e){var r;return(r={})[t]=e,r[p]=[ki()],r}var Sa=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},ka=function(t){this.opts=t,this.instanceKey=ii(this.opts.hostname)+"",this.localStore=_a,this.sessionStore=wa},Ea={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ka.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?So({},o,e):e,r))},ka.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ka.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ka.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Ea.lset.set=function(t){return this.__setMethod("localStore",t)},Ea.lget.get=function(){return this.__getMethod("localStore")},ka.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ka.prototype.lclear=function(){return this.__clearMethod("localStore")},Ea.sset.set=function(t){return this.__setMethod("sessionStore",t)},Ea.sget.get=function(){return this.__getMethod("sessionStore")},ka.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ka.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ka.prototype,Ea);var Aa=h[0],Ta=h[1],xa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Si)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Ho(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ct("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Ho(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,t},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!oi(t))throw new ct("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=oi(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=So({},{_cb:ki()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=So({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=So({},{method:Aa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return Sa(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Do(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Sa(o)}),(function(t){throw e.cleanUp(),console.error(t),new ft("Server side error",t)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?So({},a,this.getAuthHeader(),this.extraHeader):So({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=So({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(dt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new ft("getRemoteContract",t)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Bt(t)&&k(e)){var n=ja(e);return!0===r?n:Oa(t,n)}throw new ct("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Bt(t))return Oa(t,o);throw new ct("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Ta}).then(dt)},Object.defineProperties(e.prototype,r),e}(ka)))),Pa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},qa={hostname:Bo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Bo("jsonql",["string"]),loginHandlerName:Bo("login",["string"]),logoutHandlerName:Bo("logout",["string"]),enableJsonp:Bo(!1,["boolean"]),enableAuth:Bo(!1,["boolean"]),useJwt:Bo(!0,["boolean"]),persistToken:Bo(!1,["boolean","number"]),useLocalstorage:Bo(!0,["boolean"]),storageKey:Bo("jsonqlstore",["string"]),authKey:Bo("jsonqlauthkey",["string"]),contractExpired:Bo(0,["number"]),keepContract:Bo(!0,["boolean"]),exposeContract:Bo(!1,["boolean"]),exposeStore:Bo(!1,["boolean"]),showContractDesc:Bo(!1,["boolean"]),contractKey:Bo(!1,["boolean"]),contractKeyName:Bo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Bo(!1,["boolean"]),timeout:Bo(5e3,["number"]),returnInstance:Bo(!1,["boolean"]),allowReturnRawToken:Bo(!1,["boolean"]),debugOn:Bo(!1,["boolean"])};function Ca(t){return Vo(t,_)?t:function(t){return Ko(t,qa,Pa)}(t)}var $a=new WeakMap,za=new WeakMap,Na=function(){this.__suspend__=null,this.queueStore=new Set},Ra={$suspend:{configurable:!0},$queues:{configurable:!0}};Ra.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Na.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ra.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Na.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Na.prototype,Ra);var Ma=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){$a.set(this,t)},r.normalStore.get=function(){return $a.get(this)},r.lazyStore.set=function(t){za.set(this,t)},r.lazyStore.get=function(){return za.get(this)},e.prototype.hashFnToKey=function(t){return ii(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Na));function Fa(t,e){void 0===e&&(e={});var r,n=e.contract,o=Ca(e),i=new xa(t,o),a=ai(i,n),u=(r=o.debugOn,new Ma({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=ni(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),Fa(new o,t)}})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js.map b/packages/http-client/dist/jsonql-client.static.js.map index b667c96fe381470a68387030bca5166b4895c2b9..04d47b5f7572baec007edc88f5ed0b936a8efcb4 100644 --- a/packages/http-client/dist/jsonql-client.static.js.map +++ b/packages/http-client/dist/jsonql-client.static.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js","../node_modules/store/plugins/expire.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",O=Array.isArray,S="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},k="object"==typeof S&&S&&S.Object===Object&&S,E="object"==typeof self&&self&&self.Object===Object&&self,A=k||E||Function("return this")(),T=A.Symbol,x=Object.prototype,P=x.hasOwnProperty,q=x.toString,C=T?T.toStringTag:void 0;var $=Object.prototype.toString;var z="[object Null]",N="[object Undefined]",M=T?T.toStringTag:void 0;function R(t){return null==t?void 0===t?N:z:M&&M in Object(t)?function(t){var e=P.call(t,C),r=t[C];try{t[C]=void 0;var n=!0}catch(t){}var o=q.call(t);return n&&(e?t[C]=r:delete t[C]),o}(t):function(t){return $.call(t)}(t)}function F(t,e){return function(r){return t(e(r))}}var J=F(Object.getPrototypeOf,Object);function I(t){return null!=t&&"object"==typeof t}var U="[object Object]",D=Function.prototype,H=Object.prototype,L=D.toString,B=H.hasOwnProperty,K=L.call(Object);function G(t){if(!I(t)||R(t)!=U)return!1;var e=J(t);if(null===e)return!0;var r=B.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&L.call(r)==K}var V=function(t){return O(t)?t:[t]},W=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),ct=Object.freeze({__proto__:null,Jsonql406Error:Y,Jsonql500Error:X,JsonqlAuthorisationError:Q,JsonqlContractAuthError:Z,JsonqlResolverAppError:tt,JsonqlResolverNotFoundError:et,JsonqlEnumError:rt,JsonqlTypeError:nt,JsonqlCheckerError:ot,JsonqlValidationError:it,JsonqlError:at,JsonqlServerError:ut}),st=at,ft=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function lt(t){if(ft(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&ct[o])throw new ct[r](i,a);throw new st(i,a)}return t}function pt(t){if(Array.isArray(t))throw new it("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof Y:throw new Y(e,r);case t instanceof X:throw new X(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof ut:throw new ut(e,r);default:throw new at(e,r)}}function ht(t){return!!function(t){return G(t)&&(W(t,u)||W(t,c)||W(t,s))}(t)&&t}function dt(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var vt=function(t,e){return void 0===e&&(e={}),ht(e)?Promise.resolve(e):t.getContract()},gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function yt(t){this.message=t}yt.prototype=new Error,yt.prototype.name="InvalidCharacterError";var bt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new yt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=gt.indexOf(n);return a};var mt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(bt(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return bt(e)}};function _t(t){this.message=t}_t.prototype=new Error,_t.prototype.name="InvalidTokenError";var wt=function(t,e){if("string"!=typeof t)throw new _t("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(mt(t.split(".")[r]))}catch(t){throw new _t("Invalid token specified: "+t.message)}},jt=_t;function Ot(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&Ct(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Vt="[object String]";function Wt(t){return"string"==typeof t||!O(t)&&I(t)&&R(t)==Vt}var Yt=function(t){return""!==Gt(t)&&Wt(t)},Xt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Qt(t){if(Yt(t))return function(t){var e=t.iat||Xt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new at("Token has expired on "+r,t)}return t}(wt(t));throw new at("Token must be a string!")}var Zt=function(t){return!!O(t)||null!=t&&""!==Gt(t)},te="[object Number]";function ee(t){return function(t){return"number"==typeof t||I(t)&&R(t)==te}(t)&&t!=+t}var re=function(t){return!Wt(t)&&!ee(parseFloat(t))},ne=function(t){return null!=t&&"boolean"==typeof t},oe=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Gt(t)&&(!1===e||!0===e&&null!==t)},ie=d,ae=v,ue=g,ce=y,se=b,fe=m,le="continue",pe=function(t){switch(t){case"number":return re;case"string":return Yt;case"boolean":return ne;default:return oe}},he=function(t,e){return void 0===e&&(e=""),!!O(t)&&(""===e||""===Gt(e)||!(t.filter((function(t){return!pe(e)(t)})).length>0))},de=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ve=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!pe(e)(t)})).length)})).length:e.length>e.filter((function(t){return!he(r,t)})).length};var ge,ye=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ge?a:++n];if(!1===e(o[u],u,o))break}return t};var be="[object Arguments]";function me(t){return I(t)&&R(t)==be}var _e=Object.prototype,we=_e.hasOwnProperty,je=_e.propertyIsEnumerable,Oe=me(function(){return arguments}())?me:function(t){return I(t)&&we.call(t,"callee")&&!je.call(t,"callee")};var Se="object"==typeof exports&&exports&&!exports.nodeType&&exports,ke=Se&&"object"==typeof module&&module&&!module.nodeType&&module,Ee=ke&&ke.exports===Se?A.Buffer:void 0,Ae=(Ee?Ee.isBuffer:void 0)||function(){return!1},Te=9007199254740991,xe=/^(?:0|[1-9]\d*)$/;function Pe(t,e){var r=typeof t;return!!(e=null==e?Te:e)&&("number"==r||"symbol"!=r&&xe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=qe}var $e={};$e["[object Float32Array]"]=$e["[object Float64Array]"]=$e["[object Int8Array]"]=$e["[object Int16Array]"]=$e["[object Int32Array]"]=$e["[object Uint8Array]"]=$e["[object Uint8ClampedArray]"]=$e["[object Uint16Array]"]=$e["[object Uint32Array]"]=!0,$e["[object Arguments]"]=$e["[object Array]"]=$e["[object ArrayBuffer]"]=$e["[object Boolean]"]=$e["[object DataView]"]=$e["[object Date]"]=$e["[object Error]"]=$e["[object Function]"]=$e["[object Map]"]=$e["[object Number]"]=$e["[object Object]"]=$e["[object RegExp]"]=$e["[object Set]"]=$e["[object String]"]=$e["[object WeakMap]"]=!1;var ze,Ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,Me=Ne&&"object"==typeof module&&module&&!module.nodeType&&module,Re=Me&&Me.exports===Ne&&k.process,Fe=function(){try{var t=Me&&Me.require&&Me.require("util").types;return t||Re&&Re.binding&&Re.binding("util")}catch(t){}}(),Je=Fe&&Fe.isTypedArray,Ie=Je?(ze=Je,function(t){return ze(t)}):function(t){return I(t)&&Ce(t.length)&&!!$e[R(t)]},Ue=Object.prototype.hasOwnProperty;function De(t,e){var r=O(t),n=!r&&Oe(t),o=!r&&!n&&Ae(t),i=!r&&!n&&!o&&Ie(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ir.prototype.set=function(t,e){var r=this.__data__,n=nr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ar,ur=A["__core-js_shared__"],cr=(ar=/[^.]+$/.exec(ur&&ur.keys&&ur.keys.IE_PROTO||""))?"Symbol(src)_1."+ar:"";var sr=Function.prototype.toString;function fr(t){if(null!=t){try{return sr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var lr=/^\[object .+?Constructor\]$/,pr=Function.prototype,hr=Object.prototype,dr=pr.toString,vr=hr.hasOwnProperty,gr=RegExp("^"+dr.call(vr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yr(t){return!(!Ge(t)||function(t){return!!cr&&cr in t}(t))&&(Qe(t)?gr:lr).test(fr(t))}function br(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return yr(r)?r:void 0}var mr=br(A,"Map"),_r=br(Object,"create");var wr="__lodash_hash_undefined__",jr=Object.prototype.hasOwnProperty;var Or=Object.prototype.hasOwnProperty;var Sr="__lodash_hash_undefined__";function kr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&zr?new qr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=de(t))?!ve({arg:r},e):!pe(t)(r))})).length)})).length}return!1},eo=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(to,null,a);case"array"===t:return!he(e.arg);case!1!==(r=de(t)):return!ve(e,r);default:return!pe(t)(e.arg)}},ro=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},no=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!he(e))throw new at("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!he(t))throw new at("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?ro(t,a):t,index:r,param:a,optional:i}}));default:throw new at("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Zt(e)&&!(r.type.length>r.type.filter((function(e){return eo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return eo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},oo=function(){try{var t=br(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function io(t,e,r){"__proto__"==e&&oo?oo(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ao(t,e,r){(void 0===r||rr(t[e],r))&&(void 0!==r||e in t)||io(t,e,r)}var uo="object"==typeof exports&&exports&&!exports.nodeType&&exports,co=uo&&"object"==typeof module&&module&&!module.nodeType&&module,so=co&&co.exports===uo?A.Buffer:void 0,fo=so?so.allocUnsafe:void 0;function lo(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Mr(n).set(new Mr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var po=Object.create,ho=function(){function t(){}return function(e){if(!Ge(e))return{};if(po)return po(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function vo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var go=Object.prototype.hasOwnProperty;function yo(t,e,r){var n=t[e];go.call(t,e)&&rr(n,r)&&(void 0!==r||e in t)||io(t,e,r)}var bo=Object.prototype.hasOwnProperty;function mo(t){if(!Ge(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Le(t),r=[];for(var n in t)("constructor"!=n||!e&&bo.call(t,n))&&r.push(n);return r}function _o(t){return Ze(t)?De(t,!0):mo(t)}function wo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=Ao)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Eo);function qo(t,e){return Po(function(t,e,r){return e=ko(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ko(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Co.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Ge(r))return!1;var n=typeof e;return!!("number"==n?Ze(r)&&Pe(e,r.length):"string"==n&&e in r)&&rr(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=zi().key(e);t(Ni(r),r)}},remove:function(t){return zi().removeItem(t)},clearAll:function(){return zi().clear()}};function zi(){return Ci.localStorage}function Ni(t){return zi().getItem(t)}var Mi=gi.trim,Ri={name:"cookieStorage",read:function(t){if(!t||!Ui(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Fi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Fi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ji,remove:Ii,clearAll:function(){Ji((function(t,e){Ii(e)}))}},Fi=gi.Global.document;function Ji(t){for(var e=Fi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Mi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ii(t){t&&Ui(t)&&(Fi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Ui(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Fi.cookie)}var Di=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Hi="expire_mixin",Li=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+Hi);return{set:function(e,r,n,o){this.hasNamespace(Hi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(Hi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(Hi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var Qi=[$i,Ri],Zi=[Di,Li,Wi,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Xi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Xi.compress(this._serialize(r));t(e,n)}}}],ta=xi.createStore(Qi,Zi),ea=gi.Global;function ra(){return ea.sessionStorage}function na(t){return ra().getItem(t)}var oa=[{name:"sessionStorage",read:na,write:function(t,e){return ra().setItem(t,e)},each:function(t){for(var e=ra().length-1;e>=0;e--){var r=ra().key(e);t(na(r),r)}},remove:function(t){return ra().removeItem(t)},clearAll:function(){return ra().clear()}},Ri],ia=[Di,Li],aa=xi.createStore(oa,ia),ua=ta,ca=aa,sa=function(t){var e;return(e={}).args=t,e};function fa(t,e){var r;return(r={})[t]=e,r[p]=[li()],r}var la=function(t){return W(t,"data")&&!W(t,"error")?t.data:t},pa=function(t){this.opts=t,this.instanceKey=dt(this.opts.hostname)+"",this.localStore=ua,this.sessionStore=ca},ha={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};pa.prototype.__setMethod=function(t,e){var r,n=this[t],o=(this.__getMethod(t),this.opts.storageKey),i=this.instanceKey;n.set(o,((r={})[i]=n?$o({},n,e):e,r))},pa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},pa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},pa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},ha.lset.set=function(t){return this.__setMethod("localStore",t)},ha.lget.get=function(){return this.__getMethod("localStore")},pa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},pa.prototype.lclear=function(){return this.__clearMethod("localStore")},ha.sset.set=function(t){return this.__setMethod("sessionStore",t)},ha.sget.get=function(){return this.__getMethod("sessionStore")},pa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},pa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(pa.prototype,ha);var da=h[0],va=h[1],ga=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},r.jsonqlToken.set=function(t){var e;this.sset=((e={}).jsonqlcredential=t,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlToken.get=function(){var t=this.sget;return!!t&&t.jsonqlcredential},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Qt)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ht(t))throw new it("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ht(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=$o({},{_cb:li()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=$o({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=$o({},{method:da,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return la(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ui(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):la(o)}),(function(t){throw e.cleanUp(),console.error(t),new ut("Server side error",t)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?$o({},a,this.getAuthHeader(),this.extraHeader):$o({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=$o({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(lt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new ut("getRemoteContract",t)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Wt(t)&&O(e)){var n=sa(e);return!0===r?n:fa(t,n)}throw new it("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(lt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Wt(t))return fa(t,o);throw new it("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:va}).then(lt)},Object.defineProperties(e.prototype,r),e}(pa)))),ya=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,V(t))}),Reflect.apply(t,null,r))}};function ba(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function ma(t,e,r,n){void 0===n&&(n=!1);var o=ba(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var _a=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ci(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(pt)}},wa=function(t,e,r,n,o){var i={},a=function(t){i=ma(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ci(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(pt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},ja=function(t,e,r,n,o){var i={},a=function(t){i=ma(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return ci(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(pt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Oa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=_a(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=_a(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Sa=function(t,e,r,n){var o=function(t,e,r,n){return ya(wa,ja,Oa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.userdata},o.getToken=function(){return t.rawAuthToken}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),o.eventEmitter=n,o.version="1.5.0",o},ka={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ea={hostname:si(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:si("jsonql",["string"]),loginHandlerName:si("login",["string"]),logoutHandlerName:si("logout",["string"]),enableJsonp:si(!1,["boolean"]),enableAuth:si(!1,["boolean"]),useJwt:si(!0,["boolean"]),persistToken:si(!1,["boolean","number"]),useLocalstorage:si(!0,["boolean"]),storageKey:si("jsonqlstore",["string"]),authKey:si("jsonqlauthkey",["string"]),contractExpired:si(0,["number"]),keepContract:si(!0,["boolean"]),exposeContract:si(!1,["boolean"]),showContractDesc:si(!1,["boolean"]),contractKey:si(!1,["boolean"]),contractKeyName:si("X-JSONQL-CV-KEY",["string"]),enableTimeout:si(!1,["boolean"]),timeout:si(5e3,["number"]),returnInstance:si(!1,["boolean"]),allowReturnRawToken:si(!1,["boolean"]),debugOn:si(!1,["boolean"])};function Aa(t){return ba(t,_)?Promise.resolve(t):function(t){var e=t.contract;return fi(t,Ea,ka).then((function(t){return t.contract=e,t}))}(t)}var Ta=new WeakMap,xa=new WeakMap,Pa=function(){this.__suspend__=null,this.queueStore=new Set},qa={$suspend:{configurable:!0},$queues:{configurable:!0}};qa.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Pa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},qa.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Pa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Pa.prototype,qa);var Ca=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Ta.set(this,t)},r.normalStore.get=function(){return Ta.get(this)},r.lazyStore.set=function(t){xa.set(this,t)},r.lazyStore.get=function(){return xa.get(this)},e.prototype.hashFnToKey=function(t){return dt(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Pa));function $a(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Aa(e).then((function(t){return{baseClient:new ga(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return vt(r,n.contract).then((function(e){return Sa(r,n,e,t)}))}))}((r=e.debugOn,new Ca({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),$a(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="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.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],S="application/x-www-form-urlencoded";for(var O in o.trim((j||"").toLowerCase())===S?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(S="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=S),r.headers)if(O===u&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",S=Array.isArray,O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},k="object"==typeof O&&O&&O.Object===Object&&O,E="object"==typeof self&&self&&self.Object===Object&&self,A=k||E||Function("return this")(),x=A.Symbol,T=Object.prototype,P=T.hasOwnProperty,q=T.toString,C=x?x.toStringTag:void 0;var $=Object.prototype.toString;var z="[object Null]",N="[object Undefined]",R=x?x.toStringTag:void 0;function M(t){return null==t?void 0===t?N:z:R&&R in Object(t)?function(t){var e=P.call(t,C),r=t[C];try{t[C]=void 0;var n=!0}catch(t){}var o=q.call(t);return n&&(e?t[C]=r:delete t[C]),o}(t):function(t){return $.call(t)}(t)}function I(t,e){return function(r){return t(e(r))}}var F=I(Object.getPrototypeOf,Object);function J(t){return null!=t&&"object"==typeof t}var D="[object Object]",U=Function.prototype,H=Object.prototype,L=U.toString,B=H.hasOwnProperty,K=L.call(Object);function G(t){if(!J(t)||M(t)!=D)return!1;var e=F(t);if(null===e)return!0;var r=B.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&L.call(r)==K}var V=function(t){return S(t)?t:[t]},W=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),it=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),at=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),ut=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),ct=Object.freeze({__proto__:null,Jsonql406Error:Y,Jsonql500Error:Q,JsonqlAuthorisationError:X,JsonqlContractAuthError:Z,JsonqlResolverAppError:tt,JsonqlResolverNotFoundError:et,JsonqlEnumError:rt,JsonqlTypeError:nt,JsonqlCheckerError:ot,JsonqlValidationError:it,JsonqlError:at,JsonqlServerError:ut}),st=at,ft=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function lt(t){if(ft(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&ct[o])throw new ct[r](i,a);throw new st(i,a)}return t}function pt(t){if(Array.isArray(t))throw new it("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof Y:throw new Y(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof ut:throw new ut(e,r);default:throw new at(e,r)}}function ht(t){return!!function(t){return G(t)&&(W(t,u)||W(t,c)||W(t,s))}(t)&&t}function dt(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var vt=function(t,e){return void 0===e&&(e={}),ht(e)?Promise.resolve(e):t.getContract()},gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function yt(t){this.message=t}yt.prototype=new Error,yt.prototype.name="InvalidCharacterError";var bt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new yt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=gt.indexOf(n);return a};var mt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(bt(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return bt(e)}};function _t(t){this.message=t}_t.prototype=new Error,_t.prototype.name="InvalidTokenError";var wt=function(t,e){if("string"!=typeof t)throw new _t("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(mt(t.split(".")[r]))}catch(t){throw new _t("Invalid token specified: "+t.message)}},jt=_t;function St(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&Ct(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Vt="[object String]";function Wt(t){return"string"==typeof t||!S(t)&&J(t)&&M(t)==Vt}var Yt=function(t){return""!==Gt(t)&&Wt(t)},Qt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Xt(t){if(Yt(t))return function(t){var e=t.iat||Qt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new at("Token has expired on "+r,t)}return t}(wt(t));throw new at("Token must be a string!")}var Zt=function(t){return!!S(t)||null!=t&&""!==Gt(t)},te="[object Number]";function ee(t){return function(t){return"number"==typeof t||J(t)&&M(t)==te}(t)&&t!=+t}var re=function(t){return!Wt(t)&&!ee(parseFloat(t))},ne=function(t){return null!=t&&"boolean"==typeof t},oe=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Gt(t)&&(!1===e||!0===e&&null!==t)},ie=d,ae=v,ue=g,ce=y,se=b,fe=m,le="continue",pe=function(t){switch(t){case"number":return re;case"string":return Yt;case"boolean":return ne;default:return oe}},he=function(t,e){return void 0===e&&(e=""),!!S(t)&&(""===e||""===Gt(e)||!(t.filter((function(t){return!pe(e)(t)})).length>0))},de=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ve=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!pe(e)(t)})).length)})).length:e.length>e.filter((function(t){return!he(r,t)})).length};var ge,ye=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ge?a:++n];if(!1===e(o[u],u,o))break}return t};var be="[object Arguments]";function me(t){return J(t)&&M(t)==be}var _e=Object.prototype,we=_e.hasOwnProperty,je=_e.propertyIsEnumerable,Se=me(function(){return arguments}())?me:function(t){return J(t)&&we.call(t,"callee")&&!je.call(t,"callee")};var Oe="object"==typeof exports&&exports&&!exports.nodeType&&exports,ke=Oe&&"object"==typeof module&&module&&!module.nodeType&&module,Ee=ke&&ke.exports===Oe?A.Buffer:void 0,Ae=(Ee?Ee.isBuffer:void 0)||function(){return!1},xe=9007199254740991,Te=/^(?:0|[1-9]\d*)$/;function Pe(t,e){var r=typeof t;return!!(e=null==e?xe:e)&&("number"==r||"symbol"!=r&&Te.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=qe}var $e={};$e["[object Float32Array]"]=$e["[object Float64Array]"]=$e["[object Int8Array]"]=$e["[object Int16Array]"]=$e["[object Int32Array]"]=$e["[object Uint8Array]"]=$e["[object Uint8ClampedArray]"]=$e["[object Uint16Array]"]=$e["[object Uint32Array]"]=!0,$e["[object Arguments]"]=$e["[object Array]"]=$e["[object ArrayBuffer]"]=$e["[object Boolean]"]=$e["[object DataView]"]=$e["[object Date]"]=$e["[object Error]"]=$e["[object Function]"]=$e["[object Map]"]=$e["[object Number]"]=$e["[object Object]"]=$e["[object RegExp]"]=$e["[object Set]"]=$e["[object String]"]=$e["[object WeakMap]"]=!1;var ze,Ne="object"==typeof exports&&exports&&!exports.nodeType&&exports,Re=Ne&&"object"==typeof module&&module&&!module.nodeType&&module,Me=Re&&Re.exports===Ne&&k.process,Ie=function(){try{var t=Re&&Re.require&&Re.require("util").types;return t||Me&&Me.binding&&Me.binding("util")}catch(t){}}(),Fe=Ie&&Ie.isTypedArray,Je=Fe?(ze=Fe,function(t){return ze(t)}):function(t){return J(t)&&Ce(t.length)&&!!$e[M(t)]},De=Object.prototype.hasOwnProperty;function Ue(t,e){var r=S(t),n=!r&&Se(t),o=!r&&!n&&Ae(t),i=!r&&!n&&!o&&Je(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ir.prototype.set=function(t,e){var r=this.__data__,n=nr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ar,ur=A["__core-js_shared__"],cr=(ar=/[^.]+$/.exec(ur&&ur.keys&&ur.keys.IE_PROTO||""))?"Symbol(src)_1."+ar:"";var sr=Function.prototype.toString;function fr(t){if(null!=t){try{return sr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var lr=/^\[object .+?Constructor\]$/,pr=Function.prototype,hr=Object.prototype,dr=pr.toString,vr=hr.hasOwnProperty,gr=RegExp("^"+dr.call(vr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yr(t){return!(!Ge(t)||function(t){return!!cr&&cr in t}(t))&&(Xe(t)?gr:lr).test(fr(t))}function br(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return yr(r)?r:void 0}var mr=br(A,"Map"),_r=br(Object,"create");var wr="__lodash_hash_undefined__",jr=Object.prototype.hasOwnProperty;var Sr=Object.prototype.hasOwnProperty;var Or="__lodash_hash_undefined__";function kr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&zr?new qr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=de(t))?!ve({arg:r},e):!pe(t)(r))})).length)})).length}return!1},eo=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(to,null,a);case"array"===t:return!he(e.arg);case!1!==(r=de(t)):return!ve(e,r);default:return!pe(t)(e.arg)}},ro=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},no=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!he(e))throw new at("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!he(t))throw new at("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?ro(t,a):t,index:r,param:a,optional:i}}));default:throw new at("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Zt(e)&&!(r.type.length>r.type.filter((function(e){return eo(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return eo(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},oo=function(){try{var t=br(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function io(t,e,r){"__proto__"==e&&oo?oo(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ao(t,e,r){(void 0===r||rr(t[e],r))&&(void 0!==r||e in t)||io(t,e,r)}var uo="object"==typeof exports&&exports&&!exports.nodeType&&exports,co=uo&&"object"==typeof module&&module&&!module.nodeType&&module,so=co&&co.exports===uo?A.Buffer:void 0,fo=so?so.allocUnsafe:void 0;function lo(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Rr(n).set(new Rr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var po=Object.create,ho=function(){function t(){}return function(e){if(!Ge(e))return{};if(po)return po(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function vo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var go=Object.prototype.hasOwnProperty;function yo(t,e,r){var n=t[e];go.call(t,e)&&rr(n,r)&&(void 0!==r||e in t)||io(t,e,r)}var bo=Object.prototype.hasOwnProperty;function mo(t){if(!Ge(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Le(t),r=[];for(var n in t)("constructor"!=n||!e&&bo.call(t,n))&&r.push(n);return r}function _o(t){return Ze(t)?Ue(t,!0):mo(t)}function wo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=Ao)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Eo);function qo(t,e){return Po(function(t,e,r){return e=ko(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ko(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Co.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Ge(r))return!1;var n=typeof e;return!!("number"==n?Ze(r)&&Pe(e,r.length):"string"==n&&e in r)&&rr(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ni().key(e);t(Ri(r),r)}},remove:function(t){return Ni().removeItem(t)},clearAll:function(){return Ni().clear()}};function Ni(){return $i.localStorage}function Ri(t){return Ni().getItem(t)}var Mi=yi.trim,Ii={name:"cookieStorage",read:function(t){if(!t||!Ui(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Fi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Fi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ji,remove:Di,clearAll:function(){Ji((function(t,e){Di(e)}))}},Fi=yi.Global.document;function Ji(t){for(var e=Fi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Mi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Di(t){t&&Ui(t)&&(Fi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Ui(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Fi.cookie)}var Hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Li=yi.bind,Bi=yi.each,Ki=yi.create,Gi=yi.slice,Vi=function(){var t=Ki(Wi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Li(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Li(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Bi(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Wi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Li(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Gi(arguments,1);Bi(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Yi=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Qi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Yi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Yi.compress(this._serialize(r));t(e,n)}}};var Xi=[zi,Ii],Zi=[Hi,Vi,Qi],ta=Pi.createStore(Xi,Zi),ea=yi.Global;function ra(){return ea.sessionStorage}function na(t){return ra().getItem(t)}var oa=[{name:"sessionStorage",read:na,write:function(t,e){return ra().setItem(t,e)},each:function(t){for(var e=ra().length-1;e>=0;e--){var r=ra().key(e);t(na(r),r)}},remove:function(t){return ra().removeItem(t)},clearAll:function(){return ra().clear()}},Ii],ia=[Hi,Qi],aa=Pi.createStore(oa,ia),ua=ta,ca=aa,sa=function(t){var e;return(e={}).args=t,e};function fa(t,e){var r;return(r={})[t]=e,r[p]=[pi()],r}var la=function(t){return W(t,"data")&&!W(t,"error")?t.data:t},pa=function(t){this.opts=t,this.instanceKey=dt(this.opts.hostname)+"",this.localStore=ua,this.sessionStore=ca},ha={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};pa.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?$o({},o,e):e,r))},pa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},pa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},pa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},ha.lset.set=function(t){return this.__setMethod("localStore",t)},ha.lget.get=function(){return this.__getMethod("localStore")},pa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},pa.prototype.lclear=function(){return this.__clearMethod("localStore")},ha.sset.set=function(t){return this.__setMethod("sessionStore",t)},ha.sget.get=function(){return this.__getMethod("sessionStore")},pa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},pa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(pa.prototype,ha);var da=h[0],va=h[1],ga=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Xt)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(ci(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new it("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&ci(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,t},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ht(t))throw new it("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ht(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=$o({},{_cb:pi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=$o({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=$o({},{method:da,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return la(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ui(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):la(o)}),(function(t){throw e.cleanUp(),console.error(t),new ut("Server side error",t)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?$o({},a,this.getAuthHeader(),this.extraHeader):$o({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=$o({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(lt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new ut("getRemoteContract",t)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Wt(t)&&S(e)){var n=sa(e);return!0===r?n:fa(t,n)}throw new it("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(lt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Wt(t))return fa(t,o);throw new it("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:va}).then(lt)},Object.defineProperties(e.prototype,r),e}(pa)))),ya=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,V(t))}),Reflect.apply(t,null,r))}};function ba(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function ma(t,e,r,n){void 0===n&&(n=!1);var o=ba(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var _a=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return si(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(pt)}},wa=function(t,e,r,n,o){var i={},a=function(t){i=ma(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return si(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(pt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},ja=function(t,e,r,n,o){var i={},a=function(t){i=ma(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return si(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(pt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Sa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=_a(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=_a(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Oa=function(t,e,r,n){var o=function(t,e,r,n){return ya(wa,ja,Sa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.1",o.log=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return Reflect.apply(t.log,t,["[DEV DEBUG]"].concat(e))},o},ka={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ea={hostname:fi(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:fi("jsonql",["string"]),loginHandlerName:fi("login",["string"]),logoutHandlerName:fi("logout",["string"]),enableJsonp:fi(!1,["boolean"]),enableAuth:fi(!1,["boolean"]),useJwt:fi(!0,["boolean"]),persistToken:fi(!1,["boolean","number"]),useLocalstorage:fi(!0,["boolean"]),storageKey:fi("jsonqlstore",["string"]),authKey:fi("jsonqlauthkey",["string"]),contractExpired:fi(0,["number"]),keepContract:fi(!0,["boolean"]),exposeContract:fi(!1,["boolean"]),exposeStore:fi(!1,["boolean"]),showContractDesc:fi(!1,["boolean"]),contractKey:fi(!1,["boolean"]),contractKeyName:fi("X-JSONQL-CV-KEY",["string"]),enableTimeout:fi(!1,["boolean"]),timeout:fi(5e3,["number"]),returnInstance:fi(!1,["boolean"]),allowReturnRawToken:fi(!1,["boolean"]),debugOn:fi(!1,["boolean"])};function Aa(t){return ba(t,_)?Promise.resolve(t):function(t){var e=t.contract;return li(t,Ea,ka).then((function(t){return t.contract=e,t}))}(t)}var xa=new WeakMap,Ta=new WeakMap,Pa=function(){this.__suspend__=null,this.queueStore=new Set},qa={$suspend:{configurable:!0},$queues:{configurable:!0}};qa.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Pa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},qa.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Pa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Pa.prototype,qa);var Ca=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){xa.set(this,t)},r.normalStore.get=function(){return xa.get(this)},r.lazyStore.set=function(t){Ta.set(this,t)},r.lazyStore.get=function(){return Ta.get(this)},e.prototype.hashFnToKey=function(t){return dt(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Pa));function $a(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Aa(e).then((function(t){return{baseClient:new ga(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return vt(r,n.contract).then((function(e){return Oa(r,n,e,t)}))}))}((r=e.debugOn,new Ca({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),$a(new o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js.map b/packages/http-client/dist/jsonql-client.umd.js.map index d908513484ff765a54553d47ef5c9b7ce5ec5c91..020e341adac1bdfe009f6c20370da6d4792d467e 100644 --- a/packages/http-client/dist/jsonql-client.umd.js.map +++ b/packages/http-client/dist/jsonql-client.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.js","../node_modules/store/plugins/expire.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i 0) { - const ts = timestamp() - args.push( ts + parseFloat(expired) ) - } - } - this.storeIt = args; - // now decode it and store in the userdata - this.jsonqlUserdata = this.decoder(token) - return token; - } - */ - } - - /** - * this one will use the sessionStore - * basically we hook this onto the token store and decode it to store here - */ - set jsonqlUserdata(userdata) { - this.sset = {[USERDATA_TABLE]: userdata} - /* - const args = [USERDATA_TABLE, userdata] - if (userdata.exp) { - args.push(userdata.exp) - } - return Reflect.apply(localStore.set, localStore, args) - */ - } - - /** - * Jsonql token getter - * @return {string|boolean} false when failed - */ - get jsonqlToken() { - const data = this.sget - return data ? data[CREDENTIAL_STORAGE_KEY] : false - } - - /** - * this one store in the session store - * get login userdata decoded jwt - * @return {object|null} - */ - get jsonqlUserdata() { - const data = this.sget - return data ? data[USERDATA_TABLE] : false - } - /** * simple log */ diff --git a/packages/http-client/src/base/store-cls.js b/packages/http-client/src/base/store-cls.js index 3cb0671b721b4fc1f5cd96c516507f978e817b85..5659b0986dc4ffe9b8ec19d0dadd167151b77d02 100644 --- a/packages/http-client/src/base/store-cls.js +++ b/packages/http-client/src/base/store-cls.js @@ -15,6 +15,16 @@ export default class StoreClass { // pass this store for use later this.localStore = localStore this.sessionStore = sessionStore + /* + if (this.opts.debugOn) { // reuse this to clear out the data + this.log('clear all stores') + localStore.clearAll() + sessionStore.clearAll() + + localStore.set('TEST', Date.now()) + sessionStore.set('TEST', Date.now()) + } + */ } // store in local storage id by the instanceKey // values should be an object so with key so we just merge @@ -25,7 +35,7 @@ export default class StoreClass { const skey = this.opts.storageKey const ikey = this.instanceKey store.set(skey, { - [ikey]: store ? merge({}, store, values) : values + [ikey]: data ? merge({}, data, values) : values }) } // return the data id by the instaceKey @@ -81,6 +91,7 @@ export default class StoreClass { // store in session store id by the instanceKey set sset(values) { + // this.log('--- sset ---', values) return this.__setMethod(CLS_SESS_STORE_NAME, values) } @@ -95,4 +106,6 @@ export default class StoreClass { sclear() { return this.__clearMethod(CLS_SESS_STORE_NAME) } + + } diff --git a/packages/http-client/src/core/jsonql-api-generator.js b/packages/http-client/src/core/jsonql-api-generator.js index 641d1ca924eeebff18031c142ce17b5f25b6a20c..45e1035ad3267350f1b67abfebe1f829606a4d31 100644 --- a/packages/http-client/src/core/jsonql-api-generator.js +++ b/packages/http-client/src/core/jsonql-api-generator.js @@ -15,7 +15,7 @@ import { finalCatch } from 'jsonql-errors' -import methodsGenerator from './methods-generator' +import { methodsGenerator } from './methods-generator' /** * @param {object} jsonqlInstance jsonql class instance @@ -34,10 +34,19 @@ const generator = (jsonqlInstance, config, contract, ee) => { * @TODO allow to pass an id to switch to different userdata * @return {*} userdata */ - client.userdata = () => jsonqlInstance.userdata; + client.userdata = () => jsonqlInstance.jsonqlUserdata; // allow getting the token for valdiate agains the socket // if it's not require auth there is no point of calling getToken - client.getToken = () => jsonqlInstance.rawAuthToken; + client.getToken = (idx = false) => jsonqlInstance.rawAuthToken(idx); + // switch profile or read back what is the currenct index + client.profileIndex = (idx = false) => { + if (idx === false) { + return jsonqlInstance.profileIndex + } + jsonqlInstance.profileIndex = idx + } + // new in 1.5.1 to return different profiles + client.getProfiles = (idx = false) => jsonqlInstance.getProfiles(idx); } // this will pass to the ws-client if needed // client.eventEmitter = ee; @@ -46,11 +55,24 @@ const generator = (jsonqlInstance, config, contract, ee) => { // 1.4.0 change from the get (raw) to the getContract cache and raw version client.getContract = () => jsonqlInstance.getContract() } - // this is for the ws to use later + // allow developer to access the store api + if (config.exposeStore) { + // @TODO in 1.5.2 + client.tmpSave = data => {} + client.tmpGet = (key = false) => {} + client.tmpDel = (key = false) => {} + + client.persistSave = data => {} + client.persistGet = (key = false) => {} + client.persistDel = (key = false) => {} + } + // this is for the ws to use later - but this could be dangerous because it's expose the internal client.eventEmitter = ee; client.version = '__VERSION__'; + // use this method then we can hook into the debugOn at the same time + client.log = (...args) => Reflect.apply(jsonqlInstance.log, jsonqlInstance, ['[DEV DEBUG]'].concat(args)) // output return client; -}; - -export default generator; +} +// export +export default generator diff --git a/packages/http-client/src/core/jsonql-static-generator.js b/packages/http-client/src/core/jsonql-static-generator.js index 138c89d94b1e24a055801adf19fe93b181565f40..02a2b03f1821041393716424319b9140ba49d31f 100644 --- a/packages/http-client/src/core/jsonql-static-generator.js +++ b/packages/http-client/src/core/jsonql-static-generator.js @@ -3,7 +3,7 @@ import { ON_RESULT_PROP_NAME, ON_ERROR_PROP_NAME } from 'jsonql-constants' import { createEvt } from 'jsonql-utils/src/generic' -import methodsGenerator from './methods-generator' +import { methodsGenerator } from './methods-generator' /** * Group all the same methods together diff --git a/packages/http-client/src/core/methods-generator.js b/packages/http-client/src/core/methods-generator.js index a3c10743ac2af44553a73ab786d3f9f65276803d..dd6a0df3d6b6fc3aeb5afb80f34823658646102e 100644 --- a/packages/http-client/src/core/methods-generator.js +++ b/packages/http-client/src/core/methods-generator.js @@ -6,7 +6,7 @@ import { finalCatch } from 'jsonql-errors' import { validateAsync } from 'jsonql-params-validator' -import { LOGOUT_NAME, ISSUER_NAME, KEY_WORD } from 'jsonql-constants' +import { LOGOUT_NAME, LOGIN_NAME, KEY_WORD } from 'jsonql-constants' import { chainFns } from 'jsonql-utils/src/chain-fns' import { injectToFn } from 'jsonql-utils/src/obj-define-props' @@ -48,13 +48,11 @@ const createQueryMethods = (obj, jsonqlInstance, ee, config, contract) => { // const fn = (_contract.query[queryFn].auth === true) ? 'auth' : queryFn; // generate the query method query = injectToFn(query, queryFn, function queryFnHandler(...args) { - // obj.query[queryFn] = (...args) => { const params = contract.query[queryFn].params; const _args = params.map((param, i) => args[i]) // debug('query', queryFn, _params); - // @TODO this need to change - // the +1 parameter is the extra headers we want to pass - const header = args[params.length] || {}; + // @TODO this need to change to a different way to add an extra header + const header = {} // @TODO validate against the type return validateAsync(_args, params) .then(() => jsonqlInstance @@ -86,7 +84,6 @@ const createMutationMethods = (obj, jsonqlInstance, ee, config, contract) => { // plus a header at the end for (let mutationFn in contract.mutation) { mutation = injectToFn(mutation, mutationFn, function mutationFnHandler(payload, conditions, header = {}) { - //obj.mutation[mutationFn] = (payload, conditions, header = {}) => { const args = [payload, conditions]; const params = contract.mutation[mutationFn].params; return validateAsync(args, params) @@ -119,9 +116,9 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { auth[loginHandlerName] = function loginHandlerFn(...args) { const fn = authMethodGenerator(jsonqlInstance, loginHandlerName, config, contract) return fn.apply(null, args) - .then(jsonqlInstance.postLoginAction) + .then(jsonqlInstance.postLoginAction.bind(jsonqlInstance)) .then(token => { - ee.$trigger(ISSUER_NAME, token) + ee.$trigger(LOGIN_NAME, token) return token; }) } @@ -131,7 +128,7 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { auth[logoutHandlerName] = function logoutHandlerFn(...args) { const fn = authMethodGenerator(jsonqlInstance, logoutHandlerName, config, contract) return fn.apply(null, args) - .then(jsonqlInstance.postLogoutAction) + .then(jsonqlInstance.postLogoutAction.bind(jsonqlInstance)) .then(r => { ee.$trigger(LOGOUT_NAME, r) return r; @@ -143,17 +140,6 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { ee.$trigger(LOGOUT_NAME, KEY_WORD) } } - /* - // @TODO add new switch profile index method - auth.switchProfile = function switchProfile(idx) { - - } - // @TODO return all current user profiles - auth.getProfiles = function getProfiles() { - - } - - */ obj.auth = auth; } @@ -168,7 +154,7 @@ const createAuthMethods = (obj, jsonqlInstance, ee, config, contract) => { * @param {object} contract the map * @return {object} with mapped methods */ -export default function methodsGenerator(jsonqlInstance, ee, config, contract) { +export function methodsGenerator(jsonqlInstance, ee, config, contract) { let obj = {} const executor = chainFns(createQueryMethods, createMutationMethods, createAuthMethods) return executor(obj, jsonqlInstance, ee, config, contract) diff --git a/packages/http-client/src/jsonql-utils.js b/packages/http-client/src/jsonql-utils.js deleted file mode 100644 index a6189da476e7d92b8349b1c17a127af70a967b0b..0000000000000000000000000000000000000000 --- a/packages/http-client/src/jsonql-utils.js +++ /dev/null @@ -1,1367 +0,0 @@ -// break it out on its own because -// it's building from the lodash-es from scratch -// according to this discussion https://github.com/lodash/lodash/issues/3298 - -/** - * using just the map reduce to chain multiple functions together - * @param {function} mainFn the init function - * @param {array} moreFns as many as you want to take the last value and return a new one - * @return {function} accept value for the mainFn - */ -var chainFns = function (mainFn) { - var moreFns = [], len = arguments.length - 1; - while ( len-- > 0 ) moreFns[ len ] = arguments[ len + 1 ]; - - return ( - function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - return ( - moreFns.reduce(function (value, nextFn) { return ( - Reflect.apply(nextFn, null, [value]) - ); }, Reflect.apply(mainFn, null, args)) - ); - } -); -}; - -/** - * previously we already make sure the order of the namespaces - * and attach the auth client to it - * @param {array} promises array of unresolved promises - * @return {object} promise resolved with the array of promises resolved results - */ -function chainPromises(promises) { - return promises.reduce(function (promiseChain, currentTask) { return ( - promiseChain.then(function (chainResults) { return ( - currentTask.then(function (currentResult) { return ( - chainResults.concat( [currentResult]) - ); }) - ); }) - ); }, Promise.resolve([])) -} - -/** - * this is essentially the same as the injectToFn - * but this will not allow overwrite and set the setter and getter - * @param {object} obj to get injected - * @param {string} name of the property - * @param {function} setter for set - * @param {function} [getter=null] for get default return null fn - * @return {object} the injected obj - */ -function objDefineProps(obj, name, setter, getter) { - if ( getter === void 0 ) getter = null; - - if (Object.getOwnPropertyDescriptor(obj, name) === undefined) { - Object.defineProperty(obj, name, { - set: setter, - get: getter === null ? function() { return null; } : getter - }); - } - return obj -} - -/** - * After the user login we will use this Object.define add a new property - * to the resolver with the decoded user data - * @param {function} resolver target resolver - * @param {string} name the name of the object to get inject also for checking - * @param {object} data to inject into the function static interface - * @param {boolean} [overwrite=false] if we want to overwrite the existing data - * @return {function} added property resolver - */ -function injectToFn(resolver, name, data, overwrite) { - if ( overwrite === void 0 ) overwrite = false; - - var check = Object.getOwnPropertyDescriptor(resolver, name); - if (overwrite === false && check !== undefined) { - // console.info(`NOT INJECTED`) - return resolver; - } - /* this will throw error! - if (overwrite === true && check !== undefined) { - delete resolver[name] // delete this property - } - */ - // console.info(`INJECTED`) - Object.defineProperty(resolver, name, { - value: data, - writable: overwrite // if its set to true then we should able to overwrite it - }); - - return resolver; -} - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -var global$1 = (typeof global !== "undefined" ? global : - typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : {}); - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global$1 == 'object' && global$1 && global$1.Object === Object && global$1; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** Built-in value references. */ -var Symbol = root.Symbol; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; - -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - -/** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ -function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; - - try { - value[symToStringTag] = undefined; - var unmasked = true; - } catch (e) {} - - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; -} - -/** Used for built-in method references. */ -var objectProto$1 = Object.prototype; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString$1 = objectProto$1.toString; - -/** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ -function objectToString(value) { - return nativeObjectToString$1.call(value); -} - -/** `Object#toString` result references. */ -var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; - -/** Built-in value references. */ -var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined; - -/** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag$1 && symToStringTag$1 in Object(value)) - ? getRawTag(value) - : objectToString(value); -} - -/** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -/** Built-in value references. */ -var getPrototype = overArg(Object.getPrototypeOf, Object); - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return value != null && typeof value == 'object'; -} - -/** `Object#toString` result references. */ -var objectTag = '[object Object]'; - -/** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto$2 = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty$1 = objectProto$2.hasOwnProperty; - -/** Used to infer the `Object` constructor. */ -var objectCtorString = funcToString.call(Object); - -/** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @static - * @memberOf _ - * @since 0.8.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ -function isPlainObject(value) { - if (!isObjectLike(value) || baseGetTag(value) != objectTag) { - return false; - } - var proto = getPrototype(value); - if (proto === null) { - return true; - } - var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor; - return typeof Ctor == 'function' && Ctor instanceof Ctor && - funcToString.call(Ctor) == objectCtorString; -} - -/** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && baseGetTag(value) == symbolTag); -} - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return arrayMap(value, baseToString) + ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -/** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ -function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; -} - -/** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ -function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : baseSlice(array, start, end); -} - -/** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} - -/** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ -function baseIsNaN(value) { - return value !== value; -} - -/** - * A specialized version of `_.indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; -} - -/** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseIndexOf(array, value, fromIndex) { - return value === value - ? strictIndexOf(array, value, fromIndex) - : baseFindIndex(array, baseIsNaN, fromIndex); -} - -/** - * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the last unmatched string symbol. - */ -function charsEndIndex(strSymbols, chrSymbols) { - var index = strSymbols.length; - - while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; -} - -/** - * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the first unmatched string symbol. - */ -function charsStartIndex(strSymbols, chrSymbols) { - var index = -1, - length = strSymbols.length; - - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; -} - -/** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function asciiToArray(string) { - return string.split(''); -} - -/** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -var rsZWJ = '\\u200d'; - -/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ -var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); - -/** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ -function hasUnicode(string) { - return reHasUnicode.test(string); -} - -/** Used to compose unicode character classes. */ -var rsAstralRange$1 = '\\ud800-\\udfff', - rsComboMarksRange$1 = '\\u0300-\\u036f', - reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f', - rsComboSymbolsRange$1 = '\\u20d0-\\u20ff', - rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, - rsVarRange$1 = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -var rsAstral = '[' + rsAstralRange$1 + ']', - rsCombo = '[' + rsComboRange$1 + ']', - rsFitz = '\\ud83c[\\udffb-\\udfff]', - rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', - rsNonAstral = '[^' + rsAstralRange$1 + ']', - rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', - rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', - rsZWJ$1 = '\\u200d'; - -/** Used to compose unicode regexes. */ -var reOptMod = rsModifier + '?', - rsOptVar = '[' + rsVarRange$1 + ']?', - rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsSeq = rsOptVar + reOptMod + rsOptJoin, - rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - -/** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function unicodeToArray(string) { - return string.match(reUnicode) || []; -} - -/** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function stringToArray(string) { - return hasUnicode(string) - ? unicodeToArray(string) - : asciiToArray(string); -} - -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - return value == null ? '' : baseToString(value); -} - -/** Used to match leading and trailing whitespace. */ -var reTrim = /^\s+|\s+$/g; - -/** - * Removes leading and trailing whitespace or specified characters from `string`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the trimmed string. - * @example - * - * _.trim(' abc '); - * // => 'abc' - * - * _.trim('-_-abc-_-', '_-'); - * // => 'abc' - * - * _.map([' foo ', ' bar '], _.trim); - * // => ['foo', 'bar'] - */ -function trim(string, chars, guard) { - string = toString(string); - if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); - } - if (!string || !(chars = baseToString(chars))) { - return string; - } - var strSymbols = stringToArray(string), - chrSymbols = stringToArray(chars), - start = charsStartIndex(strSymbols, chrSymbols), - end = charsEndIndex(strSymbols, chrSymbols) + 1; - - return castSlice(strSymbols, start, end).join(''); -} - -/** `Object#toString` result references. */ -var stringTag = '[object String]'; - -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ -function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); -} - -// bunch of generic helpers - -/** - * DIY in Array - * @param {array} arr to check from - * @param {*} value to check against - * @return {boolean} true on found - */ -var inArray = function (arr, value) { return !!arr.filter(function (a) { return a === value; }).length; }; - -/** - * @param {object} obj for search - * @param {string} key target - * @return {boolean} true on success - */ -var isObjectHasKey = function(obj, key) { - var keys = Object.keys(obj); - return inArray(keys, key) -}; - -/** - * create a event name - * @param {string[]} args - * @return {string} event name for use - */ -var createEvt = function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - return args.join('_'); -}; - -/** - * @param {boolean} sec return in second or not - * @return {number} timestamp - */ -var timestamp = function (sec) { - if ( sec === void 0 ) sec = false; - - var time = Date.now(); - return sec ? Math.floor( time / 1000 ) : time; -}; - -/** - * construct a url with query parameters - * @param {string} url to append - * @param {object} params to append to url - * @return {string} url with appended params - */ -var urlParams = function (url, params) { - var parts = []; - for (var key in params) { - parts.push( [key, params[key]].join('=') ); - } - return [url, parts.join('&')].join('?') -}; - -/** - * construct a url with cache burster - * @param {string} url to append to - * @return {object} _cb key timestamp - */ -var cacheBurstUrl = function (url) { return urlParams(url, cacheBurst()); }; - -/** - * @return {object} _cb as key with timestamp - */ -var cacheBurst = function () { return ({ _cb: timestamp() }); }; - -/** - * From underscore.string library - * @BUG there is a bug here with the non-standard name start with _ - * @param {string} str string - * @return {string} dasherize string - */ -var dasherize = function (str) { return ( - trim(str) - .replace(/([A-Z])/g, '-$1') - .replace(/[-_\s]+/g, '-') - .toLowerCase() -); }; - -/** - * simple util method to get the value - * @param {string} name of the key - * @param {object} obj to take value from - * @return {*} the object value id by name or undefined - */ -var getConfigValue = function (name, obj) { return ( - obj && isPlainObject(obj) ? ( (name in obj) ? obj[name] : undefined ) : undefined -); }; - -/** - * Check several parameter that there is something in the param - * @param {*} param input - * @return {boolean} - */ -var isNotEmpty = function(param) { - return param !== undefined && param !== false && param !== null && trim(param) !== ''; -}; - -// the core stuff to id if it's calling with jsonql -var DATA_KEY = 'data'; -var ERROR_KEY = 'error'; - -// @TODO remove this is not in use -// export const CLIENT_CONFIG_FILE = '.clients.json'; -// export const CONTRACT_CONFIG_FILE = 'jsonql-contract-config.js'; -// type of resolvers -var QUERY_NAME = 'query'; -var MUTATION_NAME = 'mutation'; -var SOCKET_NAME = 'socket'; -// for calling the mutation -var PAYLOAD_PARAM_NAME = 'payload'; -var CONDITION_PARAM_NAME = 'condition'; -var RESOLVER_PARAM_NAME = 'resolverName'; -var QUERY_ARG_NAME = 'args'; - -// methods allow -var API_REQUEST_METHODS = ['POST', 'PUT']; -var NO_STATUS_CODE = -1; - -/** - * some time it's hard to tell where the error is throw from - * because client server throw the same, therefore this util fn - * to add a property to the error object to tell if it's throw - * from client or server - * - */ - -var isBrowser = function () { - try { - if (window || document) { - return true; - } - } catch(e) {} - return false; -}; - -var isNode = function () { - try { - if (!isBrowser() && global$1) { - return true; - } - } catch(e) {} - return false; -}; - -function whereAmI() { - if (isBrowser()) { - return 'browser' - } - if (isNode()) { - return 'node' - } - return 'unknown' -} - -// The base Error of all - -var JsonqlBaseError = /*@__PURE__*/(function (Error) { - function JsonqlBaseError() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - Error.apply(this, args); - } - - if ( Error ) JsonqlBaseError.__proto__ = Error; - JsonqlBaseError.prototype = Object.create( Error && Error.prototype ); - JsonqlBaseError.prototype.constructor = JsonqlBaseError; - - JsonqlBaseError.where = function where () { - return whereAmI() - }; - - return JsonqlBaseError; -}(Error)); - -/** - * This is a custom error to throw when could not find the resolver - * This help us to capture the right error, due to the call happens in sequence - * @param {string} message to tell what happen - * @param {mixed} extra things we want to add, 500? - */ -var JsonqlResolverNotFoundError = /*@__PURE__*/(function (JsonqlBaseError) { - function JsonqlResolverNotFoundError() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - JsonqlBaseError.apply(this, args); - - this.message = args[0]; - this.detail = args[1]; - - this.className = JsonqlResolverNotFoundError.name; - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, JsonqlResolverNotFoundError); - } - } - - if ( JsonqlBaseError ) JsonqlResolverNotFoundError.__proto__ = JsonqlBaseError; - JsonqlResolverNotFoundError.prototype = Object.create( JsonqlBaseError && JsonqlBaseError.prototype ); - JsonqlResolverNotFoundError.prototype.constructor = JsonqlResolverNotFoundError; - - var staticAccessors = { statusCode: { configurable: true },name: { configurable: true } }; - - staticAccessors.statusCode.get = function () { - return 404; - }; - - staticAccessors.name.get = function () { - return 'JsonqlResolverNotFoundError'; - }; - - Object.defineProperties( JsonqlResolverNotFoundError, staticAccessors ); - - return JsonqlResolverNotFoundError; -}(JsonqlBaseError)); - -// custom validation error class -// when validaton failed -var JsonqlValidationError = /*@__PURE__*/(function (JsonqlBaseError) { - function JsonqlValidationError() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - JsonqlBaseError.apply(this, args); - - this.message = args[0]; - this.detail = args[1]; - - this.className = JsonqlValidationError.name; - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, JsonqlValidationError); - } - } - - if ( JsonqlBaseError ) JsonqlValidationError.__proto__ = JsonqlBaseError; - JsonqlValidationError.prototype = Object.create( JsonqlBaseError && JsonqlBaseError.prototype ); - JsonqlValidationError.prototype.constructor = JsonqlValidationError; - - var staticAccessors = { name: { configurable: true } }; - - staticAccessors.name.get = function () { - return 'JsonqlValidationError'; - }; - - Object.defineProperties( JsonqlValidationError, staticAccessors ); - - return JsonqlValidationError; -}(JsonqlBaseError)); - -/** - * This is a custom error to throw whenever a error happen inside the jsonql - * This help us to capture the right error, due to the call happens in sequence - * @param {string} message to tell what happen - * @param {mixed} extra things we want to add, 500? - */ -var JsonqlError = /*@__PURE__*/(function (JsonqlBaseError) { - function JsonqlError() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - JsonqlBaseError.apply(this, args); - - this.message = args[0]; - this.detail = args[1]; - - this.className = JsonqlError.name; - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, JsonqlError); - // this.detail = this.stack; - } - } - - if ( JsonqlBaseError ) JsonqlError.__proto__ = JsonqlBaseError; - JsonqlError.prototype = Object.create( JsonqlBaseError && JsonqlBaseError.prototype ); - JsonqlError.prototype.constructor = JsonqlError; - - var staticAccessors = { name: { configurable: true },statusCode: { configurable: true } }; - - staticAccessors.name.get = function () { - return 'JsonqlError'; - }; - - staticAccessors.statusCode.get = function () { - return NO_STATUS_CODE; - }; - - Object.defineProperties( JsonqlError, staticAccessors ); - - return JsonqlError; -}(JsonqlBaseError)); - -// split the contract into the node side and the generic side -/** - * Check if the json is a contract file or not - * @param {object} contract json object - * @return {boolean} true - */ -function checkIsContract(contract) { - return isPlainObject(contract) - && ( - isObjectHasKey(contract, QUERY_NAME) - || isObjectHasKey(contract, MUTATION_NAME) - || isObjectHasKey(contract, SOCKET_NAME) - ) -} - -/** - * Ported from jsonql-params-validator but different - * if we don't find the socket part then return false - * @param {object} contract the contract object - * @return {object|boolean} false on failed - */ -function extractSocketPart(contract) { - if (isObjectHasKey(contract, 'socket')) { - return contract.socket; - } - return false; -} - -/** - * @BUG we should check the socket part instead of expect the downstream to read the menu! - * We only need this when the enableAuth is true otherwise there is only one namespace - * @param {object} contract the socket part of the contract file - * @param {boolean} [fallback=false] this is a fall back option for old code - * @return {object} 1. remap the contract using the namespace --> resolvers - * 2. the size of the object (1 all private, 2 mixed public with private) - * 3. which namespace is public - */ -function groupByNamespace(contract, fallback) { - if ( fallback === void 0 ) fallback = false; - - var socket = extractSocketPart(contract); - if (socket === false) { - if (fallback) { - return contract; // just return the whole contract - } - throw new JsonqlError("socket not found in contract!") - } - var nspSet = {}; - var size = 0; - var publicNamespace; - for (var resolverName in socket) { - var params = socket[resolverName]; - var namespace = params.namespace; - if (namespace) { - if (!nspSet[namespace]) { - ++size; - nspSet[namespace] = {}; - } - nspSet[namespace][resolverName] = params; - if (!publicNamespace) { - if (params.public) { - publicNamespace = namespace; - } - } - } - } - return { size: size, nspSet: nspSet, publicNamespace: publicNamespace } -} - -/** - * Extract the args from the payload - * @param {object} payload to work with - * @param {string} type of call - * @return {array} args - */ -function extractArgsFromPayload(payload, type) { - switch (type) { - case QUERY_NAME: - return payload[QUERY_ARG_NAME]; - case MUTATION_NAME: - return [ - payload[PAYLOAD_PARAM_NAME], - payload[CONDITION_PARAM_NAME] - ]; - default: - throw new JsonqlError(("Unknown " + type + " to extract argument from!")) - } -} - -/** - * Like what the name said - * @param {object} contract the contract json - * @param {string} type query|mutation - * @param {string} name of the function - * @return {object} the params part of the contract - */ -function extractParamsFromContract(contract, type, name) { - try { - var result = contract[type][name]; - // debug('extractParamsFromContract', result) - if (!result) { - // debug(name, type, contract) - throw new JsonqlResolverNotFoundError(name, type) - } - return result; - } catch(e) { - throw new JsonqlResolverNotFoundError(name, e) - } -} - -// ported from jsonql-params-validator - -/** - * make sure it's an object (it was call formatPayload but it doesn't make sense) - * @param {*} payload the object comes in could be string based - * @return {object} the transformed payload - */ -var toPayload = function (payload) { return isString(payload) ? JSON.parse(payload) : payload; }; - -/** - * @param {*} args arguments to send - *@return {object} formatted payload - */ -var formatPayload = function (args) { - var obj; - - return ( - ( obj = {}, obj[QUERY_ARG_NAME] = args, obj ) -); -}; - -/** - * Get name from the payload (ported back from jsonql-koa) - * @param {*} payload to extract from - * @return {string} name - */ -function getNameFromPayload(payload) { - return Object.keys(payload)[0] -} - -/** - * @param {string} resolverName name of function - * @param {array} [args=[]] from the ...args - * @param {boolean} [jsonp = false] add v1.3.0 to koa - * @return {object} formatted argument - */ -function createQuery(resolverName, args, jsonp) { - var obj; - - if ( args === void 0 ) args = []; - if ( jsonp === void 0 ) jsonp = false; - if (isString(resolverName) && isArray(args)) { - var payload = formatPayload(args); - if (jsonp === true) { - return payload; - } - return ( obj = {}, obj[resolverName] = payload, obj ) - } - throw new JsonqlValidationError("[createQuery] expect resolverName to be string and args to be array!", { resolverName: resolverName, args: args }) -} - -// string version of the above -function createQueryStr(resolverName, args, jsonp) { - if ( args === void 0 ) args = []; - if ( jsonp === void 0 ) jsonp = false; - - return JSON.stringify(createQuery(resolverName, args, jsonp)) -} - -/** - * @param {string} resolverName name of function - * @param {*} payload to send - * @param {object} [condition={}] for what - * @param {boolean} [jsonp = false] add v1.3.0 to koa - * @return {object} formatted argument - */ -function createMutation(resolverName, payload, condition, jsonp) { - var obj; - - if ( condition === void 0 ) condition = {}; - if ( jsonp === void 0 ) jsonp = false; - var _payload = {}; - _payload[PAYLOAD_PARAM_NAME] = payload; - _payload[CONDITION_PARAM_NAME] = condition; - if (jsonp === true) { - return _payload; - } - if (isString(resolverName)) { - return ( obj = {}, obj[resolverName] = _payload, obj ) - } - throw new JsonqlValidationError("[createMutation] expect resolverName to be string!", { resolverName: resolverName, payload: payload, condition: condition }) -} - -// string version of above -function createMutationStr(resolverName, payload, condition, jsonp) { - if ( condition === void 0 ) condition = {}; - if ( jsonp === void 0 ) jsonp = false; - - return JSON.stringify(createMutation(resolverName, payload, condition, jsonp)) -} - -/** - * Further break down from method below for use else where - * @param {string} resolverName name of fn - * @param {object} payload payload - * @return {object|boolean} false on failed - */ -function getQueryFromArgs(resolverName, payload) { - var obj; - - if (resolverName && isPlainObject(payload)) { - var args = payload[resolverName]; - if (args[QUERY_ARG_NAME]) { - return ( obj = {}, obj[RESOLVER_PARAM_NAME] = resolverName, obj[QUERY_ARG_NAME] = args[QUERY_ARG_NAME], obj ) - } - } - return false; -} - -/** - * Share function so no repeat - * @param {object} payload the payload from client - * @param {function} processor the last get result method - * @return {*} result processed result - */ -function processPayload(payload, processor) { - var p = toPayload(payload); - var resolverName = getNameFromPayload(p); - return Reflect.apply(processor, null, [resolverName, p]) -} - -/** - * extra the payload back - * @param {*} payload from http call - * @return {object} resolverName and args - */ -function getQueryFromPayload(payload) { - var result = processPayload(payload, getQueryFromArgs); - if (result !== false) { - return result; - } - throw new JsonqlValidationError('[getQueryArgs] Payload is malformed!', payload) -} - -/** - * Further break down from method below for use else where - * @param {string} resolverName name of fn - * @param {object} payload payload - * @return {object|boolean} false on failed - */ -function getMutationFromArgs(resolverName, payload) { - var obj; - - if (resolverName && isPlainObject(payload)) { - var args = payload[resolverName]; - if (args) { - return ( obj = {}, obj[RESOLVER_PARAM_NAME] = resolverName, obj[PAYLOAD_PARAM_NAME] = args[PAYLOAD_PARAM_NAME], obj[CONDITION_PARAM_NAME] = args[CONDITION_PARAM_NAME], obj ) - } - } - return false; -} - -/** - * @param {object} payload - * @return {object} resolverName, payload, conditon - */ -function getMutationFromPayload(payload) { - var result = processPayload(payload, getMutationFromArgs); - - if (result !== false) { - return result; - } - throw new JsonqlValidationError('[getMutationArgs] Payload is malformed!', payload) -} - -// break up from node-middleware -/** - * getting what is calling after the above check - * @param {string} method of call - * @return {mixed} false on failed - */ -var getCallMethod = function (method) { - var POST = API_REQUEST_METHODS[0]; - var PUT = API_REQUEST_METHODS[1]; - switch (true) { - case method === POST: - return QUERY_NAME; - case method === PUT: - return MUTATION_NAME; - default: - return false; - } -}; - -/** - * wrapper method - * @param {mixed} result of fn return - * @return {string} stringify data - */ -var packResult = function(result) { - var obj; - - return JSON.stringify(( obj = {}, obj[DATA_KEY] = result, obj )) -}; - -/** - * wrapper method - the output is trying to match up the structure of the Error sub class - * @param {mixed} detail of fn error - * @param {string} [className=JsonqlError] the errorName - * @param {number} [statusCode=500] the original error code - * @return {string} stringify error - */ -var packError = function(detail, className, statusCode, message) { - var obj; - - if ( className === void 0 ) className = 'JsonqlError'; - if ( statusCode === void 0 ) statusCode = 500; - if ( message === void 0 ) message = ''; - return JSON.stringify(( obj = {}, obj[ERROR_KEY] = { detail: detail, className: className, statusCode: statusCode, message: message }, obj )) -}; - -// ported from http-client - -/** - * handle the return data - * @param {object} result return from server - * @return {object} strip the data part out, or if the error is presented - */ -var resultHandler = function (result) { return ( - (isObjectHasKey(result, DATA_KEY) && !isObjectHasKey(result, ERROR_KEY)) ? result[DATA_KEY] : result -); }; - -// exportfor ES modules - -// alias -var isContract = checkIsContract; -var VERSION = '0.6.9'; - -export { VERSION, cacheBurst, cacheBurstUrl, chainFns, chainPromises, checkIsContract, createEvt, createMutation, createMutationStr, createQuery, createQueryStr, dasherize, extractArgsFromPayload, extractParamsFromContract, extractSocketPart, formatPayload, getCallMethod, getConfigValue, getMutationFromArgs, getMutationFromPayload, getNameFromPayload, getQueryFromArgs, getQueryFromPayload, groupByNamespace, inArray, injectToFn, isContract, isObjectHasKey, isNotEmpty, objDefineProps, packError, packResult, resultHandler, timestamp, toPayload, urlParams }; diff --git a/packages/http-client/src/options/base-options.js b/packages/http-client/src/options/base-options.js index 0d8101a12ca632234d53b3a714fbc76556a7d227..a0daa78f0ead31050e4f4c1b499b62a207d0a652 100644 --- a/packages/http-client/src/options/base-options.js +++ b/packages/http-client/src/options/base-options.js @@ -60,6 +60,7 @@ export const appProps = { // useful during development keepContract: createConfig(true, [BOOLEAN_TYPE]), exposeContract: createConfig(false, [BOOLEAN_TYPE]), + exposeStore: createConfig(false, [BOOLEAN_TYPE]), // whether to allow developer to access the store fn // @1.2.1 new option for the contract-console to fetch the contract with description showContractDesc: createConfig(false, [BOOLEAN_TYPE]), contractKey: createConfig(false, [BOOLEAN_TYPE]), // if the server side is lock by the key you need this diff --git a/packages/http-client/src/utils.js b/packages/http-client/src/utils.js index aeb1a4010dcad1acefca0da3b610310d77029f74..1cf4d2947a298511fbace27ff7ffb2f55f2aaae4 100644 --- a/packages/http-client/src/utils.js +++ b/packages/http-client/src/utils.js @@ -23,11 +23,13 @@ const hashCode = str => hashCodeFn(str) + '' // export some constants as well // since it's only use here there is no point of adding it to the constants module // or may be we add it back later -const ENDPOINT_TABLE = 'endpoint' +const ENDPOINT_TABLE = 'endpoint' // not in use anymore delete later @TODO const USERDATA_TABLE = 'userdata' const CLS_LOCAL_STORE_NAME = 'localStore' const CLS_SESS_STORE_NAME = 'sessionStore' const CLS_CONTRACT_NAME = 'contract' +const CLS_PROFILE_IDX = 'prof_idx' +const ZERO_IDX = 0 // export export { hashCode, @@ -36,5 +38,7 @@ export { USERDATA_TABLE, CLS_LOCAL_STORE_NAME, CLS_SESS_STORE_NAME, - CLS_CONTRACT_NAME + CLS_CONTRACT_NAME, + CLS_PROFILE_IDX, + ZERO_IDX } diff --git a/packages/http-client/static.js b/packages/http-client/static.js index ead960e40c425fb1a5c4a48c026ad0a448960fd0..3a6f3e04756eae5f5fe31d9c10d0310afc96a5ec 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b="onResult",_="onError",m=Array.isArray,w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),A=O.Symbol,k=Object.prototype,E=k.hasOwnProperty,T=k.toString,x=A?A.toStringTag:void 0;var q=Object.prototype.toString;var P="[object Null]",C="[object Undefined]",$=A?A.toStringTag:void 0;function z(t){return null==t?void 0===t?C:P:$&&$ in Object(t)?function(t){var e=E.call(t,x),r=t[x];try{t[x]=void 0;var n=!0}catch(t){}var o=T.call(t);return n&&(e?t[x]=r:delete t[x]),o}(t):function(t){return q.call(t)}(t)}function N(t,e){return function(r){return t(e(r))}}var M=N(Object.getPrototypeOf,Object);function R(t){return null!=t&&"object"==typeof t}var F="[object Object]",J=Function.prototype,I=Object.prototype,U=J.toString,D=I.hasOwnProperty,H=U.call(Object);function L(t){if(!R(t)||z(t)!=F)return!1;var e=M(t);if(null===e)return!0;var r=D.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&U.call(r)==H}var K=function(t){return m(t)?t:[t]},B=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},V=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},G=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),W=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),it=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),at=Object.freeze({__proto__:null,Jsonql406Error:G,Jsonql500Error:W,JsonqlAuthorisationError:Y,JsonqlContractAuthError:Q,JsonqlResolverAppError:X,JsonqlResolverNotFoundError:Z,JsonqlEnumError:tt,JsonqlTypeError:et,JsonqlCheckerError:rt,JsonqlValidationError:nt,JsonqlError:ot,JsonqlServerError:it}),ut=ot,ct=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function st(t){if(ct(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&at[o])throw new at[r](i,a);throw new ut(i,a)}return t}function ft(t){if(Array.isArray(t))throw new nt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof G:throw new G(e,r);case t instanceof W:throw new W(e,r);case t instanceof Y:throw new Y(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof it:throw new it(e,r);default:throw new ot(e,r)}}function lt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&mt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Mt=function(t){return!!m(t)||null!=t&&""!==Nt(t)},Rt="[object Number]";function Ft(t){return function(t){return"number"==typeof t||R(t)&&z(t)==Rt}(t)&&t!=+t}var Jt="[object String]";function It(t){return"string"==typeof t||!m(t)&&R(t)&&z(t)==Jt}var Ut=function(t){return!It(t)&&!Ft(parseFloat(t))},Dt=function(t){return""!==Nt(t)&&It(t)},Ht=function(t){return null!=t&&"boolean"==typeof t},Lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Nt(t)&&(!1===e||!0===e&&null!==t)},Kt=s,Bt=f,Vt=l,Gt=p,Wt=h,Yt=d,Qt="continue",Xt=function(t){switch(t){case"number":return Ut;case"string":return Dt;case"boolean":return Ht;default:return Lt}},Zt=function(t,e){return void 0===e&&(e=""),!!m(t)&&(""===e||""===Nt(e)||!(t.filter((function(t){return!Xt(e)(t)})).length>0))},te=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ee=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Xt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Zt(r,t)})).length};var re,ne=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[re?a:++n];if(!1===e(o[u],u,o))break}return t};var oe="[object Arguments]";function ie(t){return R(t)&&z(t)==oe}var ae=Object.prototype,ue=ae.hasOwnProperty,ce=ae.propertyIsEnumerable,se=ie(function(){return arguments}())?ie:function(t){return R(t)&&ue.call(t,"callee")&&!ce.call(t,"callee")};var fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,le=fe&&"object"==typeof module&&module&&!module.nodeType&&module,pe=le&&le.exports===fe?O.Buffer:void 0,he=(pe?pe.isBuffer:void 0)||function(){return!1},de=9007199254740991,ve=/^(?:0|[1-9]\d*)$/;function ge(t,e){var r=typeof t;return!!(e=null==e?de:e)&&("number"==r||"symbol"!=r&&ve.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ye}var _e={};_e["[object Float32Array]"]=_e["[object Float64Array]"]=_e["[object Int8Array]"]=_e["[object Int16Array]"]=_e["[object Int32Array]"]=_e["[object Uint8Array]"]=_e["[object Uint8ClampedArray]"]=_e["[object Uint16Array]"]=_e["[object Uint32Array]"]=!0,_e["[object Arguments]"]=_e["[object Array]"]=_e["[object ArrayBuffer]"]=_e["[object Boolean]"]=_e["[object DataView]"]=_e["[object Date]"]=_e["[object Error]"]=_e["[object Function]"]=_e["[object Map]"]=_e["[object Number]"]=_e["[object Object]"]=_e["[object RegExp]"]=_e["[object Set]"]=_e["[object String]"]=_e["[object WeakMap]"]=!1;var me,we="object"==typeof exports&&exports&&!exports.nodeType&&exports,je=we&&"object"==typeof module&&module&&!module.nodeType&&module,Se=je&&je.exports===we&&j.process,Oe=function(){try{var t=je&&je.require&&je.require("util").types;return t||Se&&Se.binding&&Se.binding("util")}catch(t){}}(),Ae=Oe&&Oe.isTypedArray,ke=Ae?(me=Ae,function(t){return me(t)}):function(t){return R(t)&&be(t.length)&&!!_e[z(t)]},Ee=Object.prototype.hasOwnProperty;function Te(t,e){var r=m(t),n=!r&&se(t),o=!r&&!n&&he(t),i=!r&&!n&&!o&&ke(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ke.prototype.set=function(t,e){var r=this.__data__,n=He(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Be,Ve=O["__core-js_shared__"],Ge=(Be=/[^.]+$/.exec(Ve&&Ve.keys&&Ve.keys.IE_PROTO||""))?"Symbol(src)_1."+Be:"";var We=Function.prototype.toString;function Ye(t){if(null!=t){try{return We.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Qe=/^\[object .+?Constructor\]$/,Xe=Function.prototype,Ze=Object.prototype,tr=Xe.toString,er=Ze.hasOwnProperty,rr=RegExp("^"+tr.call(er).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){return!(!$e(t)||function(t){return!!Ge&&Ge in t}(t))&&(Fe(t)?rr:Qe).test(Ye(t))}function or(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return nr(r)?r:void 0}var ir=or(O,"Map"),ar=or(Object,"create");var ur="__lodash_hash_undefined__",cr=Object.prototype.hasOwnProperty;var sr=Object.prototype.hasOwnProperty;var fr="__lodash_hash_undefined__";function lr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&mr?new yr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=te(t))?!ee({arg:r},e):!Xt(t)(r))})).length)})).length}return!1},Un=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(In,null,a);case"array"===t:return!Zt(e.arg);case!1!==(r=te(t)):return!ee(e,r);default:return!Xt(t)(e.arg)}},Dn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Hn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Zt(e))throw new ot("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Zt(t))throw new ot("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Dn(t,a):t,index:r,param:a,optional:i}}));default:throw new ot("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Mt(e)&&!(r.type.length>r.type.filter((function(e){return Un(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Un(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ln=function(){try{var t=or(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Kn(t,e,r){"__proto__"==e&&Ln?Ln(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Bn(t,e,r){(void 0===r||De(t[e],r))&&(void 0!==r||e in t)||Kn(t,e,r)}var Vn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Gn=Vn&&"object"==typeof module&&module&&!module.nodeType&&module,Wn=Gn&&Gn.exports===Vn?O.Buffer:void 0,Yn=Wn?Wn.allocUnsafe:void 0;function Qn(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new jr(n).set(new jr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Xn=Object.create,Zn=function(){function t(){}return function(e){if(!$e(e))return{};if(Xn)return Xn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function to(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var eo=Object.prototype.hasOwnProperty;function ro(t,e,r){var n=t[e];eo.call(t,e)&&De(n,r)&&(void 0!==r||e in t)||Kn(t,e,r)}var no=Object.prototype.hasOwnProperty;function oo(t){if(!$e(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=qe(t),r=[];for(var n in t)("constructor"!=n||!e&&no.call(t,n))&&r.push(n);return r}function io(t){return Je(t)?Te(t,!0):oo(t)}function ao(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=po)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(lo);function yo(t,e){return go(function(t,e,r){return e=fo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=fo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=bo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!$e(r))return!1;var n=typeof e;return!!("number"==n?Je(r)&&ge(e,r.length):"string"==n&&e in r)&&De(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,K(t))}),Reflect.apply(t,null,r))}};function Do(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Ho(t,e,r,n){void 0===n&&(n=!1);var o=Do(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Lo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Fo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ft)}},Ko=function(t,e,r,n,o){var i={},a=function(t){i=Ho(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Fo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ft)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Bo=function(t,e,r,n,o){var i={},a=function(t){i=Ho(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Fo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ft)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Vo=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Lo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Lo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Go=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(V(e,r,b),o),t.$only(V(e,r,_),i),t.$trigger(e,{resolverName:r,args:n})}))}},Wo=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Yo(t,e,r,n){var o=function(t,e,r,n){return Uo(Ko,Bo,Vo)({},t,e,r,n)}(t,e,r,n);Wo(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(V(t,n,b),r)})).catch((function(r){e.$trigger(V(t,n,_),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Qo=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Yo(t,n,e,r)}));var o={query:Go(n,"query"),mutation:Go(n,"mutation"),auth:Go(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.0",o};function Xo(t){return!!function(t){return L(t)&&(B(t,r)||B(t,n)||B(t,o))}(t)&&t}function Zo(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ti=function(t,e){return void 0===e&&(e={}),Xo(e)?Promise.resolve(e):t.getContract()},ei="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function ri(t){this.message=t}ri.prototype=new Error,ri.prototype.name="InvalidCharacterError";var ni="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ri("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ei.indexOf(n);return a};var oi=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ni(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ni(e)}};function ii(t){this.message=t}ii.prototype=new Error,ii.prototype.name="InvalidTokenError";var ai=function(t,e){if("string"!=typeof t)throw new ii("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(oi(t.split(".")[r]))}catch(t){throw new ii("Invalid token specified: "+t.message)}},ui=ii;ai.InvalidTokenError=ui;var ci,si,fi,li,pi,hi,di,vi,gi,yi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function bi(t){if(Dt(t))return function(t){var e=t.iat||yi(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new ot("Token has expired on "+r,t)}return t}(ai(t));throw new ot("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((ci={})[d]="exp",ci[f]=!0,ci)),Jo(!1,["boolean","number","string"],((si={})[d]="nbf",si[f]=!0,si)),Jo(!1,["boolean","string"],((fi={})[d]="iss",fi[f]=!0,fi)),Jo(!1,["boolean","string"],((li={})[d]="sub",li[f]=!0,li)),Jo(!1,["boolean","string"],((pi={})[d]="iss",pi[f]=!0,pi)),Jo(!1,["boolean"],((hi={})[f]=!0,hi)),Jo(!1,["boolean","string"],((di={})[f]=!0,di)),Jo(!1,["boolean","string"],((vi={})[f]=!0,vi)),Jo(!1,["boolean"],((gi={})[f]=!0,gi));var _i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},mi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var wi=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Hi().key(e);t(Li(r),r)}},remove:function(t){return Hi().removeItem(t)},clearAll:function(){return Hi().clear()}};function Hi(){return Ui.localStorage}function Li(t){return Hi().getItem(t)}var Ki=Ai.trim,Bi={name:"cookieStorage",read:function(t){if(!t||!Yi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Vi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Vi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Gi,remove:Wi,clearAll:function(){Gi((function(t,e){Wi(e)}))}},Vi=Ai.Global.document;function Gi(t){for(var e=Vi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Ki(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Wi(t){t&&Yi(t)&&(Vi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Yi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Vi.cookie)}var Qi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Xi="expire_mixin",Zi=function(){var t=this.createStore(this.storage,null,this._namespacePrefix+Xi);return{set:function(e,r,n,o){this.hasNamespace(Xi)||t.set(r,o);return e()},get:function(t,r){this.hasNamespace(Xi)||e.call(this,r);return t()},remove:function(e,r){this.hasNamespace(Xi)||t.remove(r);return e()},getExpiration:function(e,r){return t.get(r)},removeExpiredKeys:function(t){var r=[];this.each((function(t,e){r.push(e)}));for(var n=0;n>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)}));var ua=[Di,Bi],ca=[Qi,Zi,oa,function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=aa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=aa.compress(this._serialize(r));t(e,n)}}}],sa=Fi.createStore(ua,ca),fa=Ai.Global;function la(){return fa.sessionStorage}function pa(t){return la().getItem(t)}var ha=[{name:"sessionStorage",read:pa,write:function(t,e){return la().setItem(t,e)},each:function(t){for(var e=la().length-1;e>=0;e--){var r=la().key(e);t(pa(r),r)}},remove:function(t){return la().removeItem(t)},clearAll:function(){return la().clear()}},Bi],da=[Qi,Zi],va=Fi.createStore(ha,da),ga=sa,ya=va,ba=function(t){var e;return(e={}).args=t,e};function _a(t,e){var r;return(r={})[t]=e,r[u]=[_i()],r}var ma=function(t){return B(t,"data")&&!B(t,"error")?t.data:t},wa=function(t){this.opts=t,this.instanceKey=Zo(this.opts.hostname)+"",this.localStore=ga,this.sessionStore=ya},ja={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};wa.prototype.__setMethod=function(t,e){var r,n=this[t],o=(this.__getMethod(t),this.opts.storageKey),i=this.instanceKey;n.set(o,((r={})[i]=n?_o({},n,e):e,r))},wa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},wa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},wa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},ja.lset.set=function(t){return this.__setMethod("localStore",t)},ja.lget.get=function(){return this.__getMethod("localStore")},wa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},wa.prototype.lclear=function(){return this.__clearMethod("localStore")},ja.sset.set=function(t){return this.__setMethod("sessionStore",t)},ja.sget.get=function(){return this.__getMethod("sessionStore")},wa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},wa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(wa.prototype,ja);var Sa=c[0],Oa=c[1],Aa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},r.jsonqlToken.set=function(t){var e;this.sset=((e={}).jsonqlcredential=t,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlToken.get=function(){var t=this.sget;return!!t&&t.jsonqlcredential},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=bi)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={userdata:{configurable:!0},rawAuthToken:{configurable:!0},setDecoder:{configurable:!0}};return r.userdata.get=function(){return this.jsonqlUserdata},r.rawAuthToken.get=function(){return this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},e.prototype.storeToken=function(t){return this.jsonqlToken=t},e.prototype.decoder=function(t){return t},e.prototype.getAuthHeader=function(){var t,e=this.rawAuthToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Xo(t))throw new nt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Xo(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=_o({},{_cb:_i()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=_o({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=_o({},{method:Sa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ma(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ma(o)}),(function(t){throw e.cleanUp(),console.error(t),new it("Server side error",t)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?_o({},e,this.getAuthHeader(),this.extraHeader):_o({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=_o({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(st).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new it("getRemoteContract",t)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),It(t)&&m(e)){var n=ba(e);return!0===r?n:_a(t,n)}throw new nt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(st)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(It(t))return _a(t,o);throw new nt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Oa}).then(st)},Object.defineProperties(r.prototype,n),r}(wa)))),ka={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ea={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),persistToken:Jo(!1,["boolean","number"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("jsonqlstore",["string"]),authKey:Jo("jsonqlauthkey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function Ta(t){return Do(t,v)?t:function(t){return Io(t,Ea,ka)}(t)}var xa=new WeakMap,qa=new WeakMap,Pa=function(){this.__suspend__=null,this.queueStore=new Set},Ca={$suspend:{configurable:!0},$queues:{configurable:!0}};Ca.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Pa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ca.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Pa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Pa.prototype,Ca);var $a=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){xa.set(this,t)},r.normalStore.get=function(){return xa.get(this)},r.lazyStore.set=function(t){qa.set(this,t)},r.lazyStore.get=function(){return qa.get(this)},e.prototype.hashFnToKey=function(t){return Zo(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Pa));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=Ta(e),i=new Aa(t,o),a=ti(i,n),u=(r=o.debugOn,new $a({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Qo(i,o,a,u);return c.eventEmitter=u,c}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b="onResult",_="onError",m=Array.isArray,w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol,A=Object.prototype,E=A.hasOwnProperty,T=A.toString,x=k?k.toStringTag:void 0;var P=Object.prototype.toString;var q="[object Null]",C="[object Undefined]",$=k?k.toStringTag:void 0;function z(t){return null==t?void 0===t?C:q:$&&$ in Object(t)?function(t){var e=E.call(t,x),r=t[x];try{t[x]=void 0;var n=!0}catch(t){}var o=T.call(t);return n&&(e?t[x]=r:delete t[x]),o}(t):function(t){return P.call(t)}(t)}function N(t,e){return function(r){return t(e(r))}}var M=N(Object.getPrototypeOf,Object);function R(t){return null!=t&&"object"==typeof t}var I="[object Object]",F=Function.prototype,J=Object.prototype,U=F.toString,H=J.hasOwnProperty,L=U.call(Object);function D(t){if(!R(t)||z(t)!=I)return!1;var e=M(t);if(null===e)return!0;var r=H.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&U.call(r)==L}var K=function(t){return m(t)?t:[t]},B=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},V=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},G=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),W=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Y=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Q=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),X=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Z=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),rt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),it=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),at=Object.freeze({__proto__:null,Jsonql406Error:G,Jsonql500Error:W,JsonqlAuthorisationError:Y,JsonqlContractAuthError:Q,JsonqlResolverAppError:X,JsonqlResolverNotFoundError:Z,JsonqlEnumError:tt,JsonqlTypeError:et,JsonqlCheckerError:rt,JsonqlValidationError:nt,JsonqlError:ot,JsonqlServerError:it}),ut=ot,ct=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function st(t){if(ct(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&at[o])throw new at[r](i,a);throw new ut(i,a)}return t}function ft(t){if(Array.isArray(t))throw new nt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof G:throw new G(e,r);case t instanceof W:throw new W(e,r);case t instanceof Y:throw new Y(e,r);case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof it:throw new it(e,r);default:throw new ot(e,r)}}function lt(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&mt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Mt=function(t){return!!m(t)||null!=t&&""!==Nt(t)},Rt="[object Number]";function It(t){return function(t){return"number"==typeof t||R(t)&&z(t)==Rt}(t)&&t!=+t}var Ft="[object String]";function Jt(t){return"string"==typeof t||!m(t)&&R(t)&&z(t)==Ft}var Ut=function(t){return!Jt(t)&&!It(parseFloat(t))},Ht=function(t){return""!==Nt(t)&&Jt(t)},Lt=function(t){return null!=t&&"boolean"==typeof t},Dt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Nt(t)&&(!1===e||!0===e&&null!==t)},Kt=s,Bt=f,Vt=l,Gt=p,Wt=h,Yt=d,Qt="continue",Xt=function(t){switch(t){case"number":return Ut;case"string":return Ht;case"boolean":return Lt;default:return Dt}},Zt=function(t,e){return void 0===e&&(e=""),!!m(t)&&(""===e||""===Nt(e)||!(t.filter((function(t){return!Xt(e)(t)})).length>0))},te=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ee=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Xt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Zt(r,t)})).length};var re,ne=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[re?a:++n];if(!1===e(o[u],u,o))break}return t};var oe="[object Arguments]";function ie(t){return R(t)&&z(t)==oe}var ae=Object.prototype,ue=ae.hasOwnProperty,ce=ae.propertyIsEnumerable,se=ie(function(){return arguments}())?ie:function(t){return R(t)&&ue.call(t,"callee")&&!ce.call(t,"callee")};var fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,le=fe&&"object"==typeof module&&module&&!module.nodeType&&module,pe=le&&le.exports===fe?O.Buffer:void 0,he=(pe?pe.isBuffer:void 0)||function(){return!1},de=9007199254740991,ve=/^(?:0|[1-9]\d*)$/;function ge(t,e){var r=typeof t;return!!(e=null==e?de:e)&&("number"==r||"symbol"!=r&&ve.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=ye}var _e={};_e["[object Float32Array]"]=_e["[object Float64Array]"]=_e["[object Int8Array]"]=_e["[object Int16Array]"]=_e["[object Int32Array]"]=_e["[object Uint8Array]"]=_e["[object Uint8ClampedArray]"]=_e["[object Uint16Array]"]=_e["[object Uint32Array]"]=!0,_e["[object Arguments]"]=_e["[object Array]"]=_e["[object ArrayBuffer]"]=_e["[object Boolean]"]=_e["[object DataView]"]=_e["[object Date]"]=_e["[object Error]"]=_e["[object Function]"]=_e["[object Map]"]=_e["[object Number]"]=_e["[object Object]"]=_e["[object RegExp]"]=_e["[object Set]"]=_e["[object String]"]=_e["[object WeakMap]"]=!1;var me,we="object"==typeof exports&&exports&&!exports.nodeType&&exports,je=we&&"object"==typeof module&&module&&!module.nodeType&&module,Se=je&&je.exports===we&&j.process,Oe=function(){try{var t=je&&je.require&&je.require("util").types;return t||Se&&Se.binding&&Se.binding("util")}catch(t){}}(),ke=Oe&&Oe.isTypedArray,Ae=ke?(me=ke,function(t){return me(t)}):function(t){return R(t)&&be(t.length)&&!!_e[z(t)]},Ee=Object.prototype.hasOwnProperty;function Te(t,e){var r=m(t),n=!r&&se(t),o=!r&&!n&&he(t),i=!r&&!n&&!o&&Ae(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Ke.prototype.set=function(t,e){var r=this.__data__,n=Le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Be,Ve=O["__core-js_shared__"],Ge=(Be=/[^.]+$/.exec(Ve&&Ve.keys&&Ve.keys.IE_PROTO||""))?"Symbol(src)_1."+Be:"";var We=Function.prototype.toString;function Ye(t){if(null!=t){try{return We.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Qe=/^\[object .+?Constructor\]$/,Xe=Function.prototype,Ze=Object.prototype,tr=Xe.toString,er=Ze.hasOwnProperty,rr=RegExp("^"+tr.call(er).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nr(t){return!(!$e(t)||function(t){return!!Ge&&Ge in t}(t))&&(Ie(t)?rr:Qe).test(Ye(t))}function or(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return nr(r)?r:void 0}var ir=or(O,"Map"),ar=or(Object,"create");var ur="__lodash_hash_undefined__",cr=Object.prototype.hasOwnProperty;var sr=Object.prototype.hasOwnProperty;var fr="__lodash_hash_undefined__";function lr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&mr?new yr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=te(t))?!ee({arg:r},e):!Xt(t)(r))})).length)})).length}return!1},Un=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Jn,null,a);case"array"===t:return!Zt(e.arg);case!1!==(r=te(t)):return!ee(e,r);default:return!Xt(t)(e.arg)}},Hn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Ln=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Zt(e))throw new ot("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Zt(t))throw new ot("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Hn(t,a):t,index:r,param:a,optional:i}}));default:throw new ot("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Mt(e)&&!(r.type.length>r.type.filter((function(e){return Un(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Un(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Dn=function(){try{var t=or(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Kn(t,e,r){"__proto__"==e&&Dn?Dn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Bn(t,e,r){(void 0===r||He(t[e],r))&&(void 0!==r||e in t)||Kn(t,e,r)}var Vn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Gn=Vn&&"object"==typeof module&&module&&!module.nodeType&&module,Wn=Gn&&Gn.exports===Vn?O.Buffer:void 0,Yn=Wn?Wn.allocUnsafe:void 0;function Qn(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new jr(n).set(new jr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Xn=Object.create,Zn=function(){function t(){}return function(e){if(!$e(e))return{};if(Xn)return Xn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function to(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var eo=Object.prototype.hasOwnProperty;function ro(t,e,r){var n=t[e];eo.call(t,e)&&He(n,r)&&(void 0!==r||e in t)||Kn(t,e,r)}var no=Object.prototype.hasOwnProperty;function oo(t){if(!$e(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Pe(t),r=[];for(var n in t)("constructor"!=n||!e&&no.call(t,n))&&r.push(n);return r}function io(t){return Fe(t)?Te(t,!0):oo(t)}function ao(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=po)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(lo);function yo(t,e){return go(function(t,e,r){return e=fo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=fo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=bo.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!$e(r))return!1;var n=typeof e;return!!("number"==n?Fe(r)&&ge(e,r.length):"string"==n&&e in r)&&He(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,K(t))}),Reflect.apply(t,null,r))}};function Lo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Do(t,e,r,n){void 0===n&&(n=!1);var o=Lo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Ko=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Fo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ft)}},Bo=function(t,e,r,n,o){var i={},a=function(t){i=Do(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Fo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ft)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Do(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Fo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ft)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Go=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ko(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){return r.$trigger("login",t),t}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Ko(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(){e.postLogoutAction("continue"),r.$trigger("logout","continue")},t.auth=i}return t};var Wo=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(V(e,r,b),o),t.$only(V(e,r,_),i),t.$trigger(e,{resolverName:r,args:n})}))}},Yo=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Qo(t,e,r,n){var o=function(t,e,r,n){return Ho(Bo,Vo,Go)({},t,e,r,n)}(t,e,r,n);Yo(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(V(t,n,b),r)})).catch((function(r){e.$trigger(V(t,n,_),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Xo=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Qo(t,n,e,r)}));var o={query:Wo(n,"query"),mutation:Wo(n,"mutation"),auth:Wo(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.1",o};function Zo(t){return!!function(t){return D(t)&&(B(t,r)||B(t,n)||B(t,o))}(t)&&t}function ti(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ei=function(t,e){return void 0===e&&(e={}),Zo(e)?Promise.resolve(e):t.getContract()},ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function ni(t){this.message=t}ni.prototype=new Error,ni.prototype.name="InvalidCharacterError";var oi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new ni("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ri.indexOf(n);return a};var ii=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(oi(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return oi(e)}};function ai(t){this.message=t}ai.prototype=new Error,ai.prototype.name="InvalidTokenError";var ui=function(t,e){if("string"!=typeof t)throw new ai("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ii(t.split(".")[r]))}catch(t){throw new ai("Invalid token specified: "+t.message)}},ci=ai;ui.InvalidTokenError=ci;var si,fi,li,pi,hi,di,vi,gi,yi,bi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function _i(t){if(Ht(t))return function(t){var e=t.iat||bi(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new ot("Token has expired on "+r,t)}return t}(ui(t));throw new ot("Token must be a string!")}Jo("HS256",["string"]),Jo(!1,["boolean","number","string"],((si={})[d]="exp",si[f]=!0,si)),Jo(!1,["boolean","number","string"],((fi={})[d]="nbf",fi[f]=!0,fi)),Jo(!1,["boolean","string"],((li={})[d]="iss",li[f]=!0,li)),Jo(!1,["boolean","string"],((pi={})[d]="sub",pi[f]=!0,pi)),Jo(!1,["boolean","string"],((hi={})[d]="iss",hi[f]=!0,hi)),Jo(!1,["boolean"],((di={})[f]=!0,di)),Jo(!1,["boolean","string"],((vi={})[f]=!0,vi)),Jo(!1,["boolean","string"],((gi={})[f]=!0,gi)),Jo(!1,["boolean"],((yi={})[f]=!0,yi));var mi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},wi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var ji=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Di().key(e);t(Ki(r),r)}},remove:function(t){return Di().removeItem(t)},clearAll:function(){return Di().clear()}};function Di(){return Hi.localStorage}function Ki(t){return Di().getItem(t)}var Bi=Ai.trim,Vi={name:"cookieStorage",read:function(t){if(!t||!Qi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Gi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Gi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Wi,remove:Yi,clearAll:function(){Wi((function(t,e){Yi(e)}))}},Gi=Ai.Global.document;function Wi(t){for(var e=Gi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Bi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Yi(t){t&&Qi(t)&&(Gi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Qi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Gi.cookie)}var Xi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Zi=Ai.bind,ta=Ai.each,ea=Ai.create,ra=Ai.slice,na=function(){var t=ea(oa,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Zi(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Zi(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),ta(r,(function(e,r){t.fire(r,void 0,e)}))}}};var oa={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Zi(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=ra(arguments,1);ta(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},ia=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),aa=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=ia.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=ia.compress(this._serialize(r));t(e,n)}}};var ua=[Li,Vi],ca=[Xi,na,aa],sa=Fi.createStore(ua,ca),fa=Ai.Global;function la(){return fa.sessionStorage}function pa(t){return la().getItem(t)}var ha=[{name:"sessionStorage",read:pa,write:function(t,e){return la().setItem(t,e)},each:function(t){for(var e=la().length-1;e>=0;e--){var r=la().key(e);t(pa(r),r)}},remove:function(t){return la().removeItem(t)},clearAll:function(){return la().clear()}},Vi],da=[Xi,aa],va=Fi.createStore(ha,da),ga=sa,ya=va,ba=function(t){var e;return(e={}).args=t,e};function _a(t,e){var r;return(r={})[t]=e,r[u]=[mi()],r}var ma=function(t){return B(t,"data")&&!B(t,"error")?t.data:t},wa=function(t){this.opts=t,this.instanceKey=ti(this.opts.hostname)+"",this.localStore=ga,this.sessionStore=ya},ja={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};wa.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?_o({},o,e):e,r))},wa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},wa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},wa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},ja.lset.set=function(t){return this.__setMethod("localStore",t)},ja.lget.get=function(){return this.__getMethod("localStore")},wa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},wa.prototype.lclear=function(){return this.__clearMethod("localStore")},ja.sset.set=function(t){return this.__setMethod("sessionStore",t)},ja.sget.get=function(){return this.__getMethod("sessionStore")},wa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},wa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(wa.prototype,ja);var Sa=c[0],Oa=c[1],ka=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];!0===this.opts.debugOn&&Reflect.apply(console.info,console,t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=_i)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Io(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new nt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.jsonqlUserdata=this.decoder(t)},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Io(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,t},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!Zo(t))throw new nt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Zo(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=_o({},{_cb:mi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=_o({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=_o({},{method:Sa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ma(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Ro(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ma(o)}),(function(t){throw e.cleanUp(),console.error(t),new it("Server side error",t)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?_o({},e,this.getAuthHeader(),this.extraHeader):_o({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=_o({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(st).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(t){throw console.error("getRemoteContract err",t),new it("getRemoteContract",t)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Jt(t)&&m(e)){var n=ba(e);return!0===r?n:_a(t,n)}throw new nt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(st)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Jt(t))return _a(t,o);throw new nt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Oa}).then(st)},Object.defineProperties(r.prototype,n),r}(wa)))),Aa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ea={hostname:Jo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jo("jsonql",["string"]),loginHandlerName:Jo("login",["string"]),logoutHandlerName:Jo("logout",["string"]),enableJsonp:Jo(!1,["boolean"]),enableAuth:Jo(!1,["boolean"]),useJwt:Jo(!0,["boolean"]),persistToken:Jo(!1,["boolean","number"]),useLocalstorage:Jo(!0,["boolean"]),storageKey:Jo("jsonqlstore",["string"]),authKey:Jo("jsonqlauthkey",["string"]),contractExpired:Jo(0,["number"]),keepContract:Jo(!0,["boolean"]),exposeContract:Jo(!1,["boolean"]),exposeStore:Jo(!1,["boolean"]),showContractDesc:Jo(!1,["boolean"]),contractKey:Jo(!1,["boolean"]),contractKeyName:Jo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jo(!1,["boolean"]),timeout:Jo(5e3,["number"]),returnInstance:Jo(!1,["boolean"]),allowReturnRawToken:Jo(!1,["boolean"]),debugOn:Jo(!1,["boolean"])};function Ta(t){return Lo(t,v)?t:function(t){return Uo(t,Ea,Aa)}(t)}var xa=new WeakMap,Pa=new WeakMap,qa=function(){this.__suspend__=null,this.queueStore=new Set},Ca={$suspend:{configurable:!0},$queues:{configurable:!0}};Ca.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},qa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ca.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},qa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(qa.prototype,Ca);var $a=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){xa.set(this,t)},r.normalStore.get=function(){return xa.get(this)},r.lazyStore.set=function(t){Pa.set(this,t)},r.lazyStore.get=function(){return Pa.get(this)},e.prototype.hashFnToKey=function(t){return ti(t.toString())+""},Object.defineProperties(e.prototype,r),e}(qa));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=Ta(e),i=new ka(t,o),a=ei(i,n),u=(r=o.debugOn,new $a({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Xo(i,o,a,u);return c.eventEmitter=u,c}})); //# sourceMappingURL=static.js.map diff --git a/packages/http-client/static.js.map b/packages/http-client/static.js.map index a9691d6b679076ff110656b0d662fb5cff8c9e45..11d1ecd836ca2df2ee7ab99d53ccddd753df7abd 100644 --- a/packages/http-client/static.js.map +++ b/packages/http-client/static.js.map @@ -1 +1 @@ -{"version":3,"file":"static.js","sources":["node_modules/store/plugins/defaults.js","node_modules/store/plugins/expire.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n","var namespace = 'expire_mixin'\n\nmodule.exports = expirePlugin\n\nfunction expirePlugin() {\n\tvar expirations = this.createStore(this.storage, null, this._namespacePrefix+namespace)\n\t\n\treturn {\n\t\tset: expire_set,\n\t\tget: expire_get,\n\t\tremove: expire_remove,\n\t\tgetExpiration: getExpiration,\n\t\tremoveExpiredKeys: removeExpiredKeys\n\t}\n\t\n\tfunction expire_set(super_fn, key, val, expiration) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.set(key, expiration)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_get(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\t_checkExpiration.call(this, key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction expire_remove(super_fn, key) {\n\t\tif (!this.hasNamespace(namespace)) {\n\t\t\texpirations.remove(key)\n\t\t}\n\t\treturn super_fn()\n\t}\n\t\n\tfunction getExpiration(_, key) {\n\t\treturn expirations.get(key)\n\t}\n\t\n\tfunction removeExpiredKeys(_) {\n\t\tvar keys = []\n\t\tthis.each(function(val, key) {\n\t\t\tkeys.push(key)\n\t\t})\n\t\tfor (var i=0; i { - switch (process.env.TARGET) { - case 'wx': - return 'flyio/dist/npm/wx' - case 'ap': - return 'flyio/dist/npm/ap' - case 'weex': - return 'flyio/dist/npm/weex' - default: // browser - return 'flyio/dist/npm/fly' - } -} - -const getOutputFile = () => { - let fileName = env === 'production' ? 'jsonql-client.umd.js' : 'jsonql-static-client.umd.js' - switch (process.env.TARGET) { - case 'wx': - return join(__dirname, 'wx.js') - case 'ap': - return join(__dirname, 'ap.js') - case 'weex': - return join(__dirname, 'weex.js') - default: - return join(__dirname, 'dist', fileName) - } -} - -const env = process.env.NODE_ENV; - -let plugins = [ - buble({ - objectAssign: 'Object.assign' - }), - nodeResolve({ - preferBuiltins: true - }), - commonjs({ - include: 'node_modules/**' - }), - nodeGlobals(), - // builtins(), - async(), - replace({ - 'process.env.NODE_ENV': JSON.stringify('production'), - '__VERSION__': pkg.version, - '__TO_REPLACE_IMPORT__': getReplace() - }) -] - -// plugins.push(terser()) -plugins.push(size()) - -let globals = { - debug: 'debug', - 'promise-polyfill': 'Promise', - 'fs': 'fs', - 'util': 'util', - 'path': 'path' -} -let external = [ - 'debug', - 'fetch', - 'Promise', - 'promise-polyfill', - 'superagent', - 'handlebars', - 'tty', - 'fs', - 'util' -] - -let sourceFile = env === 'production' ? 'full.js' : join('src', 'static-full.js') -let moduleName = env === 'production' ? 'jsonqlClient' : 'jsonqlClientStatic' -let config = { - input: join(__dirname, sourceFile), - output: [{ - name: moduleName, - file: getOutputFile(), - format: 'umd', - sourcemap: true, - globals - }], - plugins, - external -} - -export default config diff --git a/packages/http-client/tests/fixtures/old-builds/rollup.test.config.js b/packages/http-client/tests/fixtures/old-builds/rollup.test.config.js deleted file mode 100644 index 78a778497e806155184cac6f16fc9c73f2822644..0000000000000000000000000000000000000000 --- a/packages/http-client/tests/fixtures/old-builds/rollup.test.config.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Rollup config for TESTING - * DO NOT USE THIS DIRECTLY - */ -import { join } from 'path' -import buble from 'rollup-plugin-buble' -import replace from 'rollup-plugin-replace' -import commonjs from 'rollup-plugin-commonjs' -import size from 'rollup-plugin-bundle-size' -import nodeResolve from 'rollup-plugin-node-resolve' -import nodeGlobals from 'rollup-plugin-node-globals' -import builtins from 'rollup-plugin-node-builtins'; -import async from 'rollup-plugin-async' - -const env = process.env.NODE_ENV; - -let plugins = [ - buble({ - objectAssign: 'Object.assign' - }), - nodeResolve({ preferBuiltins: false }), - commonjs({ - include: 'node_modules/**' - }), - nodeGlobals(), - builtins(), - async(), - replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), - size() -] - -const dist = join(__dirname, 'dist') -let in_file = join(__dirname, 'test.js') -let out_file = join(dist, 'jsonql-client.test.js') -let name = 'JsonqlClientOOP'; -// swith the files using the env -switch (env) { - case 'stores': - in_file = join(src, 'lib', 'stores', 'index.js') - out_file = join(dist, 'jsonql-stores.js') - name = 'JsonqlStores'; - break; - default: - // nothing -} - -let config = { - input: in_file, - output: { - name: name, - file: out_file, - format: 'umd', - sourcemap: true, - globals: { - debug: 'debug', - 'promise-polyfill': 'Promise' - } - }, - external: [ - 'debug', - 'fetch', - 'Promise', - 'promise-polyfill', - 'superagent', - 'handlebars', - 'tty' - ], - plugins: plugins -} - -export default config diff --git a/packages/http-client/tests/fixtures/resolvers/auth/issuer.js b/packages/http-client/tests/fixtures/resolvers/auth/issuer.js deleted file mode 100644 index 609c29661d8211ec41c5848abfd28a692a04ecc5..0000000000000000000000000000000000000000 --- a/packages/http-client/tests/fixtures/resolvers/auth/issuer.js +++ /dev/null @@ -1,10 +0,0 @@ -const debug = require('debug')('jsonql-client:auth:issuer'); - -/** - * @param {string} key for append - * @return {string} concat string - */ -module.exports = function(key) { - debug('got a key', key); - return 123456 + key; -} diff --git a/packages/http-client/tests/fixtures/resolvers/auth/login.js b/packages/http-client/tests/fixtures/resolvers/auth/login.js new file mode 100644 index 0000000000000000000000000000000000000000..8b999a65315ae67314a455a3ed02deaf02a4c73c --- /dev/null +++ b/packages/http-client/tests/fixtures/resolvers/auth/login.js @@ -0,0 +1,10 @@ + + +/** + * preparing the enable auth test + * @param {string} username user name + * @return {object} userdata + */ +module.exports = function issuer(username) { + return {name: username, timestamp: Date.now()} +} diff --git a/packages/http-client/tests/fixtures/resolvers/auth/validator.js b/packages/http-client/tests/fixtures/resolvers/auth/validator.js deleted file mode 100644 index ab17b33b3d8e7785db3e7b0836453bd1e8369c55..0000000000000000000000000000000000000000 --- a/packages/http-client/tests/fixtures/resolvers/auth/validator.js +++ /dev/null @@ -1,16 +0,0 @@ -const debug = require('debug')('jsonql-client:auth:validator'); - -/** - * @param {string} key for validation - * @return {boolean} true on success - */ -module.exports = function(key) { - debug('got a key', key) - return true; - /* - if (key) { - return key.substr(0, 3) === '123'; - } - return false; - */ -} diff --git a/packages/http-client/tests/fixtures/resolvers/query/get-something.js b/packages/http-client/tests/fixtures/resolvers/query/public/get-something.js similarity index 100% rename from packages/http-client/tests/fixtures/resolvers/query/get-something.js rename to packages/http-client/tests/fixtures/resolvers/query/public/get-something.js diff --git a/packages/http-client/tests/qunit/run-qunit-setup.js b/packages/http-client/tests/qunit/run-qunit-setup.js index 39c8891492351500cdd0eb3bbfc2b13ce233b66d..4a0f053c428a95808b0102419afc25c54d62690c 100644 --- a/packages/http-client/tests/qunit/run-qunit-setup.js +++ b/packages/http-client/tests/qunit/run-qunit-setup.js @@ -35,11 +35,12 @@ const getConfig = (config) => { }, middlewares: [ jsonqlKoa({ - // enableAuth: true, - // useJwt: true, - // keysDir: join(jsonqlKoaDir, 'keys'), + enableAuth: true, + useJwt: true, + keysDir: join(jsonqlKoaDir, 'keys'), resolverDir: join(jsonqlKoaDir, 'resolvers'), - contractDir: join(jsonqlKoaDir, 'contracts', 'tmp') + contractDir: join(jsonqlKoaDir, 'contracts') + // loginHandlerName: 'issuer' }) ] } diff --git a/packages/http-client/tests/qunit/tests/base-test.js b/packages/http-client/tests/qunit/tests/base-test.js index cac4495b1cfa07b93c9c0d5047996a01b9fd0e7a..1ec6751adff3db0423a534f2f1053baa284183bd 100644 --- a/packages/http-client/tests/qunit/tests/base-test.js +++ b/packages/http-client/tests/qunit/tests/base-test.js @@ -3,25 +3,55 @@ QUnit.test('jsonqlClient should able to connect to server', function(assert) { var done1 = assert.async() var done2 = assert.async() + var done3 = assert.async() + var done4 = assert.async() + var done5 = assert.async() jsonqlClient({ hostname: 'http://localhost:8081', showContractDesc: true, keepContract: false, - debugOn: true + debugOn: true, + enableAuth: true }) .then(function(client) { console.log('inited client', client) // 1.4.2 use the shorthand version client.helloWorld().then(function(result) { assert.equal('Hello world!', result, "Hello world test done") - done1() }) - + // test the query with wrong param client.query.getSomething(1).catch(err => { assert.equal(err.className, 'JsonqlValidationError', 'Expect validation error') done2() }) + // call the mutation before login + client.mutation.plus({a: '1', b: '1'}) + .catch(err => { + // @NOTE this is a cheat because the finalCatch from jsonql-errors not always able to catch the correct error + assert.equal(err.className, 'JsonqlError', 'Not allow to call private method before login') + done3() + + // test the login + client.auth.login('joel') + .then(token => { + const userdata = client.userdata() + // console.info('login result', userdata) + assert.equal(userdata.name, 'joel', 'Expect the login stored userdata name to be the same as we supplied') + done4() + // test the mutation AGAIN + client.mutation.plus({a: 'a', b: 'b'}) + .then(result => { + assert.equal(result, 'ab', 'We should now able to call private mutation method after login') + done5() + }) + .catch(err => { + console.log('still not able to call private method?', err) + }) + // @TODO test the logout method + }) + // @TODO test the swith profile + }) }) })