import { DateTime } from 'luxon'; import type { LucidBinaryValue, LucidPlainObject } from "../types"; /** * Casts an unknown value to a string * @param value - The value to cast * @returns The value as a string * @throws E_UNCASTABLE when the value cannot be cast to a string */ export declare const castValueAsString: (value: unknown) => string; /** * Casts an unknown value to a Luxon DateTime with enhanced string parsing * @param value - The value to cast (string, number, Date, or DateTime) * @returns The value as a Luxon DateTime * @throws E_UNCASTABLE when the value cannot be cast to a DateTime * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare const castValueAsDate: (value: unknown) => DateTime; /** * Casts an unknown value to a Luxon DateTime with enhanced error handling and string parsing * @param value - The value to cast (string, number, Date, or DateTime) * @returns The value as a Luxon DateTime * @throws E_UNCASTABLE when the value cannot be cast to a DateTime * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare const castValueAsDateTime: (value: unknown) => DateTime; /** * Casts an unknown value to a Uint8Array (binary data) * @param value - The value to cast * @returns The value as a Uint8Array * @throws E_UNCASTABLE when the value cannot be cast to binary data */ export declare const castValueAsBinary: (value: unknown) => Uint8Array; /** * Casts an unknown value to a number * @param value - The value to cast * @returns The value as a number * @throws E_UNCASTABLE when the value cannot be cast to a number */ export declare const castValueAsNumber: (value: unknown) => number; /** * Casts an unknown value to an integer * @param value - The value to cast * @returns The value as an integer (truncated if necessary) * @throws E_UNCASTABLE when the value cannot be cast to an integer */ export declare const castValueAsInteger: (value: unknown) => number; /** * Casts an unknown value to a bigint * @param value - The value to cast * @returns The value as a bigint * @throws E_UNCASTABLE when the value cannot be cast to a bigint */ export declare const castValueAsBigint: (value: unknown) => bigint; /** * Casts an unknown value to an unsigned integer * @param value - The value to cast * @returns The value as an unsigned integer (32-bit) * @throws E_UNCASTABLE when the value cannot be cast to an unsigned integer */ export declare const castValueAsUnsignedInt: (value: unknown) => number; /** * Casts an unknown value to a boolean * @param value - The value to cast * @returns The value as a boolean * @throws E_UNCASTABLE when the value cannot be cast to a boolean */ export declare const castValueAsBoolean: (value: unknown) => boolean; /** * Casts an unknown value to a plain object * @param value - The value to cast * @returns The value as a LucidPlainObject * @throws E_UNCASTABLE when the value cannot be cast to an object */ export declare const castValueAsObject: (value: unknown) => LucidPlainObject; /** * Casts an unknown value to an array * @param value - The value to cast * @returns The value as an array of unknown elements * @throws E_UNCASTABLE when the value cannot be cast to an array */ export declare const castValueAsArray: (value: unknown) => Array; /** * Prepares a string value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared string value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareString(key: string, value: unknown, nullable: true): string | null; export declare function prepareString(key: string, value: unknown, nullable?: false): string; /** * Prepares a date value for database storage with nullable support and enhanced string parsing * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared DateTime value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare function prepareDate(key: string, value: unknown, nullable: true): Date | null; export declare function prepareDate(key: string, value: unknown, nullable?: false): Date; /** * Prepares a datetime value for database storage with nullable support and enhanced string parsing * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared DateTime value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare function prepareDateTime(key: string, value: unknown, nullable: true): Date | null; export declare function prepareDateTime(key: string, value: unknown, nullable?: false): Date; /** * Prepares a binary value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared binary value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareBinary(key: string, value: unknown, nullable: true): LucidBinaryValue | null; export declare function prepareBinary(key: string, value: unknown, nullable?: false): LucidBinaryValue; /** * Prepares a number value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared number value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareNumber(key: string, value: unknown, nullable: true): number | null; export declare function prepareNumber(key: string, value: unknown, nullable?: false): number; /** * Prepares an integer value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared integer value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareInteger(key: string, value: unknown, nullable: true): number | null; export declare function prepareInteger(key: string, value: unknown, nullable?: false): number; /** * Prepares a bigint value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared bigint value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareBigint(key: string, value: unknown, nullable: true): bigint | null; export declare function prepareBigint(key: string, value: unknown, nullable?: false): bigint; /** * Prepares an unsigned integer value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared unsigned integer value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareUnsignedint(key: string, value: unknown, nullable: true): number | null; export declare function prepareUnsignedint(key: string, value: unknown, nullable?: false): number; /** * Prepares a boolean value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared boolean value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareBoolean(key: string, value: unknown, nullable: true): boolean | null; export declare function prepareBoolean(key: string, value: unknown, nullable?: false): boolean; /** * Prepares an object value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared object value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareObject(key: string, value: unknown, nullable: true): LucidPlainObject | null; export declare function prepareObject(key: string, value: unknown, nullable?: false): LucidPlainObject; /** * Prepares an array value for database storage with nullable support * @param key - The field name for error reporting * @param value - The value to prepare * @param nullable - Whether the field can be null * @returns The prepared array value or null if nullable and value is null * @throws E_INVALID_PREPARED_VALUE when the value cannot be prepared */ export declare function prepareArray(key: string, value: unknown, nullable: true): Array | null; export declare function prepareArray(key: string, value: unknown, nullable?: false): Array; /** * Consumes a string value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed string value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeString(key: string, value: unknown, nullable: true): string | null; export declare function consumeString(key: string, value: unknown, nullable?: false): string; /** * Consumes a date value from database results with nullable support and enhanced string parsing * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed DateTime value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare function consumeDate(key: string, value: unknown, nullable: true): DateTime | null; export declare function consumeDate(key: string, value: unknown, nullable?: false): DateTime; /** * Consumes a datetime value from database results with nullable support and enhanced string parsing * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed DateTime value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed * @remarks For string values, attempts SQL format parsing first, then falls back to ISO format parsing */ export declare function consumeDateTime(key: string, value: unknown, nullable: true): DateTime | null; export declare function consumeDateTime(key: string, value: unknown, nullable?: false): DateTime; /** * Consumes a binary value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed LucidBinaryValue or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeBinary(key: string, value: unknown, nullable: true): LucidBinaryValue | null; export declare function consumeBinary(key: string, value: unknown, nullable?: false): LucidBinaryValue; /** * Consumes a number value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed number value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeNumber(key: string, value: unknown, nullable: true): number | null; export declare function consumeNumber(key: string, value: unknown, nullable?: false): number; /** * Consumes an integer value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed integer value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeInteger(key: string, value: unknown, nullable: true): number | null; export declare function consumeInteger(key: string, value: unknown, nullable?: false): number; /** * Consumes a bigint value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed bigint value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeBigint(key: string, value: unknown, nullable: true): bigint | null; export declare function consumeBigint(key: string, value: unknown, nullable?: false): bigint; /** * Consumes an unsigned integer value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed unsigned integer value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeUnsignedint(key: string, value: unknown, nullable: true): number | null; export declare function consumeUnsignedint(key: string, value: unknown, nullable?: false): number; /** * Consumes a boolean value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed boolean value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeBoolean(key: string, value: unknown, nullable: true): boolean | null; export declare function consumeBoolean(key: string, value: unknown, nullable?: false): boolean; /** * Consumes an object value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed LucidPlainObject or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeObject(key: string, value: unknown, nullable: true): LucidPlainObject | null; export declare function consumeObject(key: string, value: unknown, nullable?: false): LucidPlainObject; /** * Consumes an array value from database results with nullable support * @param key - The field name for error reporting * @param value - The value to consume * @param nullable - Whether the field can be null * @returns The consumed array value or null if nullable and value is null * @throws E_INVALID_CONSUMED_VALUE when the value cannot be consumed */ export declare function consumeArray(key: string, value: unknown, nullable: true): Array | null; export declare function consumeArray(key: string, value: unknown, nullable?: false): Array;