1ls 0.1.13 → 0.1.14
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 +8 -0
- package/dist/browser/index.js +1 -1
- package/dist/completions/1ls.bash +6 -6
- package/dist/completions/1ls.zsh +109 -65
- package/dist/completions/constants.d.ts +124 -0
- package/dist/completions/constants.ts +41 -0
- package/dist/completions/index.d.ts +17 -0
- package/dist/completions/index.ts +197 -0
- package/dist/completions/install-completions.sh +8 -7
- package/dist/index.js +51 -51
- package/dist/version.d.ts +1 -1
- package/package.json +16 -10
package/README.md
CHANGED
|
@@ -104,6 +104,14 @@ brew install yowainwright/tap/1ls
|
|
|
104
104
|
curl -fsSL https://raw.githubusercontent.com/yowainwright/1ls/main/scripts/install.sh | bash
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
### Shell Completions (zsh)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bash <(curl -fsSL https://raw.githubusercontent.com/yowainwright/1ls/main/dist/completions/install-completions.sh)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> TODO: bash and fish shell completions are not yet supported.
|
|
114
|
+
|
|
107
115
|
## Quick Start
|
|
108
116
|
|
|
109
117
|
```bash
|
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var xe={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},Re="+-*/%<>!&|=",we=[" ","\t",`
|
|
2
|
-
`,"\r"];function N(e,t,n){return{type:e,value:t,position:n}}class ${input;position=0;current;constructor(e){this.input=e,this.current=this.input[0]||""}tokenize(){let e=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let t=this.nextToken();if(t)e.push(t)}return e.push(N("EOF","",this.position)),e}nextToken(){let e=this.position;if(this.current==="."&&this.peek()===".")return this.advance(),this.advance(),N("DOUBLE_DOT","..",e);if(this.current==="?"&&this.peek()==="?")return this.advance(),this.advance(),N("DOUBLE_QUESTION","??",e);if(this.current==="?")return this.advance(),N("QUESTION","?",e);let s=xe[this.current];if(s){let m=this.current;return this.advance(),N(s,m,e)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),N("ARROW","=>",e);if(this.current==='"'||this.current==="'")return this.readString();let c=this.isDigit(this.current),a=this.current==="-"&&this.isDigit(this.peek());if(c||a)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let e=this.position,t=this.current,n=[];this.advance();while(this.current!==t&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===t)this.advance();return N("STRING",n.join(""),e)}readNumber(){let e=this.position,t="";if(this.current==="-")t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance()}return N("NUMBER",t,e)}readIdentifier(){let e=this.position,t="";while(this.isIdentifierChar(this.current))t+=this.current,this.advance();return N("IDENTIFIER",t,e)}readOperator(){let e=this.position,t="";while(this.isOperator(this.current))t+=this.current,this.advance();return N("OPERATOR",t,e)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(e){return we.includes(e)}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){let t=e>="a"&&e<="z",n=e>="A"&&e<="Z";return t||n||e==="_"||e==="$"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}isOperator(e){return Re.includes(e)}}var x=["keys","values","entries","length"];var T=(e)=>({type:"Literal",value:e}),Q=(e)=>{if(e==="true")return T(!0);if(e==="false")return T(!1);if(e==="null")return T(null);return},y=(e,t)=>`${t} at position ${e.position} (got ${e.type}: "${e.value}")`,E=(e,t)=>({type:"PropertyAccess",property:e,object:t}),Y=(e,t)=>({type:"IndexAccess",index:e,object:t}),J=(e,t,n)=>({type:"SliceAccess",start:e,end:t,object:n}),k=(e,t,n)=>({type:"MethodCall",method:e,args:t,object:n}),z=(e,t)=>({type:"ObjectOperation",operation:e,object:t}),X=(e)=>({type:"ArraySpread",object:e}),q=(e,t)=>({type:"ArrowFunction",params:e,body:t}),O=(e)=>({type:"Root",expression:e}),C=(e)=>({type:"RecursiveDescent",object:e}),Z=(e,t)=>({type:"OptionalAccess",expression:e,object:t}),ee=(e,t)=>({type:"NullCoalescing",left:e,right:t}),te=(e)=>x.includes(e);class ne{tokens;position=0;current;constructor(e){this.tokens=e,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return O();let t=this.parseExpression();return O(t)}parseExpression(){return this.parsePrimary()}parsePrimary(){let e=this.parsePrimaryNode();return this.parsePostfix(e)}parsePrimaryNode(){let e=this.current.type;if(e==="DOUBLE_DOT")return this.advance(),C();if(e==="DOT"){if(this.advance(),this.current.type==="EOF")return O();return this.parseAccessChain()}if(e==="LEFT_BRACKET")return this.parseArrayAccess();if(e==="IDENTIFIER")return this.parseIdentifierOrFunction();if(e==="STRING"){let s=this.current.value;return this.advance(),T(s)}if(e==="NUMBER"){let s=Number(this.current.value);return this.advance(),T(s)}if(e==="LEFT_PAREN"){let s=this.parseFunctionParams();return this.parseArrowFunction(s)}throw Error(y(this.current,"Unexpected token"))}parseAccessChain(e){let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;return this.advance(),E(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(y(this.current,"Expected property name after dot"))}parseBracketAccess(e){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),X(e);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),E(c,e)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(e);throw Error(y(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(e){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,e);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,e);return this.expect("RIGHT_BRACKET"),Y(n,e)}parseSliceFromColon(e,t){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),J(e,o,t)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(e){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(y(this.current,"Expected operation name after {"));let n=this.current.value;if(!te(n)){let r=x.join(", ");throw Error(y(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),z(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=Q(e);if(n)return n;return E(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return q(e,t)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),t}return this.parseBinaryExpression()}parseBinaryExpression(){let e=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let t=this.current.value;this.advance();let n=this.parseFunctionTerm();e=k(`__operator_${t}__`,[n],e)}return e}parseFunctionTerm(){let e=this.current.type;if(e==="IDENTIFIER")return this.parseIdentifierChain();if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),T(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),T(t)}if(e==="LEFT_PAREN"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),t}throw Error(y(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let e=this.current.value;this.advance();let t=Q(e);if(t)return t;let n=E(e),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let c=n,a=c.property,l=c.object;n=this.parseMethodCall(l?l:O(),a);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=E(i,n)}return n}parseMethodCall(e,t){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),k(t,n,e)}parseMethodArguments(){let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let t=this.parseMethodArgument();if(e.push(t),this.current.type==="COMMA")this.advance()}return e}parseMethodArgument(){let e=this.current.type;if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}if(e==="IDENTIFIER"){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);return E(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),T(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),T(t)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")e.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),e}parsePostfix(e){let t=e;while(!0){let n=this.current.type;if(n==="DOUBLE_DOT"){this.advance(),t=C(t);continue}if(n==="DOT"){t=this.parsePostfixDot(t);continue}if(n==="LEFT_BRACKET"){t=this.parseBracketAccess(t);continue}if(n==="QUESTION"){this.advance(),t=Z(t);continue}if(n==="DOUBLE_QUESTION"){this.advance();let l=this.parsePrimary();t=ee(t,l);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let d=t.property;t=this.parseMethodCall(O(),d);continue}}break}return t}parsePostfixDot(e){this.advance();let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(e,n);return E(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(y(this.current,"Expected property name after dot"))}parseNumber(){let e=this.current.value==="-";if(e)this.advance();if(this.current.type!=="NUMBER")throw Error(y(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return e?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(e){if(this.current.type!==e)throw Error(y(this.current,`Expected ${e} but got ${this.current.type}`));this.advance()}}var L=Symbol("empty"),u={PIPE:"pipe",COMPOSE:"compose",HEAD:"head",LAST:"last",TAIL:"tail",TAKE:"take",DROP:"drop",UNIQ:"uniq",FLATTEN:"flatten",REVERSE:"rev",GROUPBY:"groupBy",SORTBY:"sortBy",CHUNK:"chunk",COMPACT:"compact",PICK:"pick",OMIT:"omit",KEYS:"keys",VALUES:"vals",MERGE:"merge",DEEPMERGE:"deepMerge",FROMPAIRS:"fromPairs",TOPAIRS:"toPairs",SUM:"sum",MEAN:"mean",MIN:"min",MAX:"max",LEN:"len",COUNT:"count",ISEMPTY:"isEmpty",ISNIL:"isNil",IDENTITY:"id",PLUCK:"pluck",TYPE:"type",RANGE:"range",HAS:"has",NTH:"nth",CONTAINS:"contains",ADD:"add",PATH:"path",GETPATH:"getpath",SETPATH:"setpath",RECURSE:"recurse",SPLIT:"split",JOIN:"join",STARTSWITH:"startswith",ENDSWITH:"endswith",LTRIMSTR:"ltrimstr",RTRIMSTR:"rtrimstr",TOSTRING:"tostring",TONUMBER:"tonumber",FLOOR:"floor",CEIL:"ceil",ROUND:"round",ABS:"abs",NOT:"not",SELECT:"select",EMPTY:"empty",ERROR:"error",DEBUG:"debug"};var p=(e)=>Array.isArray(e),f=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),R=(e)=>e===null||e===void 0,A=(e)=>typeof e==="string",b=(e)=>typeof e==="number",ve=(e)=>{if(e===null)return"null";if(p(e))return"array";return typeof e},re=(e,t)=>Object.keys(t).reduce((n,r)=>{let s=e[r],o=t[r],i=f(s)&&f(o);return{...n,[r]:i?re(s,o):o}},{...e}),P=(e,t)=>{if(e===t)return!0;if(p(e)&&p(t))return t.every((s)=>e.some((o)=>P(o,s)));if(f(e)&&f(t)){let s=e;return Object.entries(t).every(([o,i])=>(o in s)&&P(s[o],i))}return!1},Ie=(e,t)=>t.reduce((n,r)=>{if(R(n))return;if(p(n)&&typeof r==="number")return n[r];if(f(n)&&typeof r==="string")return n[r];return},e),se=(e,t,n)=>{if(t.length===0)return n;let[r,...s]=t,o=s.length===0?n:se(p(e)&&typeof r==="number"?e[r]:f(e)&&typeof r==="string"?e[r]:void 0,s,n);if(p(e)&&typeof r==="number")return e.map((i,c)=>c===r?o:i);if(f(e)&&typeof r==="string")return{...e,[r]:o};if(typeof r==="number")return Array.from({length:r+1},(i,c)=>c===r?o:void 0);return{[r]:o}},M=(e)=>{let t=[e],n=p(e)?e.flatMap(M):f(e)?Object.values(e).flatMap(M):[];return[...t,...n]},F=(e,t)=>{let n=[t];if(p(e)){let r=e.flatMap((s,o)=>F(s,[...t,o]));return[...n,...r]}if(f(e)){let r=Object.keys(e).flatMap((s)=>F(e[s],[...t,s]));return[...n,...r]}return n};var ke={[u.HEAD]:(e)=>p(e)?e[0]:void 0,[u.LAST]:(e)=>p(e)?e[e.length-1]:void 0,[u.TAIL]:(e)=>p(e)?e.slice(1):[],[u.TAKE]:(e,[t])=>p(e)?e.slice(0,t):[],[u.DROP]:(e,[t])=>p(e)?e.slice(t):[],[u.UNIQ]:(e)=>p(e)?[...new Set(e)]:[],[u.FLATTEN]:(e)=>p(e)?e.flat(1/0):[],[u.REVERSE]:(e)=>p(e)?[...e].reverse():[],[u.GROUPBY]:(e,[t])=>{if(!p(e))return{};let n=t;return e.reduce((r,s)=>{let o=String(n(s)),i=r[o]||[];return{...r,[o]:[...i,s]}},{})},[u.SORTBY]:(e,[t])=>{if(!p(e))return[];let n=t;return[...e].sort((r,s)=>{let o=n(r),i=n(s),c=o<i,a=o>i;if(c)return-1;if(a)return 1;return 0})},[u.CHUNK]:(e,[t])=>{if(!p(e))return[];let n=t,r=Math.ceil(e.length/n);return Array.from({length:r},(s,o)=>e.slice(o*n,(o+1)*n))},[u.COMPACT]:(e)=>p(e)?e.filter(Boolean):[],[u.PLUCK]:(e,[t])=>{if(!p(e))return[];return e.map((n)=>f(n)?n[t]:void 0)},[u.PICK]:(e,t)=>{if(!f(e))return{};return(t.length===1&&p(t[0])?t[0]:t).reduce((s,o)=>{let i=o;return i in e?{...s,[i]:e[i]}:s},{})},[u.OMIT]:(e,t)=>{if(!f(e))return{};let r=t.length===1&&p(t[0])?t[0]:t,s=new Set(r);return Object.fromEntries(Object.entries(e).filter(([o])=>!s.has(o)))},[u.KEYS]:(e)=>f(e)?Object.keys(e):[],[u.VALUES]:(e)=>f(e)?Object.values(e):[],[u.MERGE]:(e,t)=>{if(!f(e))return{};return t.reduce((n,r)=>{return{...n,...r}},e)},[u.DEEPMERGE]:(e,t)=>{if(!f(e))return{};return t.reduce((n,r)=>{return f(r)?re(n,r):n},e)},[u.FROMPAIRS]:(e)=>{if(!p(e))return{};return Object.fromEntries(e)},[u.TOPAIRS]:(e)=>f(e)?Object.entries(e):[],[u.SUM]:(e)=>{if(!p(e))return 0;return e.reduce((t,n)=>t+n,0)},[u.MEAN]:(e)=>{if(!p(e)||e.length===0)return 0;return e.reduce((r,s)=>r+s,0)/e.length},[u.MIN]:(e)=>{if(!p(e))return;return Math.min(...e)},[u.MAX]:(e)=>{if(!p(e))return;return Math.max(...e)},[u.LEN]:(e)=>{if(p(e))return e.length;if(f(e))return Object.keys(e).length;if(A(e))return e.length;return 0},[u.COUNT]:(e)=>{if(p(e))return e.length;if(f(e))return Object.keys(e).length;if(A(e))return e.length;return 0},[u.ISEMPTY]:(e)=>{if(R(e))return!0;if(p(e))return e.length===0;if(f(e))return Object.keys(e).length===0;if(A(e))return e.length===0;return!1},[u.ISNIL]:(e)=>R(e),[u.IDENTITY]:(e)=>e,[u.TYPE]:(e)=>ve(e),[u.RANGE]:(e,t)=>{let[n,r,s=1]=t,o=r===void 0,i=o?0:n,c=o?n:r,a=s,l=Math.max(0,Math.ceil((c-i)/a));return Array.from({length:l},(h,d)=>i+d*a)},[u.HAS]:(e,[t])=>{if(f(e))return t in e;if(p(e)){let n=t;return n>=0&&n<e.length}return!1},[u.NTH]:(e,[t])=>{if(!p(e))return;let n=t,s=n<0?e.length+n:n;return e[s]},[u.CONTAINS]:(e,[t])=>P(e,t),[u.ADD]:(e)=>{if(!p(e))return e;if(e.length===0)return null;let n=A(e[0]),r=p(e[0]);if(n)return e.join("");if(r)return e.flat();return e.reduce((s,o)=>s+o,0)},[u.PATH]:(e)=>F(e,[]),[u.GETPATH]:(e,[t])=>Ie(e,t),[u.SETPATH]:(e,[t,n])=>se(e,t,n),[u.RECURSE]:(e)=>M(e),[u.SPLIT]:(e,[t])=>{if(!A(e))return[];let n=t;return e.split(n)},[u.JOIN]:(e,[t])=>{if(!p(e))return"";let n=t;return e.join(n)},[u.STARTSWITH]:(e,[t])=>{if(!A(e))return!1;let n=t;return e.startsWith(n)},[u.ENDSWITH]:(e,[t])=>{if(!A(e))return!1;let n=t;return e.endsWith(n)},[u.LTRIMSTR]:(e,[t])=>{if(!A(e))return e;let n=t;return e.startsWith(n)?e.slice(n.length):e},[u.RTRIMSTR]:(e,[t])=>{if(!A(e))return e;let n=t;return e.endsWith(n)?e.slice(0,-n.length):e},[u.TOSTRING]:(e)=>{if(A(e))return e;if(R(e))return String(e);return JSON.stringify(e)},[u.TONUMBER]:(e)=>{if(b(e))return e;if(A(e)){let t=Number(e);return!Number.isNaN(t)?t:null}return null},[u.FLOOR]:(e)=>b(e)?Math.floor(e):null,[u.CEIL]:(e)=>b(e)?Math.ceil(e):null,[u.ROUND]:(e)=>b(e)?Math.round(e):null,[u.ABS]:(e)=>b(e)?Math.abs(e):null,[u.NOT]:(e)=>!e,[u.SELECT]:(e,[t])=>{return t(e)?e:L},[u.EMPTY]:()=>L,[u.ERROR]:(e,[t])=>{throw Error(t||"error")},[u.DEBUG]:(e)=>{return console.error("DEBUG:",e),e}},Ce=(e)=>(e in ke),Le=(e,t,n)=>{let r=ke[e];if(!r)throw Error(`Unknown builtin: ${e}`);return r(t,n)};var oe={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,"&&":(e,t)=>e&&t,"||":(e,t)=>e||t};var j=(e)=>e.startsWith("__operator_")&&e.endsWith("__"),D=(e)=>e.slice(11,-2),B=(e,t,n)=>{let r=oe[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)},ie=(e,t)=>Object.fromEntries(e.map((n,r)=>[n,t[r]])),w=(e)=>{return Object.values(e)[0]},ce=(e)=>e!==null&&typeof e==="object",v=(e,t)=>{if(!ce(e))return;return e[t]},_=(e,t)=>e<0?t+e:e,ue=(e,t)=>{if(!Array.isArray(e))return;let n=_(t,e.length);return e[n]},ae=(e,t,n)=>{if(!Array.isArray(e))return;let r=e.length,s=t!==void 0?_(t,r):0,o=n!==void 0?_(n,r):r;return e.slice(s,o)},le=(e,t)=>{if(!ce(e))return;switch(t){case"keys":return Object.keys(e);case"values":return Object.values(e);case"entries":return Object.entries(e);case"length":return Array.isArray(e)?e.length:Object.keys(e).length}};var Qe=(e,t)=>{if(e===null||e===void 0)return!1;return typeof e[t]==="function"},Ye=(e)=>e instanceof Error?e.message:String(e),V=(e,t,n)=>{if(!Qe(e,t))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return e[t].call(e,...n)}catch(s){let o=Ye(s);throw Error(`Error executing method ${t}: ${o}`)}};class pe{options;constructor(e={}){this.options=e}evaluate(e,t){switch(e.type){case"Root":return e.expression?this.evaluate(e.expression,t):t;case"PropertyAccess":return this.evaluatePropertyAccess(e,t);case"IndexAccess":return ue(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return ae(e.object?this.evaluate(e.object,t):t,e.start,e.end);case"ArraySpread":return e.object?this.evaluate(e.object,t):t;case"MethodCall":return this.evaluateMethodCall(e,t);case"ObjectOperation":return le(e.object?this.evaluate(e.object,t):t,e.operation);case"Literal":return e.value;case"ArrowFunction":return this.createFunction(e);case"RecursiveDescent":return this.evaluateRecursiveDescent(e,t);case"OptionalAccess":return this.evaluateOptionalAccess(e,t);case"NullCoalescing":return this.evaluateNullCoalescing(e,t);default:throw Error(`Unknown AST node type: ${e.type}`)}}evaluatePropertyAccess(e,t){let n=e.object?this.evaluate(e.object,t):t,r=v(n,e.property);if(this.options.strict&&r===void 0){let s=e.property;throw Error(`Property "${s}" is undefined`)}return r}evaluateArg(e,t){return e.type==="ArrowFunction"?this.createFunction(e):this.evaluate(e,t)}evaluateMethodCall(e,t){if(e.method===u.PIPE)return this.evaluatePipe(e.args,t);if(e.method===u.COMPOSE)return this.evaluatePipe([...e.args].reverse(),t);let n=e.object?this.evaluate(e.object,t):t;if(Ce(e.method)){let o=e.args.map((i)=>this.evaluateArg(i,t));return Le(e.method,n,o)}if(j(e.method)){let o=D(e.method),i=this.evaluate(e.args[0],t);return B(n,o,i)}let s=e.args.map((o)=>this.evaluateArg(o,t));return V(n,e.method,s)}evaluatePipe(e,t){return e.reduce((n,r)=>this.evaluate(r,n),t)}evaluateRecursiveDescent(e,t){let n=e.object?this.evaluate(e.object,t):t;return this.collectAllValues(n)}collectAllValues(e){let t=Array.isArray(e),n=e!==null&&typeof e==="object"&&!t,r=[e];if(t){let s=e.flatMap((o)=>this.collectAllValues(o));return[...r,...s]}if(n){let s=Object.values(e).flatMap((o)=>this.collectAllValues(o));return[...r,...s]}return r}evaluateOptionalAccess(e,t){try{return this.evaluate(e.expression,t)}catch{return null}}evaluateNullCoalescing(e,t){let n=this.evaluate(e.left,t);return n===null||n===void 0?this.evaluate(e.right,t):n}createFunction(e){return(...t)=>{let n=ie(e.params,t);return this.evaluateFunctionBody(e.body,n)}}evaluateFunctionBody(e,t){switch(e.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(e,t);case"MethodCall":return this.evaluateMethodCallInFunction(e,t);case"Literal":return e.value;case"Root":return e.expression?this.evaluateFunctionBody(e.expression,t):t;default:return this.evaluate(e,w(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let o=this.evaluateFunctionBody(e.object,t);return v(o,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let s=w(t);return v(s,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):w(t);if(j(e.method)){let o=D(e.method),i=this.evaluateFunctionBody(e.args[0],t);return B(n,o,i)}let s=e.args.map((o)=>this.evaluateFunctionBody(o,t));return V(n,e.method,s)}}var de=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var he=(e,t)=>{let r=de.filter((s)=>s.type===e).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${t}:
|
|
2
|
+
`,"\r"];function N(e,t,n){return{type:e,value:t,position:n}}class ${input;position=0;current;constructor(e){this.input=e,this.current=this.input[0]||""}tokenize(){let e=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let t=this.nextToken();if(t)e.push(t)}return e.push(N("EOF","",this.position)),e}nextToken(){let e=this.position;if(this.current==="."&&this.peek()===".")return this.advance(),this.advance(),N("DOUBLE_DOT","..",e);if(this.current==="?"&&this.peek()==="?")return this.advance(),this.advance(),N("DOUBLE_QUESTION","??",e);if(this.current==="?")return this.advance(),N("QUESTION","?",e);let s=xe[this.current];if(s){let m=this.current;return this.advance(),N(s,m,e)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),N("ARROW","=>",e);if(this.current==='"'||this.current==="'")return this.readString();let c=this.isDigit(this.current),a=this.current==="-"&&this.isDigit(this.peek());if(c||a)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let e=this.position,t=this.current,n=[];this.advance();while(this.current!==t&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===t)this.advance();return N("STRING",n.join(""),e)}readNumber(){let e=this.position,t="";if(this.current==="-")t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance()}return N("NUMBER",t,e)}readIdentifier(){let e=this.position,t="";while(this.isIdentifierChar(this.current))t+=this.current,this.advance();return N("IDENTIFIER",t,e)}readOperator(){let e=this.position,t="";while(this.isOperator(this.current))t+=this.current,this.advance();return N("OPERATOR",t,e)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(e){return we.includes(e)}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){let t=e>="a"&&e<="z",n=e>="A"&&e<="Z";return t||n||e==="_"||e==="$"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}isOperator(e){return Re.includes(e)}}var x=["keys","values","entries","length"];var T=(e)=>({type:"Literal",value:e}),Q=(e)=>{if(e==="true")return T(!0);if(e==="false")return T(!1);if(e==="null")return T(null);return},y=(e,t)=>`${t} at position ${e.position} (got ${e.type}: "${e.value}")`,E=(e,t)=>({type:"PropertyAccess",property:e,object:t}),Y=(e,t)=>({type:"IndexAccess",index:e,object:t}),J=(e,t,n)=>({type:"SliceAccess",start:e,end:t,object:n}),k=(e,t,n)=>({type:"MethodCall",method:e,args:t,object:n}),z=(e,t)=>({type:"ObjectOperation",operation:e,object:t}),X=(e)=>({type:"ArraySpread",object:e}),q=(e,t)=>({type:"ArrowFunction",params:e,body:t}),O=(e)=>({type:"Root",expression:e}),C=(e)=>({type:"RecursiveDescent",object:e}),Z=(e,t)=>({type:"OptionalAccess",expression:e,object:t}),ee=(e,t)=>({type:"NullCoalescing",left:e,right:t}),te=(e)=>x.includes(e);class ne{tokens;position=0;current;constructor(e){this.tokens=e,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return O();let t=this.parseExpression();return O(t)}parseExpression(){return this.parsePrimary()}parsePrimary(){let e=this.parsePrimaryNode();return this.parsePostfix(e)}parsePrimaryNode(){let e=this.current.type;if(e==="DOUBLE_DOT")return this.advance(),C();if(e==="DOT"){if(this.advance(),this.current.type==="EOF")return O();return this.parseAccessChain()}if(e==="LEFT_BRACKET")return this.parseArrayAccess();if(e==="IDENTIFIER")return this.parseIdentifierOrFunction();if(e==="STRING"){let s=this.current.value;return this.advance(),T(s)}if(e==="NUMBER"){let s=Number(this.current.value);return this.advance(),T(s)}if(e==="LEFT_PAREN"){let s=this.parseFunctionParams();return this.parseArrowFunction(s)}throw Error(y(this.current,"Unexpected token"))}parseAccessChain(e){let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;return this.advance(),E(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(y(this.current,"Expected property name after dot"))}parseBracketAccess(e){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),X(e);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),E(c,e)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(e);throw Error(y(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(e){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,e);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,e);return this.expect("RIGHT_BRACKET"),Y(n,e)}parseSliceFromColon(e,t){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),J(e,o,t)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(e){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(y(this.current,"Expected operation name after {"));let n=this.current.value;if(!te(n)){let r=x.join(", ");throw Error(y(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),z(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=Q(e);if(n)return n;return E(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return q(e,t)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),t}return this.parseBinaryExpression()}parseBinaryExpression(){let e=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let t=this.current.value;this.advance();let n=this.parseFunctionTerm();e=k(`__operator_${t}__`,[n],e)}return e}parseFunctionTerm(){let e=this.current.type;if(e==="IDENTIFIER")return this.parseIdentifierChain();if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),T(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),T(t)}if(e==="LEFT_PAREN"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),t}throw Error(y(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let e=this.current.value;this.advance();let t=Q(e);if(t)return t;let n=E(e),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let c=n,a=c.property,l=c.object;n=this.parseMethodCall(l?l:O(),a);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=E(i,n)}return n}parseMethodCall(e,t){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),k(t,n,e)}parseMethodArguments(){let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let t=this.parseMethodArgument();if(e.push(t),this.current.type==="COMMA")this.advance()}return e}parseMethodArgument(){let e=this.current.type;if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}if(e==="IDENTIFIER"){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);return E(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),T(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),T(t)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")e.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),e}parsePostfix(e){let t=e;while(!0){let n=this.current.type;if(n==="DOUBLE_DOT"){this.advance(),t=C(t);continue}if(n==="DOT"){t=this.parsePostfixDot(t);continue}if(n==="LEFT_BRACKET"){t=this.parseBracketAccess(t);continue}if(n==="QUESTION"){this.advance(),t=Z(t);continue}if(n==="DOUBLE_QUESTION"){this.advance();let l=this.parsePrimary();t=ee(t,l);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let d=t.property;t=this.parseMethodCall(O(),d);continue}}break}return t}parsePostfixDot(e){this.advance();let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(e,n);return E(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(y(this.current,"Expected property name after dot"))}parseNumber(){let e=this.current.value==="-";if(e)this.advance();if(this.current.type!=="NUMBER")throw Error(y(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return e?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(e){if(this.current.type!==e)throw Error(y(this.current,`Expected ${e} but got ${this.current.type}`));this.advance()}}var L=Symbol("empty"),u={PIPE:"pipe",COMPOSE:"compose",HEAD:"head",LAST:"last",TAIL:"tail",TAKE:"take",DROP:"drop",UNIQ:"uniq",FLATTEN:"flatten",REVERSE:"rev",GROUPBY:"groupBy",SORTBY:"sortBy",CHUNK:"chunk",COMPACT:"compact",PICK:"pick",OMIT:"omit",KEYS:"keys",VALUES:"vals",MERGE:"merge",DEEPMERGE:"deepMerge",FROMPAIRS:"fromPairs",TOPAIRS:"toPairs",SUM:"sum",MEAN:"mean",MIN:"min",MAX:"max",LEN:"len",COUNT:"count",ISEMPTY:"isEmpty",ISNIL:"isNil",IDENTITY:"id",PLUCK:"pluck",TYPE:"type",RANGE:"range",HAS:"has",NTH:"nth",CONTAINS:"contains",ADD:"add",PATH:"path",GETPATH:"getpath",SETPATH:"setpath",RECURSE:"recurse",SPLIT:"split",JOIN:"join",STARTSWITH:"startswith",ENDSWITH:"endswith",LTRIMSTR:"ltrimstr",RTRIMSTR:"rtrimstr",TOSTRING:"tostring",TONUMBER:"tonumber",FLOOR:"floor",CEIL:"ceil",ROUND:"round",ABS:"abs",NOT:"not",SELECT:"select",EMPTY:"empty",ERROR:"error",DEBUG:"debug"};var p=(e)=>Array.isArray(e),f=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),R=(e)=>e===null||e===void 0,A=(e)=>typeof e==="string",b=(e)=>typeof e==="number",ve=(e)=>{if(e===null)return"null";if(p(e))return"array";return typeof e},re=(e,t)=>Object.keys(t).reduce((n,r)=>{let s=e[r],o=t[r],i=f(s)&&f(o);return{...n,[r]:i?re(s,o):o}},{...e}),P=(e,t)=>{if(e===t)return!0;if(p(e)&&p(t))return t.every((s)=>e.some((o)=>P(o,s)));if(f(e)&&f(t)){let s=e;return Object.entries(t).every(([o,i])=>(o in s)&&P(s[o],i))}return!1},Ie=(e,t)=>t.reduce((n,r)=>{if(R(n))return;if(p(n)&&typeof r==="number")return n[r];if(f(n)&&typeof r==="string")return n[r];return},e),se=(e,t,n)=>{if(t.length===0)return n;let[r,...s]=t,o=s.length===0?n:se(p(e)&&typeof r==="number"?e[r]:f(e)&&typeof r==="string"?e[r]:void 0,s,n);if(p(e)&&typeof r==="number")return e.map((i,c)=>c===r?o:i);if(f(e)&&typeof r==="string")return{...e,[r]:o};if(typeof r==="number")return Array.from({length:r+1},(i,c)=>c===r?o:void 0);return{[r]:o}},M=(e)=>{let t=[e],n=p(e)?e.flatMap(M):f(e)?Object.values(e).flatMap(M):[];return[...t,...n]},F=(e,t)=>{let n=[t];if(p(e)){let r=e.flatMap((s,o)=>F(s,[...t,o]));return[...n,...r]}if(f(e)){let r=Object.keys(e).flatMap((s)=>F(e[s],[...t,s]));return[...n,...r]}return n};var ke={[u.HEAD]:(e)=>p(e)?e[0]:void 0,[u.LAST]:(e)=>p(e)?e[e.length-1]:void 0,[u.TAIL]:(e)=>p(e)?e.slice(1):[],[u.TAKE]:(e,[t])=>p(e)?e.slice(0,t):[],[u.DROP]:(e,[t])=>p(e)?e.slice(t):[],[u.UNIQ]:(e)=>p(e)?[...new Set(e)]:[],[u.FLATTEN]:(e)=>p(e)?e.flat(1/0):[],[u.REVERSE]:(e)=>p(e)?[...e].reverse():[],[u.GROUPBY]:(e,[t])=>{if(!p(e))return{};let n=t;return e.reduce((r,s)=>{let o=String(n(s)),i=r[o]||[];return{...r,[o]:[...i,s]}},{})},[u.SORTBY]:(e,[t])=>{if(!p(e))return[];let n=t;return[...e].sort((r,s)=>{let o=n(r),i=n(s),c=o<i,a=o>i;if(c)return-1;if(a)return 1;return 0})},[u.CHUNK]:(e,[t])=>{if(!p(e))return[];let n=t,r=Math.ceil(e.length/n);return Array.from({length:r},(s,o)=>e.slice(o*n,(o+1)*n))},[u.COMPACT]:(e)=>p(e)?e.filter(Boolean):[],[u.PLUCK]:(e,[t])=>{if(!p(e))return[];return e.map((n)=>f(n)?n[t]:void 0)},[u.PICK]:(e,t)=>{if(!f(e))return{};return(t.length===1&&p(t[0])?t[0]:t).reduce((s,o)=>{let i=o;return i in e?{...s,[i]:e[i]}:s},{})},[u.OMIT]:(e,t)=>{if(!f(e))return{};let r=t.length===1&&p(t[0])?t[0]:t,s=new Set(r);return Object.fromEntries(Object.entries(e).filter(([o])=>!s.has(o)))},[u.KEYS]:(e)=>f(e)?Object.keys(e):[],[u.VALUES]:(e)=>f(e)?Object.values(e):[],[u.MERGE]:(e,t)=>{if(!f(e))return{};return t.reduce((n,r)=>{return{...n,...r}},e)},[u.DEEPMERGE]:(e,t)=>{if(!f(e))return{};return t.reduce((n,r)=>{return f(r)?re(n,r):n},e)},[u.FROMPAIRS]:(e)=>{if(!p(e))return{};return Object.fromEntries(e)},[u.TOPAIRS]:(e)=>f(e)?Object.entries(e):[],[u.SUM]:(e)=>{if(!p(e))return 0;return e.reduce((t,n)=>t+n,0)},[u.MEAN]:(e)=>{if(!p(e)||e.length===0)return 0;return e.reduce((r,s)=>r+s,0)/e.length},[u.MIN]:(e)=>{if(!p(e))return;return Math.min(...e)},[u.MAX]:(e)=>{if(!p(e))return;return Math.max(...e)},[u.LEN]:(e)=>{if(p(e))return e.length;if(f(e))return Object.keys(e).length;if(A(e))return e.length;return 0},[u.COUNT]:(e)=>{if(p(e))return e.length;if(f(e))return Object.keys(e).length;if(A(e))return e.length;return 0},[u.ISEMPTY]:(e)=>{if(R(e))return!0;if(p(e))return e.length===0;if(f(e))return Object.keys(e).length===0;if(A(e))return e.length===0;return!1},[u.ISNIL]:(e)=>R(e),[u.IDENTITY]:(e)=>e,[u.TYPE]:(e)=>ve(e),[u.RANGE]:(e,t)=>{let[n,r,s=1]=t,o=r===void 0,i=o?0:n,c=o?n:r,a=s,l=Math.max(0,Math.ceil((c-i)/a));return Array.from({length:l},(h,d)=>i+d*a)},[u.HAS]:(e,[t])=>{if(f(e))return t in e;if(p(e)){let n=t;return n>=0&&n<e.length}return!1},[u.NTH]:(e,[t])=>{if(!p(e))return;let n=t,s=n<0?e.length+n:n;return e[s]},[u.CONTAINS]:(e,[t])=>P(e,t),[u.ADD]:(e)=>{if(!p(e))return e;if(e.length===0)return null;let n=A(e[0]),r=p(e[0]);if(n)return e.join("");if(r)return e.flat();return e.reduce((s,o)=>s+o,0)},[u.PATH]:(e)=>F(e,[]),[u.GETPATH]:(e,[t])=>Ie(e,t),[u.SETPATH]:(e,[t,n])=>se(e,t,n),[u.RECURSE]:(e)=>M(e),[u.SPLIT]:(e,[t])=>{if(!A(e))return[];let n=t;return e.split(n)},[u.JOIN]:(e,[t])=>{if(!p(e))return"";let n=t;return e.join(n)},[u.STARTSWITH]:(e,[t])=>{if(!A(e))return!1;let n=t;return e.startsWith(n)},[u.ENDSWITH]:(e,[t])=>{if(!A(e))return!1;let n=t;return e.endsWith(n)},[u.LTRIMSTR]:(e,[t])=>{if(!A(e))return e;let n=t;return e.startsWith(n)?e.slice(n.length):e},[u.RTRIMSTR]:(e,[t])=>{if(!A(e))return e;let n=t;return e.endsWith(n)?e.slice(0,-n.length):e},[u.TOSTRING]:(e)=>{if(A(e))return e;if(R(e))return String(e);return JSON.stringify(e)},[u.TONUMBER]:(e)=>{if(b(e))return e;if(A(e)){let t=Number(e);return!Number.isNaN(t)?t:null}return null},[u.FLOOR]:(e)=>b(e)?Math.floor(e):null,[u.CEIL]:(e)=>b(e)?Math.ceil(e):null,[u.ROUND]:(e)=>b(e)?Math.round(e):null,[u.ABS]:(e)=>b(e)?Math.abs(e):null,[u.NOT]:(e)=>!e,[u.SELECT]:(e,[t])=>{return t(e)?e:L},[u.EMPTY]:()=>L,[u.ERROR]:(e,[t])=>{throw Error(t||"error")},[u.DEBUG]:(e)=>{return console.error("DEBUG:",e),e}},Ce=(e)=>(e in ke),Le=(e,t,n)=>{let r=ke[e];if(!r)throw Error(`Unknown builtin: ${e}`);return r(t,n)};var oe={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,"&&":(e,t)=>e&&t,"||":(e,t)=>e||t};var j=(e)=>e.startsWith("__operator_")&&e.endsWith("__"),D=(e)=>e.slice(11,-2),B=(e,t,n)=>{let r=oe[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)},ie=(e,t)=>Object.fromEntries(e.map((n,r)=>[n,t[r]])),w=(e)=>{return Object.values(e)[0]},ce=(e)=>e!==null&&typeof e==="object",v=(e,t)=>{if(!ce(e))return;return e[t]},_=(e,t)=>e<0?t+e:e,ue=(e,t)=>{if(!Array.isArray(e))return;let n=_(t,e.length);return e[n]},ae=(e,t,n)=>{if(!Array.isArray(e))return;let r=e.length,s=t!==void 0?_(t,r):0,o=n!==void 0?_(n,r):r;return e.slice(s,o)},le=(e,t)=>{if(!ce(e))return;switch(t){case"keys":return Object.keys(e);case"values":return Object.values(e);case"entries":return Object.entries(e);case"length":return Array.isArray(e)?e.length:Object.keys(e).length}};var Qe=(e,t)=>{if(e===null||e===void 0)return!1;return typeof e[t]==="function"},Ye=(e)=>e instanceof Error?e.message:String(e),V=(e,t,n)=>{if(!Qe(e,t))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return e[t].call(e,...n)}catch(s){let o=Ye(s);throw Error(`Error executing method ${t}: ${o}`)}};class pe{options;constructor(e={}){this.options=e}evaluate(e,t){switch(e.type){case"Root":return e.expression?this.evaluate(e.expression,t):t;case"PropertyAccess":return this.evaluatePropertyAccess(e,t);case"IndexAccess":return ue(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return ae(e.object?this.evaluate(e.object,t):t,e.start,e.end);case"ArraySpread":return e.object?this.evaluate(e.object,t):t;case"MethodCall":return this.evaluateMethodCall(e,t);case"ObjectOperation":return le(e.object?this.evaluate(e.object,t):t,e.operation);case"Literal":return e.value;case"ArrowFunction":return this.createFunction(e);case"RecursiveDescent":return this.evaluateRecursiveDescent(e,t);case"OptionalAccess":return this.evaluateOptionalAccess(e,t);case"NullCoalescing":return this.evaluateNullCoalescing(e,t);default:throw Error(`Unknown AST node type: ${e.type}`)}}evaluatePropertyAccess(e,t){let n=e.object?this.evaluate(e.object,t):t,r=v(n,e.property);if(this.options.strict&&r===void 0){let s=e.property;throw Error(`Property "${s}" is undefined`)}return r}evaluateArg(e,t){return e.type==="ArrowFunction"?this.createFunction(e):this.evaluate(e,t)}evaluateMethodCall(e,t){if(e.method===u.PIPE)return this.evaluatePipe(e.args,t);if(e.method===u.COMPOSE)return this.evaluatePipe([...e.args].reverse(),t);let n=e.object?this.evaluate(e.object,t):t;if(Ce(e.method)){let o=e.args.map((i)=>this.evaluateArg(i,t));return Le(e.method,n,o)}if(j(e.method)){let o=D(e.method),i=this.evaluate(e.args[0],t);return B(n,o,i)}let s=e.args.map((o)=>this.evaluateArg(o,t));return V(n,e.method,s)}evaluatePipe(e,t){return e.reduce((n,r)=>this.evaluate(r,n),t)}evaluateRecursiveDescent(e,t){let n=e.object?this.evaluate(e.object,t):t;return this.collectAllValues(n)}collectAllValues(e,t=[]){if(t.push(e),Array.isArray(e))e.forEach((n)=>this.collectAllValues(n,t));else if(e!==null&&typeof e==="object")Object.values(e).forEach((n)=>this.collectAllValues(n,t));return t}evaluateOptionalAccess(e,t){try{return this.evaluate(e.expression,t)}catch{return null}}evaluateNullCoalescing(e,t){let n=this.evaluate(e.left,t);return n===null||n===void 0?this.evaluate(e.right,t):n}createFunction(e){return(...t)=>{let n=ie(e.params,t);return this.evaluateFunctionBody(e.body,n)}}evaluateFunctionBody(e,t){switch(e.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(e,t);case"MethodCall":return this.evaluateMethodCallInFunction(e,t);case"Literal":return e.value;case"Root":return e.expression?this.evaluateFunctionBody(e.expression,t):t;default:return this.evaluate(e,w(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let o=this.evaluateFunctionBody(e.object,t);return v(o,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let s=w(t);return v(s,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):w(t);if(j(e.method)){let o=D(e.method),i=this.evaluateFunctionBody(e.args[0],t);return B(n,o,i)}let s=e.args.map((o)=>this.evaluateFunctionBody(o,t));return V(n,e.method,s)}}var de=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var he=(e,t)=>{let r=de.filter((s)=>s.type===e).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${t}:
|
|
3
3
|
${r.join(`
|
|
4
4
|
`)}`},cn=`Expression Shortcuts:
|
|
5
5
|
|
|
@@ -6,11 +6,11 @@ _1ls_complete() {
|
|
|
6
6
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
7
7
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
8
8
|
|
|
9
|
-
opts="--help --version --raw --pretty --compact --type --format --list --grep --find --recursive --ignore-case --line-numbers --ext --max-depth --shortcuts --shorten --expand --slurp --null-input readFile"
|
|
9
|
+
opts="--help -h --version -v --raw -r --pretty -p --compact -c --type -t --format --input-format -if --detect --list -l --grep -g --find -f --recursive -R --ignore-case -i --line-numbers -n --ext --max-depth --shortcuts --shorten --expand --strict -s --slurp -S --null-input -N --interactive readFile"
|
|
10
10
|
format_opts="json yaml csv table"
|
|
11
|
-
json_paths=". .[] .. .{keys} .{values} .{entries}"
|
|
12
|
-
shortcuts=".mp .flt .rd .fnd .sm .evr .srt .rvs .jn .kys .vls .ents .lc .uc .trm"
|
|
13
|
-
|
|
11
|
+
json_paths=". .[] .. .{keys} .{values} .{entries} .foo? .foo ?? default"
|
|
12
|
+
shortcuts=".mp .flt .rd .fnd .fndIdx .sm .evr .srt .rvs .jn .slc .splt .psh .pp .shft .unshft .fltMap .flt1 .incl .idxOf .kys .vls .ents .len .lc .uc .trm .trmSt .trmEnd .rpl .rplAll .pdSt .pdEnd .stsWith .endsWith .sbstr .chr .chrCd .mtch .str .json .val"
|
|
13
|
+
builtin_fns="pipe compose head last tail take drop uniq flatten rev groupBy sortBy chunk compact pick omit keys vals merge deepMerge fromPairs toPairs sum mean min max len count isEmpty isNil id pluck type range has nth contains add path getpath setpath recurse split join startswith endswith ltrimstr rtrimstr tostring tonumber floor ceil round abs not select empty error debug hd lst tl tk drp unq fltn grpBy srtBy chnk cmpct pk omt ks mrg dMrg frPrs toPrs avg cnt emp nil plk typ rng hs ctns pth gpth spth rec spl jn stw edw ltrm rtrm tstr tnum flr cl rnd sel dbg"
|
|
14
14
|
|
|
15
15
|
case "${prev}" in
|
|
16
16
|
--format)
|
|
@@ -45,11 +45,11 @@ _1ls_complete() {
|
|
|
45
45
|
fi
|
|
46
46
|
|
|
47
47
|
if [[ ${cur} =~ ^[a-zA-Z] ]]; then
|
|
48
|
-
COMPREPLY=( $(compgen -W "${
|
|
48
|
+
COMPREPLY=( $(compgen -W "${builtin_fns}" -- ${cur}) )
|
|
49
49
|
return 0
|
|
50
50
|
fi
|
|
51
51
|
|
|
52
|
-
COMPREPLY=( $(compgen -W "${opts} ${
|
|
52
|
+
COMPREPLY=( $(compgen -W "${opts} ${builtin_fns}" -- ${cur}) )
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
complete -F _1ls_complete 1ls
|
package/dist/completions/1ls.zsh
CHANGED
|
@@ -1,51 +1,87 @@
|
|
|
1
1
|
#compdef 1ls
|
|
2
2
|
|
|
3
3
|
_1ls() {
|
|
4
|
-
local -a opts
|
|
4
|
+
local -a opts shortcuts json_paths builtin_fns subcmds
|
|
5
5
|
|
|
6
6
|
opts=(
|
|
7
7
|
'--help[Show help]'
|
|
8
8
|
'--version[Show version]'
|
|
9
|
-
'--raw[
|
|
10
|
-
'--pretty[Pretty print
|
|
11
|
-
'--compact[
|
|
12
|
-
'--type[Show
|
|
13
|
-
'--format[Output format]:format:(json yaml csv table)'
|
|
9
|
+
'--raw[Output raw strings without quotes]'
|
|
10
|
+
'--pretty[Pretty print output with indentation]'
|
|
11
|
+
'--compact[Output compact JSON (no whitespace)]'
|
|
12
|
+
'--type[Show the type of the result]'
|
|
13
|
+
'--format[Output format: json, yaml, csv, table]:format:(json yaml csv table)'
|
|
14
|
+
'--input-format[Input format: json, yaml, toml, csv, tsv, lines, text]'
|
|
15
|
+
'--detect[Show detected input format without processing]'
|
|
14
16
|
'--list[List files in directory]:directory:_files -/'
|
|
15
|
-
'--grep[Search for pattern]
|
|
17
|
+
'--grep[Search for pattern in files]'
|
|
16
18
|
'--find[Path to search in]:path:_files'
|
|
17
19
|
'--recursive[Recursive search]'
|
|
18
20
|
'--ignore-case[Case insensitive search]'
|
|
19
21
|
'--line-numbers[Show line numbers]'
|
|
20
|
-
'--ext[Filter by extensions]
|
|
21
|
-
'--max-depth[Maximum recursion depth]
|
|
22
|
+
'--ext[Filter by file extensions]'
|
|
23
|
+
'--max-depth[Maximum recursion depth]'
|
|
22
24
|
'--shortcuts[Show all available shortcuts]'
|
|
23
|
-
'--shorten[Convert expression to shorthand]
|
|
24
|
-
'--expand[Convert shorthand to full form]
|
|
25
|
+
'--shorten[Convert expression to shorthand]'
|
|
26
|
+
'--expand[Convert shorthand to full form]'
|
|
27
|
+
'--strict[Strict mode]'
|
|
25
28
|
'--slurp[Read all inputs into array]'
|
|
26
29
|
'--null-input[Use null as input]'
|
|
27
|
-
'
|
|
30
|
+
'--interactive[Interactive mode]'
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
subcmds=(
|
|
34
|
+
'readFile:Read from file'
|
|
28
35
|
)
|
|
29
36
|
|
|
30
37
|
shortcuts=(
|
|
31
|
-
'.mp
|
|
32
|
-
'.flt
|
|
33
|
-
'.rd
|
|
34
|
-
'.fnd
|
|
35
|
-
'.
|
|
36
|
-
'.
|
|
37
|
-
'.
|
|
38
|
-
'.
|
|
39
|
-
'.
|
|
40
|
-
'.
|
|
41
|
-
'.
|
|
42
|
-
'.
|
|
43
|
-
'.
|
|
44
|
-
'.
|
|
45
|
-
'.
|
|
38
|
+
'.mp:.map - Transform each element'
|
|
39
|
+
'.flt:.filter - Filter elements'
|
|
40
|
+
'.rd:.reduce - Reduce to single value'
|
|
41
|
+
'.fnd:.find - Find first match'
|
|
42
|
+
'.fndIdx:.findIndex - Find index of first match'
|
|
43
|
+
'.sm:.some - Test if any match'
|
|
44
|
+
'.evr:.every - Test if all match'
|
|
45
|
+
'.srt:.sort - Sort elements'
|
|
46
|
+
'.rvs:.reverse - Reverse order'
|
|
47
|
+
'.jn:.join - Join to string'
|
|
48
|
+
'.slc:.slice - Extract portion'
|
|
49
|
+
'.splt:.split - Split string to array'
|
|
50
|
+
'.psh:.push - Add to end'
|
|
51
|
+
'.pp:.pop - Remove from end'
|
|
52
|
+
'.shft:.shift - Remove from start'
|
|
53
|
+
'.unshft:.unshift - Add to start'
|
|
54
|
+
'.fltMap:.flatMap - Map and flatten'
|
|
55
|
+
'.flt1:.flat - Flatten array'
|
|
56
|
+
'.incl:.includes - Check if includes'
|
|
57
|
+
'.idxOf:.indexOf - Find index'
|
|
58
|
+
'.kys:.{keys} - Get object keys'
|
|
59
|
+
'.vls:.{values} - Get object values'
|
|
60
|
+
'.ents:.{entries} - Get object entries'
|
|
61
|
+
'.len:.{length} - Get length/size'
|
|
62
|
+
'.lc:.toLowerCase - Convert to lowercase'
|
|
63
|
+
'.uc:.toUpperCase - Convert to uppercase'
|
|
64
|
+
'.trm:.trim - Remove whitespace'
|
|
65
|
+
'.trmSt:.trimStart - Remove leading whitespace'
|
|
66
|
+
'.trmEnd:.trimEnd - Remove trailing whitespace'
|
|
67
|
+
'.rpl:.replace - Replace text'
|
|
68
|
+
'.rplAll:.replaceAll - Replace all occurrences'
|
|
69
|
+
'.pdSt:.padStart - Pad start'
|
|
70
|
+
'.pdEnd:.padEnd - Pad end'
|
|
71
|
+
'.stsWith:.startsWith - Check if starts with'
|
|
72
|
+
'.endsWith:.endsWith - Check if ends with'
|
|
73
|
+
'.sbstr:.substring - Extract substring'
|
|
74
|
+
'.chr:.charAt - Get character at index'
|
|
75
|
+
'.chrCd:.charCodeAt - Get character code'
|
|
76
|
+
'.mtch:.match - Match pattern'
|
|
77
|
+
'.str:.toString - Convert to string'
|
|
78
|
+
'.json:.toJSON - Convert to JSON'
|
|
79
|
+
'.val:.valueOf - Get primitive value'
|
|
46
80
|
)
|
|
47
81
|
|
|
48
|
-
|
|
82
|
+
builtin_fns=(
|
|
83
|
+
'pipe:pipe'
|
|
84
|
+
'compose:compose'
|
|
49
85
|
'head:hd - First element'
|
|
50
86
|
'last:lst - Last element'
|
|
51
87
|
'tail:tl - All but first'
|
|
@@ -53,7 +89,7 @@ _1ls() {
|
|
|
53
89
|
'drop:drp - Drop n elements'
|
|
54
90
|
'uniq:unq - Unique values'
|
|
55
91
|
'flatten:fltn - Flatten nested'
|
|
56
|
-
'rev:
|
|
92
|
+
'rev:rev'
|
|
57
93
|
'groupBy:grpBy - Group by key'
|
|
58
94
|
'sortBy:srtBy - Sort by key'
|
|
59
95
|
'chunk:chnk - Split into chunks'
|
|
@@ -61,49 +97,47 @@ _1ls() {
|
|
|
61
97
|
'pick:pk - Pick keys'
|
|
62
98
|
'omit:omt - Omit keys'
|
|
63
99
|
'keys:ks - Object keys'
|
|
64
|
-
'vals:
|
|
65
|
-
'merge:mrg -
|
|
100
|
+
'vals:vals'
|
|
101
|
+
'merge:mrg - Merge objects'
|
|
66
102
|
'deepMerge:dMrg - Deep merge'
|
|
67
103
|
'fromPairs:frPrs - Pairs to object'
|
|
68
104
|
'toPairs:toPrs - Object to pairs'
|
|
69
|
-
'sum:
|
|
70
|
-
'mean:avg - Average'
|
|
71
|
-
'min:
|
|
72
|
-
'max:
|
|
73
|
-
'len:
|
|
105
|
+
'sum:sum'
|
|
106
|
+
'mean:avg - Average value'
|
|
107
|
+
'min:min'
|
|
108
|
+
'max:max'
|
|
109
|
+
'len:len'
|
|
74
110
|
'count:cnt - Count items'
|
|
75
111
|
'isEmpty:emp - Check if empty'
|
|
76
|
-
'isNil:nil - Check if
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'id:Identity function'
|
|
81
|
-
'type:typ - Get value type'
|
|
112
|
+
'isNil:nil - Check if nil'
|
|
113
|
+
'id:id'
|
|
114
|
+
'pluck:plk - Pluck property'
|
|
115
|
+
'type:typ - Get type'
|
|
82
116
|
'range:rng - Generate range'
|
|
83
|
-
'has:hs -
|
|
84
|
-
'nth:
|
|
85
|
-
'contains:ctns -
|
|
86
|
-
'add:
|
|
87
|
-
'path:pth -
|
|
88
|
-
'getpath:gpth - Get
|
|
89
|
-
'setpath:spth - Set
|
|
90
|
-
'recurse:rec - Recurse all
|
|
117
|
+
'has:hs - Has key'
|
|
118
|
+
'nth:nth - Nth element'
|
|
119
|
+
'contains:ctns - Contains value'
|
|
120
|
+
'add:add - Add/concat'
|
|
121
|
+
'path:pth - All paths'
|
|
122
|
+
'getpath:gpth - Get at path'
|
|
123
|
+
'setpath:spth - Set at path'
|
|
124
|
+
'recurse:rec - Recurse all'
|
|
91
125
|
'split:spl - Split string'
|
|
92
126
|
'join:jn - Join array'
|
|
93
|
-
'startswith:stw -
|
|
94
|
-
'endswith:edw -
|
|
127
|
+
'startswith:stw - Starts with'
|
|
128
|
+
'endswith:edw - Ends with'
|
|
95
129
|
'ltrimstr:ltrm - Trim prefix'
|
|
96
130
|
'rtrimstr:rtrm - Trim suffix'
|
|
97
|
-
'tostring:tstr -
|
|
98
|
-
'tonumber:tnum -
|
|
131
|
+
'tostring:tstr - To string'
|
|
132
|
+
'tonumber:tnum - To number'
|
|
99
133
|
'floor:flr - Floor number'
|
|
100
134
|
'ceil:cl - Ceil number'
|
|
101
135
|
'round:rnd - Round number'
|
|
102
|
-
'abs:Absolute value'
|
|
103
|
-
'not:
|
|
136
|
+
'abs:abs - Absolute value'
|
|
137
|
+
'not:not'
|
|
104
138
|
'select:sel - Filter by predicate'
|
|
105
|
-
'empty:
|
|
106
|
-
'error:
|
|
139
|
+
'empty:empty'
|
|
140
|
+
'error:error'
|
|
107
141
|
'debug:dbg - Debug output'
|
|
108
142
|
)
|
|
109
143
|
|
|
@@ -123,17 +157,27 @@ _1ls() {
|
|
|
123
157
|
|
|
124
158
|
_arguments -C \
|
|
125
159
|
"${opts[@]}" \
|
|
160
|
+
'1: :->subcmd' \
|
|
126
161
|
'*:: :->args'
|
|
127
162
|
|
|
128
163
|
case $state in
|
|
164
|
+
subcmd)
|
|
165
|
+
_describe -t subcmds 'subcommands' subcmds
|
|
166
|
+
;;
|
|
129
167
|
args)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
168
|
+
case $words[1] in
|
|
169
|
+
readFile)
|
|
170
|
+
_files
|
|
171
|
+
;;
|
|
172
|
+
*)
|
|
173
|
+
if [[ $words[$CURRENT] == .* ]]; then
|
|
174
|
+
_describe -t shortcuts 'shortcuts' shortcuts
|
|
175
|
+
_describe -t paths 'json paths' json_paths
|
|
176
|
+
else
|
|
177
|
+
_describe -t builtin_fns 'builtin functions' builtin_fns
|
|
178
|
+
fi
|
|
179
|
+
;;
|
|
180
|
+
esac
|
|
137
181
|
;;
|
|
138
182
|
esac
|
|
139
183
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export declare const CLI_FLAGS: readonly [{
|
|
2
|
+
readonly long: "--help";
|
|
3
|
+
readonly short: "-h";
|
|
4
|
+
readonly description: "Show help";
|
|
5
|
+
}, {
|
|
6
|
+
readonly long: "--version";
|
|
7
|
+
readonly short: "-v";
|
|
8
|
+
readonly description: "Show version";
|
|
9
|
+
}, {
|
|
10
|
+
readonly long: "--raw";
|
|
11
|
+
readonly short: "-r";
|
|
12
|
+
readonly description: "Output raw strings without quotes";
|
|
13
|
+
}, {
|
|
14
|
+
readonly long: "--pretty";
|
|
15
|
+
readonly short: "-p";
|
|
16
|
+
readonly description: "Pretty print output with indentation";
|
|
17
|
+
}, {
|
|
18
|
+
readonly long: "--compact";
|
|
19
|
+
readonly short: "-c";
|
|
20
|
+
readonly description: "Output compact JSON (no whitespace)";
|
|
21
|
+
}, {
|
|
22
|
+
readonly long: "--type";
|
|
23
|
+
readonly short: "-t";
|
|
24
|
+
readonly description: "Show the type of the result";
|
|
25
|
+
}, {
|
|
26
|
+
readonly long: "--format";
|
|
27
|
+
readonly short: null;
|
|
28
|
+
readonly description: "Output format: json, yaml, csv, table";
|
|
29
|
+
}, {
|
|
30
|
+
readonly long: "--input-format";
|
|
31
|
+
readonly short: "-if";
|
|
32
|
+
readonly description: "Input format: json, yaml, toml, csv, tsv, lines, text";
|
|
33
|
+
}, {
|
|
34
|
+
readonly long: "--detect";
|
|
35
|
+
readonly short: null;
|
|
36
|
+
readonly description: "Show detected input format without processing";
|
|
37
|
+
}, {
|
|
38
|
+
readonly long: "--list";
|
|
39
|
+
readonly short: "-l";
|
|
40
|
+
readonly description: "List files in directory";
|
|
41
|
+
}, {
|
|
42
|
+
readonly long: "--grep";
|
|
43
|
+
readonly short: "-g";
|
|
44
|
+
readonly description: "Search for pattern in files";
|
|
45
|
+
}, {
|
|
46
|
+
readonly long: "--find";
|
|
47
|
+
readonly short: "-f";
|
|
48
|
+
readonly description: "Path to search in";
|
|
49
|
+
}, {
|
|
50
|
+
readonly long: "--recursive";
|
|
51
|
+
readonly short: "-R";
|
|
52
|
+
readonly description: "Recursive search";
|
|
53
|
+
}, {
|
|
54
|
+
readonly long: "--ignore-case";
|
|
55
|
+
readonly short: "-i";
|
|
56
|
+
readonly description: "Case insensitive search";
|
|
57
|
+
}, {
|
|
58
|
+
readonly long: "--line-numbers";
|
|
59
|
+
readonly short: "-n";
|
|
60
|
+
readonly description: "Show line numbers";
|
|
61
|
+
}, {
|
|
62
|
+
readonly long: "--ext";
|
|
63
|
+
readonly short: null;
|
|
64
|
+
readonly description: "Filter by file extensions";
|
|
65
|
+
}, {
|
|
66
|
+
readonly long: "--max-depth";
|
|
67
|
+
readonly short: null;
|
|
68
|
+
readonly description: "Maximum recursion depth";
|
|
69
|
+
}, {
|
|
70
|
+
readonly long: "--shortcuts";
|
|
71
|
+
readonly short: null;
|
|
72
|
+
readonly description: "Show all available shortcuts";
|
|
73
|
+
}, {
|
|
74
|
+
readonly long: "--shorten";
|
|
75
|
+
readonly short: null;
|
|
76
|
+
readonly description: "Convert expression to shorthand";
|
|
77
|
+
}, {
|
|
78
|
+
readonly long: "--expand";
|
|
79
|
+
readonly short: null;
|
|
80
|
+
readonly description: "Convert shorthand to full form";
|
|
81
|
+
}, {
|
|
82
|
+
readonly long: "--strict";
|
|
83
|
+
readonly short: "-s";
|
|
84
|
+
readonly description: "Strict mode";
|
|
85
|
+
}, {
|
|
86
|
+
readonly long: "--slurp";
|
|
87
|
+
readonly short: "-S";
|
|
88
|
+
readonly description: "Read all inputs into array";
|
|
89
|
+
}, {
|
|
90
|
+
readonly long: "--null-input";
|
|
91
|
+
readonly short: "-N";
|
|
92
|
+
readonly description: "Use null as input";
|
|
93
|
+
}, {
|
|
94
|
+
readonly long: "--interactive";
|
|
95
|
+
readonly short: null;
|
|
96
|
+
readonly description: "Interactive mode";
|
|
97
|
+
}];
|
|
98
|
+
export type CliFlag = (typeof CLI_FLAGS)[number];
|
|
99
|
+
export declare const JSON_PATH_PATTERNS: readonly [{
|
|
100
|
+
readonly pattern: ".";
|
|
101
|
+
readonly description: "Root object";
|
|
102
|
+
}, {
|
|
103
|
+
readonly pattern: ".[]";
|
|
104
|
+
readonly description: "All array elements";
|
|
105
|
+
}, {
|
|
106
|
+
readonly pattern: "..";
|
|
107
|
+
readonly description: "Recursive descent";
|
|
108
|
+
}, {
|
|
109
|
+
readonly pattern: ".{keys}";
|
|
110
|
+
readonly description: "Object keys";
|
|
111
|
+
}, {
|
|
112
|
+
readonly pattern: ".{values}";
|
|
113
|
+
readonly description: "Object values";
|
|
114
|
+
}, {
|
|
115
|
+
readonly pattern: ".{entries}";
|
|
116
|
+
readonly description: "Object entries";
|
|
117
|
+
}, {
|
|
118
|
+
readonly pattern: ".foo?";
|
|
119
|
+
readonly description: "Optional access";
|
|
120
|
+
}, {
|
|
121
|
+
readonly pattern: ".foo ?? default";
|
|
122
|
+
readonly description: "Null coalescing";
|
|
123
|
+
}];
|
|
124
|
+
export type JsonPathPattern = (typeof JSON_PATH_PATTERNS)[number];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const CLI_FLAGS = [
|
|
2
|
+
{ long: "--help", short: "-h", description: "Show help" },
|
|
3
|
+
{ long: "--version", short: "-v", description: "Show version" },
|
|
4
|
+
{ long: "--raw", short: "-r", description: "Output raw strings without quotes" },
|
|
5
|
+
{ long: "--pretty", short: "-p", description: "Pretty print output with indentation" },
|
|
6
|
+
{ long: "--compact", short: "-c", description: "Output compact JSON (no whitespace)" },
|
|
7
|
+
{ long: "--type", short: "-t", description: "Show the type of the result" },
|
|
8
|
+
{ long: "--format", short: null, description: "Output format: json, yaml, csv, table" },
|
|
9
|
+
{ long: "--input-format", short: "-if", description: "Input format: json, yaml, toml, csv, tsv, lines, text" },
|
|
10
|
+
{ long: "--detect", short: null, description: "Show detected input format without processing" },
|
|
11
|
+
{ long: "--list", short: "-l", description: "List files in directory" },
|
|
12
|
+
{ long: "--grep", short: "-g", description: "Search for pattern in files" },
|
|
13
|
+
{ long: "--find", short: "-f", description: "Path to search in" },
|
|
14
|
+
{ long: "--recursive", short: "-R", description: "Recursive search" },
|
|
15
|
+
{ long: "--ignore-case", short: "-i", description: "Case insensitive search" },
|
|
16
|
+
{ long: "--line-numbers", short: "-n", description: "Show line numbers" },
|
|
17
|
+
{ long: "--ext", short: null, description: "Filter by file extensions" },
|
|
18
|
+
{ long: "--max-depth", short: null, description: "Maximum recursion depth" },
|
|
19
|
+
{ long: "--shortcuts", short: null, description: "Show all available shortcuts" },
|
|
20
|
+
{ long: "--shorten", short: null, description: "Convert expression to shorthand" },
|
|
21
|
+
{ long: "--expand", short: null, description: "Convert shorthand to full form" },
|
|
22
|
+
{ long: "--strict", short: "-s", description: "Strict mode" },
|
|
23
|
+
{ long: "--slurp", short: "-S", description: "Read all inputs into array" },
|
|
24
|
+
{ long: "--null-input", short: "-N", description: "Use null as input" },
|
|
25
|
+
{ long: "--interactive", short: null, description: "Interactive mode" },
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
export type CliFlag = (typeof CLI_FLAGS)[number];
|
|
29
|
+
|
|
30
|
+
export const JSON_PATH_PATTERNS = [
|
|
31
|
+
{ pattern: ".", description: "Root object" },
|
|
32
|
+
{ pattern: ".[]", description: "All array elements" },
|
|
33
|
+
{ pattern: "..", description: "Recursive descent" },
|
|
34
|
+
{ pattern: ".{keys}", description: "Object keys" },
|
|
35
|
+
{ pattern: ".{values}", description: "Object values" },
|
|
36
|
+
{ pattern: ".{entries}", description: "Object entries" },
|
|
37
|
+
{ pattern: ".foo?", description: "Optional access" },
|
|
38
|
+
{ pattern: ".foo ?? default", description: "Null coalescing" },
|
|
39
|
+
] as const;
|
|
40
|
+
|
|
41
|
+
export type JsonPathPattern = (typeof JSON_PATH_PATTERNS)[number];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CliFlag, JsonPathPattern } from "./constants";
|
|
2
|
+
import type { ShortcutMapping } from "../shortcuts/types";
|
|
3
|
+
export declare function getFlags(): string[];
|
|
4
|
+
export declare function getFormatOptions(): string[];
|
|
5
|
+
export declare function getJsonPaths(): string[];
|
|
6
|
+
export declare function getShortcutCompletions(): string[];
|
|
7
|
+
export declare function getBuiltinCompletions(): string[];
|
|
8
|
+
export declare function formatZshFlag(flag: CliFlag): string;
|
|
9
|
+
export declare function formatZshShortcut(s: ShortcutMapping): string;
|
|
10
|
+
export declare function formatZshBuiltin(fn: string): string;
|
|
11
|
+
export declare function formatZshPath(p: JsonPathPattern): string;
|
|
12
|
+
export declare function generateZshOptsBlock(): string;
|
|
13
|
+
export declare function generateZshShortcutsBlock(): string;
|
|
14
|
+
export declare function generateZshBuiltinsBlock(): string;
|
|
15
|
+
export declare function generateZshPathsBlock(): string;
|
|
16
|
+
export declare function generateZshCompletions(): string;
|
|
17
|
+
export declare function generateBashCompletions(): string;
|