@neatau/dto
    Preparing search index...

    Interface DTOInterface<T>

    interface DTOInterface<T extends ZodType> {
        createdAt: number;
        id: string;
        clone(): DTOInterface<T>;
        equals(target: DTOInterface<T>): boolean;
        getData(): DTOData<T>;
        getDataItem(field: keyof output<T>): Readonly<output<T>>[keyof output<T>];
        getError(): unknown;
        getUnsafeData(): DTOData<T>;
        toHash(algo?: string): string;
        toJSONString(pretty?: boolean): string;
        toJWT(
            secretOrPrivateKey:
                | Buffer<ArrayBufferLike>
                | PrivateKeyInput
                | JsonWebKeyInput
                | Secret,
            ttl?: number,
        ): string;
        toSearchParams(): URLSearchParams;
        toString(): string;
        with(data: Partial<DTOData<T>>): DTOInterface<T>;
    }

    Type Parameters

    • T extends ZodType
    Index

    Properties

    createdAt: number

    The creation timestamp of the DTO.

    id: string

    Unique identifier assigned to the DTO at creation.

    Methods

    • Perform a deep equality check between the data contained within this DTO and the target DTO of the same type.

      Parameters

      Returns boolean

    • Parses and returns the data of the DTO instance. Throws a ZodError if the data provided does not validate against the configured schema, or your own custom error if a transformError function was provided when creating the DTO class.

      Caches the parsed data for repeat access.

      Returns DTOData<T>

    • Get a single data item from the DTO.

      Parameters

      • field: keyof output<T>

        The field to retrieve from the DTO data.

      Returns Readonly<output<T>>[keyof output<T>]

    • Returns the error encountered during data parsing, if any. Applies the provided transformError function if it exists.

      Returns unknown

    • Returns the raw input data of the DTO instance without parsing, skipping validation rules present on the Zod schema.

      Returns DTOData<T>

    • Converts the parsed data within the DTO instance to a hash.

      Parameters

      • Optionalalgo: string

        The hashing algorithm to use (e.g. 'sha1', 'md5'). Defaults to 'sha1'.

      Returns string

    • Converts the parsed data within the DTO instance to a JSON string. Creates JSON strings in a deterministic structure by recursively sorting the keys.

      Parameters

      • Optionalpretty: boolean

        Whether to format the JSON string with indentation.

      Returns string

    • Converts the parsed data within the DTO instance to a JWT.

      Parameters

      • secretOrPrivateKey: Buffer<ArrayBufferLike> | PrivateKeyInput | JsonWebKeyInput | Secret
      • Optionalttl: number

      Returns string

      secretOrPrivateKey The secret or private key to sign the JWT with.

      ttl The time-to-live for the JWT in seconds. Sets the exp claim to the current timestamp plus the TTL, or omits this claim if not provided.

    • Converts the parsed data within the DTO instance to a URLSearchParams object suitable for building a URL (e.g. for an API request).

      Returns URLSearchParams

    • Converts this DTO instance to a string representation for debugging.

      Returns string