Modules added (entities only): - biometrics (4 entities) - feature-flags (3 entities) - hr (8 entities) - invoices (4 entities) - products (7 entities) - profiles (5 entities) - projects (1 entity) - purchase (11 entities) - reports (13 entities) - sales (4 entities) - settings (4 entities) - storage (7 entities) - warehouses (3 entities) - webhooks (6 entities) - whatsapp (10 entities) Total: 90 new entity files Source: erp-construccion (validated, build clean) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
/**
|
|
* UserProfile Entity
|
|
* Role-based profile with module access, tools and pricing
|
|
* Compatible with erp-core user-profile.entity
|
|
*
|
|
* @module Profiles
|
|
*/
|
|
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
DeleteDateColumn,
|
|
Index,
|
|
OneToMany,
|
|
Unique,
|
|
} from 'typeorm';
|
|
import { ProfileTool } from './profile-tool.entity';
|
|
import { ProfileModule } from './profile-module.entity';
|
|
|
|
@Entity({ name: 'user_profiles', schema: 'auth' })
|
|
@Unique(['tenantId', 'code'])
|
|
export class UserProfile {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'tenant_id', type: 'uuid', nullable: true })
|
|
tenantId: string;
|
|
|
|
@Index()
|
|
@Column({ type: 'varchar', length: 10 })
|
|
code: string;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
name: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description: string;
|
|
|
|
@Column({ name: 'is_system', type: 'boolean', default: false })
|
|
isSystem: boolean;
|
|
|
|
@Column({ type: 'varchar', length: 20, nullable: true })
|
|
color: string;
|
|
|
|
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
icon: string;
|
|
|
|
@Column({ name: 'base_permissions', type: 'jsonb', default: [] })
|
|
basePermissions: string[];
|
|
|
|
@Column({ name: 'available_modules', type: 'text', array: true, default: [] })
|
|
availableModules: string[];
|
|
|
|
@Column({ name: 'monthly_price', type: 'decimal', precision: 10, scale: 2, default: 0 })
|
|
monthlyPrice: number;
|
|
|
|
@Column({ name: 'included_platforms', type: 'text', array: true, default: ['web'] })
|
|
includedPlatforms: string[];
|
|
|
|
@Column({ name: 'default_tools', type: 'text', array: true, default: [] })
|
|
defaultTools: string[];
|
|
|
|
@Column({ name: 'feature_flags', type: 'jsonb', default: {} })
|
|
featureFlags: Record<string, boolean>;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy: string;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy: string;
|
|
|
|
@DeleteDateColumn({ name: 'deleted_at', type: 'timestamptz', nullable: true })
|
|
deletedAt: Date;
|
|
|
|
@OneToMany(() => ProfileTool, (tool) => tool.profile, { cascade: true })
|
|
tools: ProfileTool[];
|
|
|
|
@OneToMany(() => ProfileModule, (module) => module.profile, { cascade: true })
|
|
modules: ProfileModule[];
|
|
}
|