ObjectStackObjectStack

Tenant

Tenant protocol schemas

Tenant Schema (Multi-Tenant Architecture)

Defines the tenant/tenancy model for ObjectStack SaaS deployments. Supports different levels of data isolation to meet varying security, performance, and compliance requirements.

Isolation Levels:

  • shared_schema: All tenants share the same database and schema (row-level isolation)
  • isolated_schema: Tenants have separate schemas within a shared database
  • isolated_db: Each tenant has a completely separate database

Source: packages/spec/src/system/tenant.zod.ts

TypeScript Usage

import { DatabaseLevelIsolationStrategySchema, DatabaseProviderSchema, QuotaEnforcementResultSchema, RowLevelIsolationStrategySchema, SchemaLevelIsolationStrategySchema, TenantSchema, TenantConnectionConfigSchema, TenantIsolationConfigSchema, TenantIsolationLevel, TenantQuotaSchema, TenantSecurityPolicySchema, TenantUsageSchema } from '@objectstack/spec/system';
import type { DatabaseLevelIsolationStrategy, DatabaseProvider, QuotaEnforcementResult, RowLevelIsolationStrategy, SchemaLevelIsolationStrategy, Tenant, TenantConnectionConfig, TenantIsolationConfig, TenantIsolationLevel, TenantQuota, TenantSecurityPolicy, TenantUsage } from '@objectstack/spec/system';

// Validate data
const result = DatabaseLevelIsolationStrategySchema.parse(data);

DatabaseLevelIsolationStrategy

Properties

PropertyTypeRequiredDescription
strategy'isolated_db'Database-level isolation strategy
database{ namingPattern: string; serverStrategy: Enum<'shared' | 'sharded' | 'dedicated'>; separateCredentials: boolean; autoCreateDatabase: boolean }optionalDatabase configuration
connectionPool{ poolSize: integer; maxActivePools: integer; idleTimeout: integer; usePooler: boolean }optionalConnection pool configuration
backup{ strategy: Enum<'individual' | 'consolidated' | 'on_demand'>; frequencyHours: integer; retentionDays: integer }optionalBackup configuration
encryption{ perTenantKeys: boolean; algorithm: string; keyManagement?: Enum<'aws_kms' | 'azure_key_vault' | 'gcp_kms' | 'hashicorp_vault' | 'custom'> }optionalEncryption configuration

DatabaseProvider

Database provider for tenant data

Allowed Values

  • turso
  • postgres
  • memory

QuotaEnforcementResult

Quota enforcement check result

Properties

PropertyTypeRequiredDescription
allowedbooleanWhether the operation is within quota
exceededQuotastringoptionalName of the exceeded quota
currentUsagenumberoptionalCurrent usage value
limitnumberoptionalQuota limit
messagestringoptionalHuman-readable quota message

RowLevelIsolationStrategy

Properties

PropertyTypeRequiredDescription
strategy'shared_schema'Row-level isolation strategy
database{ enableRLS: boolean; contextMethod: Enum<'session_variable' | 'search_path' | 'application_name'>; contextVariable: string; applicationValidation: boolean }optionalDatabase configuration
performance{ usePartialIndexes: boolean; usePartitioning: boolean; poolSizePerTenant?: integer }optionalPerformance settings

SchemaLevelIsolationStrategy

Properties

PropertyTypeRequiredDescription
strategy'isolated_schema'Schema-level isolation strategy
schema{ namingPattern: string; includePublicSchema: boolean; sharedSchema: string; autoCreateSchema: boolean }optionalSchema configuration
migrations{ strategy: Enum<'parallel' | 'sequential' | 'on_demand'>; maxConcurrent: integer; rollbackOnError: boolean }optionalMigration configuration
performance{ poolPerSchema: boolean; schemaCacheTTL: integer }optionalPerformance settings

Tenant

Properties

PropertyTypeRequiredDescription
idstringUnique tenant identifier
namestringTenant display name
isolationLevelEnum<'shared_schema' | 'isolated_schema' | 'isolated_db'>
databaseProviderEnum<'turso' | 'postgres' | 'memory'>optionalDatabase provider
connectionConfig{ url: string; authToken?: string; group?: string }optionalDatabase connection config
provisioningStatusEnum<'provisioning' | 'active' | 'suspended' | 'failed' | 'destroying'>optionalCurrent provisioning lifecycle status
planEnum<'free' | 'pro' | 'enterprise'>optionalSubscription plan
customizationsRecord<string, any>optionalCustom configuration values
quotas{ maxUsers?: integer; maxStorage?: integer; apiRateLimit?: integer; maxObjects?: integer; … }optional

TenantConnectionConfig

Tenant database connection configuration

Properties

PropertyTypeRequiredDescription
urlstringDatabase connection URL
authTokenstringoptionalDatabase auth token (encrypted at rest)
groupstringoptionalTurso database group name

TenantIsolationConfig

Union Options

This schema accepts one of the following structures:

Option 1

Properties

PropertyTypeRequiredDescription
strategy'shared_schema'Row-level isolation strategy
database{ enableRLS: boolean; contextMethod: Enum<'session_variable' | 'search_path' | 'application_name'>; contextVariable: string; applicationValidation: boolean }optionalDatabase configuration
performance{ usePartialIndexes: boolean; usePartitioning: boolean; poolSizePerTenant?: integer }optionalPerformance settings

Option 2

Properties

PropertyTypeRequiredDescription
strategy'isolated_schema'Schema-level isolation strategy
schema{ namingPattern: string; includePublicSchema: boolean; sharedSchema: string; autoCreateSchema: boolean }optionalSchema configuration
migrations{ strategy: Enum<'parallel' | 'sequential' | 'on_demand'>; maxConcurrent: integer; rollbackOnError: boolean }optionalMigration configuration
performance{ poolPerSchema: boolean; schemaCacheTTL: integer }optionalPerformance settings

Option 3

Properties

PropertyTypeRequiredDescription
strategy'isolated_db'Database-level isolation strategy
database{ namingPattern: string; serverStrategy: Enum<'shared' | 'sharded' | 'dedicated'>; separateCredentials: boolean; autoCreateDatabase: boolean }optionalDatabase configuration
connectionPool{ poolSize: integer; maxActivePools: integer; idleTimeout: integer; usePooler: boolean }optionalConnection pool configuration
backup{ strategy: Enum<'individual' | 'consolidated' | 'on_demand'>; frequencyHours: integer; retentionDays: integer }optionalBackup configuration
encryption{ perTenantKeys: boolean; algorithm: string; keyManagement?: Enum<'aws_kms' | 'azure_key_vault' | 'gcp_kms' | 'hashicorp_vault' | 'custom'> }optionalEncryption configuration


TenantIsolationLevel

Allowed Values

  • shared_schema
  • isolated_schema
  • isolated_db

TenantQuota

Properties

PropertyTypeRequiredDescription
maxUsersintegeroptionalMaximum number of users
maxStorageintegeroptionalMaximum storage in bytes
apiRateLimitintegeroptionalAPI requests per minute
maxObjectsintegeroptionalMaximum number of custom objects
maxRecordsPerObjectintegeroptionalMaximum records per object
maxDeploymentsPerDayintegeroptionalMaximum deployments per day
maxStorageBytesintegeroptionalMaximum storage in bytes

TenantSecurityPolicy

Properties

PropertyTypeRequiredDescription
encryption{ atRest: boolean; inTransit: boolean; fieldLevel: boolean }optionalEncryption requirements
accessControl{ requireMFA: boolean; requireSSO: boolean; ipWhitelist?: string[]; sessionTimeout: integer }optionalAccess control requirements
compliance{ standards?: Enum<'sox' | 'hipaa' | 'gdpr' | 'pci_dss' | 'iso_27001' | 'fedramp'>[]; requireAuditLog: boolean; auditRetentionDays: integer; dataResidency?: object }optionalCompliance requirements

TenantUsage

Current tenant resource usage

Properties

PropertyTypeRequiredDescription
currentObjectCountintegerCurrent number of custom objects
currentRecordCountintegerTotal records across all objects
currentStorageBytesintegerCurrent storage usage in bytes
deploymentsTodayintegerDeployments executed today
currentUsersintegerCurrent number of active users
apiRequestsThisMinuteintegerAPI requests in the current minute
lastUpdatedAtstringoptionalLast usage update time

On this page