Files
Horux360/apps/web/lib/api/tenants.ts
Consultoria AS f96a9c55c5 feat(saas): update schema for db-per-tenant and per-component FIEL encryption
- Rename Tenant.schemaName to databaseName across all services
- Add Subscription and Payment models to Prisma schema
- Update FielCredential to per-component IV/tag encryption columns
- Switch FIEL encryption key from JWT_SECRET to FIEL_ENCRYPTION_KEY
- Add Subscription and Payment shared types
- Update JWTPayload to use databaseName

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:15:55 +00:00

55 lines
1.3 KiB
TypeScript

import { apiClient } from './client';
export interface Tenant {
id: string;
nombre: string;
rfc: string;
plan: string;
databaseName: string;
createdAt: string;
_count?: {
users: number;
};
}
export interface CreateTenantData {
nombre: string;
rfc: string;
plan?: 'starter' | 'business' | 'professional' | 'enterprise';
cfdiLimit?: number;
usersLimit?: number;
}
export async function getTenants(): Promise<Tenant[]> {
const response = await apiClient.get<Tenant[]>('/tenants');
return response.data;
}
export async function getTenant(id: string): Promise<Tenant> {
const response = await apiClient.get<Tenant>(`/tenants/${id}`);
return response.data;
}
export async function createTenant(data: CreateTenantData): Promise<Tenant> {
const response = await apiClient.post<Tenant>('/tenants', data);
return response.data;
}
export interface UpdateTenantData {
nombre?: string;
rfc?: string;
plan?: 'starter' | 'business' | 'professional' | 'enterprise';
cfdiLimit?: number;
usersLimit?: number;
active?: boolean;
}
export async function updateTenant(id: string, data: UpdateTenantData): Promise<Tenant> {
const response = await apiClient.put<Tenant>(`/tenants/${id}`, data);
return response.data;
}
export async function deleteTenant(id: string): Promise<void> {
await apiClient.delete(`/tenants/${id}`);
}