kafka-ts
Version:
**KafkaTS** is a Apache Kafka client library for Node.js. It provides both a low-level API for communicating directly with the Apache Kafka cluster and high-level APIs for publishing and subscribing to Kafka topics.
506 lines (505 loc) • 16.2 kB
TypeScript
import { Api } from '../utils/api';
export declare const API: {
API_VERSIONS: Api<{}, {
errorCode: number;
versions: {
apiKey: number;
minVersion: number;
maxVersion: number;
}[];
throttleTimeMs: number;
}>;
CREATE_TOPICS: Api<{
topics: {
name: string;
numPartitions?: number;
replicationFactor?: number;
assignments?: {
partitionIndex: number;
brokerIds: number[];
}[];
configs?: {
name: string;
value: string | null;
}[];
}[];
timeoutMs?: number;
validateOnly?: boolean;
}, {
throttleTimeMs: number;
topics: {
name: string;
_topicId: string;
errorCode: number;
errorMessage: string | null;
_numPartitions: number;
_replicationFactor: number;
configs: {
name: string;
value: string | null;
readOnly: boolean;
configSource: number;
isSensitive: boolean;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
DELETE_TOPICS: Api<{
topics: {
name: string;
topicId: string | null;
}[];
timeoutMs?: number;
}, {
throttleTimeMs: number;
responses: {
name: string | null;
_topicId: string;
errorCode: number;
errorMessage: string | null;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
FETCH: Api<{
maxWaitMs: number;
minBytes: number;
maxBytes: number;
isolationLevel: import("./fetch").IsolationLevel;
sessionId: number;
sessionEpoch: number;
topics: {
topicId: string;
topicName: string;
partitions: {
partition: number;
currentLeaderEpoch: number;
fetchOffset: bigint;
lastFetchedEpoch: number;
logStartOffset: bigint;
partitionMaxBytes: number;
}[];
}[];
forgottenTopicsData: {
topicId: string;
topicName: string;
partitions: number[];
}[];
rackId: string;
}, import("./fetch").FetchResponse>;
FIND_COORDINATOR: Api<{
keyType: number;
keys: string[];
}, {
throttleTimeMs: number;
coordinators: {
key: string;
nodeId: number;
host: string;
port: number;
errorCode: number;
errorMessage: string | null;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
HEARTBEAT: Api<{
groupId: string;
generationId: number;
memberId: string;
groupInstanceId: string | null;
}, {
throttleTimeMs: number;
errorCode: number;
tags: Record<number, Buffer>;
}>;
INIT_PRODUCER_ID: Api<{
transactionalId: string | null;
transactionTimeoutMs: number;
producerId: bigint;
producerEpoch: number;
}, {
throttleTimeMs: number;
errorCode: number;
producerId: bigint;
producerEpoch: number;
tags: Record<number, Buffer>;
}>;
JOIN_GROUP: Api<{
groupId: string;
sessionTimeoutMs: number;
rebalanceTimeoutMs: number;
memberId: string;
groupInstanceId: string | null;
protocolType: string;
protocols: {
name: string;
metadata: {
version: number;
topics: string[];
};
}[];
reason: string | null;
}, {
throttleTimeMs: number;
errorCode: number;
generationId: number;
protocolType: string | null;
protocolName: string | null;
leader: string;
skipAssignment: boolean;
memberId: string;
members: {
memberId: string;
groupInstanceId: string | null;
metadata: Buffer;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
LEAVE_GROUP: Api<{
groupId: string;
members: {
memberId: string;
groupInstanceId: string | null;
reason: string | null;
}[];
}, {
throttleTimeMs: number;
errorCode: number;
members: {
memberId: string;
groupInstanceId: string | null;
errorCode: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
LIST_OFFSETS: Api<{
replicaId: number;
isolationLevel: import("./fetch").IsolationLevel;
topics: {
name: string;
partitions: {
partitionIndex: number;
currentLeaderEpoch: number;
timestamp: bigint;
}[];
}[];
}, {
throttleTimeMs: number;
topics: {
name: string;
partitions: {
partitionIndex: number;
errorCode: number;
timestamp: bigint;
offset: bigint;
leaderEpoch: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
METADATA: Api<{
topics?: {
id: string | null;
name: string;
}[] | null;
allowTopicAutoCreation?: boolean;
includeTopicAuthorizedOperations?: boolean;
}, {
throttleTimeMs: number;
brokers: {
nodeId: number;
host: string;
port: number;
rack: string | null;
}[];
clusterId: string | null;
controllerId: number;
topics: {
errorCode: number;
name: string;
topicId: string;
isInternal: boolean;
partitions: {
errorCode: number;
partitionIndex: number;
leaderId: number;
leaderEpoch: number;
replicaNodes: number[];
isrNodes: number[];
offlineReplicas: number[];
tags: Record<number, Buffer>;
}[];
topicAuthorizedOperations: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
OFFSET_COMMIT: Api<{
groupId: string;
generationIdOrMemberEpoch: number;
memberId: string;
groupInstanceId: string | null;
topics: {
name: string;
partitions: {
partitionIndex: number;
committedOffset: bigint;
committedLeaderEpoch: number;
committedMetadata: string | null;
}[];
}[];
}, {
throttleTimeMs: number;
topics: {
name: string;
partitions: {
partitionIndex: number;
errorCode: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
OFFSET_FETCH: Api<{
groups: {
groupId: string;
topics: {
name: string;
partitionIndexes: number[];
}[];
}[];
requireStable: boolean;
}, {
throttleTimeMs: number;
groups: {
groupId: string;
topics: {
name: string;
partitions: {
partitionIndex: number;
committedOffset: bigint;
committedLeaderEpoch: number;
committedMetadata: string | null;
errorCode: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}[];
errorCode: number;
tags: Record<number, Buffer>;
}[];
tags: Record<number, Buffer>;
}>;
PRODUCE: Api<{
transactionalId: string | null;
acks: number;
timeoutMs: number;
topicData: {
name: string;
partitionData: {
index: number;
baseOffset: bigint;
partitionLeaderEpoch: number;
attributes: number;
lastOffsetDelta: number;
baseTimestamp: bigint;
maxTimestamp: bigint;
producerId: bigint;
producerEpoch: number;
baseSequence: number;
records: {
attributes: number;
timestampDelta: bigint;
offsetDelta: number;
key: string | null;
value: string | null;
headers: {
key: string;
value: string;
}[];
}[];
}[];
}[];
}, {
responses: {
name: string;
partitionResponses: {
index: number;
errorCode: number;
baseOffset: bigint;
logAppendTime: bigint;
logStartOffset: bigint;
recordErrors: {
batchIndex: number;
batchIndexErrorMessage: string | null;
}[];
errorMessage: string | null;
}[];
}[];
throttleTimeMs: number;
}>;
SASL_AUTHENTICATE: Api<{
authBytes: Buffer;
}, {
errorCode: number;
errorMessage: string | null;
authBytes: Buffer;
sessionLifetimeMs: bigint;
tags: Record<number, Buffer>;
}>;
SASL_HANDSHAKE: Api<{
mechanism: string;
}, {
errorCode: number;
mechanisms: string[];
}>;
SYNC_GROUP: Api<{
groupId: string;
generationId: number;
memberId: string;
groupInstanceId: string | null;
protocolType: string | null;
protocolName: string | null;
assignments: import("./sync-group").MemberAssignment[];
}, {
throttleTimeMs: number;
errorCode: number;
protocolType: string | null;
protocolName: string | null;
assignment: import("./sync-group").Assignment;
tags: Record<number, Buffer>;
}>;
};
export declare const getApiName: <Request, Response>(api: Api<Request, Response>) => string;
export declare const API_ERROR: {
readonly UNKNOWN_SERVER_ERROR: -1;
readonly OFFSET_OUT_OF_RANGE: 1;
readonly CORRUPT_MESSAGE: 2;
readonly UNKNOWN_TOPIC_OR_PARTITION: 3;
readonly INVALID_FETCH_SIZE: 4;
readonly LEADER_NOT_AVAILABLE: 5;
readonly NOT_LEADER_OR_FOLLOWER: 6;
readonly REQUEST_TIMED_OUT: 7;
readonly BROKER_NOT_AVAILABLE: 8;
readonly REPLICA_NOT_AVAILABLE: 9;
readonly MESSAGE_TOO_LARGE: 10;
readonly STALE_CONTROLLER_EPOCH: 11;
readonly OFFSET_METADATA_TOO_LARGE: 12;
readonly NETWORK_EXCEPTION: 13;
readonly COORDINATOR_LOAD_IN_PROGRESS: 14;
readonly COORDINATOR_NOT_AVAILABLE: 15;
readonly NOT_COORDINATOR: 16;
readonly INVALID_TOPIC_EXCEPTION: 17;
readonly RECORD_LIST_TOO_LARGE: 18;
readonly NOT_ENOUGH_REPLICAS: 19;
readonly NOT_ENOUGH_REPLICAS_AFTER_APPEND: 20;
readonly INVALID_REQUIRED_ACKS: 21;
readonly ILLEGAL_GENERATION: 22;
readonly INCONSISTENT_GROUP_PROTOCOL: 23;
readonly INVALID_GROUP_ID: 24;
readonly UNKNOWN_MEMBER_ID: 25;
readonly INVALID_SESSION_TIMEOUT: 26;
readonly REBALANCE_IN_PROGRESS: 27;
readonly INVALID_COMMIT_OFFSET_SIZE: 28;
readonly TOPIC_AUTHORIZATION_FAILED: 29;
readonly GROUP_AUTHORIZATION_FAILED: 30;
readonly CLUSTER_AUTHORIZATION_FAILED: 31;
readonly INVALID_TIMESTAMP: 32;
readonly UNSUPPORTED_SASL_MECHANISM: 33;
readonly ILLEGAL_SASL_STATE: 34;
readonly UNSUPPORTED_VERSION: 35;
readonly TOPIC_ALREADY_EXISTS: 36;
readonly INVALID_PARTITIONS: 37;
readonly INVALID_REPLICATION_FACTOR: 38;
readonly INVALID_REPLICA_ASSIGNMENT: 39;
readonly INVALID_CONFIG: 40;
readonly NOT_CONTROLLER: 41;
readonly INVALID_REQUEST: 42;
readonly UNSUPPORTED_FOR_MESSAGE_FORMAT: 43;
readonly POLICY_VIOLATION: 44;
readonly OUT_OF_ORDER_SEQUENCE_NUMBER: 45;
readonly DUPLICATE_SEQUENCE_NUMBER: 46;
readonly INVALID_PRODUCER_EPOCH: 47;
readonly INVALID_TXN_STATE: 48;
readonly INVALID_PRODUCER_ID_MAPPING: 49;
readonly INVALID_TRANSACTION_TIMEOUT: 50;
readonly CONCURRENT_TRANSACTIONS: 51;
readonly TRANSACTION_COORDINATOR_FENCED: 52;
readonly TRANSACTIONAL_ID_AUTHORIZATION_FAILED: 53;
readonly SECURITY_DISABLED: 54;
readonly OPERATION_NOT_ATTEMPTED: 55;
readonly KAFKA_STORAGE_ERROR: 56;
readonly LOG_DIR_NOT_FOUND: 57;
readonly SASL_AUTHENTICATION_FAILED: 58;
readonly UNKNOWN_PRODUCER_ID: 59;
readonly REASSIGNMENT_IN_PROGRESS: 60;
readonly DELEGATION_TOKEN_AUTH_DISABLED: 61;
readonly DELEGATION_TOKEN_NOT_FOUND: 62;
readonly DELEGATION_TOKEN_OWNER_MISMATCH: 63;
readonly DELEGATION_TOKEN_REQUEST_NOT_ALLOWED: 64;
readonly DELEGATION_TOKEN_AUTHORIZATION_FAILED: 65;
readonly DELEGATION_TOKEN_EXPIRED: 66;
readonly INVALID_PRINCIPAL_TYPE: 67;
readonly NON_EMPTY_GROUP: 68;
readonly GROUP_ID_NOT_FOUND: 69;
readonly FETCH_SESSION_ID_NOT_FOUND: 70;
readonly INVALID_FETCH_SESSION_EPOCH: 71;
readonly LISTENER_NOT_FOUND: 72;
readonly TOPIC_DELETION_DISABLED: 73;
readonly FENCED_LEADER_EPOCH: 74;
readonly UNKNOWN_LEADER_EPOCH: 75;
readonly UNSUPPORTED_COMPRESSION_TYPE: 76;
readonly STALE_BROKER_EPOCH: 77;
readonly OFFSET_NOT_AVAILABLE: 78;
readonly MEMBER_ID_REQUIRED: 79;
readonly PREFERRED_LEADER_NOT_AVAILABLE: 80;
readonly GROUP_MAX_SIZE_REACHED: 81;
readonly FENCED_INSTANCE_ID: 82;
readonly ELIGIBLE_LEADERS_NOT_AVAILABLE: 83;
readonly ELECTION_NOT_NEEDED: 84;
readonly NO_REASSIGNMENT_IN_PROGRESS: 85;
readonly GROUP_SUBSCRIBED_TO_TOPIC: 86;
readonly INVALID_RECORD: 87;
readonly UNSTABLE_OFFSET_COMMIT: 88;
readonly THROTTLING_QUOTA_EXCEEDED: 89;
readonly PRODUCER_FENCED: 90;
readonly RESOURCE_NOT_FOUND: 91;
readonly DUPLICATE_RESOURCE: 92;
readonly UNACCEPTABLE_CREDENTIAL: 93;
readonly INCONSISTENT_VOTER_SET: 94;
readonly INVALID_UPDATE_VERSION: 95;
readonly FEATURE_UPDATE_FAILED: 96;
readonly PRINCIPAL_DESERIALIZATION_FAILURE: 97;
readonly SNAPSHOT_NOT_FOUND: 98;
readonly POSITION_OUT_OF_RANGE: 99;
readonly UNKNOWN_TOPIC_ID: 100;
readonly DUPLICATE_BROKER_REGISTRATION: 101;
readonly BROKER_ID_NOT_REGISTERED: 102;
readonly INCONSISTENT_TOPIC_ID: 103;
readonly INCONSISTENT_CLUSTER_ID: 104;
readonly TRANSACTIONAL_ID_NOT_FOUND: 105;
readonly FETCH_SESSION_TOPIC_ID_ERROR: 106;
readonly INELIGIBLE_REPLICA: 107;
readonly NEW_LEADER_ELECTED: 108;
readonly OFFSET_MOVED_TO_TIERED_STORAGE: 109;
readonly FENCED_MEMBER_EPOCH: 110;
readonly UNRELEASED_INSTANCE_ID: 111;
readonly UNSUPPORTED_ASSIGNOR: 112;
readonly STALE_MEMBER_EPOCH: 113;
readonly MISMATCHED_ENDPOINT_TYPE: 114;
readonly UNSUPPORTED_ENDPOINT_TYPE: 115;
readonly UNKNOWN_CONTROLLER_ID: 116;
readonly UNKNOWN_SUBSCRIPTION_ID: 117;
readonly TELEMETRY_TOO_LARGE: 118;
readonly INVALID_REGISTRATION: 119;
readonly TRANSACTION_ABORTABLE: 120;
};
export declare const handleApiError: (error: unknown) => Promise<void>;