2.77.0 • Published 8 months ago

@legalflow/types v2.77.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@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/
│   ├── 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 } from '@legalflow/types';

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

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

2.77.0

8 months ago

2.76.0

8 months ago

2.75.0

8 months ago

2.74.0

8 months ago

2.73.0

8 months ago

2.72.0

8 months ago

2.71.0

8 months ago

2.70.0

8 months ago

2.69.0

8 months ago

2.68.0

8 months ago

2.67.0

8 months ago

2.66.0

8 months ago

2.65.0

9 months ago

2.64.0

9 months ago

2.63.0

9 months ago

2.62.0

9 months ago

2.61.0

9 months ago

2.60.0

9 months ago

2.59.0

9 months ago

2.58.0

9 months ago

2.57.0

9 months ago

2.56.0

9 months ago

2.55.0

9 months ago

2.54.0

9 months ago

2.53.0

9 months ago

2.52.0

9 months ago

2.51.0

9 months ago

2.50.0

9 months ago

2.49.0

9 months ago

2.48.0

9 months ago

2.47.0

9 months ago

2.46.0

9 months ago

2.45.0

9 months ago

2.44.0

9 months ago

2.43.0

9 months ago

2.42.0

9 months ago

2.41.0

9 months ago

2.40.0

9 months ago

2.39.0

9 months ago

2.38.0

9 months ago

2.37.0

9 months ago

2.36.0

9 months ago

2.35.0

9 months ago

2.34.0

9 months ago

2.33.0

9 months ago

2.32.0

9 months ago

2.31.0

9 months ago

2.30.0

10 months ago

2.29.0

10 months ago

2.28.0

10 months ago

2.27.0

10 months ago

2.26.0

10 months ago

2.25.0

10 months ago

2.24.0

10 months ago

2.23.0

10 months ago

2.21.0

10 months ago

2.20.0

10 months ago

2.19.0

10 months ago

2.18.0

10 months ago

2.17.0

10 months ago

2.16.0

10 months ago

2.15.0

10 months ago

2.14.0

10 months ago

2.13.0

10 months ago

2.12.0

10 months ago

2.11.0

10 months ago

2.10.0

10 months ago

2.9.0

10 months ago

2.8.0

10 months ago

2.7.0

10 months ago

2.6.0

10 months ago

2.5.0

10 months ago

2.4.1

10 months ago

2.4.0

10 months ago

2.3.0

10 months ago

2.2.0

10 months ago

2.1.0

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago