npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rinari/types

v1.0.1

Published

TypeScript type definitions for RINARI framework

Readme

@rinari/types

Core type definitions and enums for the Rinari ORM framework.

npm version License

Overview

@rinari/types provides the foundational type system for Rinari ORM, including the DataTypes enum for schema definition and TypeScript interfaces for type safety across all packages.

Installation

npm install @rinari/types

This package is typically installed automatically as a dependency of @rinari/orm and driver packages.

Features

  • DataTypes Enum - Standard data type definitions for all Rinari packages
  • TypeScript Types - Comprehensive type definitions for full type safety
  • Zero Dependencies - Lightweight with no external dependencies
  • Cross-Package Compatibility - Ensures type consistency across the ecosystem

Usage

Basic Usage

import { DataTypes } from '@rinari/types';

const userSchema = {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  username: { type: DataTypes.TEXT, notNull: true },
  email: { type: DataTypes.TEXT, unique: true },
  age: { type: DataTypes.INTEGER },
  isActive: { type: DataTypes.BOOLEAN },
  metadata: { type: DataTypes.JSON },
  createdAt: { type: DataTypes.DATETIME },
};

With ORM

import { DataTypes } from '@rinari/types';
import { ORM } from '@rinari/orm';
import { SQLiteDriver } from '@rinari/sqlite';

const orm = new ORM({
  driver: new SQLiteDriver({ storageDir: './data' }),
});

const User = orm.define('mydb', 'users', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  username: { type: DataTypes.TEXT, notNull: true },
  email: { type: DataTypes.TEXT, unique: true },
});

API Reference

DataTypes Enum

Available data types for column definitions:

| Type | Description | Example | |------|-------------|---------| | DataTypes.TEXT | Text strings | 'hello world' | | DataTypes.INTEGER | Integer numbers | 42 | | DataTypes.REAL | Floating point numbers | 3.14 | | DataTypes.BLOB | Binary data | Buffer.from('data') | | DataTypes.BOOLEAN | Boolean values | true / false | | DataTypes.DATE | Date values (ISO format) | '2024-01-15' | | DataTypes.DATETIME | Date and time (ISO format) | '2024-01-15T10:30:00Z' | | DataTypes.JSON | JSON objects/arrays | { key: 'value' } |

Column Options

When defining schemas, these options are available:

{
  type: DataTypes.TEXT,           // Required: Data type
  primaryKey: true,                // Optional: Primary key flag
  autoIncrement: true,             // Optional: Auto-increment (INTEGER only)
  notNull: true,                   // Optional: NOT NULL constraint
  unique: true,                    // Optional: UNIQUE constraint
  default: 'value',                // Optional: Default value
  references: {                    // Optional: Foreign key
    table: 'other_table',
    column: 'id',
    onDelete: 'CASCADE'
  }
}

Query Operators

Operators for WHERE clauses:

// Comparison
{ age: { $gt: 18 } }                    // Greater than
{ age: { $gte: 18 } }                   // Greater than or equal
{ age: { $lt: 65 } }                    // Less than
{ age: { $lte: 65 } }                   // Less than or equal
{ status: { $ne: 'deleted' } }          // Not equal

// Set operations
{ status: { $in: ['active', 'pending'] } }      // In array
{ status: { $notIn: ['deleted', 'banned'] } }   // Not in array

// Pattern matching
{ email: { $like: '%@gmail.com' } }     // Like pattern

// Range
{ age: { $between: [18, 65] } }         // Between range

// Complex conditions
{
  age: { $gte: 18, $lt: 65 },
  status: { $in: ['active', 'verified'] },
  email: { $like: '%@company.com' }
}

Available operators:

  • $gt - Greater than
  • $gte - Greater than or equal
  • $lt - Less than
  • $lte - Less than or equal
  • $ne - Not equal
  • $in - In array
  • $notIn - Not in array
  • $like - Like pattern (SQL LIKE)
  • $between - Between range (inclusive)

TypeScript Support

Automatic Type Inference

TypeScript automatically infers types from your schema:

import { DataTypes } from '@rinari/types';
import { ORM } from '@rinari/orm';

const User = orm.define('mydb', 'users', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  username: { type: DataTypes.TEXT, notNull: true },
  email: { type: DataTypes.TEXT, unique: true },
  age: { type: DataTypes.INTEGER },
});

// TypeScript infers the return type
const user = User.findOne({ where: { id: 1 } });
// user is typed as: { id: number; username: string; email: string; age: number } | null

Advanced Type Imports

For explicit type annotations:

import {
  DataTypes,
  TableSchema,
  QueryOptions,
  WhereCondition,
  WhereOperators,
  ColumnDefinition
} from '@rinari/types';

// Explicit schema typing
const schema: TableSchema = {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  username: { type: DataTypes.TEXT, notNull: true },
};

// Type-safe query options
const options: QueryOptions = {
  where: { status: 'active' },
  limit: 10,
  orderBy: [['createdAt', 'DESC']],
};

Examples

Complete Schema Example

import { DataTypes } from '@rinari/types';

const schema = {
  // Primary key with auto-increment
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
  },
  
  // Required text field
  username: {
    type: DataTypes.TEXT,
    notNull: true,
    unique: true,
  },
  
  // Optional field with default
  status: {
    type: DataTypes.TEXT,
    default: 'active',
  },
  
  // Integer field
  age: {
    type: DataTypes.INTEGER,
  },
  
  // Boolean field
  isVerified: {
    type: DataTypes.BOOLEAN,
    default: false,
  },
  
  // JSON field
  settings: {
    type: DataTypes.JSON,
    default: '{}',
  },
  
  // DateTime field
  createdAt: {
    type: DataTypes.DATETIME,
  },
  
  // Foreign key
  profileId: {
    type: DataTypes.INTEGER,
    references: {
      table: 'profiles',
      column: 'id',
      onDelete: 'CASCADE',
    },
  },
};

Query Examples

// Simple equality
User.findAll({ where: { status: 'active' } });

// Comparison operators
User.findAll({ where: { age: { $gte: 18 } } });

// Multiple conditions
User.findAll({
  where: {
    age: { $gte: 18, $lt: 65 },
    status: { $in: ['active', 'verified'] },
  },
});

// Pattern matching
User.findAll({ where: { email: { $like: '%@gmail.com' } } });

// Range queries
User.findAll({ where: { score: { $between: [0, 100] } } });

Related Packages

Documentation

Support

License

OpenUwU Open License (OUOL-1.0) - See LICENSE for details.