UNPKG

@invoicing-sdk/domain

Version:

Core domain logic for the invoicing system including entities, value objects, services, and events

80 lines (59 loc) 1.91 kB
# Invoicing SDK: Domain Layer Core domain logic for the invoicing system following Domain-Driven Design (DDD) principles. ## Overview This package contains the pure business logic of the invoicing system, including: - **Entities**: Core business objects like Invoice - **Value Objects**: Immutable objects like Money, CustomerInfo, OrderItem - **Domain Services**: Business logic that doesn't belong to a specific entity - **Domain Events**: Events that represent important business occurrences - **Policies**: Business rules and constraints - **Types**: Shared type definitions ## Features - Pure domain logic with no external dependencies - TypeScript-first with full type safety - Domain events for decoupled communication - Rich value objects for data integrity - Comprehensive business rule validation ## Installation ```bash npm install @invoicing-sdk/domain # or pnpm add @invoicing-sdk/domain # or bun add @invoicing-sdk/domain ``` ## Usage ```typescript import { Invoice, Money, CustomerInfo } from '@invoicing-sdk/domain' // Create value objects const amount = new Money(100, 'EUR') const customer = new CustomerInfo({ name: 'John Doe', email: 'john@example.com', address: '123 Main St' }) // Work with domain entities const invoice = new Invoice({ customerId: 'customer-123', items: [/* order items */], // ... other properties }) ``` ## Architecture This package follows Domain-Driven Design principles: - **Entity**: Objects with identity that can change over time - **Value Object**: Immutable objects defined by their attributes - **Domain Service**: Stateless services that implement business logic - **Domain Event**: Events that capture business-relevant occurrences - **Policy**: Business rules and constraints ## Development ```bash # Build the package pnpm build # Watch for changes during development pnpm dev # Run tests pnpm test ``` ## License MIT