@objectstack/console 7.3.0 → 7.4.1

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 (61) hide show
  1. package/dist/assets/{AiPendingActionsPage-BbZbWYZF.js → AiPendingActionsPage-KMQsypXx.js} +1 -1
  2. package/dist/assets/{ApiConsolePage-CxtzVvxL.js → ApiConsolePage-Bt2GOTU0.js} +1 -1
  3. package/dist/assets/{AppManagementPage-CFfnxT1t.js → AppManagementPage-D11kr33p.js} +1 -1
  4. package/dist/assets/ApprovalsInboxPage-B2HaWzLT.js +1 -0
  5. package/dist/assets/{AuditLogPage-D4FqYkQH.js → AuditLogPage-BgZmEpPe.js} +1 -1
  6. package/dist/assets/{ComponentNavView-XiNMCGMg.js → ComponentNavView-q7X3o6Ba.js} +1 -1
  7. package/dist/assets/{ConsoleFloatingChatbot-DQEWG5vB.js → ConsoleFloatingChatbot-CX7Hyegq.js} +1 -1
  8. package/dist/assets/{DeveloperHubPage-lZkmDwEj.js → DeveloperHubPage-I50zoR-V.js} +1 -1
  9. package/dist/assets/FlowRunsPage-BZfhrn_O.js +1 -0
  10. package/dist/assets/{ProfilePage-BGOg1gVa.js → ProfilePage-WwvIlqOB.js} +1 -1
  11. package/dist/assets/PublicFormsPage-CFzAVfSh.js +1 -0
  12. package/dist/assets/{RecentItemsProvider-Dt0K6V1V.js → RecentItemsProvider-VqVTd5Ra.js} +1 -1
  13. package/dist/assets/{SettingsHub-D_bBB6HI.js → SettingsHub-B2khbTUV.js} +1 -1
  14. package/dist/assets/{SettingsView-CErPIsVb.js → SettingsView-RvPByUC5.js} +1 -1
  15. package/dist/assets/{SystemHubPage-B3lD5VE8.js → SystemHubPage-DRfqpp32.js} +1 -1
  16. package/dist/assets/{data-adapter-DD2mxtaH.js → data-adapter-BI1S6gix.js} +1 -1
  17. package/dist/assets/framework-Bsl5NTfe.js +34 -0
  18. package/dist/assets/{highlighted-body-OFNGDK62-_uUbA42F.js → highlighted-body-OFNGDK62-DT9uQOp0.js} +1 -1
  19. package/dist/assets/index-7sxElnrz.js +33 -0
  20. package/dist/assets/index-ljRQeZRW.css +2 -0
  21. package/dist/assets/{infrastructure-IQKE4Vv8.js → infrastructure-CFhpdDcd.js} +1 -1
  22. package/dist/assets/mermaid-GHXKKRXX-TfKfgNtY.js +1 -0
  23. package/dist/assets/{plugin-calendar-CBSUjCse.js → plugin-calendar-DYekpDbN.js} +1 -1
  24. package/dist/assets/plugin-charts-BpgCzDOC.js +7 -0
  25. package/dist/assets/plugin-chatbot-5ZYTjB3v.js +120 -0
  26. package/dist/assets/plugin-dashboard-B9i14gqH.js +3 -0
  27. package/dist/assets/plugin-form-DLpJWJgX.js +1 -0
  28. package/dist/assets/{plugin-gantt-BM_qU02_.js → plugin-gantt-DE_BIKaH.js} +1 -1
  29. package/dist/assets/plugin-grid-BwTh0lXV.js +6 -0
  30. package/dist/assets/plugin-kanban-D6PgB3bB.js +1 -0
  31. package/dist/assets/{plugin-map-D5wjaTuu.js → plugin-map-DVKSXWRF.js} +1 -1
  32. package/dist/assets/{plugin-markdown-BS1-ubYs.js → plugin-markdown-QUM2IO7x.js} +1 -1
  33. package/dist/assets/plugin-report-CFMPQgzx.js +59 -0
  34. package/dist/assets/{plugin-timeline-DHjoax2v.js → plugin-timeline-r_gNDvzq.js} +1 -1
  35. package/dist/assets/plugin-view-DMDKwmGd.js +1 -0
  36. package/dist/assets/plugins-views-Bg7xbB79.js +4 -0
  37. package/dist/assets/{src-DftmwA5L.js → src-fYuCcOkZ.js} +1 -1
  38. package/dist/assets/{types-X_Rma6be.js → types-BDFLkf-0.js} +1 -1
  39. package/dist/assets/ui-components-De4OOQs-.js +41 -0
  40. package/dist/assets/{ui-layout-Ciu790M0.js → ui-layout-B-tX4Ipa.js} +1 -1
  41. package/dist/assets/vendor-objectstack-D6pAOWWu.js +65 -0
  42. package/dist/index.html +4 -4
  43. package/package.json +1 -1
  44. package/dist/assets/ApprovalsInboxPage-BxQZcCfd.js +0 -1
  45. package/dist/assets/FlowRunsPage-RrJ1_Gcu.js +0 -1
  46. package/dist/assets/PublicFormsPage-IlBXTnnv.js +0 -1
  47. package/dist/assets/framework-DmN5Xd7Z.js +0 -34
  48. package/dist/assets/index-3n4YIBCx.js +0 -33
  49. package/dist/assets/index-DRnsSCuD.css +0 -2
  50. package/dist/assets/mermaid-GHXKKRXX-B0LJSQUI.js +0 -1
  51. package/dist/assets/plugin-charts-C1pPCTiC.js +0 -7
  52. package/dist/assets/plugin-chatbot-BHoielbC.js +0 -120
  53. package/dist/assets/plugin-dashboard-CrU-RT7P.js +0 -3
  54. package/dist/assets/plugin-form-YkI84B6S.js +0 -1
  55. package/dist/assets/plugin-grid-C__XZwVh.js +0 -6
  56. package/dist/assets/plugin-kanban-DpM0Y5w1.js +0 -1
  57. package/dist/assets/plugin-report-ClF2T8j-.js +0 -59
  58. package/dist/assets/plugin-view-DPiRuVYV.js +0 -1
  59. package/dist/assets/plugins-views-DKbDkBwY.js +0 -4
  60. package/dist/assets/ui-components-ClOuWOoQ.js +0 -41
  61. package/dist/assets/vendor-objectstack-B5adaLmw.js +0 -65
package/dist/index.html CHANGED
@@ -18,12 +18,12 @@
18
18
  <script>
19
19
  window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
20
20
  </script>
21
- <script type="module" crossorigin src="./assets/index-3n4YIBCx.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-7sxElnrz.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
23
23
  <link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
24
- <link rel="stylesheet" crossorigin href="./assets/index-DRnsSCuD.css">
25
- <link rel="modulepreload" href="./assets/framework-DmN5Xd7Z.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-ClOuWOoQ.js" />
24
+ <link rel="stylesheet" crossorigin href="./assets/index-ljRQeZRW.css">
25
+ <link rel="modulepreload" href="./assets/framework-Bsl5NTfe.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-De4OOQs-.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-thTS_QfF.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-CyVA1SE-.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "7.3.0",
3
+ "version": "7.4.1",
4
4
  "description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{r as t,y as n}from"./vendor-react-CyVA1SE-.js";import{f as r}from"./infrastructure-IQKE4Vv8.js";import{$ as i,Ai as a,At as o,Bt as s,F as ee,Ft as te,Gn as ne,Ht as c,I as re,It as ie,Kn as ae,Lt as l,Mr as oe,Mt as se,Nt as ce,Po as le,Pt as ue,Q as de,Qn as u,Qo as fe,Rt as pe,Uo as me,Vt as he,Xo as ge,ar as _e,at as d,cr as ve,ct as ye,dr as be,en as xe,et as Se,fr as Ce,ii as we,in as Te,it as Ee,lr as De,mr as f,nr as Oe,nt as p,or as ke,ot as m,pr as Ae,qn as je,rr as Me,rt as Ne,sr as h,st as Pe,tt as Fe,ur as g,vi as Ie,xr as Le,z as Re,zo as ze,zt as _}from"./ui-components-ClOuWOoQ.js";import{o as v}from"./vendor-ui-utils-BbOuugky.js";var y=e(n(),1),b=`${``.replace(/\/$/,``)}/api/v1`;async function x(e,t){let n=await fetch(`${b}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var S={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return x(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId),e.approverId&&t.set(`approverId`,e.approverId),e.submitterId&&t.set(`submitterId`,e.submitterId);let n=t.toString();return x(`/approvals/requests${n?`?${n}`:``}`)},async getRequest(e){return{data:await x(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return x(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){let n=await x(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async submit(e){return x(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function Be(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);for(let n of e.roles||[])n&&t.add(`role:${n}`);return Array.from(t)}var C=t(),w={pending:{variant:`secondary`,label:`Pending`},approved:{variant:`default`,label:`Approved`},rejected:{variant:`destructive`,label:`Rejected`},recalled:{variant:`outline`,label:`Recalled`}};function T({status:e}){let t=w[e]??{variant:`outline`,label:e};return(0,C.jsx)(u,{variant:t.variant,children:t.label})}function E(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function D(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Date.now()-t,r=Math.round(n/1e3);if(r<45)return`just now`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);if(a<24)return`${a}h ago`;let o=Math.round(a/24);if(o<30)return`${o}d ago`;try{return new Date(e).toLocaleDateString()}catch{return e}}function O(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function k(){let{user:e}=r(),t=(0,y.useMemo)(()=>Be(e),[e]),[n,b]=(0,y.useState)(`pending`),[x,w]=(0,y.useState)([]),[k,A]=(0,y.useState)(!1),[j,Ve]=(0,y.useState)(null),[He,Ue]=(0,y.useState)(null),[M,N]=(0,y.useState)(null),[We,P]=(0,y.useState)([]),[Ge,Ke]=(0,y.useState)(!1),[F,I]=(0,y.useState)(``),[L,R]=(0,y.useState)(``),[z,qe]=(0,y.useState)(null),[B,Je]=(0,y.useState)(``),[V,Ye]=(0,y.useState)(`all`),[H,Xe]=(0,y.useState)(`all`),[U,W]=(0,y.useState)(new Set),[G,Ze]=(0,y.useState)(!1),K=(0,y.useCallback)(async()=>{A(!0),Ve(null);try{let r=[];if(n===`pending`){let e=new Set;if(t.length===0){let e=await S.listRequests({status:`pending`});for(let t of e.data)r.push(t)}else for(let n of t){let t=await S.listRequests({status:`pending`,approverId:n});for(let n of t.data)e.has(n.id)||(e.add(n.id),r.push(n))}}else if(n===`submitted`){let t=e?.id;if(!t){w([]),A(!1);return}let n=await S.listRequests({submitterId:t});r.push(...n.data)}else{let e=await S.listRequests({});r.push(...e.data)}r.sort((e,t)=>(t.submitted_at||``).localeCompare(e.submitted_at||``)),w(r)}catch(e){Ve(e?.message||String(e)),w([])}finally{A(!1)}},[n,t,e?.id]);(0,y.useEffect)(()=>{K()},[K]);let Qe=(0,y.useCallback)(async e=>{Ue(e),Ke(!0),I(``),R(``);try{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);N(t.data),P(n.data)}catch(e){v.error(e?.message||`Failed to load request`),N(null),P([])}finally{Ke(!1)}},[]),$e=()=>{Ue(null),N(null),P([]),I(``),R(``)},q=(0,y.useCallback)(n=>{if(L.trim())return L.trim();if(!n)return e?.id||``;let r=new Set(n.pending_approvers||[]);for(let e of t)if(r.has(e))return e;return e?.id||``},[L,t,e?.id]),J=(0,y.useCallback)(async e=>{if(!M)return;let t=q(M);if(!t){v.error(`Cannot determine actor id`);return}qe(e);try{let n={actor_id:t,comment:F.trim()||void 0},r=await(e===`approve`?S.approve:e===`reject`?S.reject:S.recall)(M.id,n);v.success(e===`approve`?r.finalized?`Approved (finalized)`:`Approved — advanced to next step`:e===`reject`?r.finalized?`Rejected`:`Rejected — returned to previous step`:`Recalled`),I(``);let[i,a]=await Promise.all([S.getRequest(M.id),S.listActions(M.id)]);N(i.data),P(a.data),K()}catch(t){v.error(t?.message||`Failed to ${e}`)}finally{qe(null)}},[M,q,F,K]),Y=(0,y.useMemo)(()=>{if(!M||M.status!==`pending`)return!1;let e=new Set(M.pending_approvers||[]);return t.some(t=>e.has(t))||L.trim().length>0},[M,t,L]),et=(0,y.useMemo)(()=>!M||M.status!==`pending`?!1:M.submitter_id===e?.id||L.trim().length>0,[M,e?.id,L]),tt=(0,y.useMemo)(()=>x.filter(e=>e.status===`pending`).length,[x]),nt=(0,y.useMemo)(()=>{let e=new Set;for(let t of x)t.process_name&&e.add(t.process_name);return Array.from(e).sort()},[x]),rt=(0,y.useMemo)(()=>{let e=new Set;for(let t of x)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[x]),X=(0,y.useMemo)(()=>{let e=B.trim().toLowerCase();return x.filter(t=>V!==`all`&&t.process_name!==V||H!==`all`&&t.object_name!==H?!1:e?[t.process_name,t.object_name,t.record_id,t.submitter_id,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e):!0)},[x,B,V,H]);(0,y.useEffect)(()=>{if(U.size===0)return;let e=new Set(X.map(e=>e.id)),t=!1,n=new Set;for(let r of U)e.has(r)?n.add(r):t=!0;t&&W(n)},[X,U]);let Z=(0,y.useMemo)(()=>{let e=new Set(t);return X.filter(t=>U.has(t.id)&&t.status===`pending`&&(t.pending_approvers||[]).some(t=>e.has(t)))},[X,U,t]),Q=X.filter(e=>e.status===`pending`),$=Q.length>0&&Q.every(e=>U.has(e.id)),it=(0,y.useCallback)(()=>{W(e=>{if($)return new Set;let t=new Set(e);for(let e of Q)t.add(e.id);return t})},[$,Q]),at=(0,y.useCallback)(e=>{W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ot=(0,y.useCallback)(async n=>{let r=Z;if(r.length===0)return;Ze(!0);let i=0,a=0;for(let o of r){let r=new Set(o.pending_approvers||[]),s=t.find(e=>r.has(e))||e?.id||``;try{await(n===`approve`?S.approve:S.reject)(o.id,{actor_id:s}),i++}catch{a++}}Ze(!1),W(new Set),a===0?v.success(`${n===`approve`?`Approved`:`Rejected`} ${i} request${i===1?``:`s`}`):v.error(`${i} succeeded, ${a} failed`),K()},[Z,t,e?.id,K]);return(0,C.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,C.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,C.jsx)(we,{className:`h-6 w-6`}),`Approvals Inbox`]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Review and act on multi-step approval requests.`})]}),(0,C.jsxs)(f,{variant:`outline`,size:`sm`,onClick:K,disabled:k,children:[(0,C.jsx)(a,{className:`h-4 w-4 mr-2 ${k?`animate-spin`:``}`}),`Refresh`]})]}),j&&(0,C.jsxs)(Oe,{variant:`destructive`,children:[(0,C.jsx)(fe,{className:`h-4 w-4`}),(0,C.jsx)(Me,{children:j})]}),(0,C.jsxs)(i,{value:n,onValueChange:e=>b(e),children:[(0,C.jsxs)(Fe,{children:[(0,C.jsxs)(p,{value:`pending`,children:[`My Pending`,tt>0&&(0,C.jsx)(u,{variant:`secondary`,className:`ml-2`,children:tt})]}),(0,C.jsx)(p,{value:`submitted`,children:`Submitted by me`}),(0,C.jsx)(p,{value:`all`,children:`All`})]}),(0,C.jsxs)(Se,{value:n,className:`mt-4 space-y-3`,children:[!k&&x.length>0&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,C.jsx)(Ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,C.jsx)(xe,{value:B,onChange:e=>Je(e.target.value),placeholder:`Search process, record, approver…`,className:`pl-8 h-8 text-sm`}),B&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>Je(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear search`,children:(0,C.jsx)(Le,{className:`h-3.5 w-3.5`})})]}),nt.length>1&&(0,C.jsxs)(pe,{value:V,onValueChange:Ye,children:[(0,C.jsx)(he,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(c,{placeholder:`Process`})}),(0,C.jsxs)(_,{children:[(0,C.jsx)(s,{value:`all`,children:`All processes`}),nt.map(e=>(0,C.jsx)(s,{value:e,children:e},e))]})]}),rt.length>1&&(0,C.jsxs)(pe,{value:H,onValueChange:Xe,children:[(0,C.jsx)(he,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(c,{placeholder:`Object`})}),(0,C.jsxs)(_,{children:[(0,C.jsx)(s,{value:`all`,children:`All objects`}),rt.map(e=>(0,C.jsx)(s,{value:e,children:e},e))]})]}),(B||V!==`all`||H!==`all`)&&(0,C.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[X.length,` of `,x.length]})]}),n===`pending`&&U.size>0&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`strong`,{children:U.size}),` selected`,Z.length!==U.size&&(0,C.jsxs)(`span`,{className:`text-muted-foreground ml-1`,children:[`(`,Z.length,` actionable)`]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsxs)(f,{size:`sm`,onClick:()=>ot(`approve`),disabled:G||Z.length===0,children:[(0,C.jsx)(ge,{className:`h-3.5 w-3.5 mr-1`}),`Approve `,Z.length||``]}),(0,C.jsxs)(_e,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsxs)(f,{size:`sm`,variant:`outline`,disabled:G||Z.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(me,{className:`h-3.5 w-3.5 mr-1`}),`Reject `,Z.length||``]})}),(0,C.jsxs)(ve,{children:[(0,C.jsxs)(be,{children:[(0,C.jsxs)(Ce,{children:[`Reject `,Z.length,` requests?`]}),(0,C.jsx)(De,{children:`This will reject the selected requests and notify their submitters.`})]}),(0,C.jsxs)(g,{children:[(0,C.jsx)(h,{children:`Cancel`}),(0,C.jsxs)(ke,{onClick:()=>ot(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:[`Reject `,Z.length]})]})]})]}),(0,C.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>W(new Set),disabled:G,children:`Clear`})]})]}),k?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(o,{className:`h-10 w-full`}),(0,C.jsx)(o,{className:`h-10 w-full`}),(0,C.jsx)(o,{className:`h-10 w-full`})]}):x.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,C.jsxs)(ee,{children:[(0,C.jsx)(Re,{children:`No requests`}),(0,C.jsx)(re,{children:n===`pending`?`You have no pending approvals.`:`Nothing here yet.`})]})}):X.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:`No matches for current filters.`}):(0,C.jsx)(ae,{children:(0,C.jsx)(je,{className:`p-0`,children:(0,C.jsxs)(Ne,{children:[(0,C.jsx)(Pe,{children:(0,C.jsxs)(ye,{children:[n===`pending`&&(0,C.jsx)(m,{className:`w-10`,children:(0,C.jsx)(ne,{checked:$,onCheckedChange:it,"aria-label":`Select all`,disabled:Q.length===0})}),(0,C.jsx)(m,{children:`Process`}),(0,C.jsx)(m,{children:`Object`}),(0,C.jsx)(m,{children:`Record`}),(0,C.jsx)(m,{children:`Step`}),(0,C.jsx)(m,{children:`Status`}),(0,C.jsx)(m,{children:`Approvers`}),(0,C.jsx)(m,{children:`Submitted`})]})}),(0,C.jsx)(Ee,{children:X.map(e=>(0,C.jsxs)(ye,{className:`cursor-pointer hover:bg-accent/50`,onClick:()=>Qe(e.id),children:[n===`pending`&&(0,C.jsx)(d,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,C.jsx)(ne,{checked:U.has(e.id),onCheckedChange:()=>at(e.id),disabled:e.status!==`pending`,"aria-label":`Select request ${e.id}`})}),(0,C.jsx)(d,{className:`font-medium`,children:e.process_name}),(0,C.jsx)(d,{children:e.object_name}),(0,C.jsx)(d,{className:`font-mono text-xs`,title:e.record_id,children:O(e.record_id)}),(0,C.jsx)(d,{children:e.current_step?(0,C.jsxs)(`span`,{className:`text-xs`,children:[e.current_step,typeof e.current_step_index==`number`&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (#`,e.current_step_index,`)`]})]}):`—`}),(0,C.jsx)(d,{children:(0,C.jsx)(T,{status:e.status})}),(0,C.jsx)(d,{className:`max-w-[220px] truncate text-xs text-muted-foreground`,title:(e.pending_approvers||[]).join(`, `),children:(e.pending_approvers||[]).map(O).join(`, `)||`—`}),(0,C.jsxs)(d,{className:`text-xs whitespace-nowrap text-muted-foreground`,title:E(e.submitted_at),children:[(0,C.jsx)(ze,{className:`h-3 w-3 inline mr-1`}),D(e.submitted_at)]})]},e.id))})]})})})]})]}),(0,C.jsx)(se,{open:!!He,onOpenChange:e=>!e&&$e(),children:(0,C.jsxs)(ce,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,C.jsxs)(te,{children:[(0,C.jsx)(ie,{children:`Approval Request`}),(0,C.jsx)(ue,{children:M?`${M.process_name} · ${M.object_name}/${M.record_id}`:``})]}),Ge?(0,C.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,C.jsx)(o,{className:`h-6 w-3/4`}),(0,C.jsx)(o,{className:`h-6 w-1/2`}),(0,C.jsx)(o,{className:`h-20 w-full`})]}):M?(0,C.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Status`}),(0,C.jsx)(T,{status:M.status})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Current Step`}),M.current_step||`—`]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Step Index`}),M.current_step_index??`—`]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Submitter`}),(0,C.jsx)(`span`,{className:`font-mono text-xs`,title:M.submitter_id||``,children:O(M.submitter_id)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Submitted`}),E(M.submitted_at)]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Completed`}),E(M.completed_at)]}),(0,C.jsxs)(`div`,{className:`col-span-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Pending Approvers`}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:(M.pending_approvers||[]).length===0?`—`:(M.pending_approvers||[]).map((e,t)=>(0,C.jsx)(u,{variant:`outline`,className:`font-mono text-[10px]`,title:e,children:O(e)},t))})]}),M.payload&&(0,C.jsxs)(`div`,{className:`col-span-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:`Payload`}),(0,C.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(M.payload,null,2)),v.success(`Payload copied`)}catch{v.error(`Copy failed`)}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,C.jsx)(le,{className:`h-3 w-3`}),`Copy`]})]}),(0,C.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-32 mt-1`,children:JSON.stringify(M.payload,null,2)})]})]}),(0,C.jsx)(l,{}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:`Action History`}),We.length===0?(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No actions yet.`}):(0,C.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:We.map(e=>(0,C.jsxs)(`li`,{className:`relative text-xs`,children:[(0,C.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:(e.action,`bg-muted-foreground`)}`,"aria-hidden":!0}),(0,C.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,C.jsx)(`span`,{className:`font-medium capitalize`,children:e.action}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`by`}),(0,C.jsx)(`span`,{className:`font-mono`,title:e.actor_id||``,children:O(e.actor_id)}),e.step_name&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.step_name,` (#`,e.step_index,`)`]}),(0,C.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:E(e.created_at),children:D(e.created_at)})]}),e.comment&&(0,C.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id))})]}),M.status===`pending`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(l,{}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsxs)(`details`,{className:`group`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:`Override actor (advanced)`}),(0,C.jsxs)(`div`,{className:`mt-2`,children:[(0,C.jsx)(Te,{htmlFor:`actor-override`,className:`text-xs`,children:`Actor`}),(0,C.jsx)(`input`,{id:`actor-override`,type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:`Auto: ${q(M)||`(none)`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,C.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:[`e.g. `,(0,C.jsx)(`code`,{children:`role:sales_manager`}),`. Leave blank to use auto-detected.`]})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Te,{htmlFor:`comment`,className:`text-xs`,children:`Comment (optional)`}),(0,C.jsx)(de,{id:`comment`,value:F,onChange:e=>I(e.target.value),rows:2,className:`mt-1`})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,C.jsxs)(f,{size:`sm`,onClick:()=>J(`approve`),disabled:!Y||z!==null,children:[(0,C.jsx)(ge,{className:`h-4 w-4 mr-1`}),z===`approve`?`Approving…`:`Approve`]}),(0,C.jsxs)(_e,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsxs)(f,{size:`sm`,variant:`outline`,disabled:!Y||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(me,{className:`h-4 w-4 mr-1`}),z===`reject`?`Rejecting…`:`Reject`]})}),(0,C.jsxs)(ve,{children:[(0,C.jsxs)(be,{children:[(0,C.jsx)(Ce,{children:`Reject this request?`}),(0,C.jsxs)(De,{children:[`This will mark the request as rejected and notify the submitter.`,M.current_step_index!=null&&M.current_step_index>0?` If the process is multi-step, it returns to the previous step.`:``]})]}),(0,C.jsxs)(g,{children:[(0,C.jsx)(h,{children:`Cancel`}),(0,C.jsx)(ke,{onClick:()=>J(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Reject`})]})]})]}),(0,C.jsxs)(f,{size:`sm`,variant:`outline`,onClick:()=>J(`recall`),disabled:!et||z!==null,children:[(0,C.jsx)(oe,{className:`h-4 w-4 mr-1`}),z===`recall`?`Recalling…`:`Recall`]})]}),!Y&&!et&&(0,C.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`You are not in the pending approvers list and did not submit this request. Use the override above to act as another identity (e.g. `,(0,C.jsx)(`code`,{children:`role:sales_manager`}),`).`]})]})]})]}):null]})})]})}export{k as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{r as t,y as n}from"./vendor-react-CyVA1SE-.js";import{x as r}from"./framework-DmN5Xd7Z.js";import{Ai as i,At as a,Bi as o,Cr as s,Ea as c,Ft as l,It as u,Jn as d,Kn as f,Mt as p,Nt as m,Pt as h,Q as g,Qn as _,Qo as v,Uo as y,Ut as b,Xn as x,Xo as S,Yn as C,at as w,ct as T,en as E,in as D,it as O,lt as k,mr as A,ot as j,qn as M,rt as N,st as P,zo as F}from"./ui-components-ClOuWOoQ.js";import"./index-3n4YIBCx.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:S,cls:`text-emerald-600 border-emerald-300`},completed:{icon:S,cls:`text-emerald-600 border-emerald-300`},failed:{icon:y,cls:`text-red-600 border-red-300`},error:{icon:y,cls:`text-red-600 border-red-300`},running:{icon:c,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:F,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(_,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[o,c]=(0,I.useState)(!0),[l,u]=(0,I.useState)(null),[p,m]=(0,I.useState)(``),[h,g]=(0,I.useState)(0),_=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){u(`meta.getItems is not available on this client`),c(!1);return}c(!0),u(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!p&&r.length>0&&m(r[0].name)}catch(e){u(e?.message??String(e))}finally{c(!1)}},[e,p]);(0,I.useEffect)(()=>{_()},[_]);let v=(0,I.useMemo)(()=>t.find(e=>e.name===p)??null,[t,p]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(s,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(f,{children:[(0,L.jsx)(C,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(x,{className:`text-base`,children:`Flow`}),(0,L.jsx)(d,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:_,disabled:o,children:[(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 ${o?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[o&&(0,L.jsx)(a,{className:`h-9 w-72`}),l&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:l}),!o&&!l&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!o&&!l&&t.length>0&&(0,L.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),v&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:v.spec,onExecuted:()=>g(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:v.name,refreshKey:h})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[s,l]=(0,I.useState)(!1),[u,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),p(null),h(null)},[t?.name]);let v=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(f,{children:[(0,L.jsxs)(C,{className:`pb-3`,children:[(0,L.jsx)(x,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(d,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(M,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(D,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(_,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>v(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(g,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>v(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>v(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(A,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}l(!0),h(null),p(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{l(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(u||m)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[m||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(S,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(_,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,o]=(0,I.useState)([]),[s,g]=(0,I.useState)(!0),[v,y]=(0,I.useState)(null),[S,E]=(0,I.useState)(null),[D,k]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){y(`automation.listRuns is not available on this client`),g(!1);return}g(!0),y(null);try{let n=await e.automation.listRuns(t,{limit:20});o(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){y(e?.message??String(e))}finally{g(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{E(n),k(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);k(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(f,{children:[(0,L.jsx)(C,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(x,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(d,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(A,{variant:`outline`,size:`sm`,onClick:W,disabled:s,children:[s?(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(M,{children:[s&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`}),(0,L.jsx)(a,{className:`h-8 w-full`})]}),!s&&v&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:v}),!s&&!v&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!s&&!v&&r.length>0&&(0,L.jsxs)(N,{children:[(0,L.jsx)(P,{children:(0,L.jsxs)(T,{children:[(0,L.jsx)(j,{children:`Run`}),(0,L.jsx)(j,{children:`Status`}),(0,L.jsx)(j,{children:`Started`}),(0,L.jsx)(j,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(O,{children:r.map(e=>(0,L.jsxs)(T,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(w,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(w,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(w,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(w,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!S,onOpenChange:e=>{e||(E(null),k(null))},children:(0,L.jsxs)(m,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(l,{className:`p-4 border-b`,children:[(0,L.jsxs)(u,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(h,{children:D&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:D.status}),typeof D.durationMs==`number`&&(0,L.jsxs)(_,{variant:`secondary`,className:`text-[10px] font-mono`,children:[D.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(D.startedAt)})]})})]}),(0,L.jsxs)(b,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`}),(0,L.jsx)(a,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&D&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(D.steps)&&D.steps.length>0?D.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(_,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(_,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:D})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{r as t,y as n}from"./vendor-react-CyVA1SE-.js";import{x as r}from"./framework-DmN5Xd7Z.js";import{Ai as i,Bn as a,Co as o,Fn as s,In as c,Jn as ee,Kn as te,Ln as l,Ni as u,Po as ne,Qn as re,Ri as ie,Rn as d,Ro as ae,Xn as oe,Yn as se,at as f,ct as p,en as m,gi as ce,in as h,it as le,ja as ue,mr as g,ot as _,qn as de,rt as fe,st as pe,zn as v}from"./ui-components-ClOuWOoQ.js";import{o as y}from"./vendor-ui-utils-BbOuugky.js";import"./index-3n4YIBCx.js";var b=e(n(),1),x=t();function me(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,b.useState)([]),[C,he]=(0,b.useState)([]),[w,T]=(0,b.useState)(!0),[E,D]=(0,b.useState)(null),[ge,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(!1),[_e,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(``),[B,V]=(0,b.useState)(`thank-you`),[H,U]=(0,b.useState)(``),[W,G]=(0,b.useState)(``),[K,q]=(0,b.useState)(``),[J,Y]=(0,b.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=me(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,b.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),y.success(`Copied ${e}`)}catch{y.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){y.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),y.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){y.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){y.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){y.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),y.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){y.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,x.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,x.jsxs)(te,{children:[(0,x.jsxs)(se,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(oe,{className:`flex items-center gap-2`,children:[(0,x.jsx)(u,{className:`h-4 w-4`}),`Public Forms`]}),(0,x.jsx)(ee,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(g,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,x.jsx)(ie,{className:`h-3.5 w-3.5`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,x.jsxs)(g,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,x.jsx)(i,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,x.jsxs)(de,{children:[E&&(0,x.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,x.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,x.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,x.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,x.jsxs)(fe,{children:[(0,x.jsx)(pe,{children:(0,x.jsxs)(p,{children:[(0,x.jsx)(_,{children:`Name`}),(0,x.jsx)(_,{children:`Object`}),(0,x.jsx)(_,{children:`Slug`}),(0,x.jsx)(_,{children:`Public URL`}),(0,x.jsx)(_,{className:`text-right`,children:`Actions`})]})}),(0,x.jsx)(le,{children:t.map(e=>{let t=Z(e.slug);return(0,x.jsxs)(p,{children:[(0,x.jsx)(f,{children:(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,x.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,x.jsx)(f,{children:e.object?(0,x.jsx)(re,{variant:`secondary`,children:e.object}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,x.jsx)(f,{children:(0,x.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,x.jsx)(f,{children:(0,x.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,x.jsx)(o,{className:`h-3 w-3`})]})}),(0,x.jsx)(f,{className:`text-right`,children:(0,x.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,x.jsx)(g,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,x.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(g,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,x.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(g,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,x.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(g,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,x.jsx)(ce,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,x.jsx)(s,{open:ge,onOpenChange:O,children:(0,x.jsxs)(c,{className:`sm:max-w-md`,children:[(0,x.jsxs)(v,{children:[(0,x.jsx)(a,{children:`Publish a FormView`}),(0,x.jsxs)(l,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,x.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,x.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-view`,children:`FormView`}),(0,x.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`publish-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,x.jsxs)(d,{children:[(0,x.jsx)(g,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,x.jsx)(g,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,x.jsx)(s,{open:_e,onOpenChange:F,children:(0,x.jsxs)(c,{className:`sm:max-w-lg`,children:[(0,x.jsxs)(v,{children:[(0,x.jsx)(a,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,x.jsx)(l,{children:`Configure the public URL and what happens after submit.`})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(m,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-behavior`,children:`After submit`}),(0,x.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,x.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,x.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,x.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,x.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tytitle`,children:`Title`}),(0,x.jsx)(m,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-tymsg`,children:`Message`}),(0,x.jsx)(m,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(h,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,x.jsx)(m,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,x.jsxs)(d,{children:[(0,x.jsx)(g,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,x.jsx)(g,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};