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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ timestamps: true, collection: 'onboarding_definitions' }) export class OnboardingDefinition extends Document { @Prop({ required: true, unique: true, index: true }) key: string; // e.g. 'standard', 'lite' @Prop({ required: true }) name: string; @Prop({ default: true }) isActive: boolean; } export const OnboardingDefinitionSchema = SchemaFactory.createForClass(OnboardingDefinition); @Schema({ timestamps: true, collection: 'onboarding_step_definitions' }) export class OnboardingStepDefinition extends Document { @Prop({ required: true, index: true }) definitionKey: string; @Prop({ required: true, index: true }) stepKey: string; // e.g. 'company_profile', 'invite_employees' @Prop({ required: true }) title: string; @Prop({ default: '' }) description: string; @Prop({ required: true }) sequence: number; @Prop({ default: false }) isRequired: boolean; } export const OnboardingStepDefinitionSchema = SchemaFactory.createForClass( OnboardingStepDefinition, ); @Schema({ timestamps: true, collection: 'tenant_onboardings' }) export class TenantOnboarding extends Document { @Prop({ required: true, unique: true, index: true }) tenantId: string; @Prop({ required: true, default: 'standard' }) definitionKey: string; @Prop({ required: true, default: 'company_profile' }) currentStepKey: string; @Prop({ default: 0 }) completionPercentage: number; @Prop({ required: true, default: 'IN_PROGRESS', index: true }) status: string; // 'IN_PROGRESS' | 'COMPLETED' } export const TenantOnboardingSchema = SchemaFactory.createForClass(TenantOnboarding); @Schema({ timestamps: true, collection: 'tenant_onboarding_steps' }) export class TenantOnboardingStep extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) stepKey: string; @Prop({ required: true, default: 'PENDING' }) status: string; // 'PENDING' | 'COMPLETED' | 'SKIPPED' @Prop({ type: MongooseSchema.Types.Mixed, default: {} }) data: any; // Saves progress data entered at this step @Prop({ default: null }) completedAt: Date; } export const TenantOnboardingStepSchema = SchemaFactory.createForClass(TenantOnboardingStep); TenantOnboardingStepSchema.index({ tenantId: 1, stepKey: 1 }, { unique: true }); @Schema({ timestamps: true, collection: 'onboarding_checklist_items' }) export class OnboardingChecklistItem extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) taskKey: string; @Prop({ required: true }) label: string; @Prop({ default: false }) isCompleted: boolean; } export const OnboardingChecklistItemSchema = SchemaFactory.createForClass( OnboardingChecklistItem, ); OnboardingChecklistItemSchema.index({ tenantId: 1 }); |