@vaiftech/cli 1.5.0 → 1.5.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.
@@ -46,7 +46,7 @@ import g from'fs';import w from'path';import M from'dotenv';import K from'pg';im
46
46
  ORDER BY t.typname, e.enumsortorder
47
47
  `,[t]),c=new Map;for(let l of a.rows)c.set(l.table_name,[]);for(let l of e.rows){let i=c.get(l.table_name);i&&i.push(l);}let u=new Map;for(let l of o.rows){let i=u.get(l.enum_name)||[];i.push(l.enum_value),u.set(l.enum_name,i);}return {tables:c,enums:u,foreignKeys:s.rows}}var S={smallint:"number",integer:"number",bigint:"string",int2:"number",int4:"number",int8:"string",decimal:"string",numeric:"string",real:"number",float4:"number",float8:"number","double precision":"number",money:"string",boolean:"boolean",bool:"boolean",text:"string",varchar:"string",char:"string",character:"string","character varying":"string",name:"string",citext:"string",date:"string",time:"string",timetz:"string","time without time zone":"string","time with time zone":"string",timestamp:"string",timestamptz:"string","timestamp without time zone":"string","timestamp with time zone":"string",interval:"string",bytea:"Buffer",uuid:"string",json:"unknown",jsonb:"unknown",inet:"string",cidr:"string",macaddr:"string",macaddr8:"string",point:"{ x: number; y: number }",line:"string",lseg:"string",box:"string",path:"string",polygon:"string",circle:"string",ARRAY:"unknown[]"};function Y(n,t){let{data_type:a,udt_name:e,is_nullable:s}=n;if(t.has(e)){let u=t.get(e).map(l=>`"${l}"`).join(" | ");return s==="YES"?`(${u}) | null`:u}if(a==="ARRAY"){let c=e.replace(/^_/,"");if(t.has(c)){let i=t.get(c).map(d=>`"${d}"`).join(" | ");return s==="YES"?`(${i})[] | null`:`(${i})[]`}let u=S[c]||"unknown";return s==="YES"?`${u}[] | null`:`${u}[]`}let o=S[a]||S[e]||"unknown";return s==="YES"&&(o=`${o} | null`),o}function x(n){return n.split(/[_\-\s]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function $(n,t){let a=x(n),e=t.map(s=>` | "${s}"`).join(`
48
48
  `);return `export type ${a} =
49
- ${e};`}function G(n,t,a){let e=x(n),s=[],o=[],c=[];for(let d of t){let f=Y(d,a),p=d.column_name,h=d.column_default!==null||d.is_identity==="YES",b=d.is_nullable==="YES";s.push(` ${p}: ${f};`),h||d.column_name==="id"?o.push(` ${p}?: ${f.replace(" | null","")} | null;`):b?o.push(` ${p}?: ${f};`):o.push(` ${p}: ${f.replace(" | null","")};`),c.push(` ${p}?: ${f.replace(" | null","")} | null;`);}let u=`export interface ${e} {
49
+ ${e};`}function G(n,t,a){let e=x(n),s=[],o=[],c=[];for(let d of t){let f=Y(d,a),p=d.column_name,h=d.column_default!==null||d.is_identity==="YES",y=d.is_nullable==="YES";s.push(` ${p}: ${f};`),h||d.column_name==="id"?o.push(` ${p}?: ${f.replace(" | null","")} | null;`):y?o.push(` ${p}?: ${f};`):o.push(` ${p}: ${f.replace(" | null","")};`),c.push(` ${p}?: ${f.replace(" | null","")} | null;`);}let u=`export interface ${e} {
50
50
  ${s.join(`
51
51
  `)}
52
52
  }`,l=`export interface ${e}Insert {
@@ -59,7 +59,7 @@ ${c.join(`
59
59
  `)}async function de(n){let t=z("Loading configuration...").start();try{let a=await U(n.config),e=n.connection||a?.database?.url||process.env.DATABASE_URL;e||(t.fail("No database connection string provided"),console.log(r.yellow(`
60
60
  Provide a connection string via:`)),console.log(r.gray(" --connection <url>")),console.log(r.gray(" DATABASE_URL environment variable")),console.log(r.gray(" vaif.config.json database.url")),process.exit(1)),t.text="Connecting to database...";let s=new K.Client({connectionString:e});await s.connect(),t.text="Introspecting schema...";let{tables:o,enums:c,foreignKeys:u}=await B(s,n.schema);if(await s.end(),o.size===0){t.warn(`No tables found in schema "${n.schema}"`);return}t.text=`Generating types for ${o.size} tables...`;let l=H(o,c,u),i=await q.format(l,{parser:"typescript",semi:!0,singleQuote:!1,trailingComma:"es5",printWidth:100});if(n.dryRun){t.succeed("Generated types (dry run):"),console.log(""),console.log(r.gray("\u2500".repeat(60))),console.log(i),console.log(r.gray("\u2500".repeat(60)));return}let d=w.resolve(n.output),f=w.dirname(d);g.existsSync(f)||g.mkdirSync(f,{recursive:!0}),g.writeFileSync(d,i,"utf-8"),t.succeed(`Generated types for ${o.size} tables \u2192 ${r.cyan(n.output)}`),console.log(""),console.log(r.green("Generated:")),console.log(r.gray(` Tables: ${o.size}`)),console.log(r.gray(` Enums: ${c.size}`)),console.log(""),console.log(r.gray("Import in your code:")),console.log(r.cyan(` import type { Database, Row, Insert, Update } from "${n.output.replace(/\.ts$/,"")}";`));}catch(a){t.fail("Failed to generate types"),a instanceof Error&&(console.error(r.red(`
61
61
  Error: ${a.message}`)),a.message.includes("ECONNREFUSED")&&console.log(r.yellow(`
62
- Make sure your database is running and accessible.`))),process.exit(1);}}var y=[{name:"database",label:"Database",description:"CRUD queries, type-safe operations"},{name:"auth",label:"Authentication",description:"login, signup, OAuth, sessions"},{name:"realtime",label:"Realtime",description:"live subscriptions, presence"},{name:"storage",label:"Storage",description:"file uploads, signed URLs"},{name:"functions",label:"Functions",description:"serverless function calls"}],D={"nextjs-fullstack":{name:"Next.js Full-Stack",description:"Next.js app with server/client VAIF client, auth middleware, and React hooks",tag:"Next.js",defaultFeatures:["database","auth"],files:[{path:"package.json",content:`{
62
+ Make sure your database is running and accessible.`))),process.exit(1);}}var b=[{name:"database",label:"Database",description:"CRUD queries, type-safe operations"},{name:"auth",label:"Authentication",description:"login, signup, OAuth, sessions"},{name:"realtime",label:"Realtime",description:"live subscriptions, presence"},{name:"storage",label:"Storage",description:"file uploads, signed URLs"},{name:"functions",label:"Functions",description:"serverless function calls"}],D={"nextjs-fullstack":{name:"Next.js Full-Stack",description:"Next.js app with server/client VAIF client, auth middleware, and React hooks",tag:"Next.js",defaultFeatures:["database","auth"],files:[{path:"package.json",content:`{
63
63
  "name": "my-vaif-app",
64
64
  "private": true,
65
65
  "version": "0.1.0",
@@ -167,7 +167,7 @@ export function createVaifServer() {
167
167
  });
168
168
  }
169
169
  `},{path:".env.local.example",content:`# VAIF Configuration
170
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
170
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
171
171
 
172
172
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
173
173
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -204,7 +204,7 @@ A full-stack Next.js application powered by [VAIF Studio](https://vaif.studio),
204
204
  cp .env.local.example .env.local
205
205
  \\\`\\\`\\\`
206
206
 
207
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
207
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
208
208
 
209
209
  3. **Install and log in to the VAIF CLI**
210
210
 
@@ -654,7 +654,7 @@ interface ImportMeta {
654
654
  readonly env: ImportMetaEnv;
655
655
  }
656
656
  `},{path:".env.example",content:`# VAIF Configuration
657
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
657
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
658
658
 
659
659
  VITE_VAIF_PROJECT_ID=your-project-id
660
660
  VITE_VAIF_API_KEY=your-anon-key
@@ -687,7 +687,7 @@ A single-page React application built with [Vite](https://vite.dev/) and powered
687
687
  cp .env.example .env
688
688
  \\\`\\\`\\\`
689
689
 
690
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
690
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
691
691
 
692
692
  3. **Install and log in to the VAIF CLI**
693
693
 
@@ -1185,7 +1185,7 @@ An iOS/macOS application powered by [VAIF Studio](https://vaif.studio), using th
1185
1185
  <string>your-anon-key</string>
1186
1186
  \\\`\\\`\\\`
1187
1187
 
1188
- Get your credentials from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1188
+ Get your credentials from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1189
1189
 
1190
1190
  3. **Install and log in to the VAIF CLI** (for type generation)
1191
1191
 
@@ -1312,7 +1312,7 @@ export const vaif = createExpoClient({
1312
1312
  realtime: { enabled: true },
1313
1313
  });
1314
1314
  `},{path:".env.example",content:`# VAIF Configuration
1315
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1315
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1316
1316
 
1317
1317
  EXPO_PUBLIC_VAIF_PROJECT_ID=your-project-id
1318
1318
  EXPO_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -1346,7 +1346,7 @@ A React Native / Expo mobile application powered by [VAIF Studio](https://vaif.s
1346
1346
  cp .env.example .env
1347
1347
  \\\`\\\`\\\`
1348
1348
 
1349
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1349
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1350
1350
 
1351
1351
  3. **Install and log in to the VAIF CLI**
1352
1352
 
@@ -1736,7 +1736,7 @@ A Flutter application powered by [VAIF Studio](https://vaif.studio), with Dart c
1736
1736
  cp .env.example .env
1737
1737
  \\\`\\\`\\\`
1738
1738
 
1739
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1739
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1740
1740
 
1741
1741
  3. **Install and log in to the VAIF CLI** (for schema and type generation)
1742
1742
 
@@ -1994,7 +1994,7 @@ fastapi>=0.110.0
1994
1994
  uvicorn[standard]>=0.27.0
1995
1995
  python-dotenv>=1.0.0
1996
1996
  `},{path:".env.example",content:`# VAIF Configuration
1997
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1997
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1998
1998
 
1999
1999
  VAIF_PROJECT_ID=your-project-id
2000
2000
  VAIF_API_KEY=your-anon-key
@@ -2036,7 +2036,7 @@ A FastAPI backend application powered by [VAIF Studio](https://vaif.studio), wit
2036
2036
  cp .env.example .env
2037
2037
  \\\`\\\`\\\`
2038
2038
 
2039
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2039
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2040
2040
 
2041
2041
  4. **Install and log in to the VAIF CLI**
2042
2042
 
@@ -2354,7 +2354,7 @@ A Go backend API powered by [VAIF Studio](https://vaif.studio), with HTTP handle
2354
2354
  cp .env.example .env
2355
2355
  \\\`\\\`\\\`
2356
2356
 
2357
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2357
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2358
2358
 
2359
2359
  3. **Install and log in to the VAIF CLI**
2360
2360
 
@@ -2623,7 +2623,7 @@ export async function deleteTodo(id: string): Promise<void> {
2623
2623
  if (error) throw error;
2624
2624
  }
2625
2625
  `},{path:".env.example",content:`# VAIF Configuration
2626
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2626
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2627
2627
 
2628
2628
  VITE_VAIF_PROJECT_ID=your-project-id
2629
2629
  VITE_VAIF_API_KEY=your-anon-key
@@ -2651,7 +2651,7 @@ A simple React todo application for learning [VAIF Studio](https://vaif.studio)
2651
2651
  cp .env.example .env
2652
2652
  \\\`\\\`\\\`
2653
2653
 
2654
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2654
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2655
2655
 
2656
2656
  3. **Install and log in to the VAIF CLI**
2657
2657
 
@@ -2903,7 +2903,7 @@ export function useRealtimeMessages({
2903
2903
  return { messages, isLoading, error, refresh };
2904
2904
  }
2905
2905
  `},{path:".env.example",content:`# VAIF Configuration
2906
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2906
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2907
2907
 
2908
2908
  VITE_VAIF_PROJECT_ID=your-project-id
2909
2909
  VITE_VAIF_API_KEY=your-anon-key
@@ -2931,7 +2931,7 @@ A React chat application with live messaging powered by [VAIF Studio](https://va
2931
2931
  cp .env.example .env
2932
2932
  \\\`\\\`\\\`
2933
2933
 
2934
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2934
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2935
2935
 
2936
2936
  3. **Install and log in to the VAIF CLI**
2937
2937
 
@@ -3212,7 +3212,7 @@ export async function requireTeamRole(
3212
3212
  return member as TeamMember;
3213
3213
  }
3214
3214
  `},{path:".env.example",content:`# VAIF Configuration
3215
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3215
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3216
3216
 
3217
3217
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3218
3218
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3241,7 +3241,7 @@ A full SaaS starter kit powered by [VAIF Studio](https://vaif.studio) with authe
3241
3241
  cp .env.example .env.local
3242
3242
  \\\`\\\`\\\`
3243
3243
 
3244
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3244
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3245
3245
 
3246
3246
  3. **Install and log in to the VAIF CLI**
3247
3247
 
@@ -3480,7 +3480,7 @@ function getContentType(fileName: string): string {
3480
3480
  return mimeTypes[ext ?? ""] ?? "application/octet-stream";
3481
3481
  }
3482
3482
  `},{path:".env.example",content:`# VAIF Configuration
3483
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3483
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3484
3484
 
3485
3485
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3486
3486
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3509,7 +3509,7 @@ An API-first e-commerce setup powered by [VAIF Studio](https://vaif.studio) with
3509
3509
  cp .env.example .env.local
3510
3510
  \\\`\\\`\\\`
3511
3511
 
3512
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3512
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3513
3513
 
3514
3514
  3. **Install and log in to the VAIF CLI**
3515
3515
 
@@ -3620,12 +3620,12 @@ export const posts = pgTable("posts", {
3620
3620
  const { name } = await req.json().catch(() => ({ name: "World" }));
3621
3621
  return Response.json({ message: \`Hello, \${name}!\` });
3622
3622
  }
3623
- `}]},dependencies:["@vaiftech/client","@vaiftech/auth"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create a 'product-images' storage bucket in your VAIF dashboard","Import storage helpers from '@/lib/storage' in your API routes","Use uploadProductImage() in your product creation flow","Run: npx vaif generate to generate TypeScript types"]}};function ve(){console.log(""),console.log(r.bold("Available project templates")),console.log("");let n=26,t=22;console.log(` ${r.gray("Template".padEnd(n))}${r.gray("Stack".padEnd(t))}${r.gray("Description")}`),console.log(r.gray(" "+"-".repeat(n+t+40)));for(let[a,e]of Object.entries(D))console.log(` ${r.cyan(a.padEnd(n))}${r.yellow(e.tag.padEnd(t))}${r.white(e.description)}`);console.log(""),console.log(r.gray("Usage:")),console.log(r.gray(" npx @vaiftech/cli init --template <name>")),console.log(r.gray(" npx @vaiftech/cli init -t nextjs-fullstack")),console.log(r.gray(" npx @vaiftech/cli init -t react-spa --features auth,database,realtime")),console.log(""),console.log(r.gray("Available features: auth, database, realtime, storage, functions")),console.log("");}async function W(n){if(!process.stdin.isTTY||!process.stdout.isTTY)return n;let t=new Set(n.map(e=>y.findIndex(s=>s.name===e)).filter(e=>e>=0)),a=0;return new Promise(e=>{let s=V.createInterface({input:process.stdin,output:process.stdout});V.emitKeypressEvents(process.stdin,s),process.stdin.setRawMode&&process.stdin.setRawMode(true);function o(){let u=y.length+2;process.stdout.write(`\x1B[${u}A`),c();}function c(){console.log(r.bold(`
3624
- ? Which VAIF features do you want to include?`)),y.forEach((u,l)=>{let i=t.has(l)?r.green("[x]"):"[ ]",d=l===a?r.cyan("> "):" ";console.log(`${d}${i} ${u.label} ${r.gray(`(${u.description})`)}`);}),console.log(r.gray(" (up/down to move, space to toggle, enter to confirm)"));}c(),process.stdin.on("keypress",(u,l)=>{if(l.name==="up"&&a>0)a--,o();else if(l.name==="down"&&a<y.length-1)a++,o();else if(l.name==="space")t.has(a)?t.delete(a):t.add(a),o();else if(l.name==="return"){process.stdin.setRawMode&&process.stdin.setRawMode(false),s.close();let i=[...t].sort().map(d=>y[d].name);e(i.length>0?i:n);}else l.name==="c"&&l.ctrl&&(process.stdin.setRawMode&&process.stdin.setRawMode(false),s.close(),process.exit(0));});})}async function j(n,t={}){let a=D[n];a||(console.log(r.red(`
3623
+ `}]},dependencies:["@vaiftech/client","@vaiftech/auth"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create a 'product-images' storage bucket in your VAIF dashboard","Import storage helpers from '@/lib/storage' in your API routes","Use uploadProductImage() in your product creation flow","Run: npx vaif generate to generate TypeScript types"]}};function ve(){console.log(""),console.log(r.bold("Available project templates")),console.log("");let n=26,t=22;console.log(` ${r.gray("Template".padEnd(n))}${r.gray("Stack".padEnd(t))}${r.gray("Description")}`),console.log(r.gray(" "+"-".repeat(n+t+40)));for(let[a,e]of Object.entries(D))console.log(` ${r.cyan(a.padEnd(n))}${r.yellow(e.tag.padEnd(t))}${r.white(e.description)}`);console.log(""),console.log(r.gray("Usage:")),console.log(r.gray(" npx @vaiftech/cli init --template <name>")),console.log(r.gray(" npx @vaiftech/cli init -t nextjs-fullstack")),console.log(r.gray(" npx @vaiftech/cli init -t react-spa --features auth,database,realtime")),console.log(""),console.log(r.gray("Available features: auth, database, realtime, storage, functions")),console.log("");}async function W(n){if(!process.stdin.isTTY||!process.stdout.isTTY)return n;let t=new Set(n.map(e=>b.findIndex(s=>s.name===e)).filter(e=>e>=0)),a=0;return new Promise(e=>{let s=V.createInterface({input:process.stdin,output:process.stdout});V.emitKeypressEvents(process.stdin,s),process.stdin.setRawMode&&process.stdin.setRawMode(true);function o(){let u=b.length+2;process.stdout.write(`\x1B[${u}A`),c();}function c(){console.log(r.bold(`
3624
+ ? Which VAIF features do you want to include?`)),b.forEach((u,l)=>{let i=t.has(l)?r.green("[x]"):"[ ]",d=l===a?r.cyan("> "):" ";console.log(`${d}${i} ${u.label} ${r.gray(`(${u.description})`)}`);}),console.log(r.gray(" (up/down to move, space to toggle, enter to confirm)"));}c(),process.stdin.on("keypress",(u,l)=>{if(l.name==="up"&&a>0)a--,o();else if(l.name==="down"&&a<b.length-1)a++,o();else if(l.name==="space")t.has(a)?t.delete(a):t.add(a),o();else if(l.name==="return"){process.stdin.setRawMode&&process.stdin.setRawMode(false),s.close();let i=[...t].sort().map(d=>b[d].name);e(i.length>0?i:n);}else l.name==="c"&&l.ctrl&&(process.stdin.setRawMode&&process.stdin.setRawMode(false),s.close(),process.exit(0));});})}async function j(n,t={}){let a=D[n];a||(console.log(r.red(`
3625
3625
  Unknown template: ${n}`)),console.log(r.yellow(`Run 'vaif templates' to see available templates.
3626
- `)),process.exit(1));let e;t.features&&t.features.length>0?e=t.features.filter(i=>y.some(d=>d.name===i)):a.featureFiles&&Object.keys(a.featureFiles).length>0?e=await W(a.defaultFeatures??["database","auth"]):e=a.defaultFeatures??[],console.log(""),console.log(r.bold(`Scaffolding ${r.cyan(a.name)} template...`)),e.length>0&&console.log(r.gray(` Features: ${e.join(", ")}`)),console.log("");let s=[...a.files];if(a.featureFiles)for(let i of e){let d=a.featureFiles[i];d&&s.push(...d);}let o=0,c=0;for(let i of s){let d=w.resolve(i.path),f=w.dirname(d);if(g.existsSync(f)||g.mkdirSync(f,{recursive:true}),i.path==="package.json"&&g.existsSync(d)&&!t.force)try{let p=JSON.parse(g.readFileSync(d,"utf-8")),h=JSON.parse(i.content),b=P=>{if(!P)return {};let R={};for(let[k,A]of Object.entries(P))!A.startsWith("workspace:")&&!A.startsWith("link:")&&!A.startsWith("file:")&&(R[k]=A);return R};p.dependencies={...b(p.dependencies),...h.dependencies||{}},p.devDependencies={...b(p.devDependencies),...h.devDependencies||{}},h.scripts&&(p.scripts={...p.scripts||{},...h.scripts}),g.writeFileSync(d,JSON.stringify(p,null,2)+`
3627
- `,"utf-8"),console.log(r.green(` merge ${i.path} (added dependencies)`)),o++;continue}catch{}if(g.existsSync(d)&&!t.force){console.log(r.yellow(` skip ${i.path} (already exists)`)),c++;continue}g.writeFileSync(d,i.content,"utf-8"),console.log(r.green(` create ${i.path}`)),o++;}console.log(""),o>0&&console.log(r.green(`Created ${o} file${o!==1?"s":""}.`)),c>0&&console.log(r.yellow(`Skipped ${c} file${c!==1?"s":""} (use --force to overwrite).`));let u={auth:{"@vaiftech/auth":"^1.0.0"},database:{},realtime:{},storage:{},functions:{}},l=w.resolve("package.json");if(g.existsSync(l)&&e.length>0)try{let i=JSON.parse(g.readFileSync(l,"utf-8")),d=!1;for(let f of e){let p=u[f];if(p)for(let[h,b]of Object.entries(p))i.dependencies?.[h]||(i.dependencies=i.dependencies||{},i.dependencies[h]=b,d=!0);}d&&g.writeFileSync(l,JSON.stringify(i,null,2)+`
3628
- `,"utf-8");}catch{}(a.dependencies?.length||a.devDependencies?.length)&&(console.log(""),console.log(r.bold("Install dependencies:")),a.dependencies?.length&&console.log(r.cyan(` npm install ${a.dependencies.join(" ")}`)),a.devDependencies?.length&&console.log(r.cyan(` npm install -D ${a.devDependencies.join(" ")}`))),console.log(""),console.log(r.bold.green("Project scaffolded successfully!")),console.log(""),console.log(r.bold(" Next steps:")),a.postInstructions.forEach(i=>{console.log(r.gray(` ${i}`));}),console.log(""),console.log(r.gray(" Get your project credentials at https://vaif.studio")),console.log("");}var X={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function Se(n){let t=z("Initializing VAIF configuration...").start(),a=w.resolve("vaif.config.json");g.existsSync(a)&&!n.force&&(t.fail("vaif.config.json already exists"),console.log(r.yellow(`
3626
+ `)),process.exit(1));let e;t.features&&t.features.length>0?e=t.features.filter(i=>b.some(d=>d.name===i)):a.featureFiles&&Object.keys(a.featureFiles).length>0?e=await W(a.defaultFeatures??["database","auth"]):e=a.defaultFeatures??[],console.log(""),console.log(r.bold(`Scaffolding ${r.cyan(a.name)} template...`)),e.length>0&&console.log(r.gray(` Features: ${e.join(", ")}`)),console.log("");let s=[...a.files];if(a.featureFiles)for(let i of e){let d=a.featureFiles[i];d&&s.push(...d);}let o=0,c=0;for(let i of s){let d=w.resolve(i.path),f=w.dirname(d);if(g.existsSync(f)||g.mkdirSync(f,{recursive:true}),i.path==="package.json"&&g.existsSync(d)&&!t.force)try{let p=JSON.parse(g.readFileSync(d,"utf-8")),h=JSON.parse(i.content),y=P=>{if(!P)return {};let R={};for(let[k,A]of Object.entries(P))!A.startsWith("workspace:")&&!A.startsWith("link:")&&!A.startsWith("file:")&&(R[k]=A);return R};p.dependencies={...y(p.dependencies),...h.dependencies||{}},p.devDependencies={...y(p.devDependencies),...h.devDependencies||{}},h.scripts&&(p.scripts={...p.scripts||{},...h.scripts}),g.writeFileSync(d,JSON.stringify(p,null,2)+`
3627
+ `,"utf-8"),console.log(r.green(` merge ${i.path} (added dependencies)`)),o++;continue}catch{}if(g.existsSync(d)&&!t.force){console.log(r.yellow(` skip ${i.path} (already exists)`)),c++;continue}g.writeFileSync(d,i.content,"utf-8"),console.log(r.green(` create ${i.path}`)),o++;}console.log(""),o>0&&console.log(r.green(`Created ${o} file${o!==1?"s":""}.`)),c>0&&console.log(r.yellow(`Skipped ${c} file${c!==1?"s":""} (use --force to overwrite).`));let u={auth:{"@vaiftech/auth":"^1.0.0"},database:{},realtime:{},storage:{},functions:{}},l=w.resolve("package.json");if(g.existsSync(l)&&e.length>0)try{let i=JSON.parse(g.readFileSync(l,"utf-8")),d=!1;for(let f of e){let p=u[f];if(p)for(let[h,y]of Object.entries(p))i.dependencies?.[h]||(i.dependencies=i.dependencies||{},i.dependencies[h]=y,d=!0);}d&&g.writeFileSync(l,JSON.stringify(i,null,2)+`
3628
+ `,"utf-8");}catch{}(a.dependencies?.length||a.devDependencies?.length)&&(console.log(""),console.log(r.bold("Install dependencies:")),a.dependencies?.length&&console.log(r.cyan(` npm install ${a.dependencies.join(" ")}`)),a.devDependencies?.length&&console.log(r.cyan(` npm install -D ${a.devDependencies.join(" ")}`))),console.log(""),console.log(r.bold.green("Project scaffolded successfully!")),console.log(""),console.log(r.bold(" Next steps:")),a.postInstructions.forEach(i=>{console.log(r.gray(` ${i}`));}),console.log(""),console.log(r.gray(" Get your project credentials at https://vaif.studio/app/security/api-keys")),console.log("");}var X={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function Se(n){let t=z("Initializing VAIF configuration...").start(),a=w.resolve("vaif.config.json");g.existsSync(a)&&!n.force&&(t.fail("vaif.config.json already exists"),console.log(r.yellow(`
3629
3629
  Use --force to overwrite existing configuration.`)),process.exit(1));try{if(g.writeFileSync(a,JSON.stringify(X,null,2),"utf-8"),t.succeed("Created vaif.config.json"),n.template){let e=n.features?n.features.split(",").map(s=>s.trim()):void 0;await j(n.template,{force:n.force,features:e});}else {let e=w.resolve(".env.example");if(g.existsSync(e)||(g.writeFileSync(e,`# VAIF Configuration
3630
3630
  DATABASE_URL=postgresql://user:password@localhost:5432/database
3631
3631
  VAIF_API_KEY=your-api-key
package/dist/cli.cjs CHANGED
@@ -168,7 +168,7 @@ export function createVaifServer() {
168
168
  });
169
169
  }
170
170
  `},{path:".env.local.example",content:`# VAIF Configuration
171
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
171
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
172
172
 
173
173
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
174
174
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -205,7 +205,7 @@ A full-stack Next.js application powered by [VAIF Studio](https://vaif.studio),
205
205
  cp .env.local.example .env.local
206
206
  \\\`\\\`\\\`
207
207
 
208
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
208
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
209
209
 
210
210
  3. **Install and log in to the VAIF CLI**
211
211
 
@@ -655,7 +655,7 @@ interface ImportMeta {
655
655
  readonly env: ImportMetaEnv;
656
656
  }
657
657
  `},{path:".env.example",content:`# VAIF Configuration
658
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
658
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
659
659
 
660
660
  VITE_VAIF_PROJECT_ID=your-project-id
661
661
  VITE_VAIF_API_KEY=your-anon-key
@@ -688,7 +688,7 @@ A single-page React application built with [Vite](https://vite.dev/) and powered
688
688
  cp .env.example .env
689
689
  \\\`\\\`\\\`
690
690
 
691
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
691
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
692
692
 
693
693
  3. **Install and log in to the VAIF CLI**
694
694
 
@@ -1186,7 +1186,7 @@ An iOS/macOS application powered by [VAIF Studio](https://vaif.studio), using th
1186
1186
  <string>your-anon-key</string>
1187
1187
  \\\`\\\`\\\`
1188
1188
 
1189
- Get your credentials from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1189
+ Get your credentials from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1190
1190
 
1191
1191
  3. **Install and log in to the VAIF CLI** (for type generation)
1192
1192
 
@@ -1313,7 +1313,7 @@ export const vaif = createExpoClient({
1313
1313
  realtime: { enabled: true },
1314
1314
  });
1315
1315
  `},{path:".env.example",content:`# VAIF Configuration
1316
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1316
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1317
1317
 
1318
1318
  EXPO_PUBLIC_VAIF_PROJECT_ID=your-project-id
1319
1319
  EXPO_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -1347,7 +1347,7 @@ A React Native / Expo mobile application powered by [VAIF Studio](https://vaif.s
1347
1347
  cp .env.example .env
1348
1348
  \\\`\\\`\\\`
1349
1349
 
1350
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1350
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1351
1351
 
1352
1352
  3. **Install and log in to the VAIF CLI**
1353
1353
 
@@ -1737,7 +1737,7 @@ A Flutter application powered by [VAIF Studio](https://vaif.studio), with Dart c
1737
1737
  cp .env.example .env
1738
1738
  \\\`\\\`\\\`
1739
1739
 
1740
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1740
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1741
1741
 
1742
1742
  3. **Install and log in to the VAIF CLI** (for schema and type generation)
1743
1743
 
@@ -1995,7 +1995,7 @@ fastapi>=0.110.0
1995
1995
  uvicorn[standard]>=0.27.0
1996
1996
  python-dotenv>=1.0.0
1997
1997
  `},{path:".env.example",content:`# VAIF Configuration
1998
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1998
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1999
1999
 
2000
2000
  VAIF_PROJECT_ID=your-project-id
2001
2001
  VAIF_API_KEY=your-anon-key
@@ -2037,7 +2037,7 @@ A FastAPI backend application powered by [VAIF Studio](https://vaif.studio), wit
2037
2037
  cp .env.example .env
2038
2038
  \\\`\\\`\\\`
2039
2039
 
2040
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2040
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2041
2041
 
2042
2042
  4. **Install and log in to the VAIF CLI**
2043
2043
 
@@ -2355,7 +2355,7 @@ A Go backend API powered by [VAIF Studio](https://vaif.studio), with HTTP handle
2355
2355
  cp .env.example .env
2356
2356
  \\\`\\\`\\\`
2357
2357
 
2358
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2358
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2359
2359
 
2360
2360
  3. **Install and log in to the VAIF CLI**
2361
2361
 
@@ -2624,7 +2624,7 @@ export async function deleteTodo(id: string): Promise<void> {
2624
2624
  if (error) throw error;
2625
2625
  }
2626
2626
  `},{path:".env.example",content:`# VAIF Configuration
2627
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2627
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2628
2628
 
2629
2629
  VITE_VAIF_PROJECT_ID=your-project-id
2630
2630
  VITE_VAIF_API_KEY=your-anon-key
@@ -2652,7 +2652,7 @@ A simple React todo application for learning [VAIF Studio](https://vaif.studio)
2652
2652
  cp .env.example .env
2653
2653
  \\\`\\\`\\\`
2654
2654
 
2655
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2655
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2656
2656
 
2657
2657
  3. **Install and log in to the VAIF CLI**
2658
2658
 
@@ -2904,7 +2904,7 @@ export function useRealtimeMessages({
2904
2904
  return { messages, isLoading, error, refresh };
2905
2905
  }
2906
2906
  `},{path:".env.example",content:`# VAIF Configuration
2907
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2907
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2908
2908
 
2909
2909
  VITE_VAIF_PROJECT_ID=your-project-id
2910
2910
  VITE_VAIF_API_KEY=your-anon-key
@@ -2932,7 +2932,7 @@ A React chat application with live messaging powered by [VAIF Studio](https://va
2932
2932
  cp .env.example .env
2933
2933
  \\\`\\\`\\\`
2934
2934
 
2935
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2935
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2936
2936
 
2937
2937
  3. **Install and log in to the VAIF CLI**
2938
2938
 
@@ -3213,7 +3213,7 @@ export async function requireTeamRole(
3213
3213
  return member as TeamMember;
3214
3214
  }
3215
3215
  `},{path:".env.example",content:`# VAIF Configuration
3216
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3216
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3217
3217
 
3218
3218
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3219
3219
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3242,7 +3242,7 @@ A full SaaS starter kit powered by [VAIF Studio](https://vaif.studio) with authe
3242
3242
  cp .env.example .env.local
3243
3243
  \\\`\\\`\\\`
3244
3244
 
3245
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3245
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3246
3246
 
3247
3247
  3. **Install and log in to the VAIF CLI**
3248
3248
 
@@ -3481,7 +3481,7 @@ function getContentType(fileName: string): string {
3481
3481
  return mimeTypes[ext ?? ""] ?? "application/octet-stream";
3482
3482
  }
3483
3483
  `},{path:".env.example",content:`# VAIF Configuration
3484
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3484
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3485
3485
 
3486
3486
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3487
3487
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3510,7 +3510,7 @@ An API-first e-commerce setup powered by [VAIF Studio](https://vaif.studio) with
3510
3510
  cp .env.example .env.local
3511
3511
  \\\`\\\`\\\`
3512
3512
 
3513
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3513
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3514
3514
 
3515
3515
  3. **Install and log in to the VAIF CLI**
3516
3516
 
@@ -3626,7 +3626,7 @@ export const posts = pgTable("posts", {
3626
3626
  Unknown template: ${t}`)),console.log(p__default.default.yellow(`Run 'vaif templates' to see available templates.
3627
3627
  `)),process.exit(1));let n;e.features&&e.features.length>0?n=e.features.filter(c=>k.some(u=>u.name===c)):o.featureFiles&&Object.keys(o.featureFiles).length>0?n=await Xe(o.defaultFeatures??["database","auth"]):n=o.defaultFeatures??[],console.log(""),console.log(p__default.default.bold(`Scaffolding ${p__default.default.cyan(o.name)} template...`)),n.length>0&&console.log(p__default.default.gray(` Features: ${n.join(", ")}`)),console.log("");let r=[...o.files];if(o.featureFiles)for(let c of n){let u=o.featureFiles[c];u&&r.push(...u);}let s=0,i=0;for(let c of r){let u=I__default.default.resolve(c.path),f=I__default.default.dirname(u);if(R__default.default.existsSync(f)||R__default.default.mkdirSync(f,{recursive:true}),c.path==="package.json"&&R__default.default.existsSync(u)&&!e.force)try{let d=JSON.parse(R__default.default.readFileSync(u,"utf-8")),m=JSON.parse(c.content),b=C=>{if(!C)return {};let U={};for(let[$e,$]of Object.entries(C))!$.startsWith("workspace:")&&!$.startsWith("link:")&&!$.startsWith("file:")&&(U[$e]=$);return U};d.dependencies={...b(d.dependencies),...m.dependencies||{}},d.devDependencies={...b(d.devDependencies),...m.devDependencies||{}},m.scripts&&(d.scripts={...d.scripts||{},...m.scripts}),R__default.default.writeFileSync(u,JSON.stringify(d,null,2)+`
3628
3628
  `,"utf-8"),console.log(p__default.default.green(` merge ${c.path} (added dependencies)`)),s++;continue}catch{}if(R__default.default.existsSync(u)&&!e.force){console.log(p__default.default.yellow(` skip ${c.path} (already exists)`)),i++;continue}R__default.default.writeFileSync(u,c.content,"utf-8"),console.log(p__default.default.green(` create ${c.path}`)),s++;}console.log(""),s>0&&console.log(p__default.default.green(`Created ${s} file${s!==1?"s":""}.`)),i>0&&console.log(p__default.default.yellow(`Skipped ${i} file${i!==1?"s":""} (use --force to overwrite).`));let a={auth:{"@vaiftech/auth":"^1.0.0"},database:{},realtime:{},storage:{},functions:{}},l=I__default.default.resolve("package.json");if(R__default.default.existsSync(l)&&n.length>0)try{let c=JSON.parse(R__default.default.readFileSync(l,"utf-8")),u=!1;for(let f of n){let d=a[f];if(d)for(let[m,b]of Object.entries(d))c.dependencies?.[m]||(c.dependencies=c.dependencies||{},c.dependencies[m]=b,u=!0);}u&&R__default.default.writeFileSync(l,JSON.stringify(c,null,2)+`
3629
- `,"utf-8");}catch{}(o.dependencies?.length||o.devDependencies?.length)&&(console.log(""),console.log(p__default.default.bold("Install dependencies:")),o.dependencies?.length&&console.log(p__default.default.cyan(` npm install ${o.dependencies.join(" ")}`)),o.devDependencies?.length&&console.log(p__default.default.cyan(` npm install -D ${o.devDependencies.join(" ")}`))),console.log(""),console.log(p__default.default.bold.green("Project scaffolded successfully!")),console.log(""),console.log(p__default.default.bold(" Next steps:")),o.postInstructions.forEach(c=>{console.log(p__default.default.gray(` ${c}`));}),console.log(""),console.log(p__default.default.gray(" Get your project credentials at https://vaif.studio")),console.log("");}var Ze={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function le(t){let e=K__default.default("Initializing VAIF configuration...").start(),o=I__default.default.resolve("vaif.config.json");R__default.default.existsSync(o)&&!t.force&&(e.fail("vaif.config.json already exists"),console.log(p__default.default.yellow(`
3629
+ `,"utf-8");}catch{}(o.dependencies?.length||o.devDependencies?.length)&&(console.log(""),console.log(p__default.default.bold("Install dependencies:")),o.dependencies?.length&&console.log(p__default.default.cyan(` npm install ${o.dependencies.join(" ")}`)),o.devDependencies?.length&&console.log(p__default.default.cyan(` npm install -D ${o.devDependencies.join(" ")}`))),console.log(""),console.log(p__default.default.bold.green("Project scaffolded successfully!")),console.log(""),console.log(p__default.default.bold(" Next steps:")),o.postInstructions.forEach(c=>{console.log(p__default.default.gray(` ${c}`));}),console.log(""),console.log(p__default.default.gray(" Get your project credentials at https://vaif.studio/app/security/api-keys")),console.log("");}var Ze={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function le(t){let e=K__default.default("Initializing VAIF configuration...").start(),o=I__default.default.resolve("vaif.config.json");R__default.default.existsSync(o)&&!t.force&&(e.fail("vaif.config.json already exists"),console.log(p__default.default.yellow(`
3630
3630
  Use --force to overwrite existing configuration.`)),process.exit(1));try{if(R__default.default.writeFileSync(o,JSON.stringify(Ze,null,2),"utf-8"),e.succeed("Created vaif.config.json"),t.template){let n=t.features?t.features.split(",").map(r=>r.trim()):void 0;await se(t.template,{force:t.force,features:n});}else {let n=I__default.default.resolve(".env.example");if(R__default.default.existsSync(n)||(R__default.default.writeFileSync(n,`# VAIF Configuration
3631
3631
  DATABASE_URL=postgresql://user:password@localhost:5432/database
3632
3632
  VAIF_API_KEY=your-api-key
@@ -3666,4 +3666,4 @@ Error: ${a.message}`)),process.exit(1);}}async function Le(t){let e=K__default.d
3666
3666
  Generate one with: vaif keys generate`));return}let c=Math.max(8,...l.map(f=>(f.name||"").length)),u=` ${"Name".padEnd(c)} ${"Key".padEnd(24)} Created`;console.log(p__default.default.gray(u)),console.log(p__default.default.gray(" "+"-".repeat(u.length-2)));for(let f of l){let d=(f.name||"unnamed").padEnd(c),m=f.maskedKey||f.prefix||`${(f.key||"").slice(0,12)}...`,b=f.createdAt?new Date(f.createdAt).toLocaleDateString():"N/A";console.log(` ${d} ${m.padEnd(24)} ${b}`);}console.log(""),console.log(p__default.default.gray(` ${l.length} key(s) total`)),console.log("");}catch(i){e.fail("Failed to list API keys"),i instanceof Error&&console.log(p__default.default.red(`
3667
3667
  Error: ${i.message}`)),process.exit(1);}}var De=process.env.VAIF_API_URL||"https://api.vaif.studio";function Tt(t){try{let e=new URL(t);return e.password&&(e.password="****"),e.toString()}catch{return t.replace(/:[^@/]+@/,":****@")}}async function Ve(t){let e=K__default.default(),o=w();(!o||!o.token)&&(console.log(p__default.default.red("Not logged in")),console.log(p__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let s=t.projectId||r?.projectId||o.projectId;s||(console.log(p__default.default.red("No project ID specified")),console.log(p__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let i=await fetch(`${De}/v1/projects/${s}`,{headers:{Authorization:`Bearer ${o.token}`}});if(!i.ok){let u=await i.text();throw new Error(`Failed to fetch project: ${u}`)}let a=await i.json();e.stop(),console.log(""),console.log(p__default.default.bold("VAIF Project Info")),console.log("");let l=16,c=(u,f)=>{console.log(` ${p__default.default.gray(u.padEnd(l))} ${f}`);};c("Name:",p__default.default.white(a.name||"N/A")),c("Project ID:",p__default.default.white(s)),c("Region:",p__default.default.white(a.region||"us-east-1")),c("Plan:",p__default.default.white(a.plan||a.tier||"free")),c("Created:",p__default.default.white(a.createdAt?new Date(a.createdAt).toLocaleDateString():"N/A")),console.log(""),c("API URL:",p__default.default.cyan(a.apiUrl||`${De}/v1`)),c("WS URL:",p__default.default.cyan(a.wsUrl||a.realtimeUrl||"N/A")),c("DB URL:",p__default.default.cyan(a.databaseUrl?Tt(a.databaseUrl):"N/A")),c("Storage URL:",p__default.default.cyan(a.storageUrl||"N/A")),console.log("");}catch(i){e.fail("Failed to fetch project info"),i instanceof Error&&console.log(p__default.default.red(`
3668
3668
  Error: ${i.message}`)),process.exit(1);}}var Pt=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Ue(t){let e=K__default.default(),o=w();(!o||!o.token)&&(console.log(p__default.default.red("Not logged in")),console.log(p__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let s=t.projectId||r?.projectId||o.projectId;s||(console.log(p__default.default.red("No project ID specified")),console.log(p__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let i=await fetch(`${Pt}/v1/projects/${s}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${o.token}`}});if(!i.ok){let b=await i.text();throw new Error(`Failed to fetch project status: ${b}`)}let a=await i.json();e.stop(),console.log(""),console.log(p__default.default.bold("VAIF Project Status")),console.log("");let l=22,c=(b,C)=>{console.log(` ${p__default.default.gray(b.padEnd(l))} ${C}`);};c("Project:",p__default.default.white(a.name||s)),c("Plan:",p__default.default.white(a.plan||a.tier||"free")),console.log(""),console.log(p__default.default.gray(" --- Resources ---")),console.log("");let u=a.tableCount??a.tables?.length??"N/A",f=a.functionCount??a.functions?.length??"N/A",d=a.bucketCount??a.storage?.buckets?.length??"N/A",m=a.activeConnections??a.connections??"N/A";c("Tables:",p__default.default.white(String(u))),c("Functions:",p__default.default.white(String(f))),c("Storage Buckets:",p__default.default.white(String(d))),c("Active Connections:",p__default.default.white(String(m))),a.usage&&(console.log(""),console.log(p__default.default.gray(" --- Usage ---")),console.log(""),a.usage.dbSize&&c("Database Size:",p__default.default.white(a.usage.dbSize)),a.usage.storageSize&&c("Storage Size:",p__default.default.white(a.usage.storageSize)),a.usage.bandwidth&&c("Bandwidth:",p__default.default.white(a.usage.bandwidth)),a.usage.functionInvocations!=null&&c("Function Invocations:",p__default.default.white(String(a.usage.functionInvocations)))),console.log("");}catch(i){e.fail("Failed to fetch project status"),i instanceof Error&&console.log(p__default.default.red(`
3669
- Error: ${i.message}`)),process.exit(1);}}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.5.0");commander.program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(pe);commander.program.command("logout").description("Log out and remove stored credentials").action(fe);commander.program.command("whoami").description("Show current authenticated user").action(me);commander.program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").action(le);commander.program.command("templates").alias("tpl").description("List available project templates").action(re);commander.program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ve);commander.program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ue);commander.program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(ge);commander.program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(ve);commander.program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(ne);var ke=commander.program.command("functions").alias("fn").description("Manage serverless functions");ke.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(Se);ke.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(Ee);var q=commander.program.command("db").description("Database management commands");q.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(Te);q.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(Fe);q.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(_e);q.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(Pe);var Oe=commander.program.command("keys").description("Manage API keys");Oe.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ne);Oe.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Le);commander.program.parse(process.argv);process.argv.slice(2).length||commander.program.outputHelp();
3669
+ Error: ${i.message}`)),process.exit(1);}}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.5.1");commander.program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(pe);commander.program.command("logout").description("Log out and remove stored credentials").action(fe);commander.program.command("whoami").description("Show current authenticated user").action(me);commander.program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").action(le);commander.program.command("templates").alias("tpl").description("List available project templates").action(re);commander.program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ve);commander.program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ue);commander.program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(ge);commander.program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(ve);commander.program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(ne);var ke=commander.program.command("functions").alias("fn").description("Manage serverless functions");ke.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(Se);ke.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(Ee);var q=commander.program.command("db").description("Database management commands");q.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(Te);q.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(Fe);q.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(_e);q.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(Pe);var Oe=commander.program.command("keys").description("Manage API keys");Oe.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ne);Oe.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Le);commander.program.parse(process.argv);process.argv.slice(2).length||commander.program.outputHelp();
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {d,c,b,a}from'./chunk-JRB5YVG7.js';import {program}from'commander';import F from'fs';import w from'path';import So from'os';import {exec}from'child_process';import V from'ora';import c$1 from'chalk';import q from'readline';var _=w.join(So.homedir(),".vaif"),D=w.join(_,"auth.json"),O=process.env.VAIF_API_URL||"https://api.vaif.studio";function Po(){F.existsSync(_)||F.mkdirSync(_,{recursive:true});}function G(e){Po(),F.writeFileSync(D,JSON.stringify(e,null,2),"utf-8"),F.chmodSync(D,384);}function j(){if(!F.existsSync(D))return null;try{let e=F.readFileSync(D,"utf-8");return JSON.parse(e)}catch{return null}}function xo(e){let o=q.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{o.question(e,i=>{o.close(),t(i);});})}function Fo(e){return new Promise(o=>{let t=q.createInterface({input:process.stdin,output:process.stdout});process.stdin;let r=process.stdout.write.bind(process.stdout),l=false;process.stdout.write=((...s)=>l?true:r(...s)),t.question(e,s=>{l=false,process.stdout.write=r,console.log(""),t.close(),o(s);}),l=true;})}function ko(e){let o=process.platform,t;o==="darwin"?t=`open "${e}"`:o==="win32"?t=`start "" "${e}"`:t=`xdg-open "${e}"`,exec(t,i=>{});}function Co(e){return new Promise(o=>setTimeout(o,e))}async function Do(e){try{let o=await fetch(`${O}/auth/me`,{headers:{Authorization:`Bearer ${e}`}});if(o.ok){let t=await o.json();return {valid:!0,email:t.user?.email||t.email}}return {valid:!1}}catch{return {valid:false}}}async function Eo(e){let o=V();o.start("Setting up authentication...");let t,i;try{let n=await fetch(`${O}/auth/cli/authorize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});n.ok||(o.fail("Failed to initiate authentication"),console.log(c$1.red(`
2
+ import {d,c,b,a}from'./chunk-F5OP4YDB.js';import {program}from'commander';import F from'fs';import w from'path';import So from'os';import {exec}from'child_process';import V from'ora';import c$1 from'chalk';import q from'readline';var _=w.join(So.homedir(),".vaif"),D=w.join(_,"auth.json"),O=process.env.VAIF_API_URL||"https://api.vaif.studio";function Po(){F.existsSync(_)||F.mkdirSync(_,{recursive:true});}function G(e){Po(),F.writeFileSync(D,JSON.stringify(e,null,2),"utf-8"),F.chmodSync(D,384);}function j(){if(!F.existsSync(D))return null;try{let e=F.readFileSync(D,"utf-8");return JSON.parse(e)}catch{return null}}function xo(e){let o=q.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{o.question(e,i=>{o.close(),t(i);});})}function Fo(e){return new Promise(o=>{let t=q.createInterface({input:process.stdin,output:process.stdout});process.stdin;let r=process.stdout.write.bind(process.stdout),l=false;process.stdout.write=((...s)=>l?true:r(...s)),t.question(e,s=>{l=false,process.stdout.write=r,console.log(""),t.close(),o(s);}),l=true;})}function ko(e){let o=process.platform,t;o==="darwin"?t=`open "${e}"`:o==="win32"?t=`start "" "${e}"`:t=`xdg-open "${e}"`,exec(t,i=>{});}function Co(e){return new Promise(o=>setTimeout(o,e))}async function Do(e){try{let o=await fetch(`${O}/auth/me`,{headers:{Authorization:`Bearer ${e}`}});if(o.ok){let t=await o.json();return {valid:!0,email:t.user?.email||t.email}}return {valid:!1}}catch{return {valid:false}}}async function Eo(e){let o=V();o.start("Setting up authentication...");let t,i;try{let n=await fetch(`${O}/auth/cli/authorize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});n.ok||(o.fail("Failed to initiate authentication"),console.log(c$1.red(`
3
3
  Could not connect to VAIF API. Please try again later.`)),process.exit(1));let a=await n.json();t=a.code,i=a.url;}catch{o.fail("Failed to connect to VAIF API"),console.log(c$1.red(`
4
4
  Could not connect to VAIF API.`)),console.log(c$1.gray("Check your internet connection or try: vaif login --email")),process.exit(1);}o.stop(),console.log(c$1.cyan(" Opening browser for authentication...")),console.log(""),console.log(c$1.gray(" If the browser doesn't open, visit this URL:")),console.log(c$1.white(` ${i}`)),console.log(""),ko(i),o.start("Waiting for browser authentication...");let r=12e4,l=2e3,s=Date.now();for(;Date.now()-s<r;){await Co(l);try{let n=await fetch(`${O}/auth/cli/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:t})});if(!n.ok){let d=await n.json();(d.error==="ExpiredCode"||d.error==="InvalidCode")&&(o.fail("Authentication expired"),console.log(c$1.red(`
5
5
  The authentication session expired. Please try again.`)),process.exit(1));continue}let a=await n.json();if(a.ok&&a.accessToken){let d={token:a.accessToken,email:a.user?.email,projectId:e,expiresAt:new Date(Date.now()+a.expiresIn*1e3).toISOString()};G(d),o.succeed("Logged in successfully"),console.log(""),a.user?.email&&console.log(c$1.green(` Authenticated as: ${a.user.email}`)),console.log(c$1.gray(` Config saved to: ${D}`)),console.log("");return}}catch{}}o.fail("Authentication timed out"),console.log(c$1.red(`
@@ -34,4 +34,4 @@ Error: ${n.message}`)),process.exit(1);}}async function wo(e){let o=V(),t=j();(!
34
34
  Generate one with: vaif keys generate`));return}let d=Math.max(8,...a.map(f=>(f.name||"").length)),p=` ${"Name".padEnd(d)} ${"Key".padEnd(24)} Created`;console.log(c$1.gray(p)),console.log(c$1.gray(" "+"-".repeat(p.length-2)));for(let f of a){let g=(f.name||"unnamed").padEnd(d),y=f.maskedKey||f.prefix||`${(f.key||"").slice(0,12)}...`,$=f.createdAt?new Date(f.createdAt).toLocaleDateString():"N/A";console.log(` ${g} ${y.padEnd(24)} ${$}`);}console.log(""),console.log(c$1.gray(` ${a.length} key(s) total`)),console.log("");}catch(s){o.fail("Failed to list API keys"),s instanceof Error&&console.log(c$1.red(`
35
35
  Error: ${s.message}`)),process.exit(1);}}var jo=process.env.VAIF_API_URL||"https://api.vaif.studio";function Qo(e){try{let o=new URL(e);return o.password&&(o.password="****"),o.toString()}catch{return e.replace(/:[^@/]+@/,":****@")}}async function vo(e){let o=V(),t=j();(!t||!t.token)&&(console.log(c$1.red("Not logged in")),console.log(c$1.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;try{r=await a(i);}catch{}let l=e.projectId||r?.projectId||t.projectId;l||(console.log(c$1.red("No project ID specified")),console.log(c$1.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),o.start("Fetching project info...");try{let s=await fetch(`${jo}/v1/projects/${l}`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let p=await s.text();throw new Error(`Failed to fetch project: ${p}`)}let n=await s.json();o.stop(),console.log(""),console.log(c$1.bold("VAIF Project Info")),console.log("");let a=16,d=(p,f)=>{console.log(` ${c$1.gray(p.padEnd(a))} ${f}`);};d("Name:",c$1.white(n.name||"N/A")),d("Project ID:",c$1.white(l)),d("Region:",c$1.white(n.region||"us-east-1")),d("Plan:",c$1.white(n.plan||n.tier||"free")),d("Created:",c$1.white(n.createdAt?new Date(n.createdAt).toLocaleDateString():"N/A")),console.log(""),d("API URL:",c$1.cyan(n.apiUrl||`${jo}/v1`)),d("WS URL:",c$1.cyan(n.wsUrl||n.realtimeUrl||"N/A")),d("DB URL:",c$1.cyan(n.databaseUrl?Qo(n.databaseUrl):"N/A")),d("Storage URL:",c$1.cyan(n.storageUrl||"N/A")),console.log("");}catch(s){o.fail("Failed to fetch project info"),s instanceof Error&&console.log(c$1.red(`
36
36
  Error: ${s.message}`)),process.exit(1);}}var Zo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Io(e){let o=V(),t=j();(!t||!t.token)&&(console.log(c$1.red("Not logged in")),console.log(c$1.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;try{r=await a(i);}catch{}let l=e.projectId||r?.projectId||t.projectId;l||(console.log(c$1.red("No project ID specified")),console.log(c$1.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),o.start("Fetching project status...");try{let s=await fetch(`${Zo}/v1/projects/${l}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let $=await s.text();throw new Error(`Failed to fetch project status: ${$}`)}let n=await s.json();o.stop(),console.log(""),console.log(c$1.bold("VAIF Project Status")),console.log("");let a=22,d=($,k)=>{console.log(` ${c$1.gray($.padEnd(a))} ${k}`);};d("Project:",c$1.white(n.name||l)),d("Plan:",c$1.white(n.plan||n.tier||"free")),console.log(""),console.log(c$1.gray(" --- Resources ---")),console.log("");let p=n.tableCount??n.tables?.length??"N/A",f=n.functionCount??n.functions?.length??"N/A",g=n.bucketCount??n.storage?.buckets?.length??"N/A",y=n.activeConnections??n.connections??"N/A";d("Tables:",c$1.white(String(p))),d("Functions:",c$1.white(String(f))),d("Storage Buckets:",c$1.white(String(g))),d("Active Connections:",c$1.white(String(y))),n.usage&&(console.log(""),console.log(c$1.gray(" --- Usage ---")),console.log(""),n.usage.dbSize&&d("Database Size:",c$1.white(n.usage.dbSize)),n.usage.storageSize&&d("Storage Size:",c$1.white(n.usage.storageSize)),n.usage.bandwidth&&d("Bandwidth:",c$1.white(n.usage.bandwidth)),n.usage.functionInvocations!=null&&d("Function Invocations:",c$1.white(String(n.usage.functionInvocations)))),console.log("");}catch(s){o.fail("Failed to fetch project status"),s instanceof Error&&console.log(c$1.red(`
37
- Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.5.0");program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(Y);program.command("logout").description("Log out and remove stored credentials").action(H);program.command("whoami").description("Show current authenticated user").action(Q);program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").action(d);program.command("templates").alias("tpl").description("List available project templates").action(c);program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(vo);program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Io);program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(X);program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(eo);program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(b);var bo=program.command("functions").alias("fn").description("Manage serverless functions");bo.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(ro);bo.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(co);var U=program.command("db").description("Database management commands");U.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(go);U.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(fo);U.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(lo);U.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(po);var $o=program.command("keys").description("Manage API keys");$o.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(yo);$o.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(wo);program.parse(process.argv);process.argv.slice(2).length||program.outputHelp();
37
+ Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.5.1");program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(Y);program.command("logout").description("Log out and remove stored credentials").action(H);program.command("whoami").description("Show current authenticated user").action(Q);program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").action(d);program.command("templates").alias("tpl").description("List available project templates").action(c);program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(vo);program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Io);program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(X);program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(eo);program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(b);var bo=program.command("functions").alias("fn").description("Manage serverless functions");bo.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(ro);bo.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(co);var U=program.command("db").description("Database management commands");U.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(go);U.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(fo);U.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(lo);U.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(po);var $o=program.command("keys").description("Manage API keys");$o.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(yo);$o.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(wo);program.parse(process.argv);process.argv.slice(2).length||program.outputHelp();
package/dist/index.cjs CHANGED
@@ -44,22 +44,22 @@
44
44
  JOIN pg_namespace n ON n.oid = t.typnamespace
45
45
  WHERE n.nspname = $1
46
46
  ORDER BY t.typname, e.enumsortorder
47
- `,[a]),c=new Map;for(let l of t.rows)c.set(l.table_name,[]);for(let l of e.rows){let o=c.get(l.table_name);o&&o.push(l);}let u=new Map;for(let l of r.rows){let o=u.get(l.enum_name)||[];o.push(l.enum_value),u.set(l.enum_name,o);}return {tables:c,enums:u,foreignKeys:i.rows}}var S={smallint:"number",integer:"number",bigint:"string",int2:"number",int4:"number",int8:"string",decimal:"string",numeric:"string",real:"number",float4:"number",float8:"number","double precision":"number",money:"string",boolean:"boolean",bool:"boolean",text:"string",varchar:"string",char:"string",character:"string","character varying":"string",name:"string",citext:"string",date:"string",time:"string",timetz:"string","time without time zone":"string","time with time zone":"string",timestamp:"string",timestamptz:"string","timestamp without time zone":"string","timestamp with time zone":"string",interval:"string",bytea:"Buffer",uuid:"string",json:"unknown",jsonb:"unknown",inet:"string",cidr:"string",macaddr:"string",macaddr8:"string",point:"{ x: number; y: number }",line:"string",lseg:"string",box:"string",path:"string",polygon:"string",circle:"string",ARRAY:"unknown[]"};function $(n,a){let{data_type:t,udt_name:e,is_nullable:i}=n;if(a.has(e)){let u=a.get(e).map(l=>`"${l}"`).join(" | ");return i==="YES"?`(${u}) | null`:u}if(t==="ARRAY"){let c=e.replace(/^_/,"");if(a.has(c)){let o=a.get(c).map(s=>`"${s}"`).join(" | ");return i==="YES"?`(${o})[] | null`:`(${o})[]`}let u=S[c]||"unknown";return i==="YES"?`${u}[] | null`:`${u}[]`}let r=S[t]||S[e]||"unknown";return i==="YES"&&(r=`${r} | null`),r}function x(n){return n.split(/[_\-\s]+/).map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join("")}function Y(n,a){let t=x(n),e=a.map(i=>` | "${i}"`).join(`
47
+ `,[a]),c=new Map;for(let l of t.rows)c.set(l.table_name,[]);for(let l of e.rows){let s=c.get(l.table_name);s&&s.push(l);}let u=new Map;for(let l of r.rows){let s=u.get(l.enum_name)||[];s.push(l.enum_value),u.set(l.enum_name,s);}return {tables:c,enums:u,foreignKeys:i.rows}}var S={smallint:"number",integer:"number",bigint:"string",int2:"number",int4:"number",int8:"string",decimal:"string",numeric:"string",real:"number",float4:"number",float8:"number","double precision":"number",money:"string",boolean:"boolean",bool:"boolean",text:"string",varchar:"string",char:"string",character:"string","character varying":"string",name:"string",citext:"string",date:"string",time:"string",timetz:"string","time without time zone":"string","time with time zone":"string",timestamp:"string",timestamptz:"string","timestamp without time zone":"string","timestamp with time zone":"string",interval:"string",bytea:"Buffer",uuid:"string",json:"unknown",jsonb:"unknown",inet:"string",cidr:"string",macaddr:"string",macaddr8:"string",point:"{ x: number; y: number }",line:"string",lseg:"string",box:"string",path:"string",polygon:"string",circle:"string",ARRAY:"unknown[]"};function $(n,a){let{data_type:t,udt_name:e,is_nullable:i}=n;if(a.has(e)){let u=a.get(e).map(l=>`"${l}"`).join(" | ");return i==="YES"?`(${u}) | null`:u}if(t==="ARRAY"){let c=e.replace(/^_/,"");if(a.has(c)){let s=a.get(c).map(o=>`"${o}"`).join(" | ");return i==="YES"?`(${s})[] | null`:`(${s})[]`}let u=S[c]||"unknown";return i==="YES"?`${u}[] | null`:`${u}[]`}let r=S[t]||S[e]||"unknown";return i==="YES"&&(r=`${r} | null`),r}function x(n){return n.split(/[_\-\s]+/).map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join("")}function Y(n,a){let t=x(n),e=a.map(i=>` | "${i}"`).join(`
48
48
  `);return `export type ${t} =
49
- ${e};`}function G(n,a,t){let e=x(n),i=[],r=[],c=[];for(let s of a){let d=$(s,t),p=s.column_name,g=s.column_default!==null||s.is_identity==="YES",b=s.is_nullable==="YES";i.push(` ${p}: ${d};`),g||s.column_name==="id"?r.push(` ${p}?: ${d.replace(" | null","")} | null;`):b?r.push(` ${p}?: ${d};`):r.push(` ${p}: ${d.replace(" | null","")};`),c.push(` ${p}?: ${d.replace(" | null","")} | null;`);}let u=`export interface ${e} {
49
+ ${e};`}function G(n,a,t){let e=x(n),i=[],r=[],c=[];for(let o of a){let d=$(o,t),p=o.column_name,g=o.column_default!==null||o.is_identity==="YES",y=o.is_nullable==="YES";i.push(` ${p}: ${d};`),g||o.column_name==="id"?r.push(` ${p}?: ${d.replace(" | null","")} | null;`):y?r.push(` ${p}?: ${d};`):r.push(` ${p}: ${d.replace(" | null","")};`),c.push(` ${p}?: ${d.replace(" | null","")} | null;`);}let u=`export interface ${e} {
50
50
  ${i.join(`
51
51
  `)}
52
52
  }`,l=`export interface ${e}Insert {
53
53
  ${r.join(`
54
54
  `)}
55
- }`,o=`export interface ${e}Update {
55
+ }`,s=`export interface ${e}Update {
56
56
  ${c.join(`
57
57
  `)}
58
- }`;return {base:u,insert:l,update:o}}function H(n,a,t){let e=["/**"," * Auto-generated TypeScript types from database schema"," * Generated by @vaiftech/cli",` * Generated at: ${new Date().toISOString()}`," * "," * DO NOT EDIT MANUALLY - changes will be overwritten"," */",""];if(a.size>0){e.push("// ============ ENUMS ============"),e.push("");for(let[r,c]of a)e.push(Y(r,c)),e.push("");}e.push("// ============ TABLES ============"),e.push("");let i=[];for(let[r,c]of n){let{base:u,insert:l,update:o}=G(r,c,a);i.push(r),e.push(u),e.push(""),e.push(l),e.push(""),e.push(o),e.push("");}e.push("// ============ DATABASE SCHEMA ============"),e.push(""),e.push("export interface Database {");for(let r of i){let c=x(r);e.push(` ${r}: {`),e.push(` Row: ${c};`),e.push(` Insert: ${c}Insert;`),e.push(` Update: ${c}Update;`),e.push(" };");}return e.push("}"),e.push(""),e.push("export type TableName = keyof Database;"),e.push(""),e.push("// ============ HELPER TYPES ============"),e.push(""),e.push('export type Row<T extends TableName> = Database[T]["Row"];'),e.push('export type Insert<T extends TableName> = Database[T]["Insert"];'),e.push('export type Update<T extends TableName> = Database[T]["Update"];'),e.push(""),e.join(`
58
+ }`;return {base:u,insert:l,update:s}}function H(n,a,t){let e=["/**"," * Auto-generated TypeScript types from database schema"," * Generated by @vaiftech/cli",` * Generated at: ${new Date().toISOString()}`," * "," * DO NOT EDIT MANUALLY - changes will be overwritten"," */",""];if(a.size>0){e.push("// ============ ENUMS ============"),e.push("");for(let[r,c]of a)e.push(Y(r,c)),e.push("");}e.push("// ============ TABLES ============"),e.push("");let i=[];for(let[r,c]of n){let{base:u,insert:l,update:s}=G(r,c,a);i.push(r),e.push(u),e.push(""),e.push(l),e.push(""),e.push(s),e.push("");}e.push("// ============ DATABASE SCHEMA ============"),e.push(""),e.push("export interface Database {");for(let r of i){let c=x(r);e.push(` ${r}: {`),e.push(` Row: ${c};`),e.push(` Insert: ${c}Insert;`),e.push(` Update: ${c}Update;`),e.push(" };");}return e.push("}"),e.push(""),e.push("export type TableName = keyof Database;"),e.push(""),e.push("// ============ HELPER TYPES ============"),e.push(""),e.push('export type Row<T extends TableName> = Database[T]["Row"];'),e.push('export type Insert<T extends TableName> = Database[T]["Insert"];'),e.push('export type Update<T extends TableName> = Database[T]["Update"];'),e.push(""),e.join(`
59
59
  `)}async function W(n){let a=z__default.default("Loading configuration...").start();try{let t=await E(n.config),e=n.connection||t?.database?.url||process.env.DATABASE_URL;e||(a.fail("No database connection string provided"),console.log(m__default.default.yellow(`
60
- Provide a connection string via:`)),console.log(m__default.default.gray(" --connection <url>")),console.log(m__default.default.gray(" DATABASE_URL environment variable")),console.log(m__default.default.gray(" vaif.config.json database.url")),process.exit(1)),a.text="Connecting to database...";let i=new K__default.default.Client({connectionString:e});await i.connect(),a.text="Introspecting schema...";let{tables:r,enums:c,foreignKeys:u}=await B(i,n.schema);if(await i.end(),r.size===0){a.warn(`No tables found in schema "${n.schema}"`);return}a.text=`Generating types for ${r.size} tables...`;let l=H(r,c,u),o=await q__default.default.format(l,{parser:"typescript",semi:!0,singleQuote:!1,trailingComma:"es5",printWidth:100});if(n.dryRun){a.succeed("Generated types (dry run):"),console.log(""),console.log(m__default.default.gray("\u2500".repeat(60))),console.log(o),console.log(m__default.default.gray("\u2500".repeat(60)));return}let s=w__default.default.resolve(n.output),d=w__default.default.dirname(s);h__default.default.existsSync(d)||h__default.default.mkdirSync(d,{recursive:!0}),h__default.default.writeFileSync(s,o,"utf-8"),a.succeed(`Generated types for ${r.size} tables \u2192 ${m__default.default.cyan(n.output)}`),console.log(""),console.log(m__default.default.green("Generated:")),console.log(m__default.default.gray(` Tables: ${r.size}`)),console.log(m__default.default.gray(` Enums: ${c.size}`)),console.log(""),console.log(m__default.default.gray("Import in your code:")),console.log(m__default.default.cyan(` import type { Database, Row, Insert, Update } from "${n.output.replace(/\.ts$/,"")}";`));}catch(t){a.fail("Failed to generate types"),t instanceof Error&&(console.error(m__default.default.red(`
60
+ Provide a connection string via:`)),console.log(m__default.default.gray(" --connection <url>")),console.log(m__default.default.gray(" DATABASE_URL environment variable")),console.log(m__default.default.gray(" vaif.config.json database.url")),process.exit(1)),a.text="Connecting to database...";let i=new K__default.default.Client({connectionString:e});await i.connect(),a.text="Introspecting schema...";let{tables:r,enums:c,foreignKeys:u}=await B(i,n.schema);if(await i.end(),r.size===0){a.warn(`No tables found in schema "${n.schema}"`);return}a.text=`Generating types for ${r.size} tables...`;let l=H(r,c,u),s=await q__default.default.format(l,{parser:"typescript",semi:!0,singleQuote:!1,trailingComma:"es5",printWidth:100});if(n.dryRun){a.succeed("Generated types (dry run):"),console.log(""),console.log(m__default.default.gray("\u2500".repeat(60))),console.log(s),console.log(m__default.default.gray("\u2500".repeat(60)));return}let o=w__default.default.resolve(n.output),d=w__default.default.dirname(o);h__default.default.existsSync(d)||h__default.default.mkdirSync(d,{recursive:!0}),h__default.default.writeFileSync(o,s,"utf-8"),a.succeed(`Generated types for ${r.size} tables \u2192 ${m__default.default.cyan(n.output)}`),console.log(""),console.log(m__default.default.green("Generated:")),console.log(m__default.default.gray(` Tables: ${r.size}`)),console.log(m__default.default.gray(` Enums: ${c.size}`)),console.log(""),console.log(m__default.default.gray("Import in your code:")),console.log(m__default.default.cyan(` import type { Database, Row, Insert, Update } from "${n.output.replace(/\.ts$/,"")}";`));}catch(t){a.fail("Failed to generate types"),t instanceof Error&&(console.error(m__default.default.red(`
61
61
  Error: ${t.message}`)),t.message.includes("ECONNREFUSED")&&console.log(m__default.default.yellow(`
62
- Make sure your database is running and accessible.`))),process.exit(1);}}var y=[{name:"database",label:"Database",description:"CRUD queries, type-safe operations"},{name:"auth",label:"Authentication",description:"login, signup, OAuth, sessions"},{name:"realtime",label:"Realtime",description:"live subscriptions, presence"},{name:"storage",label:"Storage",description:"file uploads, signed URLs"},{name:"functions",label:"Functions",description:"serverless function calls"}],J={"nextjs-fullstack":{name:"Next.js Full-Stack",description:"Next.js app with server/client VAIF client, auth middleware, and React hooks",tag:"Next.js",defaultFeatures:["database","auth"],files:[{path:"package.json",content:`{
62
+ Make sure your database is running and accessible.`))),process.exit(1);}}var b=[{name:"database",label:"Database",description:"CRUD queries, type-safe operations"},{name:"auth",label:"Authentication",description:"login, signup, OAuth, sessions"},{name:"realtime",label:"Realtime",description:"live subscriptions, presence"},{name:"storage",label:"Storage",description:"file uploads, signed URLs"},{name:"functions",label:"Functions",description:"serverless function calls"}],J={"nextjs-fullstack":{name:"Next.js Full-Stack",description:"Next.js app with server/client VAIF client, auth middleware, and React hooks",tag:"Next.js",defaultFeatures:["database","auth"],files:[{path:"package.json",content:`{
63
63
  "name": "my-vaif-app",
64
64
  "private": true,
65
65
  "version": "0.1.0",
@@ -167,7 +167,7 @@ export function createVaifServer() {
167
167
  });
168
168
  }
169
169
  `},{path:".env.local.example",content:`# VAIF Configuration
170
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
170
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
171
171
 
172
172
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
173
173
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -204,7 +204,7 @@ A full-stack Next.js application powered by [VAIF Studio](https://vaif.studio),
204
204
  cp .env.local.example .env.local
205
205
  \\\`\\\`\\\`
206
206
 
207
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
207
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
208
208
 
209
209
  3. **Install and log in to the VAIF CLI**
210
210
 
@@ -654,7 +654,7 @@ interface ImportMeta {
654
654
  readonly env: ImportMetaEnv;
655
655
  }
656
656
  `},{path:".env.example",content:`# VAIF Configuration
657
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
657
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
658
658
 
659
659
  VITE_VAIF_PROJECT_ID=your-project-id
660
660
  VITE_VAIF_API_KEY=your-anon-key
@@ -687,7 +687,7 @@ A single-page React application built with [Vite](https://vite.dev/) and powered
687
687
  cp .env.example .env
688
688
  \\\`\\\`\\\`
689
689
 
690
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
690
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
691
691
 
692
692
  3. **Install and log in to the VAIF CLI**
693
693
 
@@ -1185,7 +1185,7 @@ An iOS/macOS application powered by [VAIF Studio](https://vaif.studio), using th
1185
1185
  <string>your-anon-key</string>
1186
1186
  \\\`\\\`\\\`
1187
1187
 
1188
- Get your credentials from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1188
+ Get your credentials from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1189
1189
 
1190
1190
  3. **Install and log in to the VAIF CLI** (for type generation)
1191
1191
 
@@ -1312,7 +1312,7 @@ export const vaif = createExpoClient({
1312
1312
  realtime: { enabled: true },
1313
1313
  });
1314
1314
  `},{path:".env.example",content:`# VAIF Configuration
1315
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1315
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1316
1316
 
1317
1317
  EXPO_PUBLIC_VAIF_PROJECT_ID=your-project-id
1318
1318
  EXPO_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -1346,7 +1346,7 @@ A React Native / Expo mobile application powered by [VAIF Studio](https://vaif.s
1346
1346
  cp .env.example .env
1347
1347
  \\\`\\\`\\\`
1348
1348
 
1349
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1349
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1350
1350
 
1351
1351
  3. **Install and log in to the VAIF CLI**
1352
1352
 
@@ -1736,7 +1736,7 @@ A Flutter application powered by [VAIF Studio](https://vaif.studio), with Dart c
1736
1736
  cp .env.example .env
1737
1737
  \\\`\\\`\\\`
1738
1738
 
1739
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
1739
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
1740
1740
 
1741
1741
  3. **Install and log in to the VAIF CLI** (for schema and type generation)
1742
1742
 
@@ -1994,7 +1994,7 @@ fastapi>=0.110.0
1994
1994
  uvicorn[standard]>=0.27.0
1995
1995
  python-dotenv>=1.0.0
1996
1996
  `},{path:".env.example",content:`# VAIF Configuration
1997
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
1997
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
1998
1998
 
1999
1999
  VAIF_PROJECT_ID=your-project-id
2000
2000
  VAIF_API_KEY=your-anon-key
@@ -2036,7 +2036,7 @@ A FastAPI backend application powered by [VAIF Studio](https://vaif.studio), wit
2036
2036
  cp .env.example .env
2037
2037
  \\\`\\\`\\\`
2038
2038
 
2039
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2039
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2040
2040
 
2041
2041
  4. **Install and log in to the VAIF CLI**
2042
2042
 
@@ -2354,7 +2354,7 @@ A Go backend API powered by [VAIF Studio](https://vaif.studio), with HTTP handle
2354
2354
  cp .env.example .env
2355
2355
  \\\`\\\`\\\`
2356
2356
 
2357
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2357
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2358
2358
 
2359
2359
  3. **Install and log in to the VAIF CLI**
2360
2360
 
@@ -2623,7 +2623,7 @@ export async function deleteTodo(id: string): Promise<void> {
2623
2623
  if (error) throw error;
2624
2624
  }
2625
2625
  `},{path:".env.example",content:`# VAIF Configuration
2626
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2626
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2627
2627
 
2628
2628
  VITE_VAIF_PROJECT_ID=your-project-id
2629
2629
  VITE_VAIF_API_KEY=your-anon-key
@@ -2651,7 +2651,7 @@ A simple React todo application for learning [VAIF Studio](https://vaif.studio)
2651
2651
  cp .env.example .env
2652
2652
  \\\`\\\`\\\`
2653
2653
 
2654
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2654
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2655
2655
 
2656
2656
  3. **Install and log in to the VAIF CLI**
2657
2657
 
@@ -2903,7 +2903,7 @@ export function useRealtimeMessages({
2903
2903
  return { messages, isLoading, error, refresh };
2904
2904
  }
2905
2905
  `},{path:".env.example",content:`# VAIF Configuration
2906
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
2906
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
2907
2907
 
2908
2908
  VITE_VAIF_PROJECT_ID=your-project-id
2909
2909
  VITE_VAIF_API_KEY=your-anon-key
@@ -2931,7 +2931,7 @@ A React chat application with live messaging powered by [VAIF Studio](https://va
2931
2931
  cp .env.example .env
2932
2932
  \\\`\\\`\\\`
2933
2933
 
2934
- Get your Project ID and API Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
2934
+ Get your Project ID and API Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
2935
2935
 
2936
2936
  3. **Install and log in to the VAIF CLI**
2937
2937
 
@@ -3212,7 +3212,7 @@ export async function requireTeamRole(
3212
3212
  return member as TeamMember;
3213
3213
  }
3214
3214
  `},{path:".env.example",content:`# VAIF Configuration
3215
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3215
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3216
3216
 
3217
3217
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3218
3218
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3241,7 +3241,7 @@ A full SaaS starter kit powered by [VAIF Studio](https://vaif.studio) with authe
3241
3241
  cp .env.example .env.local
3242
3242
  \\\`\\\`\\\`
3243
3243
 
3244
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3244
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3245
3245
 
3246
3246
  3. **Install and log in to the VAIF CLI**
3247
3247
 
@@ -3480,7 +3480,7 @@ function getContentType(fileName: string): string {
3480
3480
  return mimeTypes[ext ?? ""] ?? "application/octet-stream";
3481
3481
  }
3482
3482
  `},{path:".env.example",content:`# VAIF Configuration
3483
- # Get these values from https://vaif.studio/dashboard \u2192 Project Settings \u2192 API Keys
3483
+ # Get these values from https://vaif.studio/app/security/api-keys \u2192 Project Settings \u2192 API Keys
3484
3484
 
3485
3485
  NEXT_PUBLIC_VAIF_PROJECT_ID=your-project-id
3486
3486
  NEXT_PUBLIC_VAIF_API_KEY=your-anon-key
@@ -3509,7 +3509,7 @@ An API-first e-commerce setup powered by [VAIF Studio](https://vaif.studio) with
3509
3509
  cp .env.example .env.local
3510
3510
  \\\`\\\`\\\`
3511
3511
 
3512
- Get your Project ID, API Key, and Secret Key from <https://vaif.studio/dashboard> under **Project Settings > API Keys**.
3512
+ Get your Project ID, API Key, and Secret Key from <https://vaif.studio/app/security/api-keys> under **Project Settings > API Keys**.
3513
3513
 
3514
3514
  3. **Install and log in to the VAIF CLI**
3515
3515
 
@@ -3620,12 +3620,12 @@ export const posts = pgTable("posts", {
3620
3620
  const { name } = await req.json().catch(() => ({ name: "World" }));
3621
3621
  return Response.json({ message: \`Hello, \${name}!\` });
3622
3622
  }
3623
- `}]},dependencies:["@vaiftech/client","@vaiftech/auth"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create a 'product-images' storage bucket in your VAIF dashboard","Import storage helpers from '@/lib/storage' in your API routes","Use uploadProductImage() in your product creation flow","Run: npx vaif generate to generate TypeScript types"]}};async function X(n){if(!process.stdin.isTTY||!process.stdout.isTTY)return n;let a=new Set(n.map(e=>y.findIndex(i=>i.name===e)).filter(e=>e>=0)),t=0;return new Promise(e=>{let i=D__default.default.createInterface({input:process.stdin,output:process.stdout});D__default.default.emitKeypressEvents(process.stdin,i),process.stdin.setRawMode&&process.stdin.setRawMode(true);function r(){let u=y.length+2;process.stdout.write(`\x1B[${u}A`),c();}function c(){console.log(m__default.default.bold(`
3624
- ? Which VAIF features do you want to include?`)),y.forEach((u,l)=>{let o=a.has(l)?m__default.default.green("[x]"):"[ ]",s=l===t?m__default.default.cyan("> "):" ";console.log(`${s}${o} ${u.label} ${m__default.default.gray(`(${u.description})`)}`);}),console.log(m__default.default.gray(" (up/down to move, space to toggle, enter to confirm)"));}c(),process.stdin.on("keypress",(u,l)=>{if(l.name==="up"&&t>0)t--,r();else if(l.name==="down"&&t<y.length-1)t++,r();else if(l.name==="space")a.has(t)?a.delete(t):a.add(t),r();else if(l.name==="return"){process.stdin.setRawMode&&process.stdin.setRawMode(false),i.close();let o=[...a].sort().map(s=>y[s].name);e(o.length>0?o:n);}else l.name==="c"&&l.ctrl&&(process.stdin.setRawMode&&process.stdin.setRawMode(false),i.close(),process.exit(0));});})}async function j(n,a={}){let t=J[n];t||(console.log(m__default.default.red(`
3623
+ `}]},dependencies:["@vaiftech/client","@vaiftech/auth"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create a 'product-images' storage bucket in your VAIF dashboard","Import storage helpers from '@/lib/storage' in your API routes","Use uploadProductImage() in your product creation flow","Run: npx vaif generate to generate TypeScript types"]}};async function X(n){if(!process.stdin.isTTY||!process.stdout.isTTY)return n;let a=new Set(n.map(e=>b.findIndex(i=>i.name===e)).filter(e=>e>=0)),t=0;return new Promise(e=>{let i=D__default.default.createInterface({input:process.stdin,output:process.stdout});D__default.default.emitKeypressEvents(process.stdin,i),process.stdin.setRawMode&&process.stdin.setRawMode(true);function r(){let u=b.length+2;process.stdout.write(`\x1B[${u}A`),c();}function c(){console.log(m__default.default.bold(`
3624
+ ? Which VAIF features do you want to include?`)),b.forEach((u,l)=>{let s=a.has(l)?m__default.default.green("[x]"):"[ ]",o=l===t?m__default.default.cyan("> "):" ";console.log(`${o}${s} ${u.label} ${m__default.default.gray(`(${u.description})`)}`);}),console.log(m__default.default.gray(" (up/down to move, space to toggle, enter to confirm)"));}c(),process.stdin.on("keypress",(u,l)=>{if(l.name==="up"&&t>0)t--,r();else if(l.name==="down"&&t<b.length-1)t++,r();else if(l.name==="space")a.has(t)?a.delete(t):a.add(t),r();else if(l.name==="return"){process.stdin.setRawMode&&process.stdin.setRawMode(false),i.close();let s=[...a].sort().map(o=>b[o].name);e(s.length>0?s:n);}else l.name==="c"&&l.ctrl&&(process.stdin.setRawMode&&process.stdin.setRawMode(false),i.close(),process.exit(0));});})}async function j(n,a={}){let t=J[n];t||(console.log(m__default.default.red(`
3625
3625
  Unknown template: ${n}`)),console.log(m__default.default.yellow(`Run 'vaif templates' to see available templates.
3626
- `)),process.exit(1));let e;a.features&&a.features.length>0?e=a.features.filter(o=>y.some(s=>s.name===o)):t.featureFiles&&Object.keys(t.featureFiles).length>0?e=await X(t.defaultFeatures??["database","auth"]):e=t.defaultFeatures??[],console.log(""),console.log(m__default.default.bold(`Scaffolding ${m__default.default.cyan(t.name)} template...`)),e.length>0&&console.log(m__default.default.gray(` Features: ${e.join(", ")}`)),console.log("");let i=[...t.files];if(t.featureFiles)for(let o of e){let s=t.featureFiles[o];s&&i.push(...s);}let r=0,c=0;for(let o of i){let s=w__default.default.resolve(o.path),d=w__default.default.dirname(s);if(h__default.default.existsSync(d)||h__default.default.mkdirSync(d,{recursive:true}),o.path==="package.json"&&h__default.default.existsSync(s)&&!a.force)try{let p=JSON.parse(h__default.default.readFileSync(s,"utf-8")),g=JSON.parse(o.content),b=C=>{if(!C)return {};let N={};for(let[O,_]of Object.entries(C))!_.startsWith("workspace:")&&!_.startsWith("link:")&&!_.startsWith("file:")&&(N[O]=_);return N};p.dependencies={...b(p.dependencies),...g.dependencies||{}},p.devDependencies={...b(p.devDependencies),...g.devDependencies||{}},g.scripts&&(p.scripts={...p.scripts||{},...g.scripts}),h__default.default.writeFileSync(s,JSON.stringify(p,null,2)+`
3627
- `,"utf-8"),console.log(m__default.default.green(` merge ${o.path} (added dependencies)`)),r++;continue}catch{}if(h__default.default.existsSync(s)&&!a.force){console.log(m__default.default.yellow(` skip ${o.path} (already exists)`)),c++;continue}h__default.default.writeFileSync(s,o.content,"utf-8"),console.log(m__default.default.green(` create ${o.path}`)),r++;}console.log(""),r>0&&console.log(m__default.default.green(`Created ${r} file${r!==1?"s":""}.`)),c>0&&console.log(m__default.default.yellow(`Skipped ${c} file${c!==1?"s":""} (use --force to overwrite).`));let u={auth:{"@vaiftech/auth":"^1.0.0"},database:{},realtime:{},storage:{},functions:{}},l=w__default.default.resolve("package.json");if(h__default.default.existsSync(l)&&e.length>0)try{let o=JSON.parse(h__default.default.readFileSync(l,"utf-8")),s=!1;for(let d of e){let p=u[d];if(p)for(let[g,b]of Object.entries(p))o.dependencies?.[g]||(o.dependencies=o.dependencies||{},o.dependencies[g]=b,s=!0);}s&&h__default.default.writeFileSync(l,JSON.stringify(o,null,2)+`
3628
- `,"utf-8");}catch{}(t.dependencies?.length||t.devDependencies?.length)&&(console.log(""),console.log(m__default.default.bold("Install dependencies:")),t.dependencies?.length&&console.log(m__default.default.cyan(` npm install ${t.dependencies.join(" ")}`)),t.devDependencies?.length&&console.log(m__default.default.cyan(` npm install -D ${t.devDependencies.join(" ")}`))),console.log(""),console.log(m__default.default.bold.green("Project scaffolded successfully!")),console.log(""),console.log(m__default.default.bold(" Next steps:")),t.postInstructions.forEach(o=>{console.log(m__default.default.gray(` ${o}`));}),console.log(""),console.log(m__default.default.gray(" Get your project credentials at https://vaif.studio")),console.log("");}var Z={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function ee(n){let a=z__default.default("Initializing VAIF configuration...").start(),t=w__default.default.resolve("vaif.config.json");h__default.default.existsSync(t)&&!n.force&&(a.fail("vaif.config.json already exists"),console.log(m__default.default.yellow(`
3626
+ `)),process.exit(1));let e;a.features&&a.features.length>0?e=a.features.filter(s=>b.some(o=>o.name===s)):t.featureFiles&&Object.keys(t.featureFiles).length>0?e=await X(t.defaultFeatures??["database","auth"]):e=t.defaultFeatures??[],console.log(""),console.log(m__default.default.bold(`Scaffolding ${m__default.default.cyan(t.name)} template...`)),e.length>0&&console.log(m__default.default.gray(` Features: ${e.join(", ")}`)),console.log("");let i=[...t.files];if(t.featureFiles)for(let s of e){let o=t.featureFiles[s];o&&i.push(...o);}let r=0,c=0;for(let s of i){let o=w__default.default.resolve(s.path),d=w__default.default.dirname(o);if(h__default.default.existsSync(d)||h__default.default.mkdirSync(d,{recursive:true}),s.path==="package.json"&&h__default.default.existsSync(o)&&!a.force)try{let p=JSON.parse(h__default.default.readFileSync(o,"utf-8")),g=JSON.parse(s.content),y=C=>{if(!C)return {};let N={};for(let[k,_]of Object.entries(C))!_.startsWith("workspace:")&&!_.startsWith("link:")&&!_.startsWith("file:")&&(N[k]=_);return N};p.dependencies={...y(p.dependencies),...g.dependencies||{}},p.devDependencies={...y(p.devDependencies),...g.devDependencies||{}},g.scripts&&(p.scripts={...p.scripts||{},...g.scripts}),h__default.default.writeFileSync(o,JSON.stringify(p,null,2)+`
3627
+ `,"utf-8"),console.log(m__default.default.green(` merge ${s.path} (added dependencies)`)),r++;continue}catch{}if(h__default.default.existsSync(o)&&!a.force){console.log(m__default.default.yellow(` skip ${s.path} (already exists)`)),c++;continue}h__default.default.writeFileSync(o,s.content,"utf-8"),console.log(m__default.default.green(` create ${s.path}`)),r++;}console.log(""),r>0&&console.log(m__default.default.green(`Created ${r} file${r!==1?"s":""}.`)),c>0&&console.log(m__default.default.yellow(`Skipped ${c} file${c!==1?"s":""} (use --force to overwrite).`));let u={auth:{"@vaiftech/auth":"^1.0.0"},database:{},realtime:{},storage:{},functions:{}},l=w__default.default.resolve("package.json");if(h__default.default.existsSync(l)&&e.length>0)try{let s=JSON.parse(h__default.default.readFileSync(l,"utf-8")),o=!1;for(let d of e){let p=u[d];if(p)for(let[g,y]of Object.entries(p))s.dependencies?.[g]||(s.dependencies=s.dependencies||{},s.dependencies[g]=y,o=!0);}o&&h__default.default.writeFileSync(l,JSON.stringify(s,null,2)+`
3628
+ `,"utf-8");}catch{}(t.dependencies?.length||t.devDependencies?.length)&&(console.log(""),console.log(m__default.default.bold("Install dependencies:")),t.dependencies?.length&&console.log(m__default.default.cyan(` npm install ${t.dependencies.join(" ")}`)),t.devDependencies?.length&&console.log(m__default.default.cyan(` npm install -D ${t.devDependencies.join(" ")}`))),console.log(""),console.log(m__default.default.bold.green("Project scaffolded successfully!")),console.log(""),console.log(m__default.default.bold(" Next steps:")),t.postInstructions.forEach(s=>{console.log(m__default.default.gray(` ${s}`));}),console.log(""),console.log(m__default.default.gray(" Get your project credentials at https://vaif.studio/app/security/api-keys")),console.log("");}var Z={$schema:"https://vaif.studio/schemas/config.json",projectId:"",database:{url:"${DATABASE_URL}",schema:"public"},types:{output:"./src/types/database.ts"},api:{baseUrl:"https://api.vaif.studio"}};async function ee(n){let a=z__default.default("Initializing VAIF configuration...").start(),t=w__default.default.resolve("vaif.config.json");h__default.default.existsSync(t)&&!n.force&&(a.fail("vaif.config.json already exists"),console.log(m__default.default.yellow(`
3629
3629
  Use --force to overwrite existing configuration.`)),process.exit(1));try{if(h__default.default.writeFileSync(t,JSON.stringify(Z,null,2),"utf-8"),a.succeed("Created vaif.config.json"),n.template){let e=n.features?n.features.split(",").map(i=>i.trim()):void 0;await j(n.template,{force:n.force,features:e});}else {let e=w__default.default.resolve(".env.example");if(h__default.default.existsSync(e)||(h__default.default.writeFileSync(e,`# VAIF Configuration
3630
3630
  DATABASE_URL=postgresql://user:password@localhost:5432/database
3631
3631
  VAIF_API_KEY=your-api-key
@@ -3660,16 +3660,16 @@ Error: ${e.message}`)),process.exit(1);}}async function Le(n){let{connectionStri
3660
3660
  JOIN pg_namespace n ON n.oid = t.typnamespace
3661
3661
  WHERE n.nspname = $1
3662
3662
  ORDER BY t.typname, e.enumsortorder
3663
- `,[t]),u=new Map;for(let s of i.rows)u.set(s.table_name,[]);for(let s of r.rows){let d=u.get(s.table_name);d&&d.push(s);}let l=new Map;for(let s of c.rows){let d=l.get(s.enum_name)||[];d.push(s.enum_value),l.set(s.enum_name,d);}let o=ie(u,l);return q__default.default.format(o,{parser:"typescript",semi:!0,singleQuote:!1,trailingComma:"es5",printWidth:100})}finally{await e.end();}}var R={smallint:"number",integer:"number",bigint:"string",int2:"number",int4:"number",int8:"string",decimal:"string",numeric:"string",real:"number",float4:"number",float8:"number","double precision":"number",money:"string",boolean:"boolean",bool:"boolean",text:"string",varchar:"string",char:"string",character:"string","character varying":"string",name:"string",citext:"string",date:"string",time:"string",timetz:"string",timestamp:"string",timestamptz:"string","timestamp without time zone":"string","timestamp with time zone":"string",interval:"string",bytea:"Buffer",uuid:"string",json:"unknown",jsonb:"unknown",inet:"string",cidr:"string",macaddr:"string",point:"{ x: number; y: number }",ARRAY:"unknown[]"};function ne(n,a){let{data_type:t,udt_name:e,is_nullable:i}=n;if(a.has(e)){let u=a.get(e).map(l=>`"${l}"`).join(" | ");return i==="YES"?`(${u}) | null`:u}if(t==="ARRAY"){let c=e.replace(/^_/,"");if(a.has(c)){let o=a.get(c).map(s=>`"${s}"`).join(" | ");return i==="YES"?`(${o})[] | null`:`(${o})[]`}let u=R[c]||"unknown";return i==="YES"?`${u}[] | null`:`${u}[]`}let r=R[t]||R[e]||"unknown";return i==="YES"&&(r=`${r} | null`),r}function P(n){return n.split(/[_\-\s]+/).map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join("")}function ie(n,a){let t=["/**"," * Auto-generated TypeScript types from database schema"," * Generated by @vaiftech/cli",` * Generated at: ${new Date().toISOString()}`," * "," * DO NOT EDIT MANUALLY - changes will be overwritten"," */",""];if(a.size>0){t.push("// ============ ENUMS ============"),t.push("");for(let[i,r]of a){let c=P(i),u=r.map(l=>` | "${l}"`).join(`
3663
+ `,[t]),u=new Map;for(let o of i.rows)u.set(o.table_name,[]);for(let o of r.rows){let d=u.get(o.table_name);d&&d.push(o);}let l=new Map;for(let o of c.rows){let d=l.get(o.enum_name)||[];d.push(o.enum_value),l.set(o.enum_name,d);}let s=ie(u,l);return q__default.default.format(s,{parser:"typescript",semi:!0,singleQuote:!1,trailingComma:"es5",printWidth:100})}finally{await e.end();}}var R={smallint:"number",integer:"number",bigint:"string",int2:"number",int4:"number",int8:"string",decimal:"string",numeric:"string",real:"number",float4:"number",float8:"number","double precision":"number",money:"string",boolean:"boolean",bool:"boolean",text:"string",varchar:"string",char:"string",character:"string","character varying":"string",name:"string",citext:"string",date:"string",time:"string",timetz:"string",timestamp:"string",timestamptz:"string","timestamp without time zone":"string","timestamp with time zone":"string",interval:"string",bytea:"Buffer",uuid:"string",json:"unknown",jsonb:"unknown",inet:"string",cidr:"string",macaddr:"string",point:"{ x: number; y: number }",ARRAY:"unknown[]"};function ne(n,a){let{data_type:t,udt_name:e,is_nullable:i}=n;if(a.has(e)){let u=a.get(e).map(l=>`"${l}"`).join(" | ");return i==="YES"?`(${u}) | null`:u}if(t==="ARRAY"){let c=e.replace(/^_/,"");if(a.has(c)){let s=a.get(c).map(o=>`"${o}"`).join(" | ");return i==="YES"?`(${s})[] | null`:`(${s})[]`}let u=R[c]||"unknown";return i==="YES"?`${u}[] | null`:`${u}[]`}let r=R[t]||R[e]||"unknown";return i==="YES"&&(r=`${r} | null`),r}function P(n){return n.split(/[_\-\s]+/).map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join("")}function ie(n,a){let t=["/**"," * Auto-generated TypeScript types from database schema"," * Generated by @vaiftech/cli",` * Generated at: ${new Date().toISOString()}`," * "," * DO NOT EDIT MANUALLY - changes will be overwritten"," */",""];if(a.size>0){t.push("// ============ ENUMS ============"),t.push("");for(let[i,r]of a){let c=P(i),u=r.map(l=>` | "${l}"`).join(`
3664
3664
  `);t.push(`export type ${c} =
3665
- ${u};`),t.push("");}}t.push("// ============ TABLES ============"),t.push("");let e=[];for(let[i,r]of n){e.push(i);let c=P(i),u=[],l=[],o=[];for(let s of r){let d=ne(s,a),p=s.column_name,g=s.column_default!==null||s.is_identity==="YES",b=s.is_nullable==="YES";u.push(` ${p}: ${d};`),g||s.column_name==="id"?l.push(` ${p}?: ${d.replace(" | null","")} | null;`):b?l.push(` ${p}?: ${d};`):l.push(` ${p}: ${d.replace(" | null","")};`),o.push(` ${p}?: ${d.replace(" | null","")} | null;`);}t.push(`export interface ${c} {
3665
+ ${u};`),t.push("");}}t.push("// ============ TABLES ============"),t.push("");let e=[];for(let[i,r]of n){e.push(i);let c=P(i),u=[],l=[],s=[];for(let o of r){let d=ne(o,a),p=o.column_name,g=o.column_default!==null||o.is_identity==="YES",y=o.is_nullable==="YES";u.push(` ${p}: ${d};`),g||o.column_name==="id"?l.push(` ${p}?: ${d.replace(" | null","")} | null;`):y?l.push(` ${p}?: ${d};`):l.push(` ${p}: ${d.replace(" | null","")};`),s.push(` ${p}?: ${d.replace(" | null","")} | null;`);}t.push(`export interface ${c} {
3666
3666
  ${u.join(`
3667
3667
  `)}
3668
3668
  }`),t.push(""),t.push(`export interface ${c}Insert {
3669
3669
  ${l.join(`
3670
3670
  `)}
3671
3671
  }`),t.push(""),t.push(`export interface ${c}Update {
3672
- ${o.join(`
3672
+ ${s.join(`
3673
3673
  `)}
3674
3674
  }`),t.push("");}t.push("// ============ DATABASE SCHEMA ============"),t.push(""),t.push("export interface Database {");for(let i of e){let r=P(i);t.push(` ${i}: {`),t.push(` Row: ${r};`),t.push(` Insert: ${r}Insert;`),t.push(` Update: ${r}Update;`),t.push(" };");}return t.push("}"),t.push(""),t.push("export type TableName = keyof Database;"),t.push(""),t.push("// ============ HELPER TYPES ============"),t.push(""),t.push('export type Row<T extends TableName> = Database[T]["Row"];'),t.push('export type Insert<T extends TableName> = Database[T]["Insert"];'),t.push('export type Update<T extends TableName> = Database[T]["Update"];'),t.push(""),t.join(`
3675
3675
  `)}exports.generateTypes=W;exports.generateTypesFromConnection=Le;exports.initConfig=ee;exports.loadConfig=E;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export{b as generateTypes,d as initConfig,a as loadConfig}from'./chunk-JRB5YVG7.js';import T from'pg';import $ from'prettier';async function S(p){let{connectionString:a,schema:e="public"}=p,r=new T.Client({connectionString:a});await r.connect();try{let t=await r.query(`
1
+ export{b as generateTypes,d as initConfig,a as loadConfig}from'./chunk-F5OP4YDB.js';import T from'pg';import $ from'prettier';async function S(p){let{connectionString:a,schema:e="public"}=p,r=new T.Client({connectionString:a});await r.connect();try{let t=await r.query(`
2
2
  SELECT table_name, table_type
3
3
  FROM information_schema.tables
4
4
  WHERE table_schema = $1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaiftech/cli",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "VAIF CLI - Type generation and development tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",