@vaiftech/cli 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/{chunk-UQZPP43V.js → chunk-RBCJFCBE.js} +30 -28
- package/dist/cli.cjs +49 -47
- package/dist/cli.js +27 -27
- package/dist/index.cjs +22 -20
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d,c,b,a}from'./chunk-
|
|
2
|
+
import {d,c,b,a}from'./chunk-RBCJFCBE.js';import'dotenv/config';import {program}from'commander';import k from'fs';import w from'path';import Oe from'os';import {exec}from'child_process';import _ from'ora';import l from'chalk';import ee from'readline';var q=w.join(Oe.homedir(),".vaif"),O=w.join(q,"auth.json"),L=process.env.VAIF_API_URL||"https://api.vaif.studio";function Ne(){k.existsSync(q)||k.mkdirSync(q,{recursive:true});}function oe(e){Ne(),k.writeFileSync(O,JSON.stringify(e,null,2),"utf-8"),k.chmodSync(O,384);}function v(){if(!k.existsSync(O))return null;try{let e=k.readFileSync(O,"utf-8");return JSON.parse(e)}catch{return null}}function Le(e){let o=ee.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{o.question(e,i=>{o.close(),t(i);});})}function Te(e){return new Promise(o=>{let t=ee.createInterface({input:process.stdin,output:process.stdout});process.stdin;let r=process.stdout.write.bind(process.stdout),a=false;process.stdout.write=((...s)=>a?true:r(...s)),t.question(e,s=>{a=false,process.stdout.write=r,console.log(""),t.close(),o(s);}),a=true;})}function _e(e){let o=process.platform,t;o==="darwin"?t=`open "${e}"`:o==="win32"?t=`start "" "${e}"`:t=`xdg-open "${e}"`,exec(t,i=>{});}function Ue(e){return new Promise(o=>setTimeout(o,e))}async function ze(e){try{let o=await fetch(`${L}/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 Je(e){let o=_();o.start("Setting up authentication...");let t,i;try{let n=await fetch(`${L}/auth/cli/authorize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});n.ok||(o.fail("Failed to initiate authentication"),console.log(l.red(`
|
|
3
3
|
Could not connect to VAIF API. Please try again later.`)),process.exit(1));let c=await n.json();t=c.code,i=c.url;}catch{o.fail("Failed to connect to VAIF API"),console.log(l.red(`
|
|
4
|
-
Could not connect to VAIF API.`)),console.log(l.gray("Check your internet connection or try: vaif login --email")),process.exit(1);}o.stop(),console.log(l.cyan(" Opening browser for authentication...")),console.log(""),console.log(l.gray(" If the browser doesn't open, visit this URL:")),console.log(l.white(` ${i}`)),console.log(""),
|
|
5
|
-
The authentication session expired. Please try again.`)),process.exit(1));continue}let c=await n.json();if(c.ok&&c.accessToken){let f={token:c.accessToken,email:c.user?.email,projectId:e,expiresAt:new Date(Date.now()+c.expiresIn*1e3).toISOString()};oe(f),o.succeed("Logged in successfully"),console.log(""),c.user?.email&&console.log(l.green(` Authenticated as: ${c.user.email}`)),console.log(l.gray(` Config saved to: ${
|
|
6
|
-
Timed out waiting for browser authentication.`)),console.log(l.gray("Try again or use: vaif login --email")),process.exit(1);}async function
|
|
4
|
+
Could not connect to VAIF API.`)),console.log(l.gray("Check your internet connection or try: vaif login --email")),process.exit(1);}o.stop(),console.log(l.cyan(" Opening browser for authentication...")),console.log(""),console.log(l.gray(" If the browser doesn't open, visit this URL:")),console.log(l.white(` ${i}`)),console.log(""),_e(i),o.start("Waiting for browser authentication...");let r=12e4,a=2e3,s=Date.now();for(;Date.now()-s<r;){await Ue(a);try{let n=await fetch(`${L}/auth/cli/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:t})});if(!n.ok){let f=await n.json();(f.error==="ExpiredCode"||f.error==="InvalidCode")&&(o.fail("Authentication expired"),console.log(l.red(`
|
|
5
|
+
The authentication session expired. Please try again.`)),process.exit(1));continue}let c=await n.json();if(c.ok&&c.accessToken){let f={token:c.accessToken,email:c.user?.email,projectId:e,expiresAt:new Date(Date.now()+c.expiresIn*1e3).toISOString()};oe(f),o.succeed("Logged in successfully"),console.log(""),c.user?.email&&console.log(l.green(` Authenticated as: ${c.user.email}`)),console.log(l.gray(` Config saved to: ${O}`)),console.log("");return}}catch{}}o.fail("Authentication timed out"),console.log(l.red(`
|
|
6
|
+
Timed out waiting for browser authentication.`)),console.log(l.gray("Try again or use: vaif login --email")),process.exit(1);}async function Be(e){console.log(""),console.log(l.bold("VAIF CLI Login")),console.log(l.gray("Enter your VAIF account credentials")),console.log("");let o=await Le(l.cyan(" Email: "));(!o||o.trim()==="")&&(console.log(l.red(`
|
|
7
7
|
No email provided. Login cancelled.`)),process.exit(1));let t=await Te(l.cyan(" Password: "));(!t||t.trim()==="")&&(console.log(l.red(`
|
|
8
|
-
No password provided. Login cancelled.`)),process.exit(1));let i=
|
|
9
|
-
${a.message||"Invalid email or password."}`)),process.exit(1));let s={token:a.accessToken,email:a.user?.email,projectId:e,expiresAt:new Date(Date.now()+a.expiresIn*1e3).toISOString()};oe(s),i.succeed("Logged in successfully"),console.log(""),a.user?.email&&console.log(l.green(` Authenticated as: ${a.user.email}`)),console.log(l.gray(` Config saved to: ${
|
|
10
|
-
Could not connect to VAIF API. Please try again later.`)),process.exit(1);}}async function te(e){console.log(""),console.log(l.bold("Welcome to VAIF CLI")),console.log(l.gray("Authenticate to access your VAIF projects")),console.log(""),e.email?await
|
|
11
|
-
Your session has expired. Please login again.`)),process.exit(1)),o.succeed("Authenticated"),console.log(""),console.log(l.green(` Email: ${i||e.email||"Unknown"}`)),e.projectId&&console.log(l.green(` Project: ${e.projectId}`)),console.log("");}var qe=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Ge(e,o,t="public"){let i=await fetch(`${qe}/v1/projects/${o}/schema?schema=${t}`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok){let r=await i.text();throw new Error(`Failed to fetch schema: ${r}`)}return i.json()}async function ie(e){let o=
|
|
12
|
-
Error: ${s}`)),process.exit(1);}r||(o.fail("No configuration found"),console.log(l.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=e.projectId||r.projectId||t.projectId;a$1||(o.fail("No project ID specified"),console.log(l.yellow(`
|
|
8
|
+
No password provided. Login cancelled.`)),process.exit(1));let i=_("Authenticating...").start();try{let r=await fetch(`${L}/auth/cli/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o.trim(),password:t})}),a=await r.json();(!r.ok||!a.ok)&&(i.fail("Login failed"),console.log(l.red(`
|
|
9
|
+
${a.message||"Invalid email or password."}`)),process.exit(1));let s={token:a.accessToken,email:a.user?.email,projectId:e,expiresAt:new Date(Date.now()+a.expiresIn*1e3).toISOString()};oe(s),i.succeed("Logged in successfully"),console.log(""),a.user?.email&&console.log(l.green(` Authenticated as: ${a.user.email}`)),console.log(l.gray(` Config saved to: ${O}`)),console.log("");}catch{i.fail("Failed to connect to VAIF API"),console.log(l.red(`
|
|
10
|
+
Could not connect to VAIF API. Please try again later.`)),process.exit(1);}}async function te(e){console.log(""),console.log(l.bold("Welcome to VAIF CLI")),console.log(l.gray("Authenticate to access your VAIF projects")),console.log(""),e.email?await Be(e.projectId):await Je(e.projectId),console.log(l.gray("You can now use VAIF CLI commands like:")),console.log(l.gray(" vaif pull - Pull remote schema")),console.log(l.gray(" vaif push - Push schema changes")),console.log(l.gray(" vaif generate - Generate TypeScript types")),console.log("");}async function ne(){k.existsSync(O)?(k.unlinkSync(O),console.log(l.green("Logged out successfully"))):console.log(l.yellow("Not currently logged in"));}async function se(){let e=v();(!e||!e.token)&&(console.log(l.yellow("Not logged in")),console.log(l.gray("Run `vaif login` to authenticate")),process.exit(1));let o=_("Checking authentication...").start(),{valid:t,email:i}=await ze(e.token);t||(o.fail("Session expired"),console.log(l.yellow(`
|
|
11
|
+
Your session has expired. Please login again.`)),process.exit(1)),o.succeed("Authenticated"),console.log(""),console.log(l.green(` Email: ${i||e.email||"Unknown"}`)),e.projectId&&console.log(l.green(` Project: ${e.projectId}`)),console.log("");}var qe=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Ge(e,o,t="public"){let i=await fetch(`${qe}/v1/projects/${o}/schema?schema=${t}`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok){let r=await i.text();throw new Error(`Failed to fetch schema: ${r}`)}return i.json()}async function ie(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;o.start("Loading configuration...");try{r=await a(i);}catch(s){o.fail("Failed to load config"),console.log(l.red(`
|
|
12
|
+
Error: ${s}`)),process.exit(1);}r||(o.fail("No configuration found"),console.log(l.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=e.projectId||r.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(o.fail("No project ID specified"),console.log(l.yellow(`
|
|
13
13
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1)),o.text="Fetching remote schema...";try{let s=e.schema||r.database?.schema||"public",n=await Ge(t.token,a$1,s);o.succeed("Schema fetched successfully");let c=e.output||w.resolve("vaif.schema.json"),f={$schema:"https://vaif.studio/schemas/schema.json",projectId:a$1,schema:s,pulledAt:new Date().toISOString(),...n};k.writeFileSync(c,JSON.stringify(f,null,2),"utf-8"),console.log(""),console.log(l.green(`Schema saved to: ${c}`)),console.log(""),console.log(l.gray("Schema summary:")),console.log(l.gray(` Tables: ${(n.tables||[]).length}`)),console.log(l.gray(` Enums: ${(n.enums||[]).length}`)),console.log(l.gray(` Functions: ${(n.functions||[]).length}`)),console.log(""),console.log(l.gray("Next steps:")),console.log(l.gray(" - Run `vaif generate` to generate TypeScript types")),console.log(l.gray(" - Edit the schema and run `vaif push` to deploy changes")),console.log("");}catch(s){o.fail("Failed to fetch schema"),s instanceof Error&&console.log(l.red(`
|
|
14
|
-
Error: ${s.message}`)),process.exit(1);}}var ce=process.env.VAIF_API_URL||"https://api.vaif.studio";function Xe(e){let o=ee.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{o.question(e,i=>{o.close(),t(i);});})}async function Ze(e,o,t){let i=await fetch(`${ce}/v1/projects/${o}/schema/preview`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!i.ok){let r=await i.text();throw new Error(`Failed to preview changes: ${r}`)}return i.json()}async function eo(e,o,t){let i=await fetch(`${ce}/v1/projects/${o}/schema/apply`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!i.ok){let r=await i.text();throw new Error(`Failed to apply changes: ${r}`)}return i.json()}function oo(e){if(console.log(""),console.log(l.bold("Schema Changes:")),console.log(""),e.added.length===0&&e.modified.length===0&&e.removed.length===0){console.log(l.gray(" No changes detected. Schema is up to date."));return}if(e.added.length>0){console.log(l.green.bold(" + Added:"));for(let o of e.added)console.log(l.green(` + ${o.type}: ${o.name}`));console.log("");}if(e.modified.length>0){console.log(l.yellow.bold(" ~ Modified:"));for(let o of e.modified){console.log(l.yellow(` ~ ${o.type}: ${o.name}`));for(let t of o.changes)console.log(l.gray(` ${t}`));}console.log("");}if(e.removed.length>0){console.log(l.red.bold(" - Removed:"));for(let o of e.removed)console.log(l.red(` - ${o.type}: ${o.name}`));console.log("");}}async function ae(e){let o=
|
|
15
|
-
Error: ${c}`)),process.exit(1);}r||(o.fail("No configuration found"),console.log(l.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=e.projectId||r.projectId||t.projectId;a$1||(o.fail("No project ID specified"),console.log(l.yellow(`
|
|
14
|
+
Error: ${s.message}`)),process.exit(1);}}var ce=process.env.VAIF_API_URL||"https://api.vaif.studio";function Xe(e){let o=ee.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{o.question(e,i=>{o.close(),t(i);});})}async function Ze(e,o,t){let i=await fetch(`${ce}/v1/projects/${o}/schema/preview`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!i.ok){let r=await i.text();throw new Error(`Failed to preview changes: ${r}`)}return i.json()}async function eo(e,o,t){let i=await fetch(`${ce}/v1/projects/${o}/schema/apply`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!i.ok){let r=await i.text();throw new Error(`Failed to apply changes: ${r}`)}return i.json()}function oo(e){if(console.log(""),console.log(l.bold("Schema Changes:")),console.log(""),e.added.length===0&&e.modified.length===0&&e.removed.length===0){console.log(l.gray(" No changes detected. Schema is up to date."));return}if(e.added.length>0){console.log(l.green.bold(" + Added:"));for(let o of e.added)console.log(l.green(` + ${o.type}: ${o.name}`));console.log("");}if(e.modified.length>0){console.log(l.yellow.bold(" ~ Modified:"));for(let o of e.modified){console.log(l.yellow(` ~ ${o.type}: ${o.name}`));for(let t of o.changes)console.log(l.gray(` ${t}`));}console.log("");}if(e.removed.length>0){console.log(l.red.bold(" - Removed:"));for(let o of e.removed)console.log(l.red(` - ${o.type}: ${o.name}`));console.log("");}}async function ae(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;o.start("Loading configuration...");try{r=await a(i);}catch(c){o.fail("Failed to load config"),console.log(l.red(`
|
|
15
|
+
Error: ${c}`)),process.exit(1);}r||(o.fail("No configuration found"),console.log(l.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=e.projectId||r.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(o.fail("No project ID specified"),console.log(l.yellow(`
|
|
16
16
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1));let s=e.schema||w.resolve("vaif.schema.json");k.existsSync(s)||(o.fail("No local schema found"),console.log(l.yellow(`
|
|
17
17
|
Expected schema file at: ${s}`)),console.log(l.gray("Run `vaif pull` first to fetch the current schema.")),process.exit(1));let n;try{let c=k.readFileSync(s,"utf-8");n=JSON.parse(c);}catch(c){o.fail("Failed to parse schema file"),c instanceof Error&&console.log(l.red(`
|
|
18
18
|
Error: ${c.message}`)),process.exit(1);}o.text="Calculating schema changes...";try{let{diff:c,sql:f}=await Ze(t.token,a$1,n);if(o.stop(),oo(c),c.added.length===0&&c.modified.length===0&&c.removed.length===0){console.log("");return}if(f.length>0){console.log(l.bold("SQL Migrations:")),console.log("");for(let d of f)console.log(l.gray(` ${d}`));console.log("");}if(e.dryRun){console.log(l.yellow("Dry run mode - no changes applied.")),console.log(l.gray("Remove --dry-run to apply these changes."));return}if(!e.force){c.removed.length>0&&(console.log(l.red.bold("\u26A0\uFE0F Warning: This will remove tables/columns from your database.")),console.log(l.red(" This action cannot be undone!")),console.log(""));let g=await Xe(l.cyan("Apply these changes? [y/N] "));if(g.toLowerCase()!=="y"&&g.toLowerCase()!=="yes"){console.log(l.yellow(`
|
|
19
19
|
Cancelled. No changes applied.`));return}}o.start("Applying schema changes...");let p=await eo(t.token,a$1,n);if(p.success){if(o.succeed("Schema changes applied successfully"),console.log(""),p.migrations.length>0){console.log(l.gray("Migrations applied:"));for(let d of p.migrations)console.log(l.gray(` - ${d}`));console.log("");}console.log(l.green("Your database schema is now up to date.")),console.log(l.gray("Run `vaif generate` to update your TypeScript types.")),console.log("");}else o.fail("Failed to apply some changes");}catch(c){o.fail("Failed to push schema changes"),c instanceof Error&&console.log(l.red(`
|
|
20
|
-
Error: ${c.message}`)),process.exit(1);}}var de=process.env.VAIF_API_URL||"https://api.vaif.studio";async function to(e,o,t){let i=await fetch(`${de}/v1/projects/${o}/functions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({name:t.name,runtime:t.runtime,entrypoint:t.entrypoint,code:t.code,envId:t.envId})});if(!i.ok){let r=await i.text();throw new Error(`Failed to deploy function: ${r}`)}return i.json()}async function no(e,o,t){let i=new URL(`${de}/v1/projects/${o}/functions`);t&&i.searchParams.set("envId",t);let r=await fetch(i.toString(),{headers:{Authorization:`Bearer ${e}`}});if(!r.ok){let a=await r.text();throw new Error(`Failed to list functions: ${a}`)}return r.json()}function le(e){switch(w.extname(e).toLowerCase()){case ".ts":return "typescript";case ".js":case ".mjs":return "nodejs";case ".py":return "python";case ".go":return "go";case ".rs":return "rust";default:return "nodejs"}}function ge(e){let o=[],t=[".ts",".js",".mjs",".py",".go",".rs"];function i(r){if(!k.existsSync(r))return;let a=k.readdirSync(r,{withFileTypes:true});for(let s of a){let n=w.join(r,s.name);if(s.isDirectory())s.name!=="node_modules"&&!s.name.startsWith(".")&&i(n);else if(s.isFile()){let c=w.extname(s.name).toLowerCase();t.includes(c)&&(s.name==="index.ts"||s.name==="index.js"||s.name.includes("function")||s.name.includes("handler"))&&o.push(n);}}}return i(e),o}async function pe(e){let o=
|
|
20
|
+
Error: ${c.message}`)),process.exit(1);}}var de=process.env.VAIF_API_URL||"https://api.vaif.studio";async function to(e,o,t){let i=await fetch(`${de}/v1/projects/${o}/functions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({name:t.name,runtime:t.runtime,entrypoint:t.entrypoint,code:t.code,envId:t.envId})});if(!i.ok){let r=await i.text();throw new Error(`Failed to deploy function: ${r}`)}return i.json()}async function no(e,o,t){let i=new URL(`${de}/v1/projects/${o}/functions`);t&&i.searchParams.set("envId",t);let r=await fetch(i.toString(),{headers:{Authorization:`Bearer ${e}`}});if(!r.ok){let a=await r.text();throw new Error(`Failed to list functions: ${a}`)}return r.json()}function le(e){switch(w.extname(e).toLowerCase()){case ".ts":return "typescript";case ".js":case ".mjs":return "nodejs";case ".py":return "python";case ".go":return "go";case ".rs":return "rust";default:return "nodejs"}}function ge(e){let o=[],t=[".ts",".js",".mjs",".py",".go",".rs"];function i(r){if(!k.existsSync(r))return;let a=k.readdirSync(r,{withFileTypes:true});for(let s of a){let n=w.join(r,s.name);if(s.isDirectory())s.name!=="node_modules"&&!s.name.startsWith(".")&&i(n);else if(s.isFile()){let c=w.extname(s.name).toLowerCase();t.includes(c)&&(s.name==="index.ts"||s.name==="index.js"||s.name.includes("function")||s.name.includes("handler"))&&o.push(n);}}}return i(e),o}async function pe(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(l.bold("VAIF Functions Deploy")),console.log(""),o.start("Scanning for function files...");let s=w.resolve("functions"),n=w.resolve("src/functions"),c=[];if(e.entrypoint){let g=w.resolve(e.entrypoint);k.existsSync(g)||(o.fail(`File not found: ${e.entrypoint}`),process.exit(1)),c=[g];}else c=[...ge(s),...ge(n)];c.length===0&&(o.fail("No function files found"),console.log(l.yellow(`
|
|
21
21
|
Place your functions in:`)),console.log(l.gray(" - ./functions/")),console.log(l.gray(" - ./src/functions/")),console.log(l.gray(`
|
|
22
22
|
Or specify an entrypoint with --entrypoint`)),process.exit(1)),o.succeed(`Found ${c.length} function(s)`),e.name&&(c=c.filter(g=>w.basename(g,w.extname(g)).includes(e.name)),c.length===0&&(console.log(l.yellow(`
|
|
23
|
-
No functions matching "${e.name}" found`)),process.exit(1))),console.log(""),console.log(l.gray("Functions to deploy:"));for(let g of c){let y=w.basename(w.dirname(g))||w.basename(g,w.extname(g)),
|
|
23
|
+
No functions matching "${e.name}" found`)),process.exit(1))),console.log(""),console.log(l.gray("Functions to deploy:"));for(let g of c){let y=w.basename(w.dirname(g))||w.basename(g,w.extname(g)),A=e.runtime||le(g);console.log(l.gray(` - ${y} (${A})`));}if(console.log(""),e.dryRun){console.log(l.yellow("Dry run mode - no functions deployed."));return}let f=[];for(let g of c){let y=w.basename(w.dirname(g))||w.basename(g,w.extname(g)),A=e.runtime||le(g);o.start(`Deploying ${y}...`);try{let C=k.readFileSync(g,"utf-8"),N=await to(t.token,a$1,{name:y,runtime:A,entrypoint:w.basename(g),code:C,envId:e.envId});o.succeed(`Deployed ${y} (v${N.version})`),f.push({name:y,success:!0,version:N.version});}catch(C){let N=C instanceof Error?C.message:"Unknown error";o.fail(`Failed to deploy ${y}`),f.push({name:y,success:false,error:N});}}console.log("");let p=f.filter(g=>g.success).length;if(f.filter(g=>!g.success).length===0)console.log(l.green(`\u2713 Successfully deployed ${p} function(s)`));else {console.log(l.yellow(`Deployed ${p}/${f.length} function(s)`)),console.log(""),console.log(l.red("Failed deployments:"));for(let g of f.filter(y=>!y.success))console.log(l.red(` - ${g.name}: ${g.error}`));}console.log("");}async function ue(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),process.exit(1)),o.start("Fetching functions...");try{let s=await no(t.token,a$1,e.envId);if(o.stop(),s.length===0){console.log(l.yellow(`
|
|
24
24
|
No functions found`)),console.log(l.gray("Deploy your first function with: vaif functions deploy"));return}console.log(""),console.log(l.bold(`Functions (${s.length}):`)),console.log(""),console.log(l.gray(" "+"NAME".padEnd(25)+"RUNTIME".padEnd(15)+"VERSION".padEnd(10)+"STATUS".padEnd(12)+"LAST DEPLOYED")),console.log(l.gray(" "+"-".repeat(80)));for(let n of s){let c=n.status==="active"?l.green:n.status==="deploying"?l.yellow:l.red;console.log(" "+n.name.padEnd(25)+n.runtime.padEnd(15)+`v${n.version}`.padEnd(10)+c(n.status.padEnd(12))+(n.lastDeployed?new Date(n.lastDeployed).toLocaleDateString():"-"));}console.log("");}catch(s){o.fail("Failed to fetch functions"),s instanceof Error&&console.log(l.red(`
|
|
25
|
-
Error: ${s.message}`)),process.exit(1);}}var
|
|
25
|
+
Error: ${s.message}`)),process.exit(1);}}var U=process.env.VAIF_API_URL||"https://api.vaif.studio";async function so(e,o,t,i,r){let a=await fetch(`${U}/v1/projects/${o}/db/seed`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({table:t,records:i,truncate:r?.truncate??false})});if(!a.ok){let s=await a.text();throw new Error(`Failed to seed ${t}: ${s}`)}return a.json()}async function io(e,o){let t=await fetch(`${U}/v1/projects/${o}/db/reset`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!t.ok){let i=await t.text();throw new Error(`Failed to reset database: ${i}`)}return t.json()}function Y(e){let o=[];if(!k.existsSync(e))return o;let t=k.readdirSync(e,{withFileTypes:true});for(let i of t)if(i.isFile()){let r=w.extname(i.name).toLowerCase();(r===".json"||r===".ts"||r===".js")&&o.push(w.join(e,i.name));}return o.sort()}async function me(e){let o=w.extname(e).toLowerCase();if(o===".json"){let t=k.readFileSync(e,"utf-8"),i=JSON.parse(t);return Array.isArray(i)?[{table:w.basename(e,o),data:i}]:i.table&&i.data?[i]:Object.entries(i).map(([r,a])=>({table:r,data:a}))}else if(o===".ts"||o===".js"){let t=await import(e),i=t.default||t;return typeof i=="function"?i():i}throw new Error(`Unsupported file format: ${o}`)}async function he(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(l.bold("VAIF Database Seed")),console.log("");let s=[];if(e.file){let p=w.resolve(e.file);k.existsSync(p)||(console.log(l.red(`File not found: ${e.file}`)),process.exit(1)),s=[p];}else {let p=w.resolve("seeds"),d=w.resolve("prisma/seed"),g=w.resolve("db/seeds");s=[...Y(p),...Y(d),...Y(g)];}s.length===0&&(console.log(l.yellow("No seed files found")),console.log(l.gray(`
|
|
26
26
|
Place your seed files in one of these directories:`)),console.log(l.gray(" - ./seeds/")),console.log(l.gray(" - ./prisma/seed/")),console.log(l.gray(" - ./db/seeds/")),console.log(l.gray(`
|
|
27
27
|
Or specify a file with --file`)),console.log(l.gray(`
|
|
28
|
-
Example seed file (seeds/users.json):`)),console.log(l.gray(" [")),console.log(l.gray(' { "name": "John Doe", "email": "john@example.com" },')),console.log(l.gray(' { "name": "Jane Doe", "email": "jane@example.com" }')),console.log(l.gray(" ]")),process.exit(1)),console.log(l.gray("Seed files found:"));for(let p of s)console.log(l.gray(` - ${w.relative(process.cwd(),p)}`));if(console.log(""),e.truncate&&(console.log(l.yellow("\u26A0\uFE0F Tables will be truncated before seeding")),console.log("")),e.dryRun){console.log(l.yellow("Dry run mode - no data will be inserted.")),console.log("");for(let p of s){o.start(`Loading ${w.basename(p)}...`);try{let d=await me(p);o.stop();for(let g of d)e.table&&g.table!==e.table||(console.log(l.cyan(`Table: ${g.table}`)),console.log(l.gray(` Records: ${g.data.length}`)),g.data.length>0&&console.log(l.gray(` Sample: ${JSON.stringify(g.data[0],null,2).slice(0,100)}...`)),console.log(""));}catch(d){o.fail(`Failed to load ${w.basename(p)}`),d instanceof Error&&console.log(l.red(` Error: ${d.message}`));}}return}let n=[];for(let p of s){o.start(`Processing ${w.basename(p)}...`);try{let d=await me(p);o.stop();for(let g of d)if(!(e.table&&g.table!==e.table)){if(g.data.length===0){console.log(l.gray(` Skipping ${g.table} (no records)`));continue}o.start(`Seeding ${g.table} (${g.data.length} records)...`);try{let y=await so(t.token,a$1,g.table,g.data,{truncate:e.truncate});o.succeed(`Seeded ${g.table}: ${y.inserted} records`),n.push({table:g.table,inserted:y.inserted});}catch(y){let
|
|
28
|
+
Example seed file (seeds/users.json):`)),console.log(l.gray(" [")),console.log(l.gray(' { "name": "John Doe", "email": "john@example.com" },')),console.log(l.gray(' { "name": "Jane Doe", "email": "jane@example.com" }')),console.log(l.gray(" ]")),process.exit(1)),console.log(l.gray("Seed files found:"));for(let p of s)console.log(l.gray(` - ${w.relative(process.cwd(),p)}`));if(console.log(""),e.truncate&&(console.log(l.yellow("\u26A0\uFE0F Tables will be truncated before seeding")),console.log("")),e.dryRun){console.log(l.yellow("Dry run mode - no data will be inserted.")),console.log("");for(let p of s){o.start(`Loading ${w.basename(p)}...`);try{let d=await me(p);o.stop();for(let g of d)e.table&&g.table!==e.table||(console.log(l.cyan(`Table: ${g.table}`)),console.log(l.gray(` Records: ${g.data.length}`)),g.data.length>0&&console.log(l.gray(` Sample: ${JSON.stringify(g.data[0],null,2).slice(0,100)}...`)),console.log(""));}catch(d){o.fail(`Failed to load ${w.basename(p)}`),d instanceof Error&&console.log(l.red(` Error: ${d.message}`));}}return}let n=[];for(let p of s){o.start(`Processing ${w.basename(p)}...`);try{let d=await me(p);o.stop();for(let g of d)if(!(e.table&&g.table!==e.table)){if(g.data.length===0){console.log(l.gray(` Skipping ${g.table} (no records)`));continue}o.start(`Seeding ${g.table} (${g.data.length} records)...`);try{let y=await so(t.token,a$1,g.table,g.data,{truncate:e.truncate});o.succeed(`Seeded ${g.table}: ${y.inserted} records`),n.push({table:g.table,inserted:y.inserted});}catch(y){let A=y instanceof Error?y.message:"Unknown error";o.fail(`Failed to seed ${g.table}`),n.push({table:g.table,inserted:0,error:A});}}}catch(d){o.fail(`Failed to load ${w.basename(p)}`),d instanceof Error&&console.log(l.red(` Error: ${d.message}`));}}console.log("");let c=n.reduce((p,d)=>p+d.inserted,0),f=n.filter(p=>p.error).length;if(f===0)console.log(l.green(`\u2713 Successfully seeded ${c} records across ${n.length} table(s)`));else {console.log(l.yellow(`Seeded ${c} records with ${f} error(s)`)),console.log(""),console.log(l.red("Errors:"));for(let p of n.filter(d=>d.error))console.log(l.red(` - ${p.table}: ${p.error}`));}console.log("");}async function ye(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=w.resolve(e.dir||"./drizzle");if(console.log(""),console.log(l.bold("VAIF Database Push")),console.log(""),!k.existsSync(s)){let d=w.resolve("./migrations");k.existsSync(d)?console.log(l.gray(`Using migrations from: ${d}`)):(console.log(l.red(`Migrations directory not found: ${s}`)),console.log(l.gray(`
|
|
29
29
|
Expected one of:`)),console.log(l.gray(" - ./drizzle/")),console.log(l.gray(" - ./migrations/")),console.log(l.gray(`
|
|
30
|
-
Or specify with: vaif db push --dir <path>`)),process.exit(1));}let n=[],c=k.readdirSync(s,{withFileTypes:true});for(let d of c)if(d.isFile()&&d.name.endsWith(".sql"))n.push(w.join(s,d.name));else if(d.isDirectory()){let g=k.readdirSync(w.join(s,d.name),{withFileTypes:true});for(let y of g)y.isFile()&&y.name.endsWith(".sql")&&n.push(w.join(s,d.name,y.name));}n.sort(),n.length===0&&(console.log(l.yellow("No SQL migration files found")),process.exit(1)),console.log(l.gray(`Found ${n.length} migration(s):`));for(let d of n)console.log(l.gray(` - ${w.relative(process.cwd(),d)}`));if(console.log(""),e.dryRun){console.log(l.yellow("Dry run mode - no migrations will be applied.")),console.log("");for(let d of n){let g=k.readFileSync(d,"utf-8");console.log(l.cyan(`--- ${w.basename(d)} ---`)),console.log(l.gray(g.slice(0,500))),g.length>500&&console.log(l.gray("...")),console.log("");}return}let f=0,p=0;for(let d of n){let g=k.readFileSync(d,"utf-8"),y=w.relative(process.cwd(),d);o.start(`Applying ${y}...`);try{let
|
|
31
|
-
Error: ${n.message}`)),process.exit(1);}}async function
|
|
32
|
-
Error: ${s.message}`)),process.exit(1);}}var Ie=process.env.VAIF_API_URL||"https://api.vaif.studio";function $e(e,o,t){return e.projectId||o?.projectId||t.projectId||null}async function be(e){let o=
|
|
33
|
-
Error: ${n.message}`)),process.exit(1);}}async function
|
|
34
|
-
Generate one with: vaif keys generate`));return}let f=Math.max(8,...c.map(d=>(d.name||"").length)),p=` ${"Name".padEnd(f)} ${"Key".padEnd(24)} Created`;console.log(l.gray(p)),console.log(l.gray(" "+"-".repeat(p.length-2)));for(let d of c){let g=(d.name||"unnamed").padEnd(f),y=d.maskedKey||d.prefix||`${(d.key||"").slice(0,12)}...`,
|
|
35
|
-
Error: ${s.message}`)),process.exit(1);}}var
|
|
36
|
-
Error: ${c.message}`)),process.exit(1);}}async function Pe(e){let o=
|
|
30
|
+
Or specify with: vaif db push --dir <path>`)),process.exit(1));}let n=[],c=k.readdirSync(s,{withFileTypes:true});for(let d of c)if(d.isFile()&&d.name.endsWith(".sql"))n.push(w.join(s,d.name));else if(d.isDirectory()){let g=k.readdirSync(w.join(s,d.name),{withFileTypes:true});for(let y of g)y.isFile()&&y.name.endsWith(".sql")&&n.push(w.join(s,d.name,y.name));}n.sort(),n.length===0&&(console.log(l.yellow("No SQL migration files found")),process.exit(1)),console.log(l.gray(`Found ${n.length} migration(s):`));for(let d of n)console.log(l.gray(` - ${w.relative(process.cwd(),d)}`));if(console.log(""),e.dryRun){console.log(l.yellow("Dry run mode - no migrations will be applied.")),console.log("");for(let d of n){let g=k.readFileSync(d,"utf-8");console.log(l.cyan(`--- ${w.basename(d)} ---`)),console.log(l.gray(g.slice(0,500))),g.length>500&&console.log(l.gray("...")),console.log("");}return}let f=0,p=0;for(let d of n){let g=k.readFileSync(d,"utf-8"),y=w.relative(process.cwd(),d);o.start(`Applying ${y}...`);try{let A=await fetch(`${U}/v1/projects/${a$1}/schema/execute`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({sql:g})});if(!A.ok){let C=await A.text();throw new Error(C)}o.succeed(`Applied ${y}`),f++;}catch(A){let C=A instanceof Error?A.message:"Unknown error";o.fail(`Failed ${y}: ${C}`),p++;}}console.log(""),console.log(p===0?l.green(`Successfully applied ${f} migration(s)`):l.yellow(`Applied ${f}, failed ${p} migration(s)`)),console.log("");}async function we(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=w.resolve(e.output||"vaif.schema.json");console.log(""),console.log(l.bold("VAIF Database Pull")),console.log(""),o.start("Pulling schema from remote...");try{let n=await fetch(`${U}/v1/projects/${a$1}/schema`,{headers:{Authorization:`Bearer ${t.token}`}});if(!n.ok){let p=await n.text();throw new Error(`Failed to pull schema: ${p}`)}let c=await n.json();k.writeFileSync(s,JSON.stringify(c,null,2),"utf-8"),o.succeed(`Schema written to ${w.relative(process.cwd(),s)}`);let f=c.tables?.length??Object.keys(c).length;console.log(l.gray(` ${f} table(s) pulled`)),console.log("");}catch(n){o.fail("Failed to pull schema"),n instanceof Error&&console.log(l.red(`
|
|
31
|
+
Error: ${n.message}`)),process.exit(1);}}async function ve(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),process.exit(1)),console.log(""),console.log(l.red.bold("\u26A0\uFE0F DATABASE RESET")),console.log(""),console.log(l.red("This will:")),console.log(l.red(" - Drop all tables")),console.log(l.red(" - Delete all data")),console.log(l.red(" - Reset migrations")),console.log(""),console.log(l.red.bold("This action cannot be undone!")),console.log(""),e.force||(console.log(l.yellow("Use --force to confirm this action.")),process.exit(1)),o.start("Resetting database...");try{await io(t.token,a$1),o.succeed("Database reset complete"),console.log(""),console.log(l.gray("Your database is now empty.")),console.log(l.gray("Run `vaif push` to apply your schema, then `vaif db seed` to seed data.")),console.log("");}catch(s){o.fail("Failed to reset database"),s instanceof Error&&console.log(l.red(`
|
|
32
|
+
Error: ${s.message}`)),process.exit(1);}}var Ie=process.env.VAIF_API_URL||"https://api.vaif.studio";function $e(e,o,t){return e.projectId||o?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}async function be(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=$e(e,r,t);a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=e.name||`cli-key-${Date.now()}`;console.log(""),console.log(l.bold("VAIF Generate API Key")),console.log(""),o.start("Generating API key...");try{let n=await fetch(`${Ie}/v1/projects/${a$1}/api-keys`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:s})});if(!n.ok){let f=await n.text();throw new Error(`Failed to generate key: ${f}`)}let c=await n.json();o.succeed("API key generated"),console.log(""),console.log(l.green(` Name: ${c.name}`)),console.log(l.green(` Key: ${c.key}`)),console.log(""),console.log(l.yellow.bold(" Save this key now - it will not be shown again!")),console.log("");}catch(n){o.fail("Failed to generate API key"),n instanceof Error&&console.log(l.red(`
|
|
33
|
+
Error: ${n.message}`)),process.exit(1);}}async function Ae(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=$e(e,r,t);a$1||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(l.bold("VAIF API Keys")),console.log(""),o.start("Fetching API keys...");try{let s=await fetch(`${Ie}/v1/projects/${a$1}/api-keys`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let d=await s.text();throw new Error(`Failed to list keys: ${d}`)}let n=await s.json(),c=n.keys||n;if(o.stop(),!Array.isArray(c)||c.length===0){console.log(l.yellow("No API keys found")),console.log(l.gray(`
|
|
34
|
+
Generate one with: vaif keys generate`));return}let f=Math.max(8,...c.map(d=>(d.name||"").length)),p=` ${"Name".padEnd(f)} ${"Key".padEnd(24)} Created`;console.log(l.gray(p)),console.log(l.gray(" "+"-".repeat(p.length-2)));for(let d of c){let g=(d.name||"unnamed").padEnd(f),y=d.maskedKey||d.prefix||`${(d.key||"").slice(0,12)}...`,A=d.createdAt?new Date(d.createdAt).toLocaleDateString():"N/A";console.log(` ${g} ${y.padEnd(24)} ${A}`);}console.log(""),console.log(l.gray(` ${c.length} key(s) total`)),console.log("");}catch(s){o.fail("Failed to list API keys"),s instanceof Error&&console.log(l.red(`
|
|
35
|
+
Error: ${s.message}`)),process.exit(1);}}var V=process.env.VAIF_API_URL||"https://api.vaif.studio";function co(e,o,t){return e.projectId||o?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}function J(){let e=v();return (!e||!e.token)&&(console.log(l.red("Not logged in")),console.log(l.gray("Run `vaif login` first to authenticate")),process.exit(1)),e}async function B(e){try{return await a(e||"vaif.config.json")}catch{return null}}function K(e,o,t){let i=co(e,o,t);return i||(console.log(l.red("No project ID specified")),console.log(l.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),i}async function Se(e,o,t){let i=_(),r=J(),a=await B(t.config),s=K(t,a,r),n=o;if(t.fromFile)try{n=k.readFileSync(t.fromFile,"utf-8");}catch(c){console.log(l.red(`Failed to read file: ${t.fromFile}`)),c instanceof Error&&console.log(l.gray(c.message)),process.exit(1);}n||(console.log(l.red("No value provided")),console.log(l.gray("Provide a value as argument or use --from-file <path>")),process.exit(1)),console.log(""),console.log(l.bold("VAIF Set Secret")),console.log(""),i.start("Checking for existing secret...");try{let c=new URL(`${V}/functions/secrets/project/${s}`);t.envId&&c.searchParams.set("envId",t.envId);let f=await fetch(c.toString(),{headers:{Authorization:`Bearer ${r.token}`}});if(!f.ok)throw new Error(`Failed to check existing secrets: ${await f.text()}`);let d=(await f.json()).find(g=>g.key===e);if(d){i.text=`Updating secret "${e}"...`;let g=await fetch(`${V}/functions/secrets/${d.id}`,{method:"PUT",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!g.ok)throw new Error(`Failed to update secret: ${await g.text()}`);i.succeed(`Updated secret "${e}"`);}else {i.text=`Creating secret "${e}"...`;let g=await fetch(`${V}/functions/secrets`,{method:"POST",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:s,envId:t.envId,key:e,value:n})});if(!g.ok)throw new Error(`Failed to create secret: ${await g.text()}`);i.succeed(`Created secret "${e}"`);}console.log("");}catch(c){i.fail("Failed to set secret"),c instanceof Error&&console.log(l.red(`
|
|
36
|
+
Error: ${c.message}`)),process.exit(1);}}async function Pe(e){let o=_(),t=J(),i=await B(e.config),r=K(e,i,t);console.log(""),console.log(l.bold("VAIF Secrets")),console.log(""),o.start("Fetching secrets...");try{let a=new URL(`${V}/functions/secrets/project/${r}`);e.envId&&a.searchParams.set("envId",e.envId);let s=await fetch(a.toString(),{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok)throw new Error(`Failed to list secrets: ${await s.text()}`);let n=await s.json();if(o.stop(),n.length===0){console.log(l.yellow("No secrets found")),console.log(l.gray(`
|
|
37
37
|
Create one with: vaif secrets set <name> <value>`));return}let c=Math.max(8,...n.map(p=>p.key.length)),f=` ${"Name".padEnd(c)} Created`;console.log(l.gray(f)),console.log(l.gray(" "+"-".repeat(f.length-2)));for(let p of n){let d=p.key.padEnd(c),g=p.createdAt?new Date(p.createdAt).toLocaleDateString():"N/A";console.log(` ${d} ${g}`);}console.log(""),console.log(l.gray(` ${n.length} secret(s) total`)),console.log(l.gray(" Values are hidden. Use `vaif secrets get <name>` to reveal.")),console.log("");}catch(a){o.fail("Failed to list secrets"),a instanceof Error&&console.log(l.red(`
|
|
38
|
-
Error: ${a.message}`)),process.exit(1);}}async function xe(e,o){let t=
|
|
39
|
-
Error: ${s.message}`)),process.exit(1);}}async function Fe(e,o){let t=
|
|
40
|
-
Error: ${s.message}`)),process.exit(1);}}var ke=process.env.VAIF_API_URL||"https://api.vaif.studio";function lo(e){try{let o=new URL(e);return o.password&&(o.password="****"),o.toString()}catch{return e.replace(/:[^@/]+@/,":****@")}}async function Ce(e){let o=
|
|
41
|
-
Error: ${s.message}`)),process.exit(1);}}var fo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function De(e){let o=
|
|
42
|
-
Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.6.
|
|
38
|
+
Error: ${a.message}`)),process.exit(1);}}async function xe(e,o){let t=_(),i=J(),r=await B(o.config),a=K(o,r,i);console.log(""),t.start("Fetching secret...");try{let s=new URL(`${V}/functions/secrets/project/${a}`);o.envId&&s.searchParams.set("envId",o.envId);let n=await fetch(s.toString(),{headers:{Authorization:`Bearer ${i.token}`}});if(!n.ok)throw new Error(`Failed to fetch secrets: ${await n.text()}`);let f=(await n.json()).find(g=>g.key===e);f||(t.fail(`Secret "${e}" not found`),process.exit(1));let p=await fetch(`${V}/functions/secrets/${f.id}/value`,{headers:{Authorization:`Bearer ${i.token}`}});if(!p.ok)throw new Error(`Failed to get secret value: ${await p.text()}`);let d=await p.json();t.stop(),console.log(d.value);}catch(s){t.fail("Failed to get secret"),s instanceof Error&&console.log(l.red(`
|
|
39
|
+
Error: ${s.message}`)),process.exit(1);}}async function Fe(e,o){let t=_(),i=J(),r=await B(o.config),a=K(o,r,i);console.log(""),console.log(l.bold("VAIF Delete Secret")),console.log(""),t.start("Finding secret...");try{let s=new URL(`${V}/functions/secrets/project/${a}`);o.envId&&s.searchParams.set("envId",o.envId);let n=await fetch(s.toString(),{headers:{Authorization:`Bearer ${i.token}`}});if(!n.ok)throw new Error(`Failed to fetch secrets: ${await n.text()}`);let f=(await n.json()).find(d=>d.key===e);f||(t.fail(`Secret "${e}" not found`),process.exit(1)),t.text=`Deleting secret "${e}"...`;let p=await fetch(`${V}/functions/secrets/${f.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${i.token}`}});if(!p.ok)throw new Error(`Failed to delete secret: ${await p.text()}`);t.succeed(`Deleted secret "${e}"`),console.log("");}catch(s){t.fail("Failed to delete secret"),s instanceof Error&&console.log(l.red(`
|
|
40
|
+
Error: ${s.message}`)),process.exit(1);}}var ke=process.env.VAIF_API_URL||"https://api.vaif.studio";function lo(e){try{let o=new URL(e);return o.password&&(o.password="****"),o.toString()}catch{return e.replace(/:[^@/]+@/,":****@")}}async function Ce(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.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(`${ke}/v1/projects/${a$1}`,{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(l.bold("VAIF Project Info")),console.log("");let c=16,f=(p,d)=>{console.log(` ${l.gray(p.padEnd(c))} ${d}`);};f("Name:",l.white(n.name||"N/A")),f("Project ID:",l.white(a$1)),f("Region:",l.white(n.region||"us-east-1")),f("Plan:",l.white(n.plan||n.tier||"free")),f("Created:",l.white(n.createdAt?new Date(n.createdAt).toLocaleDateString():"N/A")),console.log(""),f("API URL:",l.cyan(n.apiUrl||`${ke}/v1`)),f("WS URL:",l.cyan(n.wsUrl||n.realtimeUrl||"N/A")),f("DB URL:",l.cyan(n.databaseUrl?lo(n.databaseUrl):"N/A")),f("Storage URL:",l.cyan(n.storageUrl||"N/A")),console.log("");}catch(s){o.fail("Failed to fetch project info"),s instanceof Error&&console.log(l.red(`
|
|
41
|
+
Error: ${s.message}`)),process.exit(1);}}var fo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function De(e){let o=_(),t=v();(!t||!t.token)&&(console.log(l.red("Not logged in")),console.log(l.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 a$1=e.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(l.red("No project ID specified")),console.log(l.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(`${fo}/v1/projects/${a$1}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let A=await s.text();throw new Error(`Failed to fetch project status: ${A}`)}let n=await s.json();o.stop(),console.log(""),console.log(l.bold("VAIF Project Status")),console.log("");let c=22,f=(A,C)=>{console.log(` ${l.gray(A.padEnd(c))} ${C}`);};f("Project:",l.white(n.name||a$1)),f("Plan:",l.white(n.plan||n.tier||"free")),console.log(""),console.log(l.gray(" --- Resources ---")),console.log("");let p=n.tableCount??n.tables?.length??"N/A",d=n.functionCount??n.functions?.length??"N/A",g=n.bucketCount??n.storage?.buckets?.length??"N/A",y=n.activeConnections??n.connections??"N/A";f("Tables:",l.white(String(p))),f("Functions:",l.white(String(d))),f("Storage Buckets:",l.white(String(g))),f("Active Connections:",l.white(String(y))),n.usage&&(console.log(""),console.log(l.gray(" --- Usage ---")),console.log(""),n.usage.dbSize&&f("Database Size:",l.white(n.usage.dbSize)),n.usage.storageSize&&f("Storage Size:",l.white(n.usage.storageSize)),n.usage.bandwidth&&f("Bandwidth:",l.white(n.usage.bandwidth)),n.usage.functionInvocations!=null&&f("Function Invocations:",l.white(String(n.usage.functionInvocations)))),console.log("");}catch(s){o.fail("Failed to fetch project status"),s instanceof Error&&console.log(l.red(`
|
|
42
|
+
Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.6.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(te);program.command("logout").description("Log out and remove stored credentials").action(ne);program.command("whoami").description("Show current authenticated user").action(se);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(Ce);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(De);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(ie);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(ae);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 Ee=program.command("functions").alias("fn").description("Manage serverless functions");Ee.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(pe);Ee.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(ue);var M=program.command("db").description("Database management commands");M.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(ye);M.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(we);M.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(he);M.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(ve);var Re=program.command("keys").description("Manage API keys");Re.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(be);Re.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(Ae);var W=program.command("secrets").alias("sec").description("Manage function secrets");W.command("set <name> [value]").description("Create or update a secret").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 or name").option("--from-file <path>","Read secret value from a file").action(Se);W.command("list").alias("ls").description("List all secrets (names only)").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 or name").action(Pe);W.command("get <name>").description("Reveal a secret value").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 or name").action(xe);W.command("delete <name>").description("Delete a secret").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 or name").action(Fe);program.parse(process.argv);process.argv.slice(2).length||program.outputHelp();
|
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ Make sure your database is running and accessible.`))),process.exit(1);}}var b=[
|
|
|
81
81
|
"@types/node": "^22.0.0",
|
|
82
82
|
"@types/react": "^19.0.0",
|
|
83
83
|
"@types/react-dom": "^19.0.0",
|
|
84
|
+
"drizzle-kit": "^0.30.0",
|
|
84
85
|
"typescript": "^5.7.0"
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -150,18 +151,17 @@ body {
|
|
|
150
151
|
-webkit-font-smoothing: antialiased;
|
|
151
152
|
-moz-osx-font-smoothing: grayscale;
|
|
152
153
|
}
|
|
153
|
-
`},{path:"lib/vaif.ts",content:`import {
|
|
154
|
-
import { createServerClient } from "@vaiftech/client/server";
|
|
154
|
+
`},{path:"lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
155
155
|
|
|
156
156
|
// Browser client \u2013 safe to use in Client Components
|
|
157
|
-
export const vaif =
|
|
157
|
+
export const vaif = createVaifClient({
|
|
158
158
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
159
159
|
apiKey: process.env.NEXT_PUBLIC_VAIF_API_KEY!,
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
// Server client \u2013 use in Server Components, Route Handlers, Server Actions
|
|
163
163
|
export function createVaifServer() {
|
|
164
|
-
return
|
|
164
|
+
return createVaifClient({
|
|
165
165
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
166
166
|
secretKey: process.env.VAIF_SECRET_KEY!,
|
|
167
167
|
});
|
|
@@ -274,7 +274,7 @@ A full-stack Next.js application powered by [VAIF Studio](https://vaif.studio),
|
|
|
274
274
|
|
|
275
275
|
Full documentation is available at <https://docs.vaif.studio>.
|
|
276
276
|
`}],featureFiles:{auth:[{path:"middleware.ts",content:`import { NextResponse, type NextRequest } from "next/server";
|
|
277
|
-
import {
|
|
277
|
+
import { createVaifClient } from "@vaiftech/client";
|
|
278
278
|
import { authMiddleware } from "@vaiftech/auth/nextjs";
|
|
279
279
|
|
|
280
280
|
const protectedRoutes = ["/dashboard", "/settings", "/api/protected"];
|
|
@@ -284,7 +284,7 @@ export async function middleware(request: NextRequest) {
|
|
|
284
284
|
const isProtected = protectedRoutes.some((route) => pathname.startsWith(route));
|
|
285
285
|
if (!isProtected) return NextResponse.next();
|
|
286
286
|
|
|
287
|
-
const vaif =
|
|
287
|
+
const vaif = createVaifClient({
|
|
288
288
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
289
289
|
secretKey: process.env.VAIF_SECRET_KEY!,
|
|
290
290
|
});
|
|
@@ -552,9 +552,11 @@ export const posts = pgTable("posts", {
|
|
|
552
552
|
"react-router-dom": "^7.0.0"
|
|
553
553
|
},
|
|
554
554
|
"devDependencies": {
|
|
555
|
+
"@types/node": "^22.0.0",
|
|
555
556
|
"@types/react": "^19.0.0",
|
|
556
557
|
"@types/react-dom": "^19.0.0",
|
|
557
558
|
"@vitejs/plugin-react": "^4.4.0",
|
|
559
|
+
"drizzle-kit": "^0.30.0",
|
|
558
560
|
"typescript": "^5.7.0",
|
|
559
561
|
"vite": "^6.0.0"
|
|
560
562
|
}
|
|
@@ -642,9 +644,9 @@ function Home() {
|
|
|
642
644
|
</div>
|
|
643
645
|
);
|
|
644
646
|
}
|
|
645
|
-
`},{path:"src/lib/vaif.ts",content:`import {
|
|
647
|
+
`},{path:"src/lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
646
648
|
|
|
647
|
-
export const vaif =
|
|
649
|
+
export const vaif = createVaifClient({
|
|
648
650
|
projectId: import.meta.env.VITE_VAIF_PROJECT_ID,
|
|
649
651
|
apiKey: import.meta.env.VITE_VAIF_API_KEY,
|
|
650
652
|
});
|
|
@@ -1269,7 +1271,9 @@ Full documentation is available at <https://docs.vaif.studio>.
|
|
|
1269
1271
|
"react-native": "~0.76.0"
|
|
1270
1272
|
},
|
|
1271
1273
|
"devDependencies": {
|
|
1274
|
+
"@types/node": "^22.0.0",
|
|
1272
1275
|
"@types/react": "^19.0.0",
|
|
1276
|
+
"drizzle-kit": "^0.30.0",
|
|
1273
1277
|
"typescript": "^5.7.0"
|
|
1274
1278
|
}
|
|
1275
1279
|
}
|
|
@@ -2593,9 +2597,9 @@ func HelloHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
2593
2597
|
Message: fmt.Sprintf("Hello, %s!", req.Name),
|
|
2594
2598
|
})
|
|
2595
2599
|
}
|
|
2596
|
-
`}]},postInstructions:["go mod tidy","# Copy .env.example to .env and add your VAIF credentials","go run main.go"]},"todo-app":{name:"Todo App",description:"Simple React todo app \u2013 great for learning VAIF basics",tag:"React Starter",defaultFeatures:["database"],files:[{path:"src/lib/vaif.ts",content:`import {
|
|
2600
|
+
`}]},postInstructions:["go mod tidy","# Copy .env.example to .env and add your VAIF credentials","go run main.go"]},"todo-app":{name:"Todo App",description:"Simple React todo app \u2013 great for learning VAIF basics",tag:"React Starter",defaultFeatures:["database"],files:[{path:"src/lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
2597
2601
|
|
|
2598
|
-
export const vaif =
|
|
2602
|
+
export const vaif = createVaifClient({
|
|
2599
2603
|
projectId: import.meta.env.VITE_VAIF_PROJECT_ID,
|
|
2600
2604
|
apiKey: import.meta.env.VITE_VAIF_API_KEY,
|
|
2601
2605
|
});
|
|
@@ -2784,9 +2788,9 @@ export const posts = pgTable("posts", {
|
|
|
2784
2788
|
|
|
2785
2789
|
return Response.json({ message: \`Hello, \${name}!\` });
|
|
2786
2790
|
}
|
|
2787
|
-
`}]},dependencies:["@vaiftech/client","@vaiftech/react"],postInstructions:["Copy .env.example to .env and fill in your project credentials","Create a 'todos' table in your VAIF dashboard with columns: id (uuid), title (text), done (boolean), created_at (timestamptz)","Import helpers from './lib/vaif' in your components","Run: npx vaif generate to generate TypeScript types"]},"realtime-chat":{name:"Realtime Chat",description:"React chat app with VAIF realtime subscriptions for live messaging",tag:"React + Realtime",defaultFeatures:["database","realtime","auth"],files:[{path:"src/lib/vaif.ts",content:`import {
|
|
2791
|
+
`}]},dependencies:["@vaiftech/client","@vaiftech/react"],postInstructions:["Copy .env.example to .env and fill in your project credentials","Create a 'todos' table in your VAIF dashboard with columns: id (uuid), title (text), done (boolean), created_at (timestamptz)","Import helpers from './lib/vaif' in your components","Run: npx vaif generate to generate TypeScript types"]},"realtime-chat":{name:"Realtime Chat",description:"React chat app with VAIF realtime subscriptions for live messaging",tag:"React + Realtime",defaultFeatures:["database","realtime","auth"],files:[{path:"src/lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
2788
2792
|
|
|
2789
|
-
export const vaif =
|
|
2793
|
+
export const vaif = createVaifClient({
|
|
2790
2794
|
projectId: import.meta.env.VITE_VAIF_PROJECT_ID,
|
|
2791
2795
|
apiKey: import.meta.env.VITE_VAIF_API_KEY,
|
|
2792
2796
|
realtime: {
|
|
@@ -3083,18 +3087,17 @@ export const posts = pgTable("posts", {
|
|
|
3083
3087
|
|
|
3084
3088
|
return Response.json({ message: \`Hello, \${name}!\` });
|
|
3085
3089
|
}
|
|
3086
|
-
`}]},dependencies:["@vaiftech/client","@vaiftech/react"],postInstructions:["Copy .env.example to .env and fill in your project credentials","Create a 'messages' table with columns: id (uuid), content (text), user_id (text), username (text), channel_id (text), created_at (timestamptz)","Enable Realtime on the messages table in your VAIF dashboard","Use the useRealtimeMessages hook in your components","Run: npx vaif generate to generate TypeScript types"]},"saas-starter":{name:"SaaS Starter",description:"Full SaaS starter with VAIF auth, team/org support, and server-side helpers",tag:"Next.js SaaS",defaultFeatures:["database","auth","functions"],files:[{path:"lib/vaif.ts",content:`import {
|
|
3087
|
-
import { createServerClient } from "@vaiftech/client/server";
|
|
3090
|
+
`}]},dependencies:["@vaiftech/client","@vaiftech/react"],postInstructions:["Copy .env.example to .env and fill in your project credentials","Create a 'messages' table with columns: id (uuid), content (text), user_id (text), username (text), channel_id (text), created_at (timestamptz)","Enable Realtime on the messages table in your VAIF dashboard","Use the useRealtimeMessages hook in your components","Run: npx vaif generate to generate TypeScript types"]},"saas-starter":{name:"SaaS Starter",description:"Full SaaS starter with VAIF auth, team/org support, and server-side helpers",tag:"Next.js SaaS",defaultFeatures:["database","auth","functions"],files:[{path:"lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
3088
3091
|
|
|
3089
3092
|
// Browser client \u2013 use in Client Components
|
|
3090
|
-
export const vaif =
|
|
3093
|
+
export const vaif = createVaifClient({
|
|
3091
3094
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
3092
3095
|
apiKey: process.env.NEXT_PUBLIC_VAIF_API_KEY!,
|
|
3093
3096
|
});
|
|
3094
3097
|
|
|
3095
3098
|
// Server client \u2013 use in Server Components, Route Handlers, Server Actions
|
|
3096
3099
|
export function createVaifServer() {
|
|
3097
|
-
return
|
|
3100
|
+
return createVaifClient({
|
|
3098
3101
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
3099
3102
|
secretKey: process.env.VAIF_SECRET_KEY!,
|
|
3100
3103
|
});
|
|
@@ -3394,18 +3397,17 @@ export const posts = pgTable("posts", {
|
|
|
3394
3397
|
|
|
3395
3398
|
return Response.json({ message: \`Hello, \${name}!\` });
|
|
3396
3399
|
}
|
|
3397
|
-
`}]},dependencies:["@vaiftech/client","@vaiftech/auth","@vaiftech/react"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create 'teams' and 'team_members' tables in your VAIF dashboard","Import auth helpers from '@/lib/auth' in your Server Components/Actions","Use requireUser() for authenticated routes and requireTeamRole() for role checks","Run: npx vaif generate to generate TypeScript types"]},"ecommerce-api":{name:"E-commerce API",description:"API-first e-commerce setup with VAIF storage for product images",tag:"Next.js E-commerce",defaultFeatures:["database","auth","storage"],files:[{path:"lib/vaif.ts",content:`import {
|
|
3398
|
-
import { createServerClient } from "@vaiftech/client/server";
|
|
3400
|
+
`}]},dependencies:["@vaiftech/client","@vaiftech/auth","@vaiftech/react"],postInstructions:["Copy .env.example to .env.local and fill in your project credentials","Create 'teams' and 'team_members' tables in your VAIF dashboard","Import auth helpers from '@/lib/auth' in your Server Components/Actions","Use requireUser() for authenticated routes and requireTeamRole() for role checks","Run: npx vaif generate to generate TypeScript types"]},"ecommerce-api":{name:"E-commerce API",description:"API-first e-commerce setup with VAIF storage for product images",tag:"Next.js E-commerce",defaultFeatures:["database","auth","storage"],files:[{path:"lib/vaif.ts",content:`import { createVaifClient } from "@vaiftech/client";
|
|
3399
3401
|
|
|
3400
3402
|
// Browser client
|
|
3401
|
-
export const vaif =
|
|
3403
|
+
export const vaif = createVaifClient({
|
|
3402
3404
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
3403
3405
|
apiKey: process.env.NEXT_PUBLIC_VAIF_API_KEY!,
|
|
3404
3406
|
});
|
|
3405
3407
|
|
|
3406
3408
|
// Server client
|
|
3407
3409
|
export function createVaifServer() {
|
|
3408
|
-
return
|
|
3410
|
+
return createVaifClient({
|
|
3409
3411
|
projectId: process.env.NEXT_PUBLIC_VAIF_PROJECT_ID!,
|
|
3410
3412
|
secretKey: process.env.VAIF_SECRET_KEY!,
|
|
3411
3413
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export{b as generateTypes,d as initConfig,a as loadConfig}from'./chunk-
|
|
1
|
+
export{b as generateTypes,d as initConfig,a as loadConfig}from'./chunk-RBCJFCBE.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
|