diff --git a/packages/errors/dist/jsonql-errors.cjs.js b/packages/errors/dist/jsonql-errors.cjs.js index cc187d79d4b3c80ee8c8d670e760708830095fd4..3955a512748c4499373d6057cc765c214199d682 100644 --- a/packages/errors/dist/jsonql-errors.cjs.js +++ b/packages/errors/dist/jsonql-errors.cjs.js @@ -1,2 +1,2 @@ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).jsonqlErrors={})}(this,(function(r){"use strict";var t=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(t,e),t}(Error),e=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(t,e),t}(Error),o=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(t,e),t}(Error),n=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(t,e),t}(Error),a=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(t,e),t}(Error),s=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(t,e),t}(Error),c=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(t,e),t}(Error),i=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(t,e),t}(Error),u=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(t,e),t}(Error),p=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(t,e),t}(Error),l="No message",f=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(t,e),t}(Error),h=function(r){function t(e,o){r.call(this,o),this.statusCode=e,this.className=t.name}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(t,e),t}(Error),m=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlAuthorisationError:o,JsonqlContractAuthError:n,JsonqlResolverAppError:a,JsonqlResolverNotFoundError:s,JsonqlEnumError:c,JsonqlTypeError:i,JsonqlCheckerError:u,JsonqlValidationError:p,JsonqlError:f,JsonqlServerError:h}),g=f,E=function(r,t){return!!Object.keys(r).filter((function(r){return t===r})).length};var d="unknown";function y(r,t){var e=function(r,t){return r.filter((function(r){return t instanceof r})).map((function(r){return r.name}))}(r,t);return e.length?e[0]:d}r.JSONQL_ERRORS_INFO="version: 1.1.8 module: umd",r.Jsonql406Error=t,r.Jsonql500Error=e,r.JsonqlAuthorisationError=o,r.JsonqlCheckerError=u,r.JsonqlContractAuthError=n,r.JsonqlEnumError=c,r.JsonqlError=f,r.JsonqlResolverAppError=a,r.JsonqlResolverNotFoundError=s,r.JsonqlServerError=h,r.JsonqlTypeError=i,r.JsonqlValidationError=p,r.UNKNOWN_ERROR=d,r.clientErrorsHandler=function(r){if(E(r,"error")){var t=r.error,e=t.className,o=t.name,n=e||o,a=t.message||l,s=t.detail||t;if(n&&m[n])throw new m[e](a,s);throw new g(a,s)}return r},r.finalCatch=function(r){if(Array.isArray(r))throw new p("",r);var m=r.message||l,g=r.detail||r;switch(!0){case r instanceof t:throw new t(m,g);case r instanceof e:throw new e(m,g);case r instanceof o:throw new o(m,g);case r instanceof n:throw new n(m,g);case r instanceof a:throw new a(m,g);case r instanceof s:throw new s(m,g);case r instanceof c:throw new c(m,g);case r instanceof i:throw new i(m,g);case r instanceof u:throw new u(m,g);case r instanceof p:throw new p(m,g);case r instanceof h:throw new h(m,g);default:throw new f(m,g)}},r.getErrorByStatus=function(r,t){switch(void 0===t&&(t=!1),r){case 401:return t?"JsonqlContractAuthError":"JsonqlAuthorisationError";case 403:return"JsonqlForbiddenError";case 404:return"JsonqlResolverNotFoundError";case 406:return"Jsonql406Error";case 500:return"Jsonql500Error";default:return"JsonqlError"}},r.getErrorNameByInstance=y,r.getErrorNameByInstanceWithDefault=function(r,t){var e=y(r,t);return e===d?"JsonqlError":e},Object.defineProperty(r,"__esModule",{value:!0})})); +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).jsonqlErrors={})}(this,(function(r){"use strict";var t=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(t,e),t}(Error),e=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(t,e),t}(Error),o=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 403},e.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(t,e),t}(Error),n=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(t,e),t}(Error),a=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(t,e),t}(Error),s=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(t,e),t}(Error),c=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(t,e),t}(Error),i=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(t,e),t}(Error),u=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(t,e),t}(Error),p=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(t,e),t}(Error),l=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(t,e),t}(Error),f="No message",h=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(t,e),t}(Error),m=function(r){function t(e,o){r.call(this,o),this.statusCode=e,this.className=t.name}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(t,e),t}(Error),d=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:o,JsonqlAuthorisationError:n,JsonqlContractAuthError:a,JsonqlResolverAppError:s,JsonqlResolverNotFoundError:c,JsonqlEnumError:i,JsonqlTypeError:u,JsonqlCheckerError:p,JsonqlValidationError:l,JsonqlError:h,JsonqlServerError:m}),g=h,E=function(r,t){return!!Object.keys(r).filter((function(r){return t===r})).length};var y="unknown";function _(r,t){var e=function(r,t){return r.filter((function(r){return t instanceof r})).map((function(r){return r.name}))}(r,t);return e.length?e[0]:y}r.JSONQL_ERRORS_INFO="version: 1.1.10 module: umd",r.Jsonql406Error=t,r.Jsonql500Error=e,r.JsonqlAuthorisationError=n,r.JsonqlCheckerError=p,r.JsonqlContractAuthError=a,r.JsonqlEnumError=i,r.JsonqlError=h,r.JsonqlForbiddenError=o,r.JsonqlResolverAppError=s,r.JsonqlResolverNotFoundError=c,r.JsonqlServerError=m,r.JsonqlTypeError=u,r.JsonqlValidationError=l,r.UNKNOWN_ERROR=y,r.clientErrorsHandler=function(r){if(E(r,"error")){var t=r.error,e=t.className,o=t.name,n=e||o,a=t.message||f,s=t.detail||t;if(n&&d[n])throw new d[e](a,s);throw new g(a,s)}return r},r.finalCatch=function(r){if(Array.isArray(r))throw new l("",r);var d=r.message||f,g=r.detail||r;switch(!0){case r instanceof t:throw new t(d,g);case r instanceof e:throw new e(d,g);case r instanceof o:throw new o(d,g);case r instanceof n:throw new n(d,g);case r instanceof a:throw new a(d,g);case r instanceof s:throw new s(d,g);case r instanceof c:throw new c(d,g);case r instanceof i:throw new i(d,g);case r instanceof u:throw new u(d,g);case r instanceof p:throw new p(d,g);case r instanceof l:throw new l(d,g);case r instanceof m:throw new m(d,g);default:throw new h(d,g)}},r.getErrorByStatus=function(r,t){switch(void 0===t&&(t=!1),r){case 401:return t?"JsonqlContractAuthError":"JsonqlAuthorisationError";case 403:return"JsonqlForbiddenError";case 404:return"JsonqlResolverNotFoundError";case 406:return"Jsonql406Error";case 500:return"Jsonql500Error";default:return"JsonqlError"}},r.getErrorNameByInstance=_,r.getErrorNameByInstanceWithDefault=function(r,t){var e=_(r,t);return e===y?"JsonqlError":e},Object.defineProperty(r,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-errors.cjs.js.map diff --git a/packages/errors/dist/jsonql-errors.umd.js b/packages/errors/dist/jsonql-errors.umd.js index 86022f546693acbd5f5980c945b22e73094bdc6f..fe4408382d9cef5124fa2bc4f4d9eb979a4433e7 100644 --- a/packages/errors/dist/jsonql-errors.umd.js +++ b/packages/errors/dist/jsonql-errors.umd.js @@ -1,2 +1,2 @@ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).jsonqlErrors={})}(this,(function(r){"use strict";var t=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(t,e),t}(Error),e=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(t,e),t}(Error),o=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(t,e),t}(Error),n=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(t,e),t}(Error),a=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(t,e),t}(Error),s=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(t,e),t}(Error),c=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(t,e),t}(Error),i=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(t,e),t}(Error),u=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(t,e),t}(Error),p=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(t,e),t}(Error),l="No message",f=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(t,e),t}(Error),h=function(r){function t(e,o){r.call(this,o),this.statusCode=e,this.className=t.name}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(t,e),t}(Error),m=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlAuthorisationError:o,JsonqlContractAuthError:n,JsonqlResolverAppError:a,JsonqlResolverNotFoundError:s,JsonqlEnumError:c,JsonqlTypeError:i,JsonqlCheckerError:u,JsonqlValidationError:p,JsonqlError:f,JsonqlServerError:h}),g=f,E=function(r,t){return!!Object.keys(r).filter((function(r){return t===r})).length};var d="unknown";function y(r,t){var e=function(r,t){return r.filter((function(r){return t instanceof r})).map((function(r){return r.name}))}(r,t);return e.length?e[0]:d}r.JSONQL_ERRORS_INFO="version: 1.1.8 module: umd",r.Jsonql406Error=t,r.Jsonql500Error=e,r.JsonqlAuthorisationError=o,r.JsonqlCheckerError=u,r.JsonqlContractAuthError=n,r.JsonqlEnumError=c,r.JsonqlError=f,r.JsonqlResolverAppError=a,r.JsonqlResolverNotFoundError=s,r.JsonqlServerError=h,r.JsonqlTypeError=i,r.JsonqlValidationError=p,r.UNKNOWN_ERROR=d,r.clientErrorsHandler=function(r){if(E(r,"error")){var t=r.error,e=t.className,o=t.name,n=e||o,a=t.message||l,s=t.detail||t;if(n&&m[n])throw new m[e](a,s);throw new g(a,s)}return r},r.finalCatch=function(r){if(Array.isArray(r))throw new p("",r);var m=r.message||l,g=r.detail||r;switch(!0){case r instanceof t:throw new t(m,g);case r instanceof e:throw new e(m,g);case r instanceof o:throw new o(m,g);case r instanceof n:throw new n(m,g);case r instanceof a:throw new a(m,g);case r instanceof s:throw new s(m,g);case r instanceof c:throw new c(m,g);case r instanceof i:throw new i(m,g);case r instanceof u:throw new u(m,g);case r instanceof p:throw new p(m,g);case r instanceof h:throw new h(m,g);default:throw new f(m,g)}},r.getErrorByStatus=function(r,t){switch(void 0===t&&(t=!1),r){case 401:return t?"JsonqlContractAuthError":"JsonqlAuthorisationError";case 403:return"JsonqlForbiddenError";case 404:return"JsonqlResolverNotFoundError";case 406:return"Jsonql406Error";case 500:return"Jsonql500Error";default:return"JsonqlError"}},r.getErrorNameByInstance=y,r.getErrorNameByInstanceWithDefault=function(r,t){var e=y(r,t);return e===d?"JsonqlError":e},Object.defineProperty(r,"__esModule",{value:!0})})); +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).jsonqlErrors={})}(this,(function(r){"use strict";var t=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 406},e.name.get=function(){return"Jsonql406Error"},Object.defineProperties(t,e),t}(Error),e=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"Jsonql500Error"},Object.defineProperties(t,e),t}(Error),o=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 403},e.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(t,e),t}(Error),n=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(t,e),t}(Error),a=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 401},e.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(t,e),t}(Error),s=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 500},e.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(t,e),t}(Error),c=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={statusCode:{configurable:!0},name:{configurable:!0}};return e.statusCode.get=function(){return 404},e.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(t,e),t}(Error),i=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(t,e),t}(Error),u=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(t,e),t}(Error),p=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(t,e),t}(Error),l=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(t,e),t}(Error),f="No message",h=function(r){function t(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];r.apply(this,e),this.message=e[0],this.detail=e[1],this.className=t.name,r.captureStackTrace&&r.captureStackTrace(this,t)}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(t,e),t}(Error),m=function(r){function t(e,o){r.call(this,o),this.statusCode=e,this.className=t.name}r&&(t.__proto__=r),t.prototype=Object.create(r&&r.prototype),t.prototype.constructor=t;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlServerError"},Object.defineProperties(t,e),t}(Error),d=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:o,JsonqlAuthorisationError:n,JsonqlContractAuthError:a,JsonqlResolverAppError:s,JsonqlResolverNotFoundError:c,JsonqlEnumError:i,JsonqlTypeError:u,JsonqlCheckerError:p,JsonqlValidationError:l,JsonqlError:h,JsonqlServerError:m}),g=h,E=function(r,t){return!!Object.keys(r).filter((function(r){return t===r})).length};var y="unknown";function _(r,t){var e=function(r,t){return r.filter((function(r){return t instanceof r})).map((function(r){return r.name}))}(r,t);return e.length?e[0]:y}r.JSONQL_ERRORS_INFO="version: 1.1.10 module: umd",r.Jsonql406Error=t,r.Jsonql500Error=e,r.JsonqlAuthorisationError=n,r.JsonqlCheckerError=p,r.JsonqlContractAuthError=a,r.JsonqlEnumError=i,r.JsonqlError=h,r.JsonqlForbiddenError=o,r.JsonqlResolverAppError=s,r.JsonqlResolverNotFoundError=c,r.JsonqlServerError=m,r.JsonqlTypeError=u,r.JsonqlValidationError=l,r.UNKNOWN_ERROR=y,r.clientErrorsHandler=function(r){if(E(r,"error")){var t=r.error,e=t.className,o=t.name,n=e||o,a=t.message||f,s=t.detail||t;if(n&&d[n])throw new d[e](a,s);throw new g(a,s)}return r},r.finalCatch=function(r){if(Array.isArray(r))throw new l("",r);var d=r.message||f,g=r.detail||r;switch(!0){case r instanceof t:throw new t(d,g);case r instanceof e:throw new e(d,g);case r instanceof o:throw new o(d,g);case r instanceof n:throw new n(d,g);case r instanceof a:throw new a(d,g);case r instanceof s:throw new s(d,g);case r instanceof c:throw new c(d,g);case r instanceof i:throw new i(d,g);case r instanceof u:throw new u(d,g);case r instanceof p:throw new p(d,g);case r instanceof l:throw new l(d,g);case r instanceof m:throw new m(d,g);default:throw new h(d,g)}},r.getErrorByStatus=function(r,t){switch(void 0===t&&(t=!1),r){case 401:return t?"JsonqlContractAuthError":"JsonqlAuthorisationError";case 403:return"JsonqlForbiddenError";case 404:return"JsonqlResolverNotFoundError";case 406:return"Jsonql406Error";case 500:return"Jsonql500Error";default:return"JsonqlError"}},r.getErrorNameByInstance=_,r.getErrorNameByInstanceWithDefault=function(r,t){var e=_(r,t);return e===y?"JsonqlError":e},Object.defineProperty(r,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-errors.umd.js.map diff --git a/packages/errors/index.js b/packages/errors/index.js index b7e5f662b274278915f377bcf57c3840c90d2315..9cc10f84ca19d9bb872f537402bdbf5a90bd0074 100644 --- a/packages/errors/index.js +++ b/packages/errors/index.js @@ -11,6 +11,7 @@ const JSONQL_ERRORS_INFO = '__PLACEHOLDER__' import { Jsonql406Error, Jsonql500Error, + JsonqlForbiddenError, JsonqlAuthorisationError, JsonqlContractAuthError, JsonqlResolverAppError, @@ -35,6 +36,7 @@ export { Jsonql406Error, Jsonql500Error, + JsonqlForbiddenError, JsonqlAuthorisationError, JsonqlContractAuthError, JsonqlResolverAppError, diff --git a/packages/errors/package.json b/packages/errors/package.json index 8537c6d691133a8022f3dddec2efdd8d7b1d2ca3..aa145afc42a9cd17caa896f31cc333ecd4dde5fb 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-errors", - "version": "1.1.8", + "version": "1.1.10", "description": "Jsonql js error classes use across the projects", "main": "dist/jsonql-errors.cjs.js", "module": "index.js", @@ -33,7 +33,7 @@ "fs-extra": "^8.1.0", "koa": "^2.11.0", "koa-bodyparser": "^4.2.1", - "rollup": "^1.27.8", + "rollup": "^1.27.9", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-async": "^1.2.0", "rollup-plugin-buble": "^0.19.8", @@ -76,6 +76,6 @@ "author": "Joel Chu ", "license": "ISC", "dependencies": { - "jsonql-constants": "^1.8.12" + "jsonql-constants": "^1.8.13" } } diff --git a/packages/errors/src/client-errors-handler.js b/packages/errors/src/client-errors-handler.js index f157fdd946c88b208382b603234aa2ee4ef2fa07..8e542ec714701a4957314752f86590fdbd35c2d7 100644 --- a/packages/errors/src/client-errors-handler.js +++ b/packages/errors/src/client-errors-handler.js @@ -1,9 +1,9 @@ // this will add directly to the then call in each http call -import * as errors from './index'; -import getErrorByStatus from './get-error-by-status'; -import { NO_ERROR_MSG } from 'jsonql-constants'; -const { JsonqlError } = errors; +import * as errors from './index' +import getErrorByStatus from './get-error-by-status' +import { NO_ERROR_MSG } from 'jsonql-constants' +const { JsonqlError } = errors /** * We can not just check something like result.data what if the result if false? diff --git a/packages/errors/src/final-catch.js b/packages/errors/src/final-catch.js index 0c849324540eec909630e8d3a061a70e315d68d7..82ba8e404f61c0dbf166f68813508b1b0faee8b8 100644 --- a/packages/errors/src/final-catch.js +++ b/packages/errors/src/final-catch.js @@ -1,25 +1,26 @@ -import Jsonql406Error from './406-error'; -import Jsonql500Error from './500-error'; -import JsonqlAuthorisationError from './authorisation-error'; -import JsonqlContractAuthError from './contract-auth-error'; -import JsonqlResolverAppError from './resolver-app-error'; -import JsonqlResolverNotFoundError from './resolver-not-found-error'; +import Jsonql406Error from './406-error' +import Jsonql500Error from './500-error' +import JsonqlForbiddenError from './forbidden-error' +import JsonqlAuthorisationError from './authorisation-error' +import JsonqlContractAuthError from './contract-auth-error' +import JsonqlResolverAppError from './resolver-app-error' +import JsonqlResolverNotFoundError from './resolver-not-found-error' // check options error -import JsonqlEnumError from './enum-error'; -import JsonqlTypeError from './type-error'; -import JsonqlCheckerError from './checker-error'; +import JsonqlEnumError from './enum-error' +import JsonqlTypeError from './type-error' +import JsonqlCheckerError from './checker-error' // share -import JsonqlValidationError from './validation-error'; +import JsonqlValidationError from './validation-error' import JsonqlError from './error'; -import JsonqlServerError from './server-error'; +import JsonqlServerError from './server-error' -import { NO_ERROR_MSG } from 'jsonql-constants'; +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 + * Error type * @param {object} e error * @param {*} msg message * @param {*} detail the full detail @@ -55,6 +56,8 @@ export default function finalCatch(e) { throw new Jsonql406Error(msg, detail) case e instanceof Jsonql500Error: throw new Jsonql500Error(msg, detail) + case e instanceof JsonqlForbiddenError: + throw new JsonqlForbiddenError(msg, detail) case e instanceof JsonqlAuthorisationError: throw new JsonqlAuthorisationError(msg, detail) case e instanceof JsonqlContractAuthError: diff --git a/packages/errors/src/index.js b/packages/errors/src/index.js index d8f6bbf57dc8aa577237d2ed97f9f6cd013692ba..48eb6134b8c3e8fe157ae3383a14b50723277789 100644 --- a/packages/errors/src/index.js +++ b/packages/errors/src/index.js @@ -1,24 +1,27 @@ // server side -import Jsonql406Error from './406-error'; -import Jsonql500Error from './500-error'; -import JsonqlAuthorisationError from './authorisation-error'; -import JsonqlContractAuthError from './contract-auth-error'; -import JsonqlResolverAppError from './resolver-app-error'; -import JsonqlResolverNotFoundError from './resolver-not-found-error'; +import Jsonql406Error from './406-error' +import Jsonql500Error from './500-error' + +import JsonqlForbiddenError from './forbidden-error' +import JsonqlAuthorisationError from './authorisation-error' +import JsonqlContractAuthError from './contract-auth-error' +import JsonqlResolverAppError from './resolver-app-error' +import JsonqlResolverNotFoundError from './resolver-not-found-error' // check options error -import JsonqlEnumError from './enum-error'; -import JsonqlTypeError from './type-error'; -import JsonqlCheckerError from './checker-error'; +import JsonqlEnumError from './enum-error' +import JsonqlTypeError from './type-error' +import JsonqlCheckerError from './checker-error' // share -import JsonqlValidationError from './validation-error'; -import JsonqlError from './error'; +import JsonqlValidationError from './validation-error' +import JsonqlError from './error' -import JsonqlServerError from './server-error'; +import JsonqlServerError from './server-error' export { Jsonql406Error, Jsonql500Error, + JsonqlForbiddenError, JsonqlAuthorisationError, JsonqlContractAuthError, JsonqlResolverAppError, diff --git a/packages/http-client/core.js b/packages/http-client/core.js index 1e62e9a5f4b02b8e886cca9b9b23a4c2344cf0f2..821c888f5718c4c1b1fd6e3857975a15ae15365e 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,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)}})); +!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}function H(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--&&X(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var dt=function(t){return b(t)?t:[t]},vt=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},gt=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),yt=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),bt=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),_t=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),mt=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),wt=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),jt=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),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}};return r.name.get=function(){return"JsonqlEnumError"},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"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),kt=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),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"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),Tt=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),xt=Object.freeze({__proto__:null,Jsonql406Error:gt,Jsonql500Error:yt,JsonqlForbiddenError:bt,JsonqlAuthorisationError:_t,JsonqlContractAuthError:mt,JsonqlResolverAppError:wt,JsonqlResolverNotFoundError:jt,JsonqlEnumError:St,JsonqlTypeError:Ot,JsonqlCheckerError:kt,JsonqlValidationError:At,JsonqlError:Et,JsonqlServerError:Tt}),Pt=Et,qt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Ct(t){if(qt(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&&xt[o])throw new xt[r](i,a);throw new Pt(i,a)}return t}function $t(t){if(Array.isArray(t))throw new At("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof gt:throw new gt(e,r);case t instanceof yt:throw new yt(e,r);case t instanceof bt:throw new bt(e,r);case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);default:throw new Et(e,r)}}function zt(t){return!!function(t){return D(t)&&(vt(t,r)||vt(t,n)||vt(t,o))}(t)&&t}function Nt(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var Mt=function(t,e){return void 0===e&&(e={}),zt(e)?Promise.resolve(e):t.getContract()},It="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Rt(t){this.message=t}Rt.prototype=new Error,Rt.prototype.name="InvalidCharacterError";var Ft="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rt("'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=It.indexOf(n);return a};var Jt=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(Ft(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 Ft(e)}};function Ut(t){this.message=t}Ut.prototype=new Error,Ut.prototype.name="InvalidTokenError";var Dt=function(t,e){if("string"!=typeof t)throw new Ut("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Jt(t.split(".")[r]))}catch(t){throw new Ut("Invalid token specified: "+t.message)}},Ht=Ut;Dt.InvalidTokenError=Ht;var Lt="[object String]";function Bt(t){return"string"==typeof t||!b(t)&&N(t)&&C(t)==Lt}var Kt=function(t){return""!==ht(t)&&Bt(t)},Gt=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||Gt(!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}(Dt(t));throw new Et("Token must be a string!")}var Wt=function(t){return!!b(t)||null!=t&&""!==ht(t)},Yt="[object Number]";function Qt(t){return function(t){return"number"==typeof t||N(t)&&C(t)==Yt}(t)&&t!=+t}var Xt=function(t){return!Bt(t)&&!Qt(parseFloat(t))},Zt=function(t){return null!=t&&"boolean"==typeof t},te=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ht(t)&&(!1===e||!0===e&&null!==t)},ee=s,re=f,ne=l,oe=p,ie=h,ae=d,ue="continue",ce=function(t){switch(t){case"number":return Xt;case"string":return Kt;case"boolean":return Zt;default:return te}},se=function(t,e){return void 0===e&&(e=""),!!b(t)&&(""===e||""===ht(e)||!(t.filter((function(t){return!ce(e)(t)})).length>0))},fe=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},le=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ce(e)(t)})).length)})).length:e.length>e.filter((function(t){return!se(r,t)})).length};var pe,he=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[pe?a:++n];if(!1===e(o[u],u,o))break}return t};var de="[object Arguments]";function ve(t){return N(t)&&C(t)==de}var ge=Object.prototype,ye=ge.hasOwnProperty,be=ge.propertyIsEnumerable,_e=ve(function(){return arguments}())?ve:function(t){return N(t)&&ye.call(t,"callee")&&!be.call(t,"callee")};var me="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=me&&"object"==typeof module&&module&&!module.nodeType&&module,je=we&&we.exports===me?j.Buffer:void 0,Se=(je?je.isBuffer:void 0)||function(){return!1},Oe=9007199254740991,ke=/^(?:0|[1-9]\d*)$/;function Ae(t,e){var r=typeof t;return!!(e=null==e?Oe:e)&&("number"==r||"symbol"!=r&&ke.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ee}var xe={};xe["[object Float32Array]"]=xe["[object Float64Array]"]=xe["[object Int8Array]"]=xe["[object Int16Array]"]=xe["[object Int32Array]"]=xe["[object Uint8Array]"]=xe["[object Uint8ClampedArray]"]=xe["[object Uint16Array]"]=xe["[object Uint32Array]"]=!0,xe["[object Arguments]"]=xe["[object Array]"]=xe["[object ArrayBuffer]"]=xe["[object Boolean]"]=xe["[object DataView]"]=xe["[object Date]"]=xe["[object Error]"]=xe["[object Function]"]=xe["[object Map]"]=xe["[object Number]"]=xe["[object Object]"]=xe["[object RegExp]"]=xe["[object Set]"]=xe["[object String]"]=xe["[object WeakMap]"]=!1;var Pe,qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ce=qe&&"object"==typeof module&&module&&!module.nodeType&&module,$e=Ce&&Ce.exports===qe&&m.process,ze=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||$e&&$e.binding&&$e.binding("util")}catch(t){}}(),Ne=ze&&ze.isTypedArray,Me=Ne?(Pe=Ne,function(t){return Pe(t)}):function(t){return N(t)&&Te(t.length)&&!!xe[C(t)]},Ie=Object.prototype.hasOwnProperty;function Re(t,e){var r=b(t),n=!r&&_e(t),o=!r&&!n&&Se(t),i=!r&&!n&&!o&&Me(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},er.prototype.set=function(t,e){var r=this.__data__,n=Ze(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var rr,nr=j["__core-js_shared__"],or=(rr=/[^.]+$/.exec(nr&&nr.keys&&nr.keys.IE_PROTO||""))?"Symbol(src)_1."+rr:"";var ir=Function.prototype.toString;function ar(t){if(null!=t){try{return ir.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ur=/^\[object .+?Constructor\]$/,cr=Function.prototype,sr=Object.prototype,fr=cr.toString,lr=sr.hasOwnProperty,pr=RegExp("^"+fr.call(lr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(t){return!(!He(t)||function(t){return!!or&&or in t}(t))&&(Ve(t)?pr:ur).test(ar(t))}function dr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return hr(r)?r:void 0}var vr=dr(j,"Map"),gr=dr(Object,"create");var yr="__lodash_hash_undefined__",br=Object.prototype.hasOwnProperty;var _r=Object.prototype.hasOwnProperty;var mr="__lodash_hash_undefined__";function wr(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&Pr?new Er:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=fe(t))?!le({arg:r},e):!ce(t)(r))})).length)})).length}return!1},Qn=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(Yn,null,a);case"array"===t:return!se(e.arg);case!1!==(r=fe(t)):return!le(e,r);default:return!ce(t)(e.arg)}},Xn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Zn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!se(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(!se(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?Xn(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!!Wt(e)&&!(r.type.length>r.type.filter((function(e){return Qn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Qn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},to=function(){try{var t=dr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function eo(t,e,r){"__proto__"==e&&to?to(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ro(t,e,r){(void 0===r||Xe(t[e],r))&&(void 0!==r||e in t)||eo(t,e,r)}var no="object"==typeof exports&&exports&&!exports.nodeType&&exports,oo=no&&"object"==typeof module&&module&&!module.nodeType&&module,io=oo&&oo.exports===no?j.Buffer:void 0,ao=io?io.allocUnsafe:void 0;function uo(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Cr(n).set(new Cr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var co=Object.create,so=function(){function t(){}return function(e){if(!He(e))return{};if(co)return co(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function fo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var lo=Object.prototype.hasOwnProperty;function po(t,e,r){var n=t[e];lo.call(t,e)&&Xe(n,r)&&(void 0!==r||e in t)||eo(t,e,r)}var ho=Object.prototype.hasOwnProperty;function vo(t){if(!He(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&&ho.call(t,n))&&r.push(n);return r}function go(t){return We(t)?Re(t,!0):vo(t)}function yo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=So)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(jo);function Eo(t,e){return Ao(function(t,e,r){return e=wo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=wo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=To.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!He(r))return!1;var n=typeof e;return!!("number"==n?We(r)&&Ae(e,r.length):"string"==n&&e in r)&&Xe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ci().key(e);t($i(r),r)}},remove:function(t){return Ci().removeItem(t)},clearAll:function(){return Ci().clear()}};function Ci(){return Pi.localStorage}function $i(t){return Ci().getItem(t)}var zi=di.trim,Ni={name:"cookieStorage",read:function(t){if(!t||!Fi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Mi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Mi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ii,remove:Ri,clearAll:function(){Ii((function(t,e){Ri(e)}))}},Mi=di.Global.document;function Ii(t){for(var e=Mi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(zi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ri(t){t&&Fi(t)&&(Mi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Fi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Mi.cookie)}var Ji=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 Ui=di.bind,Di=di.each,Hi=di.create,Li=di.slice,Bi=function(){var t=Hi(Ki,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Ui(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Ui(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(),Di(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ki={_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,Ui(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Li(arguments,1);Di(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Gi=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)})),Vi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Gi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Gi.compress(this._serialize(r));t(e,n)}}};var Wi=[qi,Ni],Yi=[Ji,Bi,Vi],Qi=Ei.createStore(Wi,Yi),Xi=di.Global;function Zi(){return Xi.sessionStorage}function ta(t){return Zi().getItem(t)}var ea=[{name:"sessionStorage",read:ta,write:function(t,e){return Zi().setItem(t,e)},each:function(t){for(var e=Zi().length-1;e>=0;e--){var r=Zi().key(e);t(ta(r),r)}},remove:function(t){return Zi().removeItem(t)},clearAll:function(){return Zi().clear()}},Ni],ra=[Ji,Vi],na=Ei.createStore(ea,ra),oa=Qi,ia=na,aa=function(t){var e;return(e={}).args=t,e};function ua(t,e){var r;return(r={})[t]=e,r[u]=[ci()],r}var ca=function(t){return vt(t,"data")&&!vt(t,"error")?t.data:t},sa=function(t){this.opts=t,this.instanceKey=Nt(this.opts.hostname)+"",this.localStore=oa,this.sessionStore=ia},fa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};sa.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?xo({},o,e):e,r))},sa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},sa.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)}},sa.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)}},fa.lset.set=function(t){return this.__setMethod("localStore",t)},fa.lget.get=function(){return this.__getMethod("localStore")},sa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},sa.prototype.lclear=function(){return this.__clearMethod("localStore")},fa.sset.set=function(t){return this.__setMethod("sessionStore",t)},fa.sget.get=function(){return this.__getMethod("sessionStore")},sa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},sa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(sa.prototype,fa);var la=c[0],pa=c[1],ha=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];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;Reflect.apply(console[r[n]],console,t.splice(0,n))}},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={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(oi(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new At("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&&oi(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(!zt(t))throw new At("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zt(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=xo({},{_cb:ci()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=xo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=xo({},{method:la,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 ca(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=ni(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ca(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Tt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?xo({},e,this.getAuthHeader(),this.extraHeader):xo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=xo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Ct).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Tt("getRemoteContract",e)}))},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),Bt(t)&&b(e)){var n=aa(e);return!0===r?n:ua(t,n)}throw new At("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Ct)},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(Bt(t))return ua(t,o);throw new At("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:pa}).then(Ct)},Object.defineProperties(r.prototype,n),r}(sa)))),da=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,dt(t))}),Reflect.apply(t,null,r))}};function va(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function ga(t,e,r,n){void 0===n&&(n=!1);var o=va(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var ya=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 ii(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch($t)}},ba=function(t,e,r,n,o){var i={},a=function(t){i=ga(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 ii(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch($t)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},_a=function(t,e,r,n,o){var i={},a=function(t){i=ga(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return ii(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch($t)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},ma=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=ya(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=ya(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 wa=function(t,e,r,n){var o=function(t,e,r,n){return da(ba,_a,ma)({},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.2",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},ja={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Sa={hostname:ai(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:ai("jsonql",["string"]),loginHandlerName:ai("login",["string"]),logoutHandlerName:ai("logout",["string"]),enableJsonp:ai(!1,["boolean"]),enableAuth:ai(!1,["boolean"]),useJwt:ai(!0,["boolean"]),persistToken:ai(!1,["boolean","number"]),useLocalstorage:ai(!0,["boolean"]),storageKey:ai("jsonqlstore",["string"]),authKey:ai("jsonqlauthkey",["string"]),contractExpired:ai(0,["number"]),keepContract:ai(!0,["boolean"]),exposeContract:ai(!1,["boolean"]),exposeStore:ai(!1,["boolean"]),showContractDesc:ai(!1,["boolean"]),contractKey:ai(!1,["boolean"]),contractKeyName:ai("X-JSONQL-CV-KEY",["string"]),enableTimeout:ai(!1,["boolean"]),timeout:ai(5e3,["number"]),returnInstance:ai(!1,["boolean"]),allowReturnRawToken:ai(!1,["boolean"]),debugOn:ai(!1,["boolean"])};function Oa(t){return va(t,v)?Promise.resolve(t):function(t){var e=t.contract;return ui(t,Sa,ja).then((function(t){return t.contract=e,t}))}(t)}var ka=new WeakMap,Aa=new WeakMap,Ea=function(){this.__suspend__=null,this.queueStore=new Set},Ta={$suspend:{configurable:!0},$queues:{configurable:!0}};Ta.$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)},Ea.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__},Ta.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ea.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(Ea.prototype,Ta);var xa=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){ka.set(this,t)},r.normalStore.get=function(){return ka.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 Nt(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Ea));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Oa(e).then((function(t){return{baseClient:new ha(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Mt(r,n.contract).then((function(e){return wa(r,n,e,t)}))}))}((r=e.debugOn,new xa({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 04ea2db523ea42b53f9ecdbe36ee58d9a9e83697..f2826e84efcd509cdb448c94826e57424fda651d 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"],"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"],"names":[],"mappings":"21vCAAA"} \ No newline at end of file +{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.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"],"names":[],"mappings":"k5wCAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 2a0a7ef70bda24372340d6ac9fedb0f36dbac504..dacebcead6839b4f4bcf11eb38d50854bfadda73 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-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="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)}})); +!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}function Y(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--&&it(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var wt=function(t){return k(t)?t:[t]},jt=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},Ot=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},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={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),kt=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 403},r.name.get=function(){return"JsonqlForbiddenError"},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={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),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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),xt=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),Pt=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),qt=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),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"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),$t=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),zt=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),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},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),Mt=Object.freeze({__proto__:null,Jsonql406Error:St,Jsonql500Error:kt,JsonqlForbiddenError:Et,JsonqlAuthorisationError:At,JsonqlContractAuthError:Tt,JsonqlResolverAppError:xt,JsonqlResolverNotFoundError:Pt,JsonqlEnumError:qt,JsonqlTypeError:Ct,JsonqlCheckerError:$t,JsonqlValidationError:zt,JsonqlError:Nt,JsonqlServerError:Rt}),Ft=Nt,Jt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function It(t){if(Jt(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&&Mt[o])throw new Mt[r](i,a);throw new Ft(i,a)}return t}function Ut(t){if(Array.isArray(t))throw new zt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof St:throw new St(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof Ct:throw new Ct(e,r);case t instanceof $t:throw new $t(e,r);case t instanceof zt:throw new zt(e,r);case t instanceof Rt:throw new Rt(e,r);default:throw new Nt(e,r)}}var Dt=function(t){return!!k(t)||null!=t&&""!==_t(t)},Ht="[object Number]";function Lt(t){return function(t){return"number"==typeof t||D(t)&&J(t)==Ht}(t)&&t!=+t}var Bt="[object String]";function Kt(t){return"string"==typeof t||!k(t)&&D(t)&&J(t)==Bt}var Gt=function(t){return!Kt(t)&&!Lt(parseFloat(t))},Vt=function(t){return""!==_t(t)&&Kt(t)},Wt=function(t){return null!=t&&"boolean"==typeof t},Yt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==_t(t)&&(!1===e||!0===e&&null!==t)},Qt=d,Xt=v,Zt=g,te=y,ee=b,re=m,ne="continue",oe=function(t){switch(t){case"number":return Gt;case"string":return Vt;case"boolean":return Wt;default:return Yt}},ie=function(t,e){return void 0===e&&(e=""),!!k(t)&&(""===e||""===_t(e)||!(t.filter((function(t){return!oe(e)(t)})).length>0))},ae=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ue=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!oe(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ie(r,t)})).length};var ce,se=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ce?a:++n];if(!1===e(o[u],u,o))break}return t};var fe="[object Arguments]";function le(t){return D(t)&&J(t)==fe}var pe=Object.prototype,he=pe.hasOwnProperty,de=pe.propertyIsEnumerable,ve=le(function(){return arguments}())?le:function(t){return D(t)&&he.call(t,"callee")&&!de.call(t,"callee")};var ge="object"==typeof exports&&exports&&!exports.nodeType&&exports,ye=ge&&"object"==typeof module&&module&&!module.nodeType&&module,be=ye&&ye.exports===ge?x.Buffer:void 0,me=(be?be.isBuffer:void 0)||function(){return!1},_e=9007199254740991,we=/^(?:0|[1-9]\d*)$/;function je(t,e){var r=typeof t;return!!(e=null==e?_e:e)&&("number"==r||"symbol"!=r&&we.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Oe}var ke={};ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Ee,Ae="object"==typeof exports&&exports&&!exports.nodeType&&exports,Te=Ae&&"object"==typeof module&&module&&!module.nodeType&&module,xe=Te&&Te.exports===Ae&&A.process,Pe=function(){try{var t=Te&&Te.require&&Te.require("util").types;return t||xe&&xe.binding&&xe.binding("util")}catch(t){}}(),qe=Pe&&Pe.isTypedArray,Ce=qe?(Ee=qe,function(t){return Ee(t)}):function(t){return D(t)&&Se(t.length)&&!!ke[J(t)]},$e=Object.prototype.hasOwnProperty;function ze(t,e){var r=k(t),n=!r&&ve(t),o=!r&&!n&&me(t),i=!r&&!n&&!o&&Ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Qe.prototype.set=function(t,e){var r=this.__data__,n=We(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Xe,Ze=x["__core-js_shared__"],tr=(Xe=/[^.]+$/.exec(Ze&&Ze.keys&&Ze.keys.IE_PROTO||""))?"Symbol(src)_1."+Xe:"";var er=Function.prototype.toString;function rr(t){if(null!=t){try{return er.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var nr=/^\[object .+?Constructor\]$/,or=Function.prototype,ir=Object.prototype,ar=or.toString,ur=ir.hasOwnProperty,cr=RegExp("^"+ar.call(ur).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sr(t){return!(!Je(t)||function(t){return!!tr&&tr in t}(t))&&(Le(t)?cr:nr).test(rr(t))}function fr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return sr(r)?r:void 0}var lr=fr(x,"Map"),pr=fr(Object,"create");var hr="__lodash_hash_undefined__",dr=Object.prototype.hasOwnProperty;var vr=Object.prototype.hasOwnProperty;var gr="__lodash_hash_undefined__";function yr(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 Or:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ae(t))?!ue({arg:r},e):!oe(t)(r))})).length)})).length}return!1},Gn=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(Kn,null,a);case"array"===t:return!ie(e.arg);case!1!==(r=ae(t)):return!ue(e,r);default:return!oe(t)(e.arg)}},Vn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Wn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ie(e))throw new Nt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ie(t))throw new Nt("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?Vn(t,a):t,index:r,param:a,optional:i}}));default:throw new Nt("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!!Dt(e)&&!(r.type.length>r.type.filter((function(e){return Gn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Gn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Yn=function(){try{var t=fr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Qn(t,e,r){"__proto__"==e&&Yn?Yn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Xn(t,e,r){(void 0===r||Ve(t[e],r))&&(void 0!==r||e in t)||Qn(t,e,r)}var Zn="object"==typeof exports&&exports&&!exports.nodeType&&exports,to=Zn&&"object"==typeof module&&module&&!module.nodeType&&module,eo=to&&to.exports===Zn?x.Buffer:void 0,ro=eo?eo.allocUnsafe:void 0;function no(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Tr(n).set(new Tr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var oo=Object.create,io=function(){function t(){}return function(e){if(!Je(e))return{};if(oo)return oo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function ao(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var uo=Object.prototype.hasOwnProperty;function co(t,e,r){var n=t[e];uo.call(t,e)&&Ve(n,r)&&(void 0!==r||e in t)||Qn(t,e,r)}var so=Object.prototype.hasOwnProperty;function fo(t){if(!Je(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Re(t),r=[];for(var n in t)("constructor"!=n||!e&&so.call(t,n))&&r.push(n);return r}function lo(t){return Be(t)?ze(t,!0):fo(t)}function po(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=mo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(bo);function Oo(t,e){return jo(function(t,e,r){return e=yo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=yo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=So.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Je(r))return!1;var n=typeof e;return!!("number"==n?Be(r)&&je(e,r.length):"string"==n&&e in r)&&Ve(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,wt(t))}),Reflect.apply(t,null,r))}};function Wo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Yo(t,e,r,n){void 0===n&&(n=!1);var o=Wo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Qo=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 Bo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ut)}},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(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 Bo(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]},Zo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Bo(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]},ti=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=Qo(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=Qo(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 ei=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(Ot(e,r,O),o),t.$only(Ot(e,r,S),i),t.$trigger(e,{resolverName:r,args:n})}))}},ri=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 ni(t,e,r,n){var o=function(t,e,r,n){return Vo(Xo,Zo,ti)({},t,e,r,n)}(t,e,r,n);ri(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(Ot(t,n,O),r)})).catch((function(r){e.$trigger(Ot(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 oi=function(t,e,r,n){n.$suspend=!0,r.then((function(r){ni(t,n,e,r)}));var o={query:ei(n,"query"),mutation:ei(n,"mutation"),auth:ei(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.2",o};function ii(t){return!!function(t){return W(t)&&(jt(t,u)||jt(t,c)||jt(t,s))}(t)&&t}function ai(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ui=function(t,e){return void 0===e&&(e={}),ii(e)?Promise.resolve(e):t.getContract()},ci="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function si(t){this.message=t}si.prototype=new Error,si.prototype.name="InvalidCharacterError";var fi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new si("'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=ci.indexOf(n);return a};var li=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(fi(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 fi(e)}};function pi(t){this.message=t}pi.prototype=new Error,pi.prototype.name="InvalidTokenError";var hi=function(t,e){if("string"!=typeof t)throw new pi("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(li(t.split(".")[r]))}catch(t){throw new pi("Invalid token specified: "+t.message)}},di=pi;hi.InvalidTokenError=di;var vi,gi,yi,bi,mi,_i,wi,ji,Oi,Si=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function ki(t){if(Vt(t))return function(t){var e=t.iat||Si(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Nt("Token has expired on "+r,t)}return t}(hi(t));throw new Nt("Token must be a string!")}Ko("HS256",["string"]),Ko(!1,["boolean","number","string"],((vi={})[m]="exp",vi[v]=!0,vi)),Ko(!1,["boolean","number","string"],((gi={})[m]="nbf",gi[v]=!0,gi)),Ko(!1,["boolean","string"],((yi={})[m]="iss",yi[v]=!0,yi)),Ko(!1,["boolean","string"],((bi={})[m]="sub",bi[v]=!0,bi)),Ko(!1,["boolean","string"],((mi={})[m]="iss",mi[v]=!0,mi)),Ko(!1,["boolean"],((_i={})[v]=!0,_i)),Ko(!1,["boolean","string"],((wi={})[v]=!0,wi)),Ko(!1,["boolean","string"],((ji={})[v]=!0,ji)),Ko(!1,["boolean"],((Oi={})[v]=!0,Oi));var Ei=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Ai=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Wi().key(e);t(Yi(r),r)}},remove:function(t){return Wi().removeItem(t)},clearAll:function(){return Wi().clear()}};function Wi(){return Gi.localStorage}function Yi(t){return Wi().getItem(t)}var Qi=qi.trim,Xi={name:"cookieStorage",read:function(t){if(!t||!ra(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:ta,remove:ea,clearAll:function(){ta((function(t,e){ea(e)}))}},Zi=qi.Global.document;function ta(t){for(var e=Zi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Qi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ea(t){t&&ra(t)&&(Zi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ra(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Zi.cookie)}var na=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 oa=qi.bind,ia=qi.each,aa=qi.create,ua=qi.slice,ca=function(){var t=aa(sa,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,oa(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,oa(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(),ia(r,(function(e,r){t.fire(r,void 0,e)}))}}};var sa={_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,oa(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=ua(arguments,1);ia(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},fa=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)})),la=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)}}};var pa=[Vi,Xi],ha=[na,ca,la],da=Li.createStore(pa,ha),va=qi.Global;function ga(){return va.sessionStorage}function ya(t){return ga().getItem(t)}var ba=[{name:"sessionStorage",read:ya,write:function(t,e){return ga().setItem(t,e)},each:function(t){for(var e=ga().length-1;e>=0;e--){var r=ga().key(e);t(ya(r),r)}},remove:function(t){return ga().removeItem(t)},clearAll:function(){return ga().clear()}},Xi],ma=[na,la],_a=Li.createStore(ba,ma),wa=da,ja=_a,Oa=function(t){var e;return(e={}).args=t,e};function Sa(t,e){var r;return(r={})[t]=e,r[p]=[Ei()],r}var ka=function(t){return jt(t,"data")&&!jt(t,"error")?t.data:t},Ea=function(t){this.opts=t,this.instanceKey=ai(this.opts.hostname)+"",this.localStore=wa,this.sessionStore=ja},Aa={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),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?ko({},o,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)}},Aa.lset.set=function(t){return this.__setMethod("localStore",t)},Aa.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")},Aa.sset.set=function(t){return this.__setMethod("sessionStore",t)},Aa.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,Aa);var Ta=h[0],xa=h[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];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;Reflect.apply(console[r[n]],console,t.splice(0,n))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=ki)}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(Lo(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new zt("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&&Lo(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(!ii(t))throw new zt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ii(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=ko({},{_cb:Ei()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=ko({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=ko({},{method:Ta,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 ka(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=Ho(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ka(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Rt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?ko({},a,this.getAuthHeader(),this.extraHeader):ko({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=ko({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(It).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Rt("getRemoteContract",e)}))},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),Kt(t)&&k(e)){var n=Oa(e);return!0===r?n:Sa(t,n)}throw new zt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(It)},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(Kt(t))return Sa(t,o);throw new zt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:xa}).then(It)},Object.defineProperties(e.prototype,r),e}(Ea)))),qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ca={hostname:Ko(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Ko("jsonql",["string"]),loginHandlerName:Ko("login",["string"]),logoutHandlerName:Ko("logout",["string"]),enableJsonp:Ko(!1,["boolean"]),enableAuth:Ko(!1,["boolean"]),useJwt:Ko(!0,["boolean"]),persistToken:Ko(!1,["boolean","number"]),useLocalstorage:Ko(!0,["boolean"]),storageKey:Ko("jsonqlstore",["string"]),authKey:Ko("jsonqlauthkey",["string"]),contractExpired:Ko(0,["number"]),keepContract:Ko(!0,["boolean"]),exposeContract:Ko(!1,["boolean"]),exposeStore:Ko(!1,["boolean"]),showContractDesc:Ko(!1,["boolean"]),contractKey:Ko(!1,["boolean"]),contractKeyName:Ko("X-JSONQL-CV-KEY",["string"]),enableTimeout:Ko(!1,["boolean"]),timeout:Ko(5e3,["number"]),returnInstance:Ko(!1,["boolean"]),allowReturnRawToken:Ko(!1,["boolean"]),debugOn:Ko(!1,["boolean"])};function $a(t){return Wo(t,_)?t:function(t){return Go(t,Ca,qa)}(t)}var za=new WeakMap,Na=new WeakMap,Ra=function(){this.__suspend__=null,this.queueStore=new Set},Ma={$suspend:{configurable:!0},$queues:{configurable:!0}};Ma.$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)},Ra.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__},Ma.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ra.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(Ra.prototype,Ma);var Fa=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){za.set(this,t)},r.normalStore.get=function(){return za.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 ai(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Ra));function Ja(t,e){void 0===e&&(e={});var r,n=e.contract,o=$a(e),i=new Pa(t,o),a=ui(i,n),u=(r=o.debugOn,new Fa({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=oi(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),Ja(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 04d47b5f7572baec007edc88f5ed0b936a8efcb4..eb8ed311ff3b3c075ef51119b87f5ff3cdb19e3a 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"],"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"],"names":[],"mappings":"ikiDAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.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"],"names":[],"mappings":"8mjDAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index a3a92b32ea8741dd1c06a5cc5cb41e89131cefec..53b86dac47df0202156fc5f0782766b2364deebf 100644 --- a/packages/http-client/dist/jsonql-client.umd.js +++ b/packages/http-client/dist/jsonql-client.umd.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="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)}})); +!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 F(t,e){return function(r){return t(e(r))}}var I=F(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=I(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}function V(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--&&nt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var mt=function(t){return S(t)?t:[t]},_t=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},wt=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),jt=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),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={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},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 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),kt=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),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 500},r.name.get=function(){return"JsonqlResolverAppError"},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={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),xt=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),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"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Pt=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),qt=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),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},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),$t=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),zt=Object.freeze({__proto__:null,Jsonql406Error:wt,Jsonql500Error:jt,JsonqlForbiddenError:St,JsonqlAuthorisationError:Ot,JsonqlContractAuthError:kt,JsonqlResolverAppError:Et,JsonqlResolverNotFoundError:At,JsonqlEnumError:xt,JsonqlTypeError:Tt,JsonqlCheckerError:Pt,JsonqlValidationError:qt,JsonqlError:Ct,JsonqlServerError:$t}),Nt=Ct,Rt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Mt(t){if(Rt(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&&zt[o])throw new zt[r](i,a);throw new Nt(i,a)}return t}function Ft(t){if(Array.isArray(t))throw new qt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof $t:throw new $t(e,r);default:throw new Ct(e,r)}}function It(t){return!!function(t){return G(t)&&(_t(t,u)||_t(t,c)||_t(t,s))}(t)&&t}function Jt(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var Dt=function(t,e){return void 0===e&&(e={}),It(e)?Promise.resolve(e):t.getContract()},Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ht(t){this.message=t}Ht.prototype=new Error,Ht.prototype.name="InvalidCharacterError";var Lt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Ht("'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=Ut.indexOf(n);return a};var Bt=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(Lt(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 Lt(e)}};function Kt(t){this.message=t}Kt.prototype=new Error,Kt.prototype.name="InvalidTokenError";var Gt=function(t,e){if("string"!=typeof t)throw new Kt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Bt(t.split(".")[r]))}catch(t){throw new Kt("Invalid token specified: "+t.message)}},Vt=Kt;Gt.InvalidTokenError=Vt;var Wt="[object String]";function Yt(t){return"string"==typeof t||!S(t)&&J(t)&&M(t)==Wt}var Qt=function(t){return""!==bt(t)&&Yt(t)},Xt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zt(t){if(Qt(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 Ct("Token has expired on "+r,t)}return t}(Gt(t));throw new Ct("Token must be a string!")}var te=function(t){return!!S(t)||null!=t&&""!==bt(t)},ee="[object Number]";function re(t){return function(t){return"number"==typeof t||J(t)&&M(t)==ee}(t)&&t!=+t}var ne=function(t){return!Yt(t)&&!re(parseFloat(t))},oe=function(t){return null!=t&&"boolean"==typeof t},ie=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==bt(t)&&(!1===e||!0===e&&null!==t)},ae=d,ue=v,ce=g,se=y,fe=b,le=m,pe="continue",he=function(t){switch(t){case"number":return ne;case"string":return Qt;case"boolean":return oe;default:return ie}},de=function(t,e){return void 0===e&&(e=""),!!S(t)&&(""===e||""===bt(e)||!(t.filter((function(t){return!he(e)(t)})).length>0))},ve=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ge=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!he(e)(t)})).length)})).length:e.length>e.filter((function(t){return!de(r,t)})).length};var ye,be=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ye?a:++n];if(!1===e(o[u],u,o))break}return t};var me="[object Arguments]";function _e(t){return J(t)&&M(t)==me}var we=Object.prototype,je=we.hasOwnProperty,Se=we.propertyIsEnumerable,Oe=_e(function(){return arguments}())?_e:function(t){return J(t)&&je.call(t,"callee")&&!Se.call(t,"callee")};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=Ee&&Ee.exports===ke?A.Buffer:void 0,xe=(Ae?Ae.isBuffer:void 0)||function(){return!1},Te=9007199254740991,Pe=/^(?:0|[1-9]\d*)$/;function qe(t,e){var r=typeof t;return!!(e=null==e?Te:e)&&("number"==r||"symbol"!=r&&Pe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}var ze={};ze["[object Float32Array]"]=ze["[object Float64Array]"]=ze["[object Int8Array]"]=ze["[object Int16Array]"]=ze["[object Int32Array]"]=ze["[object Uint8Array]"]=ze["[object Uint8ClampedArray]"]=ze["[object Uint16Array]"]=ze["[object Uint32Array]"]=!0,ze["[object Arguments]"]=ze["[object Array]"]=ze["[object ArrayBuffer]"]=ze["[object Boolean]"]=ze["[object DataView]"]=ze["[object Date]"]=ze["[object Error]"]=ze["[object Function]"]=ze["[object Map]"]=ze["[object Number]"]=ze["[object Object]"]=ze["[object RegExp]"]=ze["[object Set]"]=ze["[object String]"]=ze["[object WeakMap]"]=!1;var Ne,Re="object"==typeof exports&&exports&&!exports.nodeType&&exports,Me=Re&&"object"==typeof module&&module&&!module.nodeType&&module,Fe=Me&&Me.exports===Re&&k.process,Ie=function(){try{var t=Me&&Me.require&&Me.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Je=Ie&&Ie.isTypedArray,De=Je?(Ne=Je,function(t){return Ne(t)}):function(t){return J(t)&&$e(t.length)&&!!ze[M(t)]},Ue=Object.prototype.hasOwnProperty;function He(t,e){var r=S(t),n=!r&&Oe(t),o=!r&&!n&&xe(t),i=!r&&!n&&!o&&De(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ar.prototype.set=function(t,e){var r=this.__data__,n=or(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ur,cr=A["__core-js_shared__"],sr=(ur=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||""))?"Symbol(src)_1."+ur:"";var fr=Function.prototype.toString;function lr(t){if(null!=t){try{return fr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var pr=/^\[object .+?Constructor\]$/,hr=Function.prototype,dr=Object.prototype,vr=hr.toString,gr=dr.hasOwnProperty,yr=RegExp("^"+vr.call(gr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function br(t){return!(!Ve(t)||function(t){return!!sr&&sr in t}(t))&&(Ze(t)?yr:pr).test(lr(t))}function mr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return br(r)?r:void 0}var _r=mr(A,"Map"),wr=mr(Object,"create");var jr="__lodash_hash_undefined__",Sr=Object.prototype.hasOwnProperty;var Or=Object.prototype.hasOwnProperty;var kr="__lodash_hash_undefined__";function Er(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&Nr?new Cr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ve(t))?!ge({arg:r},e):!he(t)(r))})).length)})).length}return!1},ro=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(eo,null,a);case"array"===t:return!de(e.arg);case!1!==(r=ve(t)):return!ge(e,r);default:return!he(t)(e.arg)}},no=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!de(e))throw new Ct("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!de(t))throw new Ct("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?no(t,a):t,index:r,param:a,optional:i}}));default:throw new Ct("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!!te(e)&&!(r.type.length>r.type.filter((function(e){return ro(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return ro(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},io=function(){try{var t=mr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function ao(t,e,r){"__proto__"==e&&io?io(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function uo(t,e,r){(void 0===r||nr(t[e],r))&&(void 0!==r||e in t)||ao(t,e,r)}var co="object"==typeof exports&&exports&&!exports.nodeType&&exports,so=co&&"object"==typeof module&&module&&!module.nodeType&&module,fo=so&&so.exports===co?A.Buffer:void 0,lo=fo?fo.allocUnsafe:void 0;function po(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 ho=Object.create,vo=function(){function t(){}return function(e){if(!Ve(e))return{};if(ho)return ho(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function go(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var yo=Object.prototype.hasOwnProperty;function bo(t,e,r){var n=t[e];yo.call(t,e)&&nr(n,r)&&(void 0!==r||e in t)||ao(t,e,r)}var mo=Object.prototype.hasOwnProperty;function _o(t){if(!Ve(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Be(t),r=[];for(var n in t)("constructor"!=n||!e&&mo.call(t,n))&&r.push(n);return r}function wo(t){return tr(t)?He(t,!0):_o(t)}function jo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=xo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Ao);function Co(t,e){return qo(function(t,e,r){return e=Eo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Eo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=$o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Ve(r))return!1;var n=typeof e;return!!("number"==n?tr(r)&&qe(e,r.length):"string"==n&&e in r)&&nr(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ri().key(e);t(Mi(r),r)}},remove:function(t){return Ri().removeItem(t)},clearAll:function(){return Ri().clear()}};function Ri(){return zi.localStorage}function Mi(t){return Ri().getItem(t)}var Fi=bi.trim,Ii={name:"cookieStorage",read:function(t){if(!t||!Hi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ji.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ji.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Di,remove:Ui,clearAll:function(){Di((function(t,e){Ui(e)}))}},Ji=bi.Global.document;function Di(t){for(var e=Ji.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Fi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ui(t){t&&Hi(t)&&(Ji.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Hi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ji.cookie)}var Li=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 Bi=bi.bind,Ki=bi.each,Gi=bi.create,Vi=bi.slice,Wi=function(){var t=Gi(Yi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Bi(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Bi(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(),Ki(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Yi={_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,Bi(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Vi(arguments,1);Ki(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Qi=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)})),Xi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Qi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Qi.compress(this._serialize(r));t(e,n)}}};var Zi=[Ni,Ii],ta=[Li,Wi,Xi],ea=qi.createStore(Zi,ta),ra=bi.Global;function na(){return ra.sessionStorage}function oa(t){return na().getItem(t)}var ia=[{name:"sessionStorage",read:oa,write:function(t,e){return na().setItem(t,e)},each:function(t){for(var e=na().length-1;e>=0;e--){var r=na().key(e);t(oa(r),r)}},remove:function(t){return na().removeItem(t)},clearAll:function(){return na().clear()}},Ii],aa=[Li,Xi],ua=qi.createStore(ia,aa),ca=ea,sa=ua,fa=function(t){var e;return(e={}).args=t,e};function la(t,e){var r;return(r={})[t]=e,r[p]=[hi()],r}var pa=function(t){return _t(t,"data")&&!_t(t,"error")?t.data:t},ha=function(t){this.opts=t,this.instanceKey=Jt(this.opts.hostname)+"",this.localStore=ca,this.sessionStore=sa},da={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ha.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?zo({},o,e):e,r))},ha.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ha.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)}},ha.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)}},da.lset.set=function(t){return this.__setMethod("localStore",t)},da.lget.get=function(){return this.__getMethod("localStore")},ha.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ha.prototype.lclear=function(){return this.__clearMethod("localStore")},da.sset.set=function(t){return this.__setMethod("sessionStore",t)},da.sget.get=function(){return this.__getMethod("sessionStore")},ha.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ha.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ha.prototype,da);var va=h[0],ga=h[1],ya=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];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;Reflect.apply(console[r[n]],console,t.splice(0,n))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Zt)}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(si(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new qt("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&&si(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(!It(t))throw new qt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=It(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=zo({},{_cb:hi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=zo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=zo({},{method:va,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 pa(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=ci(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):pa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new $t("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?zo({},a,this.getAuthHeader(),this.extraHeader):zo({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=zo({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(Mt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new $t("getRemoteContract",e)}))},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),Yt(t)&&S(e)){var n=fa(e);return!0===r?n:la(t,n)}throw new qt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Mt)},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(Yt(t))return la(t,o);throw new qt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ga}).then(Mt)},Object.defineProperties(e.prototype,r),e}(ha)))),ba=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,mt(t))}),Reflect.apply(t,null,r))}};function ma(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function _a(t,e,r,n){void 0===n&&(n=!1);var o=ma(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var wa=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 fi(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ft)}},ja=function(t,e,r,n,o){var i={},a=function(t){i=_a(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 fi(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]},Sa=function(t,e,r,n,o){var i={},a=function(t){i=_a(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return fi(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]},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=wa(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=wa(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 ka=function(t,e,r,n){var o=function(t,e,r,n){return ba(ja,Sa,Oa)({},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.2",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},Ea={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Aa={hostname:li(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:li("jsonql",["string"]),loginHandlerName:li("login",["string"]),logoutHandlerName:li("logout",["string"]),enableJsonp:li(!1,["boolean"]),enableAuth:li(!1,["boolean"]),useJwt:li(!0,["boolean"]),persistToken:li(!1,["boolean","number"]),useLocalstorage:li(!0,["boolean"]),storageKey:li("jsonqlstore",["string"]),authKey:li("jsonqlauthkey",["string"]),contractExpired:li(0,["number"]),keepContract:li(!0,["boolean"]),exposeContract:li(!1,["boolean"]),exposeStore:li(!1,["boolean"]),showContractDesc:li(!1,["boolean"]),contractKey:li(!1,["boolean"]),contractKeyName:li("X-JSONQL-CV-KEY",["string"]),enableTimeout:li(!1,["boolean"]),timeout:li(5e3,["number"]),returnInstance:li(!1,["boolean"]),allowReturnRawToken:li(!1,["boolean"]),debugOn:li(!1,["boolean"])};function xa(t){return ma(t,_)?Promise.resolve(t):function(t){var e=t.contract;return pi(t,Aa,Ea).then((function(t){return t.contract=e,t}))}(t)}var Ta=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){Ta.set(this,t)},r.normalStore.get=function(){return Ta.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 Jt(t.toString())+""},Object.defineProperties(e.prototype,r),e}(qa));function za(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),xa(e).then((function(t){return{baseClient:new ya(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Dt(r,n.contract).then((function(e){return ka(r,n,e,t)}))}))}((r=e.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})),e,t)}return function(t){return void 0===t&&(t={}),za(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 020e341adac1bdfe009f6c20370da6d4792d467e..6f743419b15c31bd172b812e4ba310df33122af0 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"],"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"],"names":[],"mappings":"457CAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.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"],"names":[],"mappings":"y88CAAA"} \ No newline at end of file diff --git a/packages/http-client/package.json b/packages/http-client/package.json index ba268f61f98a6be91d77184516e249b56802a6c4..a18ab2b8818271ace5e70975814571484c1232a6 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.5.1", + "version": "1.5.2", "description": "jsonql http browser client using Fly.js", "main": "core.js", "module": "index.js", @@ -65,10 +65,10 @@ "dependencies": { "flyio": "^0.6.14", "jsonql-constants": "^1.8.13", - "jsonql-errors": "^1.1.8", + "jsonql-errors": "^1.1.10", "jsonql-jwt": "^1.3.6", "jsonql-params-validator": "^1.5.0", - "jsonql-utils": "^0.9.0", + "jsonql-utils": "^0.9.2", "lodash-es": "^4.17.15", "nb-event-service": "^1.8.5", "store": "^2.0.12" @@ -79,7 +79,7 @@ "debug": "^4.1.1", "esm": "^3.2.25", "glob": "^7.1.6", - "jsonql-koa": "^1.4.22", + "jsonql-koa": "^1.5.0", "koa-favicon": "^2.0.1", "nyc": "^14.1.1", "promise-polyfill": "8.1.3", diff --git a/packages/http-client/src/base/base-cls.js b/packages/http-client/src/base/base-cls.js index e9f975a9033bdc45c84e41515d8c04457ecf45ef..798cc4d42c07ad661adc91a80cb2f8de6a554ba3 100644 --- a/packages/http-client/src/base/base-cls.js +++ b/packages/http-client/src/base/base-cls.js @@ -4,7 +4,7 @@ import { CREDENTIAL_STORAGE_KEY } from 'jsonql-constants' // import { JsonqlValidationError } from 'jsonql-errors' // import { timestamp } from 'jsonql-utils/src/timestamp' // import { inArray } from 'jsonql-utils/src/generic' -import { USERDATA_TABLE } from '../utils' +import { USERDATA_TABLE, LOG_ERROR_SWITCH } from '../utils' import AuthCls from './auth-cls' // This class will only focus on the storage system @@ -30,7 +30,9 @@ export default class JsonqlBaseClient extends AuthCls { */ log(...args) { if (this.opts.debugOn === true) { - Reflect.apply(console.info, console, args) + const fns = ['info', 'error'] + const idx = (args[0] === LOG_ERROR_SWITCH) ? 1 : 0 + Reflect.apply(console[fns[idx]], console, args.splice(0, idx)) } } diff --git a/packages/http-client/src/base/contract-cls.js b/packages/http-client/src/base/contract-cls.js index 470b283053ba7886c6ffdba1914d70970815820d..70595062598870f0593e4e6c8bfcbba7f922bf0f 100644 --- a/packages/http-client/src/base/contract-cls.js +++ b/packages/http-client/src/base/contract-cls.js @@ -46,19 +46,7 @@ export default class ContractClass extends HttpClass { // first need to check if the contract is a contract if (!isContract(contract)) { throw new JsonqlValidationError(`Contract is malformed!`) - //return false; } - /* @TODO need to rethink how to expired the contract - let args = [contract] - if (this.opts.contractExpired) { - let expired = parseFloat(this.opts.contractExpired) - if (!isNaN(expired) && expired > 0) { - args.push(expired) - } - } - // calling the setter - this.jsonqlContract = args; - */ this.lset = {[CLS_CONTRACT_NAME]: contract} // return it this.log('storeContract return result', contract) diff --git a/packages/http-client/src/base/http-cls.js b/packages/http-client/src/base/http-cls.js index ac56e1e3ed49df0dd33ca961613dd176a02ada4d..a9d4f73f35360cfecea73df3c103e9868ba3091f 100644 --- a/packages/http-client/src/base/http-cls.js +++ b/packages/http-client/src/base/http-cls.js @@ -11,6 +11,7 @@ import { isObject, isString } from 'jsonql-params-validator' import { JsonqlValidationError, JsonqlServerError, + JsonqlError, clientErrorsHandler } from 'jsonql-errors' import { @@ -19,6 +20,7 @@ import { JSONP_CALLBACK_NAME, SHOW_CONTRACT_DESC_PARAM } from 'jsonql-constants' +import { LOG_ERROR_SWITCH } from '../utils' // extract the one we need const [ POST, PUT ] = API_REQUEST_METHODS @@ -122,7 +124,7 @@ export default class HttpClass extends StoreClass { // this get call when it's not 200 err => { self.cleanUp() - console.error(err) + this.log(LOG_ERROR_SWITCH, err) throw new JsonqlServerError('Server side error', err) } ) @@ -169,7 +171,7 @@ export default class HttpClass extends StoreClass { return result }) .catch(err => { - console.error('getRemoteContract err', err) + this.log(LOG_ERROR_SWITCH, 'getRemoteContract err', err) throw new JsonqlServerError('getRemoteContract', err) }) } diff --git a/packages/http-client/src/utils.js b/packages/http-client/src/utils.js index 1cf4d2947a298511fbace27ff7ffb2f55f2aaae4..34fd9091d7b64de9a381bb823bd660d9b3879c3d 100644 --- a/packages/http-client/src/utils.js +++ b/packages/http-client/src/utils.js @@ -29,6 +29,7 @@ const CLS_LOCAL_STORE_NAME = 'localStore' const CLS_SESS_STORE_NAME = 'sessionStore' const CLS_CONTRACT_NAME = 'contract' const CLS_PROFILE_IDX = 'prof_idx' +const LOG_ERROR_SWITCH = '__error__' const ZERO_IDX = 0 // export export { @@ -40,5 +41,6 @@ export { CLS_SESS_STORE_NAME, CLS_CONTRACT_NAME, CLS_PROFILE_IDX, + LOG_ERROR_SWITCH, ZERO_IDX } diff --git a/packages/http-client/static.js b/packages/http-client/static.js index 3a6f3e04756eae5f5fe31d9c10d0310afc96a5ec..1a55e1c2c44127541f939be0aadb7727c9f7a814 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")(),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}})); +!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,E=Object.prototype,A=E.hasOwnProperty,T=E.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=A.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 F="[object Object]",I=Function.prototype,J=Object.prototype,U=I.toString,H=J.hasOwnProperty,L=U.call(Object);function D(t){if(!R(t)||z(t)!=F)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}function K(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--&&tt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var gt=function(t){return m(t)?t:[t]},yt=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},bt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},_t=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),mt=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),wt=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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),jt=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),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={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),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 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),kt=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),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"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),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"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),xt=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),Pt=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),qt=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:_t,Jsonql500Error:mt,JsonqlForbiddenError:wt,JsonqlAuthorisationError:jt,JsonqlContractAuthError:St,JsonqlResolverAppError:Ot,JsonqlResolverNotFoundError:kt,JsonqlEnumError:Et,JsonqlTypeError:At,JsonqlCheckerError:Tt,JsonqlValidationError:xt,JsonqlError:Pt,JsonqlServerError:qt}),$t=Pt,zt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Nt(t){if(zt(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&&Ct[o])throw new Ct[r](i,a);throw new $t(i,a)}return t}function Mt(t){if(Array.isArray(t))throw new xt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof qt:throw new qt(e,r);default:throw new Pt(e,r)}}var Rt=function(t){return!!m(t)||null!=t&&""!==vt(t)},Ft="[object Number]";function It(t){return function(t){return"number"==typeof t||R(t)&&z(t)==Ft}(t)&&t!=+t}var Jt="[object String]";function Ut(t){return"string"==typeof t||!m(t)&&R(t)&&z(t)==Jt}var Ht=function(t){return!Ut(t)&&!It(parseFloat(t))},Lt=function(t){return""!==vt(t)&&Ut(t)},Dt=function(t){return null!=t&&"boolean"==typeof t},Kt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==vt(t)&&(!1===e||!0===e&&null!==t)},Bt=s,Vt=f,Gt=l,Wt=p,Yt=h,Qt=d,Xt="continue",Zt=function(t){switch(t){case"number":return Ht;case"string":return Lt;case"boolean":return Dt;default:return Kt}},te=function(t,e){return void 0===e&&(e=""),!!m(t)&&(""===e||""===vt(e)||!(t.filter((function(t){return!Zt(e)(t)})).length>0))},ee=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},re=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Zt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!te(r,t)})).length};var ne,oe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ne?a:++n];if(!1===e(o[u],u,o))break}return t};var ie="[object Arguments]";function ae(t){return R(t)&&z(t)==ie}var ue=Object.prototype,ce=ue.hasOwnProperty,se=ue.propertyIsEnumerable,fe=ae(function(){return arguments}())?ae:function(t){return R(t)&&ce.call(t,"callee")&&!se.call(t,"callee")};var le="object"==typeof exports&&exports&&!exports.nodeType&&exports,pe=le&&"object"==typeof module&&module&&!module.nodeType&&module,he=pe&&pe.exports===le?O.Buffer:void 0,de=(he?he.isBuffer:void 0)||function(){return!1},ve=9007199254740991,ge=/^(?:0|[1-9]\d*)$/;function ye(t,e){var r=typeof t;return!!(e=null==e?ve:e)&&("number"==r||"symbol"!=r&&ge.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=be}var me={};me["[object Float32Array]"]=me["[object Float64Array]"]=me["[object Int8Array]"]=me["[object Int16Array]"]=me["[object Int32Array]"]=me["[object Uint8Array]"]=me["[object Uint8ClampedArray]"]=me["[object Uint16Array]"]=me["[object Uint32Array]"]=!0,me["[object Arguments]"]=me["[object Array]"]=me["[object ArrayBuffer]"]=me["[object Boolean]"]=me["[object DataView]"]=me["[object Date]"]=me["[object Error]"]=me["[object Function]"]=me["[object Map]"]=me["[object Number]"]=me["[object Object]"]=me["[object RegExp]"]=me["[object Set]"]=me["[object String]"]=me["[object WeakMap]"]=!1;var we,je="object"==typeof exports&&exports&&!exports.nodeType&&exports,Se=je&&"object"==typeof module&&module&&!module.nodeType&&module,Oe=Se&&Se.exports===je&&j.process,ke=function(){try{var t=Se&&Se.require&&Se.require("util").types;return t||Oe&&Oe.binding&&Oe.binding("util")}catch(t){}}(),Ee=ke&&ke.isTypedArray,Ae=Ee?(we=Ee,function(t){return we(t)}):function(t){return R(t)&&_e(t.length)&&!!me[z(t)]},Te=Object.prototype.hasOwnProperty;function xe(t,e){var r=m(t),n=!r&&fe(t),o=!r&&!n&&de(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},Be.prototype.set=function(t,e){var r=this.__data__,n=De(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ve,Ge=O["__core-js_shared__"],We=(Ve=/[^.]+$/.exec(Ge&&Ge.keys&&Ge.keys.IE_PROTO||""))?"Symbol(src)_1."+Ve:"";var Ye=Function.prototype.toString;function Qe(t){if(null!=t){try{return Ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Xe=/^\[object .+?Constructor\]$/,Ze=Function.prototype,tr=Object.prototype,er=Ze.toString,rr=tr.hasOwnProperty,nr=RegExp("^"+er.call(rr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function or(t){return!(!ze(t)||function(t){return!!We&&We in t}(t))&&(Ie(t)?nr:Xe).test(Qe(t))}function ir(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return or(r)?r:void 0}var ar=ir(O,"Map"),ur=ir(Object,"create");var cr="__lodash_hash_undefined__",sr=Object.prototype.hasOwnProperty;var fr=Object.prototype.hasOwnProperty;var lr="__lodash_hash_undefined__";function pr(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&wr?new br:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ee(t))?!re({arg:r},e):!Zt(t)(r))})).length)})).length}return!1},Hn=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(Un,null,a);case"array"===t:return!te(e.arg);case!1!==(r=ee(t)):return!re(e,r);default:return!Zt(t)(e.arg)}},Ln=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Dn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!te(e))throw new Pt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!te(t))throw new Pt("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?Ln(t,a):t,index:r,param:a,optional:i}}));default:throw new Pt("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!!Rt(e)&&!(r.type.length>r.type.filter((function(e){return Hn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Hn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Kn=function(){try{var t=ir(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Bn(t,e,r){"__proto__"==e&&Kn?Kn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Vn(t,e,r){(void 0===r||Le(t[e],r))&&(void 0!==r||e in t)||Bn(t,e,r)}var Gn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wn=Gn&&"object"==typeof module&&module&&!module.nodeType&&module,Yn=Wn&&Wn.exports===Gn?O.Buffer:void 0,Qn=Yn?Yn.allocUnsafe:void 0;function Xn(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Sr(n).set(new Sr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Zn=Object.create,to=function(){function t(){}return function(e){if(!ze(e))return{};if(Zn)return Zn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function eo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ro=Object.prototype.hasOwnProperty;function no(t,e,r){var n=t[e];ro.call(t,e)&&Le(n,r)&&(void 0!==r||e in t)||Bn(t,e,r)}var oo=Object.prototype.hasOwnProperty;function io(t){if(!ze(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&&oo.call(t,n))&&r.push(n);return r}function ao(t){return Je(t)?xe(t,!0):io(t)}function uo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=ho)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(po);function bo(t,e){return yo(function(t,e,r){return e=lo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=lo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=_o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ze(r))return!1;var n=typeof e;return!!("number"==n?Je(r)&&ye(e,r.length):"string"==n&&e in r)&&Le(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,gt(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 Ko(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 Bo=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 Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Mt)}},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Ko(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 Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Go=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wo=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=Bo(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=Bo(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 Yo=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(bt(e,r,b),o),t.$only(bt(e,r,_),i),t.$trigger(e,{resolverName:r,args:n})}))}},Qo=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 Xo(t,e,r,n){var o=function(t,e,r,n){return Lo(Vo,Go,Wo)({},t,e,r,n)}(t,e,r,n);Qo(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(bt(t,n,b),r)})).catch((function(r){e.$trigger(bt(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 Zo=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Xo(t,n,e,r)}));var o={query:Yo(n,"query"),mutation:Yo(n,"mutation"),auth:Yo(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.2",o};function ti(t){return!!function(t){return D(t)&&(yt(t,r)||yt(t,n)||yt(t,o))}(t)&&t}function ei(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}var ri=function(t,e){return void 0===e&&(e={}),ti(e)?Promise.resolve(e):t.getContract()},ni="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function oi(t){this.message=t}oi.prototype=new Error,oi.prototype.name="InvalidCharacterError";var ii="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new oi("'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=ni.indexOf(n);return a};var ai=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(ii(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 ii(e)}};function ui(t){this.message=t}ui.prototype=new Error,ui.prototype.name="InvalidTokenError";var ci=function(t,e){if("string"!=typeof t)throw new ui("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ai(t.split(".")[r]))}catch(t){throw new ui("Invalid token specified: "+t.message)}},si=ui;ci.InvalidTokenError=si;var fi,li,pi,hi,di,vi,gi,yi,bi,_i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function mi(t){if(Lt(t))return function(t){var e=t.iat||_i(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Pt("Token has expired on "+r,t)}return t}(ci(t));throw new Pt("Token must be a string!")}Uo("HS256",["string"]),Uo(!1,["boolean","number","string"],((fi={})[d]="exp",fi[f]=!0,fi)),Uo(!1,["boolean","number","string"],((li={})[d]="nbf",li[f]=!0,li)),Uo(!1,["boolean","string"],((pi={})[d]="iss",pi[f]=!0,pi)),Uo(!1,["boolean","string"],((hi={})[d]="sub",hi[f]=!0,hi)),Uo(!1,["boolean","string"],((di={})[d]="iss",di[f]=!0,di)),Uo(!1,["boolean"],((vi={})[f]=!0,vi)),Uo(!1,["boolean","string"],((gi={})[f]=!0,gi)),Uo(!1,["boolean","string"],((yi={})[f]=!0,yi)),Uo(!1,["boolean"],((bi={})[f]=!0,bi));var wi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ji="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Si=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Ki().key(e);t(Bi(r),r)}},remove:function(t){return Ki().removeItem(t)},clearAll:function(){return Ki().clear()}};function Ki(){return Li.localStorage}function Bi(t){return Ki().getItem(t)}var Vi=Ai.trim,Gi={name:"cookieStorage",read:function(t){if(!t||!Xi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Wi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Wi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Yi,remove:Qi,clearAll:function(){Yi((function(t,e){Qi(e)}))}},Wi=Ai.Global.document;function Yi(t){for(var e=Wi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Vi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Qi(t){t&&Xi(t)&&(Wi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Xi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Wi.cookie)}var Zi=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 ta=Ai.bind,ea=Ai.each,ra=Ai.create,na=Ai.slice,oa=function(){var t=ra(ia,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,ta(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,ta(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(),ea(r,(function(e,r){t.fire(r,void 0,e)}))}}};var ia={_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,ta(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=na(arguments,1);ea(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},aa=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)})),ua=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)}}};var ca=[Di,Gi],sa=[Zi,oa,ua],fa=Ji.createStore(ca,sa),la=Ai.Global;function pa(){return la.sessionStorage}function ha(t){return pa().getItem(t)}var da=[{name:"sessionStorage",read:ha,write:function(t,e){return pa().setItem(t,e)},each:function(t){for(var e=pa().length-1;e>=0;e--){var r=pa().key(e);t(ha(r),r)}},remove:function(t){return pa().removeItem(t)},clearAll:function(){return pa().clear()}},Gi],va=[Zi,ua],ga=Ji.createStore(da,va),ya=fa,ba=ga,_a=function(t){var e;return(e={}).args=t,e};function ma(t,e){var r;return(r={})[t]=e,r[u]=[wi()],r}var wa=function(t){return yt(t,"data")&&!yt(t,"error")?t.data:t},ja=function(t){this.opts=t,this.instanceKey=ei(this.opts.hostname)+"",this.localStore=ya,this.sessionStore=ba},Sa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ja.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?mo({},o,e):e,r))},ja.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ja.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)}},ja.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")},ja.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ja.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")},ja.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ja.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ja.prototype,Sa);var Oa=c[0],ka=c[1],Ea=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];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;Reflect.apply(console[r[n]],console,t.splice(0,n))}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=mi)}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 xt("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(!ti(t))throw new xt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ti(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=mo({},{_cb:wi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=mo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=mo({},{method:Oa,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 wa(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=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new qt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?mo({},e,this.getAuthHeader(),this.extraHeader):mo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=mo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Nt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new qt("getRemoteContract",e)}))},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),Ut(t)&&m(e)){var n=_a(e);return!0===r?n:ma(t,n)}throw new xt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Nt)},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(Ut(t))return ma(t,o);throw new xt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ka}).then(Nt)},Object.defineProperties(r.prototype,n),r}(ja)))),Aa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ta={hostname:Uo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Uo("jsonql",["string"]),loginHandlerName:Uo("login",["string"]),logoutHandlerName:Uo("logout",["string"]),enableJsonp:Uo(!1,["boolean"]),enableAuth:Uo(!1,["boolean"]),useJwt:Uo(!0,["boolean"]),persistToken:Uo(!1,["boolean","number"]),useLocalstorage:Uo(!0,["boolean"]),storageKey:Uo("jsonqlstore",["string"]),authKey:Uo("jsonqlauthkey",["string"]),contractExpired:Uo(0,["number"]),keepContract:Uo(!0,["boolean"]),exposeContract:Uo(!1,["boolean"]),exposeStore:Uo(!1,["boolean"]),showContractDesc:Uo(!1,["boolean"]),contractKey:Uo(!1,["boolean"]),contractKeyName:Uo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Uo(!1,["boolean"]),timeout:Uo(5e3,["number"]),returnInstance:Uo(!1,["boolean"]),allowReturnRawToken:Uo(!1,["boolean"]),debugOn:Uo(!1,["boolean"])};function xa(t){return Do(t,v)?t:function(t){return Ho(t,Ta,Aa)}(t)}var Pa=new WeakMap,qa=new WeakMap,Ca=function(){this.__suspend__=null,this.queueStore=new Set},$a={$suspend:{configurable:!0},$queues:{configurable:!0}};$a.$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)},Ca.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__},$a.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ca.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(Ca.prototype,$a);var za=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){Pa.set(this,t)},r.normalStore.get=function(){return Pa.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 ei(t.toString())+""},Object.defineProperties(e.prototype,r),e}(Ca));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=xa(e),i=new Ea(t,o),a=ri(i,n),u=(r=o.debugOn,new za({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=Zo(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 11d1ecd836ca2df2ee7ab99d53ccddd753df7abd..d8541a2783e5c956f97eefb68120f1464fd12244 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"],"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"],"names":[],"mappings":"mg2CAAA"} \ No newline at end of file +{"version":3,"file":"static.js","sources":["node_modules/store/plugins/defaults.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"],"names":[],"mappings":"sj3CAAA"} \ No newline at end of file diff --git a/packages/http-client/tests/qunit/tests/base-test.js b/packages/http-client/tests/qunit/tests/base-test.js index 1ec6751adff3db0423a534f2f1053baa284183bd..8f298060427a83b7cc8804f884f373c68c1be25a 100644 --- a/packages/http-client/tests/qunit/tests/base-test.js +++ b/packages/http-client/tests/qunit/tests/base-test.js @@ -29,8 +29,9 @@ QUnit.test('jsonqlClient should able to connect to server', function(assert) { // call the mutation before login client.mutation.plus({a: '1', b: '1'}) .catch(err => { + console.error(`--- NOT LOGIN ERROR ---`, 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') + assert.equal(err.className, 'JsonqlForbiddenError', 'Not allow to call private method before login') done3() // test the login