just-bash 1.5.4 → 2.1.0
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/README.md +11 -9
- package/dist/AGENTS.md +139 -76
- package/dist/bin/chunks/chunk-WEONT2KP.js +6 -0
- package/dist/bin/chunks/jq-DT3MD2GZ.js +16 -0
- package/dist/bin/chunks/yq-XRJR6BNP.js +304 -0
- package/dist/bin/just-bash.js +38 -38
- package/dist/bin/shell/chunks/chunk-WEONT2KP.js +6 -0
- package/dist/bin/shell/chunks/jq-DT3MD2GZ.js +16 -0
- package/dist/bin/shell/chunks/yq-XRJR6BNP.js +304 -0
- package/dist/bin/shell/shell.js +54 -54
- package/dist/browser.d.ts +22 -0
- package/dist/bundle/{ai/index.js → browser.js} +310 -314
- package/dist/bundle/chunks/chunk-OQ2MSNPG.js +5 -0
- package/dist/bundle/chunks/jq-NZZAXGBX.js +15 -0
- package/dist/bundle/chunks/yq-63LJU3AR.js +303 -0
- package/dist/bundle/index.js +35 -35
- package/dist/commands/query-engine/evaluator.d.ts +25 -0
- package/dist/commands/query-engine/index.d.ts +8 -0
- package/dist/commands/{jq → query-engine}/parser.d.ts +3 -2
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/yq/formats.d.ts +64 -0
- package/dist/commands/yq/yq.d.ts +11 -0
- package/package.json +16 -23
- package/dist/ai/index.d.ts +0 -66
- package/dist/bin/chunks/jq-TRAUXD47.js +0 -19
- package/dist/bin/shell/chunks/jq-TRAUXD47.js +0 -19
- package/dist/bundle/chunks/jq-PO3DWIV2.js +0 -18
- package/dist/commands/jq/evaluator.d.ts +0 -18
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{i as g}from"./chunk-CG2HXOFG.js";import{a as L,b as M,c as T}from"./chunk-74CEPOFO.js";import"./chunk-2RUN43TJ.js";var K=1e4;function W(t){return{vars:new Map,limits:{maxIterations:t?.maxIterations??K}}}function w(t,r,s){let i=new Map(t.vars);return i.set(r,s),{vars:i,limits:t.limits}}function u(t,r,s){let i=s&&"vars"in s?s:W(s?.limits);switch(r.type){case"Identity":return[t];case"Field":return(r.base?u(t,r.base,i):[t]).flatMap(n=>n&&typeof n=="object"&&!Array.isArray(n)?[n[r.name]]:[null]);case"Index":return(r.base?u(t,r.base,i):[t]).flatMap(n=>u(n,r.index,i).flatMap(f=>{if(typeof f=="number"&&Array.isArray(n)){let c=f<0?n.length+f:f;return c>=0&&c<n.length?[n[c]]:[null]}return typeof f=="string"&&n&&typeof n=="object"&&!Array.isArray(n)?[n[f]]:[null]}));case"Slice":return(r.base?u(t,r.base,i):[t]).flatMap(n=>{if(!Array.isArray(n)&&typeof n!="string")return[null];let o=n.length,f=r.start?u(t,r.start,i):[0],c=r.end?u(t,r.end,i):[o];return f.flatMap(p=>c.map(y=>{let h=D(p,o),l=D(y,o);return Array.isArray(n),n.slice(h,l)}))});case"Iterate":return(r.base?u(t,r.base,i):[t]).flatMap(n=>Array.isArray(n)?n:n&&typeof n=="object"?Object.values(n):[]);case"Pipe":return u(t,r.left,i).flatMap(n=>u(n,r.right,i));case"Comma":{let e=u(t,r.left,i),n=u(t,r.right,i);return[...e,...n]}case"Literal":return[r.value];case"Array":return r.elements?[u(t,r.elements,i)]:[[]];case"Object":{let e=[{}];for(let n of r.entries){let o=typeof n.key=="string"?[n.key]:u(t,n.key,i),f=u(t,n.value,i),c=[];for(let p of e)for(let y of o)for(let h of f)c.push({...p,[String(y)]:h});e.length=0,e.push(...c)}return e}case"Paren":return u(t,r.expr,i);case"BinaryOp":return V(t,r.op,r.left,r.right,i);case"UnaryOp":return u(t,r.operand,i).map(n=>r.op==="-"?typeof n=="number"?-n:null:r.op==="not"?!b(n):null);case"Cond":return u(t,r.cond,i).flatMap(n=>{if(b(n))return u(t,r.then,i);for(let o of r.elifs)if(u(t,o.cond,i).some(b))return u(t,o.then,i);return r.else?u(t,r.else,i):[null]});case"Try":try{return u(t,r.body,i)}catch{return r.catch?u(t,r.catch,i):[]}case"Call":return B(t,r.name,r.args,i);case"VarBind":return u(t,r.value,i).flatMap(n=>{let o=w(i,r.name,n);return u(t,r.body,o)});case"VarRef":{let e=i.vars.get(r.name);return e!==void 0?[e]:[null]}case"Recurse":{let e=[],n=new WeakSet,o=f=>{if(f&&typeof f=="object"){if(n.has(f))return;n.add(f)}if(e.push(f),Array.isArray(f))for(let c of f)o(c);else if(f&&typeof f=="object")for(let c of Object.keys(f))o(f[c])};return o(t),e}case"Optional":try{return u(t,r.expr,i)}catch{return[]}case"StringInterp":return[r.parts.map(n=>typeof n=="string"?n:u(t,n,i).map(f=>typeof f=="string"?f:JSON.stringify(f)).join("")).join("")];case"UpdateOp":return[G(t,r.path,r.op,r.value,i)];case"Reduce":{let e=u(t,r.expr,i),n=u(t,r.init,i)[0];for(let o of e){let f=w(i,r.varName,o);n=u(n,r.update,f)[0]}return[n]}case"Foreach":{let e=u(t,r.expr,i),n=u(t,r.init,i)[0],o=[];for(let f of e){let c=w(i,r.varName,f);if(n=u(n,r.update,c)[0],r.extract){let p=u(n,r.extract,c);o.push(...p)}else o.push(n)}return o}default:{let e=r;throw new Error(`Unknown AST node type: ${e.type}`)}}}function D(t,r){return t<0?Math.max(0,r+t):Math.min(t,r)}function G(t,r,s,i,e){function n(c,p){switch(s){case"=":return p;case"|=":return u(c,i,e)[0]??null;case"+=":return typeof c=="number"&&typeof p=="number"||typeof c=="string"&&typeof p=="string"?c+p:Array.isArray(c)&&Array.isArray(p)?[...c,...p]:c&&p&&typeof c=="object"&&typeof p=="object"?{...c,...p}:p;case"-=":return typeof c=="number"&&typeof p=="number"?c-p:c;case"*=":return typeof c=="number"&&typeof p=="number"?c*p:c;case"/=":return typeof c=="number"&&typeof p=="number"?c/p:c;case"%=":return typeof c=="number"&&typeof p=="number"?c%p:c;case"//=":return c===null||c===!1?p:c;default:return p}}function o(c,p,y){switch(p.type){case"Identity":return y(c);case"Field":{if(p.base)return o(c,p.base,h=>{if(h&&typeof h=="object"&&!Array.isArray(h)){let l={...h};return l[p.name]=y(l[p.name]),l}return h});if(c&&typeof c=="object"&&!Array.isArray(c)){let h={...c};return h[p.name]=y(h[p.name]),h}return c}case"Index":{let l=u(t,p.index,e)[0];if(p.base)return o(c,p.base,A=>{if(typeof l=="number"&&Array.isArray(A)){let m=[...A],a=l<0?m.length+l:l;return a>=0&&a<m.length&&(m[a]=y(m[a])),m}if(typeof l=="string"&&A&&typeof A=="object"&&!Array.isArray(A)){let m={...A};return m[l]=y(m[l]),m}return A});if(typeof l=="number"&&Array.isArray(c)){let A=[...c],m=l<0?A.length+l:l;return m>=0&&m<A.length&&(A[m]=y(A[m])),A}if(typeof l=="string"&&c&&typeof c=="object"&&!Array.isArray(c)){let A={...c};return A[l]=y(A[l]),A}return c}case"Iterate":{let h=l=>{if(Array.isArray(l))return l.map(A=>y(A));if(l&&typeof l=="object"){let A={};for(let[m,a]of Object.entries(l))A[m]=y(a);return A}return l};return p.base?o(c,p.base,h):h(c)}case"Pipe":{let h=o(c,p.left,l=>l);return o(h,p.right,y)}default:return y(c)}}return o(t,r,c=>{if(s==="|=")return n(c,c);let p=u(t,i,e);return n(c,p[0]??null)})}function H(t,r,s){function i(e,n){switch(n.type){case"Identity":return null;case"Field":{if(e&&typeof e=="object"&&!Array.isArray(e)){let o={...e};return delete o[n.name],o}return e}case"Index":{let f=u(t,n.index,s)[0];if(typeof f=="number"&&Array.isArray(e)){let c=[...e],p=f<0?c.length+f:f;return p>=0&&p<c.length&&c.splice(p,1),c}if(typeof f=="string"&&e&&typeof e=="object"&&!Array.isArray(e)){let c={...e};return delete c[f],c}return e}case"Iterate":return Array.isArray(e)?[]:e&&typeof e=="object"?{}:e;default:return e}}return i(t,r)}function b(t){return t!==null&&t!==!1}function V(t,r,s,i,e){if(r==="and")return u(t,s,e).flatMap(c=>b(c)?u(t,i,e).map(y=>b(y)):[!1]);if(r==="or")return u(t,s,e).flatMap(c=>b(c)?[!0]:u(t,i,e).map(y=>b(y)));if(r==="//"){let c=u(t,s,e).filter(p=>p!=null&&p!==!1);return c.length>0?c:u(t,i,e)}let n=u(t,s,e),o=u(t,i,e);return n.flatMap(f=>o.map(c=>{switch(r){case"+":return typeof f=="number"&&typeof c=="number"||typeof f=="string"&&typeof c=="string"?f+c:Array.isArray(f)&&Array.isArray(c)?[...f,...c]:f&&c&&typeof f=="object"&&typeof c=="object"&&!Array.isArray(f)&&!Array.isArray(c)?{...f,...c}:null;case"-":if(typeof f=="number"&&typeof c=="number")return f-c;if(Array.isArray(f)&&Array.isArray(c)){let p=new Set(c.map(y=>JSON.stringify(y)));return f.filter(y=>!p.has(JSON.stringify(y)))}return null;case"*":return typeof f=="number"&&typeof c=="number"?f*c:typeof f=="string"&&typeof c=="number"?f.repeat(c):f&&c&&typeof f=="object"&&typeof c=="object"&&!Array.isArray(f)&&!Array.isArray(c)?U(f,c):null;case"/":return typeof f=="number"&&typeof c=="number"?f/c:typeof f=="string"&&typeof c=="string"?f.split(c):null;case"%":return typeof f=="number"&&typeof c=="number"?f%c:null;case"==":return O(f,c);case"!=":return!O(f,c);case"<":return N(f,c)<0;case"<=":return N(f,c)<=0;case">":return N(f,c)>0;case">=":return N(f,c)>=0;default:return null}}))}function O(t,r){return JSON.stringify(t)===JSON.stringify(r)}function N(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function U(t,r){let s={...t};for(let i of Object.keys(r))i in s&&s[i]&&typeof s[i]=="object"&&!Array.isArray(s[i])&&r[i]&&typeof r[i]=="object"&&!Array.isArray(r[i])?s[i]=U(s[i],r[i]):s[i]=r[i];return s}function B(t,r,s,i){switch(r){case"keys":return Array.isArray(t)?[t.map((e,n)=>n)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((e,n)=>n)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"values":return Array.isArray(t)?[t]:t&&typeof t=="object"?[Object.values(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:[null];case"utf8bytelength":return typeof t=="string"?[new TextEncoder().encode(t).length]:[null];case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"empty":return[];case"error":{let e=s.length>0?u(t,s[0],i)[0]:t;throw new Error(String(e))}case"not":return[!b(t)];case"null":return[null];case"true":return[!0];case"false":return[!1];case"first":if(s.length>0){let e=u(t,s[0],i);return e.length>0?[e[0]]:[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(s.length>0){let e=u(t,s[0],i);return e.length>0?[e[e.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(s.length<1)return[null];let n=u(t,s[0],i)[0];if(s.length>1){let o=u(t,s[1],i);return n>=0&&n<o.length?[o[n]]:[]}return Array.isArray(t)?n>=0&&n<t.length?[t[n]]:[null]:[null]}case"range":{if(s.length===0)return[];let e=u(t,s[0],i);if(s.length===1){let p=e[0];return Array.from({length:p},(y,h)=>h)}let n=u(t,s[1],i),o=e[0],f=n[0],c=[];for(let p=o;p<f;p++)c.push(p);return c}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"sort":return Array.isArray(t)?[[...t].sort(j)]:[null];case"sort_by":return!Array.isArray(t)||s.length===0?[null]:[[...t].sort((n,o)=>{let f=u(n,s[0],i)[0],c=u(o,s[0],i)[0];return j(f,c)})];case"unique":if(Array.isArray(t)){let e=new Set,n=[];for(let o of t){let f=JSON.stringify(o);e.has(f)||(e.add(f),n.push(o))}return[n]}return[null];case"unique_by":{if(!Array.isArray(t)||s.length===0)return[null];let e=new Set,n=[];for(let o of t){let f=JSON.stringify(u(o,s[0],i)[0]);e.has(f)||(e.add(f),n.push(o))}return[n]}case"group_by":{if(!Array.isArray(t)||s.length===0)return[null];let e=new Map;for(let n of t){let o=JSON.stringify(u(n,s[0],i)[0]);e.has(o)||e.set(o,[]),e.get(o)?.push(n)}return[[...e.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((e,n)=>j(e,n)>0?e:n)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||s.length===0?[null]:[t.reduce((e,n)=>{let o=u(e,s[0],i)[0],f=u(n,s[0],i)[0];return j(o,f)>0?e:n})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((e,n)=>j(e,n)<0?e:n)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||s.length===0?[null]:[t.reduce((e,n)=>{let o=u(e,s[0],i)[0],f=u(n,s[0],i)[0];return j(o,f)<0?e:n})];case"flatten":{if(!Array.isArray(t))return[null];let e=s.length>0?u(t,s[0],i)[0]:Number.POSITIVE_INFINITY;return[t.flat(e)]}case"add":if(Array.isArray(t)){if(t.length===0)return[null];if(t.every(e=>typeof e=="number"))return[t.reduce((e,n)=>e+n,0)];if(t.every(e=>typeof e=="string"))return[t.join("")];if(t.every(e=>Array.isArray(e)))return[t.flat()];if(t.every(e=>e&&typeof e=="object"&&!Array.isArray(e)))return[Object.assign({},...t)]}return[null];case"any":return s.length>0?Array.isArray(t)?[t.some(e=>b(u(e,s[0],i)[0]))]:[!1]:Array.isArray(t)?[t.some(b)]:[!1];case"all":return s.length>0?Array.isArray(t)?[t.every(e=>b(u(e,s[0],i)[0]))]:[!0]:Array.isArray(t)?[t.every(b)]:[!0];case"select":return s.length===0?[t]:u(t,s[0],i).some(b)?[t]:[];case"map":return s.length===0||!Array.isArray(t)?[null]:[t.flatMap(n=>u(n,s[0],i))];case"map_values":{if(s.length===0)return[null];if(Array.isArray(t))return[t.flatMap(e=>u(e,s[0],i))];if(t&&typeof t=="object"){let e={};for(let[n,o]of Object.entries(t)){let f=u(o,s[0],i);f.length>0&&(e[n]=f[0])}return[e]}return[null]}case"has":{if(s.length===0)return[!1];let n=u(t,s[0],i)[0];return Array.isArray(t)&&typeof n=="number"?[n>=0&&n<t.length]:t&&typeof t=="object"&&typeof n=="string"?[n in t]:[!1]}case"in":{if(s.length===0)return[!1];let n=u(t,s[0],i)[0];return Array.isArray(n)&&typeof t=="number"?[t>=0&&t<n.length]:n&&typeof n=="object"&&typeof t=="string"?[t in n]:[!1]}case"contains":{if(s.length===0)return[!1];let e=u(t,s[0],i);return[x(t,e[0])]}case"inside":{if(s.length===0)return[!1];let e=u(t,s[0],i);return[x(e[0],t)]}case"getpath":{if(s.length===0)return[null];let n=u(t,s[0],i)[0],o=t;for(let f of n){if(o==null)return[null];if(Array.isArray(o)&&typeof f=="number")o=o[f];else if(typeof o=="object"&&typeof f=="string")o=o[f];else return[null]}return[o]}case"setpath":{if(s.length<2)return[null];let n=u(t,s[0],i)[0],f=u(t,s[1],i)[0];return[I(t,n,f)]}case"delpaths":{if(s.length===0)return[t];let n=u(t,s[0],i)[0],o=t;for(let f of n.sort((c,p)=>p.length-c.length))o=C(o,f);return[o]}case"path":{if(s.length===0)return[[]];let e=[];return Q(t,s[0],i,[],e),e}case"del":return s.length===0?[t]:[H(t,s[0],i)];case"paths":{let e=[],n=(o,f)=>{if(o&&typeof o=="object")if(Array.isArray(o))for(let c=0;c<o.length;c++)e.push([...f,c]),n(o[c],[...f,c]);else for(let c of Object.keys(o))e.push([...f,c]),n(o[c],[...f,c])};return n(t,[]),s.length>0?e.filter(o=>{let f=t;for(let p of o)if(Array.isArray(f)&&typeof p=="number")f=f[p];else if(f&&typeof f=="object"&&typeof p=="string")f=f[p];else return!1;return u(f,s[0],i).some(b)}):e}case"leaf_paths":{let e=[],n=(o,f)=>{if(o===null||typeof o!="object")e.push(f);else if(Array.isArray(o))for(let c=0;c<o.length;c++)n(o[c],[...f,c]);else for(let c of Object.keys(o))n(o[c],[...f,c])};return n(t,[]),[e]}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([e,n])=>({key:e,value:n}))]:[null];case"from_entries":if(Array.isArray(t)){let e={};for(let n of t)if(n&&typeof n=="object"){let o=n,f=o.key??o.name??o.k,c=o.value??o.v;f!==void 0&&(e[String(f)]=c)}return[e]}return[null];case"with_entries":{if(s.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let n=Object.entries(t).map(([f,c])=>({key:f,value:c})).flatMap(f=>u(f,s[0],i)),o={};for(let f of n)if(f&&typeof f=="object"){let c=f,p=c.key??c.name??c.k,y=c.value??c.v;p!==void 0&&(o[String(p)]=y)}return[o]}return[null]}case"join":{if(!Array.isArray(t))return[null];let e=s.length>0?u(t,s[0],i):[""],n=String(e[0]);return[t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(n)]}case"split":{if(typeof t!="string"||s.length===0)return[null];let e=u(t,s[0],i),n=String(e[0]);return[t.split(n)]}case"test":{if(typeof t!="string"||s.length===0)return[!1];let e=u(t,s[0],i),n=String(e[0]);try{let o=s.length>1?String(u(t,s[1],i)[0]):"";return[new RegExp(n,o).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||s.length===0)return[null];let e=u(t,s[0],i),n=String(e[0]);try{let o=s.length>1?String(u(t,s[1],i)[0]):"",c=new RegExp(n,`${o}d`).exec(t);if(!c)return[];let p=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((y,h)=>({offset:p?.[h+1]?.[0]??null,length:y?.length??0,string:y??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||s.length===0)return[null];let e=u(t,s[0],i),n=String(e[0]);try{let o=s.length>1?String(u(t,s[1],i)[0]):"",f=new RegExp(n,o),c=t.match(f);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||s.length<2)return[null];let e=u(t,s[0],i),n=u(t,s[1],i),o=String(e[0]),f=String(n[0]);try{let c=s.length>2?String(u(t,s[2],i)[0]):"";return[t.replace(new RegExp(o,c),f)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||s.length<2)return[null];let e=u(t,s[0],i),n=u(t,s[1],i),o=String(e[0]),f=String(n[0]);try{let c=s.length>2?String(u(t,s[2],i)[0]):"g",p=c.includes("g")?c:`${c}g`;return[t.replace(new RegExp(o,p),f)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.toLowerCase()]:[null];case"ascii_upcase":return typeof t=="string"?[t.toUpperCase()]:[null];case"ltrimstr":{if(typeof t!="string"||s.length===0)return[t];let e=u(t,s[0],i),n=String(e[0]);return[t.startsWith(n)?t.slice(n.length):t]}case"rtrimstr":{if(typeof t!="string"||s.length===0)return[t];let e=u(t,s[0],i),n=String(e[0]);return[t.endsWith(n)?t.slice(0,-n.length):t]}case"startswith":{if(typeof t!="string"||s.length===0)return[!1];let e=u(t,s[0],i);return[t.startsWith(String(e[0]))]}case"endswith":{if(typeof t!="string"||s.length===0)return[!1];let e=u(t,s[0],i);return[t.endsWith(String(e[0]))]}case"index":{if(s.length===0)return[null];let n=u(t,s[0],i)[0];if(typeof t=="string"&&typeof n=="string"){let o=t.indexOf(n);return[o>=0?o:null]}if(Array.isArray(t)){let o=t.findIndex(f=>O(f,n));return[o>=0?o:null]}return[null]}case"rindex":{if(s.length===0)return[null];let n=u(t,s[0],i)[0];if(typeof t=="string"&&typeof n=="string"){let o=t.lastIndexOf(n);return[o>=0?o:null]}if(Array.isArray(t)){for(let o=t.length-1;o>=0;o--)if(O(t[o],n))return[o];return[null]}return[null]}case"indices":{if(s.length===0)return[[]];let n=u(t,s[0],i)[0],o=[];if(typeof t=="string"&&typeof n=="string"){let f=t.indexOf(n);for(;f!==-1;)o.push(f),f=t.indexOf(n,f+1)}else if(Array.isArray(t))for(let f=0;f<t.length;f++)O(t[f],n)&&o.push(f);return[o]}case"floor":return typeof t=="number"?[Math.floor(t)]:[null];case"ceil":return typeof t=="number"?[Math.ceil(t)]:[null];case"round":return typeof t=="number"?[Math.round(t)]:[null];case"sqrt":return typeof t=="number"?[Math.sqrt(t)]:[null];case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:[null];case"log":return typeof t=="number"?[Math.log(t)]:[null];case"log10":return typeof t=="number"?[Math.log10(t)]:[null];case"log2":return typeof t=="number"?[Math.log2(t)]:[null];case"exp":return typeof t=="number"?[Math.exp(t)]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(typeof t!="number"||s.length===0)return[null];let n=u(t,s[0],i)[0];return[t**n]}case"sin":return typeof t=="number"?[Math.sin(t)]:[null];case"cos":return typeof t=="number"?[Math.cos(t)]:[null];case"tan":return typeof t=="number"?[Math.tan(t)]:[null];case"asin":return typeof t=="number"?[Math.asin(t)]:[null];case"acos":return typeof t=="number"?[Math.acos(t)]:[null];case"atan":return typeof t=="number"?[Math.atan(t)]:[null];case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let e=Number(t);return[Number.isNaN(e)?null:e]}return[null];case"infinite":return[!Number.isFinite(t)];case"nan":return[Number.isNaN(t)];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"now":return[Date.now()/1e3];case"env":return[{}];case"recurse":{if(s.length===0){let f=[],c=p=>{if(f.push(p),Array.isArray(p))for(let y of p)c(y);else if(p&&typeof p=="object")for(let y of Object.keys(p))c(p[y])};return c(t),f}let e=[],n=new Set,o=f=>{let c=JSON.stringify(f);if(n.has(c))return;n.add(c),e.push(f);let p=u(f,s[0],i);for(let y of p)y!=null&&o(y)};return o(t),e}case"recurse_down":return B(t,"recurse",s,i);case"walk":{if(s.length===0)return[t];let e=new WeakSet,n=o=>{if(o&&typeof o=="object"){if(e.has(o))return o;e.add(o)}let f;if(Array.isArray(o))f=o.map(n);else if(o&&typeof o=="object"){let p={};for(let[y,h]of Object.entries(o))p[y]=n(h);f=p}else f=o;return u(f,s[0],i)[0]};return[n(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let e=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),n=[];for(let o=0;o<e;o++)n.push(t.map(f=>Array.isArray(f)?f[o]:null));return[n]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(e=>e.codePointAt(0))]:[null];case"implode":return Array.isArray(t)?[String.fromCodePoint(...t)]:[null];case"tojson":case"tojsonstream":return[JSON.stringify(t)];case"fromjson":{if(typeof t=="string")try{return[JSON.parse(t)]}catch{return[null]}return[null]}case"limit":{if(s.length<2)return[];let n=u(t,s[0],i)[0];return u(t,s[1],i).slice(0,n)}case"until":{if(s.length<2)return[t];let e=t,n=i.limits.maxIterations;for(let o=0;o<n;o++){if(u(e,s[0],i).some(b))return[e];let c=u(e,s[1],i);if(c.length===0)return[e];e=c[0]}throw new g(`jq until: too many iterations (${n}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(s.length<2)return[t];let e=[],n=t,o=i.limits.maxIterations;for(let f=0;f<o&&u(n,s[0],i).some(b);f++){e.push(n);let p=u(n,s[1],i);if(p.length===0)break;n=p[0]}if(e.length>=o)throw new g(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return e}case"repeat":{if(s.length===0)return[t];let e=[],n=t,o=i.limits.maxIterations;for(let f=0;f<o;f++){e.push(n);let c=u(n,s[0],i);if(c.length===0)break;n=c[0]}if(e.length>=o)throw new g(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return e}case"debug":return[t];case"input_line_number":return[1];default:throw new Error(`Unknown function: ${r}`)}}function j(t,r){let s=n=>n===null?0:typeof n=="boolean"?1:typeof n=="number"?2:typeof n=="string"?3:Array.isArray(n)?4:typeof n=="object"?5:6,i=s(t),e=s(r);if(i!==e)return i-e;if(typeof t=="number"&&typeof r=="number")return t-r;if(typeof t=="string"&&typeof r=="string")return t.localeCompare(r);if(typeof t=="boolean"&&typeof r=="boolean")return(t?1:0)-(r?1:0);if(Array.isArray(t)&&Array.isArray(r)){for(let n=0;n<Math.min(t.length,r.length);n++){let o=j(t[n],r[n]);if(o!==0)return o}return t.length-r.length}return 0}function x(t,r){if(O(t,r))return!0;if(Array.isArray(t)&&Array.isArray(r))return r.every(s=>t.some(i=>x(i,s)));if(t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)){let s=t,i=r;return Object.keys(i).every(e=>e in s&&x(s[e],i[e]))}return!1}function I(t,r,s){if(r.length===0)return s;let[i,...e]=r;if(typeof i=="number"){let o=Array.isArray(t)?[...t]:[];for(;o.length<=i;)o.push(null);return o[i]=I(o[i],e,s),o}let n=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return n[i]=I(n[i],e,s),n}function C(t,r){if(r.length===0)return null;if(r.length===1){let e=r[0];if(Array.isArray(t)&&typeof e=="number"){let n=[...t];return n.splice(e,1),n}if(t&&typeof t=="object"&&!Array.isArray(t)){let n={...t};return delete n[String(e)],n}return t}let[s,...i]=r;if(Array.isArray(t)&&typeof s=="number"){let e=[...t];return e[s]=C(e[s],i),e}if(t&&typeof t=="object"&&!Array.isArray(t)){let e={...t};return e[String(s)]=C(e[String(s)],i),e}return t}function Q(t,r,s,i,e){u(t,r,s).length>0&&e.push(i)}var z={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH"};function _(t){let r=[],s=0,i=(p=0)=>t[s+p],e=()=>t[s++],n=()=>s>=t.length,o=p=>p>="0"&&p<="9",f=p=>p>="a"&&p<="z"||p>="A"&&p<="Z"||p==="_",c=p=>f(p)||o(p);for(;!n();){let p=s,y=e();if(!(y===" "||y===" "||y===`
|
|
2
|
-
`||y==="\r")){if(y==="#"){for(;!n()&&i()!==`
|
|
3
|
-
`;)e();continue}if(y==="."&&i()==="."){e(),r.push({type:"DOTDOT",pos:p});continue}if(y==="="&&i()==="="){e(),r.push({type:"EQ",pos:p});continue}if(y==="!"&&i()==="="){e(),r.push({type:"NE",pos:p});continue}if(y==="<"&&i()==="="){e(),r.push({type:"LE",pos:p});continue}if(y===">"&&i()==="="){e(),r.push({type:"GE",pos:p});continue}if(y==="/"&&i()==="/"){e(),i()==="="?(e(),r.push({type:"UPDATE_ALT",pos:p})):r.push({type:"ALT",pos:p});continue}if(y==="+"&&i()==="="){e(),r.push({type:"UPDATE_ADD",pos:p});continue}if(y==="-"&&i()==="="){e(),r.push({type:"UPDATE_SUB",pos:p});continue}if(y==="*"&&i()==="="){e(),r.push({type:"UPDATE_MUL",pos:p});continue}if(y==="/"&&i()==="="){e(),r.push({type:"UPDATE_DIV",pos:p});continue}if(y==="%"&&i()==="="){e(),r.push({type:"UPDATE_MOD",pos:p});continue}if(y==="="&&i()!=="="){r.push({type:"ASSIGN",pos:p});continue}if(y==="."){r.push({type:"DOT",pos:p});continue}if(y==="|"){i()==="="?(e(),r.push({type:"UPDATE_PIPE",pos:p})):r.push({type:"PIPE",pos:p});continue}if(y===","){r.push({type:"COMMA",pos:p});continue}if(y===":"){r.push({type:"COLON",pos:p});continue}if(y===";"){r.push({type:"SEMICOLON",pos:p});continue}if(y==="("){r.push({type:"LPAREN",pos:p});continue}if(y===")"){r.push({type:"RPAREN",pos:p});continue}if(y==="["){r.push({type:"LBRACKET",pos:p});continue}if(y==="]"){r.push({type:"RBRACKET",pos:p});continue}if(y==="{"){r.push({type:"LBRACE",pos:p});continue}if(y==="}"){r.push({type:"RBRACE",pos:p});continue}if(y==="?"){r.push({type:"QUESTION",pos:p});continue}if(y==="+"){r.push({type:"PLUS",pos:p});continue}if(y==="-"){if(o(i())){let h=y;for(;!n()&&(o(i())||i()===".");)h+=e();r.push({type:"NUMBER",value:Number(h),pos:p});continue}r.push({type:"MINUS",pos:p});continue}if(y==="*"){r.push({type:"STAR",pos:p});continue}if(y==="/"){r.push({type:"SLASH",pos:p});continue}if(y==="%"){r.push({type:"PERCENT",pos:p});continue}if(y==="<"){r.push({type:"LT",pos:p});continue}if(y===">"){r.push({type:"GT",pos:p});continue}if(o(y)){let h=y;for(;!n()&&(o(i())||i()==="."||i()==="e"||i()==="E");)(i()==="e"||i()==="E")&&(t[s+1]==="+"||t[s+1]==="-")&&(h+=e()),h+=e();r.push({type:"NUMBER",value:Number(h),pos:p});continue}if(y==='"'){let h="";for(;!n()&&i()!=='"';)if(i()==="\\"){if(e(),n())break;let l=e();switch(l){case"n":h+=`
|
|
4
|
-
`;break;case"r":h+="\r";break;case"t":h+=" ";break;case"\\":h+="\\";break;case'"':h+='"';break;case"(":h+="\\(";break;default:h+=l}}else h+=e();n()||e(),r.push({type:"STRING",value:h,pos:p});continue}if(f(y)||y==="$"||y==="@"){let h=y;for(;!n()&&c(i());)h+=e();let l=z[h];l?r.push({type:l,pos:p}):r.push({type:"IDENT",value:h,pos:p});continue}throw new Error(`Unexpected character '${y}' at position ${p}`)}}return r.push({type:"EOF",pos:s}),r}var P=class t{tokens;pos=0;constructor(r){this.tokens=r}peek(r=0){return this.tokens[this.pos+r]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(r){return this.peek().type===r}match(...r){for(let s of r)if(this.check(s))return this.advance();return null}expect(r,s){if(!this.check(r))throw new Error(`${s} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let r=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return r}parseExpr(){return this.parsePipe()}parsePipe(){let r=this.parseComma();for(;this.match("PIPE");){let s=this.parseComma();r={type:"Pipe",left:r,right:s}}return r}parseComma(){let r=this.parseVarBind();for(;this.match("COMMA");){let s=this.parseVarBind();r={type:"Comma",left:r,right:s}}return r}parseVarBind(){let r=this.parseUpdate();if(this.match("AS")){let s=this.expect("IDENT","Expected variable name after 'as'"),i=s.value;if(!i.startsWith("$"))throw new Error(`Variable name must start with $ at position ${s.pos}`);this.expect("PIPE","Expected '|' after variable binding");let e=this.parseExpr();return{type:"VarBind",name:i,value:r,body:e}}return r}parseUpdate(){let r=this.parseAlt(),s={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},i=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(i){let e=this.parseVarBind();return{type:"UpdateOp",op:s[i.type],path:r,value:e}}return r}parseAlt(){let r=this.parseOr();for(;this.match("ALT");){let s=this.parseOr();r={type:"BinaryOp",op:"//",left:r,right:s}}return r}parseOr(){let r=this.parseAnd();for(;this.match("OR");){let s=this.parseAnd();r={type:"BinaryOp",op:"or",left:r,right:s}}return r}parseAnd(){let r=this.parseNot();for(;this.match("AND");){let s=this.parseNot();r={type:"BinaryOp",op:"and",left:r,right:s}}return r}parseNot(){return this.parseComparison()}parseComparison(){let r=this.parseAddSub(),s={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},i=this.match("EQ","NE","LT","LE","GT","GE");if(i){let e=this.parseAddSub();r={type:"BinaryOp",op:s[i.type],left:r,right:e}}return r}parseAddSub(){let r=this.parseMulDiv();for(;;)if(this.match("PLUS")){let s=this.parseMulDiv();r={type:"BinaryOp",op:"+",left:r,right:s}}else if(this.match("MINUS")){let s=this.parseMulDiv();r={type:"BinaryOp",op:"-",left:r,right:s}}else break;return r}parseMulDiv(){let r=this.parseUnary();for(;;)if(this.match("STAR")){let s=this.parseUnary();r={type:"BinaryOp",op:"*",left:r,right:s}}else if(this.match("SLASH")){let s=this.parseUnary();r={type:"BinaryOp",op:"/",left:r,right:s}}else if(this.match("PERCENT")){let s=this.parseUnary();r={type:"BinaryOp",op:"%",left:r,right:s}}else break;return r}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let r=this.parsePrimary();for(;;)if(this.match("QUESTION"))r={type:"Optional",expr:r};else if(this.check("DOT")&&this.peek(1).type==="IDENT")this.advance(),r={type:"Field",name:this.expect("IDENT","Expected field name").value,base:r};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))r={type:"Iterate",base:r};else if(this.check("COLON")){this.advance();let s=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",end:s,base:r}}else{let s=this.parseExpr();if(this.match("COLON")){let i=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",start:s,end:i,base:r}}else this.expect("RBRACKET","Expected ']'"),r={type:"Index",index:s,base:r}}else break;return r}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:s}}let r=this.parseExpr();if(this.match("COLON")){let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:r,end:s}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:r}}return this.check("IDENT")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let s=this.advance().value;return s.includes("\\(")?this.parseStringInterpolation(s):{type:"Literal",value:s}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let r=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:r}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let r=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:r}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let r=this.parsePostfix(),s;return this.match("CATCH")&&(s=this.parsePostfix()),{type:"Try",body:r,catch:s}}if(this.match("REDUCE")){let r=this.parsePostfix();this.expect("AS","Expected 'as' after reduce expression");let s=this.expect("IDENT","Expected variable name"),i=s.value;if(!i.startsWith("$"))throw new Error(`Variable name must start with $ at position ${s.pos}`);this.expect("LPAREN","Expected '(' after variable");let e=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let n=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:r,varName:i,init:e,update:n}}if(this.match("FOREACH")){let r=this.parsePostfix();this.expect("AS","Expected 'as' after foreach expression");let s=this.expect("IDENT","Expected variable name"),i=s.value;if(!i.startsWith("$"))throw new Error(`Variable name must start with $ at position ${s.pos}`);this.expect("LPAREN","Expected '(' after variable");let e=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let n=this.parseExpr(),o;return this.match("SEMICOLON")&&(o=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:r,varName:i,init:e,update:n,extract:o}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let s=this.advance().value;if(s.startsWith("$"))return{type:"VarRef",name:s};if(this.match("LPAREN")){let i=[];if(!this.check("RPAREN"))for(i.push(this.parseExpr());this.match("SEMICOLON");)i.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:s,args:i}}return{type:"Call",name:s,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let r=[];if(!this.check("RBRACE"))do{let s,i;if(this.match("LPAREN"))s=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),i=this.parseObjectValue();else if(this.check("IDENT")){let e=this.advance().value;this.match("COLON")?(s=e,i=this.parseObjectValue()):(s=e,i={type:"Field",name:e})}else if(this.check("STRING"))s=this.advance().value,this.expect("COLON","Expected ':'"),i=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);r.push({key:s,value:i})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:r}}parseObjectValue(){let r=this.parseVarBind();for(;this.match("PIPE");){let s=this.parseVarBind();r={type:"Pipe",left:r,right:s}}return r}parseIf(){let r=this.parseExpr();this.expect("THEN","Expected 'then'");let s=this.parseExpr(),i=[];for(;this.match("ELIF");){let n=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();i.push({cond:n,then:o})}let e;return this.match("ELSE")&&(e=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:r,then:s,elifs:i,else:e}}parseStringInterpolation(r){let s=[],i="",e=0;for(;e<r.length;)if(r[e]==="\\"&&r[e+1]==="("){i&&(s.push(i),i=""),e+=2;let n=1,o="";for(;e<r.length&&n>0;)r[e]==="("?n++:r[e]===")"&&n--,n>0&&(o+=r[e]),e++;let f=_(o),c=new t(f);s.push(c.parse())}else i+=r[e],e++;return i&&s.push(i),{type:"StringInterp",parts:s}}};function $(t){let r=_(t);return new P(r).parse()}var Y={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};function S(t,r,s,i,e,n=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return s?t:JSON.stringify(t);let o=e?" ":" ";if(Array.isArray(t))return t.length===0?"[]":r?`[${t.map(c=>S(c,!0,!1,i,e)).join(",")}]`:`[
|
|
5
|
-
${t.map(c=>o.repeat(n+1)+S(c,!1,!1,i,e,n+1)).join(`,
|
|
6
|
-
`)}
|
|
7
|
-
${o.repeat(n)}]`;if(typeof t=="object"){let f=Object.keys(t);return i&&(f=f.sort()),f.length===0?"{}":r?`{${f.map(p=>`${JSON.stringify(p)}:${S(t[p],!0,!1,i,e)}`).join(",")}}`:`{
|
|
8
|
-
${f.map(p=>{let y=S(t[p],!1,!1,i,e,n+1);return`${o.repeat(n+1)}${JSON.stringify(p)}: ${y}`}).join(`,
|
|
9
|
-
`)}
|
|
10
|
-
${o.repeat(n)}}`}return String(t)}var st={name:"jq",async execute(t,r){if(M(t))return L(Y);let s=!1,i=!1,e=!1,n=!1,o=!1,f=!1,c=!1,p=!1,y=".",h=!1,l=[];for(let m=0;m<t.length;m++){let a=t[m];if(a==="-r"||a==="--raw-output")s=!0;else if(a==="-c"||a==="--compact-output")i=!0;else if(a==="-e"||a==="--exit-status")e=!0;else if(a==="-s"||a==="--slurp")n=!0;else if(a==="-n"||a==="--null-input")o=!0;else if(a==="-j"||a==="--join-output")f=!0;else if(!(a==="-a"||a==="--ascii")){if(a==="-S"||a==="--sort-keys")c=!0;else if(!(a==="-C"||a==="--color")){if(!(a==="-M"||a==="--monochrome"))if(a==="--tab")p=!0;else if(a==="-")l.push("-");else{if(a.startsWith("--"))return T("jq",a);if(a.startsWith("-")){for(let d of a.slice(1))if(d==="r")s=!0;else if(d==="c")i=!0;else if(d==="e")e=!0;else if(d==="s")n=!0;else if(d==="n")o=!0;else if(d==="j")f=!0;else if(d!=="a"){if(d==="S")c=!0;else if(d!=="C"){if(d!=="M")return T("jq",`-${d}`)}}}else h?l.push(a):(y=a,h=!0)}}}}let A;if(o)A="";else if(l.length===0||l.length===1&&l[0]==="-")A=r.stdin;else try{let m=r.fs.resolvePath(r.cwd,l[0]);A=await r.fs.readFile(m)}catch{return{stdout:"",stderr:`jq: ${l[0]}: No such file or directory
|
|
11
|
-
`,exitCode:2}}try{let m=$(y),a,d={limits:r.limits?{maxIterations:r.limits.maxJqIterations}:void 0};if(o)a=u(null,m,d);else if(n){let E=[];for(let k of A.trim().split(`
|
|
12
|
-
`))k.trim()&&E.push(JSON.parse(k));a=u(E,m,d)}else{let E=A.trim();if(E.startsWith("{")||E.startsWith("["))a=u(JSON.parse(E),m,d);else{a=[];for(let k of E.split(`
|
|
13
|
-
`))k.trim()&&a.push(...u(JSON.parse(k),m,d))}}let F=a.map(E=>S(E,i,s,c,p)),J=f?"":`
|
|
14
|
-
`,R=F.join(J),q=e&&(a.length===0||a.every(E=>E==null||E===!1))?1:0;return{stdout:R?f?R:`${R}
|
|
15
|
-
`:"",stderr:"",exitCode:q}}catch(m){if(m instanceof g)return{stdout:"",stderr:`jq: ${m.message}
|
|
16
|
-
`,exitCode:g.EXIT_CODE};let a=m.message;return a.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${a}
|
|
17
|
-
`,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${a}
|
|
18
|
-
`,exitCode:5}}}};export{st as jqCommand};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* jq AST evaluator
|
|
3
|
-
*
|
|
4
|
-
* Evaluates a parsed jq AST against a JSON value.
|
|
5
|
-
*/
|
|
6
|
-
import type { AstNode } from "./parser.js";
|
|
7
|
-
export type JqValue = unknown;
|
|
8
|
-
export interface JqExecutionLimits {
|
|
9
|
-
maxIterations?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface EvalContext {
|
|
12
|
-
vars: Map<string, JqValue>;
|
|
13
|
-
limits: Required<JqExecutionLimits>;
|
|
14
|
-
}
|
|
15
|
-
export interface EvaluateOptions {
|
|
16
|
-
limits?: JqExecutionLimits;
|
|
17
|
-
}
|
|
18
|
-
export declare function evaluate(value: JqValue, ast: AstNode, ctxOrOptions?: EvalContext | EvaluateOptions): JqValue[];
|