UNPKG

@upv/ushi-shared

Version:

Shared DTOs, types, and utilities for the USHI platform (LMS, Trials, Social, Wallet).

40 lines (39 loc) 1.4 kB
import { IBaseDtoInput, IBaseDtoOutput } from "../../../types"; /** * BaseDto<T> * * Abstract base class for all Data Transfer Objects (DTOs) in the USHI platform. * Provides common properties and a consistent serialization structure. * * @template T - Raw input type extending IBaseDtoInput */ declare abstract class BaseDto<T extends IBaseDtoInput> { /** Unique identifier of the entity */ protected readonly _id: string; /** Creation timestamp in UNIX milliseconds */ protected readonly _createdAt: number; /** Last update timestamp in UNIX milliseconds */ protected readonly _updatedAt: number; /** * Initializes shared properties from raw DTO input. * @param data - Raw DTO input conforming to IBaseDtoInput */ constructor(data: T); /** Getter for the unique ID */ get id(): string; /** Getter for the creation timestamp */ get createdAt(): number; /** Getter for the last updated timestamp */ get updatedAt(): number; /** * Serializes common fields of the DTO. * Can be used by child `serialize()` implementations. */ protected serializeBase(): IBaseDtoOutput; /** * Abstract method to serialize the full DTO object. * Child classes must implement and extend this as needed. */ abstract serialize(): IBaseDtoOutput | Promise<IBaseDtoOutput>; } export default BaseDto;