Kaizen
Browse modulesTenancyInterfaces

Interface: TenancyConfig

Defined in: server/tenancy/client.ts:31

Per-consumer tenancy wiring. The consumer supplies these once (schema-specific names + the list of tenant-scoped models); the module is otherwise generic.

  • tenantColumn — the Prisma field (camelCase, e.g. "organizationId") the app-layer belt injects into read wheres. Distinct from RlsConfig.tenantDbColumn — the underlying DB column (snake_case, "organization_id") the RLS policies key on. They are the same logical column named at two layers; wire both to match your schema.
  • models — the tenant-scoped Prisma schema model names (PascalCase, e.g. "Permit"). Must match what $allOperations receives — not the camelCase client delegate (prisma.permit). Same convention as withAudit's AUDIT_FIELDS_BY_MODEL keys ("Rules", "Organization", …).
  • currentTenantGuc / publicReadGuc — the Postgres GUCs the RLS policies read (e.g. "app.current_org" / "app.public_read").

Extends

Properties

currentTenantGuc

readonly currentTenantGuc: string;

Defined in: server/tenancy/client.ts:26

Inherited from

TenantTransactionConfig.currentTenantGuc


models

readonly models: ReadonlySet<string>;

Defined in: server/tenancy/client.ts:33


publicReadGuc

readonly publicReadGuc: string;

Defined in: server/tenancy/client.ts:27

Inherited from

TenantTransactionConfig.publicReadGuc


resolveBinding?

readonly optional resolveBinding?: () => TenantBinding | undefined;

Defined in: server/tenancy/client.ts:48

How the ambient tenant binding is resolved. Defaults to this module's own ALS (runWithTenant / getTenantBinding).

A consumer that already owns a request-scoped tenant context supplies its own resolver rather than adopting a second, parallel ALS. Without this seam such a consumer gets an empty GUC on every read — RLS then fails closed and every query silently returns zero rows.

This resolver is intentionally limited to the Prisma read-scope belt and RLS transaction. Consumers retaining their own context must also source write tenant ids and audit actor ids from that context; the context helpers exported by this module continue to read this module's ALS.

Returns

TenantBinding | undefined

Overrides

TenantTransactionConfig.resolveBinding


tenantColumn

readonly tenantColumn: string;

Defined in: server/tenancy/client.ts:32

On this page