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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; // ════════════════════════════════════════════════════════════════ // DOCUMENT CATEGORY // ════════════════════════════════════════════════════════════════ @Schema({ collection: 'mdm_document_categories', timestamps: true }) export class DocumentCategory extends Document { @Prop({ required: true, unique: true }) categoryCode!: string; // IDENTITY, FINANCIAL, LEGAL, HR, PROJECT @Prop({ required: true }) categoryName!: string; @Prop() description?: string; @Prop({ default: false }) systemManaged!: boolean; @Prop({ default: true }) active!: boolean; } export const DocumentCategorySchema = SchemaFactory.createForClass(DocumentCategory); DocumentCategorySchema.index({ categoryCode: 1 }, { unique: true }); // ════════════════════════════════════════════════════════════════ // DOCUMENT TYPE // ════════════════════════════════════════════════════════════════ @Schema({ collection: 'mdm_document_types', timestamps: true }) export class DocumentType extends Document { @Prop({ required: true }) documentTypeCode!: string; // AADHAR_CARD, PAN_CARD, OFFER_LETTER @Prop({ required: true }) documentTypeName!: string; @Prop() description?: string; @Prop({ required: true }) categoryCode!: string; @Prop({ required: true }) entityTypeKey!: string; // employee, company, project, lead @Prop({ type: [String], default: [] }) allowedFileTypes!: string[]; // pdf, jpg, docx @Prop() maxFileSizeMb?: number; @Prop({ default: false }) mandatory!: boolean; @Prop({ default: false }) hasExpiry!: boolean; @Prop({ default: false }) requiresVerification!: boolean; @Prop({ default: false }) hasIdentifierField!: boolean; // document number @Prop() identifierLabel?: string; // "Aadhaar Number", "PAN", etc. @Prop() identifierPattern?: string; // regex validation @Prop({ default: false }) countrySpecific!: boolean; @Prop({ type: [String], default: [] }) countryCodes!: string[]; @Prop({ type: MongooseSchema.Types.ObjectId }) tenantId?: MongooseSchema.Types.ObjectId; @Prop({ default: false }) systemManaged!: boolean; @Prop({ default: true }) active!: boolean; } export const DocumentTypeSchema = SchemaFactory.createForClass(DocumentType); DocumentTypeSchema.index( { documentTypeCode: 1, tenantId: 1 }, { unique: true, sparse: true }, ); DocumentTypeSchema.index({ entityTypeKey: 1, categoryCode: 1, active: 1 }); DocumentTypeSchema.index({ countryCodes: 1, entityTypeKey: 1 }); // ════════════════════════════════════════════════════════════════ // DOCUMENT RETENTION POLICY // ════════════════════════════════════════════════════════════════ @Schema({ collection: 'mdm_document_retention_policies', timestamps: true }) export class DocumentRetentionPolicy extends Document { @Prop({ required: true }) policyCode!: string; @Prop({ required: true }) policyName!: string; @Prop({ type: [String], required: true }) documentTypeCodes!: string[]; @Prop({ required: true }) retentionPeriodMonths!: number; @Prop({ required: true, enum: ['archive', 'delete', 'anonymize', 'review'] }) actionAfterRetention!: string; @Prop({ default: false }) requiresApprovalToDelete!: boolean; @Prop() legalBasisRef?: string; // GDPR article, DPDP Act section, etc. @Prop({ type: [String], default: [] }) countryCodes!: string[]; @Prop({ type: MongooseSchema.Types.ObjectId }) tenantId?: MongooseSchema.Types.ObjectId; @Prop({ default: true }) active!: boolean; } export const DocumentRetentionPolicySchema = SchemaFactory.createForClass( DocumentRetentionPolicy, ); DocumentRetentionPolicySchema.index( { policyCode: 1, tenantId: 1 }, { unique: true, sparse: true }, ); DocumentRetentionPolicySchema.index({ documentTypeCodes: 1 }); |