diff --git a/packages/resolver/tests/fixtures/contract/es/contract.json b/packages/resolver/tests/fixtures/contract/es/contract.json index 37457228e9202379cadf75d9bd9fef47acaa85b9..faf8b647068f385c65a5b53a4f39317653a3c399 100644 --- a/packages/resolver/tests/fixtures/contract/es/contract.json +++ b/packages/resolver/tests/fixtures/contract/es/contract.json @@ -43,6 +43,6 @@ } }, "auth": {}, - "timestamp": 1583902632, + "timestamp": 1583902666, "sourceType": "module" } diff --git a/packages/validator/dist/jsonql-params-validator.cjs.js b/packages/validator/dist/jsonql-params-validator.cjs.js index 0a75578a670b322d25b9e8850779e8963668a403..b6300778ce862e38d8ebc77cc2763d1342ee715d 100644 --- a/packages/validator/dist/jsonql-params-validator.cjs.js +++ b/packages/validator/dist/jsonql-params-validator.cjs.js @@ -1,2 +1,2 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},freeGlobal="object"==typeof global$1&&global$1&&global$1.Object===Object&&global$1,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol=root.Symbol;function arrayMap(e,r){for(var t=-1,a=null==e?0:e.length,n=Array(a);++tn?0:n+r),(t=t>n?n:t)<0&&(t+=n),n=r>t?0:t-r>>>0,r>>>=0;for(var o=Array(n);++a=a?e:baseSlice(e,r,t)}function baseFindIndex(e,r,t,a){for(var n=e.length,o=t+(a?1:-1);a?o--:++o-1;);return t}function charsStartIndex(e,r){for(var t=-1,a=e.length;++t-1;);return t}function asciiToArray(e){return e.split("")}var rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboRange=rsComboMarksRange+reComboHalfMarksRange+rsComboSymbolsRange,rsVarRange="\\ufe0e\\ufe0f",rsZWJ="\\u200d",reHasUnicode=RegExp("["+rsZWJ+rsAstralRange+rsComboRange+rsVarRange+"]");function hasUnicode(e){return reHasUnicode.test(e)}var rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$1="\\u0300-\\u036f",reComboHalfMarksRange$1="\\ufe20-\\ufe2f",rsComboSymbolsRange$1="\\u20d0-\\u20ff",rsComboRange$1=rsComboMarksRange$1+reComboHalfMarksRange$1+rsComboSymbolsRange$1,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo="["+rsComboRange$1+"]",rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier="(?:"+rsCombo+"|"+rsFitz+")",rsNonAstral="[^"+rsAstralRange$1+"]",rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod=rsModifier+"?",rsOptVar="["+rsVarRange$1+"]?",rsOptJoin="(?:"+rsZWJ$1+"(?:"+[rsNonAstral,rsRegional,rsSurrPair].join("|")+")"+rsOptVar+reOptMod+")*",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsSymbol="(?:"+[rsNonAstral+rsCombo+"?",rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz+"(?="+rsFitz+")|"+rsSymbol+rsSeq,"g");function unicodeToArray(e){return e.match(reUnicode)||[]}function stringToArray(e){return hasUnicode(e)?unicodeToArray(e):asciiToArray(e)}function toString(e){return null==e?"":baseToString(e)}var reTrim=/^\s+|\s+$/g;function trim(e,r,t){if((e=toString(e))&&(t||void 0===r))return e.replace(reTrim,"");if(!e||!(r=baseToString(r)))return e;var a=stringToArray(e),n=stringToArray(r);return castSlice(a,charsStartIndex(a,n),charsEndIndex(a,n)+1).join("")}var isNotEmpty=function(e){return!!isArray(e)||null!=e&&""!==trim(e)},numberTag="[object Number]";function isNumber(e){return"number"==typeof e||isObjectLike(e)&&baseGetTag(e)==numberTag}function isNaN(e){return isNumber(e)&&e!=+e}var stringTag="[object String]";function isString(e){return"string"==typeof e||!isArray(e)&&isObjectLike(e)&&baseGetTag(e)==stringTag}var checkIsNumber=function(e){return!isString(e)&&!isNaN(parseFloat(e))},checkIsString=function(e){return""!==trim(e)&&isString(e)},checkIsBoolean=function(e){return null!=e&&"boolean"==typeof e},checkIsAny=function(e,r){return void 0===r&&(r=!0),void 0!==e&&""!==e&&""!==trim(e)&&(!1===r||!0===r&&null!==e)},DATA_KEY="data",ERROR_KEY="error",DEFAULT_TYPE="any",KEY_WORD="continue",TYPE_KEY="type",OPTIONAL_KEY="optional",ENUM_KEY="enumv",ARGS_KEY="args",CHECKER_KEY="checker",ALIAS_KEY="alias",OR_SEPERATOR="|",STRING_TYPE="string",BOOLEAN_TYPE="boolean",ARRAY_TYPE="array",OBJECT_TYPE="object",NUMBER_TYPE="number",ARRAY_TYPE_LFT="array.<",ARRAY_TYPE_RGT=">",NO_STATUS_CODE=-1,ARGS_NOT_ARRAY_ERR="args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)",PARAMS_NOT_ARRAY_ERR="params is not an array! Did something gone wrong when you generate the contract.json?",EXCEPTION_CASE_ERR="Could not understand your arguments and parameter structure!",DEFAULT_TYPE$1=DEFAULT_TYPE,ARRAY_TYPE_LFT$1=ARRAY_TYPE_LFT,ARRAY_TYPE_RGT$1=ARRAY_TYPE_RGT,TYPE_KEY$1=TYPE_KEY,OPTIONAL_KEY$1=OPTIONAL_KEY,ENUM_KEY$1=ENUM_KEY,ARGS_KEY$1=ARGS_KEY,CHECKER_KEY$1=CHECKER_KEY,ALIAS_KEY$1=ALIAS_KEY,ARRAY_TYPE$1=ARRAY_TYPE,OBJECT_TYPE$1=OBJECT_TYPE,STRING_TYPE$1=STRING_TYPE,BOOLEAN_TYPE$1=BOOLEAN_TYPE,NUMBER_TYPE$1=NUMBER_TYPE,KEY_WORD$1=KEY_WORD,OR_SEPERATOR$1=OR_SEPERATOR,combineFn=function(e){switch(e){case NUMBER_TYPE$1:return checkIsNumber;case STRING_TYPE$1:return checkIsString;case BOOLEAN_TYPE$1:return checkIsBoolean;default:return checkIsAny}},checkIsArray=function(e,r){return void 0===r&&(r=""),!!isArray(e)&&(""===r||""===trim(r)||!(e.filter((function(e){return!combineFn(r)(e)})).length>0))},isArrayLike=function(e){if(e.indexOf(ARRAY_TYPE_LFT$1)>-1&&e.indexOf(ARRAY_TYPE_RGT$1)>-1){var r=e.replace(ARRAY_TYPE_LFT$1,"").replace(ARRAY_TYPE_RGT$1,"");return r.indexOf(OR_SEPERATOR$1)?r.split(OR_SEPERATOR$1):[r]}return!1},arrayTypeHandler=function(e,r){var t=e.arg;return r.length>1?!t.filter((function(e){return!(r.length>r.filter((function(r){return!combineFn(r)(e)})).length)})).length:r.length>r.filter((function(e){return!checkIsArray(t,e)})).length};function overArg(e,r){return function(t){return e(r(t))}}var getPrototype=overArg(Object.getPrototypeOf,Object),objectTag="[object Object]",funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$1=objectProto$2.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=objectTag)return!1;var r=getPrototype(e);if(null===r)return!0;var t=hasOwnProperty$1.call(r,"constructor")&&r.constructor;return"function"==typeof t&&t instanceof t&&funcToString.call(t)==objectCtorString}function arrayFilter(e,r){for(var t=-1,a=null==e?0:e.length,n=0,o=[];++t-1&&e%1==0&&e-1&&e%1==0&&e<=MAX_SAFE_INTEGER$1}var argsTag$1="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag$1="[object Number]",objectTag$1="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag$1="[object String]",weakMapTag="[object WeakMap]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[baseGetTag(e)]}function baseUnary(e){return function(r){return e(r)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dataViewTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag$1]=typedArrayTags[objectTag$1]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag$1]=typedArrayTags[weakMapTag]=!1;var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,freeProcess=moduleExports$1&&freeGlobal.process,nodeUtil=function(){try{var e=freeModule$1&&freeModule$1.require&&freeModule$1.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty;function arrayLikeKeys(e,r){var t=isArray(e),a=!t&&isArguments(e),n=!t&&!a&&isBuffer(e),o=!t&&!a&&!n&&isTypedArray(e),i=t||a||n||o,s=i?baseTimes(e.length,String):[],c=s.length;for(var u in e)!r&&!hasOwnProperty$3.call(e,u)||i&&("length"==u||n&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||isIndex(u,c))||s.push(u);return s}var objectProto$5=Object.prototype;function isPrototype(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||objectProto$5)}var nativeKeys=overArg(Object.keys,Object),objectProto$6=Object.prototype,hasOwnProperty$4=objectProto$6.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys(e);var r=[];for(var t in Object(e))hasOwnProperty$4.call(e,t)&&"constructor"!=t&&r.push(t);return r}function isObject(e){var r=typeof e;return null!=e&&("object"==r||"function"==r)}var asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject(e))return!1;var r=baseGetTag(e);return r==funcTag$1||r==genTag||r==asyncTag||r==proxyTag}function isArrayLike$1(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function keys(e){return isArrayLike$1(e)?arrayLikeKeys(e):baseKeys(e)}function baseForOwn(e,r){return e&&baseFor(e,r,keys)}function listCacheClear(){this.__data__=[],this.size=0}function eq(e,r){return e===r||e!=e&&r!=r}function assocIndexOf(e,r){for(var t=e.length;t--;)if(eq(e[t][0],r))return t;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(e){var r=this.__data__,t=assocIndexOf(r,e);return!(t<0)&&(t==r.length-1?r.pop():splice.call(r,t,1),--this.size,!0)}function listCacheGet(e){var r=this.__data__,t=assocIndexOf(r,e);return t<0?void 0:r[t][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,r){var t=this.__data__,a=assocIndexOf(t,e);return a<0?(++this.size,t.push([e,r])):t[a][1]=r,this}function ListCache(e){var r=-1,t=null==e?0:e.length;for(this.clear();++rs))return!1;var u=o.get(e);if(u&&o.get(r))return u==r;var l=-1,f=!0,y=t&COMPARE_UNORDERED_FLAG?new SetCache:void 0;for(o.set(e,r),o.set(r,e);++lr.type.filter((function(e){var r;return void 0===t||(!1!==(r=isArrayLike(e))?!arrayTypeHandler({arg:t},r):!combineFn(e)(t))})).length)})).length}return!1},objectTypeHandler=function(e){var r=e.arg,t=e.param,a=[r];return Array.isArray(t.keys)&&t.keys.length&&a.push(t.keys),Reflect.apply(checkIsObject,null,a)},JsonqlEnumError=function(e){function r(){for(var t=[],a=arguments.length;a--;)t[a]=arguments[a];e.apply(this,t),this.message=t[0],this.detail=t[1],this.className=r.name,e.captureStackTrace&&e.captureStackTrace(this,r)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var t={name:{configurable:!0}};return t.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,t),r}(Error),JsonqlTypeError=function(e){function r(){for(var t=[],a=arguments.length;a--;)t[a]=arguments[a];e.apply(this,t),this.message=t[0],this.detail=t[1],this.className=r.name,e.captureStackTrace&&e.captureStackTrace(this,r)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var t={name:{configurable:!0}};return t.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,t),r}(Error),JsonqlCheckerError=function(e){function r(){for(var t=[],a=arguments.length;a--;)t[a]=arguments[a];e.apply(this,t),this.message=t[0],this.detail=t[1],this.className=r.name,e.captureStackTrace&&e.captureStackTrace(this,r)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var t={name:{configurable:!0}};return t.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,t),r}(Error),JsonqlError=function(e){function r(){for(var t=[],a=arguments.length;a--;)t[a]=arguments[a];e.apply(this,t),this.message=t[0],this.detail=t[1],this.className=r.name,e.captureStackTrace&&e.captureStackTrace(this,r)}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var t={name:{configurable:!0},statusCode:{configurable:!0}};return t.name.get=function(){return"JsonqlError"},t.statusCode.get=function(){return NO_STATUS_CODE},Object.defineProperties(r,t),r}(Error),optionalHandler=function(e){var r=e.arg,t=e.param;return!!isNotEmpty(r)&&!(t.type.length>t.type.filter((function(r){return validateHandler(r,e)})).length)},validateHandler=function(e,r){var t;switch(!0){case e===OBJECT_TYPE$1:return!objectTypeHandler(r);case e===ARRAY_TYPE$1:return!checkIsArray(r.arg);case!1!==(t=isArrayLike(e)):return!arrayTypeHandler(r,t);default:return!combineFn(e)(r.arg)}},getOptionalValue=function(e,r){return void 0!==e?e:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},normalizeArgs=function(e,r){if(!checkIsArray(r))throw new JsonqlError(PARAMS_NOT_ARRAY_ERR);if(0===r.length)return[];if(!checkIsArray(e))throw new JsonqlError(ARGS_NOT_ARRAY_ERR);switch(!0){case e.length==r.length:return e.map((function(e,t){return{arg:e,index:t,param:r[t]}}));case!0===r[0].variable:var t=r[0].type;return e.map((function(e,a){return{arg:e,index:a,param:r[a]||{type:t,name:"_"}}}));case e.lengthr.length:var a=r.length,n=[DEFAULT_TYPE$1];return e.map((function(e,t){var o=t>=a||!!r[t].optional,i=r[t]||{type:n,name:"_"+t};return{arg:o?getOptionalValue(e,i):e,index:t,param:i,optional:o}}));default:throw new JsonqlError(EXCEPTION_CASE_ERR,{args:e,params:r})}},processReturn=function(e){return e.map((function(e){return e.arg}))},validateSync=function(e,r,t){var a;void 0===t&&(t=!1);var n=normalizeArgs(e,r),o=n.filter((function(e){return!0===e.optional||!0===e.param.optional?optionalHandler(e):!(e.param.type.length>e.param.type.filter((function(r){return validateHandler(r,e)})).length)}));return t?((a={})[ERROR_KEY]=o,a[DATA_KEY]=processReturn(n),a):o},validateAsync=function(e,r,t){return void 0===t&&(t=!1),new Promise((function(a,n){var o=validateSync(e,r,t);return t?o[ERROR_KEY].length?n(o[ERROR_KEY]):a(o[DATA_KEY]):o.length?n(o):a([])}))},defineProperty=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();function baseAssignValue(e,r,t){"__proto__"==r&&defineProperty?defineProperty(e,r,{configurable:!0,enumerable:!0,value:t,writable:!0}):e[r]=t}function assignMergeValue(e,r,t){(void 0===t||eq(e[r],t))&&(void 0!==t||r in e)||baseAssignValue(e,r,t)}var freeExports$2="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,Buffer$1=moduleExports$2?root.Buffer:void 0,allocUnsafe=Buffer$1?Buffer$1.allocUnsafe:void 0;function cloneBuffer(e,r){if(r)return e.slice();var t=e.length,a=allocUnsafe?allocUnsafe(t):new e.constructor(t);return e.copy(a),a}function cloneArrayBuffer(e){var r=new e.constructor(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function cloneTypedArray(e,r){var t=r?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(t,e.byteOffset,e.length)}function copyArray(e,r){var t=-1,a=e.length;for(r||(r=Array(a));++t0){if(++r>=HOT_COUNT)return arguments[0]}else r=0;return e.apply(void 0,arguments)}}var setToString=shortOut(baseSetToString);function baseRest(e,r){return setToString(overRest(e,r,identity),e+"")}function isIterateeCall(e,r,t){if(!isObject(t))return!1;var a=typeof r;return!!("number"==a?isArrayLike$1(t)&&isIndex(r,t.length):"string"==a&&r in t)&&eq(t[r],e)}function createAssigner(e){return baseRest((function(r,t){var a=-1,n=t.length,o=n>1?t[n-1]:void 0,i=n>2?t[2]:void 0;for(o=e.length>3&&"function"==typeof o?(n--,o):void 0,i&&isIterateeCall(t[0],t[1],i)&&(o=n<3?void 0:o,n=1),r=Object(r);++a=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&m(r,t[e],0)>-1;);return e}(n,o)+1).join("")}var D=function(t){return!!i(t)||null!=t&&""!==$(t)};function R(t){return function(t){return"number"==typeof t||h(t)&&"[object Number]"==v(t)}(t)&&t!=+t}function B(t){return"string"==typeof t||!i(t)&&h(t)&&"[object String]"==v(t)}var V=function(t){return!B(t)&&!R(parseFloat(t))},I=function(t){return""!==$(t)&&B(t)},L=function(t){return null!=t&&"boolean"==typeof t},q=function(t,r){return void 0===r&&(r=!0),void 0!==t&&""!==t&&""!==$(t)&&(!1===r||!0===r&&null!==t)},U=function(t){switch(t){case"number":return V;case"string":return I;case"boolean":return L;default:return q}},J=function(t,r){return void 0===r&&(r=""),!!i(t)&&(""===r||""===$(r)||!(t.filter((function(t){return!U(r)(t)})).length>0))},W=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},G=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!U(r)(t)})).length)})).length:r.length>r.filter((function(t){return!J(e,t)})).length};function H(t,r){return function(e){return t(r(e))}}var K=H(Object.getPrototypeOf,Object),Q=Function.prototype,Y=Object.prototype,X=Q.toString,Z=Y.hasOwnProperty,tt=X.call(Object);function rt(t){if(!h(t)||"[object Object]"!=v(t))return!1;var r=K(t);if(null===r)return!0;var e=Z.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&X.call(e)==tt}var et,nt=function(t,r,e){for(var n=-1,o=Object(t),u=e(t),i=u.length;i--;){var a=u[et?i:++n];if(!1===r(o[a],a,o))break}return t};function ot(t){return h(t)&&"[object Arguments]"==v(t)}var ut=Object.prototype,it=ut.hasOwnProperty,at=ut.propertyIsEnumerable,ct=ot(function(){return arguments}())?ot:function(t){return h(t)&&it.call(t,"callee")&&!at.call(t,"callee")};var ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,st=ft&&"object"==typeof module&&module&&!module.nodeType&&module,lt=st&&st.exports===ft?n.Buffer:void 0,pt=(lt?lt.isBuffer:void 0)||function(){return!1},vt=/^(?:0|[1-9]\d*)$/;function ht(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&vt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var dt={};dt["[object Float32Array]"]=dt["[object Float64Array]"]=dt["[object Int8Array]"]=dt["[object Int16Array]"]=dt["[object Int32Array]"]=dt["[object Uint8Array]"]=dt["[object Uint8ClampedArray]"]=dt["[object Uint16Array]"]=dt["[object Uint32Array]"]=!0,dt["[object Arguments]"]=dt["[object Array]"]=dt["[object ArrayBuffer]"]=dt["[object Boolean]"]=dt["[object DataView]"]=dt["[object Date]"]=dt["[object Error]"]=dt["[object Function]"]=dt["[object Map]"]=dt["[object Number]"]=dt["[object Object]"]=dt["[object RegExp]"]=dt["[object Set]"]=dt["[object String]"]=dt["[object WeakMap]"]=!1;var bt,gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,_t=gt&&"object"==typeof module&&module&&!module.nodeType&&module,jt=_t&&_t.exports===gt&&r.process,mt=function(){try{var t=_t&&_t.require&&_t.require("util").types;return t||jt&&jt.binding&&jt.binding("util")}catch(t){}}(),Ot=mt&&mt.isTypedArray,wt=Ot?(bt=Ot,function(t){return bt(t)}):function(t){return h(t)&&yt(t.length)&&!!dt[v(t)]},At=Object.prototype.hasOwnProperty;function xt(t,r){var e=i(t),n=!e&&ct(t),o=!e&&!n&&pt(t),u=!e&&!n&&!o&&wt(t),a=e||n||o||u,c=a?function(t,r){for(var e=-1,n=Array(t);++e-1},Rt.prototype.set=function(t,r){var e=this.__data__,n=$t(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var Bt,Vt=n["__core-js_shared__"],It=(Bt=/[^.]+$/.exec(Vt&&Vt.keys&&Vt.keys.IE_PROTO||""))?"Symbol(src)_1."+Bt:"";var Lt=Function.prototype.toString;function qt(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Ut=/^\[object .+?Constructor\]$/,Jt=Function.prototype,Wt=Object.prototype,Gt=Jt.toString,Ht=Wt.hasOwnProperty,Kt=RegExp("^"+Gt.call(Ht).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qt(t){return!(!zt(t)||function(t){return!!It&&It in t}(t))&&(Tt(t)?Kt:Ut).test(qt(t))}function Yt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return Qt(e)?e:void 0}var Xt=Yt(n,"Map"),Zt=Yt(Object,"create");var tr=Object.prototype.hasOwnProperty;var rr=Object.prototype.hasOwnProperty;function er(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ra))return!1;var f=u.get(t);if(f&&u.get(r))return f==r;var s=-1,l=!0,p=2&e?new ir:void 0;for(u.set(t,r),u.set(r,t);++sr.type.filter((function(t){var r;return void 0===e||(!1!==(r=W(t))?!G({arg:e},r):!U(t)(e))})).length)})).length}return!1},ee=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(Error),ne=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(Error),oe=function(t,r){var e,n,o,u,i;switch(!0){case"object"===t:return o=(n=r).arg,u=n.param,i=[o],Array.isArray(u.keys)&&u.keys.length&&i.push(u.keys),!Reflect.apply(re,null,i);case"array"===t:return!J(r.arg);case!1!==(e=W(t)):return!G(r,e);default:return!U(t)(r.arg)}},ue=function(t,r){return void 0!==t?t:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},ie=function(t,r){if(!J(r))throw new ee("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===r.length)return[];if(!J(t))throw new ee("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==r.length:return t.map((function(t,e){return{arg:t,index:e,param:r[e]}}));case!0===r[0].variable:var e=r[0].type;return t.map((function(t,n){return{arg:t,index:n,param:r[n]||{type:e,name:"_"}}}));case t.lengthr.length:var n=r.length,o=["any"];return t.map((function(t,e){var u=e>=n||!!r[e].optional,i=r[e]||{type:o,name:"_"+e};return{arg:u?ue(t,i):t,index:e,param:i,optional:u}}));default:throw new ne("Could not understand your arguments and parameter structure!",{args:t,params:r})}},ae=function(t,r,e){var n;void 0===e&&(e=!1);var o=ie(t,r),u=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!D(r)&&!(e.type.length>e.type.filter((function(r){return oe(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return oe(r,t)})).length)}));return e?((n={}).error=u,n.data=o.map((function(t){return t.arg})),n):u},ce=function(){try{var t=Yt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function fe(t,r,e){"__proto__"==r&&ce?ce(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function se(t,r,e){(void 0===e||Mt(t[r],e))&&(void 0!==e||r in t)||fe(t,r,e)}var le="object"==typeof exports&&exports&&!exports.nodeType&&exports,pe=le&&"object"==typeof module&&module&&!module.nodeType&&module,ve=pe&&pe.exports===le?n.Buffer:void 0,he=ve?ve.allocUnsafe:void 0;function ye(t,r){var e,n,o=r?(e=t.buffer,n=new e.constructor(e.byteLength),new fr(n).set(new fr(e)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var de=Object.create,be=function(){function t(){}return function(r){if(!zt(r))return{};if(de)return de(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function ge(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var _e=Object.prototype.hasOwnProperty;function je(t,r,e){var n=t[r];_e.call(t,r)&&Mt(n,e)&&(void 0!==e||r in t)||fe(t,r,e)}var me=Object.prototype.hasOwnProperty;function Oe(t){if(!zt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=kt(t),e=[];for(var n in t)("constructor"!=n||!r&&me.call(t,n))&&e.push(n);return e}function we(t){return Ct(t)?xt(t,!0):Oe(t)}function Ae(t){return function(t,r,e,n){var o=!e;e||(e={});for(var u=-1,i=r.length;++u0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Ee);function Ce(t,r){return Te(function(t,r,e){return r=Pe(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=Pe(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Ne.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!zt(e))return!1;var n=typeof r;return!!("number"==n?Ct(e)&&ht(r,e.length):"string"==n&&r in e)&&Mt(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e=e?t:function(t,r,n){var e=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(n=n>o?o:n)<0&&(n+=o),o=r>n?0:n-r>>>0,r>>>=0;for(var u=Array(o);++e-1;);return n}(e,o),function(t,r){for(var n=t.length;n--&&P(r,t[n],0)>-1;);return n}(e,o)+1).join("")}var L=function(t){return!!a(t)||null!=t&&""!==I(t)},q="[object Number]";function U(t){return function(t){return"number"==typeof t||b(t)&&d(t)==q}(t)&&t!=+t}var J="[object String]";function W(t){return"string"==typeof t||!a(t)&&b(t)&&d(t)==J}var G=function(t){return!W(t)&&!U(parseFloat(t))},H=function(t){return""!==I(t)&&W(t)},K=function(t){return null!=t&&"boolean"==typeof t},Q=function(t,r){return void 0===r&&(r=!0),void 0!==t&&""!==t&&""!==I(t)&&(!1===r||!0===r&&null!==t)},Y="type",X="optional",Z="enumv",tt="args",rt="checker",nt="alias",et=Y,ot=X,ut=Z,it=tt,at=rt,ct=nt,ft="continue",lt=function(t){switch(t){case"number":return G;case"string":return H;case"boolean":return K;default:return Q}},st=function(t,r){return void 0===r&&(r=""),!!a(t)&&(""===r||""===I(r)||!(t.filter((function(t){return!lt(r)(t)})).length>0))},pt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},vt=function(t,r){var n=t.arg;return r.length>1?!n.filter((function(t){return!(r.length>r.filter((function(r){return!lt(r)(t)})).length)})).length:r.length>r.filter((function(t){return!st(n,t)})).length};function ht(t,r){return function(n){return t(r(n))}}var yt=ht(Object.getPrototypeOf,Object),dt="[object Object]",bt=Function.prototype,gt=Object.prototype,_t=bt.toString,jt=gt.hasOwnProperty,mt=_t.call(Object);function wt(t){if(!b(t)||d(t)!=dt)return!1;var r=yt(t);if(null===r)return!0;var n=jt.call(r,"constructor")&&r.constructor;return"function"==typeof n&&n instanceof n&&_t.call(n)==mt}var Ot,At=function(t,r,n){for(var e=-1,o=Object(t),u=n(t),i=u.length;i--;){var a=u[Ot?i:++e];if(!1===r(o[a],a,o))break}return t};var St="[object Arguments]";function Pt(t){return b(t)&&d(t)==St}var kt=Object.prototype,Et=kt.hasOwnProperty,zt=kt.propertyIsEnumerable,xt=Pt(function(){return arguments}())?Pt:function(t){return b(t)&&Et.call(t,"callee")&&!zt.call(t,"callee")};var Tt="object"==typeof t&&t&&!t.nodeType&&t,Ct=Tt&&"object"==typeof module&&module&&!module.nodeType&&module,Ft=Ct&&Ct.exports===Tt?o.Buffer:void 0,Mt=(Ft?Ft.isBuffer:void 0)||function(){return!1},Nt=9007199254740991,$t=/^(?:0|[1-9]\d*)$/;function Dt(t,r){var n=typeof t;return!!(r=null==r?Nt:r)&&("number"==n||"symbol"!=n&&$t.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Rt}var Vt={};Vt["[object Float32Array]"]=Vt["[object Float64Array]"]=Vt["[object Int8Array]"]=Vt["[object Int16Array]"]=Vt["[object Int32Array]"]=Vt["[object Uint8Array]"]=Vt["[object Uint8ClampedArray]"]=Vt["[object Uint16Array]"]=Vt["[object Uint32Array]"]=!0,Vt["[object Arguments]"]=Vt["[object Array]"]=Vt["[object ArrayBuffer]"]=Vt["[object Boolean]"]=Vt["[object DataView]"]=Vt["[object Date]"]=Vt["[object Error]"]=Vt["[object Function]"]=Vt["[object Map]"]=Vt["[object Number]"]=Vt["[object Object]"]=Vt["[object RegExp]"]=Vt["[object Set]"]=Vt["[object String]"]=Vt["[object WeakMap]"]=!1;var It,Lt="object"==typeof t&&t&&!t.nodeType&&t,qt=Lt&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=qt&&qt.exports===Lt&&n.process,Jt=function(){try{var t=qt&&qt.require&&qt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Wt=Jt&&Jt.isTypedArray,Gt=Wt?(It=Wt,function(t){return It(t)}):function(t){return b(t)&&Bt(t.length)&&!!Vt[d(t)]},Ht=Object.prototype.hasOwnProperty;function Kt(t,r){var n=a(t),e=!n&&xt(t),o=!n&&!e&&Mt(t),u=!n&&!e&&!o&&Gt(t),i=n||e||o||u,c=i?function(t,r){for(var n=-1,e=Array(t);++n-1},pr.prototype.set=function(t,r){var n=this.__data__,e=lr(n,t);return e<0?(++this.size,n.push([t,r])):n[e][1]=r,this};var vr,hr=o["__core-js_shared__"],yr=(vr=/[^.]+$/.exec(hr&&hr.keys&&hr.keys.IE_PROTO||""))?"Symbol(src)_1."+vr:"";var dr=Function.prototype.toString;function br(t){if(null!=t){try{return dr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var gr=/^\[object .+?Constructor\]$/,_r=Function.prototype,jr=Object.prototype,mr=_r.toString,wr=jr.hasOwnProperty,Or=RegExp("^"+mr.call(wr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ar(t){return!(!tr(t)||function(t){return!!yr&&yr in t}(t))&&(ur(t)?Or:gr).test(br(t))}function Sr(t,r){var n=function(t,r){return null==t?void 0:t[r]}(t,r);return Ar(n)?n:void 0}var Pr=Sr(o,"Map"),kr=Sr(Object,"create");var Er="__lodash_hash_undefined__",zr=Object.prototype.hasOwnProperty;var xr=Object.prototype.hasOwnProperty;var Tr="__lodash_hash_undefined__";function Cr(t){var r=-1,n=null==t?0:t.length;for(this.clear();++ra))return!1;var f=u.get(t);if(f&&u.get(r))return f==r;var l=-1,s=!0,p=n&Ir?new Rr:void 0;for(u.set(t,r),u.set(r,t);++lr.type.filter((function(t){var r;return void 0===n||(!1!==(r=pt(t))?!vt({arg:n},r):!lt(t)(n))})).length)})).length}return!1},ce=function(t){function r(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={name:{configurable:!0}};return n.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,n),r}(Error),fe=function(t){function r(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={name:{configurable:!0}};return n.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,n),r}(Error),le=function(t){function r(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={name:{configurable:!0}};return n.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,n),r}(Error),se=function(t){function r(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];t.apply(this,n),this.message=n[0],this.detail=n[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={name:{configurable:!0},statusCode:{configurable:!0}};return n.name.get=function(){return"JsonqlError"},n.statusCode.get=function(){return-1},Object.defineProperties(r,n),r}(Error),pe=function(t,r){var n,e,o,u,i;switch(!0){case"object"===t:return o=(e=r).arg,u=e.param,i=[o],Array.isArray(u.keys)&&u.keys.length&&i.push(u.keys),!Reflect.apply(ae,null,i);case"array"===t:return!st(r.arg);case!1!==(n=pt(t)):return!vt(r,n);default:return!lt(t)(r.arg)}},ve=function(t,r){return void 0!==t?t:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},he=function(t,r){if(!st(r))throw new se("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===r.length)return[];if(!st(t))throw new se("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==r.length:return t.map((function(t,n){return{arg:t,index:n,param:r[n]}}));case!0===r[0].variable:var n=r[0].type;return t.map((function(t,e){return{arg:t,index:e,param:r[e]||{type:n,name:"_"}}}));case t.lengthr.length:var e=r.length,o=["any"];return t.map((function(t,n){var u=n>=e||!!r[n].optional,i=r[n]||{type:o,name:"_"+n};return{arg:u?ve(t,i):t,index:n,param:i,optional:u}}));default:throw new se("Could not understand your arguments and parameter structure!",{args:t,params:r})}},ye=function(t,r,n){var e;void 0===n&&(n=!1);var o=he(t,r),u=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,n=t.param;return!!L(r)&&!(n.type.length>n.type.filter((function(r){return pe(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return pe(r,t)})).length)}));return n?((e={}).error=u,e.data=o.map((function(t){return t.arg})),e):u},de=function(){try{var t=Sr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function be(t,r,n){"__proto__"==r&&de?de(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}function ge(t,r,n){(void 0===n||fr(t[r],n))&&(void 0!==n||r in t)||be(t,r,n)}var _e="object"==typeof t&&t&&!t.nodeType&&t,je=_e&&"object"==typeof module&&module&&!module.nodeType&&module,me=je&&je.exports===_e?o.Buffer:void 0,we=me?me.allocUnsafe:void 0;function Oe(t,r){var n,e,o=r?(n=t.buffer,e=new n.constructor(n.byteLength),new qr(e).set(new qr(n)),e):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ae=Object.create,Se=function(){function t(){}return function(r){if(!tr(r))return{};if(Ae)return Ae(r);t.prototype=r;var n=new t;return t.prototype=void 0,n}}();function Pe(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var ke=Object.prototype.hasOwnProperty;function Ee(t,r,n){var e=t[r];ke.call(t,r)&&fr(e,n)&&(void 0!==n||r in t)||be(t,r,n)}var ze=Object.prototype.hasOwnProperty;function xe(t){if(!tr(t))return function(t){var r=[];if(null!=t)for(var n in Object(t))r.push(n);return r}(t);var r=Yt(t),n=[];for(var e in t)("constructor"!=e||!r&&ze.call(t,e))&&n.push(e);return n}function Te(t){return ir(t)?Kt(t,!0):xe(t)}function Ce(t){return function(t,r,n,e){var o=!n;n||(n={});for(var u=-1,i=r.length;++u0){if(++r>=Re)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(De);function Le(t,r){return Ie(function(t,r,n){return r=$e(void 0===r?t.length-1:r,0),function(){for(var e=arguments,o=-1,u=$e(e.length-r,0),i=Array(u);++o1?r[e-1]:void 0,u=e>2?r[2]:void 0;for(o=qe.length>3&&"function"==typeof o?(e--,o):void 0,u&&function(t,r,n){if(!tr(n))return!1;var e=typeof r;return!!("number"==e?ir(n)&&Dt(r,n.length):"string"==e&&r in n)&&fr(n[r],t)}(r[0],r[1],u)&&(o=e<3?void 0:o,e=1),t=Object(t);++n=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&O(r,t[e],0)>-1;);return e}(n,o)+1).join("")}var R=function(t){return!!a(t)||null!=t&&""!==D(t)};function V(t){return function(t){return"number"==typeof t||y(t)&&"[object Number]"==h(t)}(t)&&t!=+t}function B(t){return"string"==typeof t||!a(t)&&y(t)&&"[object String]"==h(t)}var q=function(t){return!B(t)&&!V(parseFloat(t))},I=function(t){return""!==D(t)&&B(t)},L=function(t){return null!=t&&"boolean"==typeof t},U=function(t,r){return void 0===r&&(r=!0),void 0!==t&&""!==t&&""!==D(t)&&(!1===r||!0===r&&null!==t)},J=function(t){switch(t){case"number":return q;case"string":return I;case"boolean":return L;default:return U}},W=function(t,r){return void 0===r&&(r=""),!!a(t)&&(""===r||""===D(r)||!(t.filter((function(t){return!J(r)(t)})).length>0))},G=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},H=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!J(r)(t)})).length)})).length:r.length>r.filter((function(t){return!W(e,t)})).length};function K(t,r){return function(e){return t(r(e))}}var Q=K(Object.getPrototypeOf,Object),Y=Function.prototype,X=Object.prototype,Z=Y.toString,tt=X.hasOwnProperty,rt=Z.call(Object);function et(t){if(!y(t)||"[object Object]"!=h(t))return!1;var r=Q(t);if(null===r)return!0;var e=tt.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&Z.call(e)==rt}var nt,ot=function(t,r,e){for(var n=-1,o=Object(t),u=e(t),i=u.length;i--;){var a=u[nt?i:++n];if(!1===r(o[a],a,o))break}return t};function ut(t){return y(t)&&"[object Arguments]"==h(t)}var it=Object.prototype,at=it.hasOwnProperty,ct=it.propertyIsEnumerable,ft=ut(function(){return arguments}())?ut:function(t){return y(t)&&at.call(t,"callee")&&!ct.call(t,"callee")};var lt="object"==typeof t&&t&&!t.nodeType&&t,st=lt&&"object"==typeof module&&module&&!module.nodeType&&module,pt=st&&st.exports===lt?o.Buffer:void 0,vt=(pt?pt.isBuffer:void 0)||function(){return!1},ht=/^(?:0|[1-9]\d*)$/;function yt(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&ht.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var bt={};bt["[object Float32Array]"]=bt["[object Float64Array]"]=bt["[object Int8Array]"]=bt["[object Int16Array]"]=bt["[object Int32Array]"]=bt["[object Uint8Array]"]=bt["[object Uint8ClampedArray]"]=bt["[object Uint16Array]"]=bt["[object Uint32Array]"]=!0,bt["[object Arguments]"]=bt["[object Array]"]=bt["[object ArrayBuffer]"]=bt["[object Boolean]"]=bt["[object DataView]"]=bt["[object Date]"]=bt["[object Error]"]=bt["[object Function]"]=bt["[object Map]"]=bt["[object Number]"]=bt["[object Object]"]=bt["[object RegExp]"]=bt["[object Set]"]=bt["[object String]"]=bt["[object WeakMap]"]=!1;var gt,_t="object"==typeof t&&t&&!t.nodeType&&t,jt=_t&&"object"==typeof module&&module&&!module.nodeType&&module,mt=jt&&jt.exports===_t&&e.process,Ot=function(){try{var t=jt&&jt.require&&jt.require("util").types;return t||mt&&mt.binding&&mt.binding("util")}catch(t){}}(),wt=Ot&&Ot.isTypedArray,At=wt?(gt=wt,function(t){return gt(t)}):function(t){return y(t)&&dt(t.length)&&!!bt[h(t)]},St=Object.prototype.hasOwnProperty;function kt(t,r){var e=a(t),n=!e&&ft(t),o=!e&&!n&&vt(t),u=!e&&!n&&!o&&At(t),i=e||n||o||u,c=i?function(t,r){for(var e=-1,n=Array(t);++e-1},Vt.prototype.set=function(t,r){var e=this.__data__,n=Dt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var Bt,qt=o["__core-js_shared__"],It=(Bt=/[^.]+$/.exec(qt&&qt.keys&&qt.keys.IE_PROTO||""))?"Symbol(src)_1."+Bt:"";var Lt=Function.prototype.toString;function Ut(t){if(null!=t){try{return Lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Jt=/^\[object .+?Constructor\]$/,Wt=Function.prototype,Gt=Object.prototype,Ht=Wt.toString,Kt=Gt.hasOwnProperty,Qt=RegExp("^"+Ht.call(Kt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Yt(t){return!(!xt(t)||function(t){return!!It&&It in t}(t))&&(Ct(t)?Qt:Jt).test(Ut(t))}function Xt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return Yt(e)?e:void 0}var Zt=Xt(o,"Map"),tr=Xt(Object,"create");var rr=Object.prototype.hasOwnProperty;var er=Object.prototype.hasOwnProperty;function nr(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ra))return!1;var f=u.get(t);if(f&&u.get(r))return f==r;var l=-1,s=!0,p=2&e?new ar:void 0;for(u.set(t,r),u.set(r,t);++lr.type.filter((function(t){var r;return void 0===e||(!1!==(r=G(t))?!H({arg:e},r):!J(t)(e))})).length)})).length}return!1},ne=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(r,e),r}(Error),oe=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(Error),ue=function(t,r){var e,n,o,u,i;switch(!0){case"object"===t:return o=(n=r).arg,u=n.param,i=[o],Array.isArray(u.keys)&&u.keys.length&&i.push(u.keys),!Reflect.apply(ee,null,i);case"array"===t:return!W(r.arg);case!1!==(e=G(t)):return!H(r,e);default:return!J(t)(r.arg)}},ie=function(t,r){return void 0!==t?t:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},ae=function(t,r){if(!W(r))throw new ne("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===r.length)return[];if(!W(t))throw new ne("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==r.length:return t.map((function(t,e){return{arg:t,index:e,param:r[e]}}));case!0===r[0].variable:var e=r[0].type;return t.map((function(t,n){return{arg:t,index:n,param:r[n]||{type:e,name:"_"}}}));case t.lengthr.length:var n=r.length,o=["any"];return t.map((function(t,e){var u=e>=n||!!r[e].optional,i=r[e]||{type:o,name:"_"+e};return{arg:u?ie(t,i):t,index:e,param:i,optional:u}}));default:throw new oe("Could not understand your arguments and parameter structure!",{args:t,params:r})}},ce=function(t,r,e){var n;void 0===e&&(e=!1);var o=ae(t,r),u=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!R(r)&&!(e.type.length>e.type.filter((function(r){return ue(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return ue(r,t)})).length)}));return e?((n={}).error=u,n.data=o.map((function(t){return t.arg})),n):u},fe=function(){try{var t=Xt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function le(t,r,e){"__proto__"==r&&fe?fe(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function se(t,r,e){(void 0===e||$t(t[r],e))&&(void 0!==e||r in t)||le(t,r,e)}var pe="object"==typeof t&&t&&!t.nodeType&&t,ve=pe&&"object"==typeof module&&module&&!module.nodeType&&module,he=ve&&ve.exports===pe?o.Buffer:void 0,ye=he?he.allocUnsafe:void 0;function de(t,r){var e,n,o=r?(e=t.buffer,n=new e.constructor(e.byteLength),new lr(n).set(new lr(e)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var be=Object.create,ge=function(){function t(){}return function(r){if(!xt(r))return{};if(be)return be(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function _e(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var je=Object.prototype.hasOwnProperty;function me(t,r,e){var n=t[r];je.call(t,r)&&$t(n,e)&&(void 0!==e||r in t)||le(t,r,e)}var Oe=Object.prototype.hasOwnProperty;function we(t){if(!xt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=Et(t),e=[];for(var n in t)("constructor"!=n||!r&&Oe.call(t,n))&&e.push(n);return e}function Ae(t){return Nt(t)?kt(t,!0):we(t)}function Se(t){return function(t,r,e,n){var o=!e;e||(e={});for(var u=-1,i=r.length;++u0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Te);function Ne(t,r){return Ce(function(t,r,e){return r=ze(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=ze(n.length-r,0),i=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Fe.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!xt(e))return!1;var n=typeof r;return!!("number"==n?Nt(e)&&yt(r,e.length):"string"==n&&r in e)&&$t(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++e !combineFn(type)(v)) return !(c.length > 0) } - return false; + return false } /** @@ -43,7 +43,7 @@ export const isArrayLike = function(type) { } return [_type] } - return false; + return false } /** @@ -53,14 +53,14 @@ export const isArrayLike = function(type) { * @return {boolean} for the filter to operate on */ export const arrayTypeHandler = function(p, type) { - const { arg } = p; + const { arg } = p // need a special case to handle the OR type // we need to test the args instead of the type(s) if (type.length > 1) { return !arg.filter(v => ( !(type.length > type.filter(t => !combineFn(t)(v)).length) - )).length; + )).length } // type is array so this will be or! - return type.length > type.filter(t => !checkIsArray(arg, t)).length; + return type.length > type.filter(t => !checkIsArray(arg, t)).length } diff --git a/packages/validator/src/combine.js b/packages/validator/src/combine.js index c6e8f9904baf720ff98e097ceae21ebad21206e9..e101502eef33fb26048f1d452c2b953590da8b5d 100644 --- a/packages/validator/src/combine.js +++ b/packages/validator/src/combine.js @@ -13,13 +13,13 @@ import { NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE } from './constants' const combineFn = function(type) { switch (type) { case NUMBER_TYPE: - return checkIsNumber; + return checkIsNumber case STRING_TYPE: - return checkIsString; + return checkIsString case BOOLEAN_TYPE: - return checkIsBoolean; + return checkIsBoolean default: - return checkIsAny; + return checkIsAny } } diff --git a/packages/validator/src/constants.js b/packages/validator/src/constants.js index e3f4594dbd87fd4903f992ebf059351febe15daf..36346fbca5a33223d6aa41db081122459b479a7d 100644 --- a/packages/validator/src/constants.js +++ b/packages/validator/src/constants.js @@ -1,31 +1,31 @@ // Good practice rule - No magic number -export const ARGS_NOT_ARRAY_ERR = `args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)`; -export const PARAMS_NOT_ARRAY_ERR = `params is not an array! Did something gone wrong when you generate the contract.json?`; -export const EXCEPTION_CASE_ERR = 'Could not understand your arguments and parameter structure!'; -export const UNUSUAL_CASE_ERR = 'This is an unusual situation where the arguments are more than the params, but not mark as spread'; +export const ARGS_NOT_ARRAY_ERR = `args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)` +export const PARAMS_NOT_ARRAY_ERR = `params is not an array! Did something gone wrong when you generate the contract.json?` +export const EXCEPTION_CASE_ERR = 'Could not understand your arguments and parameter structure!' +export const UNUSUAL_CASE_ERR = 'This is an unusual situation where the arguments are more than the params, but not mark as spread' // re-export -import * as JSONQL_CONSTANTS from 'jsonql-constants'; +import * as JSONQL_CONSTANTS from 'jsonql-constants' // @TODO the jsdoc return array. and we should also allow array syntax -export const DEFAULT_TYPE = JSONQL_CONSTANTS.DEFAULT_TYPE; -export const ARRAY_TYPE_LFT = JSONQL_CONSTANTS.ARRAY_TYPE_LFT; -export const ARRAY_TYPE_RGT = JSONQL_CONSTANTS.ARRAY_TYPE_RGT; +export const DEFAULT_TYPE = JSONQL_CONSTANTS.DEFAULT_TYPE +export const ARRAY_TYPE_LFT = JSONQL_CONSTANTS.ARRAY_TYPE_LFT +export const ARRAY_TYPE_RGT = JSONQL_CONSTANTS.ARRAY_TYPE_RGT -export const TYPE_KEY = JSONQL_CONSTANTS.TYPE_KEY; -export const OPTIONAL_KEY = JSONQL_CONSTANTS.OPTIONAL_KEY; -export const ENUM_KEY = JSONQL_CONSTANTS.ENUM_KEY; -export const ARGS_KEY = JSONQL_CONSTANTS.ARGS_KEY; -export const CHECKER_KEY = JSONQL_CONSTANTS.CHECKER_KEY; -export const ALIAS_KEY = JSONQL_CONSTANTS.ALIAS_KEY; +export const TYPE_KEY = JSONQL_CONSTANTS.TYPE_KEY +export const OPTIONAL_KEY = JSONQL_CONSTANTS.OPTIONAL_KEY +export const ENUM_KEY = JSONQL_CONSTANTS.ENUM_KEY +export const ARGS_KEY = JSONQL_CONSTANTS.ARGS_KEY +export const CHECKER_KEY = JSONQL_CONSTANTS.CHECKER_KEY +export const ALIAS_KEY = JSONQL_CONSTANTS.ALIAS_KEY -export const ARRAY_TYPE = JSONQL_CONSTANTS.ARRAY_TYPE; -export const OBJECT_TYPE = JSONQL_CONSTANTS.OBJECT_TYPE; -export const STRING_TYPE = JSONQL_CONSTANTS.STRING_TYPE; -export const BOOLEAN_TYPE = JSONQL_CONSTANTS.BOOLEAN_TYPE; -export const NUMBER_TYPE = JSONQL_CONSTANTS.NUMBER_TYPE; -export const KEY_WORD = JSONQL_CONSTANTS.KEY_WORD; -export const OR_SEPERATOR = JSONQL_CONSTANTS.OR_SEPERATOR; +export const ARRAY_TYPE = JSONQL_CONSTANTS.ARRAY_TYPE +export const OBJECT_TYPE = JSONQL_CONSTANTS.OBJECT_TYPE +export const STRING_TYPE = JSONQL_CONSTANTS.STRING_TYPE +export const BOOLEAN_TYPE = JSONQL_CONSTANTS.BOOLEAN_TYPE +export const NUMBER_TYPE = JSONQL_CONSTANTS.NUMBER_TYPE +export const KEY_WORD = JSONQL_CONSTANTS.KEY_WORD +export const OR_SEPERATOR = JSONQL_CONSTANTS.OR_SEPERATOR // not actually in use // export const NUMBER_TYPES = JSONQL_CONSTANTS.NUMBER_TYPES; diff --git a/packages/validator/src/is-in-array.js b/packages/validator/src/is-in-array.js index dd93f3065f428c1653d057d9cecd62f3731c8595..9847c04fa274ea1709f6978b91f169319f93024f 100644 --- a/packages/validator/src/is-in-array.js +++ b/packages/validator/src/is-in-array.js @@ -4,7 +4,7 @@ * @return {boolean} true on successs */ const isInArray = function(arr, value) { - return !!arr.filter(a => a === value).length; + return !!arr.filter(a => a === value).length } export default isInArray diff --git a/packages/validator/src/options/is-key-in-object.js b/packages/validator/src/is-key-in-object.js similarity index 61% rename from packages/validator/src/options/is-key-in-object.js rename to packages/validator/src/is-key-in-object.js index 1b07da4047074674dcfa73918d39f4ceb9c6e3e7..f07b4edb0d37adc0baff3eea552d99fa2a0d02cc 100644 --- a/packages/validator/src/options/is-key-in-object.js +++ b/packages/validator/src/is-key-in-object.js @@ -1,9 +1,9 @@ -import isInArray from '../is-in-array' +import isInArray from './is-in-array' const isObjectHasKey = function(obj, key) { const keys = Object.keys(obj) return isInArray(keys, key) } -export default isObjectHasKey +export default isObjectHasKey \ No newline at end of file diff --git a/packages/validator/src/not-empty.js b/packages/validator/src/not-empty.js index 0dbc3d4b623267b4979a2936e55e31b017fe1d78..f856019006775f972821d6cf99cc7adeef374ef1 100644 --- a/packages/validator/src/not-empty.js +++ b/packages/validator/src/not-empty.js @@ -9,7 +9,7 @@ import isArray from 'lodash-es/isArray' if (isArray(a)) { return true; } - return a !== undefined && a !== null && trim(a) !== ''; + return a !== undefined && a !== null && trim(a) !== '' } export default isNotEmpty diff --git a/packages/validator/src/object.js b/packages/validator/src/object.js index 55ec11236548bd484d2815e847907ea88f69410f..d56f3e4e043e4d8f5ae0e8f8090ef834f08f4cfe 100644 --- a/packages/validator/src/object.js +++ b/packages/validator/src/object.js @@ -14,7 +14,7 @@ import { checkIsArray, isArrayLike, arrayTypeHandler } from './array' export const checkIsObject = function(value, keys=null) { if (isPlainObject(value)) { if (!keys) { - return true; + return true } if (checkIsArray(keys)) { // please note we DON'T care if some is optional @@ -31,12 +31,12 @@ export const checkIsObject = function(value, keys=null) { } return !combineFn(type)(_value) } - return true; + return true }).length) }).length; } } - return false; + return false } /** @@ -45,8 +45,8 @@ export const checkIsObject = function(value, keys=null) { * @return {boolean} */ export const objectTypeHandler = function(p) { - const { arg, param } = p; - let _args = [arg]; + const { arg, param } = p + let _args = [arg] if (Array.isArray(param.keys) && param.keys.length) { _args.push(param.keys) } diff --git a/packages/validator/src/options/construct-config.js b/packages/validator/src/options/construct-config.js index 24222a76e842b266921290f796e62a9499e44c23..642653289d6565a2c506e4705ebe1da85cced8c8 100644 --- a/packages/validator/src/options/construct-config.js +++ b/packages/validator/src/options/construct-config.js @@ -12,7 +12,7 @@ import { } from 'jsonql-constants' import { checkIsArray } from '../array' -import checkIsBoolean from '../boolean' +// import checkIsBoolean from '../boolean' // import debug from 'debug'; // const debugFn = debug('jsonql-params-validator:construct-config'); /** @@ -27,18 +27,18 @@ export default function constructConfig(args, type, optional=false, enumv=false, let base = { [ARGS_KEY]: args, [TYPE_KEY]: type - }; + } if (optional === true) { - base[OPTIONAL_KEY] = true; + base[OPTIONAL_KEY] = true } if (checkIsArray(enumv)) { - base[ENUM_KEY] = enumv; + base[ENUM_KEY] = enumv } if (isFunction(checker)) { - base[CHECKER_KEY] = checker; + base[CHECKER_KEY] = checker } if (isString(alias)) { - base[ALIAS_KEY] = alias; + base[ALIAS_KEY] = alias } - return base; + return base } diff --git a/packages/validator/src/options/index.js b/packages/validator/src/options/index.js index 30cb45c5a3441831b1ecc17156c6799ff8e642f3..1a527a1354295cda4cb919835b89d053ff922bd4 100644 --- a/packages/validator/src/options/index.js +++ b/packages/validator/src/options/index.js @@ -33,7 +33,7 @@ const createConfig = (value, type, params = {}) => { } // for testing purpose -const JSONQL_PARAMS_VALIDATOR_INFO = '__PLACEHOLDER__'; +const JSONQL_PARAMS_VALIDATOR_INFO = '__PLACEHOLDER__' /** * construct the actual end user method, rename with prefix get since 1.5.2 diff --git a/packages/validator/src/options/prepare-args-for-validation.js b/packages/validator/src/options/prepare-args-for-validation.js index b40122036c76233faf4252051c4be5261f204b16..317bdbb529f07c2ddc25bb593623ae10f205f57f 100644 --- a/packages/validator/src/options/prepare-args-for-validation.js +++ b/packages/validator/src/options/prepare-args-for-validation.js @@ -16,8 +16,8 @@ import { ALIAS_KEY } from '../constants' import notEmpty from '../not-empty' -import { checkIsObject } from '../object' -import isObjectHasKey from './is-key-in-object' +// import { checkIsObject } from '../object' +import isObjectHasKey from '../is-key-in-object' // just not to make my head hurt const isEmpty = value => !notEmpty(value) diff --git a/packages/validator/src/options/run-validation.js b/packages/validator/src/options/run-validation.js index 60874190e461982f38bd4f0352f187123172fc19..ee7e5d0054ca1e313363aecf0e0029b1bd6ca6b5 100644 --- a/packages/validator/src/options/run-validation.js +++ b/packages/validator/src/options/run-validation.js @@ -67,7 +67,7 @@ const enumHandler = (value, enumv) => { if (checkIsArray(enumv)) { return inArray(enumv, value) } - return true; + return true } /** @@ -80,9 +80,9 @@ const enumHandler = (value, enumv) => { */ const checkerHandler = (value, checker) => { try { - return isFunction(checker) ? checker.apply(null, [value]) : false; + return isFunction(checker) ? checker.apply(null, [value]) : false } catch (e) { - return false; + return false } } @@ -121,7 +121,7 @@ function runValidationAction(cb) { * @return {object} of configuration values */ export default function runValidation(args, cb) { - const [ argsForValidate, pristineValues ] = args; + const [ argsForValidate, pristineValues ] = args // turn the thing into an array and see what happen here // debugFn('_args', argsForValidate) const result = mapValues(argsForValidate, runValidationAction(cb)) diff --git a/packages/validator/src/string.js b/packages/validator/src/string.js index 18411d9513dbeb786004cbaf16902f911cb05cb1..7cb7ba2bf6a933c125bced7554ecaba6e1496f28 100644 --- a/packages/validator/src/string.js +++ b/packages/validator/src/string.js @@ -6,7 +6,7 @@ import isString from 'lodash-es/isString' * @return {boolean} true if OK */ const checkIsString = function(value) { - return (trim(value) !== '') ? isString(value) : false; + return (trim(value) !== '') ? isString(value) : false } export default checkIsString diff --git a/packages/validator/src/validator.js b/packages/validator/src/validator.js index dada6d5e3fabca5a4f45d7b61492fde3179b1f90..f119fcc936cb1f060d978d629585c8d954823f19 100644 --- a/packages/validator/src/validator.js +++ b/packages/validator/src/validator.js @@ -5,7 +5,7 @@ import { isArrayLike, arrayTypeHandler, objectTypeHandler, - checkIsObject, + // checkIsObject, combineFn, notEmpty } from './index' @@ -15,11 +15,13 @@ import { OBJECT_TYPE, ARGS_NOT_ARRAY_ERR, PARAMS_NOT_ARRAY_ERR, - EXCEPTION_CASE_ERR, - UNUSUAL_CASE_ERR + EXCEPTION_CASE_ERR + // UNUSUAL_CASE_ERR } from './constants' import { DATA_KEY, ERROR_KEY } from 'jsonql-constants' -import { JsonqlError } from 'jsonql-errors' + +import JsonqlValidationError from 'jsonql-errors/src/validation-error' +import JsonqlError from 'jsonql-errors/src/error' // import debug from 'debug' // const debugFn = debug('jsonql-params-validator:validator') // also export this for use in other places @@ -38,7 +40,7 @@ const optionalHandler = function( params ) { validateHandler(type, params) ).length) } - return false; + return false } /** @@ -75,7 +77,7 @@ const validateHandler = function(type, value) { */ const getOptionalValue = function(arg, param) { if (arg !== undefined) { - return arg; + return arg } return (param.optional === true && param.defaultvalue !== undefined ? param.defaultvalue : null) } @@ -92,13 +94,13 @@ export const normalizeArgs = function(args, params) { // there will be situation where the function doesn't need args and params if (!checkIsArray(params)) { // debugFn('params value', params) - throw new JsonqlError(PARAMS_NOT_ARRAY_ERR) + throw new JsonqlValidationError(PARAMS_NOT_ARRAY_ERR) } if (params.length === 0) { - return []; + return [] } if (!checkIsArray(args)) { - throw new JsonqlError(ARGS_NOT_ARRAY_ERR) + throw new JsonqlValidationError(ARGS_NOT_ARRAY_ERR) } // debugFn(args, params); // fall through switch diff --git a/packages/validator/sync.js b/packages/validator/sync.js index f64254579369df66b8f7db598b3227b79add0941..41b45e1019d2f571c3e434eda7f6933b868870b1 100644 --- a/packages/validator/sync.js +++ b/packages/validator/sync.js @@ -1,25 +1,25 @@ // just copy the source to where it's needed for now. // don't have time to deal with the tooling fucking problem -const { join } = require('path'); -const fsx = require('fs-extra'); -const debug = require('debug')('jsonql-params-validator:sync'); +const { join } = require('path') +const fsx = require('fs-extra') +const debug = require('debug')('jsonql-params-validator:sync') // sources const src = [ join(__dirname, 'src'), join(__dirname, 'index.js') -]; +] // destinations const dest = [ join(__dirname, '..', 'client', 'src', 'lib', 'validator'), join(__dirname, '..', 'rx-client', 'src', 'lib', 'validator') -]; +] // now copy src.forEach( s => { - const ds = s.split('/'); - const last = ds[ds.length - 1]; - debug('copy ', last); + const ds = s.split('/') + const last = ds[ds.length - 1] + debug('copy ', last) dest.forEach(d => { - const result = fsx.copy(s, join(d, last)); - debug('copy result: ', result); - }); -}); + const result = fsx.copy(s, join(d, last)) + debug('copy result: ', result) + }) +}) diff --git a/packages/validator/tests/throw.test.js b/packages/validator/tests/throw.test.js index 3304e3ff10a12dd6d55fc279ec81b249adaa8a46..9c7b7b77e41eb2e7e8a8e86e8021f667164d5013 100644 --- a/packages/validator/tests/throw.test.js +++ b/packages/validator/tests/throw.test.js @@ -1,7 +1,7 @@ // testing if it throws or not const test = require('ava') const { validateSync } = require('../index.js') -const debug = require('debug')('jsonql-params-validator:test:throw') +// const debug = require('debug')('jsonql-params-validator:test:throw') // const result = validateSync(['1'], [{type: ['number'], name: 'id'}]); const { JsonqlValidationError } = require('jsonql-errors') @@ -17,6 +17,6 @@ const fn = () => { test('It should able to throw an error', t => { const error = t.throws( () => { fn(); - } , JsonqlValidationError, 'pass a string that expected number') + } , null /*JsonqlValidationError*/, 'pass a string that expected number') t.is(error.message, 'Failed!') }) diff --git a/packages/ws-server-core/package.json b/packages/ws-server-core/package.json index 9188b1e8038b24b77effcfa23a7c4ebd80f70d8c..5f74ef73543c47f1578bbd4576b6db56a4bcfff3 100644 --- a/packages/ws-server-core/package.json +++ b/packages/ws-server-core/package.json @@ -33,13 +33,13 @@ "jsonql-errors": "^1.1.10", "jsonql-jwt": "^1.3.9", "jsonql-params-validator": "^1.5.2", - "jsonql-resolver": "^1.1.1", + "jsonql-resolver": "^1.1.2", "jsonql-utils": "^1.0.6", "lodash": "^4.17.15" }, "devDependencies": { "ava": "^3.5.0", - "jsonql-contract": "^1.8.7" + "jsonql-contract": "^1.8.8" }, "ava": { "files": [ diff --git a/packages/ws-server-core/src/share/add-property.js b/packages/ws-server-core/src/share/add-property.js index 1d0ff2e71ea268d8e7469245468502c04f2418a1..382fb0d4c23bbd58708deb4dcb0c4845df52feb0 100644 --- a/packages/ws-server-core/src/share/add-property.js +++ b/packages/ws-server-core/src/share/add-property.js @@ -42,6 +42,7 @@ const addProperty = (deliverFn, fn, resolverName, ws, userdata, opts) => { // @TODO what if we run this standalone and we want to inject clients to it? return resolver }) + } module.exports = { addProperty } diff --git a/packages/ws-server-core/src/share/resolver-methods.js b/packages/ws-server-core/src/share/resolver-methods.js index 34bd8ae8edcb56d2bb1be66d85521090c19432d6..4a7b124ced29a14f1842e64843011bbdc82923b8 100644 --- a/packages/ws-server-core/src/share/resolver-methods.js +++ b/packages/ws-server-core/src/share/resolver-methods.js @@ -1,4 +1,5 @@ // Take the code out from the run-resolver to share between other method +const { JsonqlValidationError } = require('jsonql-errors') const { packError } = require('jsonql-utils') const { isNotEmpty, validateAsync } = require('jsonql-params-validator') const { getRainbowDebug, createWsReply } = require('./helpers') @@ -17,6 +18,10 @@ const debug = getRainbowDebug('share:resolver-methods') */ function validateInput(args, params) { return validateAsync(args, params, true) + .catch(err => { + + throw new JsonqlValidationError(`validateInput`, err) + }) }