@zenovay/cli 0.1.14 → 0.1.16

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.
Files changed (57) hide show
  1. package/dist/{ai-bBoxoKB9.js → ai-QwPVHbiS.js} +1 -1
  2. package/dist/analytical-screen-DQwA5IZ1.js +1 -0
  3. package/dist/{api-BhdaCghp.js → api-0Qf43hhF.js} +1 -1
  4. package/dist/{api-v2-B03fp6KF.js → api-v2-DnMJJmhi.js} +1 -1
  5. package/dist/bin.js +1 -1
  6. package/dist/companies-BPwvvD2o.js +2 -0
  7. package/dist/config-Ddkbfelp.js +1 -0
  8. package/dist/deploys-BUnVkaEg.js +2 -0
  9. package/dist/{doctor-y7_iOaxP.js → doctor-DyNONZGx.js} +1 -1
  10. package/dist/errors-DND9r91m.js +2 -0
  11. package/dist/{events-tail-C35jGarq.js → events-tail-D6UfbRj7.js} +2 -2
  12. package/dist/funnel-BpMHOOaE.js +3 -0
  13. package/dist/health-B4NtoJtP.js +1 -0
  14. package/dist/{health-B_x_w2CV.js → health-B7BBVo2z.js} +1 -1
  15. package/dist/init-B9fjLwAP.js +62 -0
  16. package/dist/init-QiTMBqJb.js +1 -0
  17. package/dist/keybar-CWo5rhK_.js +1 -0
  18. package/dist/login-2h7PjSlW.js +1 -0
  19. package/dist/{login-DHLIZV8C.js → login-CpJeUOCR.js} +1 -1
  20. package/dist/{logout-DvGiNVs9.js → logout-DBIL_bPH.js} +1 -1
  21. package/dist/projects-CYmKX2WM.js +2 -0
  22. package/dist/prompt-B1QrBhyZ.js +3 -0
  23. package/dist/query-DD6ZGKsY.js +8 -0
  24. package/dist/resolve-site-CPY8XSeq.js +2 -0
  25. package/dist/revenue-C6YPnOvr.js +2 -0
  26. package/dist/sources-BYSCTIBA.js +2 -0
  27. package/dist/stats-C0AJtjVS.js +2 -0
  28. package/dist/{themes-F-HUBXpr.js → themes-Bhj-4q-r.js} +1 -1
  29. package/dist/{ui-Bk5nl2yb.js → ui-CVGR9Ffn.js} +1 -1
  30. package/dist/{update-2SafBiSk.js → update-CgGLjHBM.js} +1 -1
  31. package/dist/use-jF2EdP8H.js +5 -0
  32. package/dist/vitals-rttZVRnn.js +2 -0
  33. package/dist/watch-Bgjke7jm.js +1 -0
  34. package/dist/{webhooks-forward-QnE7MdSy.js → webhooks-forward-DQaXTq3w.js} +1 -1
  35. package/dist/wizard-bin.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/analytical-screen-Boiw3NTp.js +0 -1
  38. package/dist/companies-Z4LkcGcD.js +0 -3
  39. package/dist/config-ZTGpKEWg.js +0 -1
  40. package/dist/deploys-28qQkagZ.js +0 -3
  41. package/dist/errors-CUUuLToC.js +0 -3
  42. package/dist/funnel-BCa_5jW3.js +0 -4
  43. package/dist/health-D-nDYCrN.js +0 -1
  44. package/dist/init-C6maV1Ia.js +0 -1
  45. package/dist/init-DacZiEma.js +0 -62
  46. package/dist/keybar-D2OI-8rx.js +0 -3
  47. package/dist/login-D4kNEDVO.js +0 -1
  48. package/dist/projects-BCK7Jspy.js +0 -3
  49. package/dist/prompt-hjzdzlyj.js +0 -1
  50. package/dist/query-B8PDpxhG.js +0 -9
  51. package/dist/revenue-39qQFWdR.js +0 -3
  52. package/dist/sources-BzZK-YOD.js +0 -3
  53. package/dist/stats-CstuCrtH.js +0 -3
  54. package/dist/vitals-D_r_rBbw.js +0 -3
  55. package/dist/watch-CtIJ1ZAz.js +0 -2
  56. /package/dist/{check-S0ACFIfq.js → check-CmOnrU4W.js} +0 -0
  57. /package/dist/{completions-GDtTbG3B.js → completions-Bqs_uGx6.js} +0 -0
@@ -1,2 +0,0 @@
1
- import{readConfig as e}from"./config-ZTGpKEWg.js";import{ApiClient as t,readToken as n}from"./api-BhdaCghp.js";import{parseSseStream as r}from"./client-DZ4Awt8u.js";import"./formatter-45-fT1Hv.js";import{emit as i,isHeadless as a}from"./emit-0WJ_OGeT.js";import{Panel as o}from"./panel-DglZ755S.js";import{Banner as s,Keybar as c}from"./keybar-D2OI-8rx.js";import{spark as l}from"./sparkline-CR_bzxwB.js";import{Box as u,Text as d,render as f,useApp as p,useInput as m}from"ink";import h,{useEffect as g,useState as _}from"react";import v from"ink-spinner";import y from"ink-text-input";const b=Math.PI*2;function x(e){let t=e,n=Math.PI*Math.sin(e);for(let e=0;e<6;e++){let e=2*t+Math.sin(2*t)-n,r=2+2*Math.cos(2*t);if(r===0)break;t-=e/r}return t}function S(e,t){if(e<-90||e>90||t<-180||t>180)return null;let n=e*Math.PI/180,r=t*Math.PI/180,i=x(n),a=r*Math.cos(i)/Math.PI,o=Math.sin(i);return{x:a,y:o}}function C(e){if(e)return!0;let t=process.env;if(t.NO_COLOR||t.ZENOVAY_GLOBE===`ascii`)return!0;let n=(t.LANG||t.LC_ALL||t.LC_CTYPE||``).toLowerCase();return!!(n&&!n.includes(`utf`))}function w(e,t){let n=e*2,r=t*4;return{dw:n,dh:r,bits:new Uint8Array(n*r)}}function T(e,t,n){t<0||t>=e.dw||n<0||n>=e.dh||(e.bits[n*e.dw+t]=1)}function E(e){let t=e.dw/2,n=e.dh/2,r=e.dw/2-1,i=e.dh/2-1,a=Math.max(e.dw,e.dh)*2;for(let o=0;o<a;o++){let s=o/a*b,c=Math.round(t+r*Math.cos(s)),l=Math.round(n+i*Math.sin(s));T(e,c,l)}}function D(e){let t=Math.floor(e.dh/2);for(let n=0;n<e.dw;n+=4)T(e,n,t)}function O(e,t){let n=e.dw/2,r=e.dh/2,i=e.dw/2-1,a=e.dh/2-1;for(let o of t){let t=S(o.lat,o.lng);if(!t)continue;let s=Math.round(n+t.x*i),c=Math.round(r-t.y*a);T(e,s,c),T(e,s+1,c),T(e,s,c+1),T(e,s+1,c+1)}}const k=[[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[0,3],[1,3]];function A(e,t,n){let r=0;for(let i=0;i<k.length;i++){let[a,o]=k[i],s=t*2+a,c=n*4+o;e.bits[c*e.dw+s]&&(r|=1<<i)}return r===0?` `:String.fromCodePoint(10240+r)}function j(e,t,n){let r=0;for(let i=0;i<4;i++)for(let a=0;a<2;a++){let o=t*2+a,s=n*4+i;e.bits[s*e.dw+o]&&r++}return r===0?` `:r<=2?`.`:r<=4?`:`:r<=6?`*`:`#`}function M({data:e,width:t=80,height:n=20,asciiOnly:r}){let i=C(r),a=w(t,n);E(a),D(a),O(a,e);let o=[];for(let e=0;e<n;e++){let n=``;for(let r=0;r<t;r++)n+=i?j(a,r,e):A(a,r,e);o.push(n)}return h.createElement(u,{flexDirection:`column`},o.map((e,t)=>h.createElement(d,{key:t,color:`magenta`},e)),h.createElement(d,{color:`gray`},e.length,` live · `,i?`ascii mode`:`braille mode`))}async function N(r){let o=await e(),s=await n({strict:!1});if(!s)return process.stderr.write("Not logged in — run `zenovay login` first.\n"),2;let c=new t({config:o,cliVersion:r.cliVersion,token:s}),l=r.siteId??s.teamId;if(!l)return process.stderr.write(`No site selected — pass --site-id.
2
- `),2;if(a(r)){let e=await c.getDashboardSnapshot(l);return i({type:`watch.tick`,snapshot:e}),0}return new Promise(e=>{let{unmount:t}=f(h.createElement(P,{api:c,siteId:l,intervalMs:r.intervalMs??15e3,cliVersion:r.cliVersion,onExit:n=>{t(),e(n)}}))})}const P=({api:e,siteId:t,intervalMs:n,cliVersion:i,onExit:a})=>{let{exit:l}=p(),[f,y]=_(null),[b,x]=_(null),[S,C]=_(null),[w,T]=_([]),[E,D]=_(!0),[O,k]=_(null),[A,j]=_(1),[N,P]=_(!1),[H,U]=_(!1);if(m((e,t)=>{if(e===`q`){l(),a(0);return}if(e===`?`||e===`/`){U(e=>!e);return}if(e===`g`){P(e=>!e);return}if(t.tab){j(e=>{let n=t.shift?(e+4)%6+1:e%6+1;return n});return}(e===`1`||e===`2`||e===`3`||e===`4`||e===`5`||e===`6`)&&j(Number(e))}),g(()=>{let r=!1,i=async()=>{try{let n=await e.getDashboardSnapshot(t);if(r)return;y(n);let i=e.getVitals;typeof i==`function`&&i.call(e,t).then(e=>{r||x(e)},()=>{});let a=e.getGoals;typeof a==`function`&&a.call(e,t).then(e=>{r||C(e)},()=>{}),D(!1),k(null)}catch(e){r||k(e.message)}};i();let a=setInterval(i,n);return()=>{r=!0,clearInterval(a)}},[e,t,n]),g(()=>{let n=new AbortController;return(async()=>{try{let i=await e.openEventsStream(t,n.signal);for await(let e of r(i))e.type===`error`&&T(t=>[...t,`[ERR ${e.code}] ${e.message}`].slice(-10))}catch{}})(),()=>n.abort()},[e,t]),E)return h.createElement(u,{flexDirection:`column`},h.createElement(s,{version:i,subtitle:`watch · ${t}`}),h.createElement(o,{title:`Loading`,state:`busy`},h.createElement(u,null,h.createElement(d,{color:`magenta`},h.createElement(v,{type:`dots`})),h.createElement(d,null,` Fetching snapshot…`))));if(O&&!f)return h.createElement(u,{flexDirection:`column`},h.createElement(s,{version:i,subtitle:`watch · ${t}`}),h.createElement(o,{title:`Error`,state:`err`},h.createElement(d,{color:`red`},O)));let W=process.stdout.columns??80,G=Math.max(20,Math.floor(W/3)-1),K=[];return h.createElement(u,{flexDirection:`column`},h.createElement(s,{version:i,subtitle:`watch · ${t}${N?` · globe`:``}`}),h.createElement(u,{flexDirection:`row`},h.createElement(u,{flexDirection:`column`},N?h.createElement(o,{title:`Live globe`,focused:A===1,width:G},h.createElement(M,{data:K,width:Math.max(40,G-4),height:12})):h.createElement(I,{snapshot:f,focused:A===1,width:G}),h.createElement(z,{events:w,focused:A===4,width:G})),h.createElement(u,{flexDirection:`column`},h.createElement(L,{snapshot:f,focused:A===2,width:G}),h.createElement(B,{vitals:b,focused:A===5,width:G})),h.createElement(u,{flexDirection:`column`},h.createElement(R,{snapshot:f,focused:A===3,width:G}),h.createElement(V,{goals:S,focused:A===6,width:G}))),H?h.createElement(F,{api:e,siteId:t,width:W-2}):null,h.createElement(c,{items:[{key:`tab`,label:`next`},{key:`1-6`,label:`jump`},{key:`g`,label:N?`panels`:`globe`},{key:`?/`,label:H?`close chat`:`ai chat`},{key:`q`,label:`quit`}]}))},F=({api:e,siteId:t,width:n})=>{let[i,a]=_(``),[s,c]=_([]),[l,f]=_(!1),[p,m]=_(``),[g,v]=_(null),b=async n=>{let i=n.trim();if(!i||l)return;v(null),a(``);let o=[...s,{role:`user`,content:i}];c(o),f(!0),m(``);try{let n=o.map(e=>({role:e.role,content:e.content})),i=await e.openAiStream(`chat`,{messages:n,siteId:t},void 0),a=``;for await(let e of r(i))if(e.type===`delta`)a+=e.content,m(a);else if(e.type===`error`)v(`${e.code}: ${e.message}`);else if(e.type===`done`)break;c([...o,{role:`assistant`,content:a}]),m(``)}catch(e){v(e instanceof Error?e.message:`chat failed`)}finally{f(!1)}};return h.createElement(u,{marginTop:1},h.createElement(o,{title:`AI chat (esc / ?/ to close)`,focused:!0,width:n},h.createElement(u,{flexDirection:`column`},s.slice(-6).map((e,t)=>h.createElement(u,{key:t,flexDirection:`column`,marginBottom:1},h.createElement(d,{color:e.role===`user`?`cyan`:`magenta`,bold:!0},e.role===`user`?`you`:`zenovay`),h.createElement(d,null,e.content))),l&&p?h.createElement(u,{flexDirection:`column`,marginBottom:1},h.createElement(d,{color:`magenta`,bold:!0},`zenovay`),h.createElement(d,null,p)):null,g?h.createElement(d,{color:`red`},`✗ `,g):null,h.createElement(u,null,h.createElement(d,{color:`cyan`},l?`⠋ `:`▸ `),h.createElement(y,{value:i,onChange:a,onSubmit:b,placeholder:l?`streaming…`:`ask anything about your analytics`})))))},I=({snapshot:e,focused:t,width:n})=>{let r=e?.visitors?.count??0,i=e?.visitors?.series??[];return h.createElement(o,{title:`Visitors`,focused:t,width:n},h.createElement(d,{bold:!0},r.toString()),h.createElement(d,{color:`gray`},i.length>0?l(i,Math.max(8,n-6)):`— no data —`))},L=({snapshot:e,focused:t,width:n})=>{let r=e?.topPages?.slice(0,5)??[];return h.createElement(o,{title:`Top pages`,focused:t,width:n},r.length===0?h.createElement(d,{color:`gray`},`— no data —`):r.map(e=>h.createElement(u,{key:e.path},h.createElement(d,null,e.path.padEnd(n-10).slice(0,n-10)),h.createElement(d,{color:`gray`},` `,e.views))))},R=({snapshot:e,focused:t,width:n})=>{let r=e?.sources?.slice(0,5)??[];return h.createElement(o,{title:`Sources`,focused:t,width:n},r.length===0?h.createElement(d,{color:`gray`},`— no data —`):r.map(e=>h.createElement(u,{key:e.source},h.createElement(d,null,e.source.padEnd(n-10).slice(0,n-10)),h.createElement(d,{color:`gray`},` `,e.visitors))))},z=({events:e,focused:t,width:n})=>h.createElement(o,{title:`Events`,focused:t,width:n},e.length===0?h.createElement(d,{color:`gray`},`— waiting —`):e.slice(-10).map((e,t)=>h.createElement(d,{key:t},e.slice(0,n-4)))),B=({vitals:e,focused:t,width:n})=>{let r=(e,t,n)=>h.createElement(u,{key:e},h.createElement(d,{bold:!0},e.padEnd(6)),h.createElement(d,{color:`gray`},typeof t==`number`?`${t.toFixed(0)}${n}`:`—`));return h.createElement(o,{title:`Vitals`,focused:t,width:n},r(`LCP`,e?.lcpP75,`ms`),r(`INP`,e?.inpP75,`ms`),r(`CLS`,e?.clsP75?e.clsP75*1e3:void 0,`/1k`),r(`TTFB`,e?.ttfbP75,`ms`),r(`FCP`,e?.fcpP75,`ms`))},V=({goals:e,focused:t,width:n})=>{let r=e?.goals?.slice(0,5)??[];return h.createElement(o,{title:`Goals`,focused:t,width:n},r.length===0?h.createElement(d,{color:`gray`},`— no data —`):r.map(e=>h.createElement(u,{key:e.name},h.createElement(d,null,e.name.padEnd(n-10).slice(0,n-10)),h.createElement(d,{color:`gray`},` `,e.completions))))};export{N as watchCommand};
File without changes