Socket
Book a DemoInstallSign in
Socket

@ahmedabdalla_85/schemakit

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@ahmedabdalla_85/schemakit

Dynamic entity management system with runtime schema creation, validation, and CRUD operations. Zero dependencies, works in Node.js and browsers.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
0
Created
Source

SchemaKit

⚠️ BETA VERSION - This is a beta version and is not recommended for production use. Please use with caution and expect potential breaking changes.

🚧 ACTIVE DEVELOPMENT - This library is actively under development. Functionality may change and features are under testing. Expect bugs and incomplete features.

SchemaKit lets you create, validate, and manage entities and data at runtime, with built-in permissions and support for SQLite and PostgreSQL. Written in TypeScript.

Features

  • Dynamic entities and fields (no migrations)
  • Data validation
  • Role-based permissions and RLS
  • Multi-database: SQLite & Postgres
  • TypeScript-first, zero dependencies

Install

  • Built-in Validation - Comprehensive data validation with custom rules
  • 🔐 Permission System - Role-based access control with row-level security
  • 🔄 Workflow Engine - Automated actions on entity lifecycle events
  • 🗃️ Multiple Databases - SQLite and PostgreSQL support
  • 📱 Universal - Works in Node.js and browsers
  • 🎯 TypeScript First - Full type safety and IntelliSense support
  • 🧩 Modular Architecture - Use individual components as needed

📦 Installation

npm install @ahmedabdalla_85/schemakit

🚀 Quick Start

import { SchemaKit } from '@ahmedabdalla_85/schemakit';

// Initialize SchemaKit
const schemaKit = new SchemaKit({
  adapter: {
    type: 'sqlite',
    config: { filename: 'database.db' }
  }
});

// Initialize (automatically installs SchemaKit if not already installed)
await schemaKit.initialize();


const user = await schemaKit.entity('users','system');

// Create a user entity
await user.create({
  name: 'John Doe',
  email: 'john@example.com'
});

// Update user
const updatedUser = await user.update(1,{
  name: 'John Smith'
});

// Find All users
const Entities = await user.read();

// Find user by name
const fieldRecord = await user.read({user_name:"John Doe"});
        
// Delete user
await user.delete(1);

Built-in Validation

Automatic validation based on field types and custom rules:

// This will validate field types automatically
const user = await schemaKit.create('user', {
  name: 'John',        // string
  age: 25,             // number
  isActive: true,      // boolean
  createdAt: new Date(), // date
  tags: ['admin', 'user'], // array
  metadata: { role: 'admin' } // object
});

Permission System

Role-based access control with fine-grained permissions:

const context = {
  user: {
    id: 'user123',
    roles: ['admin']
  }
};

// Check permissions
const canCreate = await schemaKit.checkPermission('user', 'create', context);

// Get all permissions
const permissions = await schemaKit.getEntityPermissions('user', context);

SQL Schema Files

  • sql/schema.sql - Defines system tables structure
  • sql/seed.sql - Initial data and default entities
  • Version tracking - Automatic version management
  • Migration support - Ready for future schema updates

🗄️ Database Tables

When SchemaKit is installed, it creates the following system tables in your database:

Core System Tables

Table NamePurposeDescription
system_entitiesEntity DefinitionsStores metadata for all dynamic entities including name, table name, and configuration
system_fieldsField DefinitionsDefines fields for each entity with validation rules, types, and constraints
system_permissionsAccess ControlRole-based permissions for entities and field-level access control
system_viewsQuery ViewsPredefined query configurations for entities with sorting and filtering
system_workflowsAutomationWorkflow definitions for automated actions on entity lifecycle events
system_rlsRow-Level SecuritySecurity rules that control which records users can access
system_installationVersion ManagementTracks SchemaKit installation version and metadata

🔌 Database Adapters

SQLite (Default)

const schemaKit = new SchemaKit({
  adapter: {
    type: 'sqlite',
    config: { 
      filename: 'database.db' // or ':memory:' for in-memory
    }
  }
});

Note: SQLite adapter requires better-sqlite3 to be installed separately:

npm install better-sqlite3

PostgreSQL

const schemaKit = new SchemaKit({
  adapter: {
    type: 'postgres',
    config: {
      host: 'localhost',
      port: 5432,
      database: 'mydb',
      user: 'username',
      password: 'password'
    }
  }
});

🔧 Configuration

SchemaKit Options

const schemaKit = new SchemaKit({
  adapter: {
    type: 'sqlite',
    config: { filename: 'database.db' }
  },
  cache: {
    enabled: true,
    ttl: 3600000 // 1 hour
  }
});

Field Types

Supported field types:

  • string - Text data
  • number - Numeric data
  • boolean - True/false values
  • date - Date/time values
  • array - Array data
  • json - JSON objects
  • reference - References to other entities

Validation Rules

// String validation
{
  type: 'string',
  validation_rules: {
    minLength: 2,
    maxLength: 50,
    pattern: '^[a-zA-Z]+$'
  }
}

// Number validation
{
  type: 'number',
  validation_rules: {
    min: 0,
    max: 120
  }
}

// Array validation
{
  type: 'array',
  validation_rules: {
    minItems: 1,
    maxItems: 10
  }
}

🧪 Testing

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

🏗️ Building

# Build for production
npm run build:all

# Build CommonJS
npm run build

# Build ES modules
npm run build:esm

# Build UMD
npm run build:umd

📄 License

MIT © Ahmed Abdalla

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

  • 🐛 Issues: GitHub Issues
  • 📖 Documentation: GitHub Wiki

🗺️ Roadmap

  • GraphQL support
  • MongoDB adapter
  • Real-time subscriptions
  • Advanced workflow conditions
  • Schema migrations
  • Performance optimizations
  • Browser-specific optimizations

Made with ❤️ by Ahmed Abdalla

Keywords

schema

FAQs

Package last updated on 22 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts