@cartanova/qgrid-cli 2.15.1 → 2.15.3
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/bundle/dist/application/qgrid/qgrid.frame.js +3 -2
- package/bundle/dist/application/request-log/request-log-cost.js +59 -0
- package/bundle/dist/application/request-log/request-log.model.js +55 -85
- package/bundle/src/application/request-log/request-log-cost.test.ts +40 -0
- package/bundle/src/application/request-log/request-log-cost.ts +103 -0
- package/bundle/src/application/request-log/request-log.model.test.ts +121 -123
- package/bundle/src/application/request-log/request-log.model.ts +70 -167
- package/bundle/web-dist/client/assets/{index-JkBenvsH.js → index-BakMhnHZ.js} +3 -3
- package/bundle/web-dist/client/assets/logs-Dw-GrMuH.js +1 -0
- package/bundle/web-dist/client/assets/{monit-CQ6cVvzc.js → monit-BaFFiVKs.js} +1 -1
- package/bundle/web-dist/client/assets/{routes-BkeaYiBN.js → routes-R1xBZYVT.js} +1 -1
- package/bundle/web-dist/client/assets/{settings-DJdBEFoL.js → settings-Bw_NXAx8.js} +1 -1
- package/bundle/web-dist/client/assets/{show-CcKkiy8Y.js → show-BH7nfFtF.js} +1 -1
- package/bundle/web-dist/client/assets/{tokens-DuLrdLMa.js → tokens-BPmRr7mD.js} +1 -1
- package/bundle/web-dist/client/assets/{use-oauth-login-flow-CFJY-N99.js → use-oauth-login-flow-B_MGbC3a.js} +1 -1
- package/bundle/web-dist/client/assets/{use-update-token-mutation-CrEi7wJa.js → use-update-token-mutation-Dcq7Yv2R.js} +1 -1
- package/bundle/web-dist/client/index.html +1 -1
- package/bundle/web-dist/server/assets/{logs-C0md5rmp.js → logs-6289J29J.js} +17 -4
- package/bundle/web-dist/server/assets/{routes-CCdBJqP_.js → routes-DVWRvqn0.js} +1 -1
- package/bundle/web-dist/server/assets/{tokens-C4D67FBX.js → tokens-Di1vDwm5.js} +1 -1
- package/bundle/web-dist/server/assets/{use-oauth-login-flow-CFzShQtp.js → use-oauth-login-flow-BUAcW_pK.js} +3 -3
- package/bundle/web-dist/server/entry-server.generated.js +21 -21
- package/dist/cli.js +9 -38
- package/package.json +2 -2
- package/bundle/web-dist/client/assets/logs-UozX8VD5.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,r as n}from"./vendor-react-8xo7RSum.js";import{d as r,u as i}from"./vendor-tanstack-6B86itGS.js";import{i as a,o,r as s,s as c,u as l}from"./index-JkBenvsH.js";import{i as u,r as d,t as f}from"./cost-CZzlCFS2.js";import{t as p}from"./refresh-cw-BtYoFHVw.js";import{n as m,t as h}from"./request-model-Dl31cZdf.js";var g=e(t()),_=n(),v=(0,g.forwardRef)(({title:e,titleId:t,...n},r)=>(0,_.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,_.jsx)(`title`,{id:t,children:e}):null,(0,_.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})]})),y=(0,g.forwardRef)(({title:e,titleId:t,...n},r)=>(0,_.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,ref:r,"aria-labelledby":t,...n,children:[e?(0,_.jsx)(`title`,{id:t,children:e}):null,(0,_.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})]})),b=50,x=`__unassigned__`;function S(e){let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function C(e){return e.toLocaleString()}function w(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}var T=3e3;function E({status:e,requestedModel:t,servedModel:n,imageCostMethod:r,fallbackCount:i}){if(e===`running`){let i=h({status:e,requestedModel:t,servedModel:n,imageCostMethod:r});return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`text-xs text-sand-500`,children:i.label}),(0,_.jsx)(`span`,{className:`ml-1 text-[9px] px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-600 font-medium whitespace-nowrap`,children:`실행 중`})]})}let a=h({status:e,requestedModel:t,servedModel:n,imageCostMethod:r}),o=t!==null&&n===null;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`text-xs text-sand-500`,children:a.label}),o&&(0,_.jsx)(`span`,{className:`ml-1 text-[9px] text-sand-400`,children:`요청`}),(i??0)>0&&(0,_.jsxs)(`span`,{className:`ml-1 text-[9px] text-caution-500`,children:[`×`,i]})]})}function D(e){return e<=0?`—`:e>=1e3?`${(e/1e3).toFixed(1)}s`:`${e}ms`}var O=[{label:`ID`,align:`left`,width:`w-12`,sortKey:`id`},{label:`Date`,align:`left`,width:`w-20`,sortKey:`created_at`},{label:`Project`,align:`left`,width:`w-20`},{label:`Token`,align:`left`,width:`w-24`},{label:`Model`,align:`left`,width:`w-20`},{label:`Fmt`,align:`left`,width:`w-12`},{label:`TTFT`,align:`right`,width:`w-16`,sortKey:`ttft_ms`},{label:`Duration`,align:`right`,width:`w-20`,sortKey:`duration_ms`},{label:`In`,align:`right`,width:`w-16`,sortKey:`input_tokens`},{label:`Out`,align:`right`,width:`w-20`,sortKey:`output_tokens`},{label:`C.Read`,align:`right`,width:`w-20`,sortKey:`cache_read_tokens`},{label:`C.Write`,align:`right`,width:`w-20`,sortKey:`cache_creation_tokens`},{label:`Hit`,align:`right`,width:`w-14`},{label:`Tools`,align:`right`,width:`w-14`},{label:`$`,align:`right`,width:`w-20`,sortKey:`cost_usd`}];function k({search:e,onSearchChange:t}){let n=r(),s=e.page??1,h=e.token??``,k=e.project??``,A=e.model??``,{data:j}=l.useTokens(`A`),M=(j?.rows??[]).map(e=>e.name).filter(Boolean),{data:ee}=o.useProjectNames(),te=ee?.names??[],{data:N}=o.useModelNames(),P=N?.names??[],F=k===x?{project_name_is_null:!0}:k?{project_name:k}:{},I={};h&&(I.token_name=h),Object.assign(I,F),A&&(I.model_name=A);let L=e.sort??`id-desc`,R=L.lastIndexOf(`-`),z=L.slice(0,R),B=L.slice(R+1)===`asc`?`asc`:`desc`,{data:V,isLoading:H,isError:U,refresh:W,isRefreshing:G}=c.useRequestLogs(`P`,{num:b,page:s,orderBy:L,...I}),{data:K,isError:q,refresh:J}=o.useTotalCost({num:0,page:1,...I}),Y=V?.rows??[],X=V?.total??0,Z=Y.some(e=>e.status===`running`);(0,g.useEffect)(()=>{let e=Z?setInterval(()=>{W(),J()},T):void 0;return()=>clearInterval(e)},[Z,W,J]);let Q=Math.ceil(X/b),$=n=>{t({...e,...n,page:1})};return(0,_.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`panel-header flex items-center gap-2 px-3 py-2.5 flex-wrap sm:gap-3 sm:px-5`,children:[(0,_.jsxs)(`select`,{value:h,onChange:e=>$({token:e.target.value||void 0}),disabled:M.length===0,className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300 disabled:text-sand-300 disabled:cursor-not-allowed`,children:[(0,_.jsx)(`option`,{value:``,children:M.length>0?`All Tokens`:`Tokens —`}),M.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))]}),(0,_.jsxs)(`select`,{value:k,onChange:e=>$({project:e.target.value||void 0}),className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300`,children:[(0,_.jsx)(`option`,{value:``,children:`All Projects`}),(0,_.jsx)(`option`,{value:x,children:`(unassigned)`}),te.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))]}),(0,_.jsxs)(`select`,{value:A,onChange:e=>$({model:e.target.value||void 0}),disabled:P.length===0,className:`border border-sand-200/80 rounded-lg px-2.5 py-1.5 text-[11px] text-sand-700 bg-sand-50/50 focus:outline-none focus:border-sienna-300 disabled:text-sand-300 disabled:cursor-not-allowed`,children:[(0,_.jsx)(`option`,{value:``,children:P.length>0?`All Models`:`Models —`}),P.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>void Promise.all([W(),J()]),disabled:G,"aria-label":`Reload`,title:`Reload`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,children:(0,_.jsx)(p,{className:G?`size-3.5 animate-spin`:`size-3.5`})}),(0,_.jsx)(`div`,{className:`flex-1`}),(0,_.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[U||!V?`—`:X,` results`]}),q?(0,_.jsx)(`span`,{role:`alert`,className:`text-[11px] text-danger-500`,children:`Failed to load total cost.`}):(0,_.jsx)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:K?u(K.usd):`—`})]}),U?(0,_.jsx)(`div`,{role:`alert`,className:`text-danger-500 text-center py-12 text-sm`,children:`Failed to load request logs.`}):H?(0,_.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,_.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):Y.length===0?(0,_.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`overflow-x-auto px-3 py-3 sm:px-5`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[900px] text-[13px]`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-sand-100/60`,children:[O.map(e=>{let t=e.label===`Duration`?`pl-5 pr-3`:e.width?`px-4`:`px-3`,n=e.sortKey===z;return(0,_.jsx)(`th`,{className:`${e.align===`right`?`text-right`:`text-left`} ${e.width??``} ${e.width?`whitespace-nowrap`:``} ${t} py-1.5 text-[10px] uppercase font-medium ${n?`text-sienna-600`:`text-sand-400`}`,children:e.sortKey?(0,_.jsxs)(`button`,{type:`button`,onClick:()=>$({sort:a.parse(`${e.sortKey}-${n&&B===`desc`?`asc`:`desc`}`)}),className:`inline-flex items-center gap-0.5 text-[10px] uppercase font-medium hover:text-sienna-500 transition-colors duration-150 ${e.align===`right`?`justify-end w-full`:``}`,children:[e.label,(0,_.jsx)(`span`,{className:n?``:`text-sand-300`,children:n?B===`desc`?`↓`:`↑`:`↕`})]}):e.label},e.label)}),(0,_.jsx)(`th`,{className:`w-8`,children:(0,_.jsx)(`span`,{className:`sr-only`,children:`Details`})})]})}),(0,_.jsx)(`tbody`,{className:`divide-y divide-sand-100/60`,children:Y.map(e=>(0,_.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:t=>{t.metaKey||t.ctrlKey?window.open(`/requests/show?id=${e.id}`,`_blank`):n({to:`/requests/show`,search:{id:e.id}})},children:[(0,_.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,_.jsx)(i,{to:`/requests/show`,search:{id:e.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:e.id})}),(0,_.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,_.jsx)(`span`,{className:`text-xs text-sand-400 tabular-nums`,children:S(e.created_at)})}),(0,_.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,_.jsx)(`span`,{className:`text-xs text-sand-600`,children:e.project_name??`—`})}),(0,_.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:(0,_.jsx)(`span`,{className:`text-xs text-sand-500`,children:e.token_name})}),(0,_.jsxs)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:[(0,_.jsx)(E,{status:e.status,requestedModel:e.requested_model_name,servedModel:e.model_name,imageCostMethod:e.image_cost_method,fallbackCount:e.fallback_count}),e.service_tier===`fast`&&(0,_.jsx)(`span`,{title:`Fast 모드`,className:`ml-1 inline-flex align-middle`,children:(0,_.jsx)(m,{"aria-label":`Fast 모드`,className:`size-3 text-[#1877F2] [&_path]:fill-current`})}),e.response_json_ok===!1&&(0,_.jsx)(`span`,{title:`structured 요청의 응답이 JSON 파싱에 실패했습니다`,className:`ml-1.5 rounded-full bg-caution-400/15 px-1.5 py-0.5 text-[9px] font-semibold text-caution-500`,children:`broken`})]}),(0,_.jsx)(`td`,{className:`px-4 py-1.5 whitespace-nowrap`,children:e.is_image_generation?(0,_.jsx)(`span`,{className:`rounded bg-sage-100 px-1.5 py-0.5 font-mono text-[10px] text-sage-700`,children:`img`}):e.is_structured?(0,_.jsx)(`span`,{className:`rounded bg-sienna-100 px-1.5 py-0.5 font-mono text-[10px] text-sienna-700`,children:`json`}):(0,_.jsx)(`span`,{className:`font-mono text-[10px] text-sand-400`,children:`text`})}),(0,_.jsx)(`td`,{className:`px-4 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:D(e.ttft_ms)}),(0,_.jsx)(`td`,{className:`pl-5 pr-3 py-1.5 text-right tabular-nums text-sand-500 whitespace-nowrap`,children:w(e.duration_ms)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:C(e.input_tokens)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:C(e.output_tokens)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:C(e.cache_read_tokens)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:C(e.cache_creation_tokens)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700`,children:f(e)}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-500`,children:e.tool_call_count>0?e.tool_call_count:`—`}),(0,_.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums text-sand-700 whitespace-nowrap`,children:d(e)}),(0,_.jsx)(`td`,{className:`px-2 py-1.5`,children:(0,_.jsx)(y,{className:`size-4 text-sand-400`})})]},e.id))})]})}),Q>1&&(0,_.jsxs)(`div`,{className:`flex items-center justify-center gap-3 px-5 py-2.5 border-t border-sand-100/60`,children:[(0,_.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:s===1,onClick:()=>t({...e,page:s-1}),children:(0,_.jsx)(v,{className:`size-4`})}),(0,_.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[s,` / `,Q]}),(0,_.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:s===Q,onClick:()=>t({...e,page:s+1}),children:(0,_.jsx)(y,{className:`size-4`})})]})]})]})}function A(){let e=s.useSearch(),t=s.useNavigate();return(0,_.jsx)(`div`,{className:`max-w-[100rem] mx-auto`,children:(0,_.jsx)(k,{search:e,onSearchChange:e=>t({search:e})})})}export{A as component};
|