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

@legalflow/types

v3.0.2

Published

Domain-driven TypeScript types for LegalFlow services

Readme

@legalflow/types

A domain-driven TypeScript type library for LegalFlow services with clear schema boundaries.

Purpose

This package provides a clean, domain-driven type system for all LegalFlow database schemas, with:

  • Schema-based organization: Types grouped by database schema
  • Clear boundaries: Database types stay in snake_case, conversion happens in services
  • No transformations: Pure type definitions without service-specific logic
  • No duplication: Single source of truth for all database types
  • Consistent naming: Predictable type patterns across all domains

Structure

src/
├── generated/          # Auto-generated files
│   ├── database.ts     # Database type definitions (from Supabase)
│   └── constants.ts    # Auto-generated schema/table constants
├── domains/            # Domain-specific types organized by schema
│   ├── analysis/
│   ├── assistant/
│   ├── compliance/
│   ├── core/
│   ├── documents/
│   ├── integrations/
│   ├── logs/
│   ├── sales/
│   └── telephony/
├── shared/             # Truly shared types
│   ├── constants.ts    # Shared constants
│   ├── enums.ts        # Shared enums
│   └── primitives.ts   # Shared primitive types
├── utils/              # Utilities
│   └── schema-helpers.ts # Type utilities
└── index.ts            # Domain-based exports

Installation

npm install @legalflow/types

Usage

Domain-Based Imports

Import types from specific domains:

import { Sales, Documents, Core, Logs } from '@legalflow/types';

// Access types from specific domains
const deal: Sales.Deal = { /* ... */ };
const user: Core.User = { /* ... */ };
const doc: Documents.DocumentMetadata = { /* ... */ };
const error: Logs.ErrorLog = { /* ... */ };

Schema & Table References

Type-safe schema and table constants:

import { Schema, Table, getTableRef } from '@legalflow/types';

// Reference schemas and tables in a type-safe way
const { schema, table } = getTableRef(Schema.SALES, Table.Sales.DEALS);
// Result: { schema: 'sales', table: 'deals' }

// Use in Supabase queries
await supabase.schema(schema).from(table).select('*');

Case Convention

This library follows a strict case convention approach:

  1. Database Types: All types are in snake_case to match the database

    // Database type with snake_case properties
    const deal: Sales.Deal = {
      id: 123,
      client_id: 456,
      deal_name: 'Example Deal',
      created_at: new Date().toISOString()
    };
  2. Case Conversion: Should happen at service boundaries

    // In your service layer
    import { snakeToCamel } from 'case-anything';
       
    // Convert at DB boundary
    const dealDto = snakeToCamel(deal);
    // Result: { id: 123, clientId: 456, dealName: 'Example Deal', createdAt: '...' }

Type Pattern

Each domain follows a consistent type pattern:

// Row types (database rows)
export type Deal = SalesSchema['deals']['Row'];

// Insert types (for creating new records)
export type DealInsert = SalesSchema['deals']['Insert'];

// Update types (for updating existing records)
export type DealUpdate = SalesSchema['deals']['Update'];

Contributing

When modifying this package:

  1. Maintain schema organization: Keep domain types in correct schema folders
  2. Avoid service logic: No transformations or mappings in this package
  3. Preserve case conventions: Keep database types in snake_case
  4. Test thoroughly: Ensure types work correctly in consuming services

License

MIT