VAIF CLI - Type generation and development tools
npm install @vaiftech/cliCommand-line tools for VAIF Studio - a Backend-as-a-Service platform.
``bash`
npm install -D @vaiftech/clior
pnpm add -D @vaiftech/clior
yarn add -D @vaiftech/cli
Generate TypeScript types from your VAIF database schema.
`bash`
npx vaif types generate --project
#### Options
| Flag | Description | Default |
|------|-------------|---------|
| --project | Project ID | Required |--output
| | Output file path | ./vaif.types.ts |--env
| | Environment (development, staging, production) | development |
#### Example Output
`typescript
// Generated by @vaiftech/cli
export interface User {
id: string;
email: string;
name: string | null;
avatar_url: string | null;
created_at: string;
updated_at: string;
}
export interface Post {
id: string;
title: string;
content: string;
author_id: string;
published: boolean;
created_at: string;
updated_at: string;
}
export interface Database {
users: User;
posts: Post;
}
`
`typescript
import { generateTypes } from '@vaiftech/cli';
const types = await generateTypes({
projectId: 'proj-123',
apiKey: 'vaif_sk_xxx',
baseUrl: 'https://api.vaif.io',
});
// types is a string containing TypeScript definitions
console.log(types);
`
Create a vaif.config.js file in your project root:
`javascript`
module.exports = {
projectId: 'proj-123',
output: './src/types/vaif.ts',
};
Then run without flags:
`bash`
npx vaif types generate
Use generated types with the client SDK:
`typescript
import { createVaifClient } from '@vaiftech/client';
import type { User, Post, Database } from './types/vaif';
const vaif = createVaifClient({
baseUrl: 'https://api.myproject.vaif.io',
apiKey: 'vaif_pk_xxx',
});
// Fully typed queries
const users = await vaif.from
const post = await vaif.from
``
- @vaiftech/client - Core client SDK
- @vaiftech/react - React hooks
- @vaiftech/sdk-expo - React Native/Expo SDK
MIT