erp-core-backend-v2/src/modules/billing-usage/entities/plan-feature.entity.ts
rckrdmrd e846b715c1 feat: Add billing and feature-flags entities
- Added plan-feature entity for billing
- Added flag-evaluation entity for feature flags
- Updated module configurations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 12:13:18 -06:00

62 lines
1.6 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { SubscriptionPlan } from './subscription-plan.entity.js';
/**
* PlanFeature Entity
* Maps to billing.plan_features DDL table
* Features disponibles por plan de suscripcion
* Propagated from template-saas HU-REFACT-005
*/
@Entity({ schema: 'billing', name: 'plan_features' })
@Index('idx_plan_features_plan', ['planId'])
@Index('idx_plan_features_key', ['featureKey'])
export class PlanFeature {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'uuid', nullable: false, name: 'plan_id' })
planId: string;
@Column({ type: 'varchar', length: 100, nullable: false, name: 'feature_key' })
featureKey: string;
@Column({ type: 'varchar', length: 255, nullable: false, name: 'feature_name' })
featureName: string;
@Column({ type: 'varchar', length: 100, nullable: true })
category: string | null;
@Column({ type: 'boolean', default: true })
enabled: boolean;
@Column({ type: 'jsonb', default: {} })
configuration: Record<string, any>;
@Column({ type: 'text', nullable: true })
description: string | null;
@Column({ type: 'jsonb', default: {} })
metadata: Record<string, any>;
// Relaciones
@ManyToOne(() => SubscriptionPlan, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'plan_id' })
plan: SubscriptionPlan;
// Timestamps
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
}