@auersperg/flare 0.3.11 → 0.3.12
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/cli/flare.js +1 -1
- package/dist/platform/admin.js +1 -1
- package/dist/platform/dashboard/_astro/{ai-view.DxgwI4OB.js → ai-view.De8j8CVD.js} +1 -1
- package/dist/platform/dashboard/_astro/{auth-view.C16WPVOx.js → auth-view.C9j0-OzH.js} +1 -1
- package/dist/platform/dashboard/_astro/client.BvQ8bQkQ.js +4 -0
- package/dist/platform/dashboard/_astro/{data-view.BCmdi_cs.js → data-view.Bw2dG8Wg.js} +1 -1
- package/dist/platform/dashboard/_astro/{functions-view.Cf640vhX.js → functions-view.Bsazyfej.js} +1 -1
- package/dist/platform/dashboard/_astro/{index.astro_astro_type_script_index_0_lang.cFeBPGtv.js → index.astro_astro_type_script_index_0_lang.C_U84Sz-.js} +2 -2
- package/dist/platform/dashboard/_astro/{sdk-view.Cs96E0YV.js → sdk-view.vdDnLZ5g.js} +1 -1
- package/dist/platform/dashboard/_astro/{services-view.DhwKE_RK.js → services-view.C1FjN8NY.js} +1 -1
- package/dist/platform/dashboard/_astro/{settings-view.Dsc34AAW.js → settings-view.DZldw4Vy.js} +1 -1
- package/dist/platform/dashboard/index.html +1 -1
- package/dist/platform/manifest.json +28 -28
- package/dist/platform/runtime.js +94 -5
- package/dist/sdk/client.d.ts +6 -0
- package/dist/sdk/client.js +29 -0
- package/dist/sdk/codex-stream.d.ts +28 -0
- package/dist/sdk/codex-stream.js +147 -0
- package/dist/sdk/react.d.ts +4 -0
- package/dist/sdk/server.d.ts +1 -0
- package/package.json +1 -1
- package/dist/platform/dashboard/_astro/client.4z54xJ_z.js +0 -1
package/dist/cli/flare.js
CHANGED
package/dist/platform/admin.js
CHANGED
|
@@ -309,7 +309,7 @@ async function collectCatalog(database, now = Date.now()) {
|
|
|
309
309
|
// packages/core/package.json
|
|
310
310
|
var package_default = {
|
|
311
311
|
name: "@flare/platform",
|
|
312
|
-
version: "0.3.
|
|
312
|
+
version: "0.3.12",
|
|
313
313
|
type: "module",
|
|
314
314
|
license: "MIT",
|
|
315
315
|
private: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,g as r,j as i,m as a,p as o,pt as s,q as c,s as l,u}from"./common.9pujiaSZ.js";import{i as d,t as f}from"./client.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,g as r,j as i,m as a,p as o,pt as s,q as c,s as l,u}from"./common.9pujiaSZ.js";import{i as d,t as f}from"./client.BvQ8bQkQ.js";var p=e(t(),1),m=n();function h({project:e,env:t,session:n}){let h=r(e,t),g=u(h+`/ai`),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(`{"query":""}`),[C,w]=(0,p.useState)(``),[T,E]=(0,p.useState)(``),[D,O]=(0,p.useState)(!1);(0,p.useEffect)(()=>{v(``),w(``),E(``)},[h]);async function k(){O(!0),E(``),w(``);let r=f({url:`${n.runtime}/p/${e.id}/${t}`,getToken:()=>_});try{let e=await r.action(d(y,`action`),JSON.parse(x));w(JSON.stringify(e,null,2))}catch(e){E(a(e))}finally{r.dispose(),O(!1)}}async function A(){if(confirm(`Exclude all indexed files in ${e.name}/${t}? Originals remain in Files. Provider cleanup is asynchronous.`)){O(!0),E(``);try{await o(h+`/search-clear`,t===`prod`?{confirm:e.id}:{}),g.refresh()}catch(e){E(a(e))}finally{O(!1)}}}return(0,m.jsxs)(`div`,{className:`space-y-6 p-6`,children:[(0,m.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,m.jsx)(`h1`,{className:`page-title`,children:`AI`}),(0,m.jsx)(s,{variant:`outline`,onClick:g.refresh,children:`Refresh`})]}),(0,m.jsx)(l,{loading:g.loading,error:g.error||T}),g.data&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`section`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-lg font-medium`,children:`Search`}),(0,m.jsx)(`p`,{children:g.data.search.binding?`Binding: ${g.data.search.binding}`:`Not connected. Configure an existing AI Search instance through platform update --config. No resource is created here.`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`TXT/PDF · up to 10 MiB · explicit file indexing from application actions. File permissions belong to your application.`}),(0,m.jsxs)(`p`,{children:[`Tracked index items: `,g.data.search.remaining]}),g.data.search.states.map(e=>(0,m.jsxs)(`p`,{children:[e.status,`: `,e.count]},e.status)),g.data.search.errors>0&&(0,m.jsxs)(`p`,{role:`alert`,children:[g.data.search.errors,` operations need attention. Retry indexing through the application; retry pending cleanup with Exclude all.`]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Processing states are last observed, not a live provider status. Use action search.status(fileId) to refresh a document. Files, Functions and Logs remain in their existing sections.`}),n.role!==`viewer`&&g.data.search.remaining>0&&(0,m.jsx)(s,{variant:`outline`,disabled:D,onClick:A,children:`Exclude all / retry cleanup`})]}),(0,m.jsxs)(`section`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-lg font-medium`,children:`Test application search`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Calls your existing search action with a real application session, not dashboard/admin identity. The application must authorize each result. Session is held only in this view, never saved. Dashboard origin must be allowed by the application.`}),(0,m.jsxs)(`label`,{className:`block`,children:[`Application session`,(0,m.jsx)(c,{type:`password`,autoComplete:`off`,value:_,onChange:e=>v(e.target.value),placeholder:`flared_session_…`})]}),(0,m.jsxs)(`label`,{className:`block`,children:[`Search action path`,(0,m.jsx)(c,{value:y,onChange:e=>b(e.target.value),placeholder:`documents/search`})]}),(0,m.jsxs)(`label`,{className:`block`,children:[`Arguments (JSON)`,(0,m.jsx)(i,{value:x,onChange:e=>S(e.target.value)})]}),(0,m.jsx)(s,{disabled:D||!_.startsWith(`flared_session_`)||!y||!g.data.search.binding,onClick:k,children:`Run once`}),C&&(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:C})]}),(0,m.jsxs)(`section`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-lg font-medium`,children:`MCP`}),(0,m.jsx)(`code`,{className:`break-all`,children:g.data.endpoint}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Stateless HTTP. Use a client supporting an Authorization: Bearer application-session header. No OAuth discovery. Admin, deploy and dev tokens are not accepted. Logout, expiry and disabling the user revoke access.`}),g.data.tools.length?g.data.tools.map(e=>(0,m.jsxs)(`p`,{children:[(0,m.jsx)(`strong`,{children:e.name}),` — `,e.description]},e.name)):(0,m.jsx)(`p`,{children:`No tools exposed. Add explicit mcp metadata to selected application functions and deploy that application.`})]})]})]})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,S as r,_ as i,a,b as o,f as s,g as c,n as l,p as u,pt as d,s as f,u as p,v as m,x as h,y as g}from"./common.9pujiaSZ.js";import{o as _}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,S as r,_ as i,a,b as o,f as s,g as c,n as l,p as u,pt as d,s as f,u as p,v as m,x as h,y as g}from"./common.9pujiaSZ.js";import{o as _}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";var v=e(t(),1),y=n();function b(e){let t=c(e.project,e.env),[n,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(),C=p(t+`/auth-users`+(n?`?cursor=`+encodeURIComponent(n):``)),w=p(t+`/auth-settings`),T=e.session.role===`owner`,E=(n,r,i,a=[])=>{S({title:r,description:`Passwords are never displayed. Changes revoke existing sessions.`,productionId:e.env===`prod`?e.project.id:void 0,fields:a,submit:async r=>{try{await u(t+`/`+n,{...i,...s(a,e=>new FormData(r).get(e)),confirm:e.project.id})}catch(e){throw e instanceof Error&&e.message===`INVALID_PASSWORD`?Error(`Password must contain 6–128 characters. Spaces are allowed; the password is not trimmed.`):e instanceof Error&&e.message===`REGISTRATION_UNAVAILABLE`?Error(`This login is already registered. Choose another login or manage the existing user.`):e}C.refresh(),w.refresh()}})},D={name:`password`,type:`password`,required:!0,description:`6–128 characters.`};return(0,y.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,y.jsx)(`h1`,{className:`page-title`,children:`Auth`}),(0,y.jsx)(f,{loading:C.loading||w.loading,error:C.error||w.error}),w.data&&(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(_,{status:w.data.enabled?`Enabled`:`Disabled`}),(0,y.jsx)(_,{status:w.data.registration?`Public registration`:`Registration closed`}),T&&(0,y.jsx)(d,{variant:`outline`,onClick:()=>E(`auth-configure`,`Configure authentication`,{},[{name:`enabled`,type:`boolean`,value:w.data.enabled},{name:`registration`,type:`boolean`,value:w.data.registration}]),children:`Configure`}),T&&(0,y.jsx)(d,{onClick:()=>E(`auth-create`,`Create user`,{},[{name:`login`,type:`string`,required:!0},D]),children:`Create user`})]}),C.data&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(i,{children:[(0,y.jsx)(h,{children:(0,y.jsxs)(r,{children:[(0,y.jsx)(o,{children:`Login`}),(0,y.jsx)(o,{children:`User ID`}),(0,y.jsx)(o,{children:`Status`}),(0,y.jsx)(o,{children:`Created`}),(0,y.jsx)(o,{children:`Actions`})]})}),(0,y.jsx)(m,{children:C.data.users.map(e=>(0,y.jsxs)(r,{children:[(0,y.jsx)(g,{children:e.login}),(0,y.jsx)(g,{children:(0,y.jsx)(`code`,{children:e.id})}),(0,y.jsx)(g,{children:(0,y.jsx)(_,{status:e.disabled?`Blocked`:`Active`})}),(0,y.jsx)(g,{children:new Date(e.createdAt).toLocaleString()}),(0,y.jsx)(g,{children:(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>E(`auth-password`,`Change user password`,{id:e.id},[D]),children:`Change password`}),(0,y.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>E(`auth-revoke`,`Revoke all sessions`,{id:e.id}),children:`Revoke sessions`}),(0,y.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>E(`auth-disable`,e.disabled?`Unblock user`:`Block user`,{id:e.id,disabled:!e.disabled}),children:e.disabled?`Unblock`:`Block`})]})})})]},e.id))})]}),!C.data.users.length&&(0,y.jsx)(l,{title:`No users`}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,disabled:!n,onClick:()=>b(``),children:`First page`}),(0,y.jsx)(d,{variant:`outline`,disabled:!C.data.next,onClick:()=>b(C.data.next),children:`Next page`})]})]}),x&&(0,y.jsx)(a,{modal:x,onClose:()=>S(void 0)})]})}export{b as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var e=Object.freeze({inputBytes:65536,outputBytes:262144,frameBytes:8192,subscriptions:64,fileBytes:10485760}),t=class extends Error{code;ambiguous;constructor(e,t,n=!1){super(t),this.code=e,this.ambiguous=n,this.name=`FlareError`}};function n(e){if(e.length>256||!/^[A-Za-z][A-Za-z0-9_]*(\/[A-Za-z][A-Za-z0-9_]*)*$/.test(e)||e.split(`/`).some(e=>[`__proto__`,`prototype`,`constructor`].includes(e)))throw new t(`INVALID_PATH`,`Invalid function path`)}function r(e,t){return n(e),Object.freeze({path:e,kind:t})}function i(e){let n=new Set;function r(e,i){if(i>40)throw new t(`INVALID_JSON`,`JSON nesting limit exceeded`);if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`object`||!e||n.has(e))throw new t(`INVALID_JSON`,`Expected lossless JSON`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new t(`INVALID_JSON`,`Expected plain JSON object`);if(Object.getOwnPropertySymbols(e).length)throw new t(`INVALID_JSON`,`Symbol keys are unsupported`);n.add(e);let a;if(Array.isArray(e))a=Array.from(e,e=>r(e,i+1));else{let n=Object.create(null);for(let a of Object.keys(e).sort()){let o=Object.getOwnPropertyDescriptor(e,a);if(!(`value`in o))throw new t(`INVALID_JSON`,`Getters are unsupported`);n[a]=r(o.value,i+1)}a=n}return n.delete(e),a}return JSON.stringify(r(e,0))}function a(e,n){let r=i(e);if(new TextEncoder().encode(r).byteLength>n)throw new t(`TOO_LARGE`,`JSON payload exceeds limit`);return r}async function o(e,t,n){let r=e.getReader(),i=[],a=0;try{for(;;){let{done:e,value:o}=await r.read();if(e)break;a+=o.byteLength,a>t&&n(),i.push(o)}}finally{await r.cancel().catch(()=>{})}if(i.length===1)return i[0];let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.byteLength;return o}async function*s(n){if(n.ref.kind!==`query`)throw new t(`INVALID_KIND`,`Stream authorization must be a read-only query`);let r=n.after??0,i=0;if(!Number.isSafeInteger(r)||r<0||r>4096)throw new t(`INVALID_ARGUMENT`,`Invalid cursor`);let s=n.signal;for(;!s.aborted;){let c,l=new AbortController,u=()=>l.abort(s.reason);s.addEventListener(`abort`,u,{once:!0}),s.aborted&&u();let d,f=()=>{clearTimeout(d),d=setTimeout(()=>l.abort(),45e3)};try{f();let u=await n.token();if(s.aborted)return;let d=await n.transport(n.url,{method:`POST`,redirect:`error`,signal:l.signal,headers:{"Content-Type":`application/json`,...u?{Authorization:`Bearer ${u}`}:{}},body:a({path:n.ref.path,kind:`query`,args:n.args,after:r},e.inputBytes)});if(!d.ok){let e=d.body?await o(d.body,8192,()=>{throw new t(`INVALID_RESPONSE`,`Oversized error`)}):new Uint8Array,n=`HTTP_${d.status}`;try{let t=JSON.parse(new TextDecoder().decode(e));/^[A-Z][A-Z0-9_]{0,63}$/.test(t.error)&&(n=t.error)}catch{}throw new t(n,`Event subscription failed`)}if(!d.headers.get(`content-type`)?.startsWith(`text/event-stream`)||!d.body)throw new t(`INVALID_RESPONSE`,`Expected SSE`);c=d.body.getReader();let p=new TextDecoder(`utf-8`,{fatal:!0}),m=``,h=0;for(;!s.aborted;){let e=await c.read();if(e.done)break;if(f(),h+=e.value.byteLength,h>1048576)throw new t(`INVALID_RESPONSE`,`Stream exceeds bound`);m+=p.decode(e.value,{stream:!0});let n;for(;(n=m.indexOf(`
|
|
2
|
+
|
|
3
|
+
`))>=0;){let e=m.slice(0,n);if(m=m.slice(n+2),e.length>524288)throw new t(`INVALID_RESPONSE`,`Oversized event`);let a=``,o=``,s=``;for(let t of e.split(`
|
|
4
|
+
`))t.startsWith(`event:`)&&(a=t.slice(6).trim()),t.startsWith(`data:`)&&(o+=t.slice(5).trimStart()),t.startsWith(`id:`)&&(s=t.slice(3).trim());if(!o||a===`reconnect`)continue;let c=JSON.parse(o);if(a===`task`){if(!c||typeof c.id!=`string`||![`succeeded`,`failed`,`cancelled`,`interrupted`].includes(c.state))throw new t(`INVALID_RESPONSE`,`Invalid task`);yield{type:`task`,task:c};return}if(a!==`progress`||!Number.isSafeInteger(c.seq)||String(c.seq)!==s||c.seq>4096||![`status`,`text`,`output`,`item`,`truncated`].includes(c.type))throw new t(`INVALID_RESPONSE`,`Invalid event`);if(!(c.seq<=r)){if(c.seq!==r+1)throw new t(`CODEX_EVENT_GAP`,`Event gap`);r=c.seq,i=0,yield c}}if(m.length>524288)throw new t(`INVALID_RESPONSE`,`Oversized frame`)}}catch(e){if(s.aborted)return;let n=e instanceof t?e.code:``;if(n&&![`HTTP_429`,`HTTP_500`,`HTTP_502`,`HTTP_503`,`HTTP_504`,`CODEX_UNAVAILABLE`].includes(n))throw e;if(++i>5)throw new t(`CODEX_STREAM_INTERRUPTED`,`Reconnect failed; task continues independently`)}finally{clearTimeout(d),s.removeEventListener(`abort`,u),l.abort(),await c?.cancel().catch(()=>{})}if(s.aborted)return;await new Promise(e=>{let t=()=>{clearTimeout(n),s.removeEventListener(`abort`,t),e()},n=setTimeout(t,Math.min(5e3,500*2**i));s.addEventListener(`abort`,t,{once:!0})})}}function c(n){if(n.size>e.fileBytes)throw new t(`TOO_LARGE`,`Maximum file size: 10 MiB`);if(!n.name||n.name.length>120||/[\x00-\x1f\x7f/\\]/.test(n.name))throw new t(`INVALID_INPUT`,`File name must be 1–120 characters, without path separators`);return{name:n.name,size:n.size,type:[`text/plain`,`image/png`,`image/jpeg`,`image/webp`,`application/pdf`].includes(n.type)?n.type:`application/octet-stream`}}async function l(n,r,i={}){if(r.size>e.fileBytes)throw new t(`TOO_LARGE`,`Maximum file size: 10 MiB`);let a=new URL(n.url);if(a.username||a.password||a.protocol!==`https:`&&!(a.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(a.hostname)))throw new t(`INVALID_URL`,`Expected secure upload URL`);let s;try{s=await(i.fetch??globalThis.fetch)(a.href,{method:`POST`,body:r,redirect:`error`,credentials:`omit`,signal:AbortSignal.any([...i.signal?[i.signal]:[],AbortSignal.timeout(i.timeoutMs??12e4)])})}catch{throw new t(`UPLOAD_UNKNOWN`,`Connection interrupted or upload timed out; refresh the file list before trying again`,!0)}let c=s.body?await o(s.body,e.outputBytes,()=>{throw Error(`Upload response exceeds limit`)}).then(e=>JSON.parse(new TextDecoder(`utf-8`,{fatal:!0}).decode(e))).catch(()=>null):null;if(!s.ok){let e=c&&typeof c==`object`&&`error`in c&&typeof c.error==`string`?c.error:`HTTP_${s.status}`;throw new t(e,`Upload failed: ${e}`,s.status>=500)}if(!c||typeof c!=`object`||!(`id`in c)||typeof c.id!=`string`)throw new t(`INVALID_RESPONSE`,`Upload outcome is unknown; refresh the file list before uploading again`,!0);return{id:c.id}}var u=new Set([`UNAUTHORIZED`,`AUTH_EXPIRED`,`FORBIDDEN`,`AUTH_DISABLED`,`HTTP_401`,`HTTP_403`]);function d(r){let c=new URL(r.url);if(!/^https?:$/.test(c.protocol)||c.username||c.password||c.search||c.hash)throw new t(`INVALID_URL`,`Expected backend HTTP URL`);if(c.protocol===`http:`&&![`localhost`,`127.0.0.1`,`[::1]`].includes(c.hostname))throw new t(`INVALID_URL`,`Remote backends require HTTPS`);c.pathname=c.pathname.replace(/\/$/,``);let l=r.fetch??globalThis.fetch;if(!l)throw new t(`TRANSPORT_UNAVAILABLE`,`Provide a fetch implementation`);let d=new Map,f=!1,p,m=!1,h=0,g=0,_=0,v,y=new Set,b=e=>`${c.href.replace(/\/$/,``)}${e}`,x=(e,t,n)=>{for(let r of e.observers)try{r[t]?.(t===`next`?JSON.parse(n):n)}catch{}};function S(){if(f)throw new t(`DISPOSED`,`Client is disposed`)}async function C(n,i,s){S();let c=a(i,e.inputBytes),u;try{u=await r.getToken?.()??null}catch{throw new t(`AUTH_UNAVAILABLE`,`Cannot obtain access token`)}S();let d=new AbortController,f=setTimeout(()=>d.abort(),r.requestTimeoutMs??3e4);try{let r=await l(b(n),{method:`POST`,headers:{"Content-Type":`application/json`,...u?{Authorization:`Bearer ${u}`}:{}},body:c,signal:d.signal,redirect:`error`});if(!r.body)throw new t(`INVALID_RESPONSE`,`Missing response body`,s);let i=await o(r.body,e.outputBytes,()=>{throw new t(`INVALID_RESPONSE`,`Response exceeds limit`,s)}),f;try{f=JSON.parse(new TextDecoder(`utf-8`,{fatal:!0}).decode(i))}catch(e){throw r.ok?e:new t(`HTTP_${r.status}`,`Backend request failed`,s&&r.status>=500)}if(!r.ok)throw new t(f&&typeof f==`object`&&`error`in f&&typeof f.error==`string`&&/^[A-Z][A-Z0-9_]{0,63}$/.test(f.error)?f.error:`HTTP_${r.status}`,`Backend request failed`,s&&r.status>=500);if(!f||typeof f!=`object`||!(`result`in f))throw new t(`INVALID_RESPONSE`,`Invalid protocol envelope`,s);return a(f.result,e.outputBytes),f.result}catch(e){throw e instanceof t?e:e instanceof SyntaxError?new t(`INVALID_RESPONSE`,`Invalid JSON response`,s):new t(`TRANSPORT_ERROR`,s?`Write outcome is unknown; do not replay automatically`:`Backend request interrupted`,s)}finally{clearTimeout(f)}}function w(t){p?.send(a(t,e.frameBytes))}function T(e){w({type:`subscribe`,id:e.id,path:e.ref.path,args:e.args})}function E(){if(f||!d.size||v)return;let e=Math.min(3e4,250*2**Math.min(h++,7));v=setTimeout(()=>{v=void 0,D()},e)}async function D(){if(f||m||p||!d.size)return;m=!0;let n=++g;try{let i=await C(`/v1/live/ticket`,{},!1);if(f||n!==g||!d.size)return;if(!i||typeof i.ticket!=`string`||i.ticket.length>1024)throw new t(`INVALID_RESPONSE`,`Invalid live ticket`);let o=new URL(b(`/v1/live`));o.protocol=o.protocol===`https:`?`wss:`:`ws:`,o.searchParams.set(`ticket`,i.ticket);let s=r.createWebSocket?r.createWebSocket(o.href):new globalThis.WebSocket(o.href);p=s;let c=()=>{if(!(p!==s||f)){h=0;for(let e of d.values())e.revision=-1,e.snapshot=void 0,e.terminal||T(e)}},l=n=>{if(!(p!==s||f))try{if(typeof n.data!=`string`||new TextEncoder().encode(n.data).byteLength>e.outputBytes+1024)throw Error(`Invalid frame`);let r=JSON.parse(n.data);if(r.type===`ready`)return;let i=[...d.values()].find(e=>e.id===r.id);if(!i||i.terminal)return;if(r.type===`error`){i.terminal=!0,u.has(r.code)&&(i.snapshot=void 0),x(i,`error`,new t(typeof r.code==`string`?r.code:`LIVE_ERROR`,`Live subscription failed`));return}if(r.type!==`snapshot`||!Number.isSafeInteger(r.revision)||r.revision<0||!(`result`in r))throw Error(`Invalid snapshot`);let o=a(r.result,e.outputBytes);if(r.revision>i.revision){let e=i.snapshot!==o;i.revision=r.revision,i.snapshot=o,e&&x(i,`next`,i.snapshot)}w({type:`ack`,id:i.id,revision:i.revision})}catch{s.close(1002,`Invalid protocol frame`)}},m=e=>{if(v(),p===s){p=void 0;for(let n of d.values())e.code===1008&&(n.snapshot=void 0,n.revision=-1),n.terminal||x(n,`error`,new t(e.code===1008?`AUTH_EXPIRED`:`LIVE_DISCONNECTED`,`Live reconnecting; next snapshot will be current`));E()}},_=()=>s.close(),v=()=>{s.removeEventListener(`open`,c),s.removeEventListener(`message`,l),s.removeEventListener(`close`,m),s.removeEventListener(`error`,_),y.delete(v)};y.add(v),s.addEventListener(`open`,c),s.addEventListener(`message`,l),s.addEventListener(`close`,m),s.addEventListener(`error`,_)}catch(e){if(f||n!==g)return;for(let n of d.values())e instanceof t&&u.has(e.code)&&(n.snapshot=void 0,n.revision=-1),x(n,`error`,e instanceof t?e:new t(`LIVE_UNAVAILABLE`,`Live connection failed`));E()}finally{m=!1,!f&&n!==g&&!p&&d.size&&E()}}function O(e){return async(r,i)=>{if(n(r.path),r.kind!==e)throw new t(`INVALID_KIND`,`Expected a ${e} function`);return C(`/v1/call`,{path:r.path,kind:r.kind,args:i},r.kind===`mutation`||r.kind===`action`)}}return{query:O(`query`),mutation:O(`mutation`),action:O(`action`),async*codexEvents(e,t,i={}){S(),n(e.path);let a=new AbortController,o=()=>a.abort();y.add(o),i.signal?.addEventListener(`abort`,o,{once:!0}),i.signal?.aborted&&o();try{yield*s({url:b(`/v1/codex/events`),ref:e,args:t,after:i.after,transport:l,signal:a.signal,token:async()=>(S(),await r.getToken?.()??null)})}finally{o(),y.delete(o),i.signal?.removeEventListener(`abort`,o)}},onUpdate(r,o,s,c){let l={next:s,error:c};if(S(),n(r.path),r.kind!==`query`)throw new t(`INVALID_KIND`,`Only queries are subscribable`);a({type:`subscribe`,id:`subscription-9999999999`,path:r.path,args:o},e.frameBytes);let u=i({path:r.path,args:o}),f=d.get(u);if(!f){if(d.size>=e.subscriptions)throw new t(`TOO_MANY_SUBSCRIPTIONS`,`Subscription limit exceeded`);f={id:`subscription-${++_}`,ref:r,args:JSON.parse(i(o)),observers:new Set,revision:-1,terminal:!1},d.set(u,f),p?.readyState===1&&T(f)}let m={next:l.next,error:l.error};f.observers.add(m),f.snapshot!==void 0&&x({...f,observers:new Set([l])},`next`,f.snapshot),D();let h=!1;return()=>{if(!h&&(h=!0,f.observers.delete(m),f.observers.size||(d.delete(u),p?.readyState===1&&w({type:`unsubscribe`,id:f.id})),!d.size)){++g,v&&clearTimeout(v),v=void 0;let e=p;p=void 0;for(let e of[...y])e();e?.close(1e3,`No subscriptions`)}}},refreshAuth(){S(),++g,v&&clearTimeout(v),v=void 0;for(let e of[...y])e();let e=p;p=void 0,e?.close(1e3,`Authorization changed`);for(let e of d.values())e.snapshot=void 0,e.revision=-1,e.terminal=!1,x(e,`error`,new t(`AUTH_CHANGED`,`Authorization changed; cached value invalidated`));D()},dispose(){if(!f){f=!0,++g,v&&clearTimeout(v),v=void 0;for(let e of[...y])e();d.clear(),p?.close(1e3,`Disposed`),p=void 0}}}}export{r as i,c as n,l as r,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,S as i,_ as a,a as o,b as s,d as c,g as l,h as u,l as d,n as f,p,pt as m,s as h,u as g,v as _,x as v,y}from"./common.9pujiaSZ.js";import{f as b,h as x,m as S,p as C,s as w}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,S as i,_ as a,a as o,b as s,d as c,g as l,h as u,l as d,n as f,p,pt as m,s as h,u as g,v as _,x as v,y}from"./common.9pujiaSZ.js";import{f as b,h as x,m as S,p as C,s as w}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";import{n as T,r as E,t as D}from"./input-group.Dsc4z0iT.js";var O={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};O.node;var k=r(O),A=e(t(),1),j=n();function M(e,t){return e.filter(e=>e.name!==`_id`&&e.name!==`_creationTime`).map(e=>{let n=c({properties:{[e.name]:e.schema??{type:/INT|REAL/i.test(e.type)?`number`:`string`}},required:e.notnull?[e.name]:[]})[0];return{...n,defaultMode:!t&&e.dflt_value!==null,value:t?t[e.name]:n.value}})}function N(e){let t=l(e.project,e.env),n=g(t+`/schema`),[r,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(``),s=n.data?.tables??[],c=s.find(e=>e.name===r)?.name??s[0]?.name;return(0,j.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,j.jsxs)(`section`,{className:`explorer-sidebar overflow-y-auto`,"aria-label":`Application tables`,children:[(0,j.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`h1`,{className:`page-title`,children:`Data`}),(0,j.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s.length,` tables`]})]}),(0,j.jsxs)(D,{children:[(0,j.jsx)(T,{children:(0,j.jsx)(b,{})}),(0,j.jsx)(E,{"aria-label":`Search tables`,placeholder:`Search tables…`,value:a,onChange:e=>o(e.target.value)})]})]}),(0,j.jsx)(`div`,{className:`space-y-1 px-2`,children:s.filter(e=>e.name.toLowerCase().includes(a.toLowerCase())).map(e=>(0,j.jsxs)(m,{variant:`ghost`,className:`w-full justify-start gap-2 ${c===e.name?`bg-accent`:``}`,onClick:()=>i(e.name),children:[(0,j.jsx)(x,{}),e.name]},e.name))}),(0,j.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:`Tables are defined in code.`})]}),(0,j.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,j.jsx)(h,{...n}),c?(0,j.jsx)(P,{...e,table:c},c):n.data?(0,j.jsx)(f,{title:`No application tables in this release`}):null]})]})}function P({project:e,env:t,session:n,table:r}){let[c,b]=(0,A.useState)(void 0),[x,T]=(0,A.useState)(),E=l(e,t),D=g(E+`/data?table=`+encodeURIComponent(r)+(c===void 0?``:`&cursor=`+encodeURIComponent(c))),O=D.data,N=O?.columns.find(e=>e.pk===1)?.name,P=n.role!==`viewer`,F=(n,i)=>{if(!O)return;let a=n===`delete`?void 0:M(O.columns,i);T({title:n===`insert`?`Add row`:n===`update`?`Edit row`:`Delete row`,description:n===`delete`?`This deletes the selected row. The change is audited.`:`Primary keys are immutable. NULL and defaults are explicit. Changes are revision-checked and audited.`,fields:a,productionId:t===`prod`?e.id:void 0,submit:async e=>{await p(E+`/edit`,{operation:n,table:r,key:i&&N?i[N]:void 0,values:a?d(e,a):void 0,expectedRevision:O.revision,confirm:t===`prod`?new FormData(e).get(`confirm`):void 0}),D.refresh()}})};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`detail-header`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:r}),O&&(0,j.jsxs)(w,{variant:`secondary`,children:[O.rows.length,` rows`]})]}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(m,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,disabled:D.loading,onClick:D.refresh,children:(0,j.jsx)(C,{})}),P&&(0,j.jsxs)(m,{disabled:!O||D.loading,onClick:()=>F(`insert`),children:[(0,j.jsx)(S,{}),`Add row`]})]})]}),(0,j.jsxs)(`div`,{className:`flex justify-between border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,j.jsx)(`span`,{children:O?`${O.columns.length} columns · revision ${O.revision}`:`Loading table`}),(0,j.jsx)(`span`,{children:`Snapshot · updates after edits and when returning to this tab`})]}),(0,j.jsx)(h,{...D}),O&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,"aria-label":`Table rows`,role:`region`,tabIndex:0,children:[(0,j.jsxs)(a,{containerClassName:`overflow-visible`,children:[(0,j.jsx)(v,{className:`sticky top-0 z-10 bg-background`,children:(0,j.jsxs)(i,{children:[O.columns.map(e=>(0,j.jsxs)(s,{children:[(0,j.jsx)(`span`,{children:e.name}),(0,j.jsxs)(`small`,{className:`block font-normal text-muted-foreground`,children:[e.type.toLowerCase(),e.pk?` · primary`:``]})]},e.name)),P&&(0,j.jsx)(s,{children:`Actions`})]})}),(0,j.jsx)(_,{children:O.rows.map((e,t)=>(0,j.jsxs)(i,{children:[O.columns.map(t=>(0,j.jsx)(y,{className:`max-w-sm truncate font-mono`,title:u(e[t.name]),children:u(e[t.name])},t.name)),P&&(0,j.jsx)(y,{children:N?(0,j.jsxs)(`div`,{className:`flex gap-1`,children:[(0,j.jsx)(m,{size:`xs`,variant:`ghost`,onClick:()=>F(`update`,e),disabled:D.loading,children:`Edit`}),(0,j.jsx)(m,{size:`xs`,variant:`destructive`,onClick:()=>F(`delete`,e),disabled:D.loading,children:`Delete`})]}):`Read only`})]},N?String(e[N]):t))})]}),!O.rows.length&&(0,j.jsx)(f,{title:`No rows yet`,children:`Add a row or call a mutation from your app.`})]}),(0,j.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-4 border-t p-4`,children:[(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Up to 50 rows per page · changes are audited`}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(m,{variant:`outline`,disabled:c===void 0||D.loading,onClick:()=>b(void 0),children:`First page`}),(0,j.jsxs)(m,{variant:`outline`,disabled:O.next===null||D.loading,onClick:()=>b(O.next??void 0),children:[`Next page`,(0,j.jsx)(k,{})]})]})]})]}),x&&(0,j.jsx)(o,{modal:x,onClose:()=>T(void 0)})]})}export{M as columnFields,N as default};
|
package/dist/platform/dashboard/_astro/{functions-view.Cf640vhX.js → functions-view.Bsazyfej.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,c as i,d as a,g as o,i as s,l as c,m as l,n as u,p as d,pt as f,r as p,s as m,u as h}from"./common.9pujiaSZ.js";import{a as g,c as _,d as v,f as y,g as b,l as x,o as S,u as C}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,c as i,d as a,g as o,i as s,l as c,m as l,n as u,p as d,pt as f,r as p,s as m,u as h}from"./common.9pujiaSZ.js";import{a as g,c as _,d as v,f as y,g as b,l as x,o as S,u as C}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";import{i as w,t as T}from"./client.BvQ8bQkQ.js";import{n as E,r as D,t as O}from"./input-group.Dsc4z0iT.js";var k={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};k.node;var A=r(k),j={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};j.node;var M=r(j),N=e(t(),1),P=n();function F(e){let t=h(o(e.project,e.env)+`/functions`),[n,r]=(0,N.useState)(``),[i,a]=(0,N.useState)(``),s=Object.entries(t.data?.functions??{}),c=s.find(([e])=>e===i)??s[0],l=new Map;return s.filter(([e])=>e.toLowerCase().includes(n.toLowerCase())).forEach(e=>{let t=e[0].includes(`/`)?e[0].slice(0,e[0].lastIndexOf(`/`)):`Functions`,n=l.get(t)??[];n.push(e),l.set(t,n)}),(0,P.jsxs)(`div`,{className:`flex min-h-full`,children:[(0,P.jsxs)(`section`,{className:`explorer-sidebar`,"aria-label":`Deployed functions`,children:[(0,P.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h1`,{className:`page-title`,children:`Functions`}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length})]}),(0,P.jsxs)(O,{children:[(0,P.jsx)(E,{children:(0,P.jsx)(y,{})}),(0,P.jsx)(D,{"aria-label":`Search functions`,placeholder:`Search functions…`,value:n,onChange:e=>r(e.target.value)})]})]}),(0,P.jsx)(`div`,{className:`space-y-2 px-2`,children:[...l].map(([e,t])=>(0,P.jsxs)(`details`,{open:!0,children:[(0,P.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 px-2 py-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(A,{className:`size-4`}),e]}),(0,P.jsx)(`div`,{className:`space-y-1`,children:t.map(([e,t])=>(0,P.jsxs)(f,{variant:`ghost`,onClick:()=>a(e),className:`w-full justify-between ${c?.[0]===e?`bg-accent`:``}`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()}),(0,P.jsx)(g,{kind:t.kind})]},e))})]},e))}),(0,P.jsxs)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:[`Active release · `,e.env]})]}),(0,P.jsxs)(`section`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(m,{...t}),c?(0,P.jsx)(L,{...e,path:c[0],fn:c[1]},c[0]+`:`+JSON.stringify(c[1])):t.data?(0,P.jsx)(u,{title:`No deployed functions`}):null]})]})}function I(e,t,n){return e===`dev`&&t!==`viewer`&&[`query`,`mutation`,`action`].includes(n)}function L({project:e,env:t,session:n,path:r,fn:m}){let h=a(m.input),y=I(t,n.role,m.kind)&&m.auth!==`internal`,[E,D]=(0,N.useState)(!1),[O,k]=(0,N.useState)(``),[A,j]=(0,N.useState)(),[F,L]=(0,N.useState)(!1),[R,z]=(0,N.useState)(),B=(0,N.useRef)(!0),V=(0,N.useRef)(void 0),H=(0,N.useRef)(void 0);return(0,N.useEffect)(()=>(B.current=!0,()=>{B.current=!1,H.current?.abort(),V.current?.dispose()}),[]),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`detail-header`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:r}),(0,P.jsx)(g,{kind:m.kind}),(0,P.jsx)(S,{status:m.auth,children:m.auth===`required`?`Authentication required`:m.auth})]}),(0,P.jsxs)(f,{type:`submit`,form:`function-run`,disabled:!y||E,children:[(0,P.jsx)(M,{}),E?`Running…`:`Run Function`]})]}),(0,P.jsxs)(_,{defaultValue:`runner`,children:[(0,P.jsxs)(C,{variant:`line`,className:`mx-4 mt-4`,children:[(0,P.jsx)(v,{value:`runner`,children:`Function runner`}),(0,P.jsx)(v,{value:`contract`,children:`Contract`})]}),(0,P.jsx)(x,{value:`runner`,className:`mt-4`,children:(0,P.jsxs)(`div`,{className:`grid lg:grid-cols-2`,children:[(0,P.jsxs)(`section`,{className:`space-y-4 border-b p-4 lg:border-r lg:border-b-0`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Arguments`}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[h.length,` fields`]})]}),(0,P.jsx)(`form`,{id:`function-run`,onSubmit:async n=>{if(n.preventDefault(),!y||E||H.current)return;let i=new AbortController;H.current=i,D(!0),k(``),z(void 0),j(void 0),L(!1);try{let a=c(n.currentTarget,h),s=await d(o(e,t)+`/dev-token`,{},i.signal);if(!B.current||i.signal.aborted)return;V.current=T({url:s.url,getToken:()=>s.token});let l=performance.now(),u=await V.current[m.kind](w(r,m.kind),a);B.current&&!i.signal.aborted&&(j(u),L(!0),z(Math.round(performance.now()-l)))}catch(e){B.current&&!i.signal.aborted&&k(l(e))}finally{V.current?.dispose(),H.current===i&&(H.current=void 0),B.current&&D(!1)}},children:(0,P.jsx)(s,{items:h})}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Development execution only. Mutations and actions can change data. Live subscriptions use the SDK. Writes are not automatically retried. Internal functions are called only by server capabilities or scheduled jobs, not this HTTP runner.`})]}),(0,P.jsxs)(`section`,{className:`space-y-4 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Result`}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:E?`Running…`:O?`Failed`:R===void 0?`Not executed`:`Completed · ${R} ms round trip`})]}),O?(0,P.jsx)(p,{children:O}):F?(0,P.jsx)(i,{value:A}):(0,P.jsx)(u,{title:`Run this function to see its result`,children:(0,P.jsx)(b,{className:`mx-auto mt-3 size-7`})})]})]})}),(0,P.jsxs)(x,{value:`contract`,className:`space-y-4 p-4`,children:[(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Input contract`}),(0,P.jsx)(i,{value:m.input})]}),(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Output contract`}),(0,P.jsx)(i,{value:m.output})]})]})]})]})}export{I as canRun,F as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/services-view.
|
|
2
|
-
import{a as e,r as t,t as n}from"./client.BeKNsjPN.js";import{$ as r,A as i,At as a,B as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,Ot as C,P as w,Q as T,S as E,St as D,T as O,Tt as k,U as A,V as j,W as M,X as N,Y as ee,Z as P,_ as F,_t as I,a as L,at as R,b as z,bt as te,dt as ne,et as B,ft as re,g as V,gt as H,h as ie,ht as ae,it as U,j as oe,k as se,kt as ce,lt as le,m as ue,mt as W,n as de,nt as fe,o as pe,ot as me,p as G,pt as K,q as he,r as ge,rt as _e,s as q,t as ve,tt as ye,u as J,ut as be,v as xe,vt as Se,w as Ce,wt as we,x as Te,xt as Ee,y as Y,yt as De,z as Oe}from"./common.9pujiaSZ.js";var ke={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};ke.node;var Ae=C(ke),je={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};je.node;var Me=C(je),Ne={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Ne.node;var Pe=C(Ne),Fe={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Fe.node;var Ie=C(Fe),Le={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Le.node;var Re=C(Le),ze={name:`logs`,size:24,node:[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]};ze.node;var Be=C(ze),Ve={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};Ve.node;var He=C(Ve),Ue={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};Ue.node;var We=C(Ue),Ge={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ge.node;var Ke=C(Ge),qe={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};qe.node;var Je=C(qe),Ye={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ye.node;var Xe=C(Ye),Ze={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Ze.node;var Qe=C(Ze),$e={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};$e.node;var et=C($e),tt={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};tt.node;var nt=C(tt),X=e(t(),1),rt=X.createContext(void 0);function it(){let e=X.useContext(rt);if(e===void 0)throw Error(we(64));return e}var at=`data-activation-direction`,ot={tabActivationDirection:e=>({[at]:e})},Z=a(),st=X.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,d=e.defaultValue!==void 0,p=X.useRef([]),[h,g]=X.useState(()=>new Map),[y,b]=v({controlled:s,default:r,name:`Tabs`,state:`value`}),x=s!==void 0,[S,C]=X.useState(()=>new Map),w=X.useRef(void 0),E=X.useCallback(e=>ct(S,e),[S]),[D,O]=X.useState(()=>({previousValue:y,tabActivationDirection:`none`})),{previousValue:k,tabActivationDirection:A}=D,j=A,M=!1;k!==y&&(j=lt(k,y,a,S),M=k!=null&&y!=null&&E(y)==null);let P=M?k:y,F=k!==P||A!==j;f(()=>{F&&O({previousValue:P,tabActivationDirection:j})},[P,F,j]);let I=u((e,t)=>{t.activationDirection=lt(y,e,a,S),i?.(e,t),!t.isCanceled&&b(()=>e)}),L=u((e,t)=>{i?.(e,T(t,void 0,void 0,{activationDirection:`none`}))}),R=u((e,t)=>(g(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{g(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),z=X.useCallback(e=>h.get(e),[h]),te=X.useCallback(e=>{for(let t of S.values())if(e===t.value)return t.id},[S]),ne=X.useMemo(()=>({getTabElementBySelectedValue:E,getTabIdByPanelValue:te,getTabPanelIdByValue:z,onValueChange:I,orientation:a,registerMountedTabPanel:R,setTabMap:C,tabActivationDirection:j,value:y}),[E,te,z,I,a,R,C,j,y]),B=X.useMemo(()=>{for(let e of S.values())if(e.value===y)return e},[S,y]),re=X.useMemo(()=>{for(let e of S.values())if(!e.disabled)return e.value},[S]),V=X.useRef(!d),ie=X.useRef(r),ae=X.useRef(d),U=X.useRef(!1);f(()=>{if(x)return;function e(e,t){b(()=>e),O({previousValue:e,tabActivationDirection:`none`}),L(e,t),V.current=!1}if(S.size===0){U.current&&y!==null&&!w.current?.isConnected&&e(null,N);return}U.current=!0,w.current=S.keys().next().value;let t=B?.disabled,n=B==null&&y!==null;if(!t&&y===ie.current&&(ae.current=!1),ae.current&&t&&y===ie.current)return;let r=V.current;if(t||n){let n=re??null;if(y===n){V.current=!1;return}let i=N;r?i=ee:t&&(i=_),e(n,i)}else r&&B!=null&&(L(y,ee),V.current=!1)},[re,x,L,B,b,S,y]);let oe=H(`div`,e,{state:{orientation:a,tabActivationDirection:j},ref:t,props:l,stateAttributesMapping:ot});return(0,Z.jsx)(rt.Provider,{value:ne,children:(0,Z.jsx)(m,{elementsRef:p,children:oe})})});function ct(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function lt(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=ct(r,e),c=ct(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var ut=`data-composite-item-active`;function dt(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=c(),{ref:i,index:a}=M(e),o=n===a,s=X.useRef(null),l=De(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:l,index:a}}var ft=X.createContext(void 0);function pt(){let e=X.useContext(ft);if(e===void 0)throw Error(we(65));return e}var mt=X.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:l,...d}=e,{value:p,getTabPanelIdByValue:m,onValueChange:h,orientation:g,tabActivationDirection:_}=it(),{activateOnFocus:v,registerTabResizeObserverElement:y,tabsListElement:b}=pt(),{highlightedIndex:x,onHighlightedIndexChange:S}=c(),C=re(o),{compositeProps:w,compositeRef:E,index:D}=dt({metadata:X.useMemo(()=>({disabled:r,id:C,value:a}),[r,C,a])}),O=a===p,k=X.useRef(!1),A=X.useRef(null),j=u(e=>{A.current?.(),A.current=e?y(e):null});f(()=>{if(k.current){k.current=!1;return}if(!(O&&D>-1&&x!==D))return;let e=b;if(e!=null){let t=le(Ee(e));if(t&&be(e,t))return}r||S(D)},[O,D,x,S,r,b]);let{getButtonProps:M,buttonRef:N}=te({disabled:r,native:s,focusableWhenDisabled:!0}),ee=m(a),F=X.useRef(!1),I=X.useRef(!1);function L(e){h(a,T(P,e.nativeEvent,void 0,{activationDirection:`none`}))}function R(e){O||r||L(e)}function z(e){O||r||v&&(!F.current||I.current)&&L(e)}function ne(e){if(O||r)return;F.current=!0,I.current=e.button===0;let t=Ee(e.currentTarget);function n(){F.current=!1,I.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return H(`button`,e,{state:{disabled:r,active:O,orientation:g,tabActivationDirection:_},ref:[t,N,E,j],props:[w,{role:`tab`,"aria-controls":ee,"aria-selected":O,id:C,onClick:R,onFocus:z,onPointerDown:ne,[ut]:O?``:void 0,onKeyDownCapture(){k.current=!0}},d,M],stateAttributesMapping:ot})}),ht=`data-index`,gt={...ot,...me},_t=X.forwardRef(function(e,t){let{className:n,value:i,render:a,keepMounted:o=!1,style:s,...c}=e,{value:l,getTabIdByPanelValue:u,orientation:d,tabActivationDirection:p,registerMountedTabPanel:m}=it(),h=re(),{ref:g,index:_}=M(),v=i===l,{mounted:y,transitionStatus:b,setMounted:x}=r(v),S=!y,C=u(i),w={hidden:S,orientation:d,tabActivationDirection:p,transitionStatus:b},T=X.useRef(null),E=H(`div`,e,{state:w,ref:[t,g,T],props:[{"aria-labelledby":C,hidden:S,id:h,role:`tabpanel`,tabIndex:v?0:-1,inert:A(!v),[ht]:_},c],stateAttributesMapping:gt});return B({open:v,ref:T,onComplete(){v||x(!1)}}),f(()=>{if(!(h==null||S&&!o))return m(i,h)},[S,o,i,h,m]),o||y?E:null});function vt(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:d=!1,stopEventPropagation:m,disabledIndices:_,modifierKeys:v=I}=e,[b,S]=X.useState(0),C=r!=null,T=X.useRef(null),E=De(T,l),D=X.useRef([]),O=X.useRef(!1),k=X.useRef(null),A=s??b,M=u((e,t=!1)=>{if(k.current=D.current[e]??null,(c??S)(e),t){let t=D.current[e];j(T.current,t,a,n)}}),N=u(e=>{if(e.size===0)return;if(O.current){let e=D.current,t=e.indexOf(k.current);if(t===-1){let t=e[A];!t||R(e,A,_)?M(yt(e,_)):k.current=t}else t!==A&&M(t);return}O.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)M(i);else if(R(t,A,_)){let e=ye(t,{disabledIndices:_});U(t,e)||M(e)}j(T.current,r,a,n)});f(()=>{if(_==null||s!=null||!O.current)return;let e=D.current;if(R(e,A,_)){let t=ye(e,{disabledIndices:_});U(e,t)||M(t)}},[_,s,A,D,M]);let ee=u((e,t,n)=>i?i(e,t,n,D):n),P=u(e=>{let s=e.key===`Home`||e.key===`End`;if(!y.has(e.key)||!d&&s||bt(e,v)||!T.current)return;let c=a===`rtl`,l=c?w:p,u=c?p:w,f=n===`vertical`?x:l,b=n===`vertical`?g:u,S=ne(e.nativeEvent);if(S!=null&&o(S)&&!h(S)){let t=S.selectionStart,n=S.selectionEnd,r=S.value;if(t==null||e.shiftKey||t!==n||e.key!==b&&t<r.length||e.key!==f&&t>0)return}let E=A,O=_e(D,_),k=fe(D,_);r!=null&&(E=r({disabledIndices:_,elementsRef:D,event:e,highlightedIndex:A,loopFocus:t,maxIndex:k,minIndex:O,onLoop:ee,orientation:n,rtl:c}));let j=n!==`vertical`&&e.key===l||n!==`horizontal`&&e.key===`ArrowDown`,N=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowUp`;d&&(e.key===`Home`?E=O:e.key===`End`&&(E=k)),E===A&&(j||N)&&(t&&E===k&&j?(E=O,i&&(E=i(e,A,E,D))):t&&E===O&&N?(E=k,i&&(E=i(e,A,E,D))):E=ye(D.current,{startingIndex:E,decrement:N,disabledIndices:_})),E!==A&&!U(D.current,E)&&(m&&e.stopPropagation(),(C||s||j||N)&&e.preventDefault(),M(E,!0),queueMicrotask(()=>{D.current[E]?.focus()}))});return{props:{ref:E,onFocus(e){let t=T.current,n=ne(e.nativeEvent);t&&n!=null&&o(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:P},highlightedIndex:A,onHighlightedIndexChange:M,elementsRef:D,onMapChange:N,relayKeyboardEvent:P}}function yt(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!R(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function bt(e,t){for(let n of Oe)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function xt(e){let{render:t,className:n,style:r,refs:i=I,props:a=I,state:o=Se,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:h,onMapChange:g,stopEventPropagation:_=!0,rootRef:v,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:O,elementsRef:k,onMapChange:A,relayKeyboardEvent:j}=vt({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:v,stopEventPropagation:_,enableHomeAndEndKeys:h,direction:b(),disabledIndices:y,modifierKeys:x}),M=H(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),N=X.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:O,highlightItemOnHover:S,relayKeyboardEvent:j}),[E,O,S,j]);return(0,Z.jsx)(D.Provider,{value:N,children:(0,Z.jsx)(m,{elementsRef:k,onMapChange:e=>{g?.(e),A(e)},children:M})})}var St=X.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:d}=it(),[p,m]=X.useState(0),[h,g]=X.useState(null),_=X.useRef(new Set),v=X.useRef(new Set),y=X.useRef(null);f(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.forEach(e=>{e()})});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h]);let b=u(e=>(_.current.add(e),()=>{_.current.delete(e)})),x=u(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),S={orientation:c,tabActivationDirection:d},C={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},w=X.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:b,registerTabResizeObserverElement:x,tabsListElement:h}),[n,b,x,h]);return(0,Z.jsx)(ft.Provider,{value:w,children:(0,Z.jsx)(xt,{render:a,className:r,style:o,state:S,refs:[t,g],props:[C,s],stateAttributesMapping:ot,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:m,onMapChange:l,disabledIndices:I})})}),Ct=n();function wt({className:e,orientation:t=`horizontal`,...n}){return(0,Z.jsx)(st,{"data-slot":`tabs`,"data-orientation":t,className:W(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Tt=ae(`group/tabs-list inline-flex w-fit items-center justify-center rounded-none p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Et({className:e,variant:t=`default`,...n}){return(0,Z.jsx)(St,{"data-slot":`tabs-list`,"data-variant":t,className:W(Tt({variant:t}),e),...n})}function Dt({className:e,...t}){return(0,Z.jsx)(mt,{"data-slot":`tabs-trigger`,className:W(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-none border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Ot({className:e,...t}){return(0,Z.jsx)(_t,{"data-slot":`tabs-content`,className:W(`flex-1 text-xs/relaxed outline-none`,e),...t})}function kt(e){return H(e.defaultTagName??`div`,e,e)}var At=ae(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-none border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,success:`border-emerald-600/20 bg-emerald-100/50 text-emerald-700 dark:border-emerald-400/20 dark:bg-emerald-900/50 dark:text-emerald-200`,warning:`border-amber-600/20 bg-amber-100/50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-900/50 dark:text-amber-200`,info:`border-blue-600/20 bg-blue-100/50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-900/50 dark:text-blue-200`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function jt({className:e,variant:t=`default`,render:n,...r}){return kt({defaultTagName:`span`,props:k({className:W(At({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var Mt=new Map([...[`ready`,`active`,`enabled`,`ok`,`completed`,`development`].map(e=>[e,`success`]),...[`pending`,`paused`,`activating`,`restoring`,`incomplete`,`required`].map(e=>[e,`warning`]),...[`uploading`,`running`,`queued`,`enqueued`,`production`,`public registration`,`public`].map(e=>[e,`info`]),...[`error`,`failed`,`blocked`,`unavailable`].map(e=>[e,`destructive`])]);function Q({status:e,children:t}){return(0,Z.jsx)(jt,{variant:Mt.get(e.toLowerCase())??`secondary`,children:t??e})}var Nt={query:`bg-yellow-100/50 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-200`,mutation:`bg-blue-100/50 text-blue-700 dark:bg-blue-900/50 dark:text-blue-200`,action:`bg-purple-100/50 text-purple-700 dark:bg-purple-900/50 dark:text-purple-200`};function Pt({kind:e}){return(0,Z.jsx)(jt,{variant:`secondary`,className:Nt[e],children:e})}function Ft(e){let[t,n]=(0,X.useState)(!1);return(0,Z.jsxs)(`details`,{className:`rounded-lg border`,onToggle:e=>n(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer p-4 font-medium`,children:`Deployment history`}),t&&(0,Z.jsx)(`div`,{className:`p-4 pt-0`,children:(0,Z.jsx)(It,{...e})})]})}function It(e){let[t,n]=(0,X.useState)(),[r,i]=(0,X.useState)(),a=V(e.project,e.env),o=V(e.project,e.env),s=J(a+`/history`),c=e.session.role!==`viewer`,l=async(t,n)=>{let r=n?V(e.project,`prod`):o,a=await G(r+`/health`);i({title:n?`Promote backend to production`:`Rollback backend`,description:`Activate this exact backend hash after native schema/job validation. Data, files and settings stay unchanged. Frontend is not published by this button; use the CLI release flow for that.`,productionId:n||e.env===`prod`?e.project.id:void 0,submit:async()=>{await G(r+(n?`/release-promote`:`/release-rollback`),{hash:t,expected:a.active,confirm:e.project.id}),s.refresh(),e.refresh()}})},[u,d]=(0,X.useState)();return(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(q,{loading:s.loading,error:u||s.error}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`First published`}),(0,Z.jsx)(z,{children:`Backend hash`}),(0,Z.jsx)(z,{children:`Actions`})]})}),(0,Z.jsx)(xe,{children:s.data?.map(t=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:new Date(t.at).toLocaleString()}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(`code`,{className:`text-xs`,children:t.hash.slice(0,12)}),e.active===t.hash&&(0,Z.jsx)(Q,{status:`Active`})]}),(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>n(t.hash),children:`View contracts`}),c&&e.active!==t.hash&&(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void l(t.hash,!1).catch(e=>d(e.message)),children:`Rollback backend`}),c&&e.env===`dev`&&(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void l(t.hash,!0).catch(e=>d(e.message)),children:`Promote backend`})]})})]},t.hash))})]}),t&&(0,Z.jsx)(Lt,{path:a,hash:t,close:()=>n(void 0)}),r&&(0,Z.jsx)(L,{modal:r,onClose:()=>i(void 0)})]})}function Lt({path:e,hash:t,close:n}){let r=J(e+`/release?hash=`+t);return(0,Z.jsx)(s,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(Ce,{className:`max-h-[80vh] overflow-auto`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(l,{children:`Backend release`}),(0,Z.jsx)(O,{className:`break-all`,children:t})]}),(0,Z.jsx)(q,{...r}),r.data&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`font-medium`,children:`Tables`}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`Table`}),(0,Z.jsx)(z,{children:`Fields`})]})}),(0,Z.jsx)(xe,{children:Object.entries(r.data.schema).map(([e,t])=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:e}),(0,Z.jsx)(Y,{children:Object.keys(t.document.properties??{}).join(`, `)||`No declared fields`})]},e))})]}),(0,Z.jsx)(`h3`,{className:`font-medium`,children:`Functions`}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`Function`}),(0,Z.jsx)(z,{children:`Kind`}),(0,Z.jsx)(z,{children:`Access`})]})}),(0,Z.jsx)(xe,{children:Object.entries(r.data.manifest.functions).map(([e,t])=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:e}),(0,Z.jsx)(Y,{children:(0,Z.jsx)(Pt,{kind:t.kind})}),(0,Z.jsx)(Y,{children:(0,Z.jsx)(Q,{status:t.auth})})]},e))})]})]})]})})}function Rt({className:e,size:t=`default`,...n}){return(0,Z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:W(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-none bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none`,e),...n})}function zt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-header`,className:W(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-none px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function Bt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:W(`font-heading text-sm font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function Vt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:W(`px-(--card-spacing)`,e),...t})}function Ht({project:e,env:t,session:n,connect:r}){let i=J(V(e,t)+`/health`),a=J(V(e,t)+`/settings`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Health`}),(0,Z.jsx)(q,{loading:i.loading||a.loading,error:i.error||a.error}),i.data&&a.data&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h2`,{className:`section-title`,children:`Summary`}),(0,Z.jsx)(Rt,{children:(0,Z.jsxs)(Vt,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{status:t===`dev`?`Development`:`Production`}),(0,Z.jsx)(`strong`,{children:e.name})]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`Cloudflare · Durable Objects · SQLite`}),(0,Z.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`Release `,i.data.active?.slice(0,12)??`not deployed`]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`Cloud URL`}),(0,Z.jsx)(`code`,{className:`block select-all break-all text-xs`,children:a.data.url}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Z.jsx)(Q,{status:i.data.status}),i.data.connections,` connections · `,i.data.subscriptions,` `,`subscriptions`]})]})]})}),(0,Z.jsx)(Ft,{project:e,env:t,session:n,active:i.data.active,refresh:i.refresh}),(0,Z.jsx)(K,{variant:`outline`,onClick:r,children:`Connect SDK`})]})]})}function Ut({project:e,env:t}){let n=J(V(e,t)+`/schema`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Schema`}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:(0,Z.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:n.refresh,disabled:n.loading,children:(0,Z.jsx)(Je,{})})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Defined in code; validated documents and indexes activate atomically. System tables are hidden.`}),(0,Z.jsx)(q,{...n}),n.data?.tables.map(e=>(0,Z.jsxs)(Rt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(Bt,{className:`font-mono`,children:e.name})})}),(0,Z.jsxs)(Vt,{className:`space-y-4`,children:[(0,Z.jsx)(pe,{rows:e.columns.map(e=>({Field:e.name,Type:e.type,Required:!!e.notnull,Primary:!!e.pk,Default:e.dflt_value})),columns:[`Field`,`Type`,`Required`,`Primary`,`Default`]}),(0,Z.jsx)(pe,{rows:Object.entries(e.indexes).map(([e,t])=>({Index:e,Fields:t.join(`, `)})),columns:[`Index`,`Fields`]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Document contract`}),(0,Z.jsx)(`pre`,{className:`code-block mt-3`,children:JSON.stringify(e.document,null,2)})]})]})]},e.name)),n.data&&!n.data.tables.length&&(0,Z.jsx)(de,{title:`No application tables`})]})}function Wt({project:e,env:t}){let n=J(V(e,t)+`/logs`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Logs`}),(0,Z.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:n.refresh,disabled:n.loading,children:(0,Z.jsx)(Je,{})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Last 100 invocation summaries. Successful queries are held in memory and disappear on hibernation/restart; writes and failures are persisted. Not Cloudflare Tail logs or billing analytics.`}),(0,Z.jsx)(q,{...n}),n.data&&(n.data.length?(0,Z.jsx)(pe,{rows:n.data,renderCell:(e,t)=>e===`kind`&&[`query`,`mutation`,`action`].includes(String(t))?(0,Z.jsx)(Pt,{kind:t}):e===`status`?(0,Z.jsx)(Q,{status:t===`ok`?`ok`:`error`,children:ie(t)}):e===`at`&&typeof t==`number`?new Date(t).toLocaleString():ie(t),columns:[`at`,`path`,`kind`,`status`,`ms`],labels:{at:`Time`,path:`Function`,kind:`Type`,status:`Status`,ms:`Duration (ms)`}}):(0,Z.jsx)(de,{title:`No recent function calls`}))]})}var Gt=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Kt=function(e){return`/`+e},qt={},Jt=function(e){return e.pathname.endsWith(`.css`)},Yt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},$=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))},i=function(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)},a,o=document.querySelector(`meta[property=csp-nonce]`),s=o?.nonce||o?.getAttribute(`nonce`);r=e(t.map(e=>{e=Kt(e,n);let t=i(e),r=Jt(t);return Yt(qt,t.href,()=>{if(a===void 0){a={all:new Set,styles:new Set};let e=document.getElementsByTagName(`link`);for(let t=e.length-1;t>=0;t--){let n=e[t];a.all.add(n.href),n.rel===`stylesheet`&&a.styles.add(n.href)}}if((r?a.styles:a.all).has(t.href))return;let e=document.createElement(`link`);if(e.rel=r?`stylesheet`:Gt,r||(e.as=`script`),e.crossOrigin=``,e.href=t.href,s&&e.setAttribute(`nonce`,s),document.head.appendChild(e),r)return new Promise((n,r)=>{e.addEventListener(`load`,n),e.addEventListener(`error`,()=>r(Error(`Unable to preload CSS for ${t}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Xt=(0,X.lazy)(()=>$(()=>import(`./services-view.DhwKE_RK.js`).then(e=>({default:e.FilesView})),__vite__mapDeps([0,1,2,3]))),Zt=(0,X.lazy)(()=>$(()=>import(`./services-view.DhwKE_RK.js`).then(e=>({default:e.SchedulesView})),__vite__mapDeps([0,1,2,3]))),Qt=(0,X.lazy)(()=>$(()=>import(`./data-view.BCmdi_cs.js`),__vite__mapDeps([4,1,2,5]))),$t=(0,X.lazy)(()=>$(()=>import(`./functions-view.Cf640vhX.js`),__vite__mapDeps([6,1,2,3,5]))),en=(0,X.lazy)(()=>$(()=>import(`./ai-view.DxgwI4OB.js`),__vite__mapDeps([7,1,2,3]))),tn=(0,X.lazy)(()=>$(()=>import(`./auth-view.C16WPVOx.js`),__vite__mapDeps([8,1,2]))),nn=(0,X.lazy)(()=>$(()=>import(`./settings-view.Dsc34AAW.js`),__vite__mapDeps([9,1,2]))),rn=(0,X.lazy)(()=>$(()=>import(`./sdk-view.Cs96E0YV.js`),__vite__mapDeps([10,1,2]))),an=[{key:`health`,label:`Health`,icon:Ae},{key:`data`,label:`Data`,icon:Ie},{key:`schema`,label:`Schema`,icon:Me},{key:`functions`,label:`Functions`,icon:Pe},{key:`files`,label:`Files`,icon:Re},{key:`schedules`,label:`Schedules`,icon:nt},{key:`ai`,label:`AI`,icon:Xe},{key:`auth`,label:`Auth`,icon:et},{key:`logs`,label:`Logs`,icon:Be}],on=(0,X.lazy)(()=>$(()=>import(`./cli-approval.emPTVRqn.js`),__vite__mapDeps([11,1,2])));function sn(){return new URLSearchParams(location.search).has(`cli`)?(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`p`,{children:`Loading…`}),children:(0,Z.jsx)(on,{})}):(0,Z.jsx)(cn,{})}function cn(){let[e,t]=(0,X.useState)(),[n,r]=(0,X.useState)([]),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(`dev`),[l,u]=(0,X.useState)(`health`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!0),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=new AbortController;return v(localStorage.getItem(`flare.sidebar`)===`collapsed`),Promise.all([G(`session`,void 0,e.signal),G(`projects`,void 0,e.signal)]).then(([n,i])=>{e.signal.aborted||(t(n),r(i),o(i.find(e=>e.id===localStorage.getItem(`flare.project`))??i[0]),m(!1))}).catch(t=>{e.signal.aborted||(f(ue(t)),m(!1))}),()=>e.abort()},[]);let y=e=>{let t=n.find(t=>t.id===e);t&&(o(t),c(`dev`),u(`health`),g(void 0),localStorage.setItem(`flare.project`,e))},b=()=>g({title:`Create project`,description:`Creates separate development and production environments.`,content:(0,Z.jsxs)(se,{children:[(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-name`,children:`Project name`}),(0,Z.jsx)(he,{id:`project-name`,name:`name`,required:!0,maxLength:100,placeholder:`CRM`})]}),(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-alias`,children:`Short URL name (optional)`}),(0,Z.jsx)(he,{id:`project-alias`,name:`alias`,maxLength:48,pattern:`[a-z][a-z0-9]*(?:-[a-z0-9]+)*`,placeholder:`crm`})]}),(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-origins`,children:`Allowed frontend origins · one per line`}),(0,Z.jsx)(oe,{id:`project-origins`,name:`origins`,placeholder:`http://127.0.0.1:5173`})]})]}),submit:async e=>{let t=new FormData(e),n=await G(`projects`,{name:t.get(`name`),alias:t.get(`alias`)||void 0,origins:[location.origin,...String(t.get(`origins`)).split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/services-view.C1FjN8NY.js","_astro/client.BeKNsjPN.js","_astro/common.9pujiaSZ.js","_astro/client.BvQ8bQkQ.js","_astro/data-view.Bw2dG8Wg.js","_astro/input-group.Dsc4z0iT.js","_astro/functions-view.Bsazyfej.js","_astro/ai-view.De8j8CVD.js","_astro/auth-view.C9j0-OzH.js","_astro/settings-view.DZldw4Vy.js","_astro/sdk-view.vdDnLZ5g.js","_astro/cli-approval.emPTVRqn.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,r as t,t as n}from"./client.BeKNsjPN.js";import{$ as r,A as i,At as a,B as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,Ot as C,P as w,Q as T,S as E,St as D,T as O,Tt as k,U as A,V as j,W as M,X as N,Y as ee,Z as P,_ as F,_t as I,a as L,at as R,b as z,bt as te,dt as ne,et as B,ft as re,g as V,gt as H,h as ie,ht as ae,it as U,j as oe,k as se,kt as ce,lt as le,m as ue,mt as W,n as de,nt as fe,o as pe,ot as me,p as G,pt as K,q as he,r as ge,rt as _e,s as q,t as ve,tt as ye,u as J,ut as be,v as xe,vt as Se,w as Ce,wt as we,x as Te,xt as Ee,y as Y,yt as De,z as Oe}from"./common.9pujiaSZ.js";var ke={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};ke.node;var Ae=C(ke),je={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};je.node;var Me=C(je),Ne={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Ne.node;var Pe=C(Ne),Fe={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};Fe.node;var Ie=C(Fe),Le={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Le.node;var Re=C(Le),ze={name:`logs`,size:24,node:[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]};ze.node;var Be=C(ze),Ve={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};Ve.node;var He=C(Ve),Ue={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};Ue.node;var We=C(Ue),Ge={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ge.node;var Ke=C(Ge),qe={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};qe.node;var Je=C(qe),Ye={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Ye.node;var Xe=C(Ye),Ze={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Ze.node;var Qe=C(Ze),$e={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};$e.node;var et=C($e),tt={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};tt.node;var nt=C(tt),X=e(t(),1),rt=X.createContext(void 0);function it(){let e=X.useContext(rt);if(e===void 0)throw Error(we(64));return e}var at=`data-activation-direction`,ot={tabActivationDirection:e=>({[at]:e})},Z=a(),st=X.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,d=e.defaultValue!==void 0,p=X.useRef([]),[h,g]=X.useState(()=>new Map),[y,b]=v({controlled:s,default:r,name:`Tabs`,state:`value`}),x=s!==void 0,[S,C]=X.useState(()=>new Map),w=X.useRef(void 0),E=X.useCallback(e=>ct(S,e),[S]),[D,O]=X.useState(()=>({previousValue:y,tabActivationDirection:`none`})),{previousValue:k,tabActivationDirection:A}=D,j=A,M=!1;k!==y&&(j=lt(k,y,a,S),M=k!=null&&y!=null&&E(y)==null);let P=M?k:y,F=k!==P||A!==j;f(()=>{F&&O({previousValue:P,tabActivationDirection:j})},[P,F,j]);let I=u((e,t)=>{t.activationDirection=lt(y,e,a,S),i?.(e,t),!t.isCanceled&&b(()=>e)}),L=u((e,t)=>{i?.(e,T(t,void 0,void 0,{activationDirection:`none`}))}),R=u((e,t)=>(g(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{g(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),z=X.useCallback(e=>h.get(e),[h]),te=X.useCallback(e=>{for(let t of S.values())if(e===t.value)return t.id},[S]),ne=X.useMemo(()=>({getTabElementBySelectedValue:E,getTabIdByPanelValue:te,getTabPanelIdByValue:z,onValueChange:I,orientation:a,registerMountedTabPanel:R,setTabMap:C,tabActivationDirection:j,value:y}),[E,te,z,I,a,R,C,j,y]),B=X.useMemo(()=>{for(let e of S.values())if(e.value===y)return e},[S,y]),re=X.useMemo(()=>{for(let e of S.values())if(!e.disabled)return e.value},[S]),V=X.useRef(!d),ie=X.useRef(r),ae=X.useRef(d),U=X.useRef(!1);f(()=>{if(x)return;function e(e,t){b(()=>e),O({previousValue:e,tabActivationDirection:`none`}),L(e,t),V.current=!1}if(S.size===0){U.current&&y!==null&&!w.current?.isConnected&&e(null,N);return}U.current=!0,w.current=S.keys().next().value;let t=B?.disabled,n=B==null&&y!==null;if(!t&&y===ie.current&&(ae.current=!1),ae.current&&t&&y===ie.current)return;let r=V.current;if(t||n){let n=re??null;if(y===n){V.current=!1;return}let i=N;r?i=ee:t&&(i=_),e(n,i)}else r&&B!=null&&(L(y,ee),V.current=!1)},[re,x,L,B,b,S,y]);let oe=H(`div`,e,{state:{orientation:a,tabActivationDirection:j},ref:t,props:l,stateAttributesMapping:ot});return(0,Z.jsx)(rt.Provider,{value:ne,children:(0,Z.jsx)(m,{elementsRef:p,children:oe})})});function ct(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function lt(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=ct(r,e),c=ct(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var ut=`data-composite-item-active`;function dt(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=c(),{ref:i,index:a}=M(e),o=n===a,s=X.useRef(null),l=De(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:l,index:a}}var ft=X.createContext(void 0);function pt(){let e=X.useContext(ft);if(e===void 0)throw Error(we(65));return e}var mt=X.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:l,...d}=e,{value:p,getTabPanelIdByValue:m,onValueChange:h,orientation:g,tabActivationDirection:_}=it(),{activateOnFocus:v,registerTabResizeObserverElement:y,tabsListElement:b}=pt(),{highlightedIndex:x,onHighlightedIndexChange:S}=c(),C=re(o),{compositeProps:w,compositeRef:E,index:D}=dt({metadata:X.useMemo(()=>({disabled:r,id:C,value:a}),[r,C,a])}),O=a===p,k=X.useRef(!1),A=X.useRef(null),j=u(e=>{A.current?.(),A.current=e?y(e):null});f(()=>{if(k.current){k.current=!1;return}if(!(O&&D>-1&&x!==D))return;let e=b;if(e!=null){let t=le(Ee(e));if(t&&be(e,t))return}r||S(D)},[O,D,x,S,r,b]);let{getButtonProps:M,buttonRef:N}=te({disabled:r,native:s,focusableWhenDisabled:!0}),ee=m(a),F=X.useRef(!1),I=X.useRef(!1);function L(e){h(a,T(P,e.nativeEvent,void 0,{activationDirection:`none`}))}function R(e){O||r||L(e)}function z(e){O||r||v&&(!F.current||I.current)&&L(e)}function ne(e){if(O||r)return;F.current=!0,I.current=e.button===0;let t=Ee(e.currentTarget);function n(){F.current=!1,I.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return H(`button`,e,{state:{disabled:r,active:O,orientation:g,tabActivationDirection:_},ref:[t,N,E,j],props:[w,{role:`tab`,"aria-controls":ee,"aria-selected":O,id:C,onClick:R,onFocus:z,onPointerDown:ne,[ut]:O?``:void 0,onKeyDownCapture(){k.current=!0}},d,M],stateAttributesMapping:ot})}),ht=`data-index`,gt={...ot,...me},_t=X.forwardRef(function(e,t){let{className:n,value:i,render:a,keepMounted:o=!1,style:s,...c}=e,{value:l,getTabIdByPanelValue:u,orientation:d,tabActivationDirection:p,registerMountedTabPanel:m}=it(),h=re(),{ref:g,index:_}=M(),v=i===l,{mounted:y,transitionStatus:b,setMounted:x}=r(v),S=!y,C=u(i),w={hidden:S,orientation:d,tabActivationDirection:p,transitionStatus:b},T=X.useRef(null),E=H(`div`,e,{state:w,ref:[t,g,T],props:[{"aria-labelledby":C,hidden:S,id:h,role:`tabpanel`,tabIndex:v?0:-1,inert:A(!v),[ht]:_},c],stateAttributesMapping:gt});return B({open:v,ref:T,onComplete(){v||x(!1)}}),f(()=>{if(!(h==null||S&&!o))return m(i,h)},[S,o,i,h,m]),o||y?E:null});function vt(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:d=!1,stopEventPropagation:m,disabledIndices:_,modifierKeys:v=I}=e,[b,S]=X.useState(0),C=r!=null,T=X.useRef(null),E=De(T,l),D=X.useRef([]),O=X.useRef(!1),k=X.useRef(null),A=s??b,M=u((e,t=!1)=>{if(k.current=D.current[e]??null,(c??S)(e),t){let t=D.current[e];j(T.current,t,a,n)}}),N=u(e=>{if(e.size===0)return;if(O.current){let e=D.current,t=e.indexOf(k.current);if(t===-1){let t=e[A];!t||R(e,A,_)?M(yt(e,_)):k.current=t}else t!==A&&M(t);return}O.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)M(i);else if(R(t,A,_)){let e=ye(t,{disabledIndices:_});U(t,e)||M(e)}j(T.current,r,a,n)});f(()=>{if(_==null||s!=null||!O.current)return;let e=D.current;if(R(e,A,_)){let t=ye(e,{disabledIndices:_});U(e,t)||M(t)}},[_,s,A,D,M]);let ee=u((e,t,n)=>i?i(e,t,n,D):n),P=u(e=>{let s=e.key===`Home`||e.key===`End`;if(!y.has(e.key)||!d&&s||bt(e,v)||!T.current)return;let c=a===`rtl`,l=c?w:p,u=c?p:w,f=n===`vertical`?x:l,b=n===`vertical`?g:u,S=ne(e.nativeEvent);if(S!=null&&o(S)&&!h(S)){let t=S.selectionStart,n=S.selectionEnd,r=S.value;if(t==null||e.shiftKey||t!==n||e.key!==b&&t<r.length||e.key!==f&&t>0)return}let E=A,O=_e(D,_),k=fe(D,_);r!=null&&(E=r({disabledIndices:_,elementsRef:D,event:e,highlightedIndex:A,loopFocus:t,maxIndex:k,minIndex:O,onLoop:ee,orientation:n,rtl:c}));let j=n!==`vertical`&&e.key===l||n!==`horizontal`&&e.key===`ArrowDown`,N=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowUp`;d&&(e.key===`Home`?E=O:e.key===`End`&&(E=k)),E===A&&(j||N)&&(t&&E===k&&j?(E=O,i&&(E=i(e,A,E,D))):t&&E===O&&N?(E=k,i&&(E=i(e,A,E,D))):E=ye(D.current,{startingIndex:E,decrement:N,disabledIndices:_})),E!==A&&!U(D.current,E)&&(m&&e.stopPropagation(),(C||s||j||N)&&e.preventDefault(),M(E,!0),queueMicrotask(()=>{D.current[E]?.focus()}))});return{props:{ref:E,onFocus(e){let t=T.current,n=ne(e.nativeEvent);t&&n!=null&&o(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:P},highlightedIndex:A,onHighlightedIndexChange:M,elementsRef:D,onMapChange:N,relayKeyboardEvent:P}}function yt(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!R(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function bt(e,t){for(let n of Oe)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function xt(e){let{render:t,className:n,style:r,refs:i=I,props:a=I,state:o=Se,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:h,onMapChange:g,stopEventPropagation:_=!0,rootRef:v,disabledIndices:y,modifierKeys:x,highlightItemOnHover:S=!1,tag:C=`div`,...w}=e,{props:T,highlightedIndex:E,onHighlightedIndexChange:O,elementsRef:k,onMapChange:A,relayKeyboardEvent:j}=vt({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:v,stopEventPropagation:_,enableHomeAndEndKeys:h,direction:b(),disabledIndices:y,modifierKeys:x}),M=H(C,e,{state:o,ref:i,props:[T,...a,w],stateAttributesMapping:s}),N=X.useMemo(()=>({highlightedIndex:E,onHighlightedIndexChange:O,highlightItemOnHover:S,relayKeyboardEvent:j}),[E,O,S,j]);return(0,Z.jsx)(D.Provider,{value:N,children:(0,Z.jsx)(m,{elementsRef:k,onMapChange:e=>{g?.(e),A(e)},children:M})})}var St=X.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:d}=it(),[p,m]=X.useState(0),[h,g]=X.useState(null),_=X.useRef(new Set),v=X.useRef(new Set),y=X.useRef(null);f(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.forEach(e=>{e()})});return y.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[h]);let b=u(e=>(_.current.add(e),()=>{_.current.delete(e)})),x=u(e=>(v.current.add(e),y.current?.observe(e),()=>{v.current.delete(e),y.current?.unobserve(e)})),S={orientation:c,tabActivationDirection:d},C={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},w=X.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:b,registerTabResizeObserverElement:x,tabsListElement:h}),[n,b,x,h]);return(0,Z.jsx)(ft.Provider,{value:w,children:(0,Z.jsx)(xt,{render:a,className:r,style:o,state:S,refs:[t,g],props:[C,s],stateAttributesMapping:ot,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:m,onMapChange:l,disabledIndices:I})})}),Ct=n();function wt({className:e,orientation:t=`horizontal`,...n}){return(0,Z.jsx)(st,{"data-slot":`tabs`,"data-orientation":t,className:W(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Tt=ae(`group/tabs-list inline-flex w-fit items-center justify-center rounded-none p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Et({className:e,variant:t=`default`,...n}){return(0,Z.jsx)(St,{"data-slot":`tabs-list`,"data-variant":t,className:W(Tt({variant:t}),e),...n})}function Dt({className:e,...t}){return(0,Z.jsx)(mt,{"data-slot":`tabs-trigger`,className:W(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-none border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Ot({className:e,...t}){return(0,Z.jsx)(_t,{"data-slot":`tabs-content`,className:W(`flex-1 text-xs/relaxed outline-none`,e),...t})}function kt(e){return H(e.defaultTagName??`div`,e,e)}var At=ae(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-none border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,success:`border-emerald-600/20 bg-emerald-100/50 text-emerald-700 dark:border-emerald-400/20 dark:bg-emerald-900/50 dark:text-emerald-200`,warning:`border-amber-600/20 bg-amber-100/50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-900/50 dark:text-amber-200`,info:`border-blue-600/20 bg-blue-100/50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-900/50 dark:text-blue-200`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function jt({className:e,variant:t=`default`,render:n,...r}){return kt({defaultTagName:`span`,props:k({className:W(At({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var Mt=new Map([...[`ready`,`active`,`enabled`,`ok`,`completed`,`development`].map(e=>[e,`success`]),...[`pending`,`paused`,`activating`,`restoring`,`incomplete`,`required`].map(e=>[e,`warning`]),...[`uploading`,`running`,`queued`,`enqueued`,`production`,`public registration`,`public`].map(e=>[e,`info`]),...[`error`,`failed`,`blocked`,`unavailable`].map(e=>[e,`destructive`])]);function Q({status:e,children:t}){return(0,Z.jsx)(jt,{variant:Mt.get(e.toLowerCase())??`secondary`,children:t??e})}var Nt={query:`bg-yellow-100/50 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-200`,mutation:`bg-blue-100/50 text-blue-700 dark:bg-blue-900/50 dark:text-blue-200`,action:`bg-purple-100/50 text-purple-700 dark:bg-purple-900/50 dark:text-purple-200`};function Pt({kind:e}){return(0,Z.jsx)(jt,{variant:`secondary`,className:Nt[e],children:e})}function Ft(e){let[t,n]=(0,X.useState)(!1);return(0,Z.jsxs)(`details`,{className:`rounded-lg border`,onToggle:e=>n(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer p-4 font-medium`,children:`Deployment history`}),t&&(0,Z.jsx)(`div`,{className:`p-4 pt-0`,children:(0,Z.jsx)(It,{...e})})]})}function It(e){let[t,n]=(0,X.useState)(),[r,i]=(0,X.useState)(),a=V(e.project,e.env),o=V(e.project,e.env),s=J(a+`/history`),c=e.session.role!==`viewer`,l=async(t,n)=>{let r=n?V(e.project,`prod`):o,a=await G(r+`/health`);i({title:n?`Promote backend to production`:`Rollback backend`,description:`Activate this exact backend hash after native schema/job validation. Data, files and settings stay unchanged. Frontend is not published by this button; use the CLI release flow for that.`,productionId:n||e.env===`prod`?e.project.id:void 0,submit:async()=>{await G(r+(n?`/release-promote`:`/release-rollback`),{hash:t,expected:a.active,confirm:e.project.id}),s.refresh(),e.refresh()}})},[u,d]=(0,X.useState)();return(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(q,{loading:s.loading,error:u||s.error}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`First published`}),(0,Z.jsx)(z,{children:`Backend hash`}),(0,Z.jsx)(z,{children:`Actions`})]})}),(0,Z.jsx)(xe,{children:s.data?.map(t=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:new Date(t.at).toLocaleString()}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(`code`,{className:`text-xs`,children:t.hash.slice(0,12)}),e.active===t.hash&&(0,Z.jsx)(Q,{status:`Active`})]}),(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>n(t.hash),children:`View contracts`}),c&&e.active!==t.hash&&(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void l(t.hash,!1).catch(e=>d(e.message)),children:`Rollback backend`}),c&&e.env===`dev`&&(0,Z.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void l(t.hash,!0).catch(e=>d(e.message)),children:`Promote backend`})]})})]},t.hash))})]}),t&&(0,Z.jsx)(Lt,{path:a,hash:t,close:()=>n(void 0)}),r&&(0,Z.jsx)(L,{modal:r,onClose:()=>i(void 0)})]})}function Lt({path:e,hash:t,close:n}){let r=J(e+`/release?hash=`+t);return(0,Z.jsx)(s,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(Ce,{className:`max-h-[80vh] overflow-auto`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(l,{children:`Backend release`}),(0,Z.jsx)(O,{className:`break-all`,children:t})]}),(0,Z.jsx)(q,{...r}),r.data&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`font-medium`,children:`Tables`}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`Table`}),(0,Z.jsx)(z,{children:`Fields`})]})}),(0,Z.jsx)(xe,{children:Object.entries(r.data.schema).map(([e,t])=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:e}),(0,Z.jsx)(Y,{children:Object.keys(t.document.properties??{}).join(`, `)||`No declared fields`})]},e))})]}),(0,Z.jsx)(`h3`,{className:`font-medium`,children:`Functions`}),(0,Z.jsxs)(F,{children:[(0,Z.jsx)(Te,{children:(0,Z.jsxs)(E,{children:[(0,Z.jsx)(z,{children:`Function`}),(0,Z.jsx)(z,{children:`Kind`}),(0,Z.jsx)(z,{children:`Access`})]})}),(0,Z.jsx)(xe,{children:Object.entries(r.data.manifest.functions).map(([e,t])=>(0,Z.jsxs)(E,{children:[(0,Z.jsx)(Y,{children:e}),(0,Z.jsx)(Y,{children:(0,Z.jsx)(Pt,{kind:t.kind})}),(0,Z.jsx)(Y,{children:(0,Z.jsx)(Q,{status:t.auth})})]},e))})]})]})]})})}function Rt({className:e,size:t=`default`,...n}){return(0,Z.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:W(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-none bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none`,e),...n})}function zt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-header`,className:W(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-none px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function Bt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:W(`font-heading text-sm font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function Vt({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:W(`px-(--card-spacing)`,e),...t})}function Ht({project:e,env:t,session:n,connect:r}){let i=J(V(e,t)+`/health`),a=J(V(e,t)+`/settings`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Health`}),(0,Z.jsx)(q,{loading:i.loading||a.loading,error:i.error||a.error}),i.data&&a.data&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h2`,{className:`section-title`,children:`Summary`}),(0,Z.jsx)(Rt,{children:(0,Z.jsxs)(Vt,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{status:t===`dev`?`Development`:`Production`}),(0,Z.jsx)(`strong`,{children:e.name})]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`Cloudflare · Durable Objects · SQLite`}),(0,Z.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`Release `,i.data.active?.slice(0,12)??`not deployed`]})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground`,children:`Cloud URL`}),(0,Z.jsx)(`code`,{className:`block select-all break-all text-xs`,children:a.data.url}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Z.jsx)(Q,{status:i.data.status}),i.data.connections,` connections · `,i.data.subscriptions,` `,`subscriptions`]})]})]})}),(0,Z.jsx)(Ft,{project:e,env:t,session:n,active:i.data.active,refresh:i.refresh}),(0,Z.jsx)(K,{variant:`outline`,onClick:r,children:`Connect SDK`})]})]})}function Ut({project:e,env:t}){let n=J(V(e,t)+`/schema`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Schema`}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:(0,Z.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:n.refresh,disabled:n.loading,children:(0,Z.jsx)(Je,{})})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Defined in code; validated documents and indexes activate atomically. System tables are hidden.`}),(0,Z.jsx)(q,{...n}),n.data?.tables.map(e=>(0,Z.jsxs)(Rt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(Bt,{className:`font-mono`,children:e.name})})}),(0,Z.jsxs)(Vt,{className:`space-y-4`,children:[(0,Z.jsx)(pe,{rows:e.columns.map(e=>({Field:e.name,Type:e.type,Required:!!e.notnull,Primary:!!e.pk,Default:e.dflt_value})),columns:[`Field`,`Type`,`Required`,`Primary`,`Default`]}),(0,Z.jsx)(pe,{rows:Object.entries(e.indexes).map(([e,t])=>({Index:e,Fields:t.join(`, `)})),columns:[`Index`,`Fields`]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Document contract`}),(0,Z.jsx)(`pre`,{className:`code-block mt-3`,children:JSON.stringify(e.document,null,2)})]})]})]},e.name)),n.data&&!n.data.tables.length&&(0,Z.jsx)(de,{title:`No application tables`})]})}function Wt({project:e,env:t}){let n=J(V(e,t)+`/logs`);return(0,Z.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Logs`}),(0,Z.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:n.refresh,disabled:n.loading,children:(0,Z.jsx)(Je,{})})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Last 100 invocation summaries. Successful queries are held in memory and disappear on hibernation/restart; writes and failures are persisted. Not Cloudflare Tail logs or billing analytics.`}),(0,Z.jsx)(q,{...n}),n.data&&(n.data.length?(0,Z.jsx)(pe,{rows:n.data,renderCell:(e,t)=>e===`kind`&&[`query`,`mutation`,`action`].includes(String(t))?(0,Z.jsx)(Pt,{kind:t}):e===`status`?(0,Z.jsx)(Q,{status:t===`ok`?`ok`:`error`,children:ie(t)}):e===`at`&&typeof t==`number`?new Date(t).toLocaleString():ie(t),columns:[`at`,`path`,`kind`,`status`,`ms`],labels:{at:`Time`,path:`Function`,kind:`Type`,status:`Status`,ms:`Duration (ms)`}}):(0,Z.jsx)(de,{title:`No recent function calls`}))]})}var Gt=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),Kt=function(e){return`/`+e},qt={},Jt=function(e){return e.pathname.endsWith(`.css`)},Yt=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},$=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))},i=function(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)},a,o=document.querySelector(`meta[property=csp-nonce]`),s=o?.nonce||o?.getAttribute(`nonce`);r=e(t.map(e=>{e=Kt(e,n);let t=i(e),r=Jt(t);return Yt(qt,t.href,()=>{if(a===void 0){a={all:new Set,styles:new Set};let e=document.getElementsByTagName(`link`);for(let t=e.length-1;t>=0;t--){let n=e[t];a.all.add(n.href),n.rel===`stylesheet`&&a.styles.add(n.href)}}if((r?a.styles:a.all).has(t.href))return;let e=document.createElement(`link`);if(e.rel=r?`stylesheet`:Gt,r||(e.as=`script`),e.crossOrigin=``,e.href=t.href,s&&e.setAttribute(`nonce`,s),document.head.appendChild(e),r)return new Promise((n,r)=>{e.addEventListener(`load`,n),e.addEventListener(`error`,()=>r(Error(`Unable to preload CSS for ${t}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Xt=(0,X.lazy)(()=>$(()=>import(`./services-view.C1FjN8NY.js`).then(e=>({default:e.FilesView})),__vite__mapDeps([0,1,2,3]))),Zt=(0,X.lazy)(()=>$(()=>import(`./services-view.C1FjN8NY.js`).then(e=>({default:e.SchedulesView})),__vite__mapDeps([0,1,2,3]))),Qt=(0,X.lazy)(()=>$(()=>import(`./data-view.Bw2dG8Wg.js`),__vite__mapDeps([4,1,2,5]))),$t=(0,X.lazy)(()=>$(()=>import(`./functions-view.Bsazyfej.js`),__vite__mapDeps([6,1,2,3,5]))),en=(0,X.lazy)(()=>$(()=>import(`./ai-view.De8j8CVD.js`),__vite__mapDeps([7,1,2,3]))),tn=(0,X.lazy)(()=>$(()=>import(`./auth-view.C9j0-OzH.js`),__vite__mapDeps([8,1,2]))),nn=(0,X.lazy)(()=>$(()=>import(`./settings-view.DZldw4Vy.js`),__vite__mapDeps([9,1,2]))),rn=(0,X.lazy)(()=>$(()=>import(`./sdk-view.vdDnLZ5g.js`),__vite__mapDeps([10,1,2]))),an=[{key:`health`,label:`Health`,icon:Ae},{key:`data`,label:`Data`,icon:Ie},{key:`schema`,label:`Schema`,icon:Me},{key:`functions`,label:`Functions`,icon:Pe},{key:`files`,label:`Files`,icon:Re},{key:`schedules`,label:`Schedules`,icon:nt},{key:`ai`,label:`AI`,icon:Xe},{key:`auth`,label:`Auth`,icon:et},{key:`logs`,label:`Logs`,icon:Be}],on=(0,X.lazy)(()=>$(()=>import(`./cli-approval.emPTVRqn.js`),__vite__mapDeps([11,1,2])));function sn(){return new URLSearchParams(location.search).has(`cli`)?(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(`p`,{children:`Loading…`}),children:(0,Z.jsx)(on,{})}):(0,Z.jsx)(cn,{})}function cn(){let[e,t]=(0,X.useState)(),[n,r]=(0,X.useState)([]),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(`dev`),[l,u]=(0,X.useState)(`health`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!0),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=new AbortController;return v(localStorage.getItem(`flare.sidebar`)===`collapsed`),Promise.all([G(`session`,void 0,e.signal),G(`projects`,void 0,e.signal)]).then(([n,i])=>{e.signal.aborted||(t(n),r(i),o(i.find(e=>e.id===localStorage.getItem(`flare.project`))??i[0]),m(!1))}).catch(t=>{e.signal.aborted||(f(ue(t)),m(!1))}),()=>e.abort()},[]);let y=e=>{let t=n.find(t=>t.id===e);t&&(o(t),c(`dev`),u(`health`),g(void 0),localStorage.setItem(`flare.project`,e))},b=()=>g({title:`Create project`,description:`Creates separate development and production environments.`,content:(0,Z.jsxs)(se,{children:[(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-name`,children:`Project name`}),(0,Z.jsx)(he,{id:`project-name`,name:`name`,required:!0,maxLength:100,placeholder:`CRM`})]}),(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-alias`,children:`Short URL name (optional)`}),(0,Z.jsx)(he,{id:`project-alias`,name:`alias`,maxLength:48,pattern:`[a-z][a-z0-9]*(?:-[a-z0-9]+)*`,placeholder:`crm`})]}),(0,Z.jsxs)(S,{children:[(0,Z.jsx)(i,{htmlFor:`project-origins`,children:`Allowed frontend origins · one per line`}),(0,Z.jsx)(oe,{id:`project-origins`,name:`origins`,placeholder:`http://127.0.0.1:5173`})]})]}),submit:async e=>{let t=new FormData(e),n=await G(`projects`,{name:t.get(`name`),alias:t.get(`alias`)||void 0,origins:[location.origin,...String(t.get(`origins`)).split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(Boolean)]}),i=await G(`projects`);r(i),o(i.find(e=>e.id===n.id)??i[0]),c(`dev`),u(`health`)}}),x=a&&e?{project:a,env:s,session:e}:null,C=()=>{let e=n.filter(e=>e.id!==a?.id);r(e),o(e[0]),c(`dev`),u(`health`),e[0]?localStorage.setItem(`flare.project`,e[0].id):localStorage.removeItem(`flare.project`)},w=e=>{g(void 0),u(e)};return(0,Z.jsxs)(`div`,{className:`flex h-dvh min-h-0 flex-col overflow-hidden text-sm`,children:[(0,Z.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center justify-between gap-3 border-b bg-sidebar px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(ve,{label:`Select project`,value:a?.id??``,onChange:y,items:n.map(e=>({value:e.id,label:e.name})),className:`max-w-48`}),x&&(0,Z.jsx)(wt,{value:s,onValueChange:e=>{(e===`dev`||e===`prod`)&&(c(e),g(void 0))},"aria-label":`Select environment`,children:(0,Z.jsxs)(Et,{children:[(0,Z.jsx)(Dt,{value:`dev`,children:`Dev`}),(0,Z.jsx)(Dt,{value:`prod`,children:`Production`})]})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e?.role!==`viewer`&&e&&(0,Z.jsx)(K,{"aria-label":`Create project`,size:`icon-sm`,variant:`ghost`,onClick:b,children:(0,Z.jsx)(Ke,{})}),x&&(0,Z.jsx)(K,{"aria-label":`Project settings`,size:`icon-sm`,variant:`ghost`,onClick:()=>w(`settings`),children:(0,Z.jsx)(Qe,{})}),e&&(0,Z.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full bg-muted text-xs font-medium`,title:e.email,"aria-label":`Signed in as ${e.email}`,children:e.email.slice(0,2).toUpperCase()})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Z.jsxs)(`aside`,{className:`flex shrink-0 flex-col border-r bg-sidebar px-2 py-3 ${_?`w-12`:`w-36`}`,children:[(0,Z.jsx)(`nav`,{"aria-label":`Deployment`,className:`flex flex-col gap-1`,children:an.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(K,{variant:`ghost`,disabled:!x,"aria-current":l===e?`page`:void 0,title:_?t:void 0,"aria-label":_?t:void 0,className:`w-full justify-start ${l===e?`bg-sidebar-accent text-sidebar-accent-foreground`:`text-muted-foreground`}`,onClick:()=>w(e),children:[(0,Z.jsx)(n,{className:`size-4`}),!_&&t]},e))}),(0,Z.jsxs)(K,{"aria-label":_?`Expand sidebar`:`Collapse sidebar`,className:`mt-auto justify-start text-muted-foreground`,variant:`ghost`,onClick:()=>v(e=>(localStorage.setItem(`flare.sidebar`,e?`expanded`:`collapsed`),!e)),children:[_?(0,Z.jsx)(We,{}):(0,Z.jsx)(He,{}),!_&&`Collapse`]})]}),(0,Z.jsxs)(`main`,{className:`min-h-0 min-w-0 flex-1 ${l===`data`?`overflow-hidden`:`overflow-auto`}`,"aria-label":`Deployment content`,children:[d&&(0,Z.jsx)(`div`,{className:`p-4`,children:(0,Z.jsx)(ge,{children:d})}),p?(0,Z.jsx)(q,{loading:!0}):x?(0,Z.jsx)(ce,{scope:`projects/${a.id}/${s}`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(q,{loading:!0}),children:(0,Z.jsx)(`div`,{className:l===`data`?`h-full min-h-0`:`min-h-full`,children:l===`health`?(0,Z.jsx)(Ht,{...x,connect:()=>w(`sdk`)}):l===`data`?(0,Z.jsx)(Qt,{...x}):l===`schema`?(0,Z.jsx)(Ut,{...x}):l===`functions`?(0,Z.jsx)($t,{...x}):l===`files`?(0,Z.jsx)(Xt,{...x}):l===`schedules`?(0,Z.jsx)(Zt,{...x}):l===`ai`?(0,Z.jsx)(en,{...x}):l===`auth`?(0,Z.jsx)(tn,{...x}):l===`logs`?(0,Z.jsx)(Wt,{...x}):l===`settings`?(0,Z.jsx)(nn,{...x,onDeleted:C}):(0,Z.jsx)(rn,{...x})},`${a.id}/${s}/${l}`)})},`${a.id}/${s}`):d?null:(0,Z.jsxs)(`div`,{className:`p-4`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Select a project`}),(0,Z.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`Create a project to get started.`}),e?.role!==`viewer`&&(0,Z.jsxs)(K,{className:`mt-4`,onClick:b,children:[(0,Z.jsx)(Ke,{}),`New project`]})]})]})]}),h&&(0,Z.jsx)(L,{modal:h,onClose:()=>g(void 0)})]})}var ln=document.getElementById(`flare-dashboard`);if(!ln)throw Error(`Dashboard mount missing`);(0,Ct.createRoot)(ln).render((0,X.createElement)(sn));export{Pt as a,wt as c,Dt as d,Xe as f,Pe as g,Ie as h,Bt as i,Ot as l,Ke as m,Vt as n,Q as o,Je as p,zt as r,jt as s,Rt as t,Et as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,g as i,m as a,p as o,pt as s,r as c,s as l,u}from"./common.9pujiaSZ.js";import{i as d,n as f,r as p,t as m}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,g as i,m as a,p as o,pt as s,r as c,s as l,u}from"./common.9pujiaSZ.js";import{i as d,n as f,r as p,t as m}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";var h={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};h.node;var g=r(h),_=e(t(),1),v=n();function y({project:e,env:t,session:n}){let r=i(e,t),h=u(r+`/settings`),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(void 0);(0,_.useEffect)(()=>()=>T.current?.abort(),[]);let E=async()=>{if(C||t!==`dev`||n.role===`viewer`)return;let e=new AbortController;T.current=e,w(!0),S(``),b(void 0);try{let t=await o(r+`/dev-token`,{},e.signal);e.signal.aborted||b(t)}catch(t){e.signal.aborted||S(a(t))}finally{e.signal.aborted||w(!1)}};return(0,v.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,v.jsx)(`h1`,{className:`page-title`,children:`SDK · Live`}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`One environment URL for browser, server and mobile clients. Use the generated API references from your application build.`}),(0,v.jsx)(l,{...h}),h.data&&(0,v.jsxs)(m,{children:[(0,v.jsx)(p,{children:(0,v.jsx)(d,{children:`Connect your application`})}),(0,v.jsxs)(f,{className:`space-y-4`,children:[(0,v.jsx)(`pre`,{className:`code-block`,children:`import { createClient } from '@auersperg/flare';\nimport { api } from './flare/_generated/api';\n\nconst client = createClient({\n url: '${h.data.url}',\n getToken: () => yourUserAccessToken,\n});\n\n// Use your generated query / mutation / action references.\n// Example: replace this path with your own query:\nconst stop = client.onUpdate(api.tasks.list, { limit: 50 },\n tasks => console.log(tasks));\n\n// On logout: client.refreshAuth().\n// On teardown: stop(); client.dispose();`}),(0,v.jsx)(`p`,{className:`text-muted-foreground`,children:`The task function is an illustrative name, not a requirement for other projects. Run your app locally to test live updates; this page opens no background subscription and does not write application data.`})]})]}),(0,v.jsxs)(m,{children:[(0,v.jsx)(p,{children:(0,v.jsx)(d,{children:t===`dev`?`Local developer session`:`Production authentication`})}),(0,v.jsxs)(f,{className:`space-y-4`,children:[(0,v.jsx)(`p`,{className:`text-muted-foreground`,children:t===`dev`?`A 15-minute identity for this project's development environment. Keep it in a git-ignored local file, never in a bundle or commit. Request a new token after expiry.`:`Use enabled built-in password authentication or a configured OIDC provider. Developer identities cannot access production; application handlers enforce record permissions.`}),t===`dev`&&n.role!==`viewer`&&(0,v.jsxs)(s,{variant:`outline`,onClick:E,disabled:C,children:[(0,v.jsx)(g,{}),C?`Requesting…`:`Get developer session`]}),x&&(0,v.jsx)(c,{children:x}),y&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`pre`,{className:`code-block`,children:JSON.stringify(y,null,2)}),(0,v.jsx)(s,{variant:`ghost`,onClick:()=>b(void 0),children:`Clear from view`})]})]})]})]})}export{y as default};
|
package/dist/platform/dashboard/_astro/{services-view.DhwKE_RK.js → services-view.C1FjN8NY.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,S as i,_ as a,b as o,g as s,h as c,m as l,n as u,o as d,p as f,pt as p,q as m,s as h,u as g,v as _,x as v,y}from"./common.9pujiaSZ.js";import{c as b,d as x,l as S,o as C,p as w,u as T}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{At as n,Ot as r,S as i,_ as a,b as o,g as s,h as c,m as l,n as u,o as d,p as f,pt as p,q as m,s as h,u as g,v as _,x as v,y}from"./common.9pujiaSZ.js";import{c as b,d as x,l as S,o as C,p as w,u as T}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";import{n as E,r as D}from"./client.BvQ8bQkQ.js";var O={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};O.node;var k=r(O),A={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};A.node;var j=r(A),M=e(t(),1),N=n();function P({project:e,env:t,session:n}){let[r,c]=(0,M.useState)([null]),d=r.at(-1),b=s(e,t),x=g(b+`/files`+(d?`?cursor=`+encodeURIComponent(d):``)),S=(0,M.useRef)(null),[T,O]=(0,M.useState)(!1),[A,P]=(0,M.useState)(!1),[F,I]=(0,M.useState)(``),[L,R]=(0,M.useState)(``),z=n.role!==`viewer`;async function B(){let n=S.current?.files?.[0];if(!n)return;O(!0),I(``),R(``);let r=!1;try{let i=E(n);if(t===`prod`&&!confirm(`Upload to production ${e.name}?`))return;R(`Preparing upload…`),r=!0;let a=await f(b+`/file-upload`,{...i,...t===`prod`?{confirm:e.id}:{}});R(`Uploading ${n.name}…`),await D(a,n),S.current&&(S.current.value=``),P(!1),R(`Upload complete`)}catch(e){R(``),I(l(e)+(r?`. Check the refreshed list before retrying. Incomplete uploads expire automatically; they are not queue jobs.`:``))}finally{O(!1),r&&x.refresh()}}async function V(e){I(``);try{let t=await f(b+`/file-download?id=`+encodeURIComponent(e)),n=document.createElement(`a`);n.href=t.url,n.rel=`noreferrer`,n.click()}catch(e){I(l(e))}}async function H(n){if(confirm(`Permanently delete this ${t} file?`)){O(!0),I(``);try{await f(b+`/file-delete`,{id:n,...t===`prod`?{confirm:e.id}:{}}),x.refresh()}catch(e){I(l(e))}finally{O(!1)}}}return(0,N.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`h1`,{className:`page-title`,children:`Files`}),(0,N.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:x.refresh,disabled:x.loading,children:(0,N.jsx)(w,{})})]}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Private R2 storage · streaming uploads · maximum 10 MiB · download links expire after 5 minutes. 50 files per page.`}),(0,N.jsx)(h,{loading:x.loading,error:F||x.error}),L&&(0,N.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:L}),z&&(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(m,{ref:S,type:`file`,className:`max-w-sm`,disabled:T,"aria-label":`Choose file to upload`,onChange:e=>P(!!e.target.files?.length)}),(0,N.jsx)(p,{onClick:B,disabled:T||!A,children:`Upload file`})]}),x.data?.page.length?(0,N.jsxs)(a,{children:[(0,N.jsx)(v,{children:(0,N.jsx)(i,{children:[`Name`,`Type`,`Size`,`State`,`Created`,`Actions`].map(e=>(0,N.jsx)(o,{children:e},e))})}),(0,N.jsx)(_,{children:x.data.page.map(e=>(0,N.jsxs)(i,{children:[(0,N.jsx)(y,{children:e.name}),(0,N.jsx)(y,{children:e.type}),(0,N.jsx)(y,{children:e.size>=1048576?`${(e.size/1048576).toFixed(1)} MiB`:e.size<1024?`${e.size} B`:`${(e.size/1024).toFixed(1)} KiB`}),(0,N.jsx)(y,{children:(0,N.jsx)(C,{status:e.state,children:e.state===`pending`?`Awaiting upload`:e.state===`uploading`?`Uploading / recovering`:e.state})}),(0,N.jsx)(y,{children:new Date(e.createdAt).toLocaleString()}),(0,N.jsx)(y,{children:(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(p,{size:`icon`,variant:`outline`,"aria-label":`Download ${e.name}`,disabled:e.state!==`ready`||T,onClick:()=>void V(e.id),children:(0,N.jsx)(k,{})}),z&&(0,N.jsx)(p,{size:`icon`,variant:`outline`,"aria-label":`Delete ${e.name}`,disabled:T,onClick:()=>void H(e.id),children:(0,N.jsx)(j,{})})]})})]},e.id))})]}):x.data&&(0,N.jsx)(u,{title:`No stored files`}),x.data&&(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Page `,r.length,` · `,x.data.page.length,` files`]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(p,{variant:`outline`,disabled:x.loading||r.length===1,onClick:()=>c(e=>e.slice(0,-1)),children:`Previous`}),(0,N.jsx)(p,{variant:`outline`,disabled:x.loading||x.data.isDone,onClick:()=>{x.data?.continueCursor&&c(e=>[...e,x.data.continueCursor])},children:`Next`})]})]})]})}function F({project:e,env:t,session:n}){let r=s(e,t),m=g(r+`/jobs`),[E,D]=(0,M.useState)(``);async function O(n){if(t!==`prod`||confirm(`Pause production cron ${n}?`))try{await f(r+`/cron-cancel`,{name:n,...t===`prod`?{confirm:e.id}:{}}),m.refresh()}catch(e){D(l(e))}}async function k(n){if(t!==`prod`||confirm(`Cancel this pending production job?`)){D(``);try{(await f(r+`/job-cancel`,{id:n,...t===`prod`?{confirm:e.id}:{}})).cancelled||D(`This job is already enqueued; it cannot be cancelled here.`)}catch(e){D(l(e))}finally{m.refresh()}}}return(0,N.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`h1`,{className:`page-title`,children:`Schedules`}),(0,N.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reload snapshot`,title:`Reload snapshot`,onClick:m.refresh,disabled:m.loading,children:(0,N.jsx)(w,{})})]}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Durable scheduling → transactional outbox → Cloudflare Queues. At-least-once delivery; handlers must be idempotent. Times use UTC.`}),(0,N.jsx)(h,{loading:m.loading,error:m.error||E}),(0,N.jsxs)(b,{defaultValue:`scheduled`,children:[(0,N.jsxs)(T,{variant:`line`,children:[(0,N.jsx)(x,{value:`scheduled`,children:`Scheduled Functions`}),(0,N.jsx)(x,{value:`cron`,children:`Cron Jobs`})]}),(0,N.jsxs)(S,{value:`scheduled`,className:`space-y-4 pt-4`,children:[(0,N.jsx)(`h2`,{className:`section-title`,children:`Waiting to enqueue`}),m.data&&(m.data.pending.length?(0,N.jsxs)(a,{children:[(0,N.jsx)(v,{children:(0,N.jsx)(i,{children:[`Function`,`Due (UTC)`,`Job ID`,``].map((e,t)=>(0,N.jsx)(o,{children:e},t))})}),(0,N.jsx)(_,{children:m.data.pending.map(e=>(0,N.jsxs)(i,{children:[(0,N.jsx)(y,{className:`font-mono`,children:String(e.path)}),(0,N.jsx)(y,{children:new Date(Number(e.dueAt)).toISOString()}),(0,N.jsx)(y,{className:`font-mono`,children:String(e.id)}),(0,N.jsx)(y,{children:n.role!==`viewer`&&(0,N.jsx)(p,{variant:`outline`,disabled:m.loading,onClick:()=>void k(String(e.id)),children:`Cancel`})})]},String(e.id)))})]}):(0,N.jsx)(u,{title:`No delayed jobs`})),(0,N.jsx)(`h2`,{className:`section-title`,children:`Recent queue deliveries`}),m.data&&(m.data.recent.length?(0,N.jsx)(d,{rows:m.data.recent,columns:[`id`,`path`,`state`,`attempts`,`error`,`at`],renderCell:(e,t)=>e===`state`?(0,N.jsx)(C,{status:String(t)}):e===`at`&&typeof t==`number`?new Date(t).toLocaleString():c(t)}):(0,N.jsx)(u,{title:`No queue deliveries yet`}))]}),(0,N.jsxs)(S,{value:`cron`,className:`space-y-4 pt-4`,children:[m.data?.crons.length?(0,N.jsxs)(a,{children:[(0,N.jsx)(v,{children:(0,N.jsx)(i,{children:[`Name`,`Function`,`Cron (UTC)`,`State`,``].map((e,t)=>(0,N.jsx)(o,{children:e},t))})}),(0,N.jsx)(_,{children:m.data.crons.map(e=>(0,N.jsxs)(i,{children:[(0,N.jsx)(y,{children:e.name}),(0,N.jsx)(y,{className:`font-mono`,children:e.path}),(0,N.jsx)(y,{className:`font-mono`,children:e.cron}),(0,N.jsx)(y,{children:(0,N.jsx)(C,{status:e.enabled?`Enabled`:`Paused`})}),(0,N.jsx)(y,{children:n.role!==`viewer`&&e.enabled&&(0,N.jsx)(p,{variant:`outline`,onClick:()=>void O(e.name),children:`Pause`})})]},e.name))})]}):m.data&&(0,N.jsx)(u,{title:`No cron jobs`}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Define schedules through an application action using ctx.schedules.set(). Five-field cron expressions, minimum one minute, maximum 20 per environment. No permanent frontend timers.`})]})]})]})}export{P as FilesView,F as SchedulesView};
|
package/dist/platform/dashboard/_astro/{settings-view.Dsc34AAW.js → settings-view.DZldw4Vy.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,r as t}from"./client.BeKNsjPN.js";import{A as n,At as r,O as i,S as a,_ as o,a as s,b as c,g as l,j as u,k as d,m as f,p,pt as m,q as h,r as g,s as _,u as v,v as y,x as b,y as x}from"./common.9pujiaSZ.js";import{i as S,n as C,o as w,r as T,t as E}from"./index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
import{a as e,r as t}from"./client.BeKNsjPN.js";import{A as n,At as r,O as i,S as a,_ as o,a as s,b as c,g as l,j as u,k as d,m as f,p,pt as m,q as h,r as g,s as _,u as v,v as y,x as b,y as x}from"./common.9pujiaSZ.js";import{i as S,n as C,o as w,r as T,t as E}from"./index.astro_astro_type_script_index_0_lang.C_U84Sz-.js";var D=e(t(),1),O=r();function k(e){return(0,O.jsxs)(`div`,{className:`space-y-3 p-4 pt-0`,children:[(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`On-demand data, user accounts, files and backend code snapshots. Restore only into an empty environment. Sessions, secrets and schedules are not copied. No background polling.`}),(0,O.jsx)(A,{...e})]})}function A(e){let[t,n]=(0,D.useState)(e.env),[r,i]=(0,D.useState)(null),[u,d]=(0,D.useState)(),f=l(e.project,t),h=l(e.project,e.env),g=v(f+`/backups`+(r?`?cursor=${encodeURIComponent(r)}`:``)),S=v(h+`/backup-status`),C=e.session.role===`owner`,T=(t,n,r,i)=>d({title:t,description:n,productionId:e.project.id,submit:async()=>{await p(r,{...i,confirm:e.project.id}),g.refresh(),S.refresh()}});return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Limits: 10,000 documents / 4 MiB data; 100 files / 100 MiB. Pause cron and drain jobs before creating a backup. Partial restores stay closed; retry the same backup ID.`}),S.data?.status===`restoring`&&(0,O.jsxs)(`p`,{role:`alert`,children:[(0,O.jsx)(w,{status:`restoring`,children:`Restore in progress`}),`:`,` `,S.data.id,`. Select its source environment and retry Restore to finish.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[[`dev`,`prod`].map(e=>(0,O.jsxs)(m,{variant:t===e?`secondary`:`outline`,onClick:()=>{n(e),i(null)},children:[e===`dev`?`Development`:`Production`,` backups`]},e)),C&&(0,O.jsxs)(m,{onClick:()=>{let t=crypto.randomUUID();T(`Create backup`,`Snapshot ${e.env}. Backup ID: ${t}. No data will be deleted.`,h+`/backup-create`,{id:t})},children:[`Create `,e.env,` backup`]})]}),(0,O.jsx)(_,{loading:g.loading||S.loading,error:g.error||S.error}),g.data&&(0,O.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Recovery point: `,g.data.recoveryPoint,`.`,` `,g.data.latest&&`Latest completed: ${new Date(g.data.latest.at).toLocaleString()} (${Math.floor((g.data.ageMs??0)/36e5)} hours old).`,` `,`Manual daily backup required for the 24-hour objective; no automatic schedule.`,g.data.inventory===`partial`&&(0,O.jsx)(m,{variant:`outline`,onClick:()=>{i(null),g.refresh()},children:`Continue inventory`})]}),g.data&&(0,O.jsxs)(o,{children:[(0,O.jsx)(b,{children:(0,O.jsxs)(a,{children:[(0,O.jsx)(c,{children:`Created`}),(0,O.jsx)(c,{children:`Backup / release`}),(0,O.jsx)(c,{children:`Documents`}),(0,O.jsx)(c,{children:`Files`}),(0,O.jsx)(c,{children:`Actions`})]})}),(0,O.jsxs)(y,{children:[g.data.page.map(n=>(0,O.jsxs)(a,{children:[(0,O.jsx)(x,{children:n.at?new Date(n.at).toLocaleString():(0,O.jsx)(w,{status:`Incomplete`})}),(0,O.jsxs)(x,{children:[(0,O.jsx)(`code`,{className:`text-xs select-all`,children:n.id}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.hash?.slice(0,12)??`Not restorable`})]}),(0,O.jsx)(x,{children:n.rows??`—`}),(0,O.jsx)(x,{children:n.files??`—`}),(0,O.jsx)(x,{children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[C&&t!==e.env&&n.hash&&(0,O.jsxs)(m,{variant:`outline`,size:`sm`,onClick:()=>T(`Restore backup`,`Restore ${n.id} from ${t} into empty ${e.env}. Existing data will never be overwritten. Origin/auth settings stay unchanged.`,h+`/backup-restore`,{id:n.id,sourceEnv:t}),children:[`Restore into `,e.env]}),C&&(0,O.jsx)(m,{variant:`outline`,size:`sm`,onClick:()=>T(`Delete backup`,`Permanently delete snapshot ${n.id}. Live application data is not affected. Do not delete a backup needed by an unfinished restore.`,f+`/backup-delete`,{id:n.id}),children:`Delete`})]})})]},n.id)),!g.data.page.length&&(0,O.jsx)(a,{children:(0,O.jsx)(x,{colSpan:5,children:`No backups.`})})]})]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{variant:`outline`,disabled:!r,onClick:()=>i(null),children:`First page`}),(0,O.jsx)(m,{variant:`outline`,disabled:!g.data?.cursor,onClick:()=>i(g.data?.cursor??null),children:`Next page`})]}),u&&(0,O.jsx)(s,{modal:u,onClose:()=>d(void 0)})]})}function j({onDeleted:e,...t}){let n=l(t.project,t.env),r=v(n+`/settings`),[i,a]=(0,D.useState)(!1);return(0,O.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,O.jsx)(`h1`,{className:`page-title`,children:`Settings`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Environment identity and frontend permissions.`}),(0,O.jsx)(_,{...r}),r.data&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(N,{...t,settings:r.data,refresh:r.refresh}),(0,O.jsxs)(`details`,{className:`rounded-lg border`,onToggle:e=>a(e.currentTarget.open),children:[(0,O.jsx)(`summary`,{className:`cursor-pointer p-4 font-medium`,children:`Backups`}),i&&(0,O.jsx)(k,{...t})]})]}),t.session.role===`owner`&&(0,O.jsx)(M,{...t,onDeleted:e})]})}function M({project:e,onDeleted:t}){let[r,a]=(0,D.useState)();return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(E,{children:[(0,O.jsx)(T,{children:(0,O.jsx)(S,{children:`Delete project`})}),(0,O.jsxs)(C,{className:`space-y-3`,children:[(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`Permanently delete both development and production: data, users, files, releases, backups and schedules. This cannot be undone.`}),e.deleting?(0,O.jsx)(`p`,{role:`alert`,children:`Deletion was started. Retry to finish cleanup.`}):null,(0,O.jsx)(m,{variant:`destructive`,onClick:()=>a({title:`Delete project`,description:`Delete ${e.name} and both environments permanently? The short URL stays reserved; other projects are not affected.`,destructive:!0,submitLabel:`Delete project`,content:(0,O.jsxs)(i,{children:[(0,O.jsxs)(n,{htmlFor:`delete-project-name`,children:[`Type the project name: `,e.name]}),(0,O.jsx)(h,{id:`delete-project-name`,name:`name`,required:!0,autoComplete:`off`,maxLength:100})]}),submit:async n=>{let r=new FormData(n).get(`name`);if(r!==e.name)throw Error(`Project name does not match`);try{await p(`projects/${e.id}/delete`,{name:r,confirm:e.id})}catch(t){if(f(t)!==`NOT_FOUND`||(await p(`projects`)).some(t=>t.id===e.id))throw t}t()}}),children:`Delete project`})]})]}),r&&(0,O.jsx)(s,{modal:r,onClose:()=>a(void 0)})]})}function N({project:e,env:t,session:r,settings:a,refresh:o}){let c=l(e,t),_=r.role!==`viewer`,[v,y]=(0,D.useState)(),[b,x]=(0,D.useState)(``),[w,k]=(0,D.useState)(``),[A,j]=(0,D.useState)(!1),M=async e=>{if(!A){j(!0),k(``);try{await e()}catch(e){k(f(e))}finally{j(!1)}}},N=(n,r,i)=>y({title:n,description:r,productionId:t===`prod`?e.id:void 0,submit:async e=>i(t===`prod`?String(new FormData(e).get(`confirm`)):void 0)});return(0,O.jsxs)(O.Fragment,{children:[w&&(0,O.jsx)(g,{children:w}),(0,O.jsxs)(E,{children:[(0,O.jsx)(T,{children:(0,O.jsx)(S,{children:`Cloud URL`})}),(0,O.jsxs)(C,{className:`space-y-3`,children:[(0,O.jsx)(`code`,{className:`block select-all break-all`,children:a.url}),(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`Permanent project name. Existing UUID URLs remain valid.`}),!a.alias&&r.role===`owner`&&(0,O.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault();let n=new FormData(t.currentTarget).get(`alias`);M(async()=>{await p(`projects/${e.id}/alias`,{alias:n}),o()})},children:[(0,O.jsx)(h,{name:`alias`,"aria-label":`Short URL name`,required:!0,maxLength:48,pattern:`[a-z][a-z0-9]*(?:-[a-z0-9]+)*`,placeholder:`crm`}),(0,O.jsx)(m,{type:`submit`,disabled:A,children:`Set short URL`})]})]})]}),(0,O.jsxs)(E,{children:[(0,O.jsx)(T,{children:(0,O.jsx)(S,{children:`Environment access`})}),(0,O.jsx)(C,{children:(0,O.jsx)(`form`,{className:`max-w-xl`,onSubmit:e=>{if(e.preventDefault(),!_)return;let t=new FormData(e.currentTarget),n={origins:String(t.get(`origins`)).split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(Boolean),oidc:[`issuer`,`audience`,`jwks`].some(e=>String(t.get(e)).trim())?Object.fromEntries([`issuer`,`audience`,`jwks`].map(e=>[e,String(t.get(e)).trim()])):null};N(`Save environment`,`Updates frontend origins and user token verification. Existing applications continue to use this environment.`,async e=>{await p(c+`/settings`,{...n,confirm:e}),o()})},children:(0,O.jsxs)(d,{children:[(0,O.jsxs)(i,{children:[(0,O.jsx)(n,{htmlFor:`settings-origins`,children:`Frontend origins · one per line`}),(0,O.jsx)(u,{id:`settings-origins`,name:`origins`,defaultValue:a.origins.join(`
|
|
3
3
|
`),disabled:!_})]}),(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`Authentication · OIDC / RS256`}),(0,O.jsxs)(i,{children:[(0,O.jsx)(n,{htmlFor:`settings-issuer`,children:`Issuer`}),(0,O.jsx)(h,{id:`settings-issuer`,type:`url`,name:`issuer`,defaultValue:a.oidc?.issuer??``,disabled:!_,placeholder:`https://your-provider.example`})]}),(0,O.jsxs)(i,{children:[(0,O.jsx)(n,{htmlFor:`settings-audience`,children:`Audience`}),(0,O.jsx)(h,{id:`settings-audience`,name:`audience`,defaultValue:a.oidc?.audience??``,disabled:!_})]}),(0,O.jsxs)(i,{children:[(0,O.jsx)(n,{htmlFor:`settings-jwks`,children:`JWKS URL`}),(0,O.jsx)(h,{id:`settings-jwks`,type:`url`,name:`jwks`,defaultValue:a.oidc?.jwks??``,disabled:!_,placeholder:`https://your-provider.example/.well-known/jwks.json`})]}),(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`Leave all three empty to disable OIDC. Protected production functions remain closed.`}),_&&(0,O.jsx)(m,{type:`submit`,children:`Save environment`})]})})})]}),(0,O.jsxs)(E,{children:[(0,O.jsx)(T,{children:(0,O.jsx)(S,{children:`CLI access`})}),(0,O.jsxs)(C,{className:`space-y-4`,children:[(0,O.jsx)(`p`,{children:`Project-scoped deploy credential, valid for 30 days. Never put it in frontend code. Keep it in your shell or CI secret store.`}),r.role===`owner`&&(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{variant:`outline`,onClick:()=>N(`Issue CLI credential`,`The token is shown once. It grants deployment rights only for this project.`,async t=>{let n=await p(c+`/credential`,{confirm:t});x(`export FLARE_DEPLOY_TOKEN=${n.token}\nflare link --platform ${n.platform} --project ${e.id}\nflare deploy --env dev --release ./release`)}),children:`Issue credential`}),(0,O.jsx)(m,{variant:`destructive`,onClick:()=>N(`Revoke project credentials`,`All existing CLI credentials for this project will stop working.`,async e=>{await p(c+`/revoke-credentials`,{confirm:e}),x(`Credentials revoked.`)}),children:`Revoke credentials`})]}),b&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`pre`,{className:`code-block`,children:b}),(0,O.jsx)(m,{variant:`ghost`,onClick:()=>x(``),children:`Clear from view`})]})]})]}),v&&(0,O.jsx)(s,{modal:v,onClose:()=>y(void 0)})]})}export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en" class="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>Flare · Dashboard</title><meta http-equiv="content-security-policy" content="script-src 'self' 'sha256-xIb/Pa7FUshAu4ihwjchYcQpyCI8eS8kt40GpOAYCz8=' 'sha256-1BvDVWLr3QCC20uHhUDi27eDFVJpk1uMQJGIWKUks2I=' 'sha256-kmZE/W8I1iuTnl1b3yqzv9/DQZenPngd3NjSKMQl7y0=' 'sha256-Y8t0ntteBwH+PqGKUyjWW3CAk+BNJKSoQc0xZ68FjhM=' 'sha256-0O7iB6zr9x0r6X6eWYITC9V5q+yWCGAoFvcysBGbY9Q=' 'sha256-tQIkdAw2vqfQ1PjgUE4ML2A4pIV8SByQ1Seeehy6UIc=' 'sha256-4f86GpVBksx63uHEB4f15jGyhnVEOKjwqYxwnfDVOik='; style-src 'self' 'sha256-vv9IoKo7BSLbWcUHr3tNmfNVmm5L/9Cfn2H6LMk7/ow=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=';"><link rel="stylesheet" href="/_astro/index.CDrYoVkO.css"></head><body><div id="flare-dashboard"><div class="p-6 text-sm text-muted-foreground" role="status">Loading Flare…</div></div><script type="module" src="/_astro/index.astro_astro_type_script_index_0_lang.
|
|
1
|
+
<!DOCTYPE html><html lang="en" class="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="noindex,nofollow"><title>Flare · Dashboard</title><meta http-equiv="content-security-policy" content="script-src 'self' 'sha256-xIb/Pa7FUshAu4ihwjchYcQpyCI8eS8kt40GpOAYCz8=' 'sha256-1BvDVWLr3QCC20uHhUDi27eDFVJpk1uMQJGIWKUks2I=' 'sha256-kmZE/W8I1iuTnl1b3yqzv9/DQZenPngd3NjSKMQl7y0=' 'sha256-Y8t0ntteBwH+PqGKUyjWW3CAk+BNJKSoQc0xZ68FjhM=' 'sha256-0O7iB6zr9x0r6X6eWYITC9V5q+yWCGAoFvcysBGbY9Q=' 'sha256-tQIkdAw2vqfQ1PjgUE4ML2A4pIV8SByQ1Seeehy6UIc=' 'sha256-4f86GpVBksx63uHEB4f15jGyhnVEOKjwqYxwnfDVOik='; style-src 'self' 'sha256-vv9IoKo7BSLbWcUHr3tNmfNVmm5L/9Cfn2H6LMk7/ow=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=';"><link rel="stylesheet" href="/_astro/index.CDrYoVkO.css"></head><body><div id="flare-dashboard"><div class="p-6 text-sm text-muted-foreground" role="status">Loading Flare…</div></div><script type="module" src="/_astro/index.astro_astro_type_script_index_0_lang.C_U84Sz-.js"></script></body></html>
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format": 1,
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"stateFormat": 1,
|
|
5
5
|
"protocol": 1,
|
|
6
6
|
"runtimeAbi": 4,
|
|
7
7
|
"compatibilityDate": "2026-10-10",
|
|
8
8
|
"wranglerVersion": "4.150.0",
|
|
9
9
|
"upgradeFrom": [
|
|
10
|
-
"0.3.
|
|
10
|
+
"0.3.11"
|
|
11
11
|
],
|
|
12
12
|
"files": [
|
|
13
13
|
{
|
|
14
14
|
"path": "admin.js",
|
|
15
15
|
"bytes": 37491,
|
|
16
|
-
"sha256": "
|
|
16
|
+
"sha256": "73dbe5f08d99385f26abb205568728a22899d4a5cae3a6474dbe50a19bdecf59"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
"path": "dashboard/_astro/ai-view.
|
|
19
|
+
"path": "dashboard/_astro/ai-view.De8j8CVD.js",
|
|
20
20
|
"bytes": 4493,
|
|
21
|
-
"sha256": "
|
|
21
|
+
"sha256": "79ece8b66504ee349f3ee14990087e55d24af61f7739027351b09f1947c20182"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
"path": "dashboard/_astro/auth-view.
|
|
24
|
+
"path": "dashboard/_astro/auth-view.C9j0-OzH.js",
|
|
25
25
|
"bytes": 3494,
|
|
26
|
-
"sha256": "
|
|
26
|
+
"sha256": "9ca86b1b5e6f46cffde24d28e52df533e2ffccf6f087bdb3489e7c274942cce6"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"path": "dashboard/_astro/cli-approval.emPTVRqn.js",
|
|
30
30
|
"bytes": 2090,
|
|
31
31
|
"sha256": "205448bcd17d236b992219ce3d46cc1f2fb890be8dd9152b5b13c690154176d3"
|
|
32
32
|
},
|
|
33
|
-
{
|
|
34
|
-
"path": "dashboard/_astro/client.4z54xJ_z.js",
|
|
35
|
-
"bytes": 9421,
|
|
36
|
-
"sha256": "971a52677beaca55fb45fe83c93c65873d8f33e5fbb24ef22a8e564ca9240c5b"
|
|
37
|
-
},
|
|
38
33
|
{
|
|
39
34
|
"path": "dashboard/_astro/client.Bcl1NrNO.js",
|
|
40
35
|
"bytes": 1861,
|
|
@@ -45,20 +40,25 @@
|
|
|
45
40
|
"bytes": 219497,
|
|
46
41
|
"sha256": "734f339e4f5fe6dc3597d92c36a0c55023927eebfe4f006f23ad8552e5d48e9a"
|
|
47
42
|
},
|
|
43
|
+
{
|
|
44
|
+
"path": "dashboard/_astro/client.BvQ8bQkQ.js",
|
|
45
|
+
"bytes": 12661,
|
|
46
|
+
"sha256": "0b3c8279f8e60386ca11df4013cc1a162144648ceeff67e55382f794e053759d"
|
|
47
|
+
},
|
|
48
48
|
{
|
|
49
49
|
"path": "dashboard/_astro/common.9pujiaSZ.js",
|
|
50
50
|
"bytes": 188723,
|
|
51
51
|
"sha256": "d2313bf971c2c4e73f6ed7e5bd9f687c8ece4969f1405e8cc774cbc8885e335d"
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
"path": "dashboard/_astro/data-view.
|
|
54
|
+
"path": "dashboard/_astro/data-view.Bw2dG8Wg.js",
|
|
55
55
|
"bytes": 5806,
|
|
56
|
-
"sha256": "
|
|
56
|
+
"sha256": "c038c6cb2e23a42db0846be3e5654aaf180a096df258f1871ed0e8744933518f"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
"path": "dashboard/_astro/functions-view.
|
|
59
|
+
"path": "dashboard/_astro/functions-view.Bsazyfej.js",
|
|
60
60
|
"bytes": 6206,
|
|
61
|
-
"sha256": "
|
|
61
|
+
"sha256": "d92a5b6d927b072d388e772d4b2faea4e1e10f977b383c1ae96970d918a19f1a"
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
"path": "dashboard/_astro/geist-cyrillic-ext-wght-normal.DjL33-gN.woff2",
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"sha256": "be7da729dc120b16d178fcd2606642e03a47fe2f1a2a1a8c4aa40cfcc59e848c"
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
|
-
"path": "dashboard/_astro/index.astro_astro_type_script_index_0_lang.
|
|
94
|
+
"path": "dashboard/_astro/index.astro_astro_type_script_index_0_lang.C_U84Sz-.js",
|
|
95
95
|
"bytes": 37394,
|
|
96
|
-
"sha256": "
|
|
96
|
+
"sha256": "33ea6894aebd2a0837ffd68720493d9e63e3347105d91fb8768fc20437302be7"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"path": "dashboard/_astro/input-group.Dsc4z0iT.js",
|
|
@@ -101,19 +101,19 @@
|
|
|
101
101
|
"sha256": "7ab083f8bbd656b2a49951f076afb10f008ca5630369955481018aeb27325c50"
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
|
-
"path": "dashboard/_astro/sdk-view.
|
|
104
|
+
"path": "dashboard/_astro/sdk-view.vdDnLZ5g.js",
|
|
105
105
|
"bytes": 3363,
|
|
106
|
-
"sha256": "
|
|
106
|
+
"sha256": "af9c5c4181d05aa0985e78ae6eb722fbf32adbbf3499640a66ee236e48e8f972"
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
|
-
"path": "dashboard/_astro/services-view.
|
|
109
|
+
"path": "dashboard/_astro/services-view.C1FjN8NY.js",
|
|
110
110
|
"bytes": 8249,
|
|
111
|
-
"sha256": "
|
|
111
|
+
"sha256": "aecc8cdc6c62b3e0ed765c9b1acfdbcb1d073052fc010d0cc631d30d286fede1"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
|
-
"path": "dashboard/_astro/settings-view.
|
|
114
|
+
"path": "dashboard/_astro/settings-view.DZldw4Vy.js",
|
|
115
115
|
"bytes": 10768,
|
|
116
|
-
"sha256": "
|
|
116
|
+
"sha256": "01d673b4cf9e2679a5a8df1db0b09a5c5af6799b880888a3ba53d98a8679361b"
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"path": "dashboard/_headers",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
{
|
|
159
159
|
"path": "dashboard/index.html",
|
|
160
160
|
"bytes": 1095,
|
|
161
|
-
"sha256": "
|
|
161
|
+
"sha256": "3c34afcb8dac9efea7b9af67c9e4580c3cf879ff250705d6aff4a0bcd032c4d4"
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
"path": "migrations/0001.sql",
|
|
@@ -192,9 +192,9 @@
|
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"path": "runtime.js",
|
|
195
|
-
"bytes":
|
|
196
|
-
"sha256": "
|
|
195
|
+
"bytes": 1220978,
|
|
196
|
+
"sha256": "54e0a336bdab3b7923b82576980fe1c3718726a5695127ede38f98e319b341df"
|
|
197
197
|
}
|
|
198
198
|
],
|
|
199
|
-
"digest": "
|
|
199
|
+
"digest": "1072ce9d185c8e783e00bb9e9603b3f9372a44994302c628468afcf1ea02e34f"
|
|
200
200
|
}
|
package/dist/platform/runtime.js
CHANGED
|
@@ -23076,6 +23076,79 @@ async function codexCommand(env, scope, op, input) {
|
|
|
23076
23076
|
throw new FlareError(result.code, result.code);
|
|
23077
23077
|
return result.value;
|
|
23078
23078
|
}
|
|
23079
|
+
async function codexEvents(env, scope, grant, after, guard) {
|
|
23080
|
+
if (!grant || grant.type !== "codex-events" || Object.keys(grant).some((k) => !["type", "id"].includes(k)))
|
|
23081
|
+
throw new FlareError("INVALID_INPUT", "Expected a Codex subscription descriptor");
|
|
23082
|
+
codexInput("status", { id: grant.id });
|
|
23083
|
+
if (!Number.isSafeInteger(after) || after < 0 || after > 4096)
|
|
23084
|
+
throw new FlareError("INVALID_INPUT", "Invalid event cursor");
|
|
23085
|
+
const name = appPolicy(env, scope).codex;
|
|
23086
|
+
if (!name)
|
|
23087
|
+
throw new FlareError("CODEX_DISABLED", "Codex is not granted");
|
|
23088
|
+
const binding = env[name];
|
|
23089
|
+
if (typeof binding?.events !== "function")
|
|
23090
|
+
throw new FlareError("CODEX_UNAVAILABLE", "Streaming is unavailable");
|
|
23091
|
+
guard();
|
|
23092
|
+
const result = await binding.events(scope, grant.id, after);
|
|
23093
|
+
if (!result.ok)
|
|
23094
|
+
throw new FlareError(result.code, result.code);
|
|
23095
|
+
const response = result.value;
|
|
23096
|
+
if (!response.ok || !response.body)
|
|
23097
|
+
throw new FlareError("CODEX_UNAVAILABLE", "Streaming is unavailable");
|
|
23098
|
+
const reader = response.body.getReader();
|
|
23099
|
+
let closed = false;
|
|
23100
|
+
let lease, check;
|
|
23101
|
+
const end = () => {
|
|
23102
|
+
if (closed)
|
|
23103
|
+
return;
|
|
23104
|
+
closed = true;
|
|
23105
|
+
clearTimeout(lease);
|
|
23106
|
+
clearInterval(check);
|
|
23107
|
+
reader.cancel().catch(() => {});
|
|
23108
|
+
};
|
|
23109
|
+
return new ReadableStream({
|
|
23110
|
+
start(controller) {
|
|
23111
|
+
lease = setTimeout(() => {
|
|
23112
|
+
if (!closed) {
|
|
23113
|
+
controller.close();
|
|
23114
|
+
end();
|
|
23115
|
+
}
|
|
23116
|
+
}, 30000);
|
|
23117
|
+
check = setInterval(() => {
|
|
23118
|
+
try {
|
|
23119
|
+
guard();
|
|
23120
|
+
} catch {
|
|
23121
|
+
if (!closed) {
|
|
23122
|
+
controller.error(Error("UNAUTHORIZED"));
|
|
23123
|
+
end();
|
|
23124
|
+
}
|
|
23125
|
+
}
|
|
23126
|
+
}, 5000);
|
|
23127
|
+
},
|
|
23128
|
+
async pull(controller) {
|
|
23129
|
+
try {
|
|
23130
|
+
guard();
|
|
23131
|
+
const next = await reader.read();
|
|
23132
|
+
if (closed)
|
|
23133
|
+
return;
|
|
23134
|
+
guard();
|
|
23135
|
+
if (next.done) {
|
|
23136
|
+
controller.close();
|
|
23137
|
+
end();
|
|
23138
|
+
} else
|
|
23139
|
+
controller.enqueue(next.value);
|
|
23140
|
+
} catch {
|
|
23141
|
+
if (!closed) {
|
|
23142
|
+
controller.error(Error("CODEX_STREAM_INTERRUPTED"));
|
|
23143
|
+
end();
|
|
23144
|
+
}
|
|
23145
|
+
}
|
|
23146
|
+
},
|
|
23147
|
+
cancel() {
|
|
23148
|
+
end();
|
|
23149
|
+
}
|
|
23150
|
+
});
|
|
23151
|
+
}
|
|
23079
23152
|
|
|
23080
23153
|
// packages/flare/src/sdk/http.ts
|
|
23081
23154
|
async function readBody(body, limit, tooLarge) {
|
|
@@ -24135,7 +24208,7 @@ function dashboardIdentity(value) {
|
|
|
24135
24208
|
// packages/core/package.json
|
|
24136
24209
|
var package_default = {
|
|
24137
24210
|
name: "@flare/platform",
|
|
24138
|
-
version: "0.3.
|
|
24211
|
+
version: "0.3.12",
|
|
24139
24212
|
type: "module",
|
|
24140
24213
|
license: "MIT",
|
|
24141
24214
|
private: true,
|
|
@@ -31145,8 +31218,8 @@ function projectAlias(value) {
|
|
|
31145
31218
|
return value;
|
|
31146
31219
|
}
|
|
31147
31220
|
function applicationRoute(path) {
|
|
31148
|
-
const old = path.match(/^\/p\/([^/]+)\/(dev|prod)\/v1\/(call|mcp|auth\/(?:register|login|logout|me|change-password)|live(?:\/ticket)?|files\/(?:upload|download))$/);
|
|
31149
|
-
const short = old ? null : path.match(/^\/([^/]+)\/(dev|prod)\/v1\/(call|mcp|auth\/(?:register|login|logout|me|change-password)|live(?:\/ticket)?|files\/(?:upload|download))$/);
|
|
31221
|
+
const old = path.match(/^\/p\/([^/]+)\/(dev|prod)\/v1\/(call|codex\/events|mcp|auth\/(?:register|login|logout|me|change-password)|live(?:\/ticket)?|files\/(?:upload|download))$/);
|
|
31222
|
+
const short = old ? null : path.match(/^\/([^/]+)\/(dev|prod)\/v1\/(call|codex\/events|mcp|auth\/(?:register|login|logout|me|change-password)|live(?:\/ticket)?|files\/(?:upload|download))$/);
|
|
31150
31223
|
try {
|
|
31151
31224
|
if (old)
|
|
31152
31225
|
return {
|
|
@@ -31956,12 +32029,24 @@ class EnvironmentSupervisor extends DurableObject {
|
|
|
31956
32029
|
assertPath(input.body.path);
|
|
31957
32030
|
if (!["query", "mutation", "action"].includes(input.body.kind))
|
|
31958
32031
|
fail("INVALID_KIND");
|
|
31959
|
-
|
|
32032
|
+
if (input.operation === "codex-events" && (!auth || input.body.kind !== "query"))
|
|
32033
|
+
fail("UNAUTHORIZED");
|
|
32034
|
+
const result = await this.call({
|
|
31960
32035
|
path: input.body.path,
|
|
31961
32036
|
kind: input.body.kind,
|
|
31962
32037
|
args: input.body.args,
|
|
31963
32038
|
auth
|
|
31964
32039
|
});
|
|
32040
|
+
if (input.operation === "codex-events") {
|
|
32041
|
+
const stream = await codexEvents(this.env, this.config().scope, result.result, input.body.after ?? 0, () => {
|
|
32042
|
+
this.assertAvailable();
|
|
32043
|
+
this.checkPasswordSession(auth);
|
|
32044
|
+
if (!auth || auth.expiresAt <= Date.now())
|
|
32045
|
+
fail("AUTH_EXPIRED");
|
|
32046
|
+
});
|
|
32047
|
+
return { stream };
|
|
32048
|
+
}
|
|
32049
|
+
return result;
|
|
31965
32050
|
});
|
|
31966
32051
|
return { origin: allowedOrigin, response };
|
|
31967
32052
|
}
|
|
@@ -32946,7 +33031,7 @@ var runtime_default = {
|
|
|
32946
33031
|
} : await supervisor.application({
|
|
32947
33032
|
origin: requestedOrigin,
|
|
32948
33033
|
authorization: request.headers.get("authorization"),
|
|
32949
|
-
operation: request.method === "OPTIONS" ? "preflight" : route.operation === "live/ticket" ? "ticket" : "call",
|
|
33034
|
+
operation: request.method === "OPTIONS" ? "preflight" : route.operation === "live/ticket" ? "ticket" : route.operation === "codex/events" ? "codex-events" : "call",
|
|
32950
33035
|
body
|
|
32951
33036
|
});
|
|
32952
33037
|
origin = answer.origin;
|
|
@@ -32962,6 +33047,10 @@ var runtime_default = {
|
|
|
32962
33047
|
headers.set("access-control-max-age", "600");
|
|
32963
33048
|
return new Response(null, { status: 204, headers });
|
|
32964
33049
|
}
|
|
33050
|
+
if (route.operation === "codex/events") {
|
|
33051
|
+
headers.set("content-type", "text/event-stream");
|
|
33052
|
+
return new Response(result.stream, { headers });
|
|
33053
|
+
}
|
|
32965
33054
|
headers.set("content-type", "application/json");
|
|
32966
33055
|
return new Response(boundedJson(result, LIMITS.outputBytes), { headers });
|
|
32967
33056
|
} catch (e) {
|
package/dist/sdk/client.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type CodexSubscription } from "./codex-stream.js";
|
|
2
|
+
export type { CodexEvent, CodexSubscription } from "./codex-stream.js";
|
|
1
3
|
import { FlareError, type FunctionRef } from "./protocol.js";
|
|
2
4
|
export { reference, FlareError } from "./protocol.js";
|
|
3
5
|
export type { FunctionRef, Json } from "./protocol.js";
|
|
@@ -41,6 +43,10 @@ export declare function createClient(options: ClientOptions): {
|
|
|
41
43
|
query: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
42
44
|
mutation: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
43
45
|
action: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
46
|
+
codexEvents<I>(ref: FunctionRef<I, CodexSubscription>, args: I, streamOptions?: {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
after?: number;
|
|
49
|
+
}): AsyncGenerator<import("./codex-stream.js").CodexEvent, void, any>;
|
|
44
50
|
/** One subscription delivers the initial snapshot and subsequent updates. */
|
|
45
51
|
onUpdate<I, O>(ref: FunctionRef<I, O>, args: I, next: (value: O) => void, error?: (error: FlareError) => void): () => void;
|
|
46
52
|
/** Call on login/logout/account switch; never reuse cached values across identities. */
|
package/dist/sdk/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readCodexEvents } from "./codex-stream.js";
|
|
1
2
|
import { readBody } from "./http.js";
|
|
2
3
|
import {
|
|
3
4
|
assertPath,
|
|
@@ -279,6 +280,34 @@ export function createClient(options) {
|
|
|
279
280
|
query: invoke("query"),
|
|
280
281
|
mutation: invoke("mutation"),
|
|
281
282
|
action: invoke("action"),
|
|
283
|
+
async* codexEvents(ref, args, streamOptions = {}) {
|
|
284
|
+
ensureOpen();
|
|
285
|
+
assertPath(ref.path);
|
|
286
|
+
const controller = new AbortController;
|
|
287
|
+
const abort = () => controller.abort();
|
|
288
|
+
cleanups.add(abort);
|
|
289
|
+
streamOptions.signal?.addEventListener("abort", abort, { once: true });
|
|
290
|
+
if (streamOptions.signal?.aborted)
|
|
291
|
+
abort();
|
|
292
|
+
try {
|
|
293
|
+
yield* readCodexEvents({
|
|
294
|
+
url: endpoint("/v1/codex/events"),
|
|
295
|
+
ref,
|
|
296
|
+
args,
|
|
297
|
+
after: streamOptions.after,
|
|
298
|
+
transport,
|
|
299
|
+
signal: controller.signal,
|
|
300
|
+
token: async () => {
|
|
301
|
+
ensureOpen();
|
|
302
|
+
return await options.getToken?.() ?? null;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
} finally {
|
|
306
|
+
abort();
|
|
307
|
+
cleanups.delete(abort);
|
|
308
|
+
streamOptions.signal?.removeEventListener("abort", abort);
|
|
309
|
+
}
|
|
310
|
+
},
|
|
282
311
|
onUpdate(ref, args, next, error) {
|
|
283
312
|
const observer = { next, error };
|
|
284
313
|
ensureOpen();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FunctionRef } from "./protocol.js";
|
|
2
|
+
import type { CodexTask } from "./codex.js";
|
|
3
|
+
export type CodexSubscription = {
|
|
4
|
+
type: "codex-events";
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
export type CodexEvent = {
|
|
8
|
+
type: "task";
|
|
9
|
+
task: CodexTask;
|
|
10
|
+
} | {
|
|
11
|
+
type: "status" | "text" | "output" | "item" | "truncated";
|
|
12
|
+
seq: number;
|
|
13
|
+
at: number;
|
|
14
|
+
itemId?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
state?: string;
|
|
18
|
+
exitCode?: number | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function readCodexEvents<I>(options: {
|
|
21
|
+
url: string;
|
|
22
|
+
ref: FunctionRef<I, CodexSubscription>;
|
|
23
|
+
args: I;
|
|
24
|
+
token: () => Promise<string | null>;
|
|
25
|
+
transport: typeof fetch;
|
|
26
|
+
signal: AbortSignal;
|
|
27
|
+
after?: number;
|
|
28
|
+
}): AsyncGenerator<CodexEvent>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FlareError,
|
|
3
|
+
boundedJson,
|
|
4
|
+
LIMITS
|
|
5
|
+
} from "./protocol.js";
|
|
6
|
+
import { readBody } from "./http.js";
|
|
7
|
+
export async function* readCodexEvents(options) {
|
|
8
|
+
if (options.ref.kind !== "query")
|
|
9
|
+
throw new FlareError("INVALID_KIND", "Stream authorization must be a read-only query");
|
|
10
|
+
let cursor = options.after ?? 0, failures = 0;
|
|
11
|
+
if (!Number.isSafeInteger(cursor) || cursor < 0 || cursor > 4096)
|
|
12
|
+
throw new FlareError("INVALID_ARGUMENT", "Invalid cursor");
|
|
13
|
+
const signal = options.signal;
|
|
14
|
+
while (!signal.aborted) {
|
|
15
|
+
let reader;
|
|
16
|
+
const connection = new AbortController;
|
|
17
|
+
const abort = () => connection.abort(signal.reason);
|
|
18
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
19
|
+
if (signal.aborted)
|
|
20
|
+
abort();
|
|
21
|
+
let idle;
|
|
22
|
+
const touch = () => {
|
|
23
|
+
clearTimeout(idle);
|
|
24
|
+
idle = setTimeout(() => connection.abort(), 45000);
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
touch();
|
|
28
|
+
const token = await options.token();
|
|
29
|
+
if (signal.aborted)
|
|
30
|
+
return;
|
|
31
|
+
const response = await options.transport(options.url, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
redirect: "error",
|
|
34
|
+
signal: connection.signal,
|
|
35
|
+
headers: {
|
|
36
|
+
"Content-Type": "application/json",
|
|
37
|
+
...token ? { Authorization: `Bearer ${token}` } : {}
|
|
38
|
+
},
|
|
39
|
+
body: boundedJson({
|
|
40
|
+
path: options.ref.path,
|
|
41
|
+
kind: "query",
|
|
42
|
+
args: options.args,
|
|
43
|
+
after: cursor
|
|
44
|
+
}, LIMITS.inputBytes)
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
const bytes = response.body ? await readBody(response.body, 8192, () => {
|
|
48
|
+
throw new FlareError("INVALID_RESPONSE", "Oversized error");
|
|
49
|
+
}) : new Uint8Array;
|
|
50
|
+
let code = `HTTP_${response.status}`;
|
|
51
|
+
try {
|
|
52
|
+
const value = JSON.parse(new TextDecoder().decode(bytes));
|
|
53
|
+
if (/^[A-Z][A-Z0-9_]{0,63}$/.test(value.error))
|
|
54
|
+
code = value.error;
|
|
55
|
+
} catch {}
|
|
56
|
+
throw new FlareError(code, "Event subscription failed");
|
|
57
|
+
}
|
|
58
|
+
if (!response.headers.get("content-type")?.startsWith("text/event-stream") || !response.body)
|
|
59
|
+
throw new FlareError("INVALID_RESPONSE", "Expected SSE");
|
|
60
|
+
reader = response.body.getReader();
|
|
61
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
62
|
+
let pending = "", total = 0;
|
|
63
|
+
while (!signal.aborted) {
|
|
64
|
+
const next = await reader.read();
|
|
65
|
+
if (next.done)
|
|
66
|
+
break;
|
|
67
|
+
touch();
|
|
68
|
+
total += next.value.byteLength;
|
|
69
|
+
if (total > 1048576)
|
|
70
|
+
throw new FlareError("INVALID_RESPONSE", "Stream exceeds bound");
|
|
71
|
+
pending += decoder.decode(next.value, { stream: true });
|
|
72
|
+
let end;
|
|
73
|
+
while ((end = pending.indexOf(`
|
|
74
|
+
|
|
75
|
+
`)) >= 0) {
|
|
76
|
+
const frame = pending.slice(0, end);
|
|
77
|
+
pending = pending.slice(end + 2);
|
|
78
|
+
if (frame.length > 524288)
|
|
79
|
+
throw new FlareError("INVALID_RESPONSE", "Oversized event");
|
|
80
|
+
let name = "", data = "", id = "";
|
|
81
|
+
for (const line of frame.split(`
|
|
82
|
+
`)) {
|
|
83
|
+
if (line.startsWith("event:"))
|
|
84
|
+
name = line.slice(6).trim();
|
|
85
|
+
if (line.startsWith("data:"))
|
|
86
|
+
data += line.slice(5).trimStart();
|
|
87
|
+
if (line.startsWith("id:"))
|
|
88
|
+
id = line.slice(3).trim();
|
|
89
|
+
}
|
|
90
|
+
if (!data)
|
|
91
|
+
continue;
|
|
92
|
+
if (name === "reconnect")
|
|
93
|
+
continue;
|
|
94
|
+
const value = JSON.parse(data);
|
|
95
|
+
if (name === "task") {
|
|
96
|
+
if (!value || typeof value.id !== "string" || !["succeeded", "failed", "cancelled", "interrupted"].includes(value.state))
|
|
97
|
+
throw new FlareError("INVALID_RESPONSE", "Invalid task");
|
|
98
|
+
yield { type: "task", task: value };
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (name !== "progress" || !Number.isSafeInteger(value.seq) || String(value.seq) !== id || value.seq > 4096 || !["status", "text", "output", "item", "truncated"].includes(value.type))
|
|
102
|
+
throw new FlareError("INVALID_RESPONSE", "Invalid event");
|
|
103
|
+
if (value.seq <= cursor)
|
|
104
|
+
continue;
|
|
105
|
+
if (value.seq !== cursor + 1)
|
|
106
|
+
throw new FlareError("CODEX_EVENT_GAP", "Event gap");
|
|
107
|
+
cursor = value.seq;
|
|
108
|
+
failures = 0;
|
|
109
|
+
yield value;
|
|
110
|
+
}
|
|
111
|
+
if (pending.length > 524288)
|
|
112
|
+
throw new FlareError("INVALID_RESPONSE", "Oversized frame");
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (signal.aborted)
|
|
116
|
+
return;
|
|
117
|
+
const code = error instanceof FlareError ? error.code : "";
|
|
118
|
+
if (code && ![
|
|
119
|
+
"HTTP_429",
|
|
120
|
+
"HTTP_500",
|
|
121
|
+
"HTTP_502",
|
|
122
|
+
"HTTP_503",
|
|
123
|
+
"HTTP_504",
|
|
124
|
+
"CODEX_UNAVAILABLE"
|
|
125
|
+
].includes(code))
|
|
126
|
+
throw error;
|
|
127
|
+
if (++failures > 5)
|
|
128
|
+
throw new FlareError("CODEX_STREAM_INTERRUPTED", "Reconnect failed; task continues independently");
|
|
129
|
+
} finally {
|
|
130
|
+
clearTimeout(idle);
|
|
131
|
+
signal.removeEventListener("abort", abort);
|
|
132
|
+
connection.abort();
|
|
133
|
+
await reader?.cancel().catch(() => {});
|
|
134
|
+
}
|
|
135
|
+
if (signal.aborted)
|
|
136
|
+
return;
|
|
137
|
+
await new Promise((resolve) => {
|
|
138
|
+
const done = () => {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
signal.removeEventListener("abort", done);
|
|
141
|
+
resolve();
|
|
142
|
+
};
|
|
143
|
+
const timer = setTimeout(done, Math.min(5000, 500 * 2 ** failures));
|
|
144
|
+
signal.addEventListener("abort", done, { once: true });
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
package/dist/sdk/react.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export declare function FlareProvider({ client, children, }: {
|
|
|
9
9
|
query: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
10
10
|
mutation: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
11
11
|
action: <I, O>(ref: FunctionRef<I, O>, args: I) => Promise<O>;
|
|
12
|
+
codexEvents<I>(ref: FunctionRef<I, import("./codex-stream.js").CodexSubscription>, args: I, streamOptions?: {
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
after?: number;
|
|
15
|
+
}): AsyncGenerator<import("./codex-stream.js").CodexEvent, void, any>;
|
|
12
16
|
onUpdate<I, O>(ref: FunctionRef<I, O>, args: I, next: (value: O) => void, error?: (error: FlareError) => void): () => void;
|
|
13
17
|
refreshAuth(): void;
|
|
14
18
|
dispose(): void;
|
package/dist/sdk/server.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
async function e(e,t,n){let r=e.getReader(),i=[],a=0;try{for(;;){let{done:e,value:o}=await r.read();if(e)break;a+=o.byteLength,a>t&&n(),i.push(o)}}finally{await r.cancel().catch(()=>{})}if(i.length===1)return i[0];let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.byteLength;return o}var t=Object.freeze({inputBytes:65536,outputBytes:262144,frameBytes:8192,subscriptions:64,fileBytes:10485760}),n=class extends Error{code;ambiguous;constructor(e,t,n=!1){super(t),this.code=e,this.ambiguous=n,this.name=`FlareError`}};function r(e){if(e.length>256||!/^[A-Za-z][A-Za-z0-9_]*(\/[A-Za-z][A-Za-z0-9_]*)*$/.test(e)||e.split(`/`).some(e=>[`__proto__`,`prototype`,`constructor`].includes(e)))throw new n(`INVALID_PATH`,`Invalid function path`)}function i(e,t){return r(e),Object.freeze({path:e,kind:t})}function a(e){let t=new Set;function r(e,i){if(i>40)throw new n(`INVALID_JSON`,`JSON nesting limit exceeded`);if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`object`||!e||t.has(e))throw new n(`INVALID_JSON`,`Expected lossless JSON`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new n(`INVALID_JSON`,`Expected plain JSON object`);if(Object.getOwnPropertySymbols(e).length)throw new n(`INVALID_JSON`,`Symbol keys are unsupported`);t.add(e);let a;if(Array.isArray(e))a=Array.from(e,e=>r(e,i+1));else{let t=Object.create(null);for(let a of Object.keys(e).sort()){let o=Object.getOwnPropertyDescriptor(e,a);if(!(`value`in o))throw new n(`INVALID_JSON`,`Getters are unsupported`);t[a]=r(o.value,i+1)}a=t}return t.delete(e),a}return JSON.stringify(r(e,0))}function o(e,t){let r=a(e);if(new TextEncoder().encode(r).byteLength>t)throw new n(`TOO_LARGE`,`JSON payload exceeds limit`);return r}function s(e){if(e.size>t.fileBytes)throw new n(`TOO_LARGE`,`Maximum file size: 10 MiB`);if(!e.name||e.name.length>120||/[\x00-\x1f\x7f/\\]/.test(e.name))throw new n(`INVALID_INPUT`,`File name must be 1–120 characters, without path separators`);return{name:e.name,size:e.size,type:[`text/plain`,`image/png`,`image/jpeg`,`image/webp`,`application/pdf`].includes(e.type)?e.type:`application/octet-stream`}}async function c(r,i,a={}){if(i.size>t.fileBytes)throw new n(`TOO_LARGE`,`Maximum file size: 10 MiB`);let o=new URL(r.url);if(o.username||o.password||o.protocol!==`https:`&&!(o.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(o.hostname)))throw new n(`INVALID_URL`,`Expected secure upload URL`);let s;try{s=await(a.fetch??globalThis.fetch)(o.href,{method:`POST`,body:i,redirect:`error`,credentials:`omit`,signal:AbortSignal.any([...a.signal?[a.signal]:[],AbortSignal.timeout(a.timeoutMs??12e4)])})}catch{throw new n(`UPLOAD_UNKNOWN`,`Connection interrupted or upload timed out; refresh the file list before trying again`,!0)}let c=s.body?await e(s.body,t.outputBytes,()=>{throw Error(`Upload response exceeds limit`)}).then(e=>JSON.parse(new TextDecoder(`utf-8`,{fatal:!0}).decode(e))).catch(()=>null):null;if(!s.ok){let e=c&&typeof c==`object`&&`error`in c&&typeof c.error==`string`?c.error:`HTTP_${s.status}`;throw new n(e,`Upload failed: ${e}`,s.status>=500)}if(!c||typeof c!=`object`||!(`id`in c)||typeof c.id!=`string`)throw new n(`INVALID_RESPONSE`,`Upload outcome is unknown; refresh the file list before uploading again`,!0);return{id:c.id}}var l=new Set([`UNAUTHORIZED`,`AUTH_EXPIRED`,`FORBIDDEN`,`AUTH_DISABLED`,`HTTP_401`,`HTTP_403`]);function u(i){let s=new URL(i.url);if(!/^https?:$/.test(s.protocol)||s.username||s.password||s.search||s.hash)throw new n(`INVALID_URL`,`Expected backend HTTP URL`);if(s.protocol===`http:`&&![`localhost`,`127.0.0.1`,`[::1]`].includes(s.hostname))throw new n(`INVALID_URL`,`Remote backends require HTTPS`);s.pathname=s.pathname.replace(/\/$/,``);let c=i.fetch??globalThis.fetch;if(!c)throw new n(`TRANSPORT_UNAVAILABLE`,`Provide a fetch implementation`);let u=new Map,d=!1,f,p=!1,m=0,h=0,g=0,_,v=new Set,y=e=>`${s.href.replace(/\/$/,``)}${e}`,b=(e,t,n)=>{for(let r of e.observers)try{r[t]?.(t===`next`?JSON.parse(n):n)}catch{}};function x(){if(d)throw new n(`DISPOSED`,`Client is disposed`)}async function S(r,a,s){x();let l=o(a,t.inputBytes),u;try{u=await i.getToken?.()??null}catch{throw new n(`AUTH_UNAVAILABLE`,`Cannot obtain access token`)}x();let d=new AbortController,f=setTimeout(()=>d.abort(),i.requestTimeoutMs??3e4);try{let i=await c(y(r),{method:`POST`,headers:{"Content-Type":`application/json`,...u?{Authorization:`Bearer ${u}`}:{}},body:l,signal:d.signal,redirect:`error`});if(!i.body)throw new n(`INVALID_RESPONSE`,`Missing response body`,s);let a=await e(i.body,t.outputBytes,()=>{throw new n(`INVALID_RESPONSE`,`Response exceeds limit`,s)}),f;try{f=JSON.parse(new TextDecoder(`utf-8`,{fatal:!0}).decode(a))}catch(e){throw i.ok?e:new n(`HTTP_${i.status}`,`Backend request failed`,s&&i.status>=500)}if(!i.ok)throw new n(f&&typeof f==`object`&&`error`in f&&typeof f.error==`string`&&/^[A-Z][A-Z0-9_]{0,63}$/.test(f.error)?f.error:`HTTP_${i.status}`,`Backend request failed`,s&&i.status>=500);if(!f||typeof f!=`object`||!(`result`in f))throw new n(`INVALID_RESPONSE`,`Invalid protocol envelope`,s);return o(f.result,t.outputBytes),f.result}catch(e){throw e instanceof n?e:e instanceof SyntaxError?new n(`INVALID_RESPONSE`,`Invalid JSON response`,s):new n(`TRANSPORT_ERROR`,s?`Write outcome is unknown; do not replay automatically`:`Backend request interrupted`,s)}finally{clearTimeout(f)}}function C(e){f?.send(o(e,t.frameBytes))}function w(e){C({type:`subscribe`,id:e.id,path:e.ref.path,args:e.args})}function T(){if(d||!u.size||_)return;let e=Math.min(3e4,250*2**Math.min(m++,7));_=setTimeout(()=>{_=void 0,E()},e)}async function E(){if(d||p||f||!u.size)return;p=!0;let e=++h;try{let r=await S(`/v1/live/ticket`,{},!1);if(d||e!==h||!u.size)return;if(!r||typeof r.ticket!=`string`||r.ticket.length>1024)throw new n(`INVALID_RESPONSE`,`Invalid live ticket`);let a=new URL(y(`/v1/live`));a.protocol=a.protocol===`https:`?`wss:`:`ws:`,a.searchParams.set(`ticket`,r.ticket);let s=i.createWebSocket?i.createWebSocket(a.href):new globalThis.WebSocket(a.href);f=s;let c=()=>{if(!(f!==s||d)){m=0;for(let e of u.values())e.revision=-1,e.snapshot=void 0,e.terminal||w(e)}},p=e=>{if(!(f!==s||d))try{if(typeof e.data!=`string`||new TextEncoder().encode(e.data).byteLength>t.outputBytes+1024)throw Error(`Invalid frame`);let r=JSON.parse(e.data);if(r.type===`ready`)return;let i=[...u.values()].find(e=>e.id===r.id);if(!i||i.terminal)return;if(r.type===`error`){i.terminal=!0,l.has(r.code)&&(i.snapshot=void 0),b(i,`error`,new n(typeof r.code==`string`?r.code:`LIVE_ERROR`,`Live subscription failed`));return}if(r.type!==`snapshot`||!Number.isSafeInteger(r.revision)||r.revision<0||!(`result`in r))throw Error(`Invalid snapshot`);let a=o(r.result,t.outputBytes);if(r.revision>i.revision){let e=i.snapshot!==a;i.revision=r.revision,i.snapshot=a,e&&b(i,`next`,i.snapshot)}C({type:`ack`,id:i.id,revision:i.revision})}catch{s.close(1002,`Invalid protocol frame`)}},g=e=>{if(x(),f===s){f=void 0;for(let t of u.values())e.code===1008&&(t.snapshot=void 0,t.revision=-1),t.terminal||b(t,`error`,new n(e.code===1008?`AUTH_EXPIRED`:`LIVE_DISCONNECTED`,`Live reconnecting; next snapshot will be current`));T()}},_=()=>s.close(),x=()=>{s.removeEventListener(`open`,c),s.removeEventListener(`message`,p),s.removeEventListener(`close`,g),s.removeEventListener(`error`,_),v.delete(x)};v.add(x),s.addEventListener(`open`,c),s.addEventListener(`message`,p),s.addEventListener(`close`,g),s.addEventListener(`error`,_)}catch(t){if(d||e!==h)return;for(let e of u.values())t instanceof n&&l.has(t.code)&&(e.snapshot=void 0,e.revision=-1),b(e,`error`,t instanceof n?t:new n(`LIVE_UNAVAILABLE`,`Live connection failed`));T()}finally{p=!1,!d&&e!==h&&!f&&u.size&&T()}}function D(e){return async(t,i)=>{if(r(t.path),t.kind!==e)throw new n(`INVALID_KIND`,`Expected a ${e} function`);return S(`/v1/call`,{path:t.path,kind:t.kind,args:i},t.kind===`mutation`||t.kind===`action`)}}return{query:D(`query`),mutation:D(`mutation`),action:D(`action`),onUpdate(e,i,s,c){let l={next:s,error:c};if(x(),r(e.path),e.kind!==`query`)throw new n(`INVALID_KIND`,`Only queries are subscribable`);o({type:`subscribe`,id:`subscription-9999999999`,path:e.path,args:i},t.frameBytes);let d=a({path:e.path,args:i}),p=u.get(d);if(!p){if(u.size>=t.subscriptions)throw new n(`TOO_MANY_SUBSCRIPTIONS`,`Subscription limit exceeded`);p={id:`subscription-${++g}`,ref:e,args:JSON.parse(a(i)),observers:new Set,revision:-1,terminal:!1},u.set(d,p),f?.readyState===1&&w(p)}let m={next:l.next,error:l.error};p.observers.add(m),p.snapshot!==void 0&&b({...p,observers:new Set([l])},`next`,p.snapshot),E();let y=!1;return()=>{if(!y&&(y=!0,p.observers.delete(m),p.observers.size||(u.delete(d),f?.readyState===1&&C({type:`unsubscribe`,id:p.id})),!u.size)){++h,_&&clearTimeout(_),_=void 0;let e=f;f=void 0;for(let e of[...v])e();e?.close(1e3,`No subscriptions`)}}},refreshAuth(){x(),++h,_&&clearTimeout(_),_=void 0;for(let e of[...v])e();let e=f;f=void 0,e?.close(1e3,`Authorization changed`);for(let e of u.values())e.snapshot=void 0,e.revision=-1,e.terminal=!1,b(e,`error`,new n(`AUTH_CHANGED`,`Authorization changed; cached value invalidated`));E()},dispose(){if(!d){d=!0,++h,_&&clearTimeout(_),_=void 0;for(let e of[...v])e();u.clear(),f?.close(1e3,`Disposed`),f=void 0}}}}export{i,s as n,c as r,u as t};
|