import { Destination as Destination$1, SetupFn as SetupFn$1 } from '@walkeros/core'; import { DestinationServer } from '@walkeros/server-core'; /** * Mock-friendly Producer interface used by the destination. * Tests provide this via env.Kafka; production creates a real * kafkajs Producer and adapts it through settings._producer. */ interface KafkaProducerMock { connect: () => Promise; disconnect: () => Promise; send: (record: ProducerRecord) => Promise; } /** * Mock-friendly Admin interface used by setup (subset of kafkajs.Admin). * Tests provide this via env.Kafka; production creates a real * kafkajs Admin client. */ interface KafkaAdminMock { connect: () => Promise; disconnect: () => Promise; createTopics: (args: { topics: Array<{ topic: string; numPartitions: number; replicationFactor: number; configEntries?: Array<{ name: string; value: string; }>; }>; validateOnly?: boolean; waitForLeaders?: boolean; timeout?: number; }) => Promise; fetchTopicMetadata: (args: { topics?: string[]; }) => Promise<{ topics: Array<{ name: string; partitions: Array<{ partitionId: number; leader: number; replicas: number[]; isr: number[]; }>; }>; }>; describeConfigs: (args: { resources: Array<{ type: number; name: string; }>; includeSynonyms?: boolean; }) => Promise<{ resources: Array<{ resourceName: string; configEntries: Array<{ configName: string; configValue: string; }>; }>; }>; } /** * Mock-friendly Kafka client interface (subset of kafkajs.Kafka). */ interface KafkaClientMock { producer: (config?: ProducerConfig) => KafkaProducerMock; admin: () => KafkaAdminMock; } /** * Constructor signature for the Kafka client. Accepts a config * object and returns a client with producer() factory. */ type KafkaClientConstructor = new (config: KafkaClientConfig) => KafkaClientMock; interface KafkaClientConfig { clientId?: string; brokers: string[]; ssl?: boolean | Record; sasl?: SASLConfig; connectionTimeout?: number; requestTimeout?: number; retry?: RetryConfig; } interface ProducerConfig { allowAutoTopicCreation?: boolean; idempotent?: boolean; } interface ProducerRecord { topic: string; messages: ProducerMessage[]; acks?: number; compression?: number; timeout?: number; } interface ProducerMessage { key?: string; value: string; headers?: Record; timestamp?: string; partition?: number; } interface CompressionTypesMap { None: number; GZIP: number; Snappy: number; LZ4: number; ZSTD: number; } type CompressionType = 'none' | 'gzip' | 'snappy' | 'lz4' | 'zstd'; interface SASLConfig { mechanism: 'plain' | 'scram-sha-256' | 'scram-sha-512' | 'aws' | 'oauthbearer'; username?: string; password?: string; accessKeyId?: string; secretAccessKey?: string; sessionToken?: string; authorizationIdentity?: string; } interface RetryConfig { maxRetryTime?: number; initialRetryTime?: number; retries?: number; } interface KafkaSettings { brokers: string[]; clientId?: string; ssl?: boolean | Record; sasl?: SASLConfig; connectionTimeout?: number; requestTimeout?: number; topic: string; acks?: number; timeout?: number; compression?: CompressionType; idempotent?: boolean; allowAutoTopicCreation?: boolean; key?: string; headers?: Record; retry?: RetryConfig; _producer?: KafkaProducerMock; } interface Settings { kafka: KafkaSettings; } type InitSettings = Partial; interface Mapping { /** Override message key mapping path for this rule. */ key?: string; /** Override topic for this rule. */ topic?: string; } /** * Env -- optional Kafka SDK override. Production leaves this undefined * and the destination creates real Kafka client instances. Tests provide * mocks via env.Kafka. */ interface Env extends DestinationServer.Env { Kafka?: { Kafka: KafkaClientConstructor; CompressionTypes: CompressionTypesMap; }; } /** * Provisioning options for `walkeros setup destination.`. * * Triggered only by the explicit CLI command. Idempotent. Never auto-run. * * NO SAFE DEFAULTS for `numPartitions` or `replicationFactor`: these are * cluster-specific operational decisions and depend on broker count, * expected throughput, and consumer parallelism. Both fields are optional * in the TypeScript shape (config often comes from JSON), but the runtime * REQUIRES both. Missing values throw with an actionable message. The * boolean form (setup: true) is rejected at runtime; only the object form * is valid. */ interface Setup { topic?: string; numPartitions?: number; replicationFactor?: number; configEntries?: Record; schemaRegistry?: SchemaRegistrySetup; validateOnly?: boolean; } interface SchemaRegistrySetup { url: string; subject: string; schemaType: 'AVRO' | 'JSON' | 'PROTOBUF'; schema: string; compatibility?: 'BACKWARD' | 'FORWARD' | 'FULL' | 'NONE' | 'BACKWARD_TRANSITIVE' | 'FORWARD_TRANSITIVE' | 'FULL_TRANSITIVE'; auth?: { username: string; password: string; }; } type Types = Destination$1.Types; interface Destination extends DestinationServer.Destination { init: DestinationServer.InitFn; } type Config = { settings: Settings; } & DestinationServer.Config; type InitFn = DestinationServer.InitFn; type PushFn = DestinationServer.PushFn; type SetupFn = SetupFn$1; type PartialConfig = DestinationServer.PartialConfig; type PushEvents = DestinationServer.PushEvents; type index_CompressionType = CompressionType; type index_CompressionTypesMap = CompressionTypesMap; type index_Config = Config; type index_Destination = Destination; type index_Env = Env; type index_InitFn = InitFn; type index_InitSettings = InitSettings; type index_KafkaAdminMock = KafkaAdminMock; type index_KafkaClientConfig = KafkaClientConfig; type index_KafkaClientConstructor = KafkaClientConstructor; type index_KafkaClientMock = KafkaClientMock; type index_KafkaProducerMock = KafkaProducerMock; type index_KafkaSettings = KafkaSettings; type index_Mapping = Mapping; type index_PartialConfig = PartialConfig; type index_ProducerConfig = ProducerConfig; type index_ProducerMessage = ProducerMessage; type index_ProducerRecord = ProducerRecord; type index_PushEvents = PushEvents; type index_PushFn = PushFn; type index_RetryConfig = RetryConfig; type index_SASLConfig = SASLConfig; type index_SchemaRegistrySetup = SchemaRegistrySetup; type index_Settings = Settings; type index_Setup = Setup; type index_SetupFn = SetupFn; type index_Types = Types; declare namespace index { export type { index_CompressionType as CompressionType, index_CompressionTypesMap as CompressionTypesMap, index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_KafkaAdminMock as KafkaAdminMock, index_KafkaClientConfig as KafkaClientConfig, index_KafkaClientConstructor as KafkaClientConstructor, index_KafkaClientMock as KafkaClientMock, index_KafkaProducerMock as KafkaProducerMock, index_KafkaSettings as KafkaSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_ProducerConfig as ProducerConfig, index_ProducerMessage as ProducerMessage, index_ProducerRecord as ProducerRecord, index_PushEvents as PushEvents, index_PushFn as PushFn, index_RetryConfig as RetryConfig, index_SASLConfig as SASLConfig, index_SchemaRegistrySetup as SchemaRegistrySetup, index_Settings as Settings, index_Setup as Setup, index_SetupFn as SetupFn, index_Types as Types }; } declare const destinationKafka: Destination; export { index as DestinationKafka, destinationKafka as default, destinationKafka };