import { Request } from 'express'; import { TCustomHeaders } from '../types/commonType'; import { GRADE } from '../constants/app'; import Joi from 'joi'; import { OrderItem } from 'sequelize'; export declare const pick: (objOrArray: T | T[], keys: K[]) => Pick | Pick[]; export declare const isValidMongoDbId: Joi.StringSchema; export declare const omit: (objOrArray: T | T[], keys: K[]) => Omit | Omit[]; export declare const ensureDirectoryExists: (directory: string) => void; export declare const generateOtp: (length?: number) => string; export declare const generateAlphaNumericCode: (length?: number) => string; export declare const generateTempPassword: (length?: number) => string; type UniqueByFields = (array: T[], fields: (keyof T)[]) => T[]; export declare const getUniqueArrayByFields: UniqueByFields; export declare const keyByFieldOrFields: (array: T[], fields: keyof T | (keyof T)[]) => Record; /** * Groups an array of objects by a specified field or multiple fields. * * @param array - The array of objects to group. * @param fields - A single field or an array of fields to group by. * @returns An object where keys are the grouped field values and values are arrays of grouped objects. */ export declare function groupByFieldOrFields(array: T[], fields: keyof T | (keyof T)[]): Record; export declare const isTimeWithinRange: (time: Date, rangeStart: Date, rangeEnd: Date) => boolean; export declare const isDateWithinRange: (date: Date | string, rangeStart: Date | string, rangeEnd: Date | string) => boolean; export declare const startOfDay: (date: string | Date) => Date; export declare const generateUuidToNumber: (uuid1?: string) => string; export declare const endOfDay: (date: string | Date) => Date; type GroupByFields = (array: T[], fields: keyof T | (keyof T)[]) => Record; export declare const groupByFields: GroupByFields; type SortOrder = 'asc' | 'desc'; interface SortField { key: keyof T; order?: SortOrder; } /** * Sorts an array of objects based on specified fields and order. * * @param array - The array to be sorted. * @param fields - A single sort field or an array of sort fields. * @returns A new sorted array. */ export declare const sortArray: (array: T[], fields: SortField | SortField[]) => T[]; /** * Gets all nested children for a given parent ID. * * @param array - Array of nodes representing the flat hierarchy. * @param parentIds - The ID of the parent node. * @param parentIdKey - The key used to reference the parent ID. * @returns A flattened list of all children. */ export declare const getChildrenByParentId: >(array: T[], parentIds: string | string[], parentIdKey: keyof T) => T[]; /** * Gets all nested children for a given parent ID. * * @param array - Array of nodes representing the flat hierarchy. * @param childIds - The ID of the parent node. * @param parentIdKey - The key used to reference the parent ID.. * @returns A flattened list of all parents. */ export declare const getParentsByChildrenId: >(array: T[], childIds: string | string[], parentIdKey: keyof T) => T[]; /** * Builds a nested structure from a flat array of items based on a parent-child relationship. * * @param items - The array of items that need to be organized. * @param parentIdKey - The key that refers to the parent ID in each item. * @param nestedListKey - The key that will store the nested child items for each parent. * * @returns An array of root-level items, each containing its nested children in the `nestedListKey`. */ export declare const buildNestedStructure: >(items: T[], parentIdKey: keyof T, nestedListKey: string) => T[]; /** * Flattens a nested structure into a flat array while preserving the parent-child relationship. * * @param items - The nested array of items to be flattened. * @param parentIdKey - The key that will store the parent ID in each flattened item. * @param nestedListKey - The key that contains the nested child items. * * @returns A flat array of items, each containing a reference to its parent ID. */ export declare const flattenNestedStructure: >(items: T[], parentIdKey: keyof T, nestedListKey: string) => Omit[]; /** * Removes all falsy values from an object. * * A falsy value in JavaScript/TypeScript includes: * - false * - 0 (zero) * - "" (empty string) * - null * - undefined * - NaN (Not-a-Number) * * This function iterates through the object's properties and removes any key-value pairs * where the value is falsy. Only truthy values remain in the final object. * * @param obj - The input object containing key-value pairs. * @returns A new object with all falsy values removed. * * @example * const data = { * name: "Alice", * age: 25, * isAdmin: false, * score: 0, * city: "", * country: "USA", * email: null, * phone: undefined, * balance: NaN, * }; * * const cleanedData = removeFalsyValues(data); * console.log(cleanedData); * // Output: { name: 'Alice', age: 25, country: 'USA' } */ export declare const removeFalsyValues: >(obj: T) => Partial; export declare const isValidUUID: (id: string, expectedVersion?: 1 | 4) => boolean; /** * Parses ordering input and returns Sequelize-compatible order array. * * @param inputOrder - Array like [["columnName", "ASC"], ...] * @param defaultOrder - Fallback or additional default order (e.g. [['createdAt', 'DESC']]) */ export declare const parseOrderOptions: (inputOrder: unknown, defaultOrder?: OrderItem[]) => OrderItem[]; import { IInstituteAttributes } from '../interfaces/instituteInterface'; import { IUserAttributes } from '../interfaces/userInterface'; import { TAeraModelCreationAttributes } from '../types/areaType'; import { Subject } from '../types'; export declare const capitalizeFirst: (str: string) => string; export declare const normalizeToArray: (value: string | string[] | undefined) => string[] | undefined; /** * Converts a snake_case string to Normal Text * @param {string} input - The snake_case string * @returns {string} - The converted Normal Text */ export declare const fromSnakeCaseToNormalText: (input: string) => string; export declare function slugify(text: string): string; export declare function assignNonNull>(target: T, source: Record): void; export declare function isUserSchoolInfoUpdate(institute: IInstituteAttributes, reqUser: IUserAttributes & { isAddDetails?: boolean; }): boolean; export declare function chunkArray(array: T[], size: number): T[][]; /** * Prepares userdata for EJS template based on dynamic columns config. * @param data Array of objects * @param columnsConfig Array of columns with { title, field } * @returns { userdata: any[], columns: string[] } */ export declare function extractFromObject(data: any[], config: { tableTitle: string; columns: { title: string; field: string | string[]; joinContent?: string; }[]; }): { tableTitle: string; userdata: any[]; columns: string[]; }; export declare const customPagination: (data: T[], page: number, limit: number, totalRecords: number) => Promise<{ limit: number; totalRecords: number; totalPages: number; hasPreviousPage: boolean; currentPage: number; hasNextPage: boolean; recordList: T[]; }>; export declare const generateHmacSHA256: (data: string, secret: string) => string; export declare const verifyHmacSHA256: (data: string, secret: string, signature: string) => boolean; export declare const generateVoucherCode: (format?: string) => string; export declare const getCityAreas: (cityName?: string) => Promise[]>; export declare const getNextLetter: (current: string) => string; export declare const calculateGrade: (subject: { total: number; pass: number; obtained: number; }) => GRADE; export declare const getOverallGrade: (subjects: Subject[]) => GRADE; export declare const readEmailTemplate: (templateName: string) => Promise; export declare const readEmailTemplateWithOutGlobal: (data: any, templateName?: string) => Promise; export declare const assignHeaderValues: >(bodyData: T, req: Request, fields: Array) => T; export {};