@millerbyte/react-logging

Types & Interfaces

Last updated: 1/22/2026

All types are exported from the package root. Import them for type-safe integrations.

import type { 
  ApiActionDto, 
  LoginSessionDto, 
  FilterState,
  PaginatedResponse 
} from "@millerbyte/react-logging";

Data Transfer Objects (DTOs)

LoginSessionDto

Represents a user login session.

interface LoginSessionDto {
  Id?: string;
  SchemaVersion?: number;
  UserId: string;
  TenantId: string;
  LoginTime: IsoDateString;
  LogoutTime?: IsoDateString | null;
  LastActivityTime: IsoDateString;
  IsActive: boolean;
  EndReason?: SessionEndReason;
  ActionCount?: number;
  EnvironmentName?: string;
  Metadata?: Record<string, unknown>;
}

ApiActionDto

Represents a single API request/response log.

interface ApiActionDto {
  Id?: string;
  SchemaVersion?: number;
  SessionId: string;
  UserId?: string;
  TenantId?: string;
  CorrelationId?: string;
  IdempotencyKey?: string;
  TraceId?: string;
  SpanId?: string;
  ParentSpanId?: string;
  TraceState?: string;
  TimeStamp: IsoDateString;
  RequesterInfo?: RequesterInfoDto;
  PayloadInfo?: PayloadInfoDto;
  EndpointInfo?: EndpointInfoDto;
  LogMessages?: string[];
  ResponseInfo?: ResponseInfoDto;
  MachineName?: string;
  EnvironmentName?: string;
  ApiVersion?: string;
  CustomData?: Record<string, unknown>;
}

Nested DTOs

interface RequesterInfoDto {
  IpAddress?: string;
  UserAgent?: string;
  Headers?: Record<string, string>;
  IsAuthenticated?: boolean;
  AuthenticationScheme?: string;
  UserRoles?: string[];
  UserClaims?: string[];
}

interface EndpointInfoDto {
  Controller?: string;
  Action?: string;
  Route?: string;
}

interface PayloadInfoDto {
  Method?: string;
  Body?: unknown;
  QueryParameters?: Record<string, string>;
  RouteParameters?: Record<string, string>;
}

interface ResponseInfoDto {
  StatusCode?: number;
  Body?: unknown;
  DurationMs?: number;
  Exception?: ExceptionInfoDto;
}

interface ExceptionInfoDto {
  Type?: string;
  Message?: string;
  StackTrace?: string;
  InnerException?: ExceptionInfoDto;
}

Filter Types

FilterState

State object for all filter options.

interface FilterState {
  searchText?: string;
  userId?: string;
  tenantId?: string;
  sessionId?: string;
  statusCodes?: number[];
  methods?: string[];
  isActive?: boolean | null;
  dateRange?: DateRange;
}

interface DateRange {
  from?: IsoDateString;
  to?: IsoDateString;
}

FilterConfig

Control which filter inputs are shown.

interface FilterConfig {
  showSearch?: boolean;
  showUserId?: boolean;
  showTenantId?: boolean;
  showSessionId?: boolean;
  showStatusCodes?: boolean;
  showMethods?: boolean;
  showIsActive?: boolean;
  showDateRange?: boolean;
}

Pagination Types

QueryParams

Parameters passed to fetch functions.

interface QueryParams {
  pageIndex: number;
  pageSize: number;
  sorting: SortingState;  // From @tanstack/react-table
  filters: FilterState;
}

PaginatedResponse

Expected response format from server-mode fetch functions.

interface PaginatedResponse<T> {
  data: T[];
  totalCount: number;
  pageIndex: number;
  pageSize: number;
  totalPages: number;
}

Customization Types

DataAdapter

Transform raw API data to DTOs.

interface DataAdapter<TInput, TOutput> {
  toDto: (input: TInput) => TOutput;
}

// Usage
const adapter: DataAdapter<MyRawSession, LoginSessionDto> = {
  toDto: (raw) => ({
    Id: raw.id,
    UserId: raw.user_id,
    TenantId: raw.tenant_id,
    LoginTime: raw.login_time,
    LastActivityTime: raw.last_activity,
    IsActive: raw.active,
    ActionCount: raw.action_count,
  }),
};

Formatters

Custom formatting for display values.

interface Formatters {
  date?: (value: IsoDateString) => string;
  durationMs?: (value?: number) => string;
  number?: (value: number) => string;
}

// Usage
const formatters: Formatters = {
  date: (value) => new Date(value).toLocaleString("en-US"),
  durationMs: (ms) => `${ms ?? 0}ms`,
  number: (n) => n.toLocaleString(),
};

UiStateRenderers

Custom render functions for loading, empty, and error states.

interface UiStateRenderers {
  loading?: () => ReactNode;
  empty?: () => ReactNode;
  error?: (error: unknown) => ReactNode;
}

// Usage
const renderStates: UiStateRenderers = {
  loading: () => <Spinner />,
  empty: () => <EmptyState message="No data found" />,
  error: (err) => <ErrorAlert message={String(err)} />,
};

Label Types

CommonLabels

interface CommonLabels {
  loading: string;
  empty: string;
  error: string;
  retry: string;
}

TableLabels

interface TableLabels extends CommonLabels {
  rowsPerPage: string;
  pageLabel: string;
}

FilterLabels

interface FilterLabels {
  searchPlaceholder: string;
  userId: string;
  tenantId: string;
  sessionId: string;
  statusCodes: string;
  methods: string;
  isActive: string;
  dateFrom: string;
  dateTo: string;
  clearFilters: string;
}

Analytics Types

interface AnalyticsMetrics {
  totalSessions: number;
  activeSessions: number;
  totalActions: number;
  averageSessionDurationMs?: number;
  actionsByStatusCode: Record<string, number>;
  actionsByMethod: Record<string, number>;
  topEndpoints: Array<{ endpoint: string; count: number }>;
  actionsOverTime?: Array<{ date: IsoDateString; count: number }>;
}

Enums

enum SessionEndReason {
  Logout = "Logout",
  Timeout = "Timeout",
  TokenExpired = "TokenExpired",
  ManualClose = "ManualClose",
  SystemShutdown = "SystemShutdown"
}