json-rules-engine-simplified
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -1,8 +0,8 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSONSchemaForm=t():e.JSONSchemaForm=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=5)}([function(e,t,r){"use strict";function n(e){return"object"===(void 0===e?"undefined":f(e))&&null!==e}function o(){return!1}function u(e){return Array.isArray(e)?e:[e]}function i(e){if(o())throw new ReferenceError(e);console.error(e)}function c(e,t){return t.properties[e]&&"array"===t.properties[e].type&&t.properties[e].items&&t.properties[e].items.$ref}function s(e,t){return e.startsWith("#/")?(e.substr(2).split("/"),e.substr(2).split("/").reduce(function(e,t){return e[t]},t)):void i("Only local references supported at this point use json-schema-deref")}function a(e,t){return c(e,t)?s(t.properties[e].items.$ref,t):t.properties[e]&&t.properties[e].$ref?s(t.properties[e].$ref,t):t.properties[e]&&"object"===t.properties[e].type?t.properties[e]:void i(e+" has no $ref field ref schema extraction is impossible")}Object.defineProperty(t,"__esModule",{value:!0});var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.isObject=n,t.isDevelopment=o,t.toArray=u,t.toError=i,t.isRefArray=c,t.extractRefSchema=a;var l=function(e,t){return e.concat(t)};t.flatMap=function(e,t){return e.map(t).reduce(l,[])}},function(e,t,r){"use strict";var n=e.exports,o=Array.prototype.slice,u=function(e,t){return e.toString=function(){return t.toString()},e.src=t,e},i=n.curry=function(e){return u(function(t,r){switch(arguments.length){case 0:throw new TypeError("Function called with no arguments");case 1:return u(function(r){return e(t,r)},e)}return e(t,r)},e)};n.partial=function(e){var t=o.call(arguments,1);return function(){return e.apply(null,t.concat(o.call(arguments)))}},n.complement=n.invert=function(e){return function(){var t=e.apply(null,arguments);return"function"==typeof t?n.complement(t):!t}},n.mod=i(function(e,t){return e%t}),n.assign=i(Object.assign||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e})},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),u=e.exports,i=o.curry;Object.is?u.is=i(Object.is):u.is=i(function(e,t){return 0===e&&0===t?1/e==1/t:e!==e?t!==t:e===t}),u.exists=function(e){return null!=e},u.truthy=function(e){return!(!e||!u.exists(e))},u.falsey=o.complement(u.truthy),u.equal=i(function(e,t){return e===t}),u.eq=i(function(e,t){return e==t}),u.null=u.equal(null),u.undef=u.equal(void 0),u.lt=u.less=i(function(e,t){return e<t}),u.ltEq=u.le=u.lessEq=i(function(e,t){return u.equal(e,t)||u.less(e,t)}),u.gt=u.greater=i(function(e,t){return e>t}),u.gtEq=u.ge=u.greaterEq=i(function(e,t){return u.equal(e,t)||u.greater(e,t)});var c=Object.prototype.toString,s=i(function(e,t){return u.equal(e,c.call(t))});u.object=u.obj=function(e){return e===Object(e)},u.array=u.arr=Array.isArray||s("[object Array]"),u.date=s("[object Date]"),u.regex=u.regexp=u.rgx=u.RegExp=s("[object RegExp]"),u.finite=Number.isFinite||function(e){return u.number(e)&&isFinite(e)},u.nan=u.NaN=u.is(NaN),u.instance=i(function(e,t){return t instanceof e}),u.arguments=s("[object Arguments]"),u.error=u.instance(Error);var a=i(function(e,t){return u.equal(e,void 0===t?"undefined":n(t))});[["function","fn"],["string","str"],["boolean","bool"]].reduce(function(e,t){return e[t[0]]=e[t[1]]=a(t[0]),e},u),u.number=u.num=function(e){return"number"==typeof e&&u.not.NaN(e)},u.int=function(e){return u.num(e)&&u.zero(o.mod(e,1))},u.pos=function(e){return u.num(e)&&u.greater(e,0)},u.neg=function(e){return u.num(e)&&u.less(e,0)},u.zero=function(e){return u.num(e)&&u.equal(e,0)},u.even=function(e){return u.num(e)&&u.not.zero(e)&&u.zero(o.mod(e,2))},u.odd=function(e){return u.num(e)&&u.not.zero(e)&&u.not.zero(o.mod(e,2))},u.contains=u.includes=i(function(e,t){if(!u.array(e)&&!u.string(e))throw new TypeError("Expected an array or string");return!(u.string(e)&&!u.string(t))&&(u.NaN(t)?e.some(u.NaN):!!~e.indexOf(t))});var f=Object.prototype.hasOwnProperty;u.has=i(function(e,t){return f.call(e,t)}),u.empty=function(e){if(u.not.exists(e))return!0;if(u.arr(e)||u.str(e))return!e.length;if(u.obj(e)){for(var t in e)if(u.has(e,t))return!1;return!0}throw new TypeError},u.primitive=function(e){return u.string(e)||u.num(e)||u.bool(e)||u.null(e)||u.undef(e)||u.NaN(e)},u.matches=i(function(e,t){return e.test(t)}),u.not=Object.keys(u).reduce(function(e,t){return e[t]=o.complement(u[t]),e},{})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.OR="or",t.AND="and",t.NOT="not"},function(e,t,r){"use strict";var n=r(1),o={};o.VERSION="1.0.0",[n,r(2),r(8),r(9)].reduce(n.assign,o),e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=r(7),u=r(10),i=function(e){return e&&e.__esModule?e:{default:e}}(u),c=r(0),s=function(e){var t=void 0!==e&&null!==e;return(0,c.isDevelopment)()&&t?((0,c.isObject)(e)||(0,c.toError)("Expected valid schema object, but got - "+e),function(t){(0,o.validatePredicates)([t.conditions],e),(0,o.validateConditionFields)([t.conditions],e)}):function(){}},a=function e(t,r){var o=this;n(this,e),this.addRule=function(e){o.validate(e),o.rules.push(e)},this.run=function(e){return Promise.resolve((0,i.default)(o.rules,e))},this.rules=[],this.validate=s(r),t&&(0,c.toArray)(t).forEach(function(e){return o.addRule(e)})};t.default=a},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){return(0,h.isObject)(e)?(0,h.flatMap)(Object.keys(e),function(r){var n=e[r];if((0,h.isObject)(n)||r===v.NOT){if(r===v.OR||r===v.AND)return Array.isArray(n)?(0,h.flatMap)(n,function(e){return o(e,t)}):((0,h.toError)('"'+r+'" must be an array'),[]);var u=o(n,t);return u.push(r),u}return o(r,t)}):[e]}function u(e,t){return(0,h.flatMap)(Object.keys(e),function(r){var i=e[r];if(r===v.OR||r===v.AND)return Array.isArray(i)?(0,h.flatMap)(i,function(e){return u(e,t)}):((0,h.toError)(r+" with "+JSON.stringify(i)+" must be an Array"),[]);if(r===v.NOT)return u(i,t);if(-1!==r.indexOf(".")){var c=r.indexOf("."),s=r.substr(0,c),a=(0,h.extractRefSchema)(s,t);if(a){return u(n({},r.substr(c+1),i),a)}return(0,h.toError)("Can't find schema for "+s),[]}if((0,h.isRefArray)(r,t)){var f=(0,h.extractRefSchema)(r,t);return f?u(i,f):[]}return t.properties[r]?o(i,t):((0,h.toError)("Can't validate "+r),[])})}function i(e,t){var r=(0,h.flatMap)(e,function(e){return u(e,t)});return r.filter(function(e,t,n){return r.indexOf(e)===t})}function c(e,t){return i(e,t).filter(function(e){return b.includes(e)||void 0===m.default[e]})}function s(e,t){var r=c(e,t);0!==r.length&&(0,h.toError)("Rule contains invalid predicates "+r)}function a(e){return Array.isArray(e)?(0,h.flatMap)(e,a):(0,h.isObject)(e)?(0,h.flatMap)(Object.keys(e),function(t){return a(e[t])}):"string"==typeof e&&e.startsWith("$")?[e.substr(1)]:[]}function f(e){return(0,h.flatMap)(Object.keys(e),function(t){var r=e[t];return t===v.OR||t===v.AND?(0,h.flatMap)(r,f):t===v.NOT?f(r):[t].concat(a(r))})}function l(e){var t=(0,h.flatMap)(e,f);return t.filter(function(e){return-1===e.indexOf(".")}).filter(function(e,r,n){return t.indexOf(e)===r})}function p(e,t){return l(e).filter(function(e){return void 0===t.properties[e]})}function d(e,t){var r=p(e,t);0!==r.length&&(0,h.toError)("Rule contains invalid fields "+r)}Object.defineProperty(t,"__esModule",{value:!0}),t.predicatesFromRule=o,t.predicatesFromCondition=u,t.listAllPredicates=i,t.listInvalidPredicates=c,t.validatePredicates=s,t.fieldsFromPredicates=a,t.fieldsFromCondition=f,t.listAllFields=l,t.listInvalidFields=p,t.validateConditionFields=d;var y=r(4),m=function(e){return e&&e.__esModule?e:{default:e}}(y),h=r(0),v=r(3),b=["and","or","ternary","every","some","curry","partial","complement","mod"]},function(e,t,r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),c=r(2),s=e.exports,a=function(){function e(){u(this,e),this.lazy=[]}return i(e,[{key:"valueOf",value:function(){return this.val()}},{key:"val",value:function(){return this.lazy[this.method](function(e){return e[0].apply(null,e[1])})}}]),e}(),f=function(e){function t(){u(this,t);var e=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.method="every",e}return o(t,e),t}(a),l=function(e){function t(){u(this,t);var e=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.method="some",e}return o(t,e),t}(a);[f,l].forEach(function(e){Object.keys(c).reduce(function(e,t){return c.fn(c[t])?(e[t]=function(){return this.lazy.push([c[t],arguments]),this},e):e},e.prototype)}),s.all=s.every=function(){return new f},s.any=s.some=function(){return new l}},function(e,t,r){"use strict";var n=r(2),o=r(1),u=e.exports;u.ternary=function(e,t,r){return n.bool(e)?e?t:r:n.undef(t)?o.partial(u.ternary,e):n.undef(r)?o.partial(u.ternary,e,t):u.ternary(e(t,r),t,r)};var i=Array.prototype.every,c=Array.prototype.some;u.and=function(){var e=arguments;return function(t){return i.call(e,function(e){return e(t)})}},u.or=function(){var e=arguments;return function(t){return c.call(e,function(e){return e(t)})}}},function(e,t,r){"use strict";function n(e,t){return(0,o.flatMap)(e,function(e){var r=e.conditions,n=e.event;return(0,i.default)(r,t)?(0,o.toArray)(n):[]})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var o=r(0),u=r(11),i=function(e){return e&&e.__esModule?e:{default:e}}(u)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return Array.isArray(e)?e.map(function(e){return o(e,t)}):(0,i.isObject)(e)?Object.keys(e).reduce(function(r,n){return r[n]=o(e[n],t),r},{}):"string"==typeof e&&e.startsWith("$")?(0,l.default)(e.substr(1),t):e}function u(e,t){return(0,i.isObject)(e)&&(0,i.isObject)(t)?Object.keys(e).every(function(r){var n=e[r];if(r===a.OR)return n.some(function(e){return u(e,t)});if(r===a.AND)return n.every(function(e){return u(e,t)});if(r===a.NOT)return!u(n,t);var i=(0,l.default)(r,t);if(Array.isArray(i)){return i.some(function(e){return u(n,e)})||(0,s.default)(i,o(n,t))}return(0,s.default)(i,o(n,t))}):((0,i.toError)("Rule "+JSON.stringify(e)+" with "+t+" can't be processed"),!1)}Object.defineProperty(t,"__esModule",{value:!0}),t.toRelCondition=o,t.default=u;var i=r(0),c=r(12),s=n(c),a=r(3),f=r(13),l=n(f)},function(e,t,r){"use strict";function n(e,t){if(Array.isArray(e)){if(e.some(function(e){return s(e,t)}))return!0}return s(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var o=r(4),u=function(e){return e&&e.__esModule?e:{default:e}}(o),i=r(0),c=r(3),s=function e(t,r){return(0,i.isObject)(r)?Object.keys(r).every(function(n){var o=r[n];return n===c.OR||n===c.AND?!!Array.isArray(o)&&(n===c.OR?o.some(function(r){return e(t,r)}):o.every(function(r){return e(t,r)})):n===c.NOT?!e(t,o):!!u.default[n]&&u.default[n](t,o)}):u.default[r](t)}},function(e,t,r){"use strict";function n(e,t){u("arguments:",{path:e,object:t});for(var r=-1,n="[object Array]"===s.call(e)?e:c(i(e)),o=n.length,a=o?t:void 0;++r<o;){if(Object(a)!==a)return;a=a[n[r]]}return u("ref:",a),"function"==typeof a?a():a}var o=r(14),u=r(16)("selectn"),i=r(20),c=r(21),s=Object.prototype.toString;e.exports=o(n)},function(e,t,r){"use strict";function n(e,t){var r=function r(){return 0===arguments.length?r:arguments.length>1?e.apply(t,arguments):o.call(e,t,arguments[0])};return r.uncurry=function(){return e},r}/*! | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSONSchemaForm=t():e.JSONSchemaForm=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=5)}([function(e,t,r){"use strict";function n(e,t){var r=e.replace(/\$/g,".");return(0,d.default)(r,t)}function o(e){return"object"===(void 0===e?"undefined":l(e))&&null!==e}function u(){return!1}function i(e){return Array.isArray(e)?e:[e]}function c(e){if(u())throw new ReferenceError(e);console.error(e)}function s(e,t){return t.properties[e]&&"array"===t.properties[e].type&&t.properties[e].items&&t.properties[e].items.$ref}function a(e,t){return e.startsWith("#/")?(e.substr(2).split("/"),e.substr(2).split("/").reduce(function(e,t){return e[t]},t)):void c("Only local references supported at this point use json-schema-deref")}function f(e,t){return s(e,t)?a(t.properties[e].items.$ref,t):t.properties[e]&&t.properties[e].$ref?a(t.properties[e].$ref,t):t.properties[e]&&"object"===t.properties[e].type?t.properties[e]:void c(e+" has no $ref field ref schema extraction is impossible")}Object.defineProperty(t,"__esModule",{value:!0}),t.flatMap=void 0;var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.selectRef=n,t.isObject=o,t.isDevelopment=u,t.toArray=i,t.toError=c,t.isRefArray=s,t.extractRefSchema=f;var p=r(10),d=function(e){return e&&e.__esModule?e:{default:e}}(p),y=function(e,t){return e.concat(t)};t.flatMap=function(e,t){return e.map(t).reduce(y,[])}},function(e,t,r){"use strict";var n=e.exports,o=Array.prototype.slice,u=function(e,t){return e.toString=function(){return t.toString()},e.src=t,e},i=n.curry=function(e){return u(function(t,r){switch(arguments.length){case 0:throw new TypeError("Function called with no arguments");case 1:return u(function(r){return e(t,r)},e)}return e(t,r)},e)};n.partial=function(e){var t=o.call(arguments,1);return function(){return e.apply(null,t.concat(o.call(arguments)))}},n.complement=n.invert=function(e){return function(){var t=e.apply(null,arguments);return"function"==typeof t?n.complement(t):!t}},n.mod=i(function(e,t){return e%t}),n.assign=i(Object.assign||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e})},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(1),u=e.exports,i=o.curry;Object.is?u.is=i(Object.is):u.is=i(function(e,t){return 0===e&&0===t?1/e==1/t:e!==e?t!==t:e===t}),u.exists=function(e){return null!=e},u.truthy=function(e){return!(!e||!u.exists(e))},u.falsey=o.complement(u.truthy),u.equal=i(function(e,t){return e===t}),u.eq=i(function(e,t){return e==t}),u.null=u.equal(null),u.undef=u.equal(void 0),u.lt=u.less=i(function(e,t){return e<t}),u.ltEq=u.le=u.lessEq=i(function(e,t){return u.equal(e,t)||u.less(e,t)}),u.gt=u.greater=i(function(e,t){return e>t}),u.gtEq=u.ge=u.greaterEq=i(function(e,t){return u.equal(e,t)||u.greater(e,t)});var c=Object.prototype.toString,s=i(function(e,t){return u.equal(e,c.call(t))});u.object=u.obj=function(e){return e===Object(e)},u.array=u.arr=Array.isArray||s("[object Array]"),u.date=s("[object Date]"),u.regex=u.regexp=u.rgx=u.RegExp=s("[object RegExp]"),u.finite=Number.isFinite||function(e){return u.number(e)&&isFinite(e)},u.nan=u.NaN=u.is(NaN),u.instance=i(function(e,t){return t instanceof e}),u.arguments=s("[object Arguments]"),u.error=u.instance(Error);var a=i(function(e,t){return u.equal(e,void 0===t?"undefined":n(t))});[["function","fn"],["string","str"],["boolean","bool"]].reduce(function(e,t){return e[t[0]]=e[t[1]]=a(t[0]),e},u),u.number=u.num=function(e){return"number"==typeof e&&u.not.NaN(e)},u.int=function(e){return u.num(e)&&u.zero(o.mod(e,1))},u.pos=function(e){return u.num(e)&&u.greater(e,0)},u.neg=function(e){return u.num(e)&&u.less(e,0)},u.zero=function(e){return u.num(e)&&u.equal(e,0)},u.even=function(e){return u.num(e)&&u.not.zero(e)&&u.zero(o.mod(e,2))},u.odd=function(e){return u.num(e)&&u.not.zero(e)&&u.not.zero(o.mod(e,2))},u.contains=u.includes=i(function(e,t){if(!u.array(e)&&!u.string(e))throw new TypeError("Expected an array or string");return!(u.string(e)&&!u.string(t))&&(u.NaN(t)?e.some(u.NaN):!!~e.indexOf(t))});var f=Object.prototype.hasOwnProperty;u.has=i(function(e,t){return f.call(e,t)}),u.empty=function(e){if(u.not.exists(e))return!0;if(u.arr(e)||u.str(e))return!e.length;if(u.obj(e)){for(var t in e)if(u.has(e,t))return!1;return!0}throw new TypeError},u.primitive=function(e){return u.string(e)||u.num(e)||u.bool(e)||u.null(e)||u.undef(e)||u.NaN(e)},u.matches=i(function(e,t){return e.test(t)}),u.not=Object.keys(u).reduce(function(e,t){return e[t]=o.complement(u[t]),e},{})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.OR="or",t.AND="and",t.NOT="not"},function(e,t,r){"use strict";var n=r(1),o={};o.VERSION="1.0.0",[n,r(2),r(8),r(9)].reduce(n.assign,o),e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6),o=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=o.default},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=r(7),u=r(19),i=function(e){return e&&e.__esModule?e:{default:e}}(u),c=r(0),s=function(e){var t=void 0!==e&&null!==e;return(0,c.isDevelopment)()&&t?((0,c.isObject)(e)||(0,c.toError)("Expected valid schema object, but got - "+e),function(t){(0,o.validatePredicates)([t.conditions],e),(0,o.validateConditionFields)([t.conditions],e)}):function(){}},a=function e(t,r){var o=this;n(this,e),this.addRule=function(e){o.validate(e),o.rules.push(e)},this.run=function(e){return Promise.resolve((0,i.default)(o.rules,e))},this.rules=[],this.validate=s(r),t&&(0,c.toArray)(t).forEach(function(e){return o.addRule(e)})};t.default=a},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){return(0,h.isObject)(e)?(0,h.flatMap)(Object.keys(e),function(r){var n=e[r];if((0,h.isObject)(n)||r===v.NOT){if(r===v.OR||r===v.AND)return Array.isArray(n)?(0,h.flatMap)(n,function(e){return o(e,t)}):((0,h.toError)('"'+r+'" must be an array'),[]);var u=o(n,t);return u.push(r),u}return o(r,t)}):[e]}function u(e,t){return(0,h.flatMap)(Object.keys(e),function(r){var i=e[r];if(r===v.OR||r===v.AND)return Array.isArray(i)?(0,h.flatMap)(i,function(e){return u(e,t)}):((0,h.toError)(r+" with "+JSON.stringify(i)+" must be an Array"),[]);if(r===v.NOT)return u(i,t);if(-1!==r.indexOf(".")){var c=r.indexOf("."),s=r.substr(0,c),a=(0,h.extractRefSchema)(s,t);if(a){return u(n({},r.substr(c+1),i),a)}return(0,h.toError)("Can't find schema for "+s),[]}if((0,h.isRefArray)(r,t)){var f=(0,h.extractRefSchema)(r,t);return f?u(i,f):[]}return t.properties[r]?o(i,t):((0,h.toError)("Can't validate "+r),[])})}function i(e,t){var r=(0,h.flatMap)(e,function(e){return u(e,t)});return r.filter(function(e,t,n){return r.indexOf(e)===t})}function c(e,t){return i(e,t).filter(function(e){return b.includes(e)||void 0===m.default[e]})}function s(e,t){var r=c(e,t);0!==r.length&&(0,h.toError)("Rule contains invalid predicates "+r)}function a(e){return Array.isArray(e)?(0,h.flatMap)(e,a):(0,h.isObject)(e)?(0,h.flatMap)(Object.keys(e),function(t){return a(e[t])}):"string"==typeof e&&e.startsWith("$")?[e.substr(1)]:[]}function f(e){return(0,h.flatMap)(Object.keys(e),function(t){var r=e[t];return t===v.OR||t===v.AND?(0,h.flatMap)(r,f):t===v.NOT?f(r):[t].concat(a(r))})}function l(e){var t=(0,h.flatMap)(e,f);return t.filter(function(e){return-1===e.indexOf(".")}).filter(function(e,r,n){return t.indexOf(e)===r})}function p(e,t){return l(e).filter(function(e){return void 0===t.properties[e]})}function d(e,t){var r=p(e,t);0!==r.length&&(0,h.toError)("Rule contains invalid fields "+r)}Object.defineProperty(t,"__esModule",{value:!0}),t.predicatesFromRule=o,t.predicatesFromCondition=u,t.listAllPredicates=i,t.listInvalidPredicates=c,t.validatePredicates=s,t.fieldsFromPredicates=a,t.fieldsFromCondition=f,t.listAllFields=l,t.listInvalidFields=p,t.validateConditionFields=d;var y=r(4),m=function(e){return e&&e.__esModule?e:{default:e}}(y),h=r(0),v=r(3),b=["and","or","ternary","every","some","curry","partial","complement","mod"]},function(e,t,r){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),c=r(2),s=e.exports,a=function(){function e(){u(this,e),this.lazy=[]}return i(e,[{key:"valueOf",value:function(){return this.val()}},{key:"val",value:function(){return this.lazy[this.method](function(e){return e[0].apply(null,e[1])})}}]),e}(),f=function(e){function t(){u(this,t);var e=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.method="every",e}return o(t,e),t}(a),l=function(e){function t(){u(this,t);var e=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.method="some",e}return o(t,e),t}(a);[f,l].forEach(function(e){Object.keys(c).reduce(function(e,t){return c.fn(c[t])?(e[t]=function(){return this.lazy.push([c[t],arguments]),this},e):e},e.prototype)}),s.all=s.every=function(){return new f},s.any=s.some=function(){return new l}},function(e,t,r){"use strict";var n=r(2),o=r(1),u=e.exports;u.ternary=function(e,t,r){return n.bool(e)?e?t:r:n.undef(t)?o.partial(u.ternary,e):n.undef(r)?o.partial(u.ternary,e,t):u.ternary(e(t,r),t,r)};var i=Array.prototype.every,c=Array.prototype.some;u.and=function(){var e=arguments;return function(t){return i.call(e,function(e){return e(t)})}},u.or=function(){var e=arguments;return function(t){return c.call(e,function(e){return e(t)})}}},function(e,t,r){"use strict";function n(e,t){u("arguments:",{path:e,object:t});for(var r=-1,n="[object Array]"===s.call(e)?e:c(i(e)),o=n.length,a=o?t:void 0;++r<o;){if(Object(a)!==a)return;a=a[n[r]]}return u("ref:",a),"function"==typeof a?a():a}var o=r(11),u=r(13)("selectn"),i=r(17),c=r(18),s=Object.prototype.toString;e.exports=o(n)},function(e,t,r){"use strict";function n(e,t){var r=function r(){return 0===arguments.length?r:arguments.length>1?e.apply(t,arguments):o.call(e,t,arguments[0])};return r.uncurry=function(){return e},r}/*! | ||
* imports. | ||
*/ | ||
var o=Function.prototype.bind||r(15);/*! | ||
var o=Function.prototype.bind||r(12);/*! | ||
* exports. | ||
*/ | ||
e.exports=n},function(e,t,r){"use strict";e.exports=function(e){var t,r=this;if(arguments.length<2)t=function(){if(this instanceof t){var n=r.apply(this,arguments);return Object(n)===n?n:this}return r.apply(e,arguments)};else{for(var n=new Array(arguments.length-1),o=1;o<arguments.length;o++)n[o-1]=arguments[o];t=function(){var o,u=n.length,i=new Array(u+arguments.length);for(o=0;o<u;o++)i[o]=n[o];for(o=0;o<arguments.length;o++)i[u+o]=arguments[o];if(this instanceof t){var c=r.apply(this,i);return Object(c)===c?c:this}return r.apply(e,i)}}return t.prototype=r.prototype,t}},function(e,t,r){"use strict";(function(n){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function u(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,u=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(u=o))}),e.splice(u,0,n)}}function i(){return"object"===("undefined"==typeof console?"undefined":a(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function c(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function s(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=Object({NODE_ENV:"production"}).DEBUG),e}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t=e.exports=r(18),t.log=i,t.formatArgs=u,t.save=c,t.load=s,t.useColors=o,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(s())}).call(t,r(17))},function(e,t,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(p===clearTimeout)return clearTimeout(e);if((p===o||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(e);try{return p(e)}catch(t){try{return p.call(null,e)}catch(t){return p.call(this,e)}}}function c(){h&&y&&(h=!1,y.length?m=y.concat(m):v=-1,m.length&&s())}function s(){if(!h){var e=u(c);h=!0;for(var t=m.length;t;){for(y=m,m=[];++v<t;)y&&y[v].run();v=-1,t=m.length}y=null,h=!1,i(e)}}function a(e,t){this.fun=e,this.array=t}function f(){}var l,p,d=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{p="function"==typeof clearTimeout?clearTimeout:o}catch(e){p=o}}();var y,m=[],h=!1,v=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];m.push(new a(e,t)),1!==m.length||h||u(s)},a.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=f,d.addListener=f,d.once=f,d.off=f,d.removeListener=f,d.removeAllListeners=f,d.emit=f,d.prependListener=f,d.prependOnceListener=f,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,r){"use strict";function n(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function o(e){function r(){if(r.enabled){var e=r,n=+new Date,o=n-(a||n);e.diff=o,e.prev=a,e.curr=n,a=n;for(var u=new Array(arguments.length),i=0;i<u.length;i++)u[i]=arguments[i];u[0]=t.coerce(u[0]),"string"!=typeof u[0]&&u.unshift("%O");var c=0;u[0]=u[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=u[c];r=o.call(e,i),u.splice(c,1),c--}return r}),t.formatArgs.call(e,u);(r.log||t.log||console.log.bind(console)).apply(e,u)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=n(e),"function"==typeof t.init&&t.init(r),r}function u(e){t.save(e),t.names=[],t.skips=[];for(var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length,o=0;o<n;o++)r[o]&&(e=r[o].replace(/\*/g,".*?"),"-"===e[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))}function i(){t.enable("")}function c(e){var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1}function s(e){return e instanceof Error?e.stack||e.message:e}t=e.exports=o.debug=o.default=o,t.coerce=s,t.disable=i,t.enable=u,t.enabled=c,t.humanize=r(19),t.names=[],t.skips=[],t.formatters={};var a},function(e,t,r){"use strict";function n(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*f;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function o(e){return e>=l?Math.round(e/l)+"d":e>=f?Math.round(e/f)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function u(e){return i(e,l,"day")||i(e,f,"hour")||i(e,a,"minute")||i(e,s,"second")||e+" ms"}function i(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=1e3,a=60*s,f=60*a,l=24*f,p=365.25*l;e.exports=function(e,t){t=t||{};var r=void 0===e?"undefined":c(e);if("string"===r&&e.length>0)return n(e);if("number"===r&&!1===isNaN(e))return t.long?u(e):o(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";function n(e){return"[object String]"=={}.toString.call(e)?e.replace(o,".$1").replace(u,""):""}/*! | ||
e.exports=n},function(e,t,r){"use strict";e.exports=function(e){var t,r=this;if(arguments.length<2)t=function(){if(this instanceof t){var n=r.apply(this,arguments);return Object(n)===n?n:this}return r.apply(e,arguments)};else{for(var n=new Array(arguments.length-1),o=1;o<arguments.length;o++)n[o-1]=arguments[o];t=function(){var o,u=n.length,i=new Array(u+arguments.length);for(o=0;o<u;o++)i[o]=n[o];for(o=0;o<arguments.length;o++)i[u+o]=arguments[o];if(this instanceof t){var c=r.apply(this,i);return Object(c)===c?c:this}return r.apply(e,i)}}return t.prototype=r.prototype,t}},function(e,t,r){"use strict";(function(n){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function u(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,u=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(u=o))}),e.splice(u,0,n)}}function i(){return"object"===("undefined"==typeof console?"undefined":a(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function c(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function s(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=Object({NODE_ENV:"production"}).DEBUG),e}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t=e.exports=r(15),t.log=i,t.formatArgs=u,t.save=c,t.load=s,t.useColors=o,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(s())}).call(t,r(14))},function(e,t,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(p===clearTimeout)return clearTimeout(e);if((p===o||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(e);try{return p(e)}catch(t){try{return p.call(null,e)}catch(t){return p.call(this,e)}}}function c(){h&&y&&(h=!1,y.length?m=y.concat(m):v=-1,m.length&&s())}function s(){if(!h){var e=u(c);h=!0;for(var t=m.length;t;){for(y=m,m=[];++v<t;)y&&y[v].run();v=-1,t=m.length}y=null,h=!1,i(e)}}function a(e,t){this.fun=e,this.array=t}function f(){}var l,p,d=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{p="function"==typeof clearTimeout?clearTimeout:o}catch(e){p=o}}();var y,m=[],h=!1,v=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];m.push(new a(e,t)),1!==m.length||h||u(s)},a.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=f,d.addListener=f,d.once=f,d.off=f,d.removeListener=f,d.removeAllListeners=f,d.emit=f,d.prependListener=f,d.prependOnceListener=f,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},function(e,t,r){"use strict";function n(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}function o(e){function r(){if(r.enabled){var e=r,n=+new Date,o=n-(a||n);e.diff=o,e.prev=a,e.curr=n,a=n;for(var u=new Array(arguments.length),i=0;i<u.length;i++)u[i]=arguments[i];u[0]=t.coerce(u[0]),"string"!=typeof u[0]&&u.unshift("%O");var c=0;u[0]=u[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=u[c];r=o.call(e,i),u.splice(c,1),c--}return r}),t.formatArgs.call(e,u);(r.log||t.log||console.log.bind(console)).apply(e,u)}}return r.namespace=e,r.enabled=t.enabled(e),r.useColors=t.useColors(),r.color=n(e),"function"==typeof t.init&&t.init(r),r}function u(e){t.save(e),t.names=[],t.skips=[];for(var r=("string"==typeof e?e:"").split(/[\s,]+/),n=r.length,o=0;o<n;o++)r[o]&&(e=r[o].replace(/\*/g,".*?"),"-"===e[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))}function i(){t.enable("")}function c(e){var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1}function s(e){return e instanceof Error?e.stack||e.message:e}t=e.exports=o.debug=o.default=o,t.coerce=s,t.disable=i,t.enable=u,t.enabled=c,t.humanize=r(16),t.names=[],t.skips=[],t.formatters={};var a},function(e,t,r){"use strict";function n(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*f;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function o(e){return e>=l?Math.round(e/l)+"d":e>=f?Math.round(e/f)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function u(e){return i(e,l,"day")||i(e,f,"hour")||i(e,a,"minute")||i(e,s,"second")||e+" ms"}function i(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=1e3,a=60*s,f=60*a,l=24*f,p=365.25*l;e.exports=function(e,t){t=t||{};var r=void 0===e?"undefined":c(e);if("string"===r&&e.length>0)return n(e);if("number"===r&&!1===isNaN(e))return t.long?u(e):o(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";function n(e){return"[object String]"=={}.toString.call(e)?e.replace(o,".$1").replace(u,""):""}/*! | ||
* exports. | ||
@@ -16,3 +16,3 @@ */ | ||
*/ | ||
e.exports=n}])}); | ||
e.exports=n},function(e,t,r){"use strict";function n(e,t){return(0,o.flatMap)(e,function(e){var r=e.conditions,n=e.event;return(0,i.default)(r,t)?(0,o.toArray)(n):[]})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var o=r(0),u=r(20),i=function(e){return e&&e.__esModule?e:{default:e}}(u)},function(e,t,r){"use strict";function n(e,t){return Array.isArray(e)?e.map(function(e){return n(e,t)}):(0,u.isObject)(e)?Object.keys(e).reduce(function(r,o){return r[o]=n(e[o],t),r},{}):"string"==typeof e&&e.startsWith("$")?(0,u.selectRef)(e.substr(1),t):e}function o(e,t){return(0,u.isObject)(e)&&(0,u.isObject)(t)?Object.keys(e).every(function(r){var i=e[r];if(r===s.OR)return i.some(function(e){return o(e,t)});if(r===s.AND)return i.every(function(e){return o(e,t)});if(r===s.NOT)return!o(i,t);var a=(0,u.selectRef)(r,t);if(Array.isArray(a)){return a.some(function(e){return o(i,e)})||(0,c.default)(a,n(i,t))}return(0,c.default)(a,n(i,t))}):((0,u.toError)("Rule "+JSON.stringify(e)+" with "+t+" can't be processed"),!1)}Object.defineProperty(t,"__esModule",{value:!0}),t.toRelCondition=n,t.default=o;var u=r(0),i=r(21),c=function(e){return e&&e.__esModule?e:{default:e}}(i),s=r(3)},function(e,t,r){"use strict";function n(e,t){if(Array.isArray(e)){if(e.some(function(e){return s(e,t)}))return!0}return s(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var o=r(4),u=function(e){return e&&e.__esModule?e:{default:e}}(o),i=r(0),c=r(3),s=function e(t,r){return(0,i.isObject)(r)?Object.keys(r).every(function(n){var o=r[n];return n===c.OR||n===c.AND?!!Array.isArray(o)&&(n===c.OR?o.some(function(r){return e(t,r)}):o.every(function(r){return e(t,r)})):n===c.NOT?!e(t,o):!!u.default[n]&&u.default[n](t,o)}):u.default[r](t)}}])}); | ||
//# sourceMappingURL=json-rules-engine-simplified.js.map |
@@ -17,6 +17,2 @@ "use strict"; | ||
var _selectn = require("selectn"); | ||
var _selectn2 = _interopRequireDefault(_selectn); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -35,3 +31,3 @@ | ||
} else if (typeof refCondition === "string" && refCondition.startsWith("$")) { | ||
return (0, _selectn2.default)(refCondition.substr(1), formData); | ||
return (0, _utils.selectRef)(refCondition.substr(1), formData); | ||
} else { | ||
@@ -60,3 +56,3 @@ return refCondition; | ||
} else { | ||
var refVal = (0, _selectn2.default)(ref, formData); | ||
var refVal = (0, _utils.selectRef)(ref, formData); | ||
if (Array.isArray(refVal)) { | ||
@@ -63,0 +59,0 @@ var condMeatOnce = refVal.some(function (val) { |
@@ -6,5 +6,7 @@ "use strict"; | ||
}); | ||
exports.flatMap = undefined; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.selectRef = selectRef; | ||
exports.isObject = isObject; | ||
@@ -16,2 +18,14 @@ exports.isDevelopment = isDevelopment; | ||
exports.extractRefSchema = extractRefSchema; | ||
var _selectn = require("selectn"); | ||
var _selectn2 = _interopRequireDefault(_selectn); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function selectRef(field, formData) { | ||
var ref = field.replace(/\$/g, "."); | ||
return (0, _selectn2.default)(ref, formData); | ||
} | ||
function isObject(obj) { | ||
@@ -18,0 +32,0 @@ return (typeof obj === "undefined" ? "undefined" : _typeof(obj)) === "object" && obj !== null; |
{ | ||
"name": "json-rules-engine-simplified", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Simpl JSON rules engine", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -485,2 +485,18 @@ [![Build Status](https://travis-ci.org/RxNT/json-rules-engine-simplified.svg?branch=master)](https://travis-ci.org/RxNT/json-rules-engine-simplified) | ||
## Logic on nested objects | ||
Support of nested structures with [selectn](https://github.com/wilmoore/selectn.js), so basically any query you can define in selectn you can use here. | ||
For example if in previous example, age would be a part of person object, we could work with it like this: | ||
```js | ||
let rules = [ { conditions: { "person.age": { range: [ 20, 40 ] } } } ]; | ||
``` | ||
Also in order to support systems where keys with "." not allowed (for example if you would like to store data in mongo), you can use `$` to separate references: | ||
For example, this is the same condition, but instead of `.` it uses `$`: | ||
```js | ||
let rules = [ { conditions: { "person$age": { range: [ 20, 40 ] } } } ]; | ||
``` | ||
## Relevant conditional logic | ||
@@ -487,0 +503,0 @@ |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
198841
495
579
1