All files / src/domains/performance/schemas configuration.schema.ts

100% Statements 37/37
78.04% Branches 32/41
100% Functions 0/0
100% Lines 29/29

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 891x 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_cycles' })
export class PerformanceCycle extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  name: string;
 
  @Prop({ required: true })
  startDate: Date;
 
  @Prop({ required: true })
  endDate: Date;
 
  @Prop({ required: true, enum: ['draft', 'active', 'evaluation', 'calibration', 'completed'], default: 'draft' })
  status: string;
}
export const PerformanceCycleSchema = SchemaFactory.createForClass(PerformanceCycle);
 
@Schema({ timestamps: true, collection: 'performance_rating_scales' })
export class PerformanceRatingScale extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  name: string;
 
  @Prop({ required: true, type: Number })
  minRating: number;
 
  @Prop({ required: true, type: Number })
  maxRating: number;
 
  @Prop({
    type: [{
      score: { type: Number, required: true },
      label: { type: String, required: true },
      description: { type: String }
    }],
    default: []
  })
  levels: Array<{ score: number; label: string; description?: string }>;
}
export const PerformanceRatingScaleSchema = SchemaFactory.createForClass(PerformanceRatingScale);
 
@Schema({ timestamps: true, collection: 'performance_bell_curves' })
export class PerformanceBellCurveDefinition 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({
    type: [{
      ratingLabel: { type: String, required: true },
      targetPercentage: { type: Number, required: true }, // e.g. 10 for 10%
    }],
    default: []
  })
  targets: Array<{ ratingLabel: string; targetPercentage: number }>;
}
export const PerformanceBellCurveDefinitionSchema = SchemaFactory.createForClass(PerformanceBellCurveDefinition);
 
@Schema({ timestamps: true, collection: 'performance_configurations' })
export class PerformanceConfiguration extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, default: true })
  allowSelfAppraisal: boolean;
 
  @Prop({ required: true, default: true })
  allowPeerReview: boolean;
 
  @Prop({ required: true, default: true })
  allow360Feedback: boolean;
 
  @Prop({ required: true, default: false })
  allowAnonymousFeedback: boolean;
 
  @Prop({ required: true, default: true })
  enableBellCurveCalibration: boolean;
}
export const PerformanceConfigurationSchema = SchemaFactory.createForClass(PerformanceConfiguration);