node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
function t(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function r(){return(r=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function n(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r}var i=function(){function r(t,r){this.operator=t,this.value=r,Object.defineProperty(this,"t",{writable:!0})}var n,i,e;return r.prototype.addNote=function(t){this.t=this.t||[],this.t.push(t)},n=r,(i=[{key:"notes",get:function(){return this.t}}])&&t(n.prototype,i),e&&t(n,e),r}(),e=function(t){function r(){return t.apply(this,arguments)||this}return n(r,t),r}(i),o=function(t){function r(r,n){if(!Array.isArray(n))throw new Error('"'+r+'" operator expects to receive an array of conditions');return t.call(this,r,n)||this}return n(r,t),r}(e),u="__itself__",f=function(t){function r(r,n,i){var e;return(e=t.call(this,r,i)||this).field=n,e}return n(r,t),r}(i),a=new e("__null__",null),c=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function s(t,r){return r instanceof o&&r.operator===t}function h(t,r){return 1===r.length?r[0]:new o(t,function t(r,n,i){for(var e=i||[],o=0,u=n.length;o<u;o++){var f=n[o];s(r,f)?t(r,f.value,e):e.push(f)}return e}(t,r))}var v=function(t){return t},d=function(){return Object.create(null)},l=Object.defineProperty(d(),"__@type@__",{value:"ignore value"});function p(t,r,n){if(void 0===n&&(n=!1),!t||t&&t.constructor!==Object)return!1;for(var i in t){if(c(t,i)&&c(r,i)&&(!n||t[i]!==l))return!0}return!1}function w(t){var r=[];for(var n in t)c(t,n)&&t[n]!==l&&r.push(n);return r}function b(t,r){r!==a&&t.push(r)}var y=function(t){return h("and",t)},O=function(t){return h("or",t)},j={compound:function(t,r,n){var i=(Array.isArray(r)?r:[r]).map((function(t){return n.parse(t)}));return new o(t.name,i)},field:function(t,r,n){return new f(t.name,n.field,r)},document:function(t,r){return new e(t.name,r)}},_=function(){function t(t,n){var i=this;void 0===n&&(n=d()),this.i=void 0,this.o=void 0,this.u=void 0,this.s=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.s={operatorToConditionName:n.operatorToConditionName||v,defaultOperatorName:n.defaultOperatorName||"eq",mergeFinalConditions:n.mergeFinalConditions||y},this.i=Object.keys(t).reduce((function(n,e){return n[e]=r({name:i.s.operatorToConditionName(e)},t[e]),n}),{}),this.o=r({},n.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:function(t){return p(t,i.i,n.useIgnoreValue)}}),this.u=r({},n.documentContext,{parse:this.parse,query:{}}),this.h=n.useIgnoreValue?w:Object.keys}var n=t.prototype;return n.setParse=function(t){this.parse=t,this.o.parse=t,this.u.parse=t},n.parseField=function(t,r,n,i){var e=this.i[r];if(!e)throw new Error('Unsupported operator "'+r+'"');if("field"!==e.type)throw new Error("Unexpected "+e.type+' operator "'+r+'" at field level');return this.o.field=t,this.o.query=i,this.parseInstruction(e,n,this.o)},n.parseInstruction=function(t,r,n){return"function"==typeof t.validate&&t.validate(t,r),(t.parse||j[t.type])(t,r,n)},n.parseFieldOperators=function(t,r){for(var n=[],i=this.h(r),e=0,o=i.length;e<o;e++){var u=i[e];if(!this.i[u])throw new Error('Field query for "'+t+'" may contain only operators or a plain object as a value');b(n,this.parseField(t,u,r[u],r))}return n},n.parse=function(t){var r=[],n=this.h(t);this.u.query=t;for(var i=0,e=n.length;i<e;i++){var o=n[i],u=t[o],f=this.i[o];if(f){if("document"!==f.type&&"compound"!==f.type)throw new Error('Cannot use parsing instruction for operator "'+o+'" in "document" context as it is supposed to be used in "'+f.type+'" context');b(r,this.parseInstruction(f,u,this.u))}else this.o.hasOperators(u)?r.push.apply(r,this.parseFieldOperators(o,u)):b(r,this.parseField(o,this.s.defaultOperatorName,u,t))}return this.s.mergeFinalConditions(r)},t}();function m(t,r){var n=t[r];if("function"!=typeof n)throw new Error('Unable to interpret "'+r+'" condition. Did you forget to register interpreter for it?');return n}function g(t){return t.operator}function E(t,n){var i,e=n,o=e&&e.getInterpreterName||g;switch(e?e.numberOfArguments:0){case 1:i=function(r){var n=o(r,e);return m(t,n)(r,u)};break;case 3:i=function(r,n,i){var f=o(r,e);return m(t,f)(r,n,i,u)};break;default:i=function(r,n){var i=o(r,e);return m(t,i)(r,n,u)}}var u=r({},e,{interpret:i});return u.interpret}function x(t,r){return function(n){for(var i=arguments.length,e=new Array(i>1?i-1:0),o=1;o<i;o++)e[o-1]=arguments[o];var u=t.apply(void 0,[n].concat(e)),f=r.bind(null,u);return f.ast=u,f}}var q=_.prototype.parseInstruction;export{o as CompoundCondition,i as Condition,e as DocumentCondition,f as FieldCondition,u as ITSELF,a as NULL_CONDITION,_ as ObjectQueryParser,y as buildAnd,O as buildOr,E as createInterpreter,x as createTranslatorFactory,j aLine truncated
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/Condition.ts","../../src/utils.ts","../../src/builder.ts","../../src/parsers/defaultInstructionParsers.ts","../../src/parsers/ObjectQueryParser.ts","../../src/interpreter.ts","../../src/translator.ts","../../src/index.ts"],"sourcesContent":["export interface Note<T> {\n type: string\n message?: string\n originalValue?: T\n}\n\nexport abstract class Condition<T = unknown> {\n private _notes!: Note<T>[];\n\n constructor(\n public readonly operator: string,\n public readonly value: T\n ) {\n Object.defineProperty(this, '_notes', {\n writable: true\n });\n }\n\n get notes(): ReadonlyArray<Note<T>> | undefined {\n return this._notes;\n }\n\n addNote(note: Note<T>) {\n this._notes = this._notes || [];\n this._notes.push(note);\n }\n}\n\nexport class DocumentCondition<T> extends Condition<T> {\n}\n\nexport class CompoundCondition<T extends Condition = Condition> extends DocumentCondition<T[]> {\n constructor(operator: string, conditions: T[]) {\n if (!Array.isArray(conditions)) {\n throw new Error(`\"${operator}\" operator expects to receive an array of conditions`);\n }\n\n super(operator, conditions);\n }\n}\n\nexport const ITSELF = '__itself__';\nexport class FieldCondition<T = unknown> extends Condition<T> {\n public readonly field!: string | typeof ITSELF;\n\n constructor(operator: string, field: string | typeof ITSELF, value: T) {\n super(operator, value);\n this.field = field;\n }\n}\n\nexport const NULL_CONDITION = new DocumentCondition('__null__', null);\nexport type ConditionValue<T> = T extends Condition<infer V> ? V : unknown;\n","import { Condition, CompoundCondition, NULL_CONDITION } from './Condition';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);\n\nexport function isCompound(operator: string, condition: Condition): condition is CompoundCondition {\n return condition instanceof CompoundCondition && condition.operator === operator;\n}\n\nfunction flattenConditions<T extends Condition>(\n operator: string,\n conditions: T[],\n aggregatedResult?: T[]\n) {\n const flatConditions: T[] = aggregatedResult || [];\n\n for (let i = 0, length = conditions.length; i < length; i++) {\n const currentNode = conditions[i];\n\n if (isCompound(operator, currentNode)) {\n flattenConditions(operator, currentNode.value as T[], flatConditions);\n } else {\n flatConditions.push(currentNode);\n }\n }\n\n return flatConditions;\n}\n\nexport function optimizedCompoundCondition<T extends Condition>(operator: string, conditions: T[]) {\n if (conditions.length === 1) {\n return conditions[0];\n }\n\n return new CompoundCondition(operator, flattenConditions(operator, conditions));\n}\n\nexport const identity = <T>(x: T) => x;\nexport const object = () => Object.create(null);\n\nexport const ignoreValue: IgnoreValue = Object.defineProperty(object(), '__@type@__', {\n value: 'ignore value'\n});\nexport interface IgnoreValue {\n readonly ['__@type@__']: 'ignore value'\n}\n\nexport function hasOperators<T>(\n value: any,\n instructions: Record<string, unknown>,\n skipIgnore = false,\n): value is T {\n if (!value || value && value.constructor !== Object) {\n return false;\n }\n\n for (const prop in value) { // eslint-disable-line no-restricted-syntax, guard-for-in\n const hasProp = hasOwnProperty(value, prop) && hasOwnProperty(instructions, prop);\n if (hasProp && (!skipIgnore || value[prop] !== ignoreValue)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function objectKeysSkipIgnore(anyObject: Record<string, unknown>) {\n const keys: string[] = [];\n for (const key in anyObject) { // eslint-disable-line no-restricted-syntax\n if (hasOwnProperty(anyObject, key) && anyObject[key] !== ignoreValue) {\n keys.push(key);\n }\n }\n\n return keys;\n}\n\nexport function pushIfNonNullCondition(conditions: Condition[], condition: Condition) {\n if (condition !== NULL_CONDITION) {\n conditions.push(condition);\n }\n}\n","import { Condition } from './Condition';\nimport { optimizedCompoundCondition } from './utils';\n\nexport const buildAnd = (conditions: Condition[]) => optimizedCompoundCondition('and', conditions);\nexport const buildOr = (conditions: Condition[]) => optimizedCompoundCondition('or', conditions);\n","import {\n FieldCondition,\n CompoundCondition,\n DocumentCondition,\n} from '../Condition';\nimport {\n DocumentInstruction,\n CompoundInstruction,\n FieldInstruction,\n} from '../types';\n\ninterface DefaultParsers {\n compound: Exclude<CompoundInstruction['parse'], undefined>,\n field: Exclude<FieldInstruction['parse'], undefined>,\n document: Exclude<DocumentInstruction['parse'], undefined>\n}\n\nexport const defaultInstructionParsers: DefaultParsers = {\n compound(instruction, value, context) {\n const queries = Array.isArray(value) ? value : [value];\n Line truncated
+2
View File
@@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{constructor(t,e){this.operator=t,this.value=e,Object.defineProperty(this,"t",{writable:!0})}get notes(){return this.t}addNote(t){this.t=this.t||[],this.t.push(t)}}class e extends t{}class r extends e{constructor(t,e){if(!Array.isArray(e))throw new Error(`"${t}" operator expects to receive an array of conditions`);super(t,e)}}class o extends t{constructor(t,e,r){super(t,r),this.field=e}}const s=new e("__null__",null),n=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function i(t,e){return e instanceof r&&e.operator===t}function c(t,e){return 1===e.length?e[0]:new r(t,function t(e,r,o){const s=o||[];for(let o=0,n=r.length;o<n;o++){const n=r[o];i(e,n)?t(e,n.value,s):s.push(n)}return s}(t,e))}const u=t=>t,a=()=>Object.create(null),h=Object.defineProperty(a(),"__@type@__",{value:"ignore value"});function p(t,e,r=!1){if(!t||t&&t.constructor!==Object)return!1;for(const o in t){if(n(t,o)&&n(e,o)&&(!r||t[o]!==h))return!0}return!1}function f(t){const e=[];for(const r in t)n(t,r)&&t[r]!==h&&e.push(r);return e}function l(t,e){e!==s&&t.push(e)}const d=t=>c("and",t),x={compound(t,e,o){const s=(Array.isArray(e)?e:[e]).map(t=>o.parse(t));return new r(t.name,s)},field:(t,e,r)=>new o(t.name,r.field,e),document:(t,r)=>new e(t.name,r)};class b{constructor(t,e=a()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:e.operatorToConditionName||u,defaultOperatorName:e.defaultOperatorName||"eq",mergeFinalConditions:e.mergeFinalConditions||d},this.o=Object.keys(t).reduce((e,r)=>(e[r]=Object.assign({name:this.u.operatorToConditionName(r)},t[r]),e),{}),this.s=Object.assign({},e.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:t=>p(t,this.o,e.useIgnoreValue)}),this.i=Object.assign({},e.documentContext,{parse:this.parse,query:{}}),this.h=e.useIgnoreValue?f:Object.keys}setParse(t){this.parse=t,this.s.parse=t,this.i.parse=t}parseField(t,e,r,o){const s=this.o[e];if(!s)throw new Error(`Unsupported operator "${e}"`);if("field"!==s.type)throw new Error(`Unexpected ${s.type} operator "${e}" at field level`);return this.s.field=t,this.s.query=o,this.parseInstruction(s,r,this.s)}parseInstruction(t,e,r){"function"==typeof t.validate&&t.validate(t,e);return(t.parse||x[t.type])(t,e,r)}parseFieldOperators(t,e){const r=[],o=this.h(e);for(let s=0,n=o.length;s<n;s++){const n=o[s];if(!this.o[n])throw new Error(`Field query for "${t}" may contain only operators or a plain object as a value`);l(r,this.parseField(t,n,e[n],e))}return r}parse(t){const e=[],r=this.h(t);this.i.query=t;for(let o=0,s=r.length;o<s;o++){const s=r[o],n=t[s],i=this.o[s];if(i){if("document"!==i.type&&"compound"!==i.type)throw new Error(`Cannot use parsing instruction for operator "${s}" in "document" context as it is supposed to be used in "${i.type}" context`);l(e,this.parseInstruction(i,n,this.i))}else this.s.hasOperators(n)?e.push(...this.parseFieldOperators(s,n)):l(e,this.parseField(s,this.u.defaultOperatorName,n,t))}return this.u.mergeFinalConditions(e)}}function w(t,e){const r=t[e];if("function"!=typeof r)throw new Error(`Unable to interpret "${e}" condition. Did you forget to register interpreter for it?`);return r}function O(t){return t.operator}const _=b.prototype.parseInstruction;exports.CompoundCondition=r,exports.Condition=t,exports.DocumentCondition=e,exports.FieldCondition=o,exports.ITSELF="__itself__",exports.NULL_CONDITION=s,exports.ObjectQueryParser=b,exports.buildAnd=d,exports.buildOr=t=>c("or",t),exports.createInterpreter=function(t,e){const r=e,o=r&&r.getInterpreterName||O;let s;switch(r?r.numberOfArguments:0){case 1:s=e=>{const s=o(e,r);return w(t,s)(e,n)};break;case 3:s=(e,s,i)=>{const c=o(e,r);return w(t,c)(e,s,i,n)};break;default:s=(e,s)=>{const i=o(e,r);return w(t,i)(e,s,n)}}const n=Object.assign({},r,{interpret:s});return n.interpret},exports.createTranslatorFactory=function(t,e){return(r,...o)=>{const s=t(r,...o),n=e.bind(null,s);return n.ast=s,n}},exports.defaultInstructionParsers=x,exports.hasOperators=p,exports.identity=u,exports.ignoreValue=h,exports.isCompound=i,exports.object=a,exports.optimizedCompoundCondition=c,exports.parseInstruction=_;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/Condition.ts","../../src/utils.ts","../../src/builder.ts","../../src/parsers/defaultInstructionParsers.ts","../../src/parsers/ObjectQueryParser.ts","../../src/interpreter.ts","../../src/index.ts","../../src/translator.ts"],"sourcesContent":["export interface Note<T> {\n type: string\n message?: string\n originalValue?: T\n}\n\nexport abstract class Condition<T = unknown> {\n private _notes!: Note<T>[];\n\n constructor(\n public readonly operator: string,\n public readonly value: T\n ) {\n Object.defineProperty(this, '_notes', {\n writable: true\n });\n }\n\n get notes(): ReadonlyArray<Note<T>> | undefined {\n return this._notes;\n }\n\n addNote(note: Note<T>) {\n this._notes = this._notes || [];\n this._notes.push(note);\n }\n}\n\nexport class DocumentCondition<T> extends Condition<T> {\n}\n\nexport class CompoundCondition<T extends Condition = Condition> extends DocumentCondition<T[]> {\n constructor(operator: string, conditions: T[]) {\n if (!Array.isArray(conditions)) {\n throw new Error(`\"${operator}\" operator expects to receive an array of conditions`);\n }\n\n super(operator, conditions);\n }\n}\n\nexport const ITSELF = '__itself__';\nexport class FieldCondition<T = unknown> extends Condition<T> {\n public readonly field!: string | typeof ITSELF;\n\n constructor(operator: string, field: string | typeof ITSELF, value: T) {\n super(operator, value);\n this.field = field;\n }\n}\n\nexport const NULL_CONDITION = new DocumentCondition('__null__', null);\nexport type ConditionValue<T> = T extends Condition<infer V> ? V : unknown;\n","import { Condition, CompoundCondition, NULL_CONDITION } from './Condition';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);\n\nexport function isCompound(operator: string, condition: Condition): condition is CompoundCondition {\n return condition instanceof CompoundCondition && condition.operator === operator;\n}\n\nfunction flattenConditions<T extends Condition>(\n operator: string,\n conditions: T[],\n aggregatedResult?: T[]\n) {\n const flatConditions: T[] = aggregatedResult || [];\n\n for (let i = 0, length = conditions.length; i < length; i++) {\n const currentNode = conditions[i];\n\n if (isCompound(operator, currentNode)) {\n flattenConditions(operator, currentNode.value as T[], flatConditions);\n } else {\n flatConditions.push(currentNode);\n }\n }\n\n return flatConditions;\n}\n\nexport function optimizedCompoundCondition<T extends Condition>(operator: string, conditions: T[]) {\n if (conditions.length === 1) {\n return conditions[0];\n }\n\n return new CompoundCondition(operator, flattenConditions(operator, conditions));\n}\n\nexport const identity = <T>(x: T) => x;\nexport const object = () => Object.create(null);\n\nexport const ignoreValue: IgnoreValue = Object.defineProperty(object(), '__@type@__', {\n value: 'ignore value'\n});\nexport interface IgnoreValue {\n readonly ['__@type@__']: 'ignore value'\n}\n\nexport function hasOperators<T>(\n value: any,\n instructions: Record<string, unknown>,\n skipIgnore = false,\n): value is T {\n if (!value || value && value.constructor !== Object) {\n return false;\n }\n\n for (const prop in value) { // eslint-disable-line no-restricted-syntax, guard-for-in\n const hasProp = hasOwnProperty(value, prop) && hasOwnProperty(instructions, prop);\n if (hasProp && (!skipIgnore || value[prop] !== ignoreValue)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function objectKeysSkipIgnore(anyObject: Record<string, unknown>) {\n const keys: string[] = [];\n for (const key in anyObject) { // eslint-disable-line no-restricted-syntax\n if (hasOwnProperty(anyObject, key) && anyObject[key] !== ignoreValue) {\n keys.push(key);\n }\n }\n\n return keys;\n}\n\nexport function pushIfNonNullCondition(conditions: Condition[], condition: Condition) {\n if (condition !== NULL_CONDITION) {\n conditions.push(condition);\n }\n}\n","import { Condition } from './Condition';\nimport { optimizedCompoundCondition } from './utils';\n\nexport const buildAnd = (conditions: Condition[]) => optimizedCompoundCondition('and', conditions);\nexport const buildOr = (conditions: Condition[]) => optimizedCompoundCondition('or', conditions);\n","import {\n FieldCondition,\n CompoundCondition,\n DocumentCondition,\n} from '../Condition';\nimport {\n DocumentInstruction,\n CompoundInstruction,\n FieldInstruction,\n} from '../types';\n\ninterface DefaultParsers {\n compound: Exclude<CompoundInstruction['parse'], undefined>,\n field: Exclude<FieldInstruction['parse'], undefined>,\n document: Exclude<DocumentInstruction['parse'], undefined>\n}\n\nexport const defaultInstructionParsers: DefaultParsers = {\n compound(instruction, value, context) {\n const queries = Array.isArray(value) ? value : [value];\n Line truncated
+2
View File
@@ -0,0 +1,2 @@
class t{constructor(t,e){this.operator=t,this.value=e,Object.defineProperty(this,"t",{writable:!0})}get notes(){return this.t}addNote(t){this.t=this.t||[],this.t.push(t)}}class e extends t{}class r extends e{constructor(t,e){if(!Array.isArray(e))throw new Error(`"${t}" operator expects to receive an array of conditions`);super(t,e)}}const n="__itself__";class o extends t{constructor(t,e,r){super(t,r),this.field=e}}const s=new e("__null__",null),i=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function c(t,e){return e instanceof r&&e.operator===t}function u(t,e){return 1===e.length?e[0]:new r(t,function t(e,r,n){const o=n||[];for(let n=0,s=r.length;n<s;n++){const s=r[n];c(e,s)?t(e,s.value,o):o.push(s)}return o}(t,e))}const a=t=>t,h=()=>Object.create(null),f=Object.defineProperty(h(),"__@type@__",{value:"ignore value"});function l(t,e,r=!1){if(!t||t&&t.constructor!==Object)return!1;for(const n in t){if(i(t,n)&&i(e,n)&&(!r||t[n]!==f))return!0}return!1}function d(t){const e=[];for(const r in t)i(t,r)&&t[r]!==f&&e.push(r);return e}function p(t,e){e!==s&&t.push(e)}const w=t=>u("and",t),b=t=>u("or",t),O={compound(t,e,n){const o=(Array.isArray(e)?e:[e]).map(t=>n.parse(t));return new r(t.name,o)},field:(t,e,r)=>new o(t.name,r.field,e),document:(t,r)=>new e(t.name,r)};class j{constructor(t,e=h()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:e.operatorToConditionName||a,defaultOperatorName:e.defaultOperatorName||"eq",mergeFinalConditions:e.mergeFinalConditions||w},this.o=Object.keys(t).reduce((e,r)=>(e[r]=Object.assign({name:this.u.operatorToConditionName(r)},t[r]),e),{}),this.s=Object.assign({},e.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:t=>l(t,this.o,e.useIgnoreValue)}),this.i=Object.assign({},e.documentContext,{parse:this.parse,query:{}}),this.h=e.useIgnoreValue?d:Object.keys}setParse(t){this.parse=t,this.s.parse=t,this.i.parse=t}parseField(t,e,r,n){const o=this.o[e];if(!o)throw new Error(`Unsupported operator "${e}"`);if("field"!==o.type)throw new Error(`Unexpected ${o.type} operator "${e}" at field level`);return this.s.field=t,this.s.query=n,this.parseInstruction(o,r,this.s)}parseInstruction(t,e,r){"function"==typeof t.validate&&t.validate(t,e);return(t.parse||O[t.type])(t,e,r)}parseFieldOperators(t,e){const r=[],n=this.h(e);for(let o=0,s=n.length;o<s;o++){const s=n[o];if(!this.o[s])throw new Error(`Field query for "${t}" may contain only operators or a plain object as a value`);p(r,this.parseField(t,s,e[s],e))}return r}parse(t){const e=[],r=this.h(t);this.i.query=t;for(let n=0,o=r.length;n<o;n++){const o=r[n],s=t[o],i=this.o[o];if(i){if("document"!==i.type&&"compound"!==i.type)throw new Error(`Cannot use parsing instruction for operator "${o}" in "document" context as it is supposed to be used in "${i.type}" context`);p(e,this.parseInstruction(i,s,this.i))}else this.s.hasOperators(s)?e.push(...this.parseFieldOperators(o,s)):p(e,this.parseField(o,this.u.defaultOperatorName,s,t))}return this.u.mergeFinalConditions(e)}}function _(t,e){const r=t[e];if("function"!=typeof r)throw new Error(`Unable to interpret "${e}" condition. Did you forget to register interpreter for it?`);return r}function y(t){return t.operator}function m(t,e){const r=e,n=r&&r.getInterpreterName||y;let o;switch(r?r.numberOfArguments:0){case 1:o=e=>{const o=n(e,r);return _(t,o)(e,s)};break;case 3:o=(e,o,i)=>{const c=n(e,r);return _(t,c)(e,o,i,s)};break;default:o=(e,o)=>{const i=n(e,r);return _(t,i)(e,o,s)}}const s=Object.assign({},r,{interpret:o});return s.interpret}function v(t,e){return(r,...n)=>{const o=t(r,...n),s=e.bind(null,o);return s.ast=o,s}}const x=j.prototype.parseInstruction;export{r as CompoundCondition,t as Condition,e as DocumentCondition,o as FieldCondition,n as ITSELF,s as NULL_CONDITION,j as ObjectQueryParser,w as buildAnd,b as buildOr,m as createInterpreter,v as createTranslatorFactory,O as defaultInstructionParsers,l as hasOperators,a as identity,f as ignoreValue,c as isCompound,h as object,u as optimizedCompoundCondition,x as parseInstruction};
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../src/Condition.ts","../../src/utils.ts","../../src/builder.ts","../../src/parsers/defaultInstructionParsers.ts","../../src/parsers/ObjectQueryParser.ts","../../src/interpreter.ts","../../src/translator.ts","../../src/index.ts"],"sourcesContent":["export interface Note<T> {\n type: string\n message?: string\n originalValue?: T\n}\n\nexport abstract class Condition<T = unknown> {\n private _notes!: Note<T>[];\n\n constructor(\n public readonly operator: string,\n public readonly value: T\n ) {\n Object.defineProperty(this, '_notes', {\n writable: true\n });\n }\n\n get notes(): ReadonlyArray<Note<T>> | undefined {\n return this._notes;\n }\n\n addNote(note: Note<T>) {\n this._notes = this._notes || [];\n this._notes.push(note);\n }\n}\n\nexport class DocumentCondition<T> extends Condition<T> {\n}\n\nexport class CompoundCondition<T extends Condition = Condition> extends DocumentCondition<T[]> {\n constructor(operator: string, conditions: T[]) {\n if (!Array.isArray(conditions)) {\n throw new Error(`\"${operator}\" operator expects to receive an array of conditions`);\n }\n\n super(operator, conditions);\n }\n}\n\nexport const ITSELF = '__itself__';\nexport class FieldCondition<T = unknown> extends Condition<T> {\n public readonly field!: string | typeof ITSELF;\n\n constructor(operator: string, field: string | typeof ITSELF, value: T) {\n super(operator, value);\n this.field = field;\n }\n}\n\nexport const NULL_CONDITION = new DocumentCondition('__null__', null);\nexport type ConditionValue<T> = T extends Condition<infer V> ? V : unknown;\n","import { Condition, CompoundCondition, NULL_CONDITION } from './Condition';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);\n\nexport function isCompound(operator: string, condition: Condition): condition is CompoundCondition {\n return condition instanceof CompoundCondition && condition.operator === operator;\n}\n\nfunction flattenConditions<T extends Condition>(\n operator: string,\n conditions: T[],\n aggregatedResult?: T[]\n) {\n const flatConditions: T[] = aggregatedResult || [];\n\n for (let i = 0, length = conditions.length; i < length; i++) {\n const currentNode = conditions[i];\n\n if (isCompound(operator, currentNode)) {\n flattenConditions(operator, currentNode.value as T[], flatConditions);\n } else {\n flatConditions.push(currentNode);\n }\n }\n\n return flatConditions;\n}\n\nexport function optimizedCompoundCondition<T extends Condition>(operator: string, conditions: T[]) {\n if (conditions.length === 1) {\n return conditions[0];\n }\n\n return new CompoundCondition(operator, flattenConditions(operator, conditions));\n}\n\nexport const identity = <T>(x: T) => x;\nexport const object = () => Object.create(null);\n\nexport const ignoreValue: IgnoreValue = Object.defineProperty(object(), '__@type@__', {\n value: 'ignore value'\n});\nexport interface IgnoreValue {\n readonly ['__@type@__']: 'ignore value'\n}\n\nexport function hasOperators<T>(\n value: any,\n instructions: Record<string, unknown>,\n skipIgnore = false,\n): value is T {\n if (!value || value && value.constructor !== Object) {\n return false;\n }\n\n for (const prop in value) { // eslint-disable-line no-restricted-syntax, guard-for-in\n const hasProp = hasOwnProperty(value, prop) && hasOwnProperty(instructions, prop);\n if (hasProp && (!skipIgnore || value[prop] !== ignoreValue)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function objectKeysSkipIgnore(anyObject: Record<string, unknown>) {\n const keys: string[] = [];\n for (const key in anyObject) { // eslint-disable-line no-restricted-syntax\n if (hasOwnProperty(anyObject, key) && anyObject[key] !== ignoreValue) {\n keys.push(key);\n }\n }\n\n return keys;\n}\n\nexport function pushIfNonNullCondition(conditions: Condition[], condition: Condition) {\n if (condition !== NULL_CONDITION) {\n conditions.push(condition);\n }\n}\n","import { Condition } from './Condition';\nimport { optimizedCompoundCondition } from './utils';\n\nexport const buildAnd = (conditions: Condition[]) => optimizedCompoundCondition('and', conditions);\nexport const buildOr = (conditions: Condition[]) => optimizedCompoundCondition('or', conditions);\n","import {\n FieldCondition,\n CompoundCondition,\n DocumentCondition,\n} from '../Condition';\nimport {\n DocumentInstruction,\n CompoundInstruction,\n FieldInstruction,\n} from '../types';\n\ninterface DefaultParsers {\n compound: Exclude<CompoundInstruction['parse'], undefined>,\n field: Exclude<FieldInstruction['parse'], undefined>,\n document: Exclude<DocumentInstruction['parse'], undefined>\n}\n\nexport const defaultInstructionParsers: DefaultParsers = {\n compound(instruction, value, context) {\n const queries = Array.isArray(value) ? value : [value];\nLine truncated
+25
View File
@@ -0,0 +1,25 @@
export interface Note<T> {
type: string;
message?: string;
originalValue?: T;
}
export declare abstract class Condition<T = unknown> {
readonly operator: string;
readonly value: T;
private _notes;
constructor(operator: string, value: T);
get notes(): ReadonlyArray<Note<T>> | undefined;
addNote(note: Note<T>): void;
}
export declare class DocumentCondition<T> extends Condition<T> {
}
export declare class CompoundCondition<T extends Condition = Condition> extends DocumentCondition<T[]> {
constructor(operator: string, conditions: T[]);
}
export declare const ITSELF = "__itself__";
export declare class FieldCondition<T = unknown> extends Condition<T> {
readonly field: string | typeof ITSELF;
constructor(operator: string, field: string | typeof ITSELF, value: T);
}
export declare const NULL_CONDITION: DocumentCondition<null>;
export declare type ConditionValue<T> = T extends Condition<infer V> ? V : unknown;
+3
View File
@@ -0,0 +1,3 @@
import { Condition } from './Condition';
export declare const buildAnd: (conditions: Condition[]) => Condition<unknown> | import("./Condition").CompoundCondition<Condition<unknown>>;
export declare const buildOr: (conditions: Condition[]) => Condition<unknown> | import("./Condition").CompoundCondition<Condition<unknown>>;
+14
View File
@@ -0,0 +1,14 @@
export * from './Condition';
export * from './types';
export * from './interpreter';
export * from './translator';
export * from './builder';
export { isCompound, hasOperators, identity, object, optimizedCompoundCondition, ignoreValue, } from './utils';
export type { IgnoreValue } from './utils';
export * from './parsers/ObjectQueryParser';
export * from './parsers/defaultInstructionParsers';
/**
* @deprecated use `ObjectQueryParser#parseInstruction` instead
* TODO(major): remove
*/
export declare const parseInstruction: any;
+13
View File
@@ -0,0 +1,13 @@
import { Condition } from './Condition';
declare type ArgsExceptLast<F extends (...args: any[]) => any> = F extends (a: any, c: any) => any ? Parameters<(condition: Condition) => 0> : F extends (a: any, b: any, c: any) => any ? Parameters<(condition: Condition, value: Parameters<F>[1]) => 0> : Parameters<(condition: Condition, value: Parameters<F>[1], options: Parameters<F>[2], ...args: unknown[]) => 0>;
export declare type Interpreter<T extends Condition, R> = (condition: T, ...args: any[]) => R;
export declare type AnyInterpreter = Interpreter<any, any>;
export interface InterpretationContext<T extends AnyInterpreter> {
interpret(...args: ArgsExceptLast<T>): ReturnType<T>;
}
export interface InterpreterOptions {
numberOfArguments?: 1 | 2 | 3;
getInterpreterName?(condition: Condition, context: this): string;
}
export declare function createInterpreter<T extends AnyInterpreter, U extends {} = {}>(interpreters: Record<string, T>, rawOptions?: U): (...args: ArgsExceptLast<T>) => ReturnType<T>;
export {};
@@ -0,0 +1,30 @@
import { Condition } from '../Condition';
import { NamedInstruction, ParsingInstruction, FieldParsingContext, ParsingContext } from '../types';
export declare type FieldQueryOperators<T extends {}> = {
[K in keyof T]: T[K] extends {} ? T[K] : never;
}[keyof T];
export interface QueryOptions {
operatorToConditionName?(name: string): string;
defaultOperatorName?: string;
fieldContext?: Record<string, unknown>;
documentContext?: Record<string, unknown>;
useIgnoreValue?: boolean;
mergeFinalConditions?(conditions: Condition[]): Condition;
}
export declare type ObjectQueryFieldParsingContext = ParsingContext<FieldParsingContext & {
query: {};
hasOperators<T>(value: unknown): value is T;
}>;
export declare class ObjectQueryParser<T extends Record<any, any>, U extends FieldQueryOperators<T> = FieldQueryOperators<T>> {
private readonly _instructions;
private _fieldInstructionContext;
private _documentInstructionContext;
private readonly _options;
private readonly _objectKeys;
constructor(instructions: Record<string, ParsingInstruction>, options?: QueryOptions);
setParse(parse: this['parse']): void;
protected parseField(field: string, operator: string, value: unknown, parentQuery: {}): Condition<unknown>;
protected parseInstruction(instruction: NamedInstruction, value: unknown, context: ParsingContext<{}>): Condition<unknown>;
protected parseFieldOperators(field: string, value: U): Condition<unknown>[];
parse<Q extends T>(query: Q): Condition;
}
@@ -0,0 +1,8 @@
import { DocumentInstruction, CompoundInstruction, FieldInstruction } from '../types';
interface DefaultParsers {
compound: Exclude<CompoundInstruction['parse'], undefined>;
field: Exclude<FieldInstruction['parse'], undefined>;
document: Exclude<DocumentInstruction['parse'], undefined>;
}
export declare const defaultInstructionParsers: DefaultParsers;
export {};
+9
View File
@@ -0,0 +1,9 @@
import { Condition } from './Condition';
import { Parse } from './types';
import { AnyInterpreter } from './interpreter';
declare type Bound<T> = T extends (first: Condition, ...args: infer A) => any ? {
(...args: A): ReturnType<T>;
ast: Condition;
} : never;
export declare function createTranslatorFactory<Lang, Interpreter extends AnyInterpreter>(parse: Parse<Lang>, interpret: Interpreter): (query: Lang, ...args: unknown[]) => Bound<Interpreter>;
export {};
+27
View File
@@ -0,0 +1,27 @@
import { Condition } from './Condition';
export declare type Named<T, Name extends string = string> = T & {
name: Name;
};
export declare type Parse<T = any> = (query: T, ...args: any[]) => Condition;
export declare type ParsingContext<T extends {}> = T & {
parse: Parse;
};
export interface ParsingInstruction<T = unknown, Context extends {} = {}> {
type: string;
validate?(instruction: Named<this>, value: T): void;
parse?(instruction: Named<this>, value: T, context: ParsingContext<Context>): Condition;
}
export interface CompoundInstruction<T = unknown, C extends {} = {}> extends ParsingInstruction<T, C> {
type: 'compound';
}
export interface DocumentInstruction<T = unknown, C extends {} = {}> extends ParsingInstruction<T, C> {
type: 'document';
}
export interface FieldParsingContext {
field: string;
}
export interface FieldInstruction<T = unknown, C extends FieldParsingContext = FieldParsingContext> extends ParsingInstruction<T, C> {
type: 'field';
}
export declare type NamedInstruction<T extends string = string> = Named<ParsingInstruction, T>;
export declare type Comparable = number | string | Date;
+12
View File
@@ -0,0 +1,12 @@
import { Condition, CompoundCondition } from './Condition';
export declare function isCompound(operator: string, condition: Condition): condition is CompoundCondition;
export declare function optimizedCompoundCondition<T extends Condition>(operator: string, conditions: T[]): T | CompoundCondition<T>;
export declare const identity: <T>(x: T) => T;
export declare const object: () => any;
export declare const ignoreValue: IgnoreValue;
export interface IgnoreValue {
readonly ['__@type@__']: 'ignore value';
}
export declare function hasOperators<T>(value: any, instructions: Record<string, unknown>, skipIgnore?: boolean): value is T;
export declare function objectKeysSkipIgnore(anyObject: Record<string, unknown>): string[];
export declare function pushIfNonNullCondition(conditions: Condition[], condition: Condition): void;
+2
View File
@@ -0,0 +1,2 @@
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((t=t||self).ucast=t.ucast||{},t.ucast.core={}))}(this,(function(t){"use strict";function n(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function e(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}var i=function(){function t(t,n){this.operator=t,this.value=n,Object.defineProperty(this,"t",{writable:!0})}var r,e,i;return t.prototype.addNote=function(t){this.t=this.t||[],this.t.push(t)},r=t,(e=[{key:"notes",get:function(){return this.t}}])&&n(r.prototype,e),i&&n(r,i),t}(),o=function(t){function n(){return t.apply(this,arguments)||this}return e(n,t),n}(i),u=function(t){function n(n,r){if(!Array.isArray(r))throw new Error('"'+n+'" operator expects to receive an array of conditions');return t.call(this,n,r)||this}return e(n,t),n}(o),f=function(t){function n(n,r,e){var i;return(i=t.call(this,n,e)||this).field=r,i}return e(n,t),n}(i),s=new o("__null__",null),c=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function a(t,n){return n instanceof u&&n.operator===t}function h(t,n){return 1===n.length?n[0]:new u(t,function t(n,r,e){for(var i=e||[],o=0,u=r.length;o<u;o++){var f=r[o];a(n,f)?t(n,f.value,i):i.push(f)}return i}(t,n))}var v=function(t){return t},d=function(){return Object.create(null)},l=Object.defineProperty(d(),"__@type@__",{value:"ignore value"});function p(t,n,r){if(void 0===r&&(r=!1),!t||t&&t.constructor!==Object)return!1;for(var e in t){if(c(t,e)&&c(n,e)&&(!r||t[e]!==l))return!0}return!1}function b(t){var n=[];for(var r in t)c(t,r)&&t[r]!==l&&n.push(r);return n}function w(t,n){n!==s&&t.push(n)}var y=function(t){return h("and",t)},j={compound:function(t,n,r){var e=(Array.isArray(n)?n:[n]).map((function(t){return r.parse(t)}));return new u(t.name,e)},field:function(t,n,r){return new f(t.name,r.field,n)},document:function(t,n){return new o(t.name,n)}},O=function(){function t(t,n){var e=this;void 0===n&&(n=d()),this.i=void 0,this.o=void 0,this.u=void 0,this.s=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.s={operatorToConditionName:n.operatorToConditionName||v,defaultOperatorName:n.defaultOperatorName||"eq",mergeFinalConditions:n.mergeFinalConditions||y},this.i=Object.keys(t).reduce((function(n,i){return n[i]=r({name:e.s.operatorToConditionName(i)},t[i]),n}),{}),this.o=r({},n.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:function(t){return p(t,e.i,n.useIgnoreValue)}}),this.u=r({},n.documentContext,{parse:this.parse,query:{}}),this.h=n.useIgnoreValue?b:Object.keys}var n=t.prototype;return n.setParse=function(t){this.parse=t,this.o.parse=t,this.u.parse=t},n.parseField=function(t,n,r,e){var i=this.i[n];if(!i)throw new Error('Unsupported operator "'+n+'"');if("field"!==i.type)throw new Error("Unexpected "+i.type+' operator "'+n+'" at field level');return this.o.field=t,this.o.query=e,this.parseInstruction(i,r,this.o)},n.parseInstruction=function(t,n,r){return"function"==typeof t.validate&&t.validate(t,n),(t.parse||j[t.type])(t,n,r)},n.parseFieldOperators=function(t,n){for(var r=[],e=this.h(n),i=0,o=e.length;i<o;i++){var u=e[i];if(!this.i[u])throw new Error('Field query for "'+t+'" may contain only operators or a plain object as a value');w(r,this.parseField(t,u,n[u],n))}return r},n.parse=function(t){var n=[],r=this.h(t);this.u.query=t;for(var e=0,i=r.length;e<i;e++){var o=r[e],u=t[o],f=this.i[o];if(f){if("document"!==f.type&&"compound"!==f.type)throw new Error('Cannot use parsing instruction for operator "'+o+'" in "document" context as it is supposed to be used in "'+f.type+'" context');w(n,this.parseInstruction(f,u,this.u))}else this.o.hasOperators(u)?n.push.apply(n,this.parseFieldOperators(o,u)):w(n,this.parseField(o,this.s.defaultOperatorName,u,t))}return this.s.mergeFinalConditions(n)},t}();function _(t,n){var r=t[n];if("function"!=typeof r)throw new Error('Unable to interpret "'+n+'" condition. Did you forget to register interpreter for it?');return r}function m(t){return t.operator}var x=O.prototype.parseInstruction;t.CompoundCondition=u,t.Condition=i,t.DocumentCondition=o,t.FieldCondition=f,t.ITSELF="__itself__",t.NULL_CONDITION=s,t.ObjectQueryParser=O,t.buildAnd=y,t.buildOr=function(t){return h("or",t)},t.createInterpreter=function(t,n){var e,i=n,o=i&&i.getInterpreterName||m;switch(i?i.numberOfArguments:0){case 1:e=function(n){var r=o(n,i);return _(t,r)(n,u)};break;case 3:e=function(n,r,e){var f=o(n,i);return _(t,f)(n,r,e,u)};break;default:e=function(n,r){var e=o(n,i);return _(t,e)(n,r,u)}}var u=r({},i,{interpret:e});return u.interpret},t.createTranslatorFactory=Line truncated
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/Condition.ts","../../src/utils.ts","../../src/builder.ts","../../src/parsers/defaultInstructionParsers.ts","../../src/parsers/ObjectQueryParser.ts","../../src/interpreter.ts","../../src/index.ts","../../src/translator.ts"],"sourcesContent":["export interface Note<T> {\n type: string\n message?: string\n originalValue?: T\n}\n\nexport abstract class Condition<T = unknown> {\n private _notes!: Note<T>[];\n\n constructor(\n public readonly operator: string,\n public readonly value: T\n ) {\n Object.defineProperty(this, '_notes', {\n writable: true\n });\n }\n\n get notes(): ReadonlyArray<Note<T>> | undefined {\n return this._notes;\n }\n\n addNote(note: Note<T>) {\n this._notes = this._notes || [];\n this._notes.push(note);\n }\n}\n\nexport class DocumentCondition<T> extends Condition<T> {\n}\n\nexport class CompoundCondition<T extends Condition = Condition> extends DocumentCondition<T[]> {\n constructor(operator: string, conditions: T[]) {\n if (!Array.isArray(conditions)) {\n throw new Error(`\"${operator}\" operator expects to receive an array of conditions`);\n }\n\n super(operator, conditions);\n }\n}\n\nexport const ITSELF = '__itself__';\nexport class FieldCondition<T = unknown> extends Condition<T> {\n public readonly field!: string | typeof ITSELF;\n\n constructor(operator: string, field: string | typeof ITSELF, value: T) {\n super(operator, value);\n this.field = field;\n }\n}\n\nexport const NULL_CONDITION = new DocumentCondition('__null__', null);\nexport type ConditionValue<T> = T extends Condition<infer V> ? V : unknown;\n","import { Condition, CompoundCondition, NULL_CONDITION } from './Condition';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);\n\nexport function isCompound(operator: string, condition: Condition): condition is CompoundCondition {\n return condition instanceof CompoundCondition && condition.operator === operator;\n}\n\nfunction flattenConditions<T extends Condition>(\n operator: string,\n conditions: T[],\n aggregatedResult?: T[]\n) {\n const flatConditions: T[] = aggregatedResult || [];\n\n for (let i = 0, length = conditions.length; i < length; i++) {\n const currentNode = conditions[i];\n\n if (isCompound(operator, currentNode)) {\n flattenConditions(operator, currentNode.value as T[], flatConditions);\n } else {\n flatConditions.push(currentNode);\n }\n }\n\n return flatConditions;\n}\n\nexport function optimizedCompoundCondition<T extends Condition>(operator: string, conditions: T[]) {\n if (conditions.length === 1) {\n return conditions[0];\n }\n\n return new CompoundCondition(operator, flattenConditions(operator, conditions));\n}\n\nexport const identity = <T>(x: T) => x;\nexport const object = () => Object.create(null);\n\nexport const ignoreValue: IgnoreValue = Object.defineProperty(object(), '__@type@__', {\n value: 'ignore value'\n});\nexport interface IgnoreValue {\n readonly ['__@type@__']: 'ignore value'\n}\n\nexport function hasOperators<T>(\n value: any,\n instructions: Record<string, unknown>,\n skipIgnore = false,\n): value is T {\n if (!value || value && value.constructor !== Object) {\n return false;\n }\n\n for (const prop in value) { // eslint-disable-line no-restricted-syntax, guard-for-in\n const hasProp = hasOwnProperty(value, prop) && hasOwnProperty(instructions, prop);\n if (hasProp && (!skipIgnore || value[prop] !== ignoreValue)) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function objectKeysSkipIgnore(anyObject: Record<string, unknown>) {\n const keys: string[] = [];\n for (const key in anyObject) { // eslint-disable-line no-restricted-syntax\n if (hasOwnProperty(anyObject, key) && anyObject[key] !== ignoreValue) {\n keys.push(key);\n }\n }\n\n return keys;\n}\n\nexport function pushIfNonNullCondition(conditions: Condition[], condition: Condition) {\n if (condition !== NULL_CONDITION) {\n conditions.push(condition);\n }\n}\n","import { Condition } from './Condition';\nimport { optimizedCompoundCondition } from './utils';\n\nexport const buildAnd = (conditions: Condition[]) => optimizedCompoundCondition('and', conditions);\nexport const buildOr = (conditions: Condition[]) => optimizedCompoundCondition('or', conditions);\n","import {\n FieldCondition,\n CompoundCondition,\n DocumentCondition,\n} from '../Condition';\nimport {\n DocumentInstruction,\n CompoundInstruction,\n FieldInstruction,\n} from '../types';\n\ninterface DefaultParsers {\n compound: Exclude<CompoundInstruction['parse'], undefined>,\n field: Exclude<FieldInstruction['parse'], undefined>,\n document: Exclude<DocumentInstruction['parse'], undefined>\n}\n\nexport const defaultInstructionParsers: DefaultParsers = {\n compound(instruction, value, context) {\n const queries = Array.isArray(value) ? value : [value];\n Line truncated