import type { z } from 'zod'; import type { DataIssues } from '../core/errors/types/index.js'; import type { TOrEmpty } from '../types'; import { InvalidSchemaNormalizationError } from '../core/errors/InvalidSchemaNormalizationError.js'; import { DomainError } from '../core/errors/DomainError'; import { Result } from '../core/Result'; /** * Convert a comma separated string to an array. * * @param str - The string to convert. * @returns The array of strings. * @since 5.0.0 * @author Caique Araujo */ export declare function commaStringAsArray(str?: string): Array; /** * Get the last available string. * * @param entry - The entry to get the last available string from. * @param defaultValue - The default value to return if the entry is not an array or string. * @param separator - The separator to use to split the entry. * @returns The last available string. * @returns * @since 5.0.0 * @author Caique Araujo */ export declare const lastAvailableString: (entry: string[] | string, defaultValue: string, separator?: string) => string; /** * Delete keys from an object. * * @param obj - The object to delete keys from. * @param keys - The keys to delete. * @returns The object with the keys deleted. * @since 5.0.0 * @author Caique Araujo */ export declare function deleteKeys>(obj: T, keys: string[]): Partial; /** * Get the timestamp. * * @param native - Whether to use the native timestamp. * @returns The timestamp. * @since 5.0.0 * @author Caique Araujo */ export declare function getTimestamp(native?: boolean): number; /** * Parse empty value. * * @param val - The value to parse. * @returns The parsed value. * @since 5.0.0 * @author Caique Araujo */ export declare function parseEmpty(val: T): TOrEmpty; /** * Preserve value when it is equal to `when`. * * @param {any} value * @param {any} when * @param {any} _default * @returns {any} * @since 3.0.0 * @author Caique Araujo */ export declare function preserve(value: any, when: any, _default: any): any; /** * Parse to JSON copy of an object. * * @param {Array} obj * @returns {object} * @since 3.0.0 * @author Caique Araujo */ export declare function parseToJson(obj: { [key: string]: any; }): object; /** * Remove item from array. * * @param {Array} arr * @param {T} item * @returns {Array} * @since 3.0.0 * @author Caique Araujo */ export declare function removeItem(arr: Array, item: T): Array; /** * Remove index from array. * * @param {Array} arr * @param {number} index * @returns {Array} * @since 3.0.0 * @author Caique Araujo */ export declare function removeIndex(arr: Array, index: number): Array; /** * Get a random string. * * @param {number} length * @returns {string} * @since 3.0.0 * @author Caique Araujo */ export declare function randomString(length: number): string; /** * Convert any to an JSON object. * * @param {(string|object)} obj * @returns {object} * @since 3.0.0 * @author Caique Araujo */ export declare function toJSON(obj: string | object): object; /** * Convert any to an array. * * @param {any} val * @returns {Array} * @since 3.0.0 * @author Caique Araujo */ export declare function toArray(val?: Array | T): Array; /** * Convert date to RFC3339 format. * * @param date * @param timezone * @returns * @since 3.0.0 * @author Caique Araujo */ export declare function toRFC3339(date: Date, timezone?: string): string; /** * Mount an URL based on a base and a relative path. * * @param {string} base * @param {string} relative_path * @returns {string} * @since 3.0.0 * @author Caique Araujo */ export declare function mountURL(base: string, relative_path: string): string; /** * Split a string and trim each item. * * @param {string} str * @param {string} separator * @returns {string[]} * @since 3.0.0 * @author Caique Araujo */ export declare function splitAndTrim(str: string, separator: string): Array; /** * Evaluate a schema. * * @param {string} type * @param {any} input * @param {ZodSchema} schema * @param {string} hint * @param {Record} map The map of fields. { field: 'Returning Label' } * @returns {Result} * @since 4.0.0 * @returns {Result} * @author Caique Araujo */ export declare const evaluateSchema: (type: string, input: z.input, schema: Schema, hint?: string, map?: Record) => Result, DomainError>; /** * Parse the current process environment variables. * * @param schema * @returns Output schema type. * @since 5.0.0 * @author Caique Araujo */ export declare const parseEnv: (schema: Schema) => z.output; /** * Sanitize a string recursively. * * @param {any} data * @returns {any} * @since 4.0.0 * @author Caique Araujo */ export declare const sanitizeRecursively: (data: T) => T; /** * Parse a log message. It will return an object with: * * - uuid: The UUID of the log. * - date: The date of the log in format: `YYYY-MM-DD HH:mm:ss`. * - display: The display of the log in format: `(level) "message" - arg1 - arg2 - arg3 - ...`. * - message: The message of the log in format: `[date] [uuid] display\n`. * * @param {string} level * @param {string} message * @param {...any[]} args * @returns {{ uuid: string; date: string; display: string; message: string }} * @since 4.1.0 * @author Caique Araujo */ export declare const displayLog: (level: "debug" | "error" | "fatal" | "info" | "warn", message: string, ...args: any[]) => { uuid: string; date: string; display: string; message: string; }; /** * Parse the absolute path. * * @param abspath - The absolute path to parse. * @returns The absolute path. * @since 4.1.0 * @author Caique Araujo */ export declare const parseAbspath: (abspath?: string) => string; /** * Evaluate the absolute path. * * @param abspath - The absolute path to evaluate. * @returns True if the absolute path is valid, false otherwise. * @since 4.1.0 * @author Caique Araujo */ export declare const evaluateAbspath: (abspath?: string) => boolean; /** * Generate a random string. * Unsafe, use only for non-critical purposes. * * @param size - The size of the string * @returns The string * @since 4.1.0 * @author Caique Araujo */ export declare const generateString: (size?: number, characters?: string) => string; /** * Slugify a string. * * @note It may produce an empty string as it not expected as an error. * @param v - The string to slugify. * @returns The slugified string. * @since 4.2.2 * @author Caique Araujo */ export declare const slugifyAsDash: (v: string) => string; /** * Slugify a string. * * @note It may produce an empty string as it not expected as an error. * @param v - The string to slugify. * @returns The slugified string. * @since 4.2.2 * @author Caique Araujo */ export declare const slugifyAsUnderscore: (v: string) => string; /** * Convert zod issues to data issues. * * @param issues - The zod issues. * @returns The data issues. * @since 5.0.0 * @author Caique Araujo */ export declare const zodIssuesToDataIssues: (issues: Array) => DataIssues; /** * Evaluate a schema. * * @param {string} name * @param {any} input * @param {ZodSchema} schema * @returns {Result} * @since 5.0.0 * @returns {Result} * @author Caique Araujo */ export declare const normalizeSchema: (name: string, input: unknown, schema: Schema) => Result, InvalidSchemaNormalizationError>;