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

titanic-expedition

v0.1.1

Published

Mode-aware schema projection for TypeScript, inspired by pydantic-extension.

Readme

titanic-expedition

titanic-expedition is a TypeScript library for mode-aware schema projection.

It is inspired by the core idea behind pydantic-extension:

one domain model, many policy-aware projections.

Instead of duplicating UserPublic, UserInternal, and UserLLM, you define one schema and project it into safe modes.

Why this exists

Most stacks handle exposure late:

  • database stores everything
  • backend models know everything
  • API DTOs filter later
  • prompt builders filter ad hoc

That is how leaks happen.

This library moves projection closer to the schema definition itself.

Features

  • one schema, many modes
  • runtime validation via Zod
  • mode-specific parsing and dumping
  • nested object and array projection
  • optional and nullable fields
  • union support
  • generated TypeScript inference through InferMode

Install

npm install zod
npm install -D typescript vitest

If you want to use this package itself once published:

npm install titanic-expedition zod

Quick start

import { expedition, type InferMode } from 'titanic-expedition';

const Alien = expedition.object({
  species: expedition.string().modes(['public', 'llm', 'internal']),
  planet: expedition.string().modes(['public', 'llm', 'internal']),
  invasionPlan: expedition.string().modes(['internal']),
  diplomaticSummary: expedition.string().modes(['llm', 'internal']).optional()
}).modes(['public', 'llm', 'internal']);

type PublicAlien = InferMode<typeof Alien, 'public'>;
type LLMAlien = InferMode<typeof Alien, 'llm'>;
type InternalAlien = InferMode<typeof Alien, 'internal'>;

const raw = {
  species: 'Xylar',
  planet: 'Zebulon',
  invasionPlan: 'Take over Earth',
  diplomaticSummary: 'Harmless envoy cover story'
};

const publicAlien = Alien.dump(raw, 'public');
const llmAlien = Alien.dump(raw, 'llm');
const internalAlien = Alien.dump(raw, 'internal');

Result

publicAlien
// { species: 'Xylar', planet: 'Zebulon' }

llmAlien
// {
//   species: 'Xylar',
//   planet: 'Zebulon',
//   diplomaticSummary: 'Harmless envoy cover story'
// }

internalAlien
// {
//   species: 'Xylar',
//   planet: 'Zebulon',
//   invasionPlan: 'Take over Earth',
//   diplomaticSummary: 'Harmless envoy cover story'
// }

Development setup

Requirements

  • Node.js 20+
  • npm 10+ recommended

Local install

npm install

Run tests

npm test

Watch tests

npm run test:watch

Type-check only

npm run typecheck

Build

npm run build

Package check

npm pack

API overview

Primitive builders

expedition.string()
expedition.number()
expedition.boolean()
expedition.bigint()
expedition.date()
expedition.unknown()
expedition.literal('x')
expedition.enum(['a', 'b'])
expedition.fromZod(z.string().min(1))

Composition

expedition.object({ ... })
expedition.array(node)
expedition.union([a, b])

Mode assignment

expedition.string().modes(['public', 'internal'])

Modifiers

expedition.string().modes(['public']).optional()
expedition.string().modes(['internal']).nullable()
expedition.object({ ... }).modes(['public']).array()

Parse and dump

schema.parse(input, 'public')
schema.safeParse(input, 'public')
schema.dump(input, 'public')
schema.project('public')

Design notes

This is not a literal transpilation of Python internals.

It is a native TypeScript reimplementation of the same semantic goal:

  • single domain declaration
  • projection at the model boundary
  • consistent runtime validation
  • safer outputs for APIs, logs, UIs, and LLM prompts

Repository layout

src/
  index.ts
examples/
  alien.ts
tests/
  basic.test.ts

Limitations in this starter version

This starter implementation is intentionally small. It does not yet include:

  • role-based policies beyond simple modes
  • schema export helpers for OpenAPI / JSON Schema
  • discriminated union helpers
  • field-level audit explanations for why a field was excluded
  • transform / refine pass-through helpers for every Zod API surface

Those are good next steps for a v2.