@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.

v0.29.34Core FoundationESMZero Runtime

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

bash
pnpm add @happyvertical/smrt-types

Note: You rarely need to install this directly. It's a transitive dependency of every @happyvertical/smrt-* package.

Exports

FileTypes
signals.tsSignal, SignalType, SignalAdapter -- universal signaling system
module.tsSmrtModuleMeta, ModuleUISlot, ModuleComponentType -- module registration and admin UI slots
user.tsUserStatus, TenantStatus, MembershipStatus, SessionStatus, OverrideEffect, TenantPermissionEffect -- lifecycle/permission status enums (runtime values)
ai-usage.tsAiTokenUsage, AiUsageSnapshot, AiUsageStats, SmrtAiUsageEvent, SmrtAiUsageRecord (and related options types) -- AI token-usage accounting
knowledge.tsDomainKnowledgeConfig, DomainKnowledgeManifest, DomainKnowledgeObject, DomainKnowledgeSurface -- domain knowledge surfaces
routes.tsSmrtRouteDefinition, 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:

typescript
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:

typescript
import {
  UserStatus,
  TenantStatus,
  MembershipStatus,
  SessionStatus,
  OverrideEffect,
  TenantPermissionEffect,
} from '@happyvertical/smrt-types';

const status = UserStatus.ACTIVE; // OK at runtime

Signal Types

The Signal family models the framework's universal signaling system. Adapters in downstream packages (logging, metrics, pub/sub, tracing) consume these signals.

typescript
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):

typescript
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 type for non-enum exports. Use a regular import only for enums.
  • Add shared types here if two or more packages need the same definition -- don't duplicate them in smrt-core.

Next Steps