Files
property-management-network/types/index.ts
T
Leon SerfatyandClaude Opus 4.8 857b9a7811 Initial import: property management SaaS + security hardening + admin dashboard
Property Management Network — Next.js 16 (App Router), Better Auth,
Drizzle ORM over PostgreSQL, Stripe, OpenAI, Resend.

Includes:
- Security hardening: access-control/IDOR fixes, TLS-by-default DB layer,
  constant-time cron auth, strict security headers, atomic AI quota gating,
  HTML/email output encoding, demo-backdoor disabled in production.
- Superadmin dashboard at /admin (overview/MRR, server-paginated users with
  ban/impersonate/plan/delete, billing, platform activity + admin audit log,
  AI usage, system health) via the Better Auth admin plugin.
- Seed/migration utility scripts under scripts/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 20:36:07 -04:00

85 lines
3.1 KiB
TypeScript

import type * as schema from "@/lib/db/schema"
// ── Table row types (inferred from the Drizzle schema) ───────────
export type Profile = typeof schema.profiles.$inferSelect
export type Property = typeof schema.properties.$inferSelect
export type Unit = typeof schema.units.$inferSelect
export type Tenant = typeof schema.tenants.$inferSelect
export type RentPayment = typeof schema.rent_payments.$inferSelect
export type MaintenanceRequest = typeof schema.maintenance_requests.$inferSelect
export type Lease = typeof schema.leases.$inferSelect
export type Expense = typeof schema.expenses.$inferSelect
export type Document = typeof schema.documents.$inferSelect
export type Notification = typeof schema.notifications.$inferSelect
export type UsageEvent = typeof schema.usage_events.$inferSelect
export type Vendor = typeof schema.vendors.$inferSelect
export type Inspection = typeof schema.inspections.$inferSelect
// ── Insert types ─────────────────────────────────────────────────
export type PropertyInsert = typeof schema.properties.$inferInsert
export type UnitInsert = typeof schema.units.$inferInsert
export type TenantInsert = typeof schema.tenants.$inferInsert
export type RentPaymentInsert = typeof schema.rent_payments.$inferInsert
export type MaintenanceRequestInsert = typeof schema.maintenance_requests.$inferInsert
export type LeaseInsert = typeof schema.leases.$inferInsert
export type ExpenseInsert = typeof schema.expenses.$inferInsert
export type DocumentInsert = typeof schema.documents.$inferInsert
// ── Plan types ───────────────────────────────────────────────────
export type Plan = "starter" | "pro" | "landlord" | "lifetime"
export interface PlanLimits {
maxProperties: number
maxTenants: number
maxAiCalls: number
maxStorageMB: number
hasTeamAccess: boolean
hasWhiteLabel: boolean
}
// ── UI types ─────────────────────────────────────────────────────
export interface DashboardStats {
totalProperties: number
totalUnits: number
occupiedUnits: number
vacantUnits: number
occupancyRate: number
rentCollectedThisMonth: number
rentCollectedLastMonth: number
rentPendingThisMonth: number
rentOverdue: number
openMaintenanceRequests: number
expiringLeases: number // within 60 days
}
export interface PropertyWithUnits extends Property {
units: Unit[]
occupiedCount: number
vacantCount: number
}
export interface TenantWithDetails extends Tenant {
unit?: Unit | null
property?: Property | null
latestLease?: Lease | null
latestPayment?: RentPayment | null
}
export interface RentPaymentWithTenant extends RentPayment {
tenant: Tenant
property: Property
unit?: Unit | null
}
export interface MaintenanceWithDetails extends MaintenanceRequest {
tenant?: Tenant | null
property: Property
unit?: Unit | null
}
export interface NavItem {
label: string
href: string
icon: string
}