Files
pole-book/server/node_modules/@ucast/mongo/dist/umd/index.js

3 lines
3.3 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@ucast/core")):"function"==typeof define&&define.amd?define(["exports","@ucast/core"],t):t(((e=e||self).ucast=e.ucast||{},e.ucast.mongo={}),e.ucast.core)}(this,(function(e,t){"use strict";function r(e,t){if(!Array.isArray(t))throw new Error('"'+e.name+'" expects value to be an array')}function n(e,t){if(r(e,t),!t.length)throw new Error('"'+e.name+'" expects to have at least one element in array')}var o=function(e){return function(t,r){if(typeof r!==e)throw new Error('"'+t.name+'" expects value to be a "'+e+'"')}},i={type:"compound",validate:n,parse:function(e,r,n){var o=n.parse,i=r.map((function(e){return o(e)}));return t.optimizedCompoundCondition(e.name,i)}},a=i,f={type:"compound",validate:n},u={type:"field",validate:function(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw new Error('"'+e.name+'" expects to receive either regular expression or object of field operators')},parse:function(e,r,n){var o=r instanceof RegExp?new t.FieldCondition("regex",n.field,r):n.parse(r,n);return new t.CompoundCondition(e.name,[o])}},c={type:"field",validate:function(e,t){if(!t||t.constructor!==Object)throw new Error('"'+e.name+'" expects to receive an object with nested query or field level operators')},parse:function(e,r,n){var o=n.parse,i=n.field,a=(0,n.hasOperators)(r)?o(r,{field:t.ITSELF}):o(r);return new t.FieldCondition(e.name,i,a)}},s={type:"field",validate:o("number")},p={type:"field",validate:r},l=p,d=p,v={type:"field",validate:function(e,t){if(!Array.isArray(t)||2!==t.length)throw new Error('"'+e.name+'" expects an array with 2 numeric elements')}},y={type:"field",validate:o("boolean")},w={type:"field",validate:function(e,t){if(!("string"==typeof t||"number"==typeof t||t instanceof Date))throw new Error('"'+e.name+'" expects value to be comparable (i.e., string, number or date)')}},x=w,$=x,h=x,b={type:"field"},g=b,m={type:"field",validate:function(e,t){if(!(t instanceof RegExp)&&"string"!=typeof t)throw new Error('"'+e.name+'" expects value to be a regular expression or a string that represents regular expression')},parse:function(e,r,n){var o="string"==typeof r?new RegExp(r,n.query.$options||""):r;return new t.FieldCondition(e.name,n.field,o)}},E={type:"field",parse:function(){return t.NULL_CONDITION}},j={type:"document",validate:o("function")},O=Object.freeze({__proto__:null,$and:i,$or:a,$nor:f,$not:u,$elemMatch:c,$size:s,$in:p,$nin:l,$all:d,$mod:v,$exists:y,$gte:w,$gt:x,$lt:$,$lte:h,$eq:b,$ne:g,$regex:m,$options:E,$where:j});var _=function(e){var r,n;function o(t){return e.call(this,t,{defaultOperatorName:"$eq",operatorToConditionName:function(e){return e.slice(1)}})||this}return n=e,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,o.prototype.parse=function(r,n){return n&&n.field?t.buildAnd(this.parseFieldOperators(n.field,r)):e.prototype.parse.call(this,r)},o}(t.ObjectQueryParser),q=O;Object.defineProperty(e,"defaultParsers",{enumerable:!0,get:function(){return t.defaultInstructionParsers}}),e.$all=d,e.$and=i,e.$elemMatch=c,e.$eq=b,e.$exists=y,e.$gt=x,e.$gte=w,e.$in=p,e.$lt=$,e.$lte=h,e.$mod=v,e.$ne=g,e.$nin=l,e.$nor=f,e.$not=u,e.$options=E,e.$or=a,e.$regex=m,e.$size=s,e.$where=j,e.MongoQueryParser=_,e.allParsingInstructions=q,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map