UNPKG

baseflow-client

Version:

Official TypeScript/JavaScript client for BaseFlow - a powerful BaaS with OAuth authentication, RPC functions, database indexes, real-time features, and Supabase-compatible API

54 lines (53 loc) 1.59 kB
/** * @module Schema * @description * This module provides a set of functions for defining the schema of a BaseFlow database. * It allows you to define tables, fields, and constraints using a simple and intuitive syntax. */ /** * Defines the structure of a field in a table. */ export interface FieldDefinition { type: string; constraints: { primary?: boolean; required?: boolean; unique?: boolean; autoIncrement?: boolean; default?: any; foreign?: { table: string; field: string; }; }; } /** * Defines the structure of a table, including its name, fields, and type. */ export interface TableDefinition { name: string; fields: Record<string, FieldDefinition>; type: 'table'; } /** * Defines a table with the given name and fields. * * @param tableName The name of the table. * @param fields A record of field names and their definitions. * @returns A table definition object. */ export declare function defineTable(tableName: string, fields: Record<string, string>): TableDefinition; /** * Validates a field type. * * @param type The field type to validate. * @returns `true` if the field type is valid, `false` otherwise. */ export declare function validateFieldType(type: string): boolean; /** * Creates a schema from a record of table definitions. * * @param tables A record of table definitions. * @returns A record of table definitions. */ export declare function createSchema(tables: Record<string, TableDefinition>): Record<string, TableDefinition>;