@tty-pt/hyle-source

npm version License: BSD-2-Clause TypeScript Ready Node.js Native WebAssembly Zero Dependencies

Universal Node.js and Browser bindings for libhyle-source, the dataset persistence, pluggable storage driver (fs, tok, mem), full-text query, and optimistic LRU substrate cache engine for Hyle. Canonical C header: <hyle-source/hyle_source.h>.

📖 Full C & Storage Driver Documentation: See the main libhyle-source GitHub README for hyle_source_store_ops_t driver architecture, binary .tok containers (hyle-tok), and C dataset lifecycle functions.


1. Overview & Domain Concepts

libhyle-source (@tty-pt/hyle-source) is the persistence and query execution engine pairing with @tty-pt/hyle schemas:

  1. Pluggable Dataset Persistence & CRUD:
  1. Accent-Sensitive Full-Text Search & Structured Queries (queryDataset):
  1. In-Memory LRU Query & Normalized Entity Cache:
  1. Optimistic Mutations & Reactive Store Subscriptions:

2. Installation

npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/hyle-source @tty-pt/hyle @tty-pt/corm

Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (libhyle-source) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ — libhyle-source.xcframework) are available via the tty.pt package repositories.


3. Quickstart

import {
  HyleSource,
  optimisticUpdate,
  slugify
} from "@tty-pt/hyle-source";

// 1. Initialize dataset persistence engine
const source = new HyleSource("./var/data");

source.registerDataset({
  id: "album",
  keyField: "id",
  fields: [
    { name: "title", type: "string", required: true },
    { name: "year", type: "int" }
  ]
});

// 2. Persist records and execute full-text search
source.putItem("album", "album_1", { title: "Canção do Mar", year: 1955 });
const results = source.query("album", "q=canção&sort=year&order=desc");
console.log("Matches:", results.total, results.items);

// 3. Optimistic UI cache update with commit / rollback handle
source.cacheHydrate("album", "active=1", [{ id: "album_1", title: "Canção do Mar" }]);
const tx = optimisticUpdate("album", "album_1", { title: "Canção do Mar (Remastered)" });
// Call tx.commit() on server 200 OK, or tx.rollback() on network failure:
tx.commit();

console.log("Slug:", slugify("Canção do Mar!")); // "cancao-do-mar"

4. JavaScript / TypeScript API Reference

HyleSource Class & Dataset Operations

Query Cache, Entity Store & Optimistic Updates


5. C Development Headers & Native Integration

CFLAGS += -I./node_modules/@tty-pt/hyle-source/include
LDLIBS += -lhyle-source

License

BSD-2-Clause — Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.

Documentation