lenso-cli 0.1.9

Lenso command-line interface for scaffolding and operating Lenso backend projects.
1
import{n as e}from"../../assets/rolldown-runtime-Bh1tDfsg.js";import{i as t,r as n}from"../../assets/react-qq500p4R.js";import{ct as r,n as i,r as a}from"../../assets/src-DikQ2ikd.js";var o=i({exportName:`authConsoleModule`,id:`auth`,packageName:`@lenso/auth-console`,source:`runtime_bundle`,surfaces:[{area:`data`,icon:`shield`,label:`Sessions`,navigation:{order:50,workspace:{icon:`shield`,id:`auth`,label:`Auth`}},requiredCapabilities:[`auth.users.read`],route:`/data/auth`,surfaceName:`auth`},{area:`data`,icon:`shield`,label:`Sessions`,navigation:{order:50,workspace:{icon:`shield`,id:`auth`,label:`Auth`}},requiredCapabilities:[`auth.users.read`],route:`/data/auth/sessions`,surfaceName:`sessions`},{area:`data`,icon:`shield`,label:`Users`,navigation:{order:60,workspace:{icon:`shield`,id:`auth`,label:`Auth`}},requiredCapabilities:[`auth.users.read`],route:`/data/auth/users`,surfaceName:`users`}],version:`workspace`}),s=e(t(),1),c=e=>typeof e==`string`&&e.length>0?e:`-`,l=(e,t=new Date)=>e.map(e=>{let n=c(e.disabled_at),r=c(e.disabled_until);return{createdAt:c(e.created_at),disabledAt:n,disabledReason:c(e.disabled_reason),disabledUntil:r,id:c(e.id),status:d(n,r,t)}}),u=(e,t=new Date)=>{let n={active:0,disabled:0,total:0};for(let r of l(e,t))n.total+=1,n[r.status]+=1;return n};function d(e,t,n){if(e===`-`)return`active`;let r=Date.parse(t);return Number.isFinite(r)&&r<=n.getTime()?`active`:`disabled`}var f=(e,t=new Date)=>e.map(e=>{let n=c(e.revoked_at),r=c(e.expires_at);return{createdAt:c(e.created_at),expiresAt:r,id:c(e.id),revokedAt:n,status:m(r,n,t),userId:c(e.user_id)}}),p=(e,t=new Date)=>{let n={active:0,expired:0,revoked:0,total:0};for(let r of f(e,t))n.total+=1,n[r.status]+=1;return n};function m(e,t,n){if(t!==`-`)return`revoked`;let r=Date.parse(e);return Number.isFinite(r)&&r<=n.getTime()?`expired`:`active`}var h=n(),g=({error:e,isError:t,isPending:n,onSelect:r,rows:i,selectedUser:a})=>t?(0,h.jsx)(C,{tone:`error`,value:String(e?.message)}):n?(0,h.jsx)(C,{value:`Loading auth users`}):i.length===0?(0,h.jsx)(C,{value:`No auth users found`}):(0,h.jsxs)(`div`,{className:`min-h-0 overflow-auto`,children:[(0,h.jsxs)(`div`,{className:`grid min-w-240 grid-cols-[minmax(220px,1fr)_170px_170px_170px_88px] border-b border-(--border-subtle) bg-(--surface) px-3 py-1.5 font-mono text-[10px] text-(--muted)`,children:[(0,h.jsx)(`span`,{children:`User`}),(0,h.jsx)(`span`,{children:`Created`}),(0,h.jsx)(`span`,{children:`Disabled`}),(0,h.jsx)(`span`,{children:`Until`}),(0,h.jsx)(`span`,{children:`Status`})]}),i.map(e=>{let t=a?.id===e.id;return(0,h.jsxs)(`button`,{"aria-pressed":t,className:[`grid min-h-11 w-full min-w-240 grid-cols-[minmax(220px,1fr)_170px_170px_170px_88px] items-center gap-0 border-b border-(--border-subtle) px-3 py-2 text-left font-mono text-[11px] transition`,t?`native-selection`:`hover:bg-(--bg-row-hover)`].join(` `),onClick:()=>r(e.id),type:`button`,children:[(0,h.jsx)(`span`,{className:`truncate text-(--foreground)`,children:e.id}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.createdAt}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.disabledAt}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.disabledUntil}),(0,h.jsx)(w,{status:e.status})]},e.id)})]}),_=({error:e,isError:t,isPending:n,onSelect:r,rows:i,selectedSession:a})=>t?(0,h.jsx)(C,{tone:`error`,value:String(e?.message)}):n?(0,h.jsx)(C,{value:`Loading auth sessions`}):i.length===0?(0,h.jsx)(C,{value:`No auth sessions found`}):(0,h.jsxs)(`div`,{className:`min-h-0 overflow-auto`,children:[(0,h.jsxs)(`div`,{className:`grid min-w-230 grid-cols-[minmax(220px,1fr)_minmax(180px,0.8fr)_170px_170px_92px] border-b border-(--border-subtle) bg-(--surface) px-3 py-1.5 font-mono text-[10px] text-(--muted)`,children:[(0,h.jsx)(`span`,{children:`Session`}),(0,h.jsx)(`span`,{children:`User`}),(0,h.jsx)(`span`,{children:`Created`}),(0,h.jsx)(`span`,{children:`Expires`}),(0,h.jsx)(`span`,{children:`Status`})]}),i.map(e=>{let t=a?.id===e.id;return(0,h.jsxs)(`button`,{"aria-pressed":t,className:[`grid min-h-11 w-full min-w-230 grid-cols-[minmax(220px,1fr)_minmax(180px,0.8fr)_170px_170px_92px] items-center gap-0 border-b border-(--border-subtle) px-3 py-2 text-left font-mono text-[11px] transition`,t?`native-selection`:`hover:bg-(--bg-row-hover)`].join(` `),onClick:()=>r(e.id),type:`button`,children:[(0,h.jsx)(`span`,{className:`truncate text-(--foreground)`,children:e.id}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.userId}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.createdAt}),(0,h.jsx)(`span`,{className:`truncate text-(--muted)`,children:e.expiresAt}),(0,h.jsx)(w,{status:e.status})]},e.id)})]}),v=()=>{let e=a.adminData.useRecords({entityName:`users`,moduleName:`auth`}),t=a.adminData.useInvokeAction(),[n,r]=(0,s.useState)(null),i=l(e.data?.data??[]),o=u(e.data?.data??[]),c=i.find(e=>e.id===n)??i[0]??null;return(0,h.jsxs)(`main`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden bg-(--background) text-(--foreground)`,children:[(0,h.jsx)(`header`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2`,children:(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(`h1`,{className:`font-mono text-[13px] font-semibold`,children:`Users`}),(0,h.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-(--muted)`,children:[i.length,` records`]})]})}),(0,h.jsx)(`div`,{className:`grid border-b border-(--border-subtle) bg-(--surface) md:grid-cols-3`,children:[[`total`,o.total],[`active`,o.active],[`disabled`,o.disabled]].map(([e,t])=>(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] border-r border-(--border-subtle) px-3 py-2 font-mono text-[10px] last:border-r-0`,children:[(0,h.jsx)(`span`,{className:`text-(--muted)`,children:e}),(0,h.jsx)(`span`,{className:`text-[13px] font-semibold text-(--foreground)`,children:t})]},e))}),(0,h.jsxs)(`div`,{className:`grid min-h-0 min-w-0 grid-cols-[minmax(0,1fr)_clamp(280px,28vw,380px)] overflow-hidden`,children:[(0,h.jsxs)(`section`,{className:`grid min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden border-r border-(--border-subtle)`,children:[(0,h.jsx)(x,{meta:`${i.length} records`,title:`Users`}),(0,h.jsx)(g,{error:e.error,isError:e.isError,isPending:e.isPending,onSelect:r,rows:i,selectedUser:c})]}),(0,h.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-(--sidebar)`,children:[(0,h.jsx)(x,{meta:c?c.status:`no selection`,title:c?.id??`User`}),c?(0,h.jsxs)(`div`,{className:`min-h-0 overflow-auto`,children:[(0,h.jsx)(S,{label:`created`,value:c.createdAt}),(0,h.jsx)(S,{label:`disabled`,value:c.disabledAt}),(0,h.jsx)(S,{label:`reason`,value:c.disabledReason}),(0,h.jsx)(S,{label:`until`,value:c.disabledUntil}),(0,h.jsx)(S,{label:`status`,value:c.status}),(0,h.jsxs)(`div`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2`,children:[c.status===`active`?(0,h.jsxs)(`form`,{className:`grid gap-2`,onSubmit:e=>{if(e.preventDefault(),!c)return;let n=new FormData(e.currentTarget),r=String(n.get(`reason`)??``).trim(),i=String(n.get(`disabled_until`)??``).trim(),a={user_id:c.id};r.length>0&&(a.reason=r),i.length>0&&(a.disabled_until=new Date(i).toISOString()),t.mutate({actionName:`disable_user`,input:a,moduleName:`auth`})},children:[(0,h.jsxs)(`label`,{className:`grid gap-1 font-mono text-[10px] text-(--muted)`,children:[`Reason`,(0,h.jsx)(`input`,{"aria-label":`Disable reason`,className:`h-7 border border-(--border-subtle) bg-(--bg-control) px-2 text-[11px] text-(--foreground)`,name:`reason`,type:`text`})]}),(0,h.jsxs)(`label`,{className:`grid gap-1 font-mono text-[10px] text-(--muted)`,children:[`Until`,(0,h.jsx)(`input`,{"aria-label":`Disable until`,className:`h-7 border border-(--border-subtle) bg-(--bg-control) px-2 text-[11px] text-(--foreground)`,name:`disabled_until`,type:`datetime-local`})]}),(0,h.jsx)(`button`,{className:`h-7 justify-self-start border border-[var(--tone-error-border)] bg-[var(--tone-error-bg)] px-2 font-mono text-[11px] font-semibold text-(--tone-error-fg) disabled:opacity-45`,disabled:t.isPending,type:`submit`,children:t.isPending?`Disabling`:`Disable`})]},c.id):(0,h.jsx)(`button`,{className:`h-7 border border-[var(--tone-success-border)] bg-[var(--tone-success-bg)] px-2 font-mono text-[11px] font-semibold text-(--tone-success-fg) disabled:opacity-45`,disabled:t.isPending,onClick:()=>t.mutate({actionName:`enable_user`,input:{user_id:c.id},moduleName:`auth`}),type:`button`,children:t.isPending?`Enabling`:`Enable`}),t.isError?(0,h.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-(--error)`,children:String(t.error.message)}):null]})]}):(0,h.jsx)(C,{value:`Select a user`})]})]})]})},y=()=>{let e=a.adminData.useRecords({entityName:`sessions`,moduleName:`auth`}),t=a.adminData.useInvokeAction(),[n,r]=(0,s.useState)(null),i=f(e.data?.data??[]),o=p(e.data?.data??[]),c=i.find(e=>e.id===n)??i[0]??null;return(0,h.jsxs)(`main`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden bg-(--background) text-(--foreground)`,children:[(0,h.jsx)(`header`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2`,children:(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,h.jsx)(`h1`,{className:`font-mono text-[13px] font-semibold`,children:`Sessions`}),(0,h.jsxs)(`span`,{className:`ml-auto font-mono text-[10px] text-(--muted)`,children:[i.length,` records`]})]})}),(0,h.jsx)(`div`,{className:`grid border-b border-(--border-subtle) bg-(--surface) md:grid-cols-4`,children:[[`total`,o.total],[`active`,o.active],[`expired`,o.expired],[`revoked`,o.revoked]].map(([e,t])=>(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] border-r border-(--border-subtle) px-3 py-2 font-mono text-[10px] last:border-r-0`,children:[(0,h.jsx)(`span`,{className:`text-(--muted)`,children:e}),(0,h.jsx)(`span`,{className:`text-[13px] font-semibold text-(--foreground)`,children:t})]},e))}),(0,h.jsxs)(`div`,{className:`grid min-h-0 min-w-0 grid-cols-[minmax(0,1fr)_clamp(280px,28vw,380px)] overflow-hidden`,children:[(0,h.jsxs)(`section`,{className:`grid min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden border-r border-(--border-subtle)`,children:[(0,h.jsx)(x,{meta:`${i.length} records`,title:`Sessions`}),(0,h.jsx)(_,{error:e.error,isError:e.isError,isPending:e.isPending,onSelect:r,rows:i,selectedSession:c})]}),(0,h.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-(--sidebar)`,children:[(0,h.jsx)(x,{meta:c?c.status:`no selection`,title:c?.id??`Session`}),c?(0,h.jsxs)(`div`,{className:`min-h-0 overflow-auto`,children:[(0,h.jsx)(S,{label:`user`,value:c.userId}),(0,h.jsx)(S,{label:`created`,value:c.createdAt}),(0,h.jsx)(S,{label:`expires`,value:c.expiresAt}),(0,h.jsx)(S,{label:`revoked`,value:c.revokedAt}),(0,h.jsx)(S,{label:`status`,value:c.status}),c.status===`active`?(0,h.jsxs)(`div`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2`,children:[(0,h.jsx)(`button`,{className:`h-7 border border-[var(--tone-error-border)] bg-[var(--tone-error-bg)] px-2 font-mono text-[11px] font-semibold text-(--tone-error-fg) disabled:opacity-45`,disabled:t.isPending,onClick:()=>t.mutate({actionName:`revoke_session`,input:{session_id:c.id},moduleName:`auth`}),type:`button`,children:t.isPending?`Revoking`:`Revoke`}),t.isError?(0,h.jsx)(`div`,{className:`mt-1 truncate font-mono text-[10px] text-(--error)`,children:String(t.error.message)}):null]}):null]}):(0,h.jsx)(C,{value:`Select a session`})]})]})]})},b=v;function x({meta:e,title:t}){return(0,h.jsxs)(`header`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2`,children:[(0,h.jsx)(`h2`,{className:`font-mono text-[12px] font-semibold text-(--foreground)`,children:t}),(0,h.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-(--muted)`,children:e})]})}function S({label:e,value:t}){return(0,h.jsxs)(`div`,{className:`border-b border-(--border-subtle) bg-(--surface) px-3 py-2 font-mono`,children:[(0,h.jsx)(`div`,{className:`text-[10px] text-(--muted)`,children:e}),(0,h.jsx)(`div`,{className:`mt-1 truncate text-[12px] font-semibold text-(--foreground)`,children:t})]})}function C({tone:e=`muted`,value:t}){return(0,h.jsx)(`div`,{className:[`p-3 font-mono text-[11px]`,e===`error`?`text-(--error)`:`text-(--muted)`].join(` `),children:t})}function w({status:e}){return(0,h.jsx)(`span`,{className:[`inline-flex h-5 items-center justify-center border px-1.5 font-mono text-[10px] font-semibold`,T(e)].join(` `),children:e})}function T(e){return e===`active`?`border-[var(--tone-success-border)] bg-[var(--tone-success-bg)] text-(--tone-success-fg)`:e===`expired`?`border-(--border-subtle) bg-(--bg-control) text-(--muted)`:`border-[var(--tone-error-border)] bg-[var(--tone-error-bg)] text-(--tone-error-fg)`}var E=o.surfaces.find(e=>e.surfaceName===`auth`),D=o.surfaces.find(e=>e.surfaceName===`sessions`),O=o.surfaces.find(e=>e.surfaceName===`users`),k=r({id:o.id,surfaces:[{area:E.area,component:y,icon:E.icon,label:E.label,navigation:E.navigation,path:E.route},{area:D.area,component:y,icon:D.icon,label:D.label,navigation:D.navigation,path:D.route},{area:O.area,component:b,icon:O.icon,label:O.label,navigation:O.navigation,path:O.route}]});export{y as AuthSessionsPage,b as AuthUsersPage,o as authConsoleManifest,k as authConsoleModule};