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 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ucast/core");function t(e,t){if(!Array.isArray(t))throw new Error(`"${e.name}" expects value to be an array`)}function r(e,r){if(t(e,r),!r.length)throw new Error(`"${e.name}" expects to have at least one element in array`)}const o=e=>(t,r)=>{if(typeof r!==e)throw new Error(`"${t.name}" expects value to be a "${e}"`)},s={type:"compound",validate:r,parse(t,r,{parse:o}){const s=r.map(e=>o(e));return e.optimizedCompoundCondition(t.name,s)}},a=s,n={type:"compound",validate:r},p={type:"field",validate(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(t,r,o){const s=r instanceof RegExp?new e.FieldCondition("regex",o.field,r):o.parse(r,o);return new e.CompoundCondition(t.name,[s])}},i={type:"field",validate(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(t,r,{parse:o,field:s,hasOperators:a}){const n=a(r)?o(r,{field:e.ITSELF}):o(r);return new e.FieldCondition(t.name,s,n)}},l={type:"field",validate:o("number")},c={type:"field",validate:t},x=c,f=c,u={type:"field",validate(e,t){if(!Array.isArray(t)||2!==t.length)throw new Error(`"${e.name}" expects an array with 2 numeric elements`)}},d={type:"field",validate:o("boolean")},$={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)`)}},w=$,y=w,v=w,b={type:"field"},g=b,h={type:"field",validate(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(t,r,o){const s="string"==typeof r?new RegExp(r,o.query.$options||""):r;return new e.FieldCondition(t.name,o.field,s)}},m={type:"field",parse:()=>e.NULL_CONDITION},E={type:"document",validate:o("function")};var j=Object.freeze({__proto__:null,$and:s,$or:a,$nor:n,$not:p,$elemMatch:i,$size:l,$in:c,$nin:x,$all:f,$mod:u,$exists:d,$gte:$,$gt:w,$lt:y,$lte:v,$eq:b,$ne:g,$regex:h,$options:m,$where:E});class O extends e.ObjectQueryParser{constructor(e){super(e,{defaultOperatorName:"$eq",operatorToConditionName:e=>e.slice(1)})}parse(t,r){return r&&r.field?e.buildAnd(this.parseFieldOperators(r.field,t)):super.parse(t)}}const _=j;Object.defineProperty(exports,"defaultParsers",{enumerable:!0,get:function(){return e.defaultInstructionParsers}}),exports.$all=f,exports.$and=s,exports.$elemMatch=i,exports.$eq=b,exports.$exists=d,exports.$gt=w,exports.$gte=$,exports.$in=c,exports.$lt=y,exports.$lte=v,exports.$mod=u,exports.$ne=g,exports.$nin=x,exports.$nor=n,exports.$not=p,exports.$options=m,exports.$or=a,exports.$regex=h,exports.$size=l,exports.$where=E,exports.MongoQueryParser=O,exports.allParsingInstructions=_;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/instructions.ts","../../src/MongoQueryParser.ts","../../src/index.ts"],"sourcesContent":["import {\n CompoundCondition,\n FieldCondition,\n NamedInstruction,\n CompoundInstruction,\n FieldInstruction,\n DocumentInstruction,\n Comparable,\n ITSELF,\n NULL_CONDITION,\n FieldParsingContext,\n optimizedCompoundCondition,\n ObjectQueryFieldParsingContext,\n} from '@ucast/core';\nimport { MongoQuery } from './types';\n\nfunction ensureIsArray(instruction: NamedInstruction, value: unknown) {\n if (!Array.isArray(value)) {\n throw new Error(`\"${instruction.name}\" expects value to be an array`);\n }\n}\n\nfunction ensureIsNonEmptyArray(instruction: NamedInstruction, value: unknown[]) {\n ensureIsArray(instruction, value);\n\n if (!value.length) {\n throw new Error(`\"${instruction.name}\" expects to have at least one element in array`);\n }\n}\n\nfunction ensureIsComparable(instruction: NamedInstruction, value: string | number | Date) {\n const isComparable = typeof value === 'string' || typeof value === 'number' || value instanceof Date;\n\n if (!isComparable) {\n throw new Error(`\"${instruction.name}\" expects value to be comparable (i.e., string, number or date)`);\n }\n}\n\nconst ensureIs = (type: string) => (instruction: NamedInstruction, value: unknown) => {\n if (typeof value !== type) { // eslint-disable-line valid-typeof\n throw new Error(`\"${instruction.name}\" expects value to be a \"${type}\"`);\n }\n};\n\nexport const $and: CompoundInstruction<MongoQuery<any>[]> = {\n type: 'compound',\n validate: ensureIsNonEmptyArray,\n parse(instruction, queries, { parse }) {\n const conditions = queries.map(query => parse(query));\n return optimizedCompoundCondition(instruction.name, conditions);\n }\n};\nexport const $or = $and;\nexport const $nor: CompoundInstruction<MongoQuery<any>[]> = {\n type: 'compound',\n validate: ensureIsNonEmptyArray,\n};\n\nexport const $not: FieldInstruction<MongoQuery<any> | RegExp> = {\n type: 'field',\n validate(instruction, value) {\n const isValid = value && (value instanceof RegExp || value.constructor === Object);\n\n if (!isValid) {\n throw new Error(`\"${instruction.name}\" expects to receive either regular expression or object of field operators`);\n }\n },\n parse(instruction, value, context) {\n const condition = value instanceof RegExp\n ? new FieldCondition('regex' as typeof instruction.name, context.field, value)\n : context.parse(value, context);\n\n return new CompoundCondition(instruction.name, [condition]);\n },\n};\nexport const $elemMatch: FieldInstruction<MongoQuery<any>, ObjectQueryFieldParsingContext> = {\n type: 'field',\n validate(instruction, value) {\n if (!value || value.constructor !== Object) {\n throw new Error(`\"${instruction.name}\" expects to receive an object with nested query or field level operators`);\n }\n },\n parse(instruction, value, { parse, field, hasOperators }) {\n const condition = hasOperators(value) ? parse(value, { field: ITSELF }) : parse(value);\n return new FieldCondition(instruction.name, field, condition);\n }\n};\n\nexport const $size: FieldInstruction<number> = {\n type: 'field',\n validate: ensureIs('number')\n};\nexport const $in: FieldInstruction<unknown[]> = {\n type: 'field',\n validate: ensureIsArray,\n};\nexport const $nin = $in;\nexport const $all = $in;\nexport const $mod: FieldInstruction<[number, number]> = {\n type: 'field',\n validate(instruction, value) {\n if (!Array.isArray(value) || value.length !== 2) {\n throw new Error(`\"${instruction.name}\" expects an array with 2 numeric elements`);\n }\n }\n};\n\nexport const $exists: FieldInstruction<boolean> = {\n type: 'field',\n validate: ensureIs('boolean'),\n};\n\nexport const $gte: FieldInstruction<Comparable> = {\n type: 'field',\n validate: ensureIsComparable\n};\nexport const $gt = $gte;\nexport const $lt = $gt;\nexport const $lte = $gt;\n\nexport const $eq: FieldInstruction = {\n type: 'field',\n};\nexport const $ne = $eq;\n\nexport interface RegExpFieldContext extends FieldParsingContext {\n query: {\n $options?: string\n }\n}\n\nexport const $regex: FieldInstruction<string | RegExp, RegExpFieldContext> = {\n type: 'field',\n validate(instruction, value) {\n if (!(value instanceof RegExp) && typeof value !== 'string') {\n throw new Error(`\"${instruction.name}\" expects value to be a regular expression or a string that represents regular expression`);\n }\n },\n parse(instruction, rawValue, context) {\n const value = typeof rawValue === 'string'\n ? new RegExp(rawValue, context.query.$options || '')\n : rawValue;\n return new FieldCondition(instruction.name, context.field, value);\n }\n};\nexport const $options: FieldInstruction = {\n type: 'field',\n parse: () => NULL_CONDITION,\n};\n\nexport const $where: DocumentInstruction<() => booleanLine truncated