cloud-ide-lms-model
Version:
Package for Model management of Cloud IDEsys LMS
217 lines (216 loc) • 10.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreUserRoleExceptionsMapping = exports.AuthUserCoreUserDocuments = exports.AuthUserCoreUserFamilyDetails = exports.AuthUserCoreUserContactAddresses = exports.AuthUserCoreEntityMapping = exports.AuthUserMstGetByIdData = exports.AuthUserMstGetByIdPayload = exports.AuthUserMstCreatePayload = exports.AuthUserMstListPayload = void 0;
const common_types_1 = require("../../common-types");
const schema_1 = require("../../schema");
const core_user_contact_addresses_1 = require("../../schema/core/core_user_contact_addresses");
const core_user_documents_1 = require("../../schema/core/core_user_documents");
const core_user_family_details_1 = require("../../schema/core/core_user_family_details");
const core_user_role_exceptions_1 = require("../../schema/core/core_user_role_exceptions");
/* INTERFACE END */
/* MODEL START */
class AuthUserMstListPayload extends common_types_1.MTableQueries {
constructor(init) {
super(init);
Object.assign(this, init);
}
Validate() {
let errorLogger = {};
// Validate user type if provided
if (this.syutm_user_type && !['STUDENT', 'EMPLOYEE', 'TEACHER', 'PARENT', 'GUARDIAN', 'ADMIN', 'STAFF', 'OTHER', 'DRIVER'].includes(this.syutm_user_type.toUpperCase())) {
errorLogger.syutm_user_type = 'Invalid user type. Must be one of: STUDENT, EMPLOYEE, TEACHER, PARENT, GUARDIAN, ADMIN, STAFF, OTHER, DRIVER';
}
return errorLogger;
}
}
exports.AuthUserMstListPayload = AuthUserMstListPayload;
class AuthUserMstCreatePayload {
constructor(init) {
this.auth_user_mst = new schema_1.AuthUserMst();
this.core_user_contact_addresses = [];
this.core_user_documents = [];
this.core_user_family_details = [];
this.core_user_attributes = [];
this.core_entity_mapping = [];
this.core_user_role_exceptions = [];
if (init) {
Object.assign(this, init);
// Ensure arrays are properly initialized
this.core_user_contact_addresses = init.core_user_contact_addresses || [];
this.core_user_documents = init.core_user_documents || [];
this.core_user_family_details = init.core_user_family_details || [];
this.core_user_attributes = init.core_user_attributes || [];
this.core_entity_mapping = init.core_entity_mapping || [];
this.core_user_role_exceptions = init.core_user_role_exceptions || [];
// Initialize auth_user_mst if provided
if (init.auth_user_mst) {
this.auth_user_mst = Object.assign(Object.assign({}, new schema_1.AuthUserMst()), init.auth_user_mst);
}
if (init.core_user_type_mapping) {
this.core_user_type_mapping = Object.assign({}, init.core_user_type_mapping);
}
}
}
Validate() {
let errorLogger = {};
// Validate required fields in auth_user_mst
if (!this.auth_user_mst) {
errorLogger.auth_user_mst = 'User data (auth_user_mst) is required';
return errorLogger;
}
// Validate user_username is required (min 5, max 20 characters)
if (!this.auth_user_mst.user_username || !this.auth_user_mst.user_username.trim()) {
errorLogger.auth_user_mst = 'Username (user_username) is required';
}
else {
const username = this.auth_user_mst.user_username.trim();
if (username.length < 5) {
errorLogger.auth_user_mst = 'Username must be at least 5 characters long';
}
else if (username.length > 20) {
errorLogger.auth_user_mst = 'Username must not exceed 20 characters';
}
}
// Validate user_fullname is required (min 8, max 80 characters)
if (!this.auth_user_mst.user_fullname || !this.auth_user_mst.user_fullname.trim()) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Full name (user_fullname) is required';
}
else {
errorLogger.auth_user_mst += '; Full name (user_fullname) is required';
}
}
else {
const fullname = this.auth_user_mst.user_fullname.trim();
if (fullname.length < 3) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Full name must be at least 3 characters long';
}
else {
errorLogger.auth_user_mst += '; Full name must be at least 3 characters long';
}
}
else if (fullname.length > 80) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Full name must not exceed 80 characters';
}
else {
errorLogger.auth_user_mst += '; Full name must not exceed 80 characters';
}
}
}
// Validate user_emailid format if provided (min 8, max 50 characters)
if (this.auth_user_mst.user_emailid && this.auth_user_mst.user_emailid.trim()) {
const email = this.auth_user_mst.user_emailid.trim();
if (email.length < 8) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Email must be at least 8 characters long';
}
else {
errorLogger.auth_user_mst += '; Email must be at least 8 characters long';
}
}
else if (email.length > 50) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Email must not exceed 50 characters';
}
else {
errorLogger.auth_user_mst += '; Email must not exceed 50 characters';
}
}
else {
// Basic email format validation
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Email format is invalid';
}
else {
errorLogger.auth_user_mst += '; Email format is invalid';
}
}
}
}
// Validate user_firstname if provided (min 3, max 20 characters)
if (this.auth_user_mst.user_firstname && this.auth_user_mst.user_firstname.trim()) {
const firstname = this.auth_user_mst.user_firstname.trim();
if (firstname.length < 3) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'First name must be at least 3 characters long';
}
else {
errorLogger.auth_user_mst += '; First name must be at least 3 characters long';
}
}
else if (firstname.length > 20) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'First name must not exceed 20 characters';
}
else {
errorLogger.auth_user_mst += '; First name must not exceed 20 characters';
}
}
}
// Validate user_lastname if provided (min 3, max 20 characters)
if (this.auth_user_mst.user_lastname && this.auth_user_mst.user_lastname.trim()) {
const lastname = this.auth_user_mst.user_lastname.trim();
if (lastname.length < 3) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Last name must be at least 3 characters long';
}
else {
errorLogger.auth_user_mst += '; Last name must be at least 3 characters long';
}
}
else if (lastname.length > 20) {
if (!errorLogger.auth_user_mst) {
errorLogger.auth_user_mst = 'Last name must not exceed 20 characters';
}
else {
errorLogger.auth_user_mst += '; Last name must not exceed 20 characters';
}
}
}
return errorLogger;
}
}
exports.AuthUserMstCreatePayload = AuthUserMstCreatePayload;
class AuthUserMstGetByIdPayload {
constructor(init) {
this.user_id = '';
if (init) {
Object.assign(this, init);
}
}
Validate() {
var _a, _b;
let errorLogger = {};
// Validate that auth_user_mst has required ID for get operation
if (!((_a = this.user_id) === null || _a === void 0 ? void 0 : _a.trim())) {
errorLogger.user_id = 'User ID is required for get operation';
}
if (!((_b = this.syenm_entity_id_syen) === null || _b === void 0 ? void 0 : _b.trim())) {
errorLogger.syenm_entity_id_syen = 'Entity ID is required for get operation';
}
return errorLogger;
}
}
exports.AuthUserMstGetByIdPayload = AuthUserMstGetByIdPayload;
class AuthUserMstGetByIdData {
}
exports.AuthUserMstGetByIdData = AuthUserMstGetByIdData;
class CoreUserRoleExceptionsMapping extends core_user_role_exceptions_1.CoreUserRoleExceptionsBase {
}
exports.CoreUserRoleExceptionsMapping = CoreUserRoleExceptionsMapping;
class AuthUserCoreEntityMapping extends schema_1.CoreEntityMappingBase {
}
exports.AuthUserCoreEntityMapping = AuthUserCoreEntityMapping;
class AuthUserCoreUserContactAddresses extends core_user_contact_addresses_1.CoreUserContactAddressesBase {
}
exports.AuthUserCoreUserContactAddresses = AuthUserCoreUserContactAddresses;
class AuthUserCoreUserDocuments extends core_user_documents_1.CoreUserDocumentsBase {
}
exports.AuthUserCoreUserDocuments = AuthUserCoreUserDocuments;
class AuthUserCoreUserFamilyDetails extends core_user_family_details_1.CoreUserFamilyDetailsBase {
}
exports.AuthUserCoreUserFamilyDetails = AuthUserCoreUserFamilyDetails;