@kizenapps/cli 1.1.1 → 1.1.2-590a1f4
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/dist/viewer/assets/{CodeStepsPage-B8GxbLxI.js → CodeStepsPage-DnL8JwSJ.js} +1 -1
- package/dist/viewer/assets/{ConfigurationPage-Dxbnrr9j.js → ConfigurationPage-CAdaFi9y.js} +1 -1
- package/dist/viewer/assets/SandboxPage-CU6fvI8A.js +1 -0
- package/dist/viewer/assets/{WhenBadge-BcgTLbpu.js → WhenBadge-DZrl6k94.js} +1 -1
- package/dist/viewer/assets/{api-BcUybEsl.js → api-DtXiAEKW.js} +1 -1
- package/dist/viewer/assets/{configStorage-CJZAV_2p.js → configStorage-aLI-65re.js} +1 -1
- package/dist/viewer/assets/{index-CiXkrLfH.js → index-Cp0A29vq.js} +3 -3
- package/dist/viewer/assets/useCriticalExceptionDialog-C8PL9Dxt.js +5 -0
- package/dist/viewer/index.html +2 -2
- package/package.json +1 -1
- package/dist/viewer/assets/SandboxPage-B0MxFcYd.js +0 -1
- package/dist/viewer/assets/useCriticalExceptionDialog-DQOlM11I.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,a as n,j as r,k as i,r as a}from"./fa-core-BoBqCOD3.js";import{t as o}from"./useNavigate-BblEmQ3O.js";import{n as s,t as c}from"./bundleQuery-CjbA01rb.js";import{t as l}from"./useQuery-5OkVbV1s.js";import{i as u,o as d}from"./api-BcUybEsl.js";import{t as f}from"./Card-BpDJPrPZ.js";import{t as p}from"./CodeViewer-C9aVhzG7.js";import{t as m}from"./useLocalStorage-CyZiO78q.js";import{i as h,r as g}from"./configStorage-CJZAV_2p.js";import{t as _}from"./WhenBadge-BcgTLbpu.js";var v=e(r(),1),y=t(),b=({title:e,defaultOpen:t=!1,children:r})=>{let[o,s]=(0,v.useState)(t);return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`button`,{onClick:()=>{s(e=>!e)},className:`flex w-full items-center gap-1.5 py-1 text-[11px] font-semibold uppercase tracking-widest text-neutral-400 hover:text-neutral-600`,children:[(0,y.jsx)(i,{icon:o?a:n,className:`w-2.5`}),e]}),o&&(0,y.jsx)(`div`,{className:`pb-2`,children:r})]})},x=({result:e})=>{let t=Object.entries(e.outputValues);return(0,y.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-black/10 bg-white p-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold ${e.success?`bg-green-100 text-green-700`:`bg-red-100 text-red-700`}`,children:e.success?`Success`:`Error`}),(0,y.jsxs)(`span`,{className:`text-[11px] text-neutral-400`,children:[String(e.durationMs),`ms`]}),e.exitCode!==0&&(0,y.jsxs)(`span`,{className:`text-[11px] text-neutral-400`,children:[`exit code `,String(e.exitCode)]}),(0,y.jsx)(`button`,{onClick:e=>{let t=e.currentTarget;for(;t;){if(t.scrollHeight>t.clientHeight){t.scrollTo({top:0,behavior:`smooth`});return}t=t.parentElement}},className:`ml-auto text-[11px] text-neutral-400 hover:text-neutral-600`,children:`↑ top`})]}),e.error&&(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-red-50 p-3 font-mono text-[12px] text-red-800`,children:e.error}),t.length>0&&(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Outputs`}),(0,y.jsx)(`div`,{className:`divide-y divide-black/5`,children:t.map(([e,t])=>(0,y.jsxs)(`div`,{className:`flex items-start gap-2 py-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 font-mono text-[12px] text-neutral-600`,children:e}),(0,y.jsx)(`span`,{className:`text-[11px] text-neutral-300`,children:`=`}),(0,y.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-auto font-mono text-[12px] text-neutral-800`,children:typeof t==`string`?t:JSON.stringify(t,null,2)})]},e))})]}),e.logs.length>0&&(0,y.jsx)(b,{title:`Logs (${String(e.logs.length)})`,children:(0,y.jsx)(`div`,{className:`space-y-0.5`,children:e.logs.map((e,t)=>(0,y.jsx)(`div`,{className:`font-mono text-[12px] text-neutral-600`,children:e},t))})}),e.stdout&&(0,y.jsx)(b,{title:`Stdout`,children:(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-neutral-50 p-3 font-mono text-[12px] text-neutral-700`,children:e.stdout})}),e.stderr&&(0,y.jsx)(b,{title:`Stderr`,children:(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-neutral-50 p-3 font-mono text-[12px] text-neutral-700`,children:e.stderr})}),e.httpRequests&&e.httpRequests.count>0&&(0,y.jsx)(b,{title:`Network (${String(e.httpRequests.count)}${e.httpRequests.notLogged>0?`, ${String(e.httpRequests.notLogged)} not logged`:``})`,children:(0,y.jsx)(`div`,{className:`space-y-1.5`,children:e.httpRequests.requests.map((e,t)=>(0,y.jsx)(w,{request:e},t))})})]})},S=e=>{switch(e.toUpperCase()){case`GET`:return`bg-blue-100 text-blue-700`;case`POST`:return`bg-green-100 text-green-700`;case`PUT`:case`PATCH`:return`bg-amber-100 text-amber-700`;case`DELETE`:return`bg-red-100 text-red-700`;default:return`bg-neutral-100 text-neutral-700`}},C=(e,t)=>t||e>=500?`text-red-700`:e>=400?`text-amber-700`:e>=200?`text-green-700`:`text-neutral-600`,w=({request:e})=>{let[t,r]=(0,v.useState)(!1),o=e.requestErrorType!==null;return(0,y.jsxs)(`div`,{className:`rounded border border-black/5 bg-neutral-50`,children:[(0,y.jsxs)(`button`,{onClick:()=>{r(e=>!e)},className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left hover:bg-neutral-100`,children:[(0,y.jsx)(i,{icon:t?a:n,className:`w-2.5 text-neutral-400`}),(0,y.jsx)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold ${S(e.method)}`,children:e.method}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-neutral-700`,children:e.url}),(0,y.jsx)(`span`,{className:`font-mono text-[11px] font-semibold ${C(e.responseStatusCode,o)}`,children:o?e.requestErrorType:e.responseStatusCode}),(0,y.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[(e.duration*1e3).toFixed(0),`ms`]})]}),t&&(0,y.jsxs)(`div`,{className:`space-y-2 border-t border-black/5 p-2.5`,children:[(0,y.jsx)(T,{title:`Request Headers`,data:e.headers}),e.body&&(0,y.jsx)(E,{title:`Request Body`,body:e.body}),(0,y.jsx)(T,{title:`Response Headers`,data:e.responseHeaders}),e.responseBody&&(0,y.jsx)(E,{title:`Response Body`,body:e.responseBody})]})]})},T=({title:e,data:t})=>{let n=Object.entries(t);return n.length===0?null:(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,y.jsx)(`div`,{className:`divide-y divide-black/5 rounded border border-black/5 bg-white`,children:n.map(([e,t])=>(0,y.jsxs)(`div`,{className:`flex gap-2 px-2 py-1 font-mono text-[11px]`,children:[(0,y.jsxs)(`span`,{className:`shrink-0 text-neutral-500`,children:[e,`:`]}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 break-all text-neutral-800`,children:t})]},e))})]})},E=({title:e,body:t})=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,y.jsx)(`pre`,{className:`overflow-auto rounded border border-black/5 bg-white p-2 font-mono text-[11px] text-neutral-800`,children:t})]}),D=[`python-3-13`,`python-3-12`],O=`python-3-12`,k={text:`s`,string:`s`,number:`n`,integer:`n`,boolean:`b`,date:`d`,datetime:`dt`,phone:`p`,phonenumber:`p`,uuid:`u`,file:`f`,list:`l`};function A(e){return k[e.toLowerCase()]??`s`}function j(e){return D.includes(e)?e:O}function M(e,t){let n=Object.keys(e);if(n.length===0)return null;let r={};for(let i of n)r[i]={t:A(t[i]??`string`),v:e[i]};return r}function N(e){let t=Object.keys(e);if(t.length===0)return null;let n={};for(let r of t)n[r]=A(e[r]??`string`);return n}function P(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r.v;return t}function F(e){if(!e)return;let t=e.requests.map(e=>({method:e.method,url:e.url,headers:e.headers,body:e.body,requestSubmittedAt:e.requestSubmittedAt,session:e.session,responseStatusCode:e.responseStatusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,requestErrorType:e.requestErrorType,duration:e.duration}));return{count:e.count,notLogged:e.not_logged,requests:t}}async function I(e,t){let n=Date.now(),r={user_script:t.script,runtime:j(t.scriptRuntime),secrets:t.secretNames.length>0?t.secretNames:void 0,inputs:M(t.inputs,t.inputTypes),output_types:N(t.outputTypes)};try{let t=await e(`/coderunner/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),i=Date.now()-n;if(!t.ok){let e=await t.text();return{success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:`Remote runner returned ${String(t.status)}: ${e}`,exitCode:1,durationMs:i}}let a=await t.json(),o=a.error!==null,s=F(a.http_requests),c={success:!o,outputValues:P(a.values),logs:a.logs??[],stdout:``,stderr:``,exitCode:+!!o,durationMs:a.duration_ms??i,...s&&{httpRequests:s}};return o&&a.error&&(c.error=a.error.detail?`${a.error.error}\n${a.error.detail}`:a.error.error),c}catch(e){return{success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:`Remote execution failed: ${e instanceof Error?e.message:String(e)}`,exitCode:1,durationMs:Date.now()-n}}}var L=()=>{let{apiName:e,stepApiName:t}=s({strict:!1}),n=o(),{data:r,isLoading:i,isError:a}=l(c),b=u(),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(null),[D,O]=m(`kizen-step-inputs:${e??``}:${t??``}`,{}),[k,A]=m(`kizen-step-secrets:${e??``}:${t??``}`,{}),[j,M]=m(`kizen-code-runner-mode`,`local`),N=r?.find(t=>t.api_name===e),P=(0,v.useMemo)(()=>N?.artifacts.automation_action_configs??[],[N]),F=P.find(e=>e.action_step_api_name===t)??P[0],L=(0,v.useMemo)(()=>{if(!e||!N)return{};let t=N.base_config,n=g(e),r=h(e),i=d(n?.__kizen_clean_config??{},[],n?.__kizen_setup_assistant_values??{},t?.setup_assistant?.fields),a=d(r?.__kizen_clean_config??{},[],r?.__kizen_setup_assistant_values??{},t?.user_setup_assistant?.fields),o={};for(let[e,t]of Object.entries(i))o[`config__${e}`]=t;for(let[e,t]of Object.entries(a))o[`userConfig__${e}`]=t;return o},[e,N]);if((0,v.useEffect)(()=>{if(!t&&P.length>0&&e){let t=P[0];t&&n({to:`/$apiName/code-steps/$stepApiName`,params:{apiName:e,stepApiName:t.action_step_api_name},replace:!0})}},[t,P,e,n]),(0,v.useEffect)(()=>{T(null)},[t]),(0,v.useEffect)(()=>{w&&E.current&&E.current.scrollIntoView({behavior:`smooth`,block:`start`})},[w]),i)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(a)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});if(!N)return(0,y.jsx)(f,{children:(0,y.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,y.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});if(P.length===0)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:`This app has no automation code steps.`})});if(!F)return(0,y.jsx)(f,{children:(0,y.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`Step not found: `,(0,y.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:t}),`.`]})});let R=async()=>{C(!0),T(null);try{let t=Object.fromEntries(F.inputs.map(e=>[e.name,D[e.name]??``])),n;n=j===`remote`?await I(b,{script:F.script,scriptRuntime:F.script_runtime,inputs:t,inputTypes:Object.fromEntries(F.inputs.map(e=>[e.name,e.data_type])),outputTypes:Object.fromEntries(F.outputs.map(e=>[e.name,e.data_type])),secretNames:F.secrets.map(t=>`${e??``}__${t}`)}):await(await fetch(`/api/execute-step`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({script:F.script,scriptRuntime:F.script_runtime,inputs:t,secrets:Object.fromEntries(F.secrets.map(t=>[`${e??``}__${t}`,k[t]??``]))})})).json(),T(n)}catch(e){T({success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:e instanceof Error?e.message:String(e),exitCode:1,durationMs:0})}finally{C(!1)}};return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(f,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Code Step`}),(0,y.jsx)(`select`,{value:F.action_step_api_name,onChange:t=>{e&&n({to:`/$apiName/code-steps/$stepApiName`,params:{apiName:e,stepApiName:t.target.value}})},className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:P.map(e=>(0,y.jsx)(`option`,{value:e.action_step_api_name,children:e.name},e.action_step_api_name))}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsx)(`span`,{className:`rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600`,children:F.script_runtime})]}),F.overall_description&&(0,y.jsx)(`p`,{className:`mt-2 text-[12px] text-neutral-500`,children:F.overall_description}),F.when&&(0,y.jsx)(`div`,{className:`mt-2`,children:(0,y.jsx)(_,{when:F.when,whenState:L})})]}),(0,y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Inputs`}),F.inputs.length>0?(0,y.jsx)(`div`,{className:`space-y-3`,children:F.inputs.map(e=>(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`label`,{className:`mb-1 block text-[12px] text-neutral-700`,children:[e.label,e.required&&(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`})]}),(0,y.jsx)(`input`,{type:`text`,value:D[e.name]??``,onChange:t=>{O({...D,[e.name]:t.target.value})},placeholder:e.name,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[13px] text-neutral-800 placeholder:text-neutral-300 focus:border-blue-300 focus:outline-none`}),(0,y.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-neutral-400`,children:e.name})]},e.name))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]}),(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Outputs`}),F.outputs.length>0?(0,y.jsx)(`div`,{className:`space-y-2`,children:F.outputs.map(e=>(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2 rounded border border-black/5 bg-neutral-50 px-2.5 py-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[13px] text-neutral-700`,children:e.label}),(0,y.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:e.name}),(0,y.jsx)(`span`,{className:`ml-auto rounded bg-white px-1.5 py-0.5 font-mono text-[10px] text-neutral-500`,children:e.data_type})]},e.name))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]}),(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Secrets`}),j===`remote`&&(0,y.jsx)(`p`,{className:`mb-3 rounded border border-blue-100 bg-blue-50 px-2.5 py-1.5 text-[12px] text-blue-700`,children:`Remote runner uses secrets from your business context.`}),F.secrets.length>0?(0,y.jsx)(`div`,{className:`space-y-3`,children:F.secrets.map(e=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:`mb-1 block text-[12px] text-neutral-700`,children:e}),(0,y.jsx)(`input`,{type:`password`,value:k[e]??``,onChange:t=>{A({...k,[e]:t.target.value})},placeholder:e,disabled:j===`remote`,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[13px] text-neutral-800 placeholder:text-neutral-300 focus:border-blue-300 focus:outline-none disabled:cursor-not-allowed disabled:bg-neutral-50 disabled:text-neutral-400`})]},e))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]})]}),(0,y.jsx)(p,{code:F.script,language:`python`,onRun:()=>void R(),isRunning:S,executionMode:j,onModeChange:M}),w&&(0,y.jsx)(`div`,{ref:E,children:(0,y.jsx)(x,{result:w})})]})};export{L as CodeStepsPage};
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,a as n,j as r,k as i,r as a}from"./fa-core-BoBqCOD3.js";import{t as o}from"./useNavigate-BblEmQ3O.js";import{n as s,t as c}from"./bundleQuery-CjbA01rb.js";import{t as l}from"./useQuery-5OkVbV1s.js";import{i as u,o as d}from"./api-DtXiAEKW.js";import{t as f}from"./Card-BpDJPrPZ.js";import{t as p}from"./CodeViewer-C9aVhzG7.js";import{t as m}from"./useLocalStorage-CyZiO78q.js";import{i as h,r as g}from"./configStorage-aLI-65re.js";import{t as _}from"./WhenBadge-DZrl6k94.js";var v=e(r(),1),y=t(),b=({title:e,defaultOpen:t=!1,children:r})=>{let[o,s]=(0,v.useState)(t);return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`button`,{onClick:()=>{s(e=>!e)},className:`flex w-full items-center gap-1.5 py-1 text-[11px] font-semibold uppercase tracking-widest text-neutral-400 hover:text-neutral-600`,children:[(0,y.jsx)(i,{icon:o?a:n,className:`w-2.5`}),e]}),o&&(0,y.jsx)(`div`,{className:`pb-2`,children:r})]})},x=({result:e})=>{let t=Object.entries(e.outputValues);return(0,y.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-black/10 bg-white p-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold ${e.success?`bg-green-100 text-green-700`:`bg-red-100 text-red-700`}`,children:e.success?`Success`:`Error`}),(0,y.jsxs)(`span`,{className:`text-[11px] text-neutral-400`,children:[String(e.durationMs),`ms`]}),e.exitCode!==0&&(0,y.jsxs)(`span`,{className:`text-[11px] text-neutral-400`,children:[`exit code `,String(e.exitCode)]}),(0,y.jsx)(`button`,{onClick:e=>{let t=e.currentTarget;for(;t;){if(t.scrollHeight>t.clientHeight){t.scrollTo({top:0,behavior:`smooth`});return}t=t.parentElement}},className:`ml-auto text-[11px] text-neutral-400 hover:text-neutral-600`,children:`↑ top`})]}),e.error&&(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-red-50 p-3 font-mono text-[12px] text-red-800`,children:e.error}),t.length>0&&(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Outputs`}),(0,y.jsx)(`div`,{className:`divide-y divide-black/5`,children:t.map(([e,t])=>(0,y.jsxs)(`div`,{className:`flex items-start gap-2 py-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 font-mono text-[12px] text-neutral-600`,children:e}),(0,y.jsx)(`span`,{className:`text-[11px] text-neutral-300`,children:`=`}),(0,y.jsx)(`pre`,{className:`min-w-0 flex-1 overflow-auto font-mono text-[12px] text-neutral-800`,children:typeof t==`string`?t:JSON.stringify(t,null,2)})]},e))})]}),e.logs.length>0&&(0,y.jsx)(b,{title:`Logs (${String(e.logs.length)})`,children:(0,y.jsx)(`div`,{className:`space-y-0.5`,children:e.logs.map((e,t)=>(0,y.jsx)(`div`,{className:`font-mono text-[12px] text-neutral-600`,children:e},t))})}),e.stdout&&(0,y.jsx)(b,{title:`Stdout`,children:(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-neutral-50 p-3 font-mono text-[12px] text-neutral-700`,children:e.stdout})}),e.stderr&&(0,y.jsx)(b,{title:`Stderr`,children:(0,y.jsx)(`pre`,{className:`overflow-auto rounded bg-neutral-50 p-3 font-mono text-[12px] text-neutral-700`,children:e.stderr})}),e.httpRequests&&e.httpRequests.count>0&&(0,y.jsx)(b,{title:`Network (${String(e.httpRequests.count)}${e.httpRequests.notLogged>0?`, ${String(e.httpRequests.notLogged)} not logged`:``})`,children:(0,y.jsx)(`div`,{className:`space-y-1.5`,children:e.httpRequests.requests.map((e,t)=>(0,y.jsx)(w,{request:e},t))})})]})},S=e=>{switch(e.toUpperCase()){case`GET`:return`bg-blue-100 text-blue-700`;case`POST`:return`bg-green-100 text-green-700`;case`PUT`:case`PATCH`:return`bg-amber-100 text-amber-700`;case`DELETE`:return`bg-red-100 text-red-700`;default:return`bg-neutral-100 text-neutral-700`}},C=(e,t)=>t||e>=500?`text-red-700`:e>=400?`text-amber-700`:e>=200?`text-green-700`:`text-neutral-600`,w=({request:e})=>{let[t,r]=(0,v.useState)(!1),o=e.requestErrorType!==null;return(0,y.jsxs)(`div`,{className:`rounded border border-black/5 bg-neutral-50`,children:[(0,y.jsxs)(`button`,{onClick:()=>{r(e=>!e)},className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left hover:bg-neutral-100`,children:[(0,y.jsx)(i,{icon:t?a:n,className:`w-2.5 text-neutral-400`}),(0,y.jsx)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold ${S(e.method)}`,children:e.method}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-neutral-700`,children:e.url}),(0,y.jsx)(`span`,{className:`font-mono text-[11px] font-semibold ${C(e.responseStatusCode,o)}`,children:o?e.requestErrorType:e.responseStatusCode}),(0,y.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[(e.duration*1e3).toFixed(0),`ms`]})]}),t&&(0,y.jsxs)(`div`,{className:`space-y-2 border-t border-black/5 p-2.5`,children:[(0,y.jsx)(T,{title:`Request Headers`,data:e.headers}),e.body&&(0,y.jsx)(E,{title:`Request Body`,body:e.body}),(0,y.jsx)(T,{title:`Response Headers`,data:e.responseHeaders}),e.responseBody&&(0,y.jsx)(E,{title:`Response Body`,body:e.responseBody})]})]})},T=({title:e,data:t})=>{let n=Object.entries(t);return n.length===0?null:(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,y.jsx)(`div`,{className:`divide-y divide-black/5 rounded border border-black/5 bg-white`,children:n.map(([e,t])=>(0,y.jsxs)(`div`,{className:`flex gap-2 px-2 py-1 font-mono text-[11px]`,children:[(0,y.jsxs)(`span`,{className:`shrink-0 text-neutral-500`,children:[e,`:`]}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 break-all text-neutral-800`,children:t})]},e))})]})},E=({title:e,body:t})=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,y.jsx)(`pre`,{className:`overflow-auto rounded border border-black/5 bg-white p-2 font-mono text-[11px] text-neutral-800`,children:t})]}),D=[`python-3-13`,`python-3-12`],O=`python-3-12`,k={text:`s`,string:`s`,number:`n`,integer:`n`,boolean:`b`,date:`d`,datetime:`dt`,phone:`p`,phonenumber:`p`,uuid:`u`,file:`f`,list:`l`};function A(e){return k[e.toLowerCase()]??`s`}function j(e){return D.includes(e)?e:O}function M(e,t){let n=Object.keys(e);if(n.length===0)return null;let r={};for(let i of n)r[i]={t:A(t[i]??`string`),v:e[i]};return r}function N(e){let t=Object.keys(e);if(t.length===0)return null;let n={};for(let r of t)n[r]=A(e[r]??`string`);return n}function P(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r.v;return t}function F(e){if(!e)return;let t=e.requests.map(e=>({method:e.method,url:e.url,headers:e.headers,body:e.body,requestSubmittedAt:e.requestSubmittedAt,session:e.session,responseStatusCode:e.responseStatusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,requestErrorType:e.requestErrorType,duration:e.duration}));return{count:e.count,notLogged:e.not_logged,requests:t}}async function I(e,t){let n=Date.now(),r={user_script:t.script,runtime:j(t.scriptRuntime),secrets:t.secretNames.length>0?t.secretNames:void 0,inputs:M(t.inputs,t.inputTypes),output_types:N(t.outputTypes)};try{let t=await e(`/coderunner/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),i=Date.now()-n;if(!t.ok){let e=await t.text();return{success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:`Remote runner returned ${String(t.status)}: ${e}`,exitCode:1,durationMs:i}}let a=await t.json(),o=a.error!==null,s=F(a.http_requests),c={success:!o,outputValues:P(a.values),logs:a.logs??[],stdout:``,stderr:``,exitCode:+!!o,durationMs:a.duration_ms??i,...s&&{httpRequests:s}};return o&&a.error&&(c.error=a.error.detail?`${a.error.error}\n${a.error.detail}`:a.error.error),c}catch(e){return{success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:`Remote execution failed: ${e instanceof Error?e.message:String(e)}`,exitCode:1,durationMs:Date.now()-n}}}var L=()=>{let{apiName:e,stepApiName:t}=s({strict:!1}),n=o(),{data:r,isLoading:i,isError:a}=l(c),b=u(),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),E=(0,v.useRef)(null),[D,O]=m(`kizen-step-inputs:${e??``}:${t??``}`,{}),[k,A]=m(`kizen-step-secrets:${e??``}:${t??``}`,{}),[j,M]=m(`kizen-code-runner-mode`,`local`),N=r?.find(t=>t.api_name===e),P=(0,v.useMemo)(()=>N?.artifacts.automation_action_configs??[],[N]),F=P.find(e=>e.action_step_api_name===t)??P[0],L=(0,v.useMemo)(()=>{if(!e||!N)return{};let t=N.base_config,n=g(e),r=h(e),i=d(n?.__kizen_clean_config??{},[],n?.__kizen_setup_assistant_values??{},t?.setup_assistant?.fields),a=d(r?.__kizen_clean_config??{},[],r?.__kizen_setup_assistant_values??{},t?.user_setup_assistant?.fields),o={};for(let[e,t]of Object.entries(i))o[`config__${e}`]=t;for(let[e,t]of Object.entries(a))o[`userConfig__${e}`]=t;return o},[e,N]);if((0,v.useEffect)(()=>{if(!t&&P.length>0&&e){let t=P[0];t&&n({to:`/$apiName/code-steps/$stepApiName`,params:{apiName:e,stepApiName:t.action_step_api_name},replace:!0})}},[t,P,e,n]),(0,v.useEffect)(()=>{T(null)},[t]),(0,v.useEffect)(()=>{w&&E.current&&E.current.scrollIntoView({behavior:`smooth`,block:`start`})},[w]),i)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(a)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});if(!N)return(0,y.jsx)(f,{children:(0,y.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,y.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});if(P.length===0)return(0,y.jsx)(f,{children:(0,y.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:`This app has no automation code steps.`})});if(!F)return(0,y.jsx)(f,{children:(0,y.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`Step not found: `,(0,y.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:t}),`.`]})});let R=async()=>{C(!0),T(null);try{let t=Object.fromEntries(F.inputs.map(e=>[e.name,D[e.name]??``])),n;n=j===`remote`?await I(b,{script:F.script,scriptRuntime:F.script_runtime,inputs:t,inputTypes:Object.fromEntries(F.inputs.map(e=>[e.name,e.data_type])),outputTypes:Object.fromEntries(F.outputs.map(e=>[e.name,e.data_type])),secretNames:F.secrets.map(t=>`${e??``}__${t}`)}):await(await fetch(`/api/execute-step`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({script:F.script,scriptRuntime:F.script_runtime,inputs:t,secrets:Object.fromEntries(F.secrets.map(t=>[`${e??``}__${t}`,k[t]??``]))})})).json(),T(n)}catch(e){T({success:!1,outputValues:{},logs:[],stdout:``,stderr:``,error:e instanceof Error?e.message:String(e),exitCode:1,durationMs:0})}finally{C(!1)}};return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(f,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Code Step`}),(0,y.jsx)(`select`,{value:F.action_step_api_name,onChange:t=>{e&&n({to:`/$apiName/code-steps/$stepApiName`,params:{apiName:e,stepApiName:t.target.value}})},className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:P.map(e=>(0,y.jsx)(`option`,{value:e.action_step_api_name,children:e.name},e.action_step_api_name))}),(0,y.jsx)(`div`,{className:`flex-1`}),(0,y.jsx)(`span`,{className:`rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600`,children:F.script_runtime})]}),F.overall_description&&(0,y.jsx)(`p`,{className:`mt-2 text-[12px] text-neutral-500`,children:F.overall_description}),F.when&&(0,y.jsx)(`div`,{className:`mt-2`,children:(0,y.jsx)(_,{when:F.when,whenState:L})})]}),(0,y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Inputs`}),F.inputs.length>0?(0,y.jsx)(`div`,{className:`space-y-3`,children:F.inputs.map(e=>(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`label`,{className:`mb-1 block text-[12px] text-neutral-700`,children:[e.label,e.required&&(0,y.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`})]}),(0,y.jsx)(`input`,{type:`text`,value:D[e.name]??``,onChange:t=>{O({...D,[e.name]:t.target.value})},placeholder:e.name,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[13px] text-neutral-800 placeholder:text-neutral-300 focus:border-blue-300 focus:outline-none`}),(0,y.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-neutral-400`,children:e.name})]},e.name))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]}),(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Outputs`}),F.outputs.length>0?(0,y.jsx)(`div`,{className:`space-y-2`,children:F.outputs.map(e=>(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2 rounded border border-black/5 bg-neutral-50 px-2.5 py-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[13px] text-neutral-700`,children:e.label}),(0,y.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:e.name}),(0,y.jsx)(`span`,{className:`ml-auto rounded bg-white px-1.5 py-0.5 font-mono text-[10px] text-neutral-500`,children:e.data_type})]},e.name))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]}),(0,y.jsxs)(f,{children:[(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Secrets`}),j===`remote`&&(0,y.jsx)(`p`,{className:`mb-3 rounded border border-blue-100 bg-blue-50 px-2.5 py-1.5 text-[12px] text-blue-700`,children:`Remote runner uses secrets from your business context.`}),F.secrets.length>0?(0,y.jsx)(`div`,{className:`space-y-3`,children:F.secrets.map(e=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`label`,{className:`mb-1 block text-[12px] text-neutral-700`,children:e}),(0,y.jsx)(`input`,{type:`password`,value:k[e]??``,onChange:t=>{A({...k,[e]:t.target.value})},placeholder:e,disabled:j===`remote`,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[13px] text-neutral-800 placeholder:text-neutral-300 focus:border-blue-300 focus:outline-none disabled:cursor-not-allowed disabled:bg-neutral-50 disabled:text-neutral-400`})]},e))}):(0,y.jsx)(`p`,{className:`m-0 text-[12px] text-neutral-400`,children:`None defined.`})]})]}),(0,y.jsx)(p,{code:F.script,language:`python`,onRun:()=>void R(),isRunning:S,executionMode:j,onModeChange:M}),w&&(0,y.jsx)(`div`,{ref:E,children:(0,y.jsx)(x,{result:w})})]})};export{L as CodeStepsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,T as n,j as r,k as i}from"./fa-core-BoBqCOD3.js";import{n as a,t as o}from"./bundleQuery-CjbA01rb.js";import{t as s}from"./useQuery-5OkVbV1s.js";import{a as c,i as l,n as u}from"./BootstrapContext-D5ZnMrOp.js";import{
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{A as t,T as n,j as r,k as i}from"./fa-core-BoBqCOD3.js";import{n as a,t as o}from"./bundleQuery-CjbA01rb.js";import{t as s}from"./useQuery-5OkVbV1s.js";import{a as c,i as l,n as u}from"./BootstrapContext-D5ZnMrOp.js";import{n as d,o as f,r as p,s as m,t as h}from"./useCriticalExceptionDialog-C8PL9Dxt.js";import{d as g}from"./storageKeys-C6c8YF5Y.js";import{i as _,n as v,r as y,w as b}from"./api-DtXiAEKW.js";import{t as x}from"./Card-BpDJPrPZ.js";import{t as S}from"./CodeViewer-C9aVhzG7.js";import{c as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./configStorage-aLI-65re.js";var A=e(r(),1),j=t(),M=e=>e?JSON.stringify(e,null,2):`{}`,N=({apiName:e,configTemplate:t})=>{let n=D(e),r=M(t),[i,a]=(0,A.useState)(n?.__kizen_clean_config?JSON.stringify(n.__kizen_clean_config,null,2):r),[o,s]=(0,A.useState)(null),[c,l]=(0,A.useState)(!1);return(0,j.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,j.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,j.jsxs)(`p`,{className:`text-[13px] text-neutral-500 m-0`,children:[`No setup assistant defined. Enter configuration as JSON.`,t?` Pre-populated from config_template.`:``]})}),(0,j.jsx)(`textarea`,{value:i,onChange:e=>{a(e.target.value),s(null),l(!1)},spellCheck:!1,className:`w-full min-h-[300px] rounded border p-3 text-[13px] font-mono leading-relaxed focus:outline-none focus:ring-1 ${o?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`}`}),o&&(0,j.jsxs)(`span`,{className:`text-[12px] text-red-500`,children:[`Parse error: `,o]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`button`,{onClick:()=>{try{O(e,JSON.parse(i)),s(null),l(!0),setTimeout(()=>{l(!1)},2e3)}catch(e){s(e instanceof Error?e.message:`Invalid JSON`),l(!1)}},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,j.jsx)(`button`,{onClick:()=>{k(e),a(r),s(null),l(!1)},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),c&&(0,j.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})},P=({open:e,onClose:t,apiName:n,loadFn:r,label:i})=>{let a=(0,A.useMemo)(()=>e?r(n)?.__kizen_clean_config??null:null,[e,n,r]),o=(0,A.useMemo)(()=>a?JSON.stringify(a,null,2):``,[a]),[s,u]=(0,A.useState)(!1);return(0,A.useEffect)(()=>{e||u(!1)},[e]),(0,j.jsx)(l,{open:e,size:`xl`,ariaModal:!0,onBackdropClick:t,header:(0,j.jsx)(c,{title:`Stored JSON — ${i}`,onClose:t}),footer:a?(0,j.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{u(!0),setTimeout(()=>{u(!1)},1200)})},className:`rounded border border-black/10 px-3 py-1 text-[12px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:s?`Copied`:`Copy`}):void 0,children:(0,j.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,j.jsxs)(`p`,{className:`m-0 mb-3 text-[12px] text-neutral-500`,children:[`This is the saved JSON the plugin runtime will see as`,` `,(0,j.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 font-mono text-[11px]`,children:i}),`. Save the form to refresh.`]}),a?(0,j.jsx)(S,{code:o,language:`json`}):(0,j.jsx)(`div`,{className:`rounded border border-dashed border-black/10 px-4 py-6 text-center text-[12px] text-neutral-400`,children:`No saved configuration yet. Save the form to populate this view.`})]})})},F=({config:e,apiName:t,loadFn:n,saveFn:r,clearFn:i})=>{let a=n(t)?.__kizen_setup_assistant_values,o=(0,A.useRef)({}),[s,c]=(0,A.useState)(!1),{getObjectByAPIName:l,getCustomObjectDetails:u}=d(),f=(0,A.useCallback)(e=>{o.current=e},[]);return(0,j.jsx)(m,{config:e,value:a,onStateChange:f,disabledKeys:[],getObjectByAPIName:l,getCustomObjectDetails:u,children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.fields?.map(e=>(0,j.jsx)(p,{field:e,pluginApiName:t},e.key)),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,j.jsx)(`button`,{onClick:()=>{let n=o.current;r(t,n,e),c(!0),setTimeout(()=>{c(!1)},2e3)},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,j.jsx)(`button`,{onClick:()=>{i(t),window.location.reload()},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),s&&(0,j.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})})},I=({config:e,apiName:t,loadFn:r,saveFn:a,clearFn:o})=>{let s=u(),c=_(),l=(0,A.useMemo)(()=>b(c),[c]),{environment:d}=g(),p=v[d],[m,x]=(0,A.useState)(!1),[S,C]=(0,A.useState)(!1),{onMonitoringException:w,dialog:T}=h();return s?(0,j.jsx)(f,{appPath:p,user:{id:s.team.user,crm_client_id:``},business:s.business,clientObject:s.business.client_object?{id:s.business.client_object.id,objectName:s.business.client_object.object_name}:void 0,teamMember:s.team,onNavigate:()=>{},performFileUpload:()=>Promise.resolve({url:``}),monitoringExceptionHelper:w,performRequest:y(l),modal:{showing:m,show:S,showPrompt:()=>{x(!0),C(!0)},onConfirm:()=>{x(!1),C(!1)},onHide:()=>{x(!1),C(!1)}},showToast:()=>{},clearToasts:()=>{},children:()=>(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(F,{config:e,apiName:t,loadFn:r,saveFn:a,clearFn:o}),T]})}):(0,j.jsx)(i,{icon:n,className:`animate-spin text-neutral-400`})},L=()=>{let{apiName:e}=a({strict:!1}),{data:t,isLoading:n,isError:r}=s(o),[i,c]=(0,A.useState)(null);if(n)return(0,j.jsx)(x,{children:(0,j.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(r)return(0,j.jsx)(x,{children:(0,j.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let l=t?.find(t=>t.api_name===e);if(!l)return(0,j.jsx)(x,{children:(0,j.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,j.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});let u=l.base_config,d=u?.setup_assistant,f=u?.user_setup_assistant,p=(d?.fields?.length??0)>0,m=(f?.fields?.length??0)>0;return!p&&!m?(0,j.jsx)(x,{children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{className:`text-[15px] font-bold text-neutral-900 m-0`,children:`Configuration`}),(0,j.jsx)(`p`,{className:`text-[12px] text-neutral-400 m-0 mt-1`,children:`Enter plugin configuration as JSON.`})]}),(0,j.jsx)(N,{apiName:e??``,configTemplate:l.config_template})]})}):(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start`,children:[p&&d&&(0,j.jsx)(x,{className:`lg:flex-1 lg:min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{className:`text-[15px] font-bold text-neutral-900 m-0`,children:`Business Configuration`}),(0,j.jsxs)(`p`,{className:`text-[12px] text-neutral-400 m-0 mt-1`,children:[`Configure the business-level setup assistant fields. These values are shared across the whole business and exposed to plugin scripts at`,` `,(0,j.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 font-mono text-[11px]`,children:`this.config`}),`.`]})]}),(0,j.jsx)(`button`,{onClick:()=>{c(`business`)},className:`shrink-0 rounded border border-black/10 px-3 py-1.5 text-[12px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`View JSON`})]}),(0,j.jsx)(I,{config:d,apiName:e??``,loadFn:D,saveFn:E,clearFn:k})]})}),m&&f&&(0,j.jsx)(x,{className:`lg:flex-1 lg:min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{className:`text-[15px] font-bold text-neutral-900 m-0`,children:`User Configuration`}),(0,j.jsxs)(`p`,{className:`text-[12px] text-neutral-400 m-0 mt-1`,children:[`Configure the per-user setup assistant fields. These values are scoped to the logged-in user and exposed to plugin scripts at`,` `,(0,j.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 font-mono text-[11px]`,children:`this.userConfig`}),`.`]})]}),(0,j.jsx)(`button`,{onClick:()=>{c(`user`)},className:`shrink-0 rounded border border-black/10 px-3 py-1.5 text-[12px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`View JSON`})]}),(0,j.jsx)(I,{config:f,apiName:e??``,loadFn:w,saveFn:C,clearFn:T})]})}),(0,j.jsx)(P,{open:i===`business`,onClose:()=>{c(null)},apiName:e??``,loadFn:D,label:`this.config`}),(0,j.jsx)(P,{open:i===`user`,onClose:()=>{c(null)},apiName:e??``,loadFn:w,label:`this.userConfig`})]})};export{L as ConfigurationPage};
|