genosdb 0.11.5 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai.min.js CHANGED
@@ -1,13 +1 @@
1
- function C(c){const O=c.map;return c.map=async function(...A){const L=await O.call(this,...A),h=A.find((j)=>j&&typeof j==="object")||{},{prompt:b}=h;if(b)L.results=await w(L.results,b);return L},c}async function w(c,O){const A=c.map((b)=>b.value),L=`
2
- ${O}
3
-
4
- Strict rules:
5
- - Return a JSON array with the SAME structure as the input.
6
- - Each array element must be a modification of the corresponding input object.
7
- - Only modify fields INSIDE the \`value\` object.
8
- - DO NOT add, remove, or restructure external nodes like \`id\`, \`edges\`, or \`timestamp\`.
9
- - DO NOT include explanations or extra text. Return ONLY the JSON array with modified \`value\` objects.
10
-
11
- Input example:
12
- ${JSON.stringify(A)}
13
- `,h=await z(L);return console.log(h),c.map((b,j)=>{const k=Array.isArray(h)?h[j]:h;return{...b,value:{...b.value,...k||{}}}})}async function z(c){try{const A=await fetch("https://text.pollinations.ai/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"system",content:"You are an AI assistant specialized in processing structured data objects."},{role:"user",content:c}],model:"openai",seed:Math.floor(Math.random()*1000),jsonMode:!0})});if(!A.ok)throw new Error(`Pollinations API error: ${A.statusText}`);const L=await A.json();return L.data||L}catch(O){throw console.error("Error processing prompt with Pollinations API:",O.message),O}}export{C as withAI};
1
+ import*as i from"https://esm.run/@mlc-ai/web-llm";var u=function(f){if(console.log("\uD83E\uDDE0 Loading AI (WebLLM) model..."),!f.webllm)f.webllm={engine:null,isReady:!1,initPromise:null,async init(g="Phi-3.5-mini-instruct-q4f16_1-MLC"){if(this.initPromise)return this.initPromise;return this.engine=new i.MLCEngine,this.initPromise=this.engine.reload(g,{temperature:0.7,top_p:0.9}).then(()=>{return this.isReady=!0,console.log("\u2705 [WebLLM] Model Ready."),this.engine}),this.initPromise}},f.webllm.init().catch((g)=>{console.error("\u274C [WebLLM] Error al inicializar:",g)});return f},a=(f)=>{return u(f)};export{a as init};
package/dist/ai.min.js.gz CHANGED
Binary file
package/dist/nlq.min.js CHANGED
@@ -1 +1 @@
1
- function j0(J){const Z=J.map;return J.map=async function(...j){let H={},_=null;j.forEach((G)=>{if(typeof G==="object")H={...H,...G};if(typeof G==="function")_=G});let A=!1;if(H.prompt)try{const G=await H0(H.prompt);if(console.log("Query generated from local DSL:",G),H={...H,...G},G.__nlqReturnDeepest)A=!0;delete H.prompt}catch(G){console.error("Error parsing prompt:",G.message),H.query={}}const L=A&&_?(G)=>{try{const T=w(G);_&&_(T)}catch{_&&_(G)}}:_,Q=await Z.call(this,H,L);if(A&&Q&&Array.isArray(Q.results))Q.results=w(Q.results);return Q},J}async function H0(J){return J0(J)}var J0=function(J){const Z=i(String(J||""));let j=x(Z);const H={query:{}},_=H.query,A=$0(j);if(A.length){H.$_ors=[];for(let Y of A)H.$_ors.push(Y.left,Y.right),j=W(j,Y.span)}const F=M0(j);if(F)_.type=F.type,H.type=F.type,j=W(j,F.span);if(!_.type){const Y=F0(j);if(Y)_.type=Y.type,H.type=Y.type,j=W(j,Y.span)}const L=Q0(j);if(L&&L.edge){if(_.$edge=L.edge,L.span)j=W(j,L.span)}if(L&&L.edge&&/\bthen\s+finds?\s+(?:that\s+[A-Za-z]+s?\s+)?descendant\s+(?:named|called|with\s+name)\b/i.test(Z))H.__nlqReturnDeepest=!0;const Q=p(j);for(let Y of Q){if(Y.mode==="in"){const K=Y.values??[Y.value];_[Y.field]={..._[Y.field]||{},$in:K}}else _[Y.field]={..._[Y.field]||{},$contains:Y.value};j=W(j,Y.span)}const G=u(j);for(let Y of G)_[Y.field]={..._[Y.field]||{},$regex:`^${Y.value}`},j=W(j,Y.span);const T=c(j);for(let Y of T)_[Y.field]={..._[Y.field]||{},$regex:`${Y.value}\$`},j=W(j,Y.span);const U=d(j);for(let Y of U)_[Y.field]={..._[Y.field]||{},$like:Y.value},j=W(j,Y.span);const B=X0(j);if(B){const Y=B.value,K=[{name:{$regex:Y}},{role:{$regex:Y}},{level:{$regex:Y}},{country:{$regex:Y}},{title:{$regex:Y}},{body:{$regex:Y}},{tags:{$in:[Y]}}];H.query.$or=[...H.query.$or||[],...K],j=W(j,B.span)}else if(Y0(j))H.query.__nlq_no_match="__NLQ_NO_MATCH__";const f=l(j);for(let Y of f)_[Y.field]={..._[Y.field]||{},$exists:!0},j=W(j,Y.span);const $=L0(j);if($.after)H.$after=$.after;if($.before)H.$before=$.before;for(let Y of $.spans)j=W(j,Y);const M=m(j);for(let Y of M)_[Y.field]=Y.value,j=W(j,Y.span);const C=a(j);for(let Y of C)_[Y.field]={..._[Y.field]||{},$between:[Y.min,Y.max]},j=W(j,Y.span);const P=Z0(j);for(let Y of P){if(Y.op==="eq")_[Y.field]=Y.value;else _[Y.field]={..._[Y.field]||{},[Y.op]:Y.value};j=W(j,Y.span)}const v=r(j);for(let Y of v){if(Y.op==="eq")_[Y.field]=Y.value;else _[Y.field]={..._[Y.field]||{},[Y.op]:Y.value};j=W(j,Y.span)}const V=n(j);for(let Y of V)_[Y.field]={..._[Y.field]||{},$not:{$eq:Y.value}},j=W(j,Y.span);const R=o(j);for(let Y of R){if(Y.kind==="in")_.id={..._.id||{},$in:Y.values};else if(Y.kind==="eq")_.id=Y.value;j=W(j,Y.span)}const q=s(j);for(let Y of q)_[Y.field]={..._[Y.field]||{},$in:Y.values},j=W(j,Y.span);const h=_0(j);if(h)H.order=h.order,H.field=h.field;const X=U0(j);if(X!=null)H.$limit=X;if(H.order&&!H.field){const Y=Object.keys(_)[0];if(Y)H.field=Y}if(H.$_ors&&H.$_ors.length)H.query.$or=[...H.query.$or||[],...H.$_ors],delete H.$_ors;return H.query=A0(H.query),H},i=function(J){return J.replace(/\s+/g," ").trim()},W=function(J,Z){if(!Z)return J;return i(`${J.slice(0,Z.start)} ${J.slice(Z.end)}`)},x=function(J){const Z=/^(?:searches\s+for|search\s+for|searches|search|finds?|gets?|lists?|returns?|shows?|filters?)\s+/i;return J.replace(Z,"")},p=function(J){const Z=[],j=[{re:/\bwhose\s+([a-z][\w\.]*)\s+(includes|including|has)\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig,mode:"in",list:!0},{re:/\b([a-z][\w\.]*)\s+(includes|including|has)\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig,mode:"in",list:!0},{re:/\bwhose\s+([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?"([^\"]+)"/ig,mode:"contains"},{re:/\bwhose\s+([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?([A-Za-z0-9_\-]+)/ig,mode:"contains"},{re:/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?"([^\"]+)"/ig,mode:"contains"},{re:/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?([A-Za-z0-9_\-]+)/ig,mode:"contains"}];for(let{re:H,mode:_,list:A}of j){let F;while((F=H.exec(J))!==null){const L=F[1];if(_==="in"&&A){const G=F[3].split(/\s*,\s*/).map((T)=>T.replace(/^"|"$/g,""));Z.push({field:L,mode:"in",values:G,span:{start:F.index,end:F.index+F[0].length}})}else if(_==="contains"){const Q=F[2];Z.push({field:L,mode:"contains",value:Q,span:{start:F.index,end:F.index+F[0].length}})}}}return Z},u=function(J){const Z=[],j=/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+"([^\"]+)"/ig;let H;while((H=j.exec(J))!==null)Z.push({field:H[1],value:H[2],span:{start:H.index,end:H.index+H[0].length}});const _=/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+([A-Za-z0-9_\-]+)/ig;while((H=_.exec(J))!==null)Z.push({field:H[1],value:H[2],span:{start:H.index,end:H.index+H[0].length}});return Z},c=function(J){const Z=[],j=/\b(?:whose\s+)?([a-z][\w\.]*)\s+ends\s+with\s+"([^\"]+)"/ig;let H;while((H=j.exec(J))!==null)Z.push({field:H[1],value:H[2],span:{start:H.index,end:H.index+H[0].length}});const _=/\b(?:whose\s+)?([a-z][\w\.]*)\s+ends\s+with\s+([A-Za-z0-9_\-]+)/ig;while((H=_.exec(J))!==null)Z.push({field:H[1],value:H[2],span:{start:H.index,end:H.index+H[0].length}});return Z},d=function(J){const Z=[];let j;const H=/\b(?:whose\s+)?([a-z][\w\.]*)\s+like\s+"([^\"]+)"/ig;while((j=H.exec(J))!==null)Z.push({field:j[1],value:j[2],span:{start:j.index,end:j.index+j[0].length}});const _=/\b(?:whose\s+)?([a-z][\w\.]*)\s+like\s+([A-Za-z0-9_%\-\.\*]+)/ig;while((j=_.exec(J))!==null)Z.push({field:j[1],value:j[2],span:{start:j.index,end:j.index+j[0].length}});return Z},X0=function(J){const j=/\b(?:full[-\s]?text\s+search|text\s+search)\s+(?:"([^\"]+)"|([A-Za-z0-9_\-]+))/i.exec(J);if(j)return{value:j[1]||j[2],span:{start:j.index,end:j.index+j[0].length}};return null},Y0=function(J){return/\b(?:full[-\s]?text\s+search|text\s+search|full[-\s]?text)\b/i.test(J)},n=function(J){const Z=[];let j;const H=/\b([a-z][\w\.]*)\s*(?:!=|is\s+not|not\s+equals)\s+"([^\"]+)"\b/ig;while((j=H.exec(J))!==null)Z.push({field:j[1],value:j[2],span:{start:j.index,end:j.index+j[0].length}});const _=/\b([a-z][\w\.]*)\s*(?:!=|is\s+not|not\s+equals)\s+([A-Za-z0-9_\-\.]+)\b/ig;while((j=_.exec(J))!==null)Z.push({field:j[1],value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});return Z},s=function(J){const Z=[];let j;const H=/\b([a-z][\w\.]*)\s+is\s+([A-Za-z0-9_\-]+)\s+or\s+([A-Za-z0-9_\-]+)(?:\s+or\s+([A-Za-z0-9_\-]+))*/ig;while((j=H.exec(J))!==null){const A=j[1],F=j[0].replace(new RegExp(`^${j[1]}\\s+is\\s+`,"i"),"").split(/\s+or\s+/i).map((L)=>L.trim().replace(/[,\.]$/,""));Z.push({field:A,values:F,span:{start:j.index,end:j.index+j[0].length}})}const _=/\b([a-z][\w\.]*)\s+in\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig;while((j=_.exec(J))!==null){const A=j[1],L=j[2].split(/\s*,\s*/).map((Q)=>Q.replace(/^"|"$/g,""));Z.push({field:A,values:L,span:{start:j.index,end:j.index+j[0].length}})}return Z},l=function(J){const Z=[];let j;const H=/\b(?:has|with|having)\s+([a-z][\w\.]*)\b(?!\s+(?:"[^"]+"|[A-Za-z0-9_\-.]+)\b)/ig;while((j=H.exec(J))!==null)Z.push({field:j[1],span:{start:j.index,end:j.index+j[0].length}});const _=/\b(?:has|with|having)\s+([a-z][\w\.]*)\s+exists\b/ig;while((j=_.exec(J))!==null)Z.push({field:j[1],span:{start:j.index,end:j.index+j[0].length}});const A=/\bwhose\s+([a-z][\w\.]*)\s+exists\b/ig;while((j=A.exec(J))!==null)Z.push({field:j[1],span:{start:j.index,end:j.index+j[0].length}});const F=/\b([a-z][\w\.]*)\s+exists\b/ig;while((j=F.exec(J))!==null)Z.push({field:j[1],span:{start:j.index,end:j.index+j[0].length}});return Z},m=function(J){const Z=[];let j;const H=/\bwith\s+([a-z][\w\.]*)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((j=H.exec(J))!==null){const _=j[1],A=D(j[2]);Z.push({field:_,value:A,span:{start:j.index,end:j.index+j[0].length}})}return Z},a=function(J){const Z=[],j=/\b([a-z][\w\.]*)\s+between\s+(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\s*(?:and|,|to)\s*(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\b/ig;let H;const _=[];while((H=j.exec(J))!==null){const F={start:H.index,end:H.index+H[0].length};Z.push({field:H[1],min:H[2]||H[3],max:H[4]||H[5],span:F}),_.push(F)}const A=/\b([a-z][\w\.]*)\s+between\s+(-?\d+(?:\.\d+)?)\s*(?:and|,|to)\s*(-?\d+(?:\.\d+)?)\b/ig;while((H=A.exec(J))!==null){const F={start:H.index,end:H.index+H[0].length};if(_.some((Q)=>!(F.end<=Q.start||F.start>=Q.end)))continue;Z.push({field:H[1],min:b(H[2]),max:b(H[3]),span:F})}return Z},o=function(J){const Z=[],j=/\bids?\b\s+((?:-?\d+(?:\.\d+)?\s*,\s*)+-?\d+(?:\.\d+)?)\b/ig;let H;while((H=j.exec(J))!==null){const F=H[1].split(/\s*,\s*/).map(b);Z.push({kind:"in",values:F,span:{start:H.index,end:H.index+H[0].length}})}const _=/\bids?\b\s+(-?\d+(?:\.\d+)?)\b/ig;while((H=_.exec(J))!==null){const A={start:H.index,end:H.index+H[0].length};if(!Z.some((L)=>!(A.end<=L.span.start||A.start>=L.span.end)))Z.push({kind:"eq",value:b(H[1]),span:A})}return Z},r=function(J){const Z=[];let j;const H=/\b([a-z][\w\.]*)\s*(?:>=|at\s+least)\s*(-?\d+(?:\.\d+)?)\b/ig;while((j=H.exec(J))!==null)Z.push({field:j[1],op:"$gte",value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});const _=/\b([a-z][\w\.]*)\s*(?:<=|at\s+most)\s*(-?\d+(?:\.\d+)?)\b/ig;while((j=_.exec(J))!==null)Z.push({field:j[1],op:"$lte",value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});const A=/\b([a-z][\w\.]*)\s*(?:>|greater\s+than|more\s+than)\s*(-?\d+(?:\.\d+)?)\b/ig;while((j=A.exec(J))!==null)Z.push({field:j[1],op:"$gt",value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});const F=/\b([a-z][\w\.]*)\s*(?:<|less\s+than|fewer\s+than)\s*(-?\d+(?:\.\d+)?)\b/ig;while((j=F.exec(J))!==null)Z.push({field:j[1],op:"$lt",value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});const L=/\b([a-z][\w\.]*)\s*(?:=|equals|is)(?!\s+not)\s*"([^"]+)"\b/ig;while((j=L.exec(J))!==null)Z.push({field:j[1],op:"eq",value:j[2],span:{start:j.index,end:j.index+j[0].length}});const Q=/\b([a-z][\w\.]*)\s*(?:=|equals|is)(?!\s+not)\s*([a-z0-9_\-\.]+)\b/ig;while((j=Q.exec(J))!==null)Z.push({field:j[1],op:"eq",value:b(j[2]),span:{start:j.index,end:j.index+j[0].length}});return Z},Z0=function(J){const Z=[];let j;const H=/\b([a-z][\w\.]*)\s+(on\s+or\s+after|on\s+or\s+before|after|before|on)\s+(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\b/ig;while((j=H.exec(J))!==null){const _=j[1],A=j[2].toLowerCase().replace(/\s+/g," "),F=j[3]||j[4];let L="$gt";if(A==="before")L="$lt";else if(A==="on")L="eq";else if(A==="on or after")L="$gte";else if(A==="on or before")L="$lte";Z.push({field:_,op:L,value:F,span:{start:j.index,end:j.index+j[0].length}})}return Z},_0=function(J){const Z=[{re:/\b(?:order|sort|sorted)\s+by\s+([a-z][\w\.]*)\s*(asc|ascending|desc|descending)?\b/i,groups:{field:1,dir:2}},{re:/\b(?:order|sort|sorted)\s+(asc|ascending|desc|descending)\s+by\s+([a-z][\w\.]*)\b/i,groups:{dir:1,field:2}}];for(let j of Z){const H=J.match(j.re);if(H){const _=(H[j.groups.dir]||"asc").toLowerCase(),A=/desc|descending/.test(_)?"desc":"asc";return{field:H[j.groups.field],order:A}}}return null},U0=function(J){const Z=J.match(/\blimit\s+(\d+)\b/i);return Z?Number(Z[1]):null},b=function(J){const Z=Number(J);return Number.isFinite(Z)?Z:J},w=function(J){if(!Array.isArray(J))return J;const Z=[],j=(H)=>{const _=Array.isArray(H?._edgeResult)?H._edgeResult:null;if(_&&_.length)for(let A of _)j(A);else Z.push(H)};for(let H of J)j(H);return Z},$0=function(J){const Z=[];let j;const H=/\b([a-z][\w\.]*)\s*(=|is|equals)\s*("[^"]+"|[A-Za-z0-9_\-.]+)\s+or\s+\1\s*(=|is|equals)\s*("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((j=H.exec(J))!==null){const F={[j[1]]:D(j[3])},L={[j[1]]:D(j[5])};Z.push({left:F,right:L,span:{start:j.index,end:j.index+j[0].length}})}const _=/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\s+or\s+\1\s+(?:contains|containing)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((j=_.exec(J))!==null){const F={[j[1]]:{$contains:D(j[2])}},L={[j[1]]:{$contains:D(j[3])}};Z.push({left:F,right:L,span:{start:j.index,end:j.index+j[0].length}})}const A=/\b([a-z][\w\.]*)\s+starts\s+with\s+("[^"]+"|[A-Za-z0-9_\-]+)\s+or\s+\1\s+starts\s+with\s+("[^"]+"|[A-Za-z0-9_\-]+)\b/ig;while((j=A.exec(J))!==null){const F=String(D(j[2])),L=String(D(j[3])),Q={[j[1]]:{$regex:`^${F}`}},G={[j[1]]:{$regex:`^${L}`}};Z.push({left:Q,right:G,span:{start:j.index,end:j.index+j[0].length}})}return Z},D=function(J){if(!J)return J;const Z=J.replace(/^"|"$/g,"");return b(Z)},A0=function(J){if(!J||typeof J!=="object")return J;const{$edge:Z,...j}=J,H=Z?e(Z):void 0,_=Object.keys(j);if(_.length>1){const A={};if(H)A.$edge=H;return A.$and=_.map((F)=>({[F]:j[F]})),A}return{...j,...Z?{$edge:H}:{}}},e=function(J){if(!J||typeof J!=="object")return J;const{$edge:Z,...j}=J,H=Object.keys(j),_=Z?e(Z):void 0;if(H.length>1){const A={};if(_)A.$edge=_;return A.$and=H.map((F)=>({[F]:j[F]})),A}return{...j,..._?{$edge:_}:{}}},M0=function(J){const j=/\bonly\s+([A-Z][a-zA-Z]+)s?\b/ig.exec(J);if(!j)return null;return{type:O(j[1]),span:{start:j.index,end:j.index+j[0].length}}},F0=function(J){const j=/\b(?:a|an)\s+([A-Z][a-zA-Z]+)s?\b/ig.exec(J);if(!j)return null;return{type:O(j[1]),span:{start:j.index,end:j.index+j[0].length}}},Q0=function(J){const Z=J.split(/\bthen\b/ig).map((L)=>L.trim()).filter(Boolean);let j=null,H=null,_=null,A=null;for(let L of Z){const Q=x(L),G=H?.type?"type":H?.role?"role":null,T=G?String(H[G]).toLowerCase():null;let U=Q.match(/\bdescendant[s]?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),B=null,f="role",$=null,M=null,C=!1,P=Q.match(/\b(?:that|this|those|their|its)\s+([A-Za-z][A-Za-z]+)\s*'s\s+descendant[s]?\b/i);if(!P)P=Q.match(/\b(?:that|this|those|their|its)\s+([A-Za-z][A-Za-z]+)s?\s+descendant[s]?\b/i);if(P){const X=O(P[1]).toLowerCase();if(T&&X===T)C=!0,$=P.index,M=P.index+P[0].length}if(U)B=O(U[1]),$=U.index,M=U.index+U[0].length,f="type";else if(U=!C&&Q.match(/\b(?:that|this|those|their|its|a|an)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+descendant[s]?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;else if(U=!C&&Q.match(/\bdescendant[s]?\s+(?:of\s+)?(?!named\b|called\b|with\b)([A-Za-z][A-Za-z]+)s?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;else if(U=Q.match(/\bchild(?:ren)?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length,f="type";else if(U=Q.match(/\bchild(?:ren)?\s+(?:of\s+)?([A-Za-z][A-Za-z]+)s?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;else if(U=Q.match(/\b(?:that|this|those|their|its)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+child(?:ren)?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;else if(U=Q.match(/\bgrandchild(?:ren)?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length,f="type";else if(U=Q.match(/\bgrandchild(?:ren)?\s+(?:of\s+)?([A-Za-z][A-Za-z]+)s?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;else if(U=Q.match(/\b(?:that|this|those|their|its)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+grandchild(?:ren)?\b/i),U)B=O(U[1]),$=U.index,M=U.index+U[0].length;const v=/\b(descendant|child|children|grandchild|grandchildren)\b/i.test(Q);let V=null;if(B)V={[f]:B};else if(v)V={};else continue;const R=Q.match(/\b(?:named|called)\s+"([^"]+)"|\b(?:named|called)\s+([A-Za-z0-9_\-]+)\b|\bwith\s+name\s+"([^"]+)"|\bwith\s+name\s+([A-Za-z0-9_\-]+)\b/i);if(R){const X=R[1]||R[2]||R[3]||R[4];V.name=X;const Y=R.index,K=R[0].length;if($===null||Y<$)$=Y;const N=Y+K;if(M===null||N>M)M=N}for(let X of p(Q)){if(X.mode==="in"){const Y=X.values??[X.value];V[X.field]={...V[X.field]||{},$in:Y}}else V[X.field]={...V[X.field]||{},$contains:X.value};$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end)}for(let X of u(Q))V[X.field]={...V[X.field]||{},$regex:`^${X.value}`},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of c(Q))V[X.field]={...V[X.field]||{},$regex:`${X.value}\$`},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of a(Q))V[X.field]={...V[X.field]||{},$between:[X.min,X.max]},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of r(Q)){if(X.op==="eq")V[X.field]=X.value;else V[X.field]={...V[X.field]||{},[X.op]:X.value};$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end)}for(let X of n(Q))V[X.field]={...V[X.field]||{},$not:{$eq:X.value}},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of s(Q))V[X.field]={...V[X.field]||{},$in:X.values},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);const q=l(Q);for(let X of q)V[X.field]={...V[X.field]||{},$exists:!0},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);let h=Q.replace(/\b(?:has|with|having)\s+[a-z][\w\.]*\s+exists\b/ig," ").replace(/\bwhose\s+[a-z][\w\.]*\s+exists\b/ig," ").replace(/\b([a-z][\w\.]*)\s+exists\b/ig," ").replace(/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+(?:"[^\"]+"|[A-Za-z0-9_\-]+)/ig," ");for(let X of d(Q))V[X.field]={...V[X.field]||{},$like:X.value},$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of m(h))V[X.field]=X.value,$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end);for(let X of o(Q)){if(X.kind==="in")V.id={...V.id||{},$in:X.values};else if(X.kind==="eq")V.id=X.value;$=$==null?X.span.start:Math.min($,X.span.start),M=M==null?X.span.end:Math.max(M,X.span.end)}if(!V||Object.keys(V).length===0)continue;if(!j)j=V,H=V,_=_??J.indexOf(Q)+($??0),A=J.indexOf(Q)+(M??0);else{const X=H.type?"type":H.role?"role":null,Y=X?String(H[X]).toLowerCase():null,K=V.type?"type":V.role?"role":null,N=K?String(V[K]).toLowerCase():null;if(!H.$edge||typeof H.$edge!=="object")H.$edge={};const z=H.$edge,E=z.type?"type":z.role?"role":null,V0=E?String(z[E]).toLowerCase():null,g=(y)=>{const S={};for(let[I,t]of Object.entries(V)){if(I==="$edge")continue;if(y&&(I==="type"||I==="role"))continue;S[I]=t}return S};if(N&&Y&&N===Y)Object.assign(z,g(!0));else if(N){for(let y of["type","role"])delete z[y];Object.assign(z,g(!1))}else Object.assign(z,g(!1));H=H.$edge;const k=J.indexOf(Q);if(_===null)_=k+($??0);A=k+(M??0)}}if(!j)return null;const F=_!=null&&A!=null?{start:_,end:A}:void 0;return{edge:j,span:F}},O=function(J){if(!J)return J;if(/ies$/i.test(J))return J.replace(/ies$/i,"y");if(/ses$/i.test(J))return J.replace(/es$/i,"e");if(/s$/i.test(J))return J.replace(/s$/i,"");return J},L0=function(J){const Z={after:null,before:null,spans:[]},j=[{kind:"after",re:/\b(?:start(?:ing)?\s+)?after\s+(?:id\s+)?(?:"([^"]+)"|([A-Za-z0-9_\-]+))(?=\s|$)/ig},{kind:"before",re:/\b(?:before|until)\s+(?:id\s+)?(?:"([^"]+)"|([A-Za-z0-9_\-]+))(?=\s|$)/ig}];for(let H of j){let _;while((_=H.re.exec(J))!==null){const A=_[1]||_[2];if(H.kind==="after"&&!Z.after)Z.after=A;if(H.kind==="before"&&!Z.before)Z.before=A;Z.spans.push({start:_.index,end:_.index+_[0].length})}}return Z},G0=(J)=>{return console.log("\uD83E\uDDE0 NLQ module loaded (local DSL)."),j0(J)};export{j0 as withModule,G0 as init};
1
+ function _1(j){const H=j.map;return j.map=async function(..._){let Z={},J=null;_.forEach((B)=>{if(typeof B==="object")Z={...Z,...B};if(typeof B==="function")J=B});let M=!1;if(Z.prompt)try{const B=await Z1(Z.prompt);if(console.log("Query generated from local DSL:",B),Z={...Z,...B},B.__nlqReturnDeepest)M=!0;delete Z.prompt}catch(B){console.error("Error parsing prompt:",B.message),Z.query={}}const G=M&&J?(B)=>{try{const f=w(B);J&&J(f)}catch{J&&J(B)}}:J,Q=await H.call(this,Z,G);if(M&&Q&&Array.isArray(Q.results))Q.results=w(Q.results);return Q},j}async function Z1(j){return j1(j)}var j1=function(j){const H=i(String(j||""));let _=x(H);const Z={query:{}},J=Z.query,M=U1(_);if(M.length){Z.$_ors=[];for(let A of M)Z.$_ors.push(A.left,A.right),_=V(_,A.span)}const F=Q1(_);if(F)J.type=F.type,Z.type=F.type,_=V(_,F.span);if(!J.type){const A=G1(_);if(A)J.type=A.type,Z.type=A.type,_=V(_,A.span)}if(!J.type){const A=W1(_);if(A)J.type=A.type,Z.type=A.type,_=V(_,A.span)}const G=B1(_);if(G&&G.edge){if(J.$edge=G.edge,G.span)_=V(_,G.span)}if(G&&G.edge&&/\bthen\s+finds?\s+(?:that\s+[A-Za-z]+s?\s+)?descendant\s+(?:named|called|with\s+name)\b/i.test(H))Z.__nlqReturnDeepest=!0;const Q=p(_);for(let A of Q){if(A.mode==="in"){const L=A.values??[A.value];J[A.field]={...J[A.field]||{},$in:L}}else J[A.field]={...J[A.field]||{},$contains:A.value};_=V(_,A.span)}const B=u(_);for(let A of B)J[A.field]={...J[A.field]||{},$regex:`^${A.value}`},_=V(_,A.span);const f=c(_);for(let A of f)J[A.field]={...J[A.field]||{},$regex:`${A.value}\$`},_=V(_,A.span);const Y=d(_);for(let A of Y)J[A.field]={...J[A.field]||{},$like:A.value},_=V(_,A.span);const z=A1(_);if(z){const A=z.value,L=[{name:{$regex:A}},{role:{$regex:A}},{level:{$regex:A}},{country:{$regex:A}},{title:{$regex:A}},{body:{$regex:A}},{tags:{$in:[A]}}];Z.query.$or=[...Z.query.$or||[],...L],_=V(_,z.span)}else if(H1(_))Z.query.__nlq_no_match="__NLQ_NO_MATCH__";const C=l(_);for(let A of C)J[A.field]={...J[A.field]||{},$exists:!0},_=V(_,A.span);const $=V1(_);if($.after)Z.$after=$.after;if($.before)Z.$before=$.before;for(let A of $.spans)_=V(_,A);const U=m(_);for(let A of U)J[A.field]=A.value,_=V(_,A.span);const N=J1(_);for(let A of N)J.name=A.value,_=V(_,A.span);const R=X1(_);for(let A of R)J.country=A.value,_=V(_,A.span);const g=a(_);for(let A of g)J[A.field]={...J[A.field]||{},$between:[A.min,A.max]},_=V(_,A.span);const W=Y1(_);for(let A of W){if(A.op==="eq")J[A.field]=A.value;else J[A.field]={...J[A.field]||{},[A.op]:A.value};_=V(_,A.span)}const D=r(_);for(let A of D){if(A.op==="eq")J[A.field]=A.value;else J[A.field]={...J[A.field]||{},[A.op]:A.value};_=V(_,A.span)}const v=n(_);for(let A of v)J[A.field]={...J[A.field]||{},$not:{$eq:A.value}},_=V(_,A.span);const q=o(_);for(let A of q){if(A.kind==="in")J.id={...J.id||{},$in:A.values};else if(A.kind==="eq")J.id=A.value;_=V(_,A.span)}const X=s(_);for(let A of X)J[A.field]={...J[A.field]||{},$in:A.values},_=V(_,A.span);const P=$1(_);if(P)Z.order=P.order,Z.field=P.field;const b=M1(_);if(b!=null)Z.$limit=b;if(Z.order&&!Z.field){const A=Object.keys(J)[0];if(A)Z.field=A}if(Object.keys(Z.query).length===0){const A=!!Z.order,L=Z.$limit!=null,h=!!(Z.$after||Z.$before);if(!A&&!L&&!h)Z.query.__nlq_no_match="__NLQ_NO_MATCH__"}if(Z.$_ors&&Z.$_ors.length)Z.query.$or=[...Z.query.$or||[],...Z.$_ors],delete Z.$_ors;return Z.query=F1(Z.query),Z},i=function(j){return j.replace(/\s+/g," ").trim()},V=function(j,H){if(!H)return j;return i(`${j.slice(0,H.start)} ${j.slice(H.end)}`)},x=function(j){const H=/^(?:searches\s+for|search\s+for|searches|search|finds?|gets?|lists?|returns?|shows?|filters?)\s+/i;return j.replace(H,"")},p=function(j){const H=[],_=[{re:/\bwhose\s+([a-z][\w\.]*)\s+(includes|including|has)\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig,mode:"in",list:!0},{re:/\b([a-z][\w\.]*)\s+(includes|including|has)\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig,mode:"in",list:!0},{re:/\bwhose\s+([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?"([^\"]+)"/ig,mode:"contains"},{re:/\bwhose\s+([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?([A-Za-z0-9_\-]+)/ig,mode:"contains"},{re:/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?"([^\"]+)"/ig,mode:"contains"},{re:/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+(?:the\s+(?:word|phrase|number|value|text|string|token|term|email|url|date|time|datetime)s?\s*:?\s*)?([A-Za-z0-9_\-]+)/ig,mode:"contains"}];for(let{re:Z,mode:J,list:M}of _){let F;while((F=Z.exec(j))!==null){const G=F[1];if(J==="in"&&M){const B=F[3].split(/\s*,\s*/).map((f)=>f.replace(/^"|"$/g,""));H.push({field:G,mode:"in",values:B,span:{start:F.index,end:F.index+F[0].length}})}else if(J==="contains"){const Q=F[2];H.push({field:G,mode:"contains",value:Q,span:{start:F.index,end:F.index+F[0].length}})}}}return H},u=function(j){const H=[],_=/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+"([^\"]+)"/ig;let Z;while((Z=_.exec(j))!==null)H.push({field:Z[1],value:Z[2],span:{start:Z.index,end:Z.index+Z[0].length}});const J=/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+([A-Za-z0-9_\-]+)/ig;while((Z=J.exec(j))!==null)H.push({field:Z[1],value:Z[2],span:{start:Z.index,end:Z.index+Z[0].length}});return H},c=function(j){const H=[],_=/\b(?:whose\s+)?([a-z][\w\.]*)\s+ends\s+with\s+"([^\"]+)"/ig;let Z;while((Z=_.exec(j))!==null)H.push({field:Z[1],value:Z[2],span:{start:Z.index,end:Z.index+Z[0].length}});const J=/\b(?:whose\s+)?([a-z][\w\.]*)\s+ends\s+with\s+([A-Za-z0-9_\-]+)/ig;while((Z=J.exec(j))!==null)H.push({field:Z[1],value:Z[2],span:{start:Z.index,end:Z.index+Z[0].length}});return H},d=function(j){const H=[];let _;const Z=/\b(?:whose\s+)?([a-z][\w\.]*)\s+like\s+"([^\"]+)"/ig;while((_=Z.exec(j))!==null)H.push({field:_[1],value:_[2],span:{start:_.index,end:_.index+_[0].length}});const J=/\b(?:whose\s+)?([a-z][\w\.]*)\s+like\s+([A-Za-z0-9_%\-\.\*]+)/ig;while((_=J.exec(j))!==null)H.push({field:_[1],value:_[2],span:{start:_.index,end:_.index+_[0].length}});return H},A1=function(j){const _=/\b(?:full[-\s]?text\s+search|text\s+search)\s+(?:"([^\"]+)"|([A-Za-z0-9_\-]+))/i.exec(j);if(_)return{value:_[1]||_[2],span:{start:_.index,end:_.index+_[0].length}};return null},H1=function(j){return/\b(?:full[-\s]?text\s+search|text\s+search|full[-\s]?text)\b/i.test(j)},n=function(j){const H=[];let _;const Z=/\b([a-z][\w\.]*)\s*(?:!=|is\s+not|not\s+equals)\s+"([^\"]+)"\b/ig;while((_=Z.exec(j))!==null)H.push({field:_[1],value:_[2],span:{start:_.index,end:_.index+_[0].length}});const J=/\b([a-z][\w\.]*)\s*(?:!=|is\s+not|not\s+equals)\s+([A-Za-z0-9_\-\.]+)\b/ig;while((_=J.exec(j))!==null)H.push({field:_[1],value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});return H},s=function(j){const H=[];let _;const Z=/\b([a-z][\w\.]*)\s+is\s+([A-Za-z0-9_\-]+)\s+or\s+([A-Za-z0-9_\-]+)(?:\s+or\s+([A-Za-z0-9_\-]+))*/ig;while((_=Z.exec(j))!==null){const M=_[1],F=_[0].replace(new RegExp(`^${_[1]}\\s+is\\s+`,"i"),"").split(/\s+or\s+/i).map((G)=>G.trim().replace(/[,\.]$/,""));H.push({field:M,values:F,span:{start:_.index,end:_.index+_[0].length}})}const J=/\b([a-z][\w\.]*)\s+in\s+((?:"[^\"]+"|[A-Za-z0-9_\-]+)(?:\s*,\s*(?:"[^\"]+"|[A-Za-z0-9_\-]+))*)/ig;while((_=J.exec(j))!==null){const M=_[1],G=_[2].split(/\s*,\s*/).map((Q)=>Q.replace(/^"|"$/g,""));H.push({field:M,values:G,span:{start:_.index,end:_.index+_[0].length}})}return H},l=function(j){const H=[];let _;const Z=/\b(?:has|with|having)\s+([a-z][\w\.]*)\b(?!\s+(?:"[^"]+"|[A-Za-z0-9_\-.]+)\b)/ig;while((_=Z.exec(j))!==null)H.push({field:_[1],span:{start:_.index,end:_.index+_[0].length}});const J=/\b(?:has|with|having)\s+([a-z][\w\.]*)\s+exists\b/ig;while((_=J.exec(j))!==null)H.push({field:_[1],span:{start:_.index,end:_.index+_[0].length}});const M=/\bwhose\s+([a-z][\w\.]*)\s+exists\b/ig;while((_=M.exec(j))!==null)H.push({field:_[1],span:{start:_.index,end:_.index+_[0].length}});const F=/\b([a-z][\w\.]*)\s+exists\b/ig;while((_=F.exec(j))!==null)H.push({field:_[1],span:{start:_.index,end:_.index+_[0].length}});return H},m=function(j){const H=[];let _;const Z=/\bwith\s+([a-z][\w\.]*)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((_=Z.exec(j))!==null){const J=_[1],M=T(_[2]);H.push({field:J,value:M,span:{start:_.index,end:_.index+_[0].length}})}return H},J1=function(j){const H=[],_=/\bname\s+(?:"([^"]+)"|(([A-Z][a-zA-Z]+)(?:\s+[A-Z][a-zA-Z]+)*))\b/g;let Z;while((Z=_.exec(j))!==null){const J=Z[1]||(Z[2]?Z[2].trim():null);if(!J)continue;H.push({value:J,span:{start:Z.index,end:Z.index+Z[0].length}})}return H},X1=function(j){const H=[],_=/\bfrom\s+(?:"([^"]+)"|([A-Za-z][A-Za-z]+))\b/ig;let Z;while((Z=_.exec(j))!==null){const J=Z[1]||Z[2];H.push({value:J,span:{start:Z.index,end:Z.index+Z[0].length}})}return H},a=function(j){const H=[],_=/\b([a-z][\w\.]*)\s+between\s+(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\s*(?:and|,|to)\s*(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\b/ig;let Z;const J=[];while((Z=_.exec(j))!==null){const F={start:Z.index,end:Z.index+Z[0].length};H.push({field:Z[1],min:Z[2]||Z[3],max:Z[4]||Z[5],span:F}),J.push(F)}const M=/\b([a-z][\w\.]*)\s+between\s+(-?\d+(?:\.\d+)?)\s*(?:and|,|to)\s*(-?\d+(?:\.\d+)?)\b/ig;while((Z=M.exec(j))!==null){const F={start:Z.index,end:Z.index+Z[0].length};if(J.some((Q)=>!(F.end<=Q.start||F.start>=Q.end)))continue;H.push({field:Z[1],min:K(Z[2]),max:K(Z[3]),span:F})}return H},o=function(j){const H=[],_=/\bids?\b\s+((?:-?\d+(?:\.\d+)?\s*,\s*)+-?\d+(?:\.\d+)?)\b/ig;let Z;while((Z=_.exec(j))!==null){const F=Z[1].split(/\s*,\s*/).map(K);H.push({kind:"in",values:F,span:{start:Z.index,end:Z.index+Z[0].length}})}const J=/\bids?\b\s+(-?\d+(?:\.\d+)?)\b/ig;while((Z=J.exec(j))!==null){const M={start:Z.index,end:Z.index+Z[0].length};if(!H.some((G)=>!(M.end<=G.span.start||M.start>=G.span.end)))H.push({kind:"eq",value:K(Z[1]),span:M})}return H},r=function(j){const H=[];let _;const Z=/\b([a-z][\w\.]*)\s*(?:>=|at\s+least)\s*(-?\d+(?:\.\d+)?)\b/ig;while((_=Z.exec(j))!==null)H.push({field:_[1],op:"$gte",value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});const J=/\b([a-z][\w\.]*)\s*(?:<=|at\s+most)\s*(-?\d+(?:\.\d+)?)\b/ig;while((_=J.exec(j))!==null)H.push({field:_[1],op:"$lte",value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});const M=/\b([a-z][\w\.]*)\s*(?:>|greater\s+than|more\s+than)\s*(-?\d+(?:\.\d+)?)\b/ig;while((_=M.exec(j))!==null)H.push({field:_[1],op:"$gt",value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});const F=/\b([a-z][\w\.]*)\s*(?:<|less\s+than|fewer\s+than)\s*(-?\d+(?:\.\d+)?)\b/ig;while((_=F.exec(j))!==null)H.push({field:_[1],op:"$lt",value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});const G=/\b([a-z][\w\.]*)\s*(?:=|equals|is)(?!\s+not)\s*"([^"]+)"\b/ig;while((_=G.exec(j))!==null)H.push({field:_[1],op:"eq",value:_[2],span:{start:_.index,end:_.index+_[0].length}});const Q=/\b([a-z][\w\.]*)\s*(?:=|equals|is)(?!\s+not)\s*([a-z0-9_\-\.]+)\b/ig;while((_=Q.exec(j))!==null)H.push({field:_[1],op:"eq",value:K(_[2]),span:{start:_.index,end:_.index+_[0].length}});return H},Y1=function(j){const H=[];let _;const Z=/\b([a-z][\w\.]*)\s+(on\s+or\s+after|on\s+or\s+before|after|before|on)\s+(?:"([^"]+)"|([0-9]{4}-[0-9]{2}-[0-9]{2}[T\d:._+\-Z]*))\b/ig;while((_=Z.exec(j))!==null){const J=_[1],M=_[2].toLowerCase().replace(/\s+/g," "),F=_[3]||_[4];let G="$gt";if(M==="before")G="$lt";else if(M==="on")G="eq";else if(M==="on or after")G="$gte";else if(M==="on or before")G="$lte";H.push({field:J,op:G,value:F,span:{start:_.index,end:_.index+_[0].length}})}return H},$1=function(j){const H=[{re:/\b(?:order|sort|sorted)\s+by\s+([a-z][\w\.]*)\s*(asc|ascending|desc|descending)?\b/i,groups:{field:1,dir:2}},{re:/\b(?:order|sort|sorted)\s+(asc|ascending|desc|descending)\s+by\s+([a-z][\w\.]*)\b/i,groups:{dir:1,field:2}}];for(let _ of H){const Z=j.match(_.re);if(Z){const J=(Z[_.groups.dir]||"asc").toLowerCase(),M=/desc|descending/.test(J)?"desc":"asc";return{field:Z[_.groups.field],order:M}}}return null},M1=function(j){const H=j.match(/\blimit\s+(\d+)\b/i);return H?Number(H[1]):null},K=function(j){const H=Number(j);return Number.isFinite(H)?H:j},w=function(j){if(!Array.isArray(j))return j;const H=[],_=(Z)=>{const J=Array.isArray(Z?._edgeResult)?Z._edgeResult:null;if(J&&J.length)for(let M of J)_(M);else H.push(Z)};for(let Z of j)_(Z);return H},U1=function(j){const H=[];let _;const Z=/\b([a-z][\w\.]*)\s*(=|is|equals)\s*("[^"]+"|[A-Za-z0-9_\-.]+)\s+or\s+\1\s*(=|is|equals)\s*("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((_=Z.exec(j))!==null){const F={[_[1]]:T(_[3])},G={[_[1]]:T(_[5])};H.push({left:F,right:G,span:{start:_.index,end:_.index+_[0].length}})}const J=/\b([a-z][\w\.]*)\s+(?:contains|containing)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\s+or\s+\1\s+(?:contains|containing)\s+("[^"]+"|[A-Za-z0-9_\-.]+)\b/ig;while((_=J.exec(j))!==null){const F={[_[1]]:{$contains:T(_[2])}},G={[_[1]]:{$contains:T(_[3])}};H.push({left:F,right:G,span:{start:_.index,end:_.index+_[0].length}})}const M=/\b([a-z][\w\.]*)\s+starts\s+with\s+("[^"]+"|[A-Za-z0-9_\-]+)\s+or\s+\1\s+starts\s+with\s+("[^"]+"|[A-Za-z0-9_\-]+)\b/ig;while((_=M.exec(j))!==null){const F=String(T(_[2])),G=String(T(_[3])),Q={[_[1]]:{$regex:`^${F}`}},B={[_[1]]:{$regex:`^${G}`}};H.push({left:Q,right:B,span:{start:_.index,end:_.index+_[0].length}})}return H},T=function(j){if(!j)return j;const H=j.replace(/^"|"$/g,"");return K(H)},F1=function(j){if(!j||typeof j!=="object")return j;const{$edge:H,..._}=j,Z=H?e(H):void 0,J=Object.keys(_);if(J.length>1){const M={};if(Z)M.$edge=Z;return M.$and=J.map((F)=>({[F]:_[F]})),M}return{..._,...H?{$edge:Z}:{}}},e=function(j){if(!j||typeof j!=="object")return j;const{$edge:H,..._}=j,Z=Object.keys(_),J=H?e(H):void 0;if(Z.length>1){const M={};if(J)M.$edge=J;return M.$and=Z.map((F)=>({[F]:_[F]})),M}return{..._,...J?{$edge:J}:{}}},Q1=function(j){const _=/\bonly\s+([A-Z][a-zA-Z]+)s?\b/ig.exec(j);if(!_)return null;return{type:O(_[1]),span:{start:_.index,end:_.index+_[0].length}}},G1=function(j){const _=/\b(?:a|an)\s+([A-Z][a-zA-Z]+)s?\b/ig.exec(j);if(!_)return null;return{type:O(_[1]),span:{start:_.index,end:_.index+_[0].length}}},W1=function(j){if(/^(?:full[-\s]?text\s+search|text\s+search)\b/i.test(j))return null;const H=j.match(/^([A-Z][a-zA-Z]+)s?\b/);if(!H)return null;return{type:O(H[1]),span:{start:0,end:H[0].length}}},B1=function(j){const H=j.split(/\bthen\b/ig).map((G)=>G.trim()).filter(Boolean);let _=null,Z=null,J=null,M=null;for(let G of H){const Q=x(G),B=Z?.type?"type":Z?.role?"role":null,f=B?String(Z[B]).toLowerCase():null;let Y=Q.match(/\bdescendant[s]?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),z=null,C="role",$=null,U=null,N=!1,R=Q.match(/\b(?:that|this|those|their|its)\s+([A-Za-z][A-Za-z]+)\s*'s\s+descendant[s]?\b/i);if(!R)R=Q.match(/\b(?:that|this|those|their|its)\s+([A-Za-z][A-Za-z]+)s?\s+descendant[s]?\b/i);if(R){const X=O(R[1]).toLowerCase();if(f&&X===f)N=!0,$=R.index,U=R.index+R[0].length}if(Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length,C="type";else if(Y=!N&&Q.match(/\b(?:that|this|those|their|its|a|an)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+descendant[s]?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;else if(Y=!N&&Q.match(/\bdescendant[s]?\s+(?:of\s+)?(?!named\b|called\b|with\b)([A-Za-z][A-Za-z]+)s?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;else if(Y=Q.match(/\bchild(?:ren)?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length,C="type";else if(Y=Q.match(/\bchild(?:ren)?\s+(?:of\s+)?([A-Za-z][A-Za-z]+)s?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;else if(Y=Q.match(/\b(?:that|this|those|their|its)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+child(?:ren)?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;else if(Y=Q.match(/\bgrandchild(?:ren)?\s+of\s+type\s+([A-Za-z][A-Za-z]+)s?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length,C="type";else if(Y=Q.match(/\bgrandchild(?:ren)?\s+(?:of\s+)?([A-Za-z][A-Za-z]+)s?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;else if(Y=Q.match(/\b(?:that|this|those|their|its)?\s*([A-Za-z][A-Za-z]+)s?(?:'s)?\s+grandchild(?:ren)?\b/i),Y)z=O(Y[1]),$=Y.index,U=Y.index+Y[0].length;const g=/\b(descendant|child|children|grandchild|grandchildren)\b/i.test(Q);let W=null;if(z)W={[C]:z};else if(g)W={};else continue;const D=Q.match(/\b(?:named|called)\s+"([^"]+)"|\b(?:named|called)\s+([A-Za-z0-9_\-]+)\b|\bwith\s+name\s+"([^"]+)"|\bwith\s+name\s+([A-Za-z0-9_\-]+)\b/i);if(D){const X=D[1]||D[2]||D[3]||D[4];W.name=X;const P=D.index,b=D[0].length;if($===null||P<$)$=P;const A=P+b;if(U===null||A>U)U=A}for(let X of p(Q)){if(X.mode==="in"){const P=X.values??[X.value];W[X.field]={...W[X.field]||{},$in:P}}else W[X.field]={...W[X.field]||{},$contains:X.value};$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end)}for(let X of u(Q))W[X.field]={...W[X.field]||{},$regex:`^${X.value}`},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of c(Q))W[X.field]={...W[X.field]||{},$regex:`${X.value}\$`},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of a(Q))W[X.field]={...W[X.field]||{},$between:[X.min,X.max]},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of r(Q)){if(X.op==="eq")W[X.field]=X.value;else W[X.field]={...W[X.field]||{},[X.op]:X.value};$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end)}for(let X of n(Q))W[X.field]={...W[X.field]||{},$not:{$eq:X.value}},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of s(Q))W[X.field]={...W[X.field]||{},$in:X.values},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);const v=l(Q);for(let X of v)W[X.field]={...W[X.field]||{},$exists:!0},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);let q=Q.replace(/\b(?:has|with|having)\s+[a-z][\w\.]*\s+exists\b/ig," ").replace(/\bwhose\s+[a-z][\w\.]*\s+exists\b/ig," ").replace(/\b([a-z][\w\.]*)\s+exists\b/ig," ").replace(/\b(?:whose\s+)?([a-z][\w\.]*)\s+starts\s+with\s+(?:"[^\"]+"|[A-Za-z0-9_\-]+)/ig," ");for(let X of d(Q))W[X.field]={...W[X.field]||{},$like:X.value},$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of m(q))W[X.field]=X.value,$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end);for(let X of o(Q)){if(X.kind==="in")W.id={...W.id||{},$in:X.values};else if(X.kind==="eq")W.id=X.value;$=$==null?X.span.start:Math.min($,X.span.start),U=U==null?X.span.end:Math.max(U,X.span.end)}if(!W||Object.keys(W).length===0)continue;if(!_)_=W,Z=W,J=J??j.indexOf(Q)+($??0),M=j.indexOf(Q)+(U??0);else{const X=Z.type?"type":Z.role?"role":null,P=X?String(Z[X]).toLowerCase():null,b=W.type?"type":W.role?"role":null,A=b?String(W[b]).toLowerCase():null;if(!Z.$edge||typeof Z.$edge!=="object")Z.$edge={};const L=Z.$edge,h=L.type?"type":L.role?"role":null,z1=h?String(L[h]).toLowerCase():null,y=(E)=>{const k={};for(let[I,t]of Object.entries(W)){if(I==="$edge")continue;if(E&&(I==="type"||I==="role"))continue;k[I]=t}return k};if(A&&P&&A===P)Object.assign(L,y(!0));else if(A){for(let E of["type","role"])delete L[E];Object.assign(L,y(!1))}else Object.assign(L,y(!1));Z=Z.$edge;const S=j.indexOf(Q);if(J===null)J=S+($??0);M=S+(U??0)}}if(!_)return null;const F=J!=null&&M!=null?{start:J,end:M}:void 0;return{edge:_,span:F}},O=function(j){if(!j)return j;if(/ies$/i.test(j))return j.replace(/ies$/i,"y");if(/ses$/i.test(j))return j.replace(/es$/i,"e");if(/s$/i.test(j))return j.replace(/s$/i,"");return j},V1=function(j){const H={after:null,before:null,spans:[]},_=[{kind:"after",re:/\b(?:start(?:ing)?\s+)?after\s+(?:id\s+)?(?:"([^"]+)"|([A-Za-z0-9_\-]+))(?=\s|$)/ig},{kind:"before",re:/\b(?:before|until)\s+(?:id\s+)?(?:"([^"]+)"|([A-Za-z0-9_\-]+))(?=\s|$)/ig}];for(let Z of _){let J;while((J=Z.re.exec(j))!==null){const M=J[1]||J[2];if(Z.kind==="after"&&!H.after)H.after=M;if(Z.kind==="before"&&!H.before)H.before=M;H.spans.push({start:J.index,end:J.index+J[0].length})}}return H},L1=(j)=>{return console.log("\uD83E\uDDE0 NLQ module loaded (local DSL)."),_1(j)};export{_1 as withModule,L1 as init};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genosdb",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
4
4
  "description": "GenosDB (GDB): distributed graph database in real-time, peer-to-peer, scalable storage - efficient querying of complex relationships.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@vitest/ui": "3.2.4",
52
- "eslint": "9.35.0",
52
+ "eslint": "9.37.0",
53
53
  "eslint-config-standard": "17.1.0",
54
54
  "eslint-plugin-import": "2.32.0",
55
- "eslint-plugin-n": "17.21.3",
55
+ "eslint-plugin-n": "17.23.1",
56
56
  "eslint-plugin-promise": "7.2.1",
57
- "jsdom": "26.1.0",
57
+ "jsdom": "27.0.0",
58
58
  "vitest": "3.2.4"
59
59
  }
60
60
  }