node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ucast/core"),t=require("@ucast/mongo"),n=require("@ucast/js");function r(e){return null===e||"object"!=typeof e?e:e instanceof Date?e.getTime():e&&"function"==typeof e.toJSON?e.toJSON():e}const o=(e,t)=>n.compare(r(e),r(t));function c(r,c,u){const s=new t.MongoQueryParser(r),i=n.createJsInterpreter(c,Object.assign({compare:o},u));if(u&&u.forPrimitives){const t={field:e.ITSELF},n=s.parse;s.setParse(e=>n(e,t))}return e.createTranslatorFactory(s.parse,i)}const u=c(t.allParsingInstructions,n.allInterpreters),s=c(["$and","$or"].reduce((e,t)=>(e[t]=Object.assign({},e[t],{type:"field"}),e),Object.assign({},t.allParsingInstructions,{$nor:Object.assign({},t.allParsingInstructions.$nor,{type:"field",parse:t.defaultParsers.compound})})),n.allInterpreters,{forPrimitives:!0}),i=u;Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(t).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),exports.createFactory=c,exports.filter=i,exports.guard=u,exports.squire=s;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/factory.ts"],"sourcesContent":["import { createTranslatorFactory, ParsingInstruction, Condition, ITSELF } from '@ucast/core';\nimport {\n MongoQuery,\n MongoQueryParser,\n MongoQueryFieldOperators,\n allParsingInstructions,\n defaultParsers\n} from '@ucast/mongo';\nimport {\n createJsInterpreter,\n allInterpreters,\n JsInterpreter,\n JsInterpretationOptions,\n compare\n} from '@ucast/js';\n\ntype ThingFilter<T> = {\n (object: T): boolean\n ast: Condition\n};\n\ninterface HasToJSON {\n toJSON(): unknown\n}\n\nfunction toPrimitive(value: unknown) {\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n if (value && typeof (value as HasToJSON).toJSON === 'function') {\n return (value as HasToJSON).toJSON();\n }\n\n return value;\n}\n\nconst comparePrimitives: typeof compare = (a, b) => compare(toPrimitive(a), toPrimitive(b));\n\nexport interface FactoryOptions extends JsInterpretationOptions {\n forPrimitives: boolean\n}\n\nexport type Filter = <\n T = Record<string, unknown>,\n Q extends MongoQuery<T> = MongoQuery<T>\n>(query: Q) => ThingFilter<T>;\n\nexport type PrimitiveMongoQuery<T> = MongoQueryFieldOperators<T> & Partial<{\n $and: MongoQueryFieldOperators<T>[],\n $or: MongoQueryFieldOperators<T>[],\n $nor: MongoQueryFieldOperators<T>[]\n}>;\nexport type PrimitiveFilter = <\n T,\n Q extends PrimitiveMongoQuery<T> = PrimitiveMongoQuery<T>\n>(query: Q) => ThingFilter<T>;\n\ntype FilterType<T extends { forPrimitives?: true }> = T['forPrimitives'] extends true\n ? PrimitiveFilter\n : Filter;\n\nexport function createFactory<\n T extends Record<string, ParsingInstruction<any, any>>,\n I extends Record<string, JsInterpreter<any>>,\n P extends { forPrimitives?: true }\n>(instructions: T, interpreters: I, options?: Partial<FactoryOptions> & P): FilterType<P> {\n const parser = new MongoQueryParser(instructions);\n const interpret = createJsInterpreter(interpreters, {\n compare: comparePrimitives,\n ...options\n });\n\n if (options && options.forPrimitives) {\n const params = { field: ITSELF };\n const parse = parser.parse;\n parser.setParse(query => parse(query, params));\n }\n\n return createTranslatorFactory(parser.parse, interpret) as any;\n}\n\nexport const guard = createFactory(allParsingInstructions, allInterpreters);\n\nconst compoundOperators = ['$and', '$or'] as const;\nconst allPrimitiveParsingInstructions = compoundOperators.reduce((instructions, name) => {\n instructions[name] = { ...instructions[name], type: 'field' } as any;\n return instructions;\n}, {\n ...allParsingInstructions,\n $nor: {\n ...allParsingInstructions.$nor,\n type: 'field',\n parse: defaultParsers.compound\n }\n});\n\nexport const squire = createFactory(allPrimitiveParsingInstructions, allInterpreters, {\n forPrimitives: true\n});\nexport const filter = guard; // TODO: remove in next major version\n"],"names":["toPrimitive","value","Date","getTime","toJSON","comparePrimitives","a","b","compare","createFactory","instructions","interpreters","options","parser","MongoQueryParser","interpret","createJsInterpreter","forPrimitives","params","field","ITSELF","parse","setParse","query","createTranslatorFactory","guard","allParsingInstructions","allInterpreters","squire","reduce","name","type","$nor","defaultParsers","compound","filter"],"mappings":"kJAyBA,SAASA,EAAYC,UACL,OAAVA,GAAmC,iBAAVA,EACpBA,EAGLA,aAAiBC,KACZD,EAAME,UAGXF,GAAgD,mBAA/BA,EAAoBG,OAC/BH,EAAoBG,SAGvBH,EAGT,MAAMI,EAAoC,CAACC,EAAGC,IAAMC,UAAQR,EAAYM,GAAIN,EAAYO,IAyBjF,SAASE,EAIdC,EAAiBC,EAAiBC,SAC5BC,EAAS,IAAIC,mBAAiBJ,GAC9BK,EAAYC,sBAAoBL,iBACpCH,QAASH,GACNO,OAGDA,GAAWA,EAAQK,cAAe,OAC9BC,EAAS,CAAEC,MAAOC,UAClBC,EAAQR,EAAOQ,MACrBR,EAAOS,SAASC,GAASF,EAAME,EAAOL,WAGjCM,0BAAwBX,EAAOQ,MAAON,SAGlCU,EAAQhB,EAAciB,yBAAwBC,mBAe9CC,EAASnB,EAbI,CAAC,OAAQ,OACuBoB,OAAO,CAACnB,EAAcoB,KAC9EpB,EAAaoB,oBAAapB,EAAaoB,IAAOC,KAAM,UAC7CrB,oBAEJgB,0BACHM,sBACKN,yBAAuBM,MAC1BD,KAAM,QACNV,MAAOY,iBAAeC,cAI2CP,kBAAiB,CACpFV,eAAe,IAEJkB,EAASV"}