---
title: "Types"
description: "Public TypeScript types for logs, queries, reliability, adapters, and request context."
---

> Documentation Index
> Fetch the complete documentation index at: https://logbun-docs.abshahin.workers.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

Exported from `logbun`.

## Primitives

```ts
type DurabilityMode = 'volatile' | 'durable';
type QueueFullBehavior = 'dlq' | 'drop';
type TenancyMode = 'single_database' | 'database_per_tenant';
```

## Log shapes

```ts
interface LogbunLogInput<TAction extends string = string> {
  tenantId?: string;
  actorId: string;
  action: TAction;
  entityId?: string;
  oldValues?: Record<string, unknown>;
  newValues?: Record<string, unknown>;
  metadata?: Record<string, unknown>;
}

interface LogbunLog<TAction extends string = string> extends LogbunLogInput<TAction> {
  id: string;          // UUIDv7 (RFC 9562 via Web Crypto)
  createdAt: string;   // ISO 8601 UTC (generated by the library)
  ipAddress?: string;  // Injected by framework plugins
  userAgent?: string;
  prevHash?: string;
  contentHash?: string;
}
```

`id` is time-sortable. Query order is newest-first by `id`.

## Query

```ts
interface LogbunQueryFilters<TAction extends string = string> {
  action?: TAction;
  actorId?: string;
  entityId?: string;
  startDate?: string; // ISO 8601
  endDate?: string;
}

interface LogbunQueryResult<TAction extends string = string> {
  logs: LogbunLog<TAction>[];
  nextCursor: string | null; // last row id, or null if no more pages
}
```

## Request context

Structural and runtime-neutral. Plugins populate it; you can pass it to `fire` / `fireAsync` yourself.

```ts
interface LogbunRequestContext {
  ipAddress?: string;
  userAgent?: string;
  waitUntil?: (task: Promise<unknown>) => void;
  resolveTenantId?: () => string | undefined;
}
```

Hono passes an execution context’s `waitUntil` without exporting Cloudflare types from the root package.

## Reliability

See [Reliability](/reference/reliability) for `ReliabilityAdapter`, `DLQEntry`, `ClaimedDlqBatch`, `JournalRecoveryResult`, `ReliabilityStats`, and `DlqState`.

## Destination

See [Custom adapter](/guides/custom-adapter) for `IAdapter`.

## `ENTERPRISE_DEFAULTS`

```ts
const ENTERPRISE_DEFAULTS = {
  mode: 'durable' as const,
  requireTenantId: true,
} as const;
```

Source: https://logbun-docs.abshahin.workers.dev/reference/types/index.mdx
