import type { Value as ProtoValue } from '../../../generated/values/v1/values_pb'; import type { CreSerializable, PrimitiveTypes } from './serializer_types'; /** * Type that can validate a value and return a typed result. * Compatible with Zod schemas, Yup validators, and other similar libraries. */ export interface SchemaValidator { parse(value: unknown): T; } /** * Options for the unwrapToType function - * - for primitive types, use the instance option to verify the type matches, the value is ignored. * - for non-primitive types, either use a schema validator OR a factory function, not both. */ export type UnwrapOptions = T extends PrimitiveTypes ? { instance: T; } : { schema: SchemaValidator; factory?: never; } | { schema?: never; factory: () => T; }; export declare class Int64 { static readonly INT64_MIN: bigint; static readonly INT64_MAX: bigint; readonly value: bigint; static toInt64Bigint(v: number | bigint | string): bigint; constructor(v: number | bigint | string); add(i: Int64, safe?: boolean): Int64; sub(i: Int64, safe?: boolean): Int64; mul(i: Int64, safe?: boolean): Int64; div(i: Int64, safe?: boolean): Int64; } export declare class UInt64 { static readonly UINT64_MAX: bigint; readonly value: bigint; static toUint64Bigint(v: number | bigint | string): bigint; constructor(v: number | bigint | string); add(i: UInt64, safe?: boolean): UInt64; sub(i: UInt64, safe?: boolean): UInt64; mul(i: UInt64, safe?: boolean): UInt64; div(i: UInt64, safe?: boolean): UInt64; } export declare class Decimal { readonly coeffecient: bigint; readonly exponent: number; static parse(s: string): Decimal; constructor(coeffecient: bigint, exponent: number); } export declare class Value { private readonly value; static from(value: CreSerializable): Value; static wrap(value: ProtoValue): Value; private constructor(); proto(): ProtoValue; private static toUint8Array; /** * Converts a bigint to a byte array using big-endian byte order. * Big-endian means the most significant byte comes first in the array. */ private static bigintToBytesBE; /** * Converts a JavaScript Native bigint to a protobuf BigInt message. */ private static bigIntToProtoBigInt; private static toTimestamp; private static isPlainObject; private static isObject; private static wrapInternal; unwrap(): unknown; /** * Unwraps a Value object into its native JavaScript equivalent and casts it to type T. * If the value is null or undefined, throws an exception. * * @param options - Either a schema validator or a factory function (but not both), used for non-primitive types * @returns The unwrapped JavaScript value cast to type T * @throws Error if value is null, undefined, contains an invalid case, or fails schema validation */ unwrapToType(options: UnwrapOptions): T; }