diff --git a/types/kafka-node/index.d.ts b/types/kafka-node/index.d.ts index b90acfa762..441f9e88c2 100644 --- a/types/kafka-node/index.d.ts +++ b/types/kafka-node/index.d.ts @@ -5,6 +5,7 @@ // Michael Haan // Amiram Korach // Insanehong +// Roger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -103,9 +104,32 @@ export class KeyedMessage { export class Admin { constructor(kafkaClient: KafkaClient); listGroups(cb: (error: any, data: any) => any): void; - describeGroups(consumerGroups: any, cb: (error: any, data: any) => any): void; + describeGroups( + consumerGroups: any, + cb: (error: any, data: any) => any, + ): void; + listTopics(cb: (error: any, data: any) => any): void; + createTopics( + topics: TopicConfigData[], + cb: (error: any, data: any) => any, + ): void; + describeConfigs( + payload: { resources: Resource[]; includeSynonyms: boolean }, + cb: (error: any, data: any) => any, + ): void; +} +export interface Resource { + resourceType: string; + resourceName: string; + configNames: string[]; } +export interface TopicConfigData { + topic: string; + partitions?: number; + replicationFactor?: number; + configEntry?: Array<{ name: string; value: string }>; +} // # Interfaces export interface Message { @@ -115,7 +139,7 @@ export interface Message { partition?: number; highWaterOffset?: number; key?: string; - } +} export interface ProducerOptions { requireAcks?: number; @@ -173,10 +197,10 @@ export interface ConsumerOptions { } export interface HighLevelConsumerOptions extends ConsumerOptions { - id?: string; - maxNumSegments?: number; - maxTickMessages?: number; - rebalanceRetry?: RetryOptions; + id?: string; + maxNumSegments?: number; + maxTickMessages?: number; + rebalanceRetry?: RetryOptions; } export interface CustomPartitionAssignmentProtocol { diff --git a/types/kafka-node/kafka-node-tests.ts b/types/kafka-node/kafka-node-tests.ts index 0a8713aa27..7af6d11358 100644 --- a/types/kafka-node/kafka-node-tests.ts +++ b/types/kafka-node/kafka-node-tests.ts @@ -280,3 +280,19 @@ admin.listGroups((err, data) => { }); admin.describeGroups({}, (err, data) => { }); +admin.createTopics([{ topic: 'testing' }], (err, data) => {}); +admin.listTopics((err, data) => { +}); + +const resource = { + resourceType: "", // 'broker' or 'topic' + resourceName: 'my-topic-name', + configNames: [] // specific config names, or empty array to return all, +}; +const payload = { + resources: [resource], + includeSynonyms: false // requires kafka 2.0+ +}; +admin.describeConfigs(payload, (err, res) => { + console.log(JSON.stringify(res, null, 1)); +});