- Add modules: ai, audit, billing-usage, biometrics, branches, dashboard, feature-flags, invoices, mcp, mobile, notifications, partners, payment-terminals, products, profiles, purchases, reports, sales, storage, warehouses, webhooks, whatsapp - Add controllers, DTOs, entities, and services for each module - Add shared services and utilities Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
Index,
|
|
} from 'typeorm';
|
|
|
|
export type ChangeType = 'create' | 'update' | 'delete' | 'restore';
|
|
|
|
@Entity({ name: 'entity_changes', schema: 'audit' })
|
|
export class EntityChange {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'entity_type', type: 'varchar', length: 100 })
|
|
entityType: string;
|
|
|
|
@Index()
|
|
@Column({ name: 'entity_id', type: 'uuid' })
|
|
entityId: string;
|
|
|
|
@Column({ name: 'entity_name', type: 'varchar', length: 255, nullable: true })
|
|
entityName: string;
|
|
|
|
@Column({ name: 'version', type: 'int', default: 1 })
|
|
version: number;
|
|
|
|
@Column({ name: 'previous_version', type: 'int', nullable: true })
|
|
previousVersion: number;
|
|
|
|
@Column({ name: 'data_snapshot', type: 'jsonb' })
|
|
dataSnapshot: Record<string, any>;
|
|
|
|
@Column({ name: 'changes', type: 'jsonb', default: [] })
|
|
changes: Record<string, any>[];
|
|
|
|
@Index()
|
|
@Column({ name: 'changed_by', type: 'uuid', nullable: true })
|
|
changedBy: string;
|
|
|
|
@Column({ name: 'change_reason', type: 'text', nullable: true })
|
|
changeReason: string;
|
|
|
|
@Column({ name: 'change_type', type: 'varchar', length: 20 })
|
|
changeType: ChangeType;
|
|
|
|
@Index()
|
|
@Column({ name: 'changed_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
changedAt: Date;
|
|
}
|