UNPKG

@lunora/cli

Version:

The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands

2 lines (1 loc) 694 B
import{buildSchemaSnapshot as u,isD1GlobalTable as f}from"@lunora/codegen";import{validatorKindToSqlType as m}from"./diffSnapshots-DtC5Cs4Z.mjs";const d=n=>m(n.kind==="optional"&&n.inner?n.inner.kind:n.kind),b=(n,s)=>n.kind==="optional"?!0:s===void 0?!1:s.nullable===!0,p=f,q=n=>{const s={},r=u(n,[]);for(const o of n.tables){if(!p(o))continue;const l={};for(const[e,i]of Object.entries(o.shape)){const t=r.tables[o.name]?.fields[e],c={nullable:b(i,t),sqlType:d(i)};l[e]=t===void 0?c:{...c,field:t}}const a={};for(const e of o.indexes)a[e.name]={fields:[...e.fields],name:e.name,unique:e.unique??!1};s[o.name]={columns:l,indexes:a,name:o.name}}return{tables:s,version:1}};export{q as default};