@sharpee/if-domain
v0.9.92
Published
Core domain model and contracts for Sharpee Interactive Fiction Platform
Maintainers
Readme
@sharpee/if-domain
Core domain model and contracts for the Sharpee Interactive Fiction Platform.
Overview
This package contains the shared domain types, events, and contracts that define the Interactive Fiction domain model. It serves as the single source of truth for domain concepts used across the Sharpee platform.
Contents
Events (events.ts)
IFEvents- Standard interactive fiction event constantsIFEventType- Type-safe event typeIFEventCategory- Event categorization for filtering and handling
Contracts (contracts.ts)
EventHandler- Function type for handling eventsEventValidator- Function type for validating eventsEventPreviewer- Function type for previewing event effectsWorldChange- Interface for world state changesProcessedEvents- Result of event processingProcessorOptions- Event processing configuration
Changes (changes.ts)
WorldChangeType- Types of world state changesContentsOptions- Options for querying entity contentsFindOptions- Options for finding entitiesWorldConfig- World behavior configurationWorldState- World state storage interface
Sequencing (sequencing.ts)
TurnPhase- Phases of turn executionEventSequence- Sequencing information for eventsSequencedEvent- Event with sequence informationEventSequencer- Interface for event sequencing
Usage
import { IFEvents, EventHandler, WorldChange } from '@sharpee/if-domain';
// Use event constants
const moveEvent = {
type: IFEvents.ACTOR_MOVED,
// ...
};
// Implement event handlers
const handleMove: EventHandler = (event, world) => {
// Handle the event
};Design Principles
- Domain-Driven Design: All types represent domain concepts, not technical implementations
- Single Source of Truth: Event constants and core types defined once
- No Implementation: Pure type definitions with no runtime code (except constants)
- Minimal Dependencies: Only depends on @sharpee/core for base types
Dependencies
@sharpee/core- Core semantic event types
Build Order
This package must be built after core but before:
world-modelevent-processorenginestdlib
