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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vital-ai/vital-model-utils

v0.1.6

Published

TypeScript utilities for VitalSigns ontology - generate type-safe classes, convert JSON-LD, traverse knowledge graphs, and integrate with REST APIs

Downloads

27

Readme

Vital Model Utils TypeScript

A comprehensive TypeScript library for working with VitalSigns ontologies, providing schema-to-class generation, JSON-LD conversion, JSONL processing, and graph traversal capabilities.

Features

  • 🏗️ VitalSigns Base Classes: Complete implementation of VITAL_Node, VITAL_Edge, VITAL_HyperNode, VITAL_HyperEdge, and VITAL_GraphContainerObject
  • 🔄 JSON-LD Support: Seamless conversion between JSON-LD and VitalSigns JSON formats
  • 📄 JSONL Processing: Process large datasets from JSONL files with auto-format detection
  • 🕸️ Graph Traversal: Advanced graph navigation with filtering and path finding
  • 🎯 Type Safety: Full TypeScript support with branded union types
  • 🛠️ CLI Tools: Command-line utilities for schema validation and data processing
  • Performance: Optimized for large VitalSigns datasets

Installation

npm install vital-model-utils

Quick Start

Processing VitalSigns Data

import { 
  VitalSignsJsonlProcessor, 
  VitalSignsGraphTraverser,
  VitalSignsConverter 
} from 'vital-model-utils';

// Process JSON-LD instances file
const schema = JSON.parse(fs.readFileSync('schema.json', 'utf-8'));
const graphInstance = await VitalSignsJsonlProcessor.processJsonLDFile(
  'instances.jsonl',
  schema
);

// Traverse the graph
const traverser = new VitalSignsGraphTraverser(graphInstance);
const connectedNodes = traverser.findConnectedNodes('urn:node-123', {
  direction: 'outgoing',
  maxDepth: 2
});

Converting JSON-LD Objects

// JSON-LD format (from instances.jsonl)
const jsonLD = {
  "@id": "http://vital.ai/ontology/haley-ai-kg#KGActionStatus_OK",
  "@type": "http://vital.ai/ontology/haley-ai-kg#KGActionStatus"
};

const result = VitalSignsConverter.toInstance(jsonLD, KGEntity);
const entity = result.instance;

REST API Integration

The library provides specialized methods for REST service integration:

import { VitalSignsConverter, KGEntity } from 'vital-model-utils';

// REST Output: Convert VitalSigns objects to JSON for API response
const entities = [entity1, entity2, entity3];
const mapList = VitalSignsConverter.toMapList(entities);
const jsonResponse = JSON.stringify(mapList.map(m => Object.fromEntries(m)));

// REST Input: Parse JSON from API request to VitalSigns objects
const jsonData = JSON.parse(requestBody);
const maps = jsonData.map(obj => new Map(Object.entries(obj)));
const entities = VitalSignsConverter.fromJsonMapList(maps, KGEntity);

Individual Object Map Methods

// Convert object to Map (helpful for batch processing)
const entityMap = entity.toMap();

// Create object from Map (helpful for parsing)
const newEntity = new KGEntity();
newEntity.fromMap(entityMap);

CLI Usage

Generate Classes

npx vital-model-utils generate-classes schema.json
# Process JSON-LD format
npx vital-model-utils process-jsonl instances.jsonl \
  --schema schema.json \
  --format json-ld \
  --stats

# Auto-detect format
npx vital-model-utils process-jsonl data.jsonl \
  --schema schema.json \
  --format auto \
  --output processed-data.json

Schema Information

npx vital-model-utils info schema.json

Development

Setup

git clone <repository>
cd vital-model-utils-ts
npm install

Build

npm run build        # Build for production
npm run build:watch  # Build in watch mode

Test

npm test            # Run tests
npm run test:watch  # Run tests in watch mode
npm run test:coverage # Run with coverage

License

MIT License - see LICENSE file for details.