Classes

c
ColumnPerTenant(columnName?: string)

Isolates tenants by stamping a tenant column on every row.

c
DatabasePerTenant(prefix?: string)

Isolates tenants by assigning each a separate database.

c
HeaderResolver(options?: HeaderResolverOptions)

Resolves the tenant id from an HTTP header.

c
JwtResolver(options:
JwtResolverOptions
& { decode: (token: string) => Record<string, unknown> | null; }
)

Resolves the tenant id from a claim in an unverified JWT payload.

c
MemoryTenantDataStore(options?: MemoryTenantDataStoreOptions)

A zero-dependency in-memory ITenantDataStore that partitions rows by strategy-derived scope ('column' → tenantId, 'schema' → resolved schema, 'database' → resolved database).

c
PathResolver(options?: PathResolverOptions)

Resolves the tenant id from a segment of request.path.

c
SchemaPerTenant(prefix?: string)

Isolates tenants by assigning each a separate database schema.

c
SubdomainResolver(options?: SubdomainResolverOptions)

Resolves the tenant id from the first subdomain label of request.url.

c
TenantNotResolvedError(message?: string)

Thrown by IMultiTenancyService.getRepository when no tenant is resolved in the request context.

Functions

f
getTenantCachePrefix(ctx: { state: Map<string, unknown>; }): string | undefined

Exported accessor that reads the cache-prefix stamped into ctx.state by the middleware. Consumers never hardcode the state key string.

f
tenantMiddleware(arg_0: TenantMiddlewareOptions): MiddlewareFunction

Factory that creates a middleware function resolving the tenant and attaching it to ctx.request.tenant.

Interfaces

I
HeaderResolverOptions

Options for HeaderResolver.

I
IMultiTenancyService

Multi-tenancy service — exposes tenant context, repository creation, and cache-key helpers.

I
ITenant

A resolved tenant.

I
ITenantDataStore

Tenant-scoped data-store port.

I
ITenantRepository

Tenant-scoped repository — delegates CRUD to the data store the multi-tenancy plugin was configured with (ITenantDataStore, declared in that plugin), while threading the resolved tenant id.

I
ITenantResolver

Resolves the tenant for an incoming request (by subdomain, header, path, or JWT claim, depending on the implementation).

I
JwtResolverOptions

Options for JwtResolver.

I
MemoryTenantDataStoreOptions

Options passed to the MemoryTenantDataStore constructor.

  • generateId: () => string

    Generate a unique identifier for new records when data.id is not a string or number. Defaults to a monotonic counter ('1', '2', …).

I
MultiTenancyPluginOptions

Top-level options for MultiTenancyPlugin.

I
PathResolverOptions

Options for PathResolver.

I
SubdomainResolverOptions

Options for SubdomainResolver.

I
TenantCacheOptions

Options for cache-prefix stamping.

Type Aliases

Variables

v
CAPABILITIES: { RUNTIME: string; LOGGER: string; CONFIG: string; VALIDATION: string; DATABASE: string; CACHE: string; EVENTS: string; MESSAGING: string; AUTH: string; AUTHORIZATION: string; JWT: string; SCHEDULER: string; METRICS: string; HEALTH: string; OPENAPI: string; TELEMETRY: string; SECRETS: string; AUDIT: string; RESILIENCE: string; STORAGE: string; MAIL: string; NOTIFICATION: string; FEATURE_FLAGS: string; QUEUE: string; CQRS: string; COMMAND_BUS: string; QUERY_BUS: string; MULTI_TENANCY: string; WORKER_POOL: string; DI_CONTAINER: string; HTTP_ADAPTER: string; SSE: string; WEBSOCKET: string; REALTIME_BACKPLANE: string; SSR: string; SESSION: string; SERVICE_DISCOVERY: string; HEALTH_INDICATOR: string; METRIC_REGISTRATION: string; OPENAPI_SCHEMA: string; CLI_COMMAND: string; DECORATOR_HANDLER: string; METADATA_STORE: string; GRPC: string; CLOUDFLARE: string; GRAPHQL: string; STATIC_FILES: string; VIEW: string; }

Standard capability tokens provided by the first-party plugins.

v
TENANT_CACHE_PREFIX_STATE_KEY: "multi-tenancy-plugin:cache-prefix"

State key for the cache prefix — consumers should use getTenantCachePrefix instead of reading this directly.