@happyvertical/smrt-types
Shared TypeScript types and enums for the SMRT framework. Prevents circular dependencies between packages by centralizing types that more than one package needs. Zero runtime code except for enums.
Overview
@happyvertical/smrt-types is a small, dependency-free package that exists to keep
shared types out of smrt-core and break the circular dependencies that would otherwise
form between domain packages. If two or more packages need the same type, it lives here.
The package ships zero runtime code except enums -- everything else is erased by the TypeScript compiler.
Installation
pnpm add @happyvertical/smrt-typesNote: You rarely need to install this directly. It's a transitive dependency
of every @happyvertical/smrt-* package.
Exports
| File | Types |
|---|---|
signals.ts | Signal, SignalType, SignalAdapter -- universal signaling
system |
module.ts | SmrtModuleMeta, ModuleUISlot, ModuleComponentType -- module registration and admin UI slots |
user.ts | UserStatus, TenantStatus, MembershipStatus, SessionStatus, OverrideEffect, TenantPermissionEffect -- lifecycle/permission status enums (runtime values) |
ai-usage.ts | AiTokenUsage, AiUsageSnapshot, AiUsageStats, SmrtAiUsageEvent, SmrtAiUsageRecord (and related options types)
-- AI token-usage accounting |
knowledge.ts | DomainKnowledgeConfig, DomainKnowledgeManifest, DomainKnowledgeObject, DomainKnowledgeSurface -- domain knowledge
surfaces |
routes.ts | SmrtRouteDefinition, SmrtRouteModule, SmrtRouteNavigationItem, SmrtRouteNavigationMeta -- route definition
and navigation metadata |
Usage
Type-only imports (Signal, Module)
For the type-only exports, always use import type so the bundler can drop them completely:
import type {
Signal,
SignalType,
SignalAdapter,
} from '@happyvertical/smrt-types';
import type {
SmrtModuleMeta,
ModuleUISlot,
ModuleComponentType,
ModuleUIBaseProps,
ModuleUIRegistryInterface,
} from '@happyvertical/smrt-types';Enum imports (User, Tenant, Membership, Session)
Status enums have runtime values, so use a regular import:
import {
UserStatus,
TenantStatus,
MembershipStatus,
SessionStatus,
OverrideEffect,
TenantPermissionEffect,
} from '@happyvertical/smrt-types';
const status = UserStatus.ACTIVE; // OK at runtimeSignal Types
The Signal family models the framework's universal signaling system. Adapters in downstream
packages (logging, metrics, pub/sub, tracing) consume these signals.
import type { Signal, SignalType, SignalAdapter } from '@happyvertical/smrt-types';
// Lifecycle stages for a tracked method execution
type SignalType = 'start' | 'step' | 'end' | 'error';
// Adapter contract -- implement this in your logging/metrics/tracing layer
class MyAdapter implements SignalAdapter {
async handle(signal: Signal): Promise<void> {
// Errors are caught by the signal bus, but it's good practice to log them yourself
}
}Module UI Types
Used by packages that register admin-panel UI slots (e.g. smrt-svelte, smrt-users):
import type {
SmrtModuleMeta,
ModuleUISlot,
ModuleComponentType,
ModuleUIBaseProps,
ModuleUIRegistryInterface,
} from '@happyvertical/smrt-types';Rules
- Zero runtime code -- only type definitions and enums live here. No implementations, no classes, no constants beyond enum members.
- Always
import typefor non-enum exports. Use a regularimportonly for enums. - Add shared types here if two or more packages need the same definition --
don't duplicate them in
smrt-core.