import type { ValueOf } from '../../type.utils.js'; import { type ParsedOptions } from '../options.utils.js'; /** * Basic topic information without partition details. */ export type BaseTopic = { /** Topic ID */ id: number; /** Topic name */ name: string; /** Topic creation timestamp */ createdAt: Date; /** Number of partitions */ partitionsCount: number; /** Compression algorithm used */ compressionAlgorithm: number; /** Message expiry time in microseconds (0 = unlimited) */ messageExpiry: bigint; /** Maximum topic size in bytes (0 = unlimited) */ maxTopicSize: bigint; /** Total size of the topic in bytes */ sizeBytes: bigint; /** Total number of messages in the topic */ messagesCount: bigint; /** Options the client explicitly sent at create */ options: ParsedOptions; /** Options resolved from server defaults at create */ derivedOptions: ParsedOptions; }; /** * Partition information within a topic. */ export type Partition = { /** Partition ID */ id: number; /** Partition creation timestamp */ createdAt: Date; /** Number of segments in the partition */ segmentsCount: number; /** Current offset in the partition */ currentOffset: bigint; /** Total size of the partition in bytes */ sizeBytes: bigint; /** Total number of messages in the partition */ messagesCount: bigint; }; /** Topic with partition details */ export type Topic = BaseTopic & { partitions: Partition[]; }; /** Base serialization result */ type Serialized = { bytesRead: number; }; /** Result of deserializing a partition */ type PartitionSerialized = { data: Partition; } & Serialized; /** Result of deserializing a base topic */ type BaseTopicSerialized = { data: BaseTopic; } & Serialized; /** Result of deserializing a topic */ type TopicSerialized = { data: Topic; } & Serialized; /** * Compression algorithm options. */ export declare const CompressionAlgorithm: { /** No compression */ None: number; /** Gzip compression */ Gzip: number; }; /** Type alias for the CompressionAlgorithm object */ export type CompressionAlgorithmKind = typeof CompressionAlgorithm; /** String literal type of compression algorithm names */ export type CompressionAlgorithmKindId = keyof CompressionAlgorithm; /** Numeric values of compression algorithms */ export type CompressionAlgorithmKindValue = ValueOf; /** No compression type */ export type CompressionAlgorithmNone = CompressionAlgorithmKind['None']; /** Gzip compression type */ export type CompressionAlgorithmGzip = CompressionAlgorithmKind['Gzip']; /** Union of compression algorithm types */ export type CompressionAlgorithm = CompressionAlgorithmNone | CompressionAlgorithmGzip; /** * Type guard for valid compression algorithms. * * @param ca - Compression algorithm value to check * @returns True if the value is a valid compression algorithm */ export declare const isValidCompressionAlgorithm: (ca: number) => ca is CompressionAlgorithm; /** * Maps a compression algorithm code to its wire option name. * * @param ca - Compression algorithm code * @returns Option value string ('none' or 'gzip') */ export declare const compressionAlgorithmName: (ca: CompressionAlgorithm) => string; /** * Deserializes a topic header from a buffer. * Layout: 50 fixed bytes, name, then two length-prefixed options blocks * (client-explicit and server-derived). * * @param p - Buffer containing serialized topic data * @param pos - Starting position in the buffer * @returns Object with bytes read and deserialized topic data */ export declare const deserializeBaseTopic: (p: Buffer, pos?: number) => BaseTopicSerialized; /** * Deserializes a partition from a buffer. * * @param p - Buffer containing serialized partition data * @param pos - Starting position in the buffer * @returns Object with bytes read and deserialized partition data */ export declare const deserializePartition: (p: Buffer, pos?: number) => PartitionSerialized; /** * Deserializes a topic with partitions from a buffer. * Partition elements are count-driven from the topic's partitionsCount: * the header's variable-length options blocks make greedy consumption * ambiguous. * * @param p - Buffer containing serialized topic data * @param pos - Starting position in the buffer * @returns Object with bytes read and deserialized topic with partitions * @throws Error if the buffer is empty (topic does not exist) */ export declare const deserializeTopic: (p: Buffer, pos?: number) => TopicSerialized; /** * Deserializes a GetTopics response: `[topics_count:u32_le]` prefix followed * by count-driven topic headers (no partition details). * * @param p - Buffer containing serialized topics data * @param pos - Starting position in the buffer * @returns Array of deserialized topics */ export declare const deserializeTopics: (p: Buffer, pos?: number) => Topic[]; export declare const Durability: { readonly Replicated: "replicated"; readonly Persisted: "persisted"; }; export type Durability = typeof Durability[keyof typeof Durability]; export {}; //# sourceMappingURL=topic.utils.d.ts.map