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

@artefacto/schemascript

v0.0.2

Published

**SchemaScript** is an *ECMAScript-based* **data-centric** ORM that lets you *declaratively* define database schemas with maximum type safety and constraint enforcement. It's built as an abstraction over low-level backends like Drizzle ORM, offering a flu

Downloads

855

Readme

SchemaScript

SchemaScript is an ECMAScript-based data-centric ORM that lets you declaratively define database schemas with maximum type safety and constraint enforcement. It's built as an abstraction over low-level backends like Drizzle ORM, offering a fluent API running securely within a sandboxed Rust runtime.


Features

  • TypeScript (interface) .ts code generation.
  • JSON schema .json code generation.
  • JavaScript runtime validator .js code generation.
  • SQL table creation & migration .sql code generation.

Getting Started

Installation

Use your favorite pacakge manager and install @artefacto/schemascript:


npm install -d @artefacto/schemascript

Usage

Schema Definition & Table Creation

Schemas are defined using the Schema function, which creates a type-safe schema definition that can be used for type generation and validation:

Tables are created using the Table function, which converts your schema definition into your targeted ORM table instance ready for database operations:

import type { SchemaBuilder } from "@artefacto/schemascript";
import { Schema, Table, value } from "@artefacto/schemascript";

const User: SchemaBuilder = (prop) => ({
	id: prop.integer().identifier(),
	username: prop.text().unique(),
	email: prop.text().optional(),
	created_at: prop.datetime().default(value.now),
});
const UserSchema = Schema("User", User);
const UserTable = Table("users", User);

export { User, UserSchema, UserTable };

Data Types

SchemaScript provides 8 core primitive data types:

| SchemaScript Type | Description / Usage | JS Type | SQLite Type | | :---------------- | :--------------------------------- | :--------------- | :----------------- | | integer | Whole number integer values | bigint | INTEGER | | real | Floating-point real numbers | number | REAL | | text | Textual string data | string | TEXT | | boolean | True or false values | boolean | INTEGER (0 or 1) | | blob | Binary data | Uint8Array | BLOB | | datetime | Dates and times | Date | INTEGER | | node | Structured objects and documents | object | BLOB (JSON) | | enum | Performant, type-safe enumerations | string (union) | INTEGER |


Modifiers

All properties support the following modifiers through method chaining:

  • .identifier(): Marks the column as a primary key.
  • .optional(): Allows the column to be null.
  • .unique(): Adds a unique constraint (mapped to a unique index in SQLite).
  • .default(value): Sets a default value. Supports literals and SQL expressions like value.now.
  • .references(ref, actions?): Creates a foreign key constraint.
  • .array(): Marks the column as an array.

Note: All fields are required (non-nullable) by default. Use .optional() to allow null values.


Relations

SchemaScript allows you to define database relationships between tables using the .references() modifier.

One-to-Many Relationship

import type { SchemaBuilder } from "@artefacto/schemascript";
import { Schema, Table } from "@artefacto/schemascript";
import { UserTable } from "./user";

const Post: SchemaBuilder = (prop) => ({
	id: prop.integer().identifier(),
	author_id: prop
		.integer()
		.references(() => UserTable.id, { onDelete: "cascade" }),
	title: prop.text(),
});

const PostSchema = Schema("Post", Post);
const PostTable = Table("posts", Post);

export { Post, PostSchema, PostTable };

Enums

First-class support for enums. Enums are defined using an object mapping keys to values or an array of strings. Column names are inferred from the object key.

const Profile = Schema("Profile", (prop) => ({
	role: prop.enum({ options: ["admin", "user", "guest"] }).default("guest"),
	status: prop.enum({ options: { ACTIVE: 1, INACTIVE: 0 } }).default("ACTIVE"),
}));

TypeScript Generation

SchemaScript can generate standard TypeScript interfaces from your schema definitions.

const userInterface = UserSchema.toTypeScriptInterface();
/*
interface User {
	id: bigint;
	username: string;
	email: string | null;
	created_at: Date;
}
*/

Architecture

The project is architected in three main domains, ensuring a hard boundary between high-level definition and low-level execution.

1. SchemaScript DSL (JavaScript)

A type-safe, fluent API for defining database schemas with SQLite-optimised primitives.

  • Immutability: Every property modifier returns a new instance.
  • Strict Naming: Column names are automatically and strictly inferred from object keys.
  • Drizzle Integration: Definitions are translated into drizzle-orm compatible column builders.

2. High-Performance Runtime (Rust Host)

A secure execution environment leveraging WasmEdge and smol for ultra-fast, lightweight sandboxing.

3. The SYSCALL Bridge

Uses drizzle-orm/sqlite-proxy to capture SQL queries across the Host-Guest boundary.


License

This project is dedicated to the public domain under the CC0 1.0 Universal license.