All files / performance/schemas competency-career-talent.schema.ts

100% Statements 44/44
79.31% Branches 46/58
100% Functions 0/0
100% Lines 34/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 1031x 1x     1x   1x     1x     1x     1x   1x     1x   1x     1x     1x     1x     1x   1x     1x   1x     1x                   1x   1x     1x   1x     1x     1x     1x     1x     1x   1x     1x   1x     1x     1x                   1x   1x  
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'performance_competency_libraries' })
export class PerformanceCompetencyLibrary extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  name: string;
 
  @Prop({ required: true })
  description: string;
 
  @Prop({ required: true, default: 'core', enum: ['core', 'functional', 'leadership'] })
  type: string;
}
export const PerformanceCompetencyLibrarySchema = SchemaFactory.createForClass(PerformanceCompetencyLibrary);
 
@Schema({ timestamps: true, collection: 'performance_employee_skills' })
export class PerformanceEmployeeSkillMatrix extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'PerformanceCompetencyLibrary' })
  competencyId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: Number })
  acquiredLevel: number; // e.g. 1 to 5 scale
 
  @Prop({ required: true, type: Number })
  targetLevel: number;
}
export const PerformanceEmployeeSkillMatrixSchema = SchemaFactory.createForClass(PerformanceEmployeeSkillMatrix);
 
@Schema({ timestamps: true, collection: 'performance_career_tracks' })
export class PerformanceCareerTrack extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  name: string; // e.g. "Technical Track"
 
  @Prop({
    type: [{
      levelCode: { type: String, required: true },
      title: { type: String, required: true },
      experienceYears: { type: Number, required: true }
    }],
    default: []
  })
  levels: Array<{ levelCode: string; title: string; experienceYears: number }>;
}
export const PerformanceCareerTrackSchema = SchemaFactory.createForClass(PerformanceCareerTrack);
 
@Schema({ timestamps: true, collection: 'performance_talent_matrices' })
export class PerformanceTalentMatrix extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'PerformanceCycle' })
  cycleId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, enum: ['low', 'medium', 'high'] })
  performanceRating: string;
 
  @Prop({ required: true, enum: ['low', 'medium', 'high'] })
  potentialRating: string;
 
  @Prop({ required: true })
  nineBoxCell: string; // Auto-computed (e.g. "High Performance - High Potential")
}
export const PerformanceTalentMatrixSchema = SchemaFactory.createForClass(PerformanceTalentMatrix);
 
@Schema({ timestamps: true, collection: 'performance_succession_plans' })
export class PerformanceSuccessionPlan extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: String })
  criticalPositionCode: string;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  currentOccupantId: MongooseSchema.Types.ObjectId;
 
  @Prop({
    type: [{
      successorId: { type: MongooseSchema.Types.ObjectId, ref: 'Employee', required: true },
      readinessLevel: { type: String, enum: ['ready_now', '1_to_2_years', '3_plus_years'], required: true },
      retentionRisk: { type: String, enum: ['low', 'medium', 'high'], required: true }
    }],
    default: []
  })
  successors: Array<{ successorId: MongooseSchema.Types.ObjectId; readinessLevel: string; retentionRisk: string }>;
}
export const PerformanceSuccessionPlanSchema = SchemaFactory.createForClass(PerformanceSuccessionPlan);