@hulla/db-studio 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Samuel Hulla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # `@hulla/db-studio`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Optional local database workbench for `@hulla/db`. Start with a relationship diagram,
4
+ open a table to browse and filter its rows, or search the schema catalog for fields,
5
+ indexes and reference rules. Select rows on the current page to export JSON or
6
+ delete them together, and edit fields through managed database transactions.
7
+ Studio uses database scalar representations, so
8
+ int64 values remain lossless decimal strings and JSON stays structured.
9
+
10
+ The interface uses `@hulla/style`, `@hulla/ui`'s semantic theme and native control
11
+ adaptations, with self-hosted Schibsted Grotesk and IBM Plex Mono. Light and dark
12
+ themes follow the system initially; the header toggle saves your preference.
13
+ No framework runtime or component generator is loaded in the browser or server.
14
+
15
+ Install `@hulla/db-studio` alongside `@hulla/db`, then run:
16
+
17
+ ```sh
18
+ hulla-db dev --studio
19
+ # Or connect to an already running database without starting a function service:
20
+ hulla-db studio db.config.ts
21
+ ```
22
+
23
+ Open the access link printed in the terminal. Studio binds `127.0.0.1:4983`;
24
+ `--studio-port 4984` selects another port. Use `--read-only` to disable editing.
25
+ With `NODE_ENV=production`, Studio defaults to read-only; `--write` explicitly
26
+ enables managed row edits and deletions. The package and listener are loaded only when requested.
27
+
28
+ Studio is an operator interface. It bypasses application business authorization;
29
+ its access link grants access to all tables in the configured schema. Keep that
30
+ link private. Browser requests require its per-session token, and the listener
31
+ rejects foreign origins and hostnames. There is no public remote listener or SQL
32
+ console. For a production database, run Studio locally with a private database
33
+ connection, or run it on the host and forward the same loopback port over SSH.
34
+
35
+ Saving checks the loaded row snapshot inside a serializable managed transaction.
36
+ A changed or deleted row produces a conflict instead of overwriting newer data.
37
+ Bulk deletion verifies every selected snapshot and deletes the batch atomically;
38
+ reference restrictions and cascades still apply. Changing the page, sort or filters
39
+ clears selection. Read-only mode retains selection and export.
40
+ Primary keys cannot be edited. Constraints, codecs and synchronization revisions
41
+ still apply; direct edits do not invoke application query/mutation declarations
42
+ or create browser recovery receipts.
43
+
44
+ See the [Studio guide](https://github.com/hulladev/db/blob/main/docs/studio.md) for the checkout demo, architecture
45
+ and validation commands.
46
+
47
+ Licensed under MIT.
package/dist/app.js ADDED
@@ -0,0 +1 @@
1
+ import{c as Ue}from"./chunks/app-3jxkzzh5.js";function he(e){let t=function n(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o=="object"){if(Array.isArray(o))return o.map(n).join(" ");if(o instanceof Set||o instanceof Map)return Array.from(o).map(n).join(" ");let r="";return Object.entries(o??{}).forEach(([p,l])=>{l&&(r+=(r?" ":"")+p)}),r}return null}(e);return t?String(t):""}function qe(...e){let t=new Set,n=[];for(let o of e)if(o)for(let r of o.split(/\s+/))!r||t.has(r)||(t.add(r),n.push(r));return n.join(" ")}function Le(e){let{serializer:t=he,composer:n=qe}=e??{},o=t===he?(...r)=>{for(let p=0;p<r.length;p++){let l=r[p];typeof l!="string"&&(r[p]=he(l))}return n(...r)}:(...r)=>n(...r.map((p)=>t(p)));return{cn:o,vn:function(r){let p=(l)=>o(r[l]);return p.infer=void 0,p}}}var{cn:oe,vn:xe}=Le(),Fe=xe({primary:"primary",secondary:"secondary",ghost:"ghost"}),P=(e="ghost")=>oe("button",Fe(e)),Te={string:"type-text",uuid:"type-key",int64:"type-number",float64:"type-number",boolean:"type-boolean",json:"type-json",date:"type-date",timestamp:"type-date",localTimestamp:"type-date"},Pe=xe(Te),_=(e)=>oe("field-type",Pe(Object.hasOwn(Te,e)?e:"string")),X=(e)=>({string:"Aa",uuid:"⌑",int64:"#",float64:"#",boolean:"◐",json:"{}",date:"◷",timestamp:"◷",localTimestamp:"◷"})[e]??"Aa";function R(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","icon"),t.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","use");return n.setAttribute("href",`#i-${e}`),t.append(n),t}var ke,Y,$e=(e)=>[...e.querySelectorAll("pre code.language-json")].filter((t)=>!t.dataset.highlighted&&(t.textContent?.length??0)<=131072);function ge(e){if(Y)return Y;if(!$e(e).length)return Promise.resolve();return Y=(async()=>{try{let{highlightJSON:t}=await(ke??=import("./chunks/syntax-dg543ev3.js"));for(let n of $e(e)){if(!n.isConnected)continue;n.innerHTML=t(n.textContent??""),n.dataset.highlighted="true"}}catch{ke=void 0}finally{Y=void 0}})(),Y}function W(e){let t=new Map(e.map((n)=>[n.name,n]));return e.flatMap((n)=>n.fields.flatMap((o)=>{let r=o.reference===void 0?void 0:t.get(o.reference);return r?[{source:n,field:o,target:r}]:[]}))}var re=(e)=>Array.isArray(e.indexes)?e.indexes.length:0,ie=(e)=>(Array.isArray(e.checks)?e.checks.length:0)+(e.unique&&typeof e.unique==="object"?Object.keys(e.unique).length:0);function Me(e){let t=W(e),n=new Map(e.map((i)=>[i.name,i])),o=new Map(e.map((i)=>[i.name,new Set]));for(let{source:i,target:d}of t)if(i!==d)o.get(i.name).add(d.name),o.get(d.name).add(i.name);let r=(i,d)=>o.get(d).size-o.get(i).size||i.localeCompare(d),p=new Set(e.map((i)=>i.name)),l=[],f=50,u=500;for(let i of[...p].sort(r)){if(!p.delete(i))continue;let d=new Map([[i,0]]),y=[i];for(let S=0;S<y.length;S++){let E=y[S];for(let m of[...o.get(E)].sort()){if(!p.delete(m))continue;d.set(m,d.get(E)+1),y.push(m)}}let x=new Map;for(let[S,E]of d){let m=n.get(S),M=m.fields.filter((K)=>K.name===m.primaryKey),A=m.fields.filter((K)=>K.name!==m.primaryKey&&K.reference),q=m.fields.filter((K)=>K.name!==m.primaryKey&&!K.reference).slice(0,6),N=[...M,...A,...q],F=x.get(E)??[];x.set(E,F),F.push({table:m,fields:N,omitted:m.fields.length-N.length,x:50+E*450,y:0,width:286,height:80+N.length*25})}let c=[...x.values()].map((S)=>S.reduce((E,m)=>E+m.height+45,-45)),w=Math.max(0,...c),b=0;for(let S of x.values()){let E=f+(w-c[b++])/2;for(let m of S)m.y=E,E+=m.height+45,l.push(m),u=Math.max(u,m.x+m.width+120)}f+=w+90}let h=new Map(l.map((i)=>[i.table.name,i])),L=t.map((i)=>{let d=h.get(i.source.name),y=h.get(i.target.name),x=d.y+50+d.fields.findIndex((b)=>b.name===i.field.name)*25+12.5,c=y.y+62.5,w;if(d.x===y.x){let b=d.x+d.width,S=y.x+y.width,E=Math.max(b,S)+65,m=d===y&&x===c?45:0;w=`M${b},${x} C${E},${x-m} ${E},${c+m} ${S},${c}`}else{let b=d.x>y.x,S=b?d.x:d.x+d.width,E=b?y.x+y.width:y.x,m=Math.abs(E-S)/2;w=`M${S},${x} C${S+(b?-m:m)},${x} ${E+(b?m:-m)},${c} ${E},${c}`}return{...i,path:w}});return{nodes:l,edges:L,width:u,height:Math.max(320,f-40)}}function T(e,t,n){let o=document.createElement(e);if(o.className=t,n!==void 0)o.textContent=n;return o}function Ce(e,t){let n=Me(e),o=T("div","diagram"),r=T("div","diagram-viewport");r.tabIndex=0,r.setAttribute("aria-label","Table relationship diagram. Scroll to pan, or use the zoom controls.");let p=T("div","diagram-sizer"),l=T("div","diagram-world");l.style.width=`${n.width}px`,l.style.height=`${n.height}px`;let f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("class","diagram-connections"),f.setAttribute("width",String(n.width)),f.setAttribute("height",String(n.height)),f.setAttribute("aria-hidden","true");let u=document.createElementNS(f.namespaceURI,"defs"),h=document.createElementNS(f.namespaceURI,"marker");h.setAttribute("id","reference-arrow"),h.setAttribute("viewBox","0 0 10 10"),h.setAttribute("refX","9"),h.setAttribute("refY","5"),h.setAttribute("markerWidth","6"),h.setAttribute("markerHeight","6"),h.setAttribute("orient","auto-start-reverse");let L=document.createElementNS(f.namespaceURI,"path");L.setAttribute("d","M0 0L10 5L0 10Z"),h.append(L),u.append(h),f.append(u);for(let M of n.edges){let A=document.createElementNS(f.namespaceURI,"path");A.setAttribute("d",M.path),A.setAttribute("class","relationship-line"),A.setAttribute("marker-end","url(#reference-arrow)"),f.append(A)}l.append(f);for(let M of n.nodes){let A=T("article","diagram-node");A.style.left=`${M.x}px`,A.style.top=`${M.y}px`,A.style.width=`${M.width}px`;let q=T("button","diagram-node-title");q.type="button",q.setAttribute("aria-label",`Open table ${M.table.name}`),q.append(R("table"),T("strong","",M.table.name),T("span","node-field-count",String(M.table.fields.length))),A.append(q);for(let N of M.fields){let F=T("div","diagram-field"),K=T("span",_(N.scalar),X(N.scalar));if(K.setAttribute("aria-hidden","true"),F.append(K,T("span","diagram-field-name",N.name),T("small","",N.scalar)),N.name===M.table.primaryKey){let Ee=R("key");Ee.setAttribute("class","icon primary-key-icon"),F.append(Ee)}else if(N.reference)F.append(T("span","foreign-key-label","FK"));F.title=N.reference?`${N.name} → ${N.reference} · on delete ${N.onDelete??"restrict"}`:`${N.name}: ${N.scalar}${N.nullable?" · nullable":""}`,A.append(F)}A.append(T("div","diagram-node-footer",M.omitted?`+ ${M.omitted} more fields · Open table`:"Open table →")),A.addEventListener("click",()=>t(M.table)),l.append(A)}if(!e.length)l.append(T("p","diagram-empty","No tables are defined in this schema."));p.append(l),r.append(p),o.append(r);let i=T("div","diagram-tools"),d=T("button",P("secondary"),"−"),y=T("button",P("secondary"),"+");d.setAttribute("aria-label","Zoom out"),y.setAttribute("aria-label","Zoom in");let x=T("span","diagram-zoom","100%"),c=T("button",P("secondary"),"Fit");c.setAttribute("aria-label","Fit diagram"),i.append(d,x,y,c),o.append(i);let w=T("div","diagram-legend");w.append(R("key"),T("span","","Primary key"),T("span","foreign-key-label","FK"),T("span","","Reference → primary key")),o.append(w);let b=1,S=!0;function E(M){let A=(r.scrollLeft+r.clientWidth/2)/b,q=(r.scrollTop+r.clientHeight/2)/b;b=Math.max(0.25,Math.min(1.5,M)),l.style.transform=`scale(${b})`,p.style.width=`${n.width*b}px`,p.style.height=`${n.height*b}px`,x.textContent=`${Math.round(b*100)}%`,r.scrollLeft=A*b-r.clientWidth/2,r.scrollTop=q*b-r.clientHeight/2}function m(){if(!r.clientWidth||!r.clientHeight)return;S=!0,E(Math.min(1,Math.max(0.25,Math.min(r.clientWidth/n.width,r.clientHeight/n.height)))),r.scrollLeft=0,r.scrollTop=0}return y.addEventListener("click",()=>{S=!1,E(b+0.15)}),d.addEventListener("click",()=>{S=!1,E(b-0.15)}),c.addEventListener("click",m),new ResizeObserver(()=>{if(S)m()}).observe(r),E(1),{root:o,fit:m}}function k(e,t,n){let o=document.createElement(e);if(o.className=t,n!==void 0)o.textContent=n;return o}function He(e,t){let n=k("div","catalog"),o=k("div","catalog-toolbar"),r=k("input","catalog-search");r.type="search",r.placeholder="Find a table, field, or type…",r.setAttribute("aria-label","Search schema catalog");let p=k("span","catalog-count");o.append(r,p);let l=k("div","catalog-content");n.append(o,l);let f=W(e);function u(){let h=r.value.toLowerCase().trim(),L=e.filter((c)=>[c.name,...c.fields.flatMap((w)=>[w.name,w.scalar,w.reference??""])].some((w)=>w.toLowerCase().includes(h)));p.textContent=`${L.length} of ${e.length} tables`;let i=k("div","catalog-grid");for(let c of L){let w=k("article","catalog-card"),b=k("button","catalog-title");b.type="button",b.setAttribute("aria-label",`Browse ${c.name}`),b.append(R("table"),k("strong","",c.name)),b.addEventListener("click",()=>t(c)),w.append(b),w.append(k("p","catalog-meta",`${c.fields.length} fields · ${re(c)} indexes · ${ie(c)} unique/check rules`));let S=k("div","catalog-fields");for(let m of c.fields.slice(0,8)){let M=k("span","catalog-field",m.name);if(M.title=`${m.scalar}${m.nullable?" · nullable":""}${m.reference?` → ${m.reference}`:""}`,m.name===c.primaryKey)M.prepend(R("key"));S.append(M)}if(c.fields.length>8)S.append(k("span","catalog-more",`+${c.fields.length-8}`));w.append(S);let E=k("button",P(),"Inspect schema →");E.type="button",E.setAttribute("aria-label",`Inspect schema of ${c.name}`),E.addEventListener("click",()=>t(c,"schema")),w.append(E),i.append(w)}let d=k("section","catalog-relations");d.append(k("h2","","References & delete behavior"));let y=new Set(L.map((c)=>c.name)),x=k("div","reference-list");for(let c of f.filter((w)=>y.has(w.source.name)||y.has(w.target.name))){let w=k("div","reference-item"),b=k("button","reference-link",`${c.source.name}.${c.field.name}`),S=k("button","reference-link",`${c.target.name}.${c.target.primaryKey}`);if(b.addEventListener("click",()=>t(c.source,"schema")),S.addEventListener("click",()=>t(c.target,"schema")),w.append(b,R("arrow"),S,k("span","reference-policy",c.field.onDelete??"restrict")),c.field.nullable)w.append(k("span","reference-nullable","nullable"));x.append(w)}if(!x.children.length)x.append(k("p","catalog-empty",h?"No references match this search.":"No references are declared in this schema."));if(d.append(x),l.replaceChildren(i,d),!L.length)i.append(k("p","catalog-empty","No tables or fields match this search."))}return r.addEventListener("input",u),u(),n}function a(e){let t=document.getElementById(e);if(!t)throw Error(`Missing Studio element ${e}`);return t}function s(e,t,n){let o=document.createElement(e);if(t!==void 0)o.textContent=t;if(n)o.className=oe(n);return o}var j=(e)=>e===null?"null":typeof e==="object"?JSON.stringify(e):String(e),Re=(e)=>JSON.stringify(e,null,2),U=a("editor"),ae=a("delete-dialog"),Ae=a("notice"),v,g,D=[],J=[],I,ue=[null],z=0,Z=null,G=0,O=!1,C=!1,Oe="map",ne=!1,be,H=new Map,B,ee,le,ye=[],Je=new URLSearchParams(location.hash.slice(1)),Ne=Je.get("token");if(Ne)sessionStorage.setItem("hulla-studio-token",Ne),history.replaceState(null,"",location.pathname);var Ve=sessionStorage.getItem("hulla-studio-token")??"";window.addEventListener("hashchange",()=>{if(new URLSearchParams(location.hash.slice(1)).has("token"))location.reload()});async function pe(e,t){let n=await fetch(`/api/${e}`,{method:t===void 0?"GET":"POST",headers:{Authorization:`Bearer ${Ve}`,...t===void 0?{}:{"Content-Type":"application/json"}},...t===void 0?{}:{body:JSON.stringify(t)},signal:AbortSignal.timeout(15000)}),o=await n.json();if(!n.ok)throw Error(o.error??"Studio request failed");return o}function Q(e){Ae.hidden=e===void 0,Ae.textContent=e instanceof Error?e.message:e===void 0?"":String(e)}function Se(){let e=a("table-search").value.toLowerCase();a("tables").replaceChildren(...v.tables.filter((t)=>t.name.toLowerCase().includes(e)).map((t)=>{let n=s("button");return n.append(R("table"),s("span",t.name,"table-name")),n.setAttribute("aria-current",String(g?.name===t.name)),n.addEventListener("click",()=>de(t)),n}))}function De(e){Oe=e,a("map-page").hidden=e!=="map",a("catalog-page").hidden=e!=="catalog",a("table-detail").hidden=e!=="table";for(let t of["map","catalog"]){let n=a(`nav-${t}`);if(e===t)n.setAttribute("aria-current","page");else n.removeAttribute("aria-current")}}function me(e,t=!0){if(C)return;if(G++,O=!1,ne=!1,g=void 0,H.clear(),B=void 0,U.close(),a("delete-dialog").close(),Q(),De(e),Se(),a("breadcrumb").textContent=e==="map"?"Schema map":"Schema catalog",t)history.pushState(null,"",`#${e}`);if(e==="map")requestAnimationFrame(()=>be?.fit())}function de(e,t="data",n=!0){if(C)return;G++,O=!1,ne=!1,U.close(),g=e,J=[],I=void 0,H.clear(),B=void 0,De("table"),Q(),a("edit-hint").textContent=v.readOnly?"Select rows to export JSON, or open a row to inspect it.":"Select rows for bulk actions, or open a row to edit it. Selection stays on the current page.",a("table-title").textContent=e.name,a("breadcrumb").textContent=e.name;let o=e.indexes instanceof Array?e.indexes.length:0;if(a("table-description").textContent=`${e.fields.length} fields · ${o} ${o===1?"index":"indexes"} · ${e.primaryKey} primary key`,a("refresh").disabled=!1,a("filter-field").replaceChildren(...e.fields.map((r)=>{let p=s("option",r.name);return p.value=r.name,p})),ue=[null],z=0,Z=null,D=[],a("schema-view").hidden=t!=="schema",Ie(),Se(),We(e),Be(),ve(),ce(),n)history.pushState(null,"",`#table=${encodeURIComponent(e.name)}&view=${t}`);we(t)}function Ke(){let e=new URLSearchParams(location.hash.slice(1)),t=e.get("table"),n=v.tables.find((o)=>o.name===t);if(n)de(n,e.get("view")==="schema"?"schema":"data",!1);else me(e.has("catalog")?"catalog":"map",!1)}function Ie(){let e=g?.fields.find((n)=>n.name===a("filter-field").value),t=["=","!=",...e?.scalar==="json"||e?.scalar==="boolean"?[]:[">",">=","<","<="],...e?.scalar==="string"?["contains"]:[],...e?.nullable?["is","is not"]:[]];a("filter-operator").replaceChildren(...t.map((n)=>{let o=s("option",n==="is"?"is null":n==="is not"?"is not null":n);return o.value=n,o})),a("filter-value").disabled=!1}function je(e,t){if(e.scalar==="json")return JSON.parse(t);if(e.scalar==="boolean"){if(t!=="true"&&t!=="false")throw Error(`${e.name} requires true or false`);return t==="true"}if(e.scalar==="float64"){if(!t.trim()||!Number.isFinite(Number(t)))throw Error(`${e.name} requires a finite number`);return Number(t)}return t}function Be(){a("filter-chips").replaceChildren(...J.map((e,t)=>{let n=s("span",`${e.field} ${e.operator} ${j(e.value)}`,"chip"),o=s("button",void 0,P());return o.append(R("close")),o.setAttribute("aria-label",`Remove filter on ${e.field}`),o.addEventListener("click",()=>{J.splice(t,1),V()}),n.append(o),n}))}function V(){ue=[null],z=0,Be(),fe()}function ce(){a("previous").disabled=C||O||z===0,a("next").disabled=C||O||Z===null,a("refresh").disabled=C||O||!g,a("page-number").textContent=`Page ${z+1}`,a("row-count").textContent=O?"Loading rows…":`${D.length} ${D.length===1?"row":"rows"} on this page`,te()}async function fe(){if(!g)return;let e=++G;O=!0,ne=!1,Z=null,D=[],H.clear(),B=void 0,ce(),ve(),Q();try{let t=await pe("rows",{table:g.name,filters:J,...I?{sort:I}:{},cursor:ue[z],limit:Number(a("page-size").value)});if(e!==G)return;D=t.rows,Z=t.cursor,ne=!0,a("connection-status").textContent="Connected · PostgreSQL",a("database-state").textContent="Connected"}catch(t){if(e!==G)return;Q(t),a("connection-status").textContent="Query failed · refresh to retry",a("database-state").textContent="Query failed"}finally{if(e===G)O=!1,ve(),ce()}}function ve(){let e=document.querySelector("#grid thead"),t=document.querySelector("#grid tbody"),n=s("tr"),o=s("th",void 0,"selection-cell"),r=s("input");r.type="checkbox",r.id="select-page",r.setAttribute("aria-label","Select all rows on this page"),r.addEventListener("change",()=>{if(H.clear(),r.checked)for(let l of D)H.set(se(l),l);te()}),o.append(r),n.append(o,s("th","#","row-number"));for(let l of g?.fields??[]){let f=s("th"),u=s(l.scalar==="json"?"span":"button",void 0,"column-heading"),h=s("span",X(l.scalar),_(l.scalar));if(h.setAttribute("aria-hidden","true"),u.append(h,s("span",`${l.name}${I?.field===l.name?I.direction==="asc"?" ↑":" ↓":""}`)),l.name===g?.primaryKey){let L=R("key");L.setAttribute("class","icon column-key"),u.append(L)}if(u instanceof HTMLButtonElement)f.setAttribute("aria-sort",I?.field===l.name?I.direction==="asc"?"ascending":"descending":"none"),u.title=`Sort by ${l.name}`,u.addEventListener("click",()=>{I={field:l.name,direction:I?.field===l.name&&I.direction==="asc"?"desc":"asc"},V()});f.append(u),n.append(f)}e.replaceChildren(n),t.replaceChildren(...D.map((l,f)=>{let u=s("tr"),h=s("td",void 0,"selection-cell"),L=s("input");L.type="checkbox",L.dataset.rowKey=se(l),L.setAttribute("aria-label",`Select row ${j(l.values[g.primaryKey])}`),L.addEventListener("click",(i)=>{i.stopPropagation();let d=i.shiftKey&&B!==void 0?Math.min(f,B):f,y=i.shiftKey&&B!==void 0?Math.max(f,B):f;for(let x=d;x<=y;x++){let c=D[x];if(L.checked)H.set(se(c),c);else H.delete(se(c))}B=f,te()}),h.addEventListener("click",(i)=>i.stopPropagation()),h.append(L),u.append(h),u.append(s("td",String(z*Number(a("page-size").value)+f+1).padStart(2,"0"),"row-number"));for(let i of g.fields){let d=l.values[i.name],y=s("td");if(y.title=j(d),i.name===g.primaryKey){let x=s("button",j(d),"open-row");x.setAttribute("aria-label",`Inspect row ${j(d)}`),y.append(x)}else if(d===null)y.append(s("span","null","null"));else if(typeof d==="boolean")y.append(s("span",String(d),`bool ${d}`));else y.textContent=j(d);u.append(y)}return u.addEventListener("click",()=>Ge(l)),u}));let p=a("empty");p.hidden=D.length>0,p.querySelector("h2").textContent=O?"Reading your table…":"No rows to show.",p.querySelector("p").textContent=O?"Fetching a bounded page from the database.":J.length?"Try changing or removing a filter.":"This table is empty, or the last request could not complete.",te()}function se(e){return JSON.stringify(e.values[g.primaryKey])}function te(){let e=H.size;a("selection-bar").hidden=e===0,a("selection-count").textContent=`${e} ${e===1?"row":"rows"} selected on this page`;let t=document.getElementById("select-page");if(t)t.checked=D.length>0&&e===D.length,t.indeterminate=e>0&&e<D.length,t.disabled=O||C||D.length===0;for(let n of document.querySelectorAll("#grid input[data-row-key]"))n.checked=H.has(n.dataset.rowKey),n.disabled=C,n.closest("tr").dataset.selected=String(n.checked);a("delete-selected").hidden=v?.readOnly??!0}a("clear-selection").addEventListener("click",()=>{H.clear(),B=void 0,te()});a("export-selected").addEventListener("click",()=>{if(!g||!H.size)return;let e=new Blob([JSON.stringify({table:g.name,rows:[...H.values()].map((o)=>o.values)},null,2)],{type:"application/json"}),t=URL.createObjectURL(e),n=s("a");n.href=t,n.download=`${g.name.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,80)}-selected.json`,n.click(),setTimeout(()=>URL.revokeObjectURL(t),1000)});a("delete-selected").addEventListener("click",()=>{if(!g||!H.size||C||v.readOnly)return;le={table:g,rows:[...H.values()]},a("delete-title").textContent=`Delete ${H.size} selected ${H.size===1?"row":"rows"}?`,a("delete-description").textContent=`The selected rows will be permanently removed from “${g.name}”. This cannot be undone in Studio.`;let e=W(v.tables).filter((n)=>n.target.name===g.name),t=a("delete-effects");if(t.replaceChildren(),e.length){t.append(s("strong","Related table rules"));let n=s("ul");for(let o of e)n.append(s("li",`${o.source.name}.${o.field.name} → ${o.field.onDelete??"restrict"}`));t.append(n,s("p","Cascade rules can also delete related rows; restrict rules can prevent deletion."))}a("delete-error").hidden=!0,a("confirm-delete").textContent=`Delete ${H.size} ${H.size===1?"row":"rows"}`,ae.showModal()});a("cancel-delete").addEventListener("click",()=>{if(!C)ae.close()});ae.addEventListener("cancel",(e)=>{if(C)e.preventDefault()});ae.addEventListener("close",()=>{le=void 0});a("delete-form").addEventListener("submit",(e)=>{if(e.preventDefault(),!le||C||v.readOnly)return;let t=le;(async()=>{C=!0,a("delete-error").hidden=!0,a("confirm-delete").disabled=!0,a("cancel-delete").disabled=!0,a("confirm-delete").textContent="Deleting…";try{let n=await pe("delete",{table:t.table.name,rows:t.rows.map((o)=>({key:o.values[t.table.primaryKey],snapshot:o.snapshot}))});ae.close(),V(),a("edit-hint").textContent=`Deleted ${n.deleted} selected ${n.deleted===1?"row":"rows"} from ${t.table.name}.`}catch(n){a("delete-error").hidden=!1,a("delete-error").textContent=n instanceof Error?n.message:"Could not delete the selected rows"}finally{C=!1,a("confirm-delete").disabled=!1,a("cancel-delete").disabled=!1,a("confirm-delete").textContent=`Delete ${t.rows.length} ${t.rows.length===1?"row":"rows"}`,ce()}})()});function We(e){let t=s("div",void 0,"schema-card"),n=s("h2");n.append(R("table"),document.createTextNode("Fields & relationships")),t.append(n);let o=s("table"),r=s("thead"),p=s("tr");for(let i of["Field","Type","Nullable","Default / generation","Reference"])p.append(s("th",i));r.append(p),o.append(r);let l=s("tbody");for(let i of e.fields){let d=s("tr");for(let y of[i.name+(i.name===e.primaryKey?" · primary key":""),i.scalar+(i.precision===void 0?"":` (${i.precision})`),i.nullable?"yes":"no",i.hasDefault?j(i.default):i.name===e.primaryKey?j(e.keyGeneration):"—",i.reference?`${i.reference} · ${i.onDelete??"restrict"}`:"—"])d.append(s("td",y));l.append(d)}o.append(l),t.append(o);let f=s("div",void 0,"schema-card"),u=s("h2");u.append(R("code"),document.createTextNode("Constraints & indexes")),f.append(u),u.append(s("span","JSON","code-language"));let h=s("pre"),L=s("code",Re({indexes:e.indexes,unique:e.unique,checks:e.checks,fields:Object.fromEntries(e.fields.filter((i)=>i.constraints||i.jsonShape).map((i)=>[i.name,{constraints:i.constraints,jsonShape:i.jsonShape}]))}),"language-json");if(h.append(L),f.append(h),a("schema-view").replaceChildren(t,f),!a("schema-view").hidden)ge(a("schema-view"))}function Ge(e){if(!g||C)return;if(ee=e,ye=[],a("editor-table").textContent=g.name,a("editor-title").textContent=v.readOnly?"Inspect row":"Edit row",a("editor-note").textContent=v.readOnly?"Read-only connection. Values are shown in their database representation.":"Changes are validated and saved in one managed transaction. Values use their database representation.",a("editor-error").hidden=!0,a("cancel-editor").textContent=v.readOnly?"Close":"Cancel",a("save-row").hidden=v.readOnly,a("editor-fields").replaceChildren(...g.fields.map((t,n)=>{let o=e.values[t.name],r=v.readOnly||t.name===g.primaryKey,p=s("div",void 0,"editor-field"),l=s("label",void 0,"field-label");l.htmlFor=`edit-${n}`;let f=s("span",X(t.scalar),_(t.scalar));f.setAttribute("aria-hidden","true"),l.append(f,s("span",t.name),s("small",t.name===g.primaryKey?`${t.scalar} · primary key`:t.scalar));let u;if(t.scalar==="json")u=s("textarea"),u.value=o===null?"":Re(o);else if(t.scalar==="boolean"){u=s("select");for(let L of["false","true"]){let i=s("option",L);i.value=L,u.append(i)}u.value=String(o??!1)}else u=s("input"),u.type="text",u.value=o===null?"":j(o);u.id=`edit-${n}`,u.disabled=r||o===null,u.autocomplete="off",p.append(l,u);let h;if(t.nullable){h=s("input"),h.type="checkbox",h.checked=o===null,h.disabled=r;let L=s("label",void 0,"null-toggle");L.append(h,document.createTextNode("Set to null")),h.addEventListener("change",()=>{u.disabled=r||h.checked}),p.append(L)}return ye.push({field:t,input:u,...h?{nullable:h}:{}}),p})),!U.open)U.showModal()}a("editor-form").addEventListener("submit",(e)=>{if(e.preventDefault(),C||!g||!ee||v.readOnly)return;(async()=>{let t=a("editor-error");t.hidden=!0;try{let n=Object.fromEntries(ye.filter(({field:o})=>o.name!==g.primaryKey).map(({field:o,input:r,nullable:p})=>[o.name,p?.checked?null:je(o,r.value)]).filter(([o,r])=>JSON.stringify(r)!==JSON.stringify(ee.values[o])));if(!Object.keys(n).length){U.close();return}C=!0,a("save-row").disabled=!0,a("close-editor").disabled=!0,a("cancel-editor").disabled=!0,await pe("update",{table:g.name,key:ee.values[g.primaryKey],snapshot:ee.snapshot,patch:n}),U.close(),V()}catch(n){t.hidden=!1,t.textContent=n instanceof Error?n.message:"Could not save row"}finally{C=!1,a("save-row").disabled=!1,a("close-editor").disabled=!1,a("cancel-editor").disabled=!1}})()});U.addEventListener("cancel",(e)=>{if(C)e.preventDefault()});for(let e of["close-editor","cancel-editor"])a(e).addEventListener("click",()=>U.close());a("table-search").addEventListener("input",()=>{if(v)Se()});a("filter-field").addEventListener("change",Ie);a("filter-operator").addEventListener("change",()=>{a("filter-value").disabled=["is","is not"].includes(a("filter-operator").value)});a("filter-form").addEventListener("submit",(e)=>{if(e.preventDefault(),!g)return;try{if(J.length>=12)throw Error("Use at most 12 filters");let t=g.fields.find((r)=>r.name===a("filter-field").value),n=a("filter-operator").value,o=a("filter-value").value;J.push({field:t.name,operator:n,value:["is","is not"].includes(n)?null:n==="contains"?o:je(t,o)}),V()}catch(t){Q(t)}});a("refresh").addEventListener("click",V);a("page-size").addEventListener("change",V);a("previous").addEventListener("click",()=>{if(!O&&z>0)z--,fe()});a("next").addEventListener("click",()=>{if(!O&&Z)ue[++z]=Z,fe()});function we(e){for(let t of["data","schema"]){let n=a(`${t}-tab`);n.setAttribute("aria-selected",String(t===e)),n.tabIndex=t===e?0:-1,a(`${t}-view`).hidden=t!==e}if(a("view-description").textContent=e==="data"?"Table contents":"Fields, relationships & constraints",g&&Oe==="table")history.replaceState(null,"",`#table=${encodeURIComponent(g.name)}&view=${e}`);if(e==="data"&&g&&!ne&&!O)fe();if(e==="schema")ge(a("schema-view"))}for(let e of["data","schema"]){let t=a(`${e}-tab`);t.addEventListener("click",()=>we(e)),t.addEventListener("keydown",(n)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(n.key))return;n.preventDefault();let o=n.key==="Home"?"data":n.key==="End"?"schema":e==="data"?"schema":"data";we(o),a(`${o}-tab`).focus()})}function ze(){a("theme-toggle").setAttribute("aria-label",`Switch to ${document.documentElement.dataset.theme==="dark"?"light":"dark"} theme`)}ze();a("nav-map").addEventListener("click",()=>{if(v)me("map")});a("nav-catalog").addEventListener("click",()=>{if(v)me("catalog")});document.querySelector(".brand").addEventListener("click",(e)=>{if(v)e.preventDefault(),me("map")});window.addEventListener("popstate",()=>{if(v&&!C)Ke()});a("theme-toggle").addEventListener("click",()=>{let e=document.documentElement.dataset.theme==="dark"?"light":"dark";document.documentElement.dataset.theme=e;try{localStorage.setItem("hulla-studio-theme",e)}catch{}ze()});(async()=>{try{v=await pe("schema"),a("namespace").textContent=v.namespace,a("table-count").textContent=String(v.tables.length).padStart(2,"0"),a("access").replaceChildren(R(v.readOnly?"lock":"check"),document.createTextNode(v.readOnly?"Read only":"Read / write")),a("database-state").textContent="Schema loaded",a("connection-status").textContent="Schema loaded · open a table to read data";let e=[["Tables",v.tables.length],["References",W(v.tables).length],["Indexes",v.tables.reduce((t,n)=>t+re(n),0)],["Unique / check rules",v.tables.reduce((t,n)=>t+ie(n),0)]];a("schema-stats").replaceChildren(...e.map(([t,n])=>{let o=s("div",void 0,"schema-stat");return o.append(s("span",t),s("strong",String(n).padStart(2,"0"))),o})),be=Ce(v.tables,(t)=>de(t)),a("schema-diagram").append(be.root),a("schema-catalog").append(He(v.tables,de)),Ke()}catch(e){Q(e),a("access").textContent="Disconnected",a("connection-status").textContent="Connection unavailable"}})();
@@ -0,0 +1 @@
1
+ ["app.js","chunks/app-3jxkzzh5.js","chunks/syntax-dg543ev3.js"]
@@ -0,0 +1,2 @@
1
+ var j=Object.create;var{getPrototypeOf:k,defineProperty:i,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,q=(a,b,c)=>{var f=a!=null&&typeof a==="object";if(f){var g=b?o??=new WeakMap:p??=new WeakMap,h=g.get(a);if(h)return h}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?i(c,"default",{value:a,enumerable:!0}):c;if(a&&typeof a==="object"||typeof a==="function"){for(let e of l(a))if(!m.call(d,e))i(d,e,{get:n.bind(a,e),enumerable:!0})}if(f)g.set(a,d);return d};var r=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
2
+ export{q as a,r as b,s as c};
@@ -0,0 +1,3 @@
1
+ import{a as Zt,b as rt}from"./app-3jxkzzh5.js";var Pe=rt(function(mt,je){function Oe(e){if(e instanceof Map)e.clear=e.delete=e.set=function(){throw Error("map is read-only")};else if(e instanceof Set)e.add=e.clear=e.delete=function(){throw Error("set is read-only")};return Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t)=>{let c=e[t],l=typeof c;if((l==="object"||l==="function")&&!Object.isFrozen(c))Oe(c)}),e}class ne{constructor(e){if(e.data===void 0)e.data={};this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function we(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function D(e,...t){let c=Object.create(null);for(let l in e)c[l]=e[l];return t.forEach(function(l){for(let b in l)c[b]=l[b]}),c}var ct="</span>",de=(e)=>!!e.scope,ot=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){let c=e.split(".");return[`${t}${c.shift()}`,...c.map((l,b)=>`${l}${"_".repeat(b+1)}`)].join(" ")}return`${t}${e}`};class Ne{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=we(e)}openNode(e){if(!de(e))return;let t=ot(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){if(!de(e))return;this.buffer+=ct}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}var Ee=(e={})=>{let t={children:[]};return Object.assign(t,e),t};class ie{constructor(){this.rootNode=Ee(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=Ee({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop();return}closeAllNodes(){while(this.closeNode());}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){if(typeof t==="string")e.addText(t);else if(t.children)e.openNode(t),t.children.forEach((c)=>this._walk(e,c)),e.closeNode(t);return e}static _collapse(e){if(typeof e==="string")return;if(!e.children)return;if(e.children.every((t)=>typeof t==="string"))e.children=[e.children.join("")];else e.children.forEach((t)=>{ie._collapse(t)})}}class Re extends ie{constructor(e){super();this.options=e}addText(e){if(e==="")return;this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let c=e.root;if(t)c.scope=`language:${t}`;this.add(c)}toHTML(){return new Ne(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function H(e){if(!e)return null;if(typeof e==="string")return e;return e.source}function Se(e){return L("(?=",e,")")}function at(e){return L("(?:",e,")*")}function lt(e){return L("(?:",e,")?")}function L(...e){return e.map((c)=>H(c)).join("")}function ut(e){let t=e[e.length-1];if(typeof t==="object"&&t.constructor===Object)return e.splice(e.length-1,1),t;else return{}}function Y(...e){return"("+(ut(e).capture?"":"?:")+e.map((l)=>H(l)).join("|")+")"}function ye(e){return new RegExp(e.toString()+"|").exec("").length-1}function ft(e,t){let c=e&&e.exec(t);return c&&c.index===0}var gt=new RegExp(Y(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function se(e,{joinWith:t}){let c=0;return e.map((l)=>{c+=1;let b=c,_=H(l),i="";while(_.length>0){let r=gt.exec(_);if(!r){i+=_;break}if(i+=_.substring(0,r.index),_=_.substring(r.index+r[0].length),r[0][0]==="\\"&&r[1])i+="\\"+String(Number(r[1])+b);else if(i+=r[0],r[0]==="("||/^\(\?[<']/.test(r[0]))c++}return i}).map((l)=>`(${l})`).join(t)}var ht=/\b\B/,Ae="[a-zA-Z]\\w*",re="[a-zA-Z_]\\w*",Te="\\b\\d+(\\.\\d+)?",Ie="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",ke="\\b(0b[01]+)",pt="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",dt=(e={})=>{let t=/^#![ ]*\//;if(e.binary)e.begin=L(t,/.*\b/,e.binary,/\b.*/);return D({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(c,l)=>{if(c.index!==0)l.ignoreMatch()}},e)},U={begin:"\\\\[\\s\\S]",relevance:0},Et={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[U]},bt={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[U]},_t={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Z=function(e,t,c={}){let l=D({scope:"comment",begin:e,end:t,contains:[]},c);l.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let b=Y("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return l.contains.push({begin:L(/[ ]+/,"(",b,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),l},Mt=Z("//","$"),xt=Z("/\\*","\\*/"),Ot=Z("#","$"),wt={scope:"number",begin:Te,relevance:0},Nt={scope:"number",begin:Ie,relevance:0},Rt={scope:"number",begin:ke,relevance:0},St={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[U,{begin:/\[/,end:/\]/,relevance:0,contains:[U]}]},yt={scope:"title",begin:Ae,relevance:0},At={scope:"title",begin:re,relevance:0},Tt={begin:"\\.\\s*"+re,relevance:0},It=function(e){return Object.assign(e,{"on:begin":(t,c)=>{c.data._beginMatch=t[1]},"on:end":(t,c)=>{if(c.data._beginMatch!==t[1])c.ignoreMatch()}})},z=Object.freeze({__proto__:null,APOS_STRING_MODE:Et,BACKSLASH_ESCAPE:U,BINARY_NUMBER_MODE:Rt,BINARY_NUMBER_RE:ke,COMMENT:Z,C_BLOCK_COMMENT_MODE:xt,C_LINE_COMMENT_MODE:Mt,C_NUMBER_MODE:Nt,C_NUMBER_RE:Ie,END_SAME_AS_BEGIN:It,HASH_COMMENT_MODE:Ot,IDENT_RE:Ae,MATCH_NOTHING_RE:ht,METHOD_GUARD:Tt,NUMBER_MODE:wt,NUMBER_RE:Te,PHRASAL_WORDS_MODE:_t,QUOTE_STRING_MODE:bt,REGEXP_MODE:St,RE_STARTERS_RE:pt,SHEBANG:dt,TITLE_MODE:yt,UNDERSCORE_IDENT_RE:re,UNDERSCORE_TITLE_MODE:At});function kt(e,t){if(e.input[e.index-1]===".")t.ignoreMatch()}function Dt(e,t){if(e.className!==void 0)e.scope=e.className,delete e.className}function Bt(e,t){if(!t)return;if(!e.beginKeywords)return;if(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=kt,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0)e.relevance=0}function Ct(e,t){if(!Array.isArray(e.illegal))return;e.illegal=Y(...e.illegal)}function Lt(e,t){if(!e.match)return;if(e.begin||e.end)throw Error("begin & end are not supported with match");e.begin=e.match,delete e.match}function vt(e,t){if(e.relevance===void 0)e.relevance=1}var jt=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error("beforeMatch cannot be used with starts");let c=Object.assign({},e);Object.keys(e).forEach((l)=>{delete e[l]}),e.keywords=c.keywords,e.begin=L(c.beforeMatch,Se(c.begin)),e.starts={relevance:0,contains:[Object.assign(c,{endsParent:!0})]},e.relevance=0,delete c.beforeMatch},Pt=["of","and","for","in","not","or","if","then","parent","list","value"],Ht="keyword";function De(e,t,c=Ht){let l=Object.create(null);if(typeof e==="string")b(c,e.split(" "));else if(Array.isArray(e))b(c,e);else Object.keys(e).forEach(function(_){Object.assign(l,De(e[_],t,_))});return l;function b(_,i){if(t)i=i.map((r)=>r.toLowerCase());i.forEach(function(r){let g=r.split("|");l[g[0]]=[_,Ut(g[0],g[1])]})}}function Ut(e,t){if(t)return Number(t);return $t(e)?0:1}function $t(e){return Pt.includes(e.toLowerCase())}var be={},C=(e)=>{console.error(e)},_e=(e,...t)=>{console.log(`WARN: ${e}`,...t)},v=(e,t)=>{if(be[`${e}/${t}`])return;console.log(`Deprecated as of ${e}. ${t}`),be[`${e}/${t}`]=!0},J=Error();function Be(e,t,{key:c}){let l=0,b=e[c],_={},i={};for(let r=1;r<=t.length;r++)i[r+l]=b[r],_[r+l]=!0,l+=ye(t[r-1]);e[c]=i,e[c]._emit=_,e[c]._multi=!0}function Gt(e){if(!Array.isArray(e.begin))return;if(e.skip||e.excludeBegin||e.returnBegin)throw C("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),J;if(typeof e.beginScope!=="object"||e.beginScope===null)throw C("beginScope must be object"),J;Be(e,e.begin,{key:"beginScope"}),e.begin=se(e.begin,{joinWith:""})}function Kt(e){if(!Array.isArray(e.end))return;if(e.skip||e.excludeEnd||e.returnEnd)throw C("skip, excludeEnd, returnEnd not compatible with endScope: {}"),J;if(typeof e.endScope!=="object"||e.endScope===null)throw C("endScope must be object"),J;Be(e,e.end,{key:"endScope"}),e.end=se(e.end,{joinWith:""})}function Wt(e){if(e.scope&&typeof e.scope==="object"&&e.scope!==null)e.beginScope=e.scope,delete e.scope}function Xt(e){if(Wt(e),typeof e.beginScope==="string")e.beginScope={_wrap:e.beginScope};if(typeof e.endScope==="string")e.endScope={_wrap:e.endScope};Gt(e),Kt(e)}function Ft(e){function t(i,r){return new RegExp(H(i),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(r?"g":""))}class c{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(i,r){r.position=this.position++,this.matchIndexes[this.matchAt]=r,this.regexes.push([r,i]),this.matchAt+=ye(i)+1}compile(){if(this.regexes.length===0)this.exec=()=>null;let i=this.regexes.map((r)=>r[1]);this.matcherRe=t(se(i,{joinWith:"|"}),!0),this.lastIndex=0}exec(i){this.matcherRe.lastIndex=this.lastIndex;let r=this.matcherRe.exec(i);if(!r)return null;let g=r.findIndex((w,P)=>P>0&&w!==void 0),N=this.matchIndexes[g];return r.splice(0,g),Object.assign(r,N)}}class l{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(i){if(this.multiRegexes[i])return this.multiRegexes[i];let r=new c;return this.rules.slice(i).forEach(([g,N])=>r.addRule(g,N)),r.compile(),this.multiRegexes[i]=r,r}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(i,r){if(this.rules.push([i,r]),r.type==="begin")this.count++}exec(i){let r=this.getMatcher(this.regexIndex);r.lastIndex=this.lastIndex;let g=r.exec(i);if(this.resumingScanAtSamePosition())if(g&&g.index===this.lastIndex);else{let N=this.getMatcher(0);N.lastIndex=this.lastIndex+1,g=N.exec(i)}if(g){if(this.regexIndex+=g.position+1,this.regexIndex===this.count)this.considerAll()}return g}}function b(i){let r=new l;if(i.contains.forEach((g)=>r.addRule(g.begin,{rule:g,type:"begin"})),i.terminatorEnd)r.addRule(i.terminatorEnd,{type:"end"});if(i.illegal)r.addRule(i.illegal,{type:"illegal"});return r}function _(i,r){let g=i;if(i.isCompiled)return g;[Dt,Lt,Xt,jt].forEach((w)=>w(i,r)),e.compilerExtensions.forEach((w)=>w(i,r)),i.__beforeBegin=null,[Bt,Ct,vt].forEach((w)=>w(i,r)),i.isCompiled=!0;let N=null;if(typeof i.keywords==="object"&&i.keywords.$pattern)i.keywords=Object.assign({},i.keywords),N=i.keywords.$pattern,delete i.keywords.$pattern;if(N=N||/\w+/,i.keywords)i.keywords=De(i.keywords,e.case_insensitive);if(g.keywordPatternRe=t(N,!0),r){if(!i.begin)i.begin=/\B|\b/;if(g.beginRe=t(g.begin),!i.end&&!i.endsWithParent)i.end=/\B|\b/;if(i.end)g.endRe=t(g.end);if(g.terminatorEnd=H(g.end)||"",i.endsWithParent&&r.terminatorEnd)g.terminatorEnd+=(i.end?"|":"")+r.terminatorEnd}if(i.illegal)g.illegalRe=t(i.illegal);if(!i.contains)i.contains=[];if(i.contains=[].concat(...i.contains.map(function(w){return zt(w==="self"?i:w)})),i.contains.forEach(function(w){_(w,g)}),i.starts)_(i.starts,r);return g.matcher=b(g),g}if(!e.compilerExtensions)e.compilerExtensions=[];if(e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=D(e.classNameAliases||{}),_(e)}function Ce(e){if(!e)return!1;return e.endsWithParent||Ce(e.starts)}function zt(e){if(e.variants&&!e.cachedVariants)e.cachedVariants=e.variants.map(function(t){return D(e,{variants:null},t)});if(e.cachedVariants)return e.cachedVariants;if(Ce(e))return D(e,{starts:e.starts?D(e.starts):null});if(Object.isFrozen(e))return D(e);return e}var Jt="11.12.0";class Le extends Error{constructor(e,t){super(e);this.name="HTMLInjectionError",this.html=t}}var te=we,Me=D,xe=Symbol("nomatch"),Yt=7,ve=function(e){let t=Object.create(null),c=Object.create(null),l=[],b=!0,_="Could not find the language '{}', did you forget to load/include a language module?",i={disableAutodetect:!0,name:"Plain text",contains:[]},r={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Re};function g(n){return r.noHighlightRe.test(n)}function N(n){let a=n.className+" ";a+=n.parentNode?n.parentNode.className:"";let h=r.languageDetectRe.exec(a);if(h){let d=I(h[1]);if(!d)_e(_.replace("{}",h[1])),_e("Falling back to no-highlight mode for this block.",n);return d?h[1]:"no-highlight"}return a.split(/\s+/).find((d)=>g(d)||I(d))}function w(n,a,h){let d="",M="";if(typeof a==="object")d=n,h=a.ignoreIllegals,M=a.language;else v("10.7.0","highlight(lang, code, ...args) has been deprecated."),v("10.7.0",`Please use highlight(code, options) instead.
2
+ https://github.com/highlightjs/highlight.js/issues/2277`),M=n,d=a;if(h===void 0)h=!0;let S={code:d,language:M};K("before:highlight",S);let k=S.result?S.result:P(S.language,S.code,h);return k.code=S.code,K("after:highlight",k),k}function P(n,a,h,d){let M=Object.create(null);function S(s,o){return s.keywords[o]}function k(){if(!u.keywords){x.addText(E);return}let s=0;u.keywordPatternRe.lastIndex=0;let o=u.keywordPatternRe.exec(E),f="";while(o){f+=E.substring(s,o.index);let p=A.case_insensitive?o[0].toLowerCase():o[0],O=S(u,p);if(O){let[T,it]=O;if(x.addText(f),f="",M[p]=(M[p]||0)+1,M[p]<=Yt)F+=it;if(T.startsWith("_"))f+=o[0];else{let st=A.classNameAliases[T]||T;y(o[0],st)}}else f+=o[0];s=u.keywordPatternRe.lastIndex,o=u.keywordPatternRe.exec(E)}f+=E.substring(s),x.addText(f)}function W(){if(E==="")return;let s=null;if(typeof u.subLanguage==="string"){if(!t[u.subLanguage]){x.addText(E);return}s=P(u.subLanguage,E,!0,pe[u.subLanguage]),pe[u.subLanguage]=s._top}else s=V(E,u.subLanguage.length?u.subLanguage:null);if(u.relevance>0)F+=s.relevance;x.__addSublanguage(s._emitter,s.language)}function R(){if(u.subLanguage!=null)W();else k();E=""}function y(s,o){if(s==="")return;x.startScope(o),x.addText(s),x.endScope()}function ue(s,o){let f=1,p=o.length-1;while(f<=p){if(!s._emit[f]){f++;continue}let O=A.classNameAliases[s[f]]||s[f],T=o[f];if(O)y(T,O);else E=T,k(),E="";f++}}function fe(s,o){if(s.scope&&typeof s.scope==="string")x.openNode(A.classNameAliases[s.scope]||s.scope);if(s.beginScope){if(s.beginScope._wrap)y(E,A.classNameAliases[s.beginScope._wrap]||s.beginScope._wrap),E="";else if(s.beginScope._multi)ue(s.beginScope,o),E=""}return u=Object.create(s,{parent:{value:u}}),u}function ge(s,o,f){let p=ft(s.endRe,f);if(p){if(s["on:end"]){let O=new ne(s);if(s["on:end"](o,O),O.isMatchIgnored)p=!1}if(p){while(s.endsParent&&s.parent)s=s.parent;return s}}if(s.endsWithParent)return ge(s.parent,o,f)}function Qe(s){if(u.matcher.regexIndex===0)return E+=s[0],1;else return ee=!0,0}function qe(s){let o=s[0],f=s.rule,p=new ne(f),O=[f.__beforeBegin,f["on:begin"]];for(let T of O){if(!T)continue;if(T(s,p),p.isMatchIgnored)return Qe(o)}if(f.skip)E+=o;else{if(f.excludeBegin)E+=o;if(R(),!f.returnBegin&&!f.excludeBegin)E=o}return fe(f,s),f.returnBegin?0:o.length}function et(s){let o=s[0],f=a.substring(s.index),p=ge(u,s,f);if(!p)return xe;let O=u;if(u.endScope&&u.endScope._wrap)R(),y(o,u.endScope._wrap);else if(u.endScope&&u.endScope._multi)R(),ue(u.endScope,s);else if(O.skip)E+=o;else{if(!(O.returnEnd||O.excludeEnd))E+=o;if(R(),O.excludeEnd)E=o}do{if(u.scope)x.closeNode();if(!u.skip&&!u.subLanguage)F+=u.relevance;u=u.parent}while(u!==p.parent);if(p.starts)fe(p.starts,s);return O.returnEnd?0:o.length}function tt(){let s=[];for(let o=u;o!==A;o=o.parent)if(o.scope)s.unshift(o.scope);s.forEach((o)=>x.openNode(o))}let X={};function he(s,o){let f=o&&o[0];if(E+=s,f==null)return R(),0;if(X.type==="begin"&&o.type==="end"&&X.index===o.index&&f===""){if(E+=a.slice(o.index,o.index+1),!b){let p=Error(`0 width match regex (${n})`);throw p.languageName=n,p.badRule=X.rule,p}return 1}if(X=o,o.type==="begin")return qe(o);else if(o.type==="illegal"&&!h){let p=Error('Illegal lexeme "'+f+'" for mode "'+(u.scope||"<unnamed>")+'"');throw p.mode=u,p}else if(o.type==="end"){let p=et(o);if(p!==xe)return p}if(o.type==="illegal"&&f===""){if(o.index===a.length);else E+=`
3
+ `;return 1}if(q>1e5&&q>o.index*3)throw Error("potential infinite loop, way more iterations than matches");return E+=f,f.length}let A=I(n);if(!A)throw C(_.replace("{}",n)),Error('Unknown language: "'+n+'"');let nt=Ft(A),Q="",u=d||nt,pe={},x=new r.__emitter(r);tt();let E="",F=0,B=0,q=0,ee=!1;try{if(!A.__emitTokens){u.matcher.considerAll();for(;;){if(q++,ee)ee=!1;else u.matcher.considerAll();u.matcher.lastIndex=B;let s=u.matcher.exec(a);if(!s)break;let o=a.substring(B,s.index),f=he(o,s);B=s.index+f}he(a.substring(B))}else A.__emitTokens(a,x);return x.finalize(),Q=x.toHTML(),{language:n,value:Q,relevance:F,illegal:!1,_emitter:x,_top:u}}catch(s){if(s.message&&s.message.includes("Illegal"))return{language:n,value:te(a),illegal:!0,relevance:0,_illegalBy:{message:s.message,index:B,context:a.slice(B-100,B+100),mode:s.mode,resultSoFar:Q},_emitter:x};else if(b)return{language:n,value:te(a),illegal:!1,relevance:0,errorRaised:s,_emitter:x,_top:u};else throw s}}function $e(n){let a={value:te(n),illegal:!1,relevance:0,_top:i,_emitter:new r.__emitter(r)};return a._emitter.addText(n),a}function V(n,a){a=a||r.languages||Object.keys(t);let h=$e(n),d=a.filter(I).filter(le).map((R)=>P(R,n,!1));d.unshift(h);let M=d.sort((R,y)=>{if(R.relevance!==y.relevance)return y.relevance-R.relevance;if(R.language&&y.language){if(I(R.language).supersetOf===y.language)return 1;else if(I(y.language).supersetOf===R.language)return-1}return 0}),[S,k]=M,W=S;return W.secondBest=k,W}function Ge(n,a,h){let d=a&&c[a]||h;n.classList.add("hljs"),n.classList.add(`language-${d}`)}function m(n){let a=null,h=N(n);if(g(h))return;if(K("before:highlightElement",{el:n,language:h}),n.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",n);return}if(n.children.length>0){if(!r.ignoreUnescapedHTML)console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(n);if(r.throwUnescapedHTML)throw new Le("One of your code blocks includes unescaped HTML.",n.innerHTML)}a=n;let d=a.textContent,M=h?w(d,{language:h,ignoreIllegals:!0}):V(d);if(n.innerHTML=M.value,n.dataset.highlighted="yes",Ge(n,h,M.language),n.result={language:M.language,re:M.relevance,relevance:M.relevance},M.secondBest)n.secondBest={language:M.secondBest.language,relevance:M.secondBest.relevance};K("after:highlightElement",{el:n,result:M,text:d})}function Ke(n){r=Me(r,n)}let We=()=>{G(),v("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Xe(){G(),v("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let oe=!1;function G(){function n(){G()}if(document.readyState==="loading"){if(!oe)window.addEventListener("DOMContentLoaded",n,!1);oe=!0;return}document.querySelectorAll(r.cssSelector).forEach(m)}function Fe(n,a){let h=null;try{h=a(e)}catch(d){if(C("Language definition for '{}' could not be registered.".replace("{}",n)),!b)throw d;else C(d);h=i}if(!h.name)h.name=n;if(t[n]=h,h.rawDefinition=a.bind(null,e),h.aliases)ae(h.aliases,{languageName:n})}function ze(n){delete t[n];for(let a of Object.keys(c))if(c[a]===n)delete c[a]}function Je(){return Object.keys(t)}function I(n){return n=(n||"").toLowerCase(),t[n]||t[c[n]]}function ae(n,{languageName:a}){if(typeof n==="string")n=[n];n.forEach((h)=>{c[h.toLowerCase()]=a})}function le(n){let a=I(n);return a&&!a.disableAutodetect}function Ye(n){if(n["before:highlightBlock"]&&!n["before:highlightElement"])n["before:highlightElement"]=(a)=>{n["before:highlightBlock"](Object.assign({block:a.el},a))};if(n["after:highlightBlock"]&&!n["after:highlightElement"])n["after:highlightElement"]=(a)=>{n["after:highlightBlock"](Object.assign({block:a.el},a))}}function Ze(n){Ye(n),l.push(n)}function Ve(n){let a=l.indexOf(n);if(a!==-1)l.splice(a,1)}function K(n,a){let h=n;l.forEach(function(d){if(d[h])d[h](a)})}function me(n){return v("10.7.0","highlightBlock will be removed entirely in v12.0"),v("10.7.0","Please use highlightElement now."),m(n)}Object.assign(e,{highlight:w,highlightAuto:V,highlightAll:G,highlightElement:m,highlightBlock:me,configure:Ke,initHighlighting:We,initHighlightingOnLoad:Xe,registerLanguage:Fe,unregisterLanguage:ze,listLanguages:Je,getLanguage:I,registerAliases:ae,autoDetection:le,inherit:Me,addPlugin:Ze,removePlugin:Ve}),e.debugMode=function(){b=!1},e.safeMode=function(){b=!0},e.versionString=Jt,e.regex={concat:L,lookahead:Se,either:Y,optional:lt,anyNumberOfTimes:at};for(let n in z)if(typeof z[n]==="object")Oe(z[n]);return Object.assign(e,z),e},j=ve({});j.newInstance=()=>ve({});je.exports=j;j.HighlightJS=j;j.default=j});var He=Zt(Pe(),1);var ce=He.default;var Vt={scope:"number",match:"([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",relevance:0};function Ue(e){let t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},c={match:/[{}[\],:]/,className:"punctuation",relevance:0},l=["true","false","null"],b={scope:"literal",beginKeywords:l.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:l},contains:[t,c,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,Vt,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}ce.registerLanguage("json",Ue);var nn=(e)=>ce.highlight(e,{language:"json",ignoreIllegals:!0}).value;export{nn as highlightJSON};
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
2
+ <rect width="64" height="64" rx="12" fill="#0a1016"/>
3
+ <path d="M16 17v30M16 32h20M36 17v30M48 17 38 47" fill="none" stroke="#a2ff4f" stroke-width="6" stroke-linecap="square"/>
4
+ </svg>
@@ -0,0 +1,93 @@
1
+ Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ThinItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLight.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Light.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-LightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Regular.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Italic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Medium.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-MediumItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Bold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-BoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved.
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
@@ -0,0 +1,93 @@
1
+ Copyright 2023 The Schibsted-Grotesk Project Authors (https://github.com/schibsted/schibsted-grotesk) SchibstedGrotesk-Italic[wght].ttf: Copyright 2023 The Schibsted-Grotesk Project Authors (https://github.com/schibsted/schibsted-grotesk)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,19 @@
1
+ import { type DatabaseConnection, type InvocationLimits } from "@hulla/db/config";
2
+ import { type SchemaDefinition } from "@hulla/db/schema";
3
+ export type { StudioField, StudioTable, StudioSchema, StudioRow, StudioPage, StudioDeleteResult } from "./types.ts";
4
+ export interface StudioOptions {
5
+ readonly schema: SchemaDefinition;
6
+ readonly connection: DatabaseConnection;
7
+ readonly limits?: InvocationLimits | undefined;
8
+ readonly port?: number;
9
+ readonly readOnly?: boolean;
10
+ /** A supervisor may retain access across development worker restarts. */
11
+ readonly accessToken?: string | undefined;
12
+ }
13
+ export interface Studio {
14
+ readonly url: string;
15
+ readonly closed: Promise<void>;
16
+ close(): Promise<void>;
17
+ }
18
+ /** Private loopback operator surface. Never mounts on application function routes. */
19
+ export declare function startStudio(options: StudioOptions): Promise<Studio>;
@@ -0,0 +1,84 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="color-scheme" content="light dark">
7
+ <title>Hulla Studio</title>
8
+ <link rel="icon" href="/favicon.svg" type="image/svg+xml">
9
+ <script src="/theme.js"></script>
10
+ <link rel="stylesheet" href="/style.css">
11
+ <script type="module" src="/app.js"></script>
12
+ </head>
13
+ <body>
14
+ <svg class="icon-library" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
15
+ <defs>
16
+ <symbol id="i-database" viewBox="0 0 24 24"><ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></symbol>
17
+ <symbol id="i-table" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M3 10h18M9 10v10"/></symbol>
18
+ <symbol id="i-search" viewBox="0 0 24 24"><circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 4 4"/></symbol>
19
+ <symbol id="i-chevron" viewBox="0 0 24 24"><path d="m9 5 7 7-7 7"/></symbol>
20
+ <symbol id="i-refresh" viewBox="0 0 24 24"><path d="M20 7v5h-5M4 17v-5h5M6 6a8 8 0 0 1 13 3M18 18a8 8 0 0 1-13-3"/></symbol>
21
+ <symbol id="i-filter" viewBox="0 0 24 24"><path d="M4 5h16M7 12h10M10 19h4"/></symbol>
22
+ <symbol id="i-code" viewBox="0 0 24 24"><path d="m8 6-6 6 6 6m8-12 6 6-6 6m-3-15-2 18"/></symbol>
23
+ <symbol id="i-arrow" viewBox="0 0 24 24"><path d="M5 12h14m-6-6 6 6-6 6"/></symbol>
24
+ <symbol id="i-close" viewBox="0 0 24 24"><path d="m6 6 12 12M6 18 18 6"/></symbol>
25
+ <symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5"/></symbol>
26
+ <symbol id="i-moon" viewBox="0 0 24 24"><path d="M20.5 13.4A9 9 0 0 1 10.6 3.5a9 9 0 1 0 9.9 9.9Z"/></symbol>
27
+ <symbol id="i-lock" viewBox="0 0 24 24"><rect x="5" y="10" width="14" height="11" rx="2"/><path d="M8 10V6a4 4 0 0 1 8 0v4m-4 4v3"/></symbol>
28
+ <symbol id="i-check" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6"/></symbol>
29
+ <symbol id="i-key" viewBox="0 0 24 24"><circle cx="8" cy="8" r="5"/><path d="m12 12 9 9m-6-6 3-3m0 6 3-3"/></symbol>
30
+ <symbol id="i-map" viewBox="0 0 24 24"><rect x="2" y="3" width="7" height="6" rx="1"/><rect x="15" y="15" width="7" height="6" rx="1"/><path d="M5 9v9h10M9 6h9v9"/></symbol>
31
+ <symbol id="i-trash" viewBox="0 0 24 24"><path d="M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7m4-7v7"/></symbol>
32
+ <symbol id="i-download" viewBox="0 0 24 24"><path d="M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"/></symbol>
33
+ </defs>
34
+ </svg>
35
+ <aside class="sidebar">
36
+ <a class="brand" href="/" aria-label="Hulla Studio home"><img class="brand-mark" src="/favicon.svg" width="28" height="28" alt=""><span>hulla<span class="brand-dot">.</span><span class="brand-product">studio</span></span></a>
37
+ <div class="database-card"><span class="database-icon"><svg class="icon"><use href="#i-database"/></svg></span><div><strong id="namespace">Connecting…</strong><small>PostgreSQL <span class="status-dot"></span> <span id="database-state">Connecting</span></small></div></div>
38
+ <div class="sidebar-section"><span>Workspace</span><span class="local-label">LOCAL</span></div>
39
+ <div class="workspace-navigation"><button id="nav-map" class="workspace-link" aria-current="page"><svg class="icon"><use href="#i-map"/></svg>Schema map</button><button id="nav-catalog" class="workspace-link"><svg class="icon"><use href="#i-code"/></svg>Schema catalog</button></div>
40
+ <div class="section-label"><span>Tables</span><span id="table-count">—</span></div>
41
+ <label class="search-label"><svg class="icon"><use href="#i-search"/></svg><input id="table-search" type="search" aria-label="Find a table" placeholder="Find a table…" autocomplete="off"></label>
42
+ <nav id="tables" aria-label="Database tables"></nav>
43
+ <div class="sidebar-bottom"><div><span class="status-dot"></span> Direct database connection</div><span>Powered by <strong>Hulla DB</strong></span></div>
44
+ </aside>
45
+ <main>
46
+ <header class="topbar"><div class="breadcrumb"><svg class="icon"><use href="#i-database"/></svg><span>Database</span><svg class="icon"><use href="#i-chevron"/></svg><strong id="breadcrumb">Explorer</strong></div><div class="topbar-actions"><span id="access" class="access">Connecting</span><span class="topbar-divider"></span><button id="theme-toggle" class="button ghost icon-button" type="button" aria-label="Switch to dark theme"><svg class="icon theme-sun"><use href="#i-sun"/></svg><svg class="icon theme-moon"><use href="#i-moon"/></svg></button></div></header>
47
+ <section class="workspace">
48
+ <div id="notice" class="notice" role="status" hidden></div>
49
+ <section id="map-page" class="studio-page" aria-labelledby="map-title">
50
+ <div class="heading"><div><div class="eyebrow">WORKSPACE OVERVIEW</div><h1 id="map-title">Your schema, connected.</h1><p>Explore table relationships. Open a table to browse and manage its data.</p></div></div>
51
+ <div id="schema-stats" class="schema-stats"></div>
52
+ <div id="schema-diagram" class="diagram-host"></div>
53
+ </section>
54
+ <section id="catalog-page" class="studio-page" aria-labelledby="catalog-title" hidden><div class="heading"><div><div class="eyebrow">SCHEMA CATALOG</div><h1 id="catalog-title">Find your way around.</h1><p>Search tables and fields, inspect constraints, and follow references.</p></div></div><div id="schema-catalog" class="catalog-host"></div></section>
55
+ <section id="table-detail" class="studio-page" aria-labelledby="table-title" hidden>
56
+ <div class="heading"><div class="heading-title"><span class="table-heading-icon"><svg class="icon"><use href="#i-table"/></svg></span><div><h1 id="table-title">Database explorer</h1><p id="table-description">Choose a table to explore its data and structure.</p></div></div><button id="refresh" class="button secondary" disabled><svg class="icon"><use href="#i-refresh"/></svg><span>Refresh</span></button></div>
57
+ <div class="view-bar"><div class="tabs" role="tablist" aria-label="Table view"><button id="data-tab" role="tab" aria-selected="true" aria-controls="data-view"><svg class="icon"><use href="#i-table"/></svg>Data</button><button id="schema-tab" role="tab" tabindex="-1" aria-selected="false" aria-controls="schema-view"><svg class="icon"><use href="#i-code"/></svg>Schema</button></div><span class="view-description" id="view-description">Table contents</span></div>
58
+ <section id="data-view" role="tabpanel" aria-labelledby="data-tab">
59
+ <div class="toolbar"><form id="filter-form"><svg class="icon filter-icon"><use href="#i-filter"/></svg><select id="filter-field" aria-label="Filter field"></select><select id="filter-operator" aria-label="Filter operator"></select><input id="filter-value" placeholder="Enter a value…" aria-label="Filter value"><button class="button secondary" type="submit">Add filter</button></form><label class="page-size">Rows per page <select id="page-size"><option>25</option><option selected>50</option><option>100</option><option>200</option></select></label></div>
60
+ <div id="filter-chips" class="filter-chips"></div>
61
+ <div id="selection-bar" class="selection-bar" hidden><span id="selection-count"></span><div><button id="clear-selection" class="button ghost" type="button">Clear</button><button id="export-selected" class="button secondary" type="button"><svg class="icon"><use href="#i-download"/></svg>Export JSON</button><button id="delete-selected" class="button danger" type="button"><svg class="icon"><use href="#i-trash"/></svg>Delete selected</button></div></div>
62
+ <div class="grid-frame"><table id="grid"><thead></thead><tbody></tbody></table><div id="empty" class="empty"><span class="empty-symbol"><svg class="icon"><use href="#i-table"/></svg></span><h2>Database explorer</h2><p>Your tables will appear here when Studio connects.</p></div></div>
63
+ <footer class="grid-footer"><span id="row-count">No table selected</span><div><button id="previous" class="button ghost" disabled><svg class="icon arrow-left"><use href="#i-arrow"/></svg>Previous</button><span id="page-number">Page 1</span><button id="next" class="button ghost" disabled>Next<svg class="icon"><use href="#i-arrow"/></svg></button></div></footer>
64
+ <p class="hint" id="edit-hint">Select a row to inspect its values.</p>
65
+ </section>
66
+ <section id="schema-view" role="tabpanel" aria-labelledby="schema-tab" hidden></section>
67
+ </section>
68
+ </section>
69
+ <footer class="app-footer"><span><span class="status-dot"></span><span id="connection-status">Connecting to database</span></span><span class="package-signature">@hulla/db <span class="footer-separator">/</span> Studio</span></footer>
70
+ </main>
71
+ <dialog id="editor" aria-labelledby="editor-title">
72
+ <form id="editor-form">
73
+ <div class="editor-header"><div><div class="eyebrow" id="editor-table">ROW INSPECTOR</div><h2 id="editor-title">Edit row</h2></div><button id="close-editor" class="button ghost icon-button" type="button" aria-label="Close row inspector"><svg class="icon"><use href="#i-close"/></svg></button></div>
74
+ <p class="editor-note" id="editor-note">Changes are validated and saved in one managed transaction.</p>
75
+ <div id="editor-fields"></div>
76
+ <div id="editor-error" class="notice" role="alert" hidden></div>
77
+ <div class="editor-footer"><button id="cancel-editor" class="button secondary" type="button">Cancel</button><button id="save-row" class="button primary" type="submit">Save changes<svg class="icon"><use href="#i-check"/></svg></button></div>
78
+ </form>
79
+ </dialog>
80
+ <dialog id="delete-dialog" class="confirmation-dialog" aria-labelledby="delete-title" aria-describedby="delete-description">
81
+ <form id="delete-form"><div class="confirmation-heading"><span class="danger-symbol"><svg class="icon"><use href="#i-trash"/></svg></span><h2 id="delete-title">Delete selected rows?</h2></div><p id="delete-description"></p><div id="delete-effects"></div><div id="delete-error" class="notice" role="alert" hidden></div><div class="confirmation-actions"><button id="cancel-delete" class="button secondary" type="button">Cancel</button><button id="confirm-delete" class="button danger" type="submit">Delete rows</button></div></form>
82
+ </dialog>
83
+ </body>
84
+ </html>
package/dist/index.js ADDED
@@ -0,0 +1,303 @@
1
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
2
+ import { readFile } from "node:fs/promises";
3
+ import { createServer } from "node:http";
4
+ import { DatabaseError } from "@hulla/db";
5
+ import { defineConfig } from "@hulla/db/config";
6
+ import { createDatabase } from "@hulla/db/server";
7
+ import { compileSchema } from "@hulla/db/schema";
8
+ class HTTPError extends Error {
9
+ status;
10
+ constructor(status, message) { super(message); this.status = status; }
11
+ }
12
+ function record(value) {
13
+ if (!value || typeof value !== "object" || Array.isArray(value))
14
+ throw new HTTPError(400, "Expected an object");
15
+ return value;
16
+ }
17
+ function keys(value, allowed) {
18
+ if (Object.keys(value).some(key => !allowed.includes(key)))
19
+ throw new HTTPError(400, "Unknown request field");
20
+ }
21
+ function wire(value) {
22
+ if (typeof value === "bigint")
23
+ return value.toString();
24
+ if (Array.isArray(value))
25
+ return value.map(wire);
26
+ if (value && typeof value === "object")
27
+ return Object.fromEntries(Object.keys(value).sort().map(key => [key, wire(value[key])]));
28
+ return value;
29
+ }
30
+ function stored(table, row) {
31
+ return Object.fromEntries(Object.entries(table.fields).map(([name, field]) => [name, wire(field.encode(row[name]))]));
32
+ }
33
+ function equalSecret(actual, expected) {
34
+ const left = Buffer.from(actual), right = Buffer.from(expected);
35
+ return left.length === right.length && timingSafeEqual(left, right);
36
+ }
37
+ async function body(request) {
38
+ if (request.headers["content-type"]?.split(";")[0]?.trim() !== "application/json")
39
+ throw new HTTPError(415, "Use application/json");
40
+ const chunks = [];
41
+ let bytes = 0;
42
+ for await (const chunk of request) {
43
+ bytes += chunk.length;
44
+ if (bytes > 1024 * 1024)
45
+ throw new HTTPError(413, "Request exceeds 1 MiB");
46
+ chunks.push(Buffer.from(chunk));
47
+ }
48
+ try {
49
+ return record(JSON.parse(Buffer.concat(chunks).toString("utf8")));
50
+ }
51
+ catch {
52
+ throw new HTTPError(400, "Invalid JSON object");
53
+ }
54
+ }
55
+ function json(response, status, value) {
56
+ const text = JSON.stringify(value);
57
+ if (Buffer.byteLength(text) > 8 * 1024 * 1024)
58
+ throw new HTTPError(413, "Result exceeds 8 MiB; use a smaller page");
59
+ response.writeHead(status, { "Content-Type": "application/json; charset=utf-8" });
60
+ response.end(text);
61
+ }
62
+ /** Private loopback operator surface. Never mounts on application function routes. */
63
+ export async function startStudio(options) {
64
+ const connection = defineConfig({ database: { server: options.connection } }).database.server;
65
+ const port = options.port ?? 4983;
66
+ if (!Number.isInteger(port) || port < 0 || port > 65535)
67
+ throw new TypeError("Invalid Studio port");
68
+ const readOnly = options.readOnly ?? process.env.NODE_ENV === "production";
69
+ if (typeof readOnly !== "boolean")
70
+ throw new TypeError("Invalid Studio access mode");
71
+ const tables = new Map(compileSchema(options.schema).map(table => [table.name, table]));
72
+ const assets = new Map();
73
+ const directory = new URL(import.meta.url.endsWith(".ts") ? "../dist/" : "./", import.meta.url);
74
+ try {
75
+ for (const [path, file, type] of [
76
+ ["/", "index.html", "text/html; charset=utf-8"],
77
+ ["/theme.js", "theme.js", "text/javascript; charset=utf-8"], ["/style.css", "style.css", "text/css; charset=utf-8"],
78
+ ["/favicon.svg", "favicon.svg", "image/svg+xml"],
79
+ ["/fonts/schibsted-grotesk.woff2", "fonts/schibsted-grotesk.woff2", "font/woff2"],
80
+ ["/fonts/ibm-plex-mono.woff2", "fonts/ibm-plex-mono.woff2", "font/woff2"],
81
+ ]) {
82
+ assets.set(path, { content: await readFile(new URL(file, directory)), type: type });
83
+ }
84
+ const scripts = JSON.parse(await readFile(new URL("browser-assets.json", directory), "utf8"));
85
+ if (!Array.isArray(scripts) || !scripts.includes("app.js") || scripts.length > 32
86
+ || scripts.some(file => typeof file !== "string" || !(file === "app.js" || /^chunks\/[A-Za-z0-9_-]+\.js$/.test(file))))
87
+ throw new Error("Invalid browser asset manifest");
88
+ for (const file of scripts) {
89
+ assets.set(`/${file}`, { content: await readFile(new URL(file, directory)), type: "text/javascript; charset=utf-8" });
90
+ }
91
+ }
92
+ catch {
93
+ throw new Error("Studio browser assets are missing; build @hulla/db-studio before starting it");
94
+ }
95
+ const token = options.accessToken ?? randomBytes(32).toString("base64url"), signingKey = randomBytes(32);
96
+ if (!/^[A-Za-z0-9_-]{43}$/.test(token))
97
+ throw new TypeError("Studio access tokens must be 32-byte base64url secrets");
98
+ const snapshot = (table, values) => createHmac("sha256", signingKey).update(JSON.stringify(wire([table.name, values]))).digest("hex");
99
+ const row = (table, value) => {
100
+ const values = stored(table, value);
101
+ return { values, snapshot: snapshot(table, values) };
102
+ };
103
+ const metadata = {
104
+ namespace: connection.namespace ?? "hulla", readOnly,
105
+ tables: [...tables.values()].map(table => ({
106
+ name: table.name, primaryKey: table.primaryKey, keyGeneration: table.keyGeneration,
107
+ indexes: table.indexes, unique: table.unique, checks: wire(table.checks),
108
+ fields: Object.entries(table.fields).map(([name, field]) => ({
109
+ name, scalar: field.scalar, nullable: field.allowsNull, hasDefault: field.hasDefault,
110
+ ...(field.hasDefault ? { default: wire(field.encode(field.defaultValue)) } : {}),
111
+ ...(field.target === undefined ? {} : { reference: String(field.target), onDelete: field.onDelete ?? "restrict" }),
112
+ ...(field.constraints ? { constraints: wire(field.constraints) } : {}),
113
+ ...(field.precision === undefined ? {} : { precision: field.precision }),
114
+ ...(field.jsonShape ? { jsonShape: field.jsonShape } : {}),
115
+ })),
116
+ })),
117
+ };
118
+ const database = createDatabase(options.schema, connection, {
119
+ ...options.limits,
120
+ readRows: Math.min(options.limits?.readRows ?? 1000, 1000),
121
+ readBytes: Math.min(options.limits?.readBytes ?? 8 * 1024 * 1024, 8 * 1024 * 1024),
122
+ });
123
+ function tableFor(value) {
124
+ if (typeof value !== "string" || !tables.has(value))
125
+ throw new HTTPError(400, "Unknown table");
126
+ return tables.get(value);
127
+ }
128
+ async function page(input) {
129
+ keys(input, ["table", "filters", "sort", "limit", "cursor"]);
130
+ const table = tableFor(input.table);
131
+ const limit = input.limit ?? 50;
132
+ if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1 || limit > 200)
133
+ throw new HTTPError(400, "Page size must be from 1 to 200");
134
+ if (input.cursor !== undefined && input.cursor !== null && (typeof input.cursor !== "string" || input.cursor.length > 65536))
135
+ throw new HTTPError(400, "Invalid page cursor");
136
+ let query = database.select(table.name);
137
+ if (input.filters !== undefined) {
138
+ if (!Array.isArray(input.filters) || input.filters.length > 12)
139
+ throw new HTTPError(400, "Use at most 12 filters");
140
+ for (const item of input.filters) {
141
+ const filter = record(item);
142
+ keys(filter, ["field", "operator", "value"]);
143
+ const field = typeof filter.field === "string" ? table.fields[filter.field] : undefined;
144
+ const operator = filter.operator;
145
+ if (!field || typeof operator !== "string" || !["=", "!=", ">", ">=", "<", "<=", "contains", "is", "is not"].includes(operator))
146
+ throw new HTTPError(400, "Invalid filter");
147
+ const value = operator === "contains" ? filter.value : filter.value === null ? null : field.decode(filter.value);
148
+ if (operator === "contains" && field.scalar !== "string")
149
+ throw new HTTPError(400, "Contains requires a text field");
150
+ // The public query builder owns operator/type validation and SQL compilation.
151
+ query = query.where(filter.field, operator, value);
152
+ }
153
+ }
154
+ if (input.sort !== undefined) {
155
+ const sort = record(input.sort);
156
+ keys(sort, ["field", "direction"]);
157
+ if (typeof sort.field !== "string" || !table.fields[sort.field] || !["asc", "desc"].includes(String(sort.direction)))
158
+ throw new HTTPError(400, "Invalid sort");
159
+ query = query.orderBy(sort.field, sort.direction);
160
+ }
161
+ const result = await query.paginate({ limit, cursor: input.cursor ?? null });
162
+ return { rows: result.page.map(value => row(table, value)), cursor: result.cursor };
163
+ }
164
+ async function update(input) {
165
+ if (readOnly)
166
+ throw new HTTPError(403, "Studio is read-only");
167
+ keys(input, ["table", "key", "snapshot", "patch"]);
168
+ const table = tableFor(input.table), patch = record(input.patch);
169
+ if (!Object.keys(patch).length || Object.keys(patch).some(name => name === table.primaryKey || !Object.hasOwn(table.fields, name)))
170
+ throw new HTTPError(400, "Patch must contain editable fields; primary keys cannot change");
171
+ if (typeof input.snapshot !== "string" || !/^[a-f0-9]{64}$/.test(input.snapshot))
172
+ throw new HTTPError(400, "Invalid row snapshot");
173
+ const expected = input.snapshot;
174
+ const key = table.fields[table.primaryKey].decode(input.key);
175
+ const decoded = Object.fromEntries(Object.entries(patch).map(([name, value]) => [name, table.fields[name].decode(value)]));
176
+ return database.transaction(async (tx) => {
177
+ const current = await tx.select(table.name).where({ [table.primaryKey]: key }).unique();
178
+ if (!current || !equalSecret(snapshot(table, stored(table, current)), expected))
179
+ throw new HTTPError(409, "This row changed or was deleted. Reload it before saving.");
180
+ const result = await tx.update(table.name, decoded).where({ [table.primaryKey]: key }).expectRows(1);
181
+ return row(table, result[0]);
182
+ }, { retries: 2 });
183
+ }
184
+ async function deleteRows(input) {
185
+ if (readOnly)
186
+ throw new HTTPError(403, "Studio is read-only");
187
+ keys(input, ["table", "rows"]);
188
+ const table = tableFor(input.table);
189
+ if (!Array.isArray(input.rows) || input.rows.length < 1 || input.rows.length > 200)
190
+ throw new HTTPError(400, "Select from 1 to 200 rows");
191
+ const primary = table.fields[table.primaryKey];
192
+ const expected = new Map();
193
+ const identities = input.rows.map(item => {
194
+ const selection = record(item);
195
+ keys(selection, ["key", "snapshot"]);
196
+ if (typeof selection.snapshot !== "string" || !/^[a-f0-9]{64}$/.test(selection.snapshot))
197
+ throw new HTTPError(400, "Invalid row snapshot");
198
+ const key = primary.decode(selection.key), identity = JSON.stringify(wire(primary.encode(key)));
199
+ if (expected.has(identity))
200
+ throw new HTTPError(400, "Select each row only once");
201
+ expected.set(identity, selection.snapshot);
202
+ return key;
203
+ });
204
+ return database.transaction(async (tx) => {
205
+ const current = await tx.select(table.name).where(table.primaryKey, "in", identities).limit(identities.length);
206
+ if (current.length !== identities.length || current.some(value => {
207
+ const values = stored(table, value), identity = JSON.stringify(values[table.primaryKey]);
208
+ return !equalSecret(snapshot(table, values), expected.get(identity) ?? "");
209
+ }))
210
+ throw new HTTPError(409, "A selected row changed or was deleted. Refresh the table and select the rows again.");
211
+ await tx.delete(table.name).where(table.primaryKey, "in", identities).expectRows(identities.length);
212
+ return { deleted: identities.length };
213
+ }, { retries: 2 });
214
+ }
215
+ let origin = "", active = 0;
216
+ const server = createServer((request, response) => {
217
+ response.setHeader("Cache-Control", "no-store");
218
+ response.setHeader("X-Content-Type-Options", "nosniff");
219
+ response.setHeader("Referrer-Policy", "no-referrer");
220
+ response.setHeader("Content-Security-Policy", "default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self'; connect-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'");
221
+ void (async () => {
222
+ if (`http://${request.headers.host}` !== origin || (request.headers.origin !== undefined && request.headers.origin !== origin))
223
+ throw new HTTPError(403, "Studio only accepts requests from its own loopback origin");
224
+ if (active >= 16)
225
+ throw new HTTPError(503, "Studio is busy; try again shortly");
226
+ active++;
227
+ try {
228
+ const path = new URL(request.url ?? "/", origin).pathname;
229
+ const asset = assets.get(path);
230
+ if (asset && request.method === "GET") {
231
+ if (asset.type === "font/woff2")
232
+ response.setHeader("Cache-Control", "private, max-age=86400");
233
+ response.writeHead(200, { "Content-Type": asset.type });
234
+ response.end(asset.content);
235
+ return;
236
+ }
237
+ if (!path.startsWith("/api/"))
238
+ throw new HTTPError(404, "Not found");
239
+ if (!equalSecret(request.headers.authorization ?? "", `Bearer ${token}`))
240
+ throw new HTTPError(401, "Open Studio using the access link printed in your terminal");
241
+ if (path === "/api/schema" && request.method === "GET")
242
+ json(response, 200, metadata);
243
+ else if (path === "/api/rows" && request.method === "POST")
244
+ json(response, 200, await page(await body(request)));
245
+ else if (path === "/api/update" && request.method === "POST")
246
+ json(response, 200, await update(await body(request)));
247
+ else if (path === "/api/delete" && request.method === "POST")
248
+ json(response, 200, await deleteRows(await body(request)));
249
+ else
250
+ throw new HTTPError(404, "Not found");
251
+ }
252
+ finally {
253
+ active--;
254
+ }
255
+ })().catch(error => {
256
+ if (response.destroyed || response.writableEnded)
257
+ return;
258
+ if (error instanceof HTTPError)
259
+ json(response, error.status, { error: error.message });
260
+ else if (error instanceof TypeError)
261
+ json(response, 400, { error: "Invalid field value or query. Check the schema and use database scalar values." });
262
+ else if (error instanceof DatabaseError) {
263
+ const conflict = ["serialization_conflict", "row_count_mismatch"].includes(error.code);
264
+ json(response, conflict ? 409 : 422, { error: conflict ? "This row changed. Reload it before saving." : error.message, code: error.code });
265
+ }
266
+ else
267
+ json(response, 500, { error: "Studio could not complete this operation" });
268
+ });
269
+ });
270
+ server.requestTimeout = 10_000;
271
+ server.headersTimeout = 5_000;
272
+ server.keepAliveTimeout = 2_000;
273
+ server.maxConnections = 32;
274
+ let finish;
275
+ const closed = new Promise(resolve => { finish = resolve; });
276
+ let closing;
277
+ const close = () => closing ??= (async () => {
278
+ const stopped = new Promise(resolve => server.close(() => resolve()));
279
+ server.closeAllConnections();
280
+ await Promise.all([database.close(), stopped]);
281
+ finish();
282
+ })();
283
+ try {
284
+ await new Promise((resolve, reject) => {
285
+ server.once("error", reject);
286
+ server.listen(port, "127.0.0.1", () => { server.off("error", reject); resolve(); });
287
+ });
288
+ const address = server.address();
289
+ if (!address || typeof address === "string")
290
+ throw new Error("Studio listener unavailable");
291
+ origin = `http://127.0.0.1:${address.port}`;
292
+ server.on("error", () => { void close(); });
293
+ server.on("close", () => { if (!closing)
294
+ void close(); });
295
+ return { url: `${origin}/#token=${token}`, closed, close };
296
+ }
297
+ catch (error) {
298
+ await close();
299
+ if (error.code === "EADDRINUSE")
300
+ throw Object.assign(new Error(`Studio port ${port} is in use; choose another with --studio-port`), { code: "EADDRINUSE" });
301
+ throw error;
302
+ }
303
+ }
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2006, Ivan Sagalaev.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ @font-face{font-family:Schibsted Grotesk;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/schibsted-grotesk.woff2)format(woff2)}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/ibm-plex-mono.woff2)format(woff2)}:root{--buncss-light:initial;--buncss-dark: ;color-scheme:light;--font-sans:"Schibsted Grotesk",ui-sans-serif,system-ui,sans-serif;--font-mono:"IBM Plex Mono",ui-monospace,"SFMono-Regular",Menlo,monospace;--color-background:oklch(.982 .012 250);--color-surface:oklch(.996 .004 250);--color-surface-raised:oklch(1 0 0);--color-foreground:oklch(.16 .04 265);--color-muted-foreground:oklch(.44 .04 255);--color-border:color-mix(in oklab,var(--color-foreground)14%,transparent);--color-primary:oklch(.52 .22 264);--color-primary-text:var(--color-primary);--color-primary-foreground:oklch(.99 .005 245);--color-focus-ring:color-mix(in oklab,var(--color-primary)82%,var(--color-foreground));--color-success:oklch(.54 .14 150);--color-warning:oklch(.77 .13 85);--color-danger:oklch(.56 .18 27);--color-on-emphasis:oklch(.99 .005 245);--color-disabled-foreground:color-mix(in oklab,var(--color-muted-foreground)75%,transparent);--color-disabled-surface:color-mix(in oklab,var(--color-foreground)3.5%,transparent);--color-disabled-border:color-mix(in oklab,var(--color-foreground)8%,transparent);--color-hover-surface:color-mix(in oklab,var(--color-foreground)8%,transparent);--color-selected-surface:color-mix(in oklab,var(--color-primary)10%,transparent);--color-selected-hover-surface:color-mix(in oklab,var(--color-primary)16%,transparent);--shadow-control:0 1px 2px oklch(0 0 0/.1),inset 0 1px 0 oklch(1 0 0/.12);--shadow-raised:0 2px 4px -2px oklch(0 0 0/.08),0 12px 32px -12px oklch(0 0 0/.14);--shadow-overlay:0 2px 4px -2px oklch(0 0 0/.12),0 24px 80px -28px oklch(0 0 0/.28);--radius-sm:.4375rem;--radius-md:.6875rem;--radius-lg:1rem;--code-property:oklch(.42 .09 210);--code-string:oklch(.4 .12 150);--code-number:oklch(.5 .18 28);--code-literal:oklch(.43 .19 315);--code-punctuation:oklch(.4 0 0)}:root[data-theme=dark]{--buncss-light: ;--buncss-dark:initial;color-scheme:dark;--color-background:oklch(.105 0 0);--color-surface:oklch(.145 0 0);--color-surface-raised:oklch(.19 0 0);--color-foreground:oklch(.97 0 0);--color-muted-foreground:oklch(.7 0 0);--color-border:color-mix(in oklab,var(--color-foreground)14%,transparent);--color-primary-text:color-mix(in oklab,var(--color-primary)55%,var(--color-foreground));--color-focus-ring:color-mix(in oklab,var(--color-primary)72%,white);--color-success:oklch(.73 .105 155);--color-warning:oklch(.77 .105 75);--color-danger:oklch(.68 .18 20);--code-property:oklch(.76 .1 205);--code-string:oklch(.74 .12 150);--code-number:oklch(.75 .15 32);--code-literal:oklch(.75 .16 320);--code-punctuation:oklch(.72 .025 250);--color-hover-surface:color-mix(in oklab,var(--color-foreground)12%,transparent);--color-selected-surface:color-mix(in oklab,var(--color-primary)18%,transparent);--color-selected-hover-surface:color-mix(in oklab,var(--color-primary)26%,transparent);--shadow-control:0 1px 2px oklch(0 0 0/.3),inset 0 1px 0 oklch(1 0 0/.1);--shadow-raised:0 2px 4px -2px oklch(0 0 0/.18),0 12px 32px -12px oklch(0 0 0/.5),inset 0 1px 0 oklch(1 0 0/.05);--shadow-overlay:0 2px 4px -2px oklch(0 0 0/.28),0 24px 80px -28px oklch(0 0 0/.9),inset 0 1px 0 oklch(1 0 0/.08)}*{box-sizing:border-box}html{font:13px/1.5 var(--font-sans);color:var(--color-foreground);background:var(--color-background);text-rendering:optimizeLegibility}body{display:flex;overflow:hidden;height:100dvh;min-height:480px;margin:0}button,input,select,textarea{font:inherit;color:inherit}button{cursor:pointer;touch-action:manipulation}button:disabled{cursor:not-allowed}a{color:inherit}[hidden]{display:none!important}:focus-visible{outline:2px solid var(--color-focus-ring);outline-offset:3px}::selection{background:var(--color-selected-hover-surface)}.icon-library{position:absolute;overflow:hidden;width:0;height:0}.icon{fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round;vertical-align:middle;flex-shrink:0;width:16px;height:16px}.status-dot{display:inline-block;background:var(--color-success);border-radius:50%;flex-shrink:0;width:5px;height:5px}.button{position:relative;display:inline-flex;letter-spacing:-.01em;white-space:nowrap;border:1px solid #0000;border-radius:7px;flex-shrink:0;justify-content:center;align-items: center;gap:7px;height:32px;padding:0 11px;transition:background-color .12s,border-color .12s,color .12s;font-size:12px;font-weight:500;line-height:1}.button .icon{width:14px;height:14px}.primary{background:var(--color-primary);border-color:var(--color-primary);color:var(--color-primary-foreground);box-shadow:var(--shadow-control)}.primary:hover:enabled{background:color-mix(in oklab,var(--color-primary)84%,var(--color-foreground))}.secondary{background:var(--color-disabled-surface);border-color:var(--color-border)}.secondary:hover:enabled{background:var(--color-hover-surface);border-color:color-mix(in oklab,var(--color-foreground)25%,transparent)}.ghost{color:var(--color-muted-foreground);background:0 0}.ghost:hover:enabled{color:var(--color-foreground);background:var(--color-hover-surface)}.button:disabled{color:var(--color-disabled-foreground);background:var(--color-disabled-surface);border-color:var(--color-disabled-border);box-shadow:none}.icon-button{width:32px;padding:0}input,select,textarea{border:1px solid color-mix(in oklab,var(--color-foreground)25%,transparent);border-radius:var(--radius-sm);background:var(--color-surface);color:var(--color-foreground);box-shadow:inset 0 1px 2px oklch(0 0 0/.025);min-width:0;padding:7px 10px;transition:border-color .15s,box-shadow .15s}input::placeholder,textarea::placeholder{color:var(--color-muted-foreground)}input:hover:enabled,select:hover:enabled,textarea:hover:enabled{border-color:color-mix(in oklab,var(--color-foreground)40%,transparent)}input:focus-visible{outline:0;border-color:var(--color-focus-ring);box-shadow:0 0 0 3px color-mix(in oklab,var(--color-focus-ring)22%,transparent)}select:focus-visible{outline:0;border-color:var(--color-focus-ring);box-shadow:0 0 0 3px color-mix(in oklab,var(--color-focus-ring)22%,transparent)}textarea:focus-visible{outline:0;border-color:var(--color-focus-ring);box-shadow:0 0 0 3px color-mix(in oklab,var(--color-focus-ring)22%,transparent)}input:disabled,select:disabled,textarea:disabled{background:var(--color-disabled-surface);border-color:var(--color-disabled-border);color:var(--color-disabled-foreground);cursor:not-allowed;box-shadow:none}.sidebar{display:flex;border-right:1px solid var(--color-border);background:var(--color-surface);flex-direction:column;flex-shrink:0;width:230px;padding:0 14px}.brand{display:flex;text-decoration:none;letter-spacing:-.055em;white-space:nowrap;flex-shrink:0;align-items: center;gap:10px;height:64px;padding-left:6px;font-size:19px;font-weight:650}.brand-mark{flex-shrink:0;width:28px;height:28px}.brand-dot{color:var(--color-primary)}.brand-product{letter-spacing:-.04em;color:var(--color-muted-foreground);font-size:18px;font-weight:400}.database-card{display:flex;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-background);align-items: center;gap:11px;margin:10px 0 26px;padding:12px 10px}.database-icon{display:grid;border:1px solid var(--color-border);background:var(--color-surface);color:var(--color-primary-text);border-radius:7px;place-items: center;width:31px;height:34px}.database-card>div{min-width:0}.database-card strong{display:block;letter-spacing:-.2px;overflow:hidden;text-overflow:ellipsis;font-size:12px;font-weight:550}.database-card small{display:flex;color:var(--color-muted-foreground);align-items: center;gap:6px;margin-top:3px;font-size:10px}.database-card small .status-dot{width:4px;height:4px;margin-left:3px}.sidebar-section,.section-label{display:flex;color:var(--color-muted-foreground);justify-content:space-between;align-items: center;padding:0 10px;font-size:10px;font-weight:500}.local-label{font:8px var(--font-mono);letter-spacing:.7px;border:1px solid var(--color-border);border-radius:3px;padding:2px 4px}.workspace-link{display:flex;color:var(--color-primary-text);background:var(--color-selected-surface);border-radius:7px;align-items: center;gap:9px;margin-top:8px;padding:10px;font-size:12px;font-weight:500}.workspace-link .icon{width:15px;height:15px}.workspace-chevron{margin-left:auto;width:12px!important}.section-label{margin-top:29px;margin-bottom:12px}.section-label>span:last-child{font:9px var(--font-mono)}.search-label{display:flex;position:relative;align-items: center;margin:0 4px 8px}.search-label>.icon{position:absolute;color:var(--color-muted-foreground);pointer-events:none;width:13px;height:13px;left:9px}.search-label input{background:var(--color-disabled-surface);box-shadow:none;border-color:#0000;width:100%;height:31px;padding-left:29px;font-size:11px}nav{overflow:auto;flex:1;min-height:50px}nav button{display:flex;text-align:left;color:var(--color-muted-foreground);background:0 0;border:1px solid #0000;border-radius:6px;align-items: center;gap:9px;width:100%;min-height:34px;margin-bottom:2px;padding:7px 12px;font-size:12px}nav button>.icon{opacity:.75;width:14px;height:14px}nav button>.table-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nav button:hover{background:var(--color-hover-surface);color:var(--color-foreground)}nav button[aria-current=true]{color:var(--color-primary-text);background:var(--color-selected-surface);font-weight:550}nav button[aria-current=true]:after{content:"";background:var(--color-primary-text);border-radius:50%;flex-shrink:0;width:4px;height:4px;margin-left:auto}.sidebar-bottom{display:grid;border-top:1px solid var(--color-border);color:var(--color-muted-foreground);gap:9px;margin-top:20px;padding:17px 8px 20px;font-size:9px}.sidebar-bottom>div{display:flex;align-items: center;gap:6px}.sidebar-bottom>span{color:var(--color-disabled-foreground);font-size:10px}.sidebar-bottom strong{color:var(--color-muted-foreground);font-weight:500}main{display:flex;flex-direction:column;flex:1;min-width:0}.topbar{display:flex;border-bottom:1px solid var(--color-border);background:var(--color-surface);flex-shrink:0;justify-content:space-between;align-items: center;gap:15px;height:64px;padding:0 28px}.breadcrumb,.topbar-actions{display:flex;align-items: center;gap:12px}.breadcrumb{color:var(--color-muted-foreground);min-width:0;font-size:11px}.breadcrumb>.icon{width:13px;height:13px}.breadcrumb>.icon:nth-of-type(2){opacity:.5;width:9px}.breadcrumb strong{color:var(--color-foreground);overflow:hidden;text-overflow:ellipsis;font-weight:500}.topbar-actions{gap:14px}.topbar-divider{background:var(--color-border);width:1px;height:16px}.access{display:inline-flex;color:var(--color-muted-foreground);white-space:nowrap;align-items: center;gap:6px;font-size:10px}.access>.icon{width:12px;height:12px}.theme-sun{display:none}[data-theme=dark] .theme-sun{display:block}[data-theme=dark] .theme-moon{display:none}.workspace{display:flex;flex-direction:column;flex:1;min-height:0;padding:27px 28px 0}.heading{display:flex;flex-shrink:0;justify-content:space-between;align-items: center;gap:20px;margin-bottom:25px}.heading-title{display:flex;align-items: center;gap:13px;min-width:0}.heading-title>div{min-width:0}.table-heading-icon{display:grid;background:var(--color-surface);border:1px solid var(--color-border);box-shadow:0 2px 3px oklch(0 0 0/.025);color:var(--color-primary-text);border-radius:10px;flex-shrink:0;place-items: center;width:39px;height:43px}.table-heading-icon>.icon{stroke-width:1.45;width:21px;height:21px}h1{letter-spacing:-.055em;overflow:hidden;text-overflow:ellipsis;margin:0 0 5px;font-size:24px;font-weight:550;line-height:1.2}.heading p{color:var(--color-muted-foreground);margin:0;font-size:11px}.view-bar{display:flex;border-bottom:1px solid var(--color-border);flex-shrink:0;justify-content:space-between;align-items: center;margin-bottom:17px}.tabs{display:flex;gap:24px}.tabs button{display:flex;color:var(--color-muted-foreground);background:0 0;border:0;border-bottom:2px solid #0000;align-items: center;gap:7px;margin-bottom:-1px;padding:0 2px 12px;font-size:12px}.tabs .icon{width:14px;height:14px}.tabs button[aria-selected=true]{color:var(--color-primary-text);border-bottom-color:var(--color-primary);font-weight:500}.view-description{color:var(--color-muted-foreground);padding-bottom:11px;font-size:10px}#data-view{display:flex;flex-direction:column;flex:1;min-height:0}.toolbar{display:flex;flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items: center;gap:12px;margin-bottom:13px}.toolbar form{display:flex;flex-wrap:wrap;align-items: center;gap:7px}.filter-icon{color:var(--color-muted-foreground);width:15px;margin-right:3px}.toolbar select,.toolbar input{border-color:var(--color-border);height:31px;padding:5px 9px;font-size:11px}#filter-field{width:105px}#filter-operator{width:84px}#filter-value{width:155px}.page-size{display:flex;color:var(--color-muted-foreground);align-items: center;gap:8px;font-size:10px}.page-size select{font:10px var(--font-mono);padding:6px 8px}.filter-chips{display:flex;flex-wrap:wrap;flex-shrink:0;gap:7px}.filter-chips:not(:empty){margin-bottom:12px}.chip{display:inline-flex;border:1px solid color-mix(in oklab,var(--color-primary)25%,transparent);background:var(--color-selected-surface);color:var(--color-primary-text);font:10px var(--font-mono);overflow-wrap:anywhere;border-radius:5px;align-items: center;gap:8px;max-width:100%;padding:4px 5px 4px 9px}.chip .button{color:inherit;border-radius:3px;width:20px;height:20px;padding:0}.chip .icon{width:11px;height:11px}.grid-frame{position:relative;overflow:auto;background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-md);scrollbar-width:thin;flex:1;min-height:140px}table{border-collapse:separate;border-spacing:0;text-align:left;min-width:100%;font-size:11px}thead{position:sticky;z-index:1;top:0}th{background:color-mix(in oklab,var(--color-surface)97%,var(--color-foreground));color:var(--color-muted-foreground);border-bottom:1px solid var(--color-border);white-space:nowrap;padding:0;font-weight:500}th button,th .column-heading{display:flex;text-align:left;color:var(--color-foreground);white-space:nowrap;background:0 0;border:0;border-radius:0;align-items: center;gap:8px;width:100%;min-width:135px;padding:11px 15px;font-size:11px}th button:hover{background:var(--color-hover-surface)}.column-key{color:var(--color-muted-foreground);width:11px;height:11px;margin-left:auto}.field-type{display:inline-flex;font:10px var(--font-mono);color:var(--color-muted-foreground);background:var(--color-disabled-surface);border-radius:4px;flex-shrink:0;justify-content:center;align-items: center;width:18px;height:18px}.type-text{color:oklch(.49 .1 160);background:oklch(.64 .13 160/.09)}.type-number{color:oklch(.5 .15 285);background:oklch(.65 .15 285/.1)}.type-boolean{color:oklch(.5 .13 245);background:oklch(.65 .13 245/.1)}.type-json{color:oklch(.5 .12 65);background:oklch(.65 .12 65/.1)}.type-date{color:oklch(.5 .12 320);background:oklch(.65 .12 320/.1)}.type-key{color:var(--color-primary-text);background:var(--color-selected-surface)}[data-theme=dark] .field-type{color:var(--color-muted-foreground)}td{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:11px/1.6 var(--font-mono);border-bottom:1px solid color-mix(in oklab,var(--color-foreground)7%,transparent);min-width:110px;max-width:290px;height:41px;padding:11px 15px}#grid tbody tr{cursor:pointer}#grid tbody tr:hover{background:var(--color-selected-surface)}#grid tbody tr:last-child td{border-bottom:0}td.row-number,th.row-number{text-align:right;font:9px var(--font-mono);color:var(--color-disabled-foreground);border-right:1px solid color-mix(in oklab,var(--color-foreground)7%,transparent);width:45px;min-width:45px;padding:10px 12px}.null{color:var(--color-disabled-foreground);font-style:italic}.bool{display:inline-flex;border:1px solid var(--color-border);color:var(--color-muted-foreground);border-radius:4px;align-items: center;gap:6px;padding:1px 6px;font-size:10px}.bool:before{content:"";background:var(--color-disabled-foreground);border-radius:50%;width:4px;height:4px}.bool.true{color:var(--color-success);background:color-mix(in oklab,var(--color-success)8%,transparent);border-color:color-mix(in oklab,var(--color-success)18%,transparent)}.bool.true:before{background:var(--color-success)}.open-row{color:var(--color-muted-foreground);font:inherit;text-align:left;background:0 0;border:0;padding:0}.open-row:hover{color:var(--color-primary-text);text-decoration:underline;text-underline-offset:3px}.empty{text-align:center;color:var(--color-muted-foreground);padding:65px 20px}.empty-symbol{display:inline-grid;border:1px solid var(--color-border);background:var(--color-background);border-radius:13px;place-items: center;width:46px;height:46px}.empty-symbol .icon{width:23px;height:23px}.empty h2{color:var(--color-foreground);letter-spacing:-.3px;margin:17px 0 7px;font-size:16px;font-weight:500}.empty p{max-width:400px;margin:0 auto;font-size:12px;line-height:1.7}.grid-footer{display:flex;color:var(--color-muted-foreground);flex-shrink:0;justify-content:space-between;align-items: center;gap:15px;padding-top:10px;font-size:10px}.grid-footer>div{display:flex;align-items: center;gap:13px}.grid-footer .button{height:28px;padding:0 8px;font-size:10px}.grid-footer .button:disabled{background:0 0;border-color:#0000}#page-number{font:9px var(--font-mono)}.arrow-left{transform:rotate(180deg)}.hint{color:var(--color-muted-foreground);flex-shrink:0;margin:13px 0 17px;font-size:10px}.app-footer{display:flex;border-top:1px solid var(--color-border);background:var(--color-surface);color:var(--color-muted-foreground);flex-shrink:0;justify-content:space-between;align-items: center;gap:15px;min-height:35px;padding:7px 28px;font-size:9px}.app-footer>span:first-child{display:flex;align-items: center;gap:7px}.footer-separator{color:var(--color-border);margin:0 5px}.package-signature{font-family:var(--font-mono)}.notice{border:1px solid color-mix(in oklab,var(--color-danger)25%,transparent);background:color-mix(in oklab,var(--color-danger)6%,var(--color-surface));color:var(--color-danger);overflow-wrap:anywhere;border-radius:7px;flex-shrink:0;margin:0 0 15px;padding:11px 14px;font-size:12px}#schema-view{overflow:auto;flex:1;min-height:0;padding-bottom:20px}.schema-card{overflow:auto;border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);margin-bottom:17px}.schema-card h2{display:flex;border-bottom:1px solid var(--color-border);align-items: center;gap:9px;margin:0;padding:14px 17px;font-size:12px;font-weight:500}.schema-card h2 .icon{color:var(--color-muted-foreground);width:14px}.schema-card th{padding:10px 17px;font-size:10px}.schema-card td{white-space:normal;vertical-align:top;overflow-wrap:anywhere;min-width:100px;max-width:300px;padding:12px 17px}.schema-card td:first-child{color:var(--color-foreground)}.schema-card pre{font:10px/1.8 var(--font-mono);color:var(--color-muted-foreground);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;padding:15px 17px}.schema-card pre code{font:inherit;color:var(--color-foreground)}.code-language{font:9px var(--font-mono);color:var(--color-muted-foreground);margin-left:auto}.language-json .hljs-attr{color:var(--code-property)}.language-json .hljs-string{color:var(--code-string)}.language-json .hljs-number{color:var(--code-number)}.language-json .hljs-literal{color:var(--code-literal)}.language-json .hljs-punctuation{color:var(--code-punctuation)}dialog{position:fixed;overflow:hidden;border:0;border-left:1px solid var(--color-border);background:var(--color-surface);color:var(--color-foreground);box-shadow:var(--shadow-overlay);width:440px;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;padding:0;inset:0 0 0 auto}dialog::backdrop{background:oklch(0 0 0/.35)}#editor-form{display:flex;flex-direction:column;height:100%}.editor-header{display:flex;flex-shrink:0;justify-content:space-between;align-items: center;gap:15px;padding:25px 25px 0}.eyebrow{color:var(--color-muted-foreground);font:9px var(--font-mono);text-transform:uppercase;letter-spacing:1px}.editor-header h2{letter-spacing:-.8px;margin:7px 0 0;font-size:22px;font-weight:500}.editor-note{color:var(--color-muted-foreground);border-bottom:1px solid var(--color-border);flex-shrink:0;margin:0;padding:12px 25px 20px;font-size:11px;line-height:1.7}#editor-fields{overflow:auto;flex:1;min-height:0;padding:21px 25px 5px}.editor-field{margin-bottom:21px}.field-label{display:flex;align-items: center;gap:8px;margin-bottom:8px;font-size:12px;font-weight:500}.field-label small{font:9px var(--font-mono);color:var(--color-muted-foreground);margin-left:auto;font-weight:400}.editor-field input:not([type=checkbox]),.editor-field select,.editor-field textarea{font:11px/1.6 var(--font-mono);width:100%;padding:9px 11px}.editor-field textarea{resize:vertical;min-height:110px}.editor-field :disabled{color:var(--color-muted-foreground)}.null-toggle{display:flex;color:var(--color-muted-foreground);align-items: center;gap:5px;margin-top:8px;font-size:10px}.null-toggle input{accent-color:var(--color-primary);margin:0 2px 0 0}.editor-footer{display:flex;border-top:1px solid var(--color-border);background:var(--color-background);flex-shrink:0;justify-content:flex-end;gap:8px;padding:17px 25px}#editor-error{overflow:auto;max-height:140px;margin:10px 25px 17px}@media (min-width:1550px){.workspace{padding:32px 40px 0}.topbar,.app-footer{padding-left:40px;padding-right:40px}}@media (max-width:1100px){.sidebar{width:205px}.workspace{padding:22px 20px 0}.topbar,.app-footer{padding-left:20px;padding-right:20px}.toolbar{gap:9px}.page-size{margin-left:auto}}@media (max-width:760px){.sidebar{width:175px;padding:0 10px}.brand{gap:6px;font-size:17px}.brand-product{font-size:14px}.database-card{gap:7px;padding:10px 8px}.database-icon{display:none}.sidebar-bottom>div{font-size:8px}.topbar{height:54px;padding:0 15px}.workspace{padding:20px 15px 0}.toolbar form{gap:6px}.filter-icon,.view-description{display:none}#filter-field{width:100px}#filter-operator{width:75px}#filter-value{width:130px}.heading-title{gap:9px}.heading p{font-size:10px}.table-heading-icon,.app-footer>span:last-child{display:none}}@media (max-width:540px){body{display:block;overflow:auto;height:auto;min-height:100dvh}.sidebar{border-right:0;border-bottom:1px solid var(--color-border);display:grid;grid-template-columns:1fr 1fr;align-items: center;gap:0 10px;width:100%;padding:0 16px 12px}.brand{height:58px}.database-card{background:0 0;border:0;justify-content:flex-end;margin:0;padding:0}.database-card small{font-size:9px}.database-card strong{text-align:right}.sidebar-section,.workspace-link,.section-label,.sidebar-bottom{display:none}.search-label{grid-column:1/-1;margin:3px 0 10px}nav{grid-column:1/-1;display:flex;gap:5px;min-height:0;max-height:110px}nav button{flex-shrink:0;width:auto;margin:0;padding:7px 10px}nav button[aria-current=true]:after{display:none}main{min-height:calc(100dvh - 157px)}.topbar{height:47px}.topbar-actions{gap:7px}.topbar-divider{display:none}.workspace{padding:21px 15px 0}.heading{margin-bottom:24px}h1{font-size:22px}.heading p{max-width:230px}#filter-field{flex:1}#filter-operator{width:84px}#filter-value{flex:1;width:100%;min-width:110px}.toolbar form{width:100%}.toolbar .button{font-size:11px}.grid-frame{flex:none;height:45dvh;min-height:200px}.grid-footer{gap:8px}.grid-footer>div{gap:5px}.grid-footer .button{padding:0 5px;font-size:9px}.grid-footer .icon{width:12px}.hint{margin-top:15px;font-size:9px}.app-footer{padding:10px 15px}#schema-view{max-height:60dvh}}@media (prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}.studio-page{display:flex;flex-direction:column;flex:1;min-height:0}.studio-page>.heading .eyebrow{margin-bottom:8px}.workspace-navigation{display:grid;gap:3px;margin-top:8px}.workspace-link{text-align:left;color:var(--color-muted-foreground);background:0 0;border:0;width:100%;margin-top:0}.workspace-link:hover{background:var(--color-hover-surface);color:var(--color-foreground)}.workspace-link[aria-current=page]{background:var(--color-selected-surface);color:var(--color-primary-text)}.schema-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));flex-shrink:0;gap:12px;margin-bottom:20px}.schema-stat{display:flex;border:1px solid var(--color-border);background:var(--color-surface);border-radius:9px;flex-direction:column;gap:6px;padding:12px 16px}.schema-stat>span{color:var(--color-muted-foreground);font-size:10px}.schema-stat>strong{letter-spacing:-1px;font-size:24px;font-weight:500;line-height:1.1}.diagram-host{flex:1;min-height:180px;margin-bottom:20px}.diagram{min-height:inherit;position:relative;border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden;background:var(--color-background);height:100%}.diagram-viewport{overflow:auto;scrollbar-width:thin;background-image:radial-gradient(var(--color-border).7px,transparent .7px);background-size:18px 18px;width:100%;height:100%}.diagram-sizer{position:relative;min-width:100%;min-height:100%}.diagram-world{position:absolute;transform-origin:0 0;top:0;left:0}.diagram-connections{position:absolute;color:var(--color-primary-text);pointer-events:none;inset:0}.diagram-connections marker path{fill:currentColor}.relationship-line{fill:none;stroke:var(--color-primary-text);stroke-width:1.5px;opacity:.65}.diagram-node{position:absolute;z-index:1;border:1px solid var(--color-border);overflow:hidden;background:var(--color-surface);box-shadow:var(--shadow-raised);cursor:pointer;border-radius:9px}.diagram-node:hover,.diagram-node:focus-within{border-color:var(--color-primary-text)}.diagram-node-title{display:flex;text-align:left;border:0;border-bottom:1px solid var(--color-border);background:var(--color-disabled-surface);color:var(--color-foreground);align-items: center;gap:9px;width:100%;height:49px;padding:0 14px}.diagram-node-title>.icon{color:var(--color-primary-text);width:15px}.diagram-node-title>strong{text-overflow:ellipsis;overflow:hidden;min-width:0;font-size:13px;font-weight:550}.node-field-count{font:10px var(--font-mono);color:var(--color-muted-foreground);margin-left:auto}.diagram-field{display:flex;font:10px var(--font-mono);align-items: center;gap:8px;height:25px;padding:0 13px}.diagram-field .field-type{width:15px;height:15px;font-size:8px}.diagram-field-name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;min-width:0}.diagram-field>small{color:var(--color-muted-foreground);margin-left:auto;font-size:9px}.primary-key-icon{color:var(--color-warning);width:11px;height:11px}.foreign-key-label{font:8px var(--font-mono);color:var(--color-primary-text)}.diagram-node-footer{display:flex;color:var(--color-muted-foreground);border-top:1px solid var(--color-border);align-items: center;height:30px;padding:0 14px;font-size:9px}.diagram-tools{position:absolute;z-index:2;display:flex;border:1px solid var(--color-border);background:var(--color-surface);box-shadow:var(--shadow-control);border-radius:8px;align-items: center;gap:5px;padding:4px;bottom:12px;right:12px}.diagram-tools .button{min-width:26px;height:26px;padding:0 7px;font-size:11px}.diagram-zoom{text-align:center;font:9px var(--font-mono);color:var(--color-muted-foreground);min-width:36px}.diagram-legend{position:absolute;display:flex;background:var(--color-surface);color:var(--color-muted-foreground);border-radius:5px;align-items: center;gap:7px;padding:4px 7px;font-size:9px;bottom:17px;left:14px}.diagram-legend>.icon{color:var(--color-warning);width:11px;height:11px}.diagram-legend>.foreign-key-label{margin-left:8px}.diagram-empty{position:absolute;color:var(--color-muted-foreground);top:80px;left:50px}.catalog-host{flex:1;min-height:0}.catalog{display:flex;flex-direction:column;height:100%}.catalog-toolbar{display:flex;flex-shrink:0;justify-content:space-between;align-items: center;gap:12px;margin-bottom:17px}.catalog-search{width:320px;max-width:75%;font-size:12px}.catalog-count{color:var(--color-muted-foreground);font:10px var(--font-mono)}.catalog-content{overflow:auto;flex:1;min-height:0;padding-bottom:24px}.catalog-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:15px}.catalog-card{border:1px solid var(--color-border);border-radius:var(--radius-md);background:var(--color-surface);padding:17px}.catalog-title{display:flex;text-align:left;background:0 0;border:0;align-items: center;gap:9px;padding:0;font-size:14px}.catalog-title>.icon{color:var(--color-primary-text);width:16px}.catalog-title>strong{overflow-wrap:anywhere;font-weight:550}.catalog-title:hover{color:var(--color-primary-text)}.catalog-meta{color:var(--color-muted-foreground);margin:8px 0 15px;font-size:10px}.catalog-fields{display:flex;flex-wrap:wrap;align-content: flex-start;gap:5px;min-height:52px;margin-bottom:9px}.catalog-field{display:inline-flex;overflow-wrap:anywhere;border:1px solid var(--color-border);font:9px var(--font-mono);color:var(--color-muted-foreground);border-radius:4px;align-items: center;gap:4px;max-width:100%;padding:3px 6px}.catalog-field>.icon{color:var(--color-warning);width:9px;height:9px}.catalog-more{color:var(--color-muted-foreground);padding:3px;font-size:10px}.catalog-card>.button{color:var(--color-primary-text);height:28px;padding-left:0;font-size:11px}.catalog-relations{margin-top:27px}.catalog-relations>h2{margin-bottom:13px;font-size:14px;font-weight:500}.reference-list{border:1px solid var(--color-border);background:var(--color-surface);border-radius:9px}.reference-item{display:flex;border-bottom:1px solid var(--color-border);flex-wrap:wrap;align-items: center;gap:10px;padding:13px 16px}.reference-item:last-child{border-bottom:0}.reference-link{font:10px var(--font-mono);color:var(--color-primary-text);overflow-wrap:anywhere;background:0 0;border:0;padding:0}.reference-link:hover{text-decoration:underline;text-underline-offset:3px}.reference-item>.icon{color:var(--color-muted-foreground);width:13px}.reference-policy{font:9px var(--font-mono);border:1px solid var(--color-border);color:var(--color-muted-foreground);border-radius:4px;margin-left:auto;padding:3px 6px}.reference-nullable{color:var(--color-muted-foreground);font-size:9px}.catalog-empty{color:var(--color-muted-foreground);margin:20px;font-size:12px}.selection-cell{text-align:center;width:37px;min-width:37px;padding:10px!important}.selection-cell input{accent-color:var(--color-primary);cursor:pointer;box-shadow:none;width:13px;height:13px;margin:0;padding:0}#grid tbody tr[data-selected=true]{background:var(--color-selected-surface)}.selection-bar{display:flex;border:1px solid color-mix(in oklab,var(--color-primary)25%,transparent);background:var(--color-selected-surface);color:var(--color-primary-text);border-radius:7px;flex-shrink:0;justify-content:space-between;align-items: center;gap:12px;margin-bottom:12px;padding:9px 12px;font-size:11px}.selection-bar>div{display:flex;align-items: center;gap:7px}.selection-bar .button{height:28px;padding:0 9px;font-size:10px}.danger{background:var(--color-danger);color:var(--color-on-emphasis);border-color:var(--color-danger);box-shadow:var(--shadow-control)}.danger:hover:enabled{background:color-mix(in oklab,var(--color-danger)84%,var(--color-foreground))}.confirmation-dialog{overflow:auto;border:1px solid var(--color-border);border-radius:13px;width:470px;max-width:calc(100vw - 30px);height:auto;max-height:calc(100dvh - 40px);margin:auto;padding:25px;inset:0}.confirmation-heading{display:flex;align-items: center;gap:12px}.confirmation-heading>h2{letter-spacing:-.5px;margin:0;font-size:19px;font-weight:550}.danger-symbol{display:inline-grid;background:color-mix(in oklab,var(--color-danger)10%,transparent);border:1px solid color-mix(in oklab,var(--color-danger)20%,transparent);color:var(--color-danger);border-radius:9px;place-items: center;width:35px;height:35px}#delete-description{color:var(--color-muted-foreground);margin:17px 0;font-size:12px;line-height:1.7}#delete-effects:empty{display:none}#delete-effects{border:1px solid var(--color-border);border-radius:7px;margin:15px 0;padding:13px;font-size:11px}#delete-effects>strong{font-weight:500}#delete-effects ul{font:10px/1.8 var(--font-mono);padding-left:18px}#delete-effects p{color:var(--color-muted-foreground);margin-bottom:0}.confirmation-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:23px}@media (max-width:760px){.schema-stats{gap:8px}.schema-stat{padding:10px}.schema-stat>strong{font-size:21px}.diagram-legend{display:none}.selection-bar{flex-wrap:wrap}}@media (max-width:540px){.workspace-navigation{grid-column:1/-1;display:flex;gap:5px;margin:0 0 8px}.workspace-navigation .workspace-link{display:flex;width:auto;padding:7px 10px;font-size:11px}.schema-stats{grid-template-columns:repeat(2,minmax(0,1fr));margin-bottom:15px}.diagram-host{min-height:440px}#map-page>.heading p,#catalog-page>.heading p{max-width:none}.catalog-host{min-height:400px}.catalog-toolbar{flex-wrap:wrap}.catalog-search{width:100%;max-width:100%}.catalog-grid{grid-template-columns:1fr}.catalog-content{max-height:65dvh}.selection-bar{align-items: flex-start}.selection-bar>div{flex-wrap:wrap}.reference-policy{margin-left:0}}
package/dist/theme.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{try{let e=localStorage.getItem("hulla-studio-theme");document.documentElement.dataset.theme=e==="light"||e==="dark"?e:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{document.documentElement.dataset.theme="light"}})();
@@ -0,0 +1,38 @@
1
+ export interface StudioField {
2
+ readonly name: string;
3
+ readonly scalar: string;
4
+ readonly nullable: boolean;
5
+ readonly hasDefault: boolean;
6
+ readonly default?: unknown;
7
+ readonly reference?: string;
8
+ readonly onDelete?: string;
9
+ readonly constraints?: unknown;
10
+ readonly precision?: number;
11
+ readonly jsonShape?: unknown;
12
+ }
13
+ export interface StudioTable {
14
+ readonly name: string;
15
+ readonly primaryKey: string;
16
+ readonly keyGeneration: unknown;
17
+ readonly fields: readonly StudioField[];
18
+ readonly indexes: unknown;
19
+ readonly unique: unknown;
20
+ readonly checks: unknown;
21
+ }
22
+ export interface StudioSchema {
23
+ readonly namespace: string;
24
+ readonly readOnly: boolean;
25
+ readonly tables: readonly StudioTable[];
26
+ }
27
+ /** Values use database scalar representations: int64 is a decimal string. */
28
+ export interface StudioRow {
29
+ readonly values: Record<string, unknown>;
30
+ readonly snapshot: string;
31
+ }
32
+ export interface StudioPage {
33
+ readonly rows: readonly StudioRow[];
34
+ readonly cursor: string | null;
35
+ }
36
+ export interface StudioDeleteResult {
37
+ readonly deleted: number;
38
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@hulla/db-studio",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "description": "Optional local database workbench for @hulla/db",
6
+ "license": "MIT",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "peerDependencies": {
19
+ "@hulla/db": "^0.1.1"
20
+ },
21
+ "engines": {
22
+ "node": ">=22.18.0"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/hulladev/db.git",
27
+ "directory": "packages/studio"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "registry": "https://registry.npmjs.org/"
32
+ }
33
+ }