conduithub 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/core/conduit-hub/index.cjs +1 -1
  2. package/dist/core/conduit-hub/index.d.cts +1 -1
  3. package/dist/core/conduit-hub/index.d.mts +1 -1
  4. package/dist/core/conduit-hub/index.d.ts +1 -1
  5. package/dist/core/conduit-hub/index.mjs +1 -1
  6. package/dist/core/config-manager/index.d.cts +1 -1
  7. package/dist/core/config-manager/index.d.mts +1 -1
  8. package/dist/core/config-manager/index.d.ts +1 -1
  9. package/dist/core/event-bus/index.cjs +4 -4
  10. package/dist/core/event-bus/index.mjs +1 -1
  11. package/dist/core/hook/index.cjs +6 -6
  12. package/dist/core/hook/index.mjs +1 -1
  13. package/dist/core/index.cjs +5 -3
  14. package/dist/core/index.d.cts +8 -184
  15. package/dist/core/index.d.mts +8 -184
  16. package/dist/core/index.d.ts +8 -184
  17. package/dist/core/index.mjs +4 -3
  18. package/dist/core/plugin/index.d.cts +1 -1
  19. package/dist/core/plugin/index.d.mts +1 -1
  20. package/dist/core/plugin/index.d.ts +1 -1
  21. package/dist/core/service-container/index.cjs +9 -9
  22. package/dist/core/service-container/index.mjs +1 -1
  23. package/dist/core/state-manager/index.cjs +3 -3
  24. package/dist/core/state-manager/index.mjs +1 -1
  25. package/dist/{shared/conduithub.BqUYv04j.cjs → error/index.cjs} +3 -0
  26. package/dist/error/index.d.cts +47 -0
  27. package/dist/error/index.d.mts +47 -0
  28. package/dist/error/index.d.ts +47 -0
  29. package/dist/{shared/conduithub.BDwZXllF.mjs → error/index.mjs} +3 -1
  30. package/dist/index.cjs +191 -16
  31. package/dist/index.d.cts +65 -47
  32. package/dist/index.d.mts +65 -47
  33. package/dist/index.d.ts +65 -47
  34. package/dist/index.mjs +161 -5
  35. package/dist/plugins/index.cjs +40 -0
  36. package/dist/plugins/index.d.cts +10 -0
  37. package/dist/plugins/index.d.mts +10 -0
  38. package/dist/plugins/index.d.ts +10 -0
  39. package/dist/plugins/index.mjs +24 -0
  40. package/dist/plugins/kafka/index.cjs +34 -0
  41. package/dist/plugins/kafka/index.d.cts +250 -0
  42. package/dist/plugins/kafka/index.d.mts +250 -0
  43. package/dist/plugins/kafka/index.d.ts +250 -0
  44. package/dist/plugins/kafka/index.mjs +23 -0
  45. package/dist/plugins/redis/index.cjs +33 -0
  46. package/dist/plugins/redis/index.d.cts +151 -0
  47. package/dist/plugins/redis/index.d.mts +151 -0
  48. package/dist/plugins/redis/index.d.ts +151 -0
  49. package/dist/plugins/redis/index.mjs +23 -0
  50. package/dist/shared/conduithub.0FKJet8c.cjs +1130 -0
  51. package/dist/shared/conduithub.B16qn6pY.mjs +174 -0
  52. package/dist/shared/conduithub.BW-S7Bp_.d.cts +181 -0
  53. package/dist/shared/conduithub.BdX_BLza.mjs +1124 -0
  54. package/dist/shared/conduithub.BzuAKyjY.mjs +971 -0
  55. package/dist/shared/conduithub.DSAmRivG.d.ts +181 -0
  56. package/dist/shared/conduithub.DhMIxMx2.cjs +981 -0
  57. package/dist/shared/{conduithub.gF2DFc43.cjs → conduithub.Dlvl2xGE.cjs} +3 -3
  58. package/dist/shared/conduithub.GrtzQn_7.d.mts +181 -0
  59. package/dist/shared/{conduithub.bsiNMTVD.mjs → conduithub.Up0QYVao.mjs} +1 -1
  60. package/dist/shared/conduithub.jH-df3Zd.cjs +181 -0
  61. package/dist/utils/index.cjs +3 -2
  62. package/dist/utils/index.mjs +3 -2
  63. package/package.json +22 -1
package/dist/index.mjs CHANGED
@@ -1,16 +1,172 @@
1
+ import { existsSync } from 'node:fs';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { ConduithubError } from './error/index.mjs';
5
+ export { MissingDependencyError, getPkgManager, setPkgManager } from './error/index.mjs';
6
+ import { p as parseJson } from './shared/conduithub.alPiaJax.mjs';
7
+ export { a as safeStringifyJson, s as stringifyJson } from './shared/conduithub.alPiaJax.mjs';
8
+ import { a as logger } from './shared/conduithub.BNefRQsK.mjs';
9
+ export { c as createLogger, l as levels, s as shouldPublishLog } from './shared/conduithub.BNefRQsK.mjs';
10
+ import { E as ERROR_CODE } from './shared/conduithub.G7ICpZIy.mjs';
11
+ export { K as KafkaPluginConfigSchema, c as conduithubConfigSchema, a as createConfigSchema, e as extendConfigSchema, m as mergeConfigSchemas } from './shared/conduithub.B16qn6pY.mjs';
12
+ export { ConduitHub } from './core/conduit-hub/index.mjs';
1
13
  export { ConfigManager } from './core/config-manager/index.mjs';
2
14
  export { EventBus } from './core/event-bus/index.mjs';
3
15
  export { Hook } from './core/hook/index.mjs';
4
16
  export { BasePlugin } from './core/plugin/index.mjs';
5
17
  export { ServiceContainer } from './core/service-container/index.mjs';
6
18
  export { StateManager } from './core/state-manager/index.mjs';
7
- export { C as ConduithubError, M as MissingDependencyError, g as getPkgManager, s as setPkgManager } from './shared/conduithub.BDwZXllF.mjs';
8
- export { p as parseJson, a as safeStringifyJson, s as stringifyJson } from './shared/conduithub.alPiaJax.mjs';
9
- export { c as createLogger, l as levels, a as logger, s as shouldPublishLog } from './shared/conduithub.BNefRQsK.mjs';
10
- export { P as PackageManagerUtil, p as packageManagerUtil } from './shared/conduithub.bsiNMTVD.mjs';
19
+ export { K as KafkaPlugin, g as getKafka, i as initKafka, k as kafka, s as shutdownKafka } from './shared/conduithub.BdX_BLza.mjs';
20
+ export { R as RedisPlugin, g as getRedis, i as initRedis, r as redis, s as shutdownRedis } from './shared/conduithub.BzuAKyjY.mjs';
21
+ export { P as PackageManagerUtil, p as packageManagerUtil } from './shared/conduithub.Up0QYVao.mjs';
11
22
  export { a as generateShortId, g as generateUuid, i as isValidUuid } from './shared/conduithub.CkOQG3cD.mjs';
12
23
  export { P as PluginManager } from './shared/conduithub.DyQQrHW9.mjs';
13
- export { E as ERROR_CODE } from './shared/conduithub.G7ICpZIy.mjs';
24
+ import 'zod';
14
25
  import 'process';
15
26
  import 'readline';
16
27
  import 'uuid';
28
+ import 'ioredis';
29
+
30
+ async function loadConfig(options = {}) {
31
+ const {
32
+ filePath = "./config.json",
33
+ envPrefix = "CONDUIT_",
34
+ defaults = {},
35
+ schema,
36
+ override = {}
37
+ } = options;
38
+ let config = { ...defaults };
39
+ try {
40
+ const fileConfig = await loadConfigFromFile(filePath);
41
+ config = mergeConfigs(config, fileConfig);
42
+ } catch (error) {
43
+ handleConfigLoadError(error, filePath);
44
+ }
45
+ const envConfig = loadConfigFromEnv(envPrefix);
46
+ config = mergeConfigs(config, envConfig, override);
47
+ if (schema) {
48
+ return validateConfigWithSchema(config, schema);
49
+ }
50
+ return config;
51
+ }
52
+ function handleConfigLoadError(error, filePath) {
53
+ if (error instanceof Error && error.code !== "ENOENT") {
54
+ logger.warn(`Could not load config file ${filePath}:`, error.message);
55
+ }
56
+ }
57
+ function validateConfigWithSchema(config, schema) {
58
+ const result = schema.safeParse(config);
59
+ if (!result.success) {
60
+ throw new ConduithubError(
61
+ `${ERROR_CODE.INVALID_CONFIG}: ${result.error.message}`
62
+ );
63
+ }
64
+ return result.data;
65
+ }
66
+ async function loadConfigFromFile(filePath) {
67
+ const absolutePath = path.resolve(filePath);
68
+ const fileContent = await fs.readFile(absolutePath, "utf-8");
69
+ try {
70
+ const parsed = parseJson(fileContent);
71
+ if (!parsed) {
72
+ throw new ConduithubError(ERROR_CODE.INVALID_JSON);
73
+ }
74
+ return parsed;
75
+ } catch (jsonError) {
76
+ if (filePath.endsWith(".js")) {
77
+ throw new ConduithubError(ERROR_CODE.UNSUPPORTED_CONFIG_FORMAT);
78
+ }
79
+ throw jsonError;
80
+ }
81
+ }
82
+ function loadConfigFromEnv(prefix) {
83
+ const config = {};
84
+ for (const [key, value] of Object.entries(process.env)) {
85
+ if (key.startsWith(prefix) && value !== void 0) {
86
+ const configKey = key.slice(prefix.length);
87
+ const nestedKey = configKey.replace(/__/g, ".");
88
+ const typedValue = convertEnvValue(value);
89
+ setNestedValue(config, nestedKey.toLowerCase(), typedValue);
90
+ }
91
+ }
92
+ return config;
93
+ }
94
+ function convertEnvValue(value) {
95
+ try {
96
+ return JSON.parse(value);
97
+ } catch {
98
+ return convertPrimitiveValue(value);
99
+ }
100
+ }
101
+ function convertPrimitiveValue(value) {
102
+ const lower = value.toLowerCase();
103
+ if (lower === "true") return true;
104
+ if (lower === "false") return false;
105
+ if (lower === "null") return null;
106
+ if (lower === "undefined") return void 0;
107
+ if (/^-?\d+$/.test(value)) return parseInt(value, 10);
108
+ if (/^-?\d+\.\d+$/.test(value)) return parseFloat(value);
109
+ return value;
110
+ }
111
+ function setNestedValue(obj, path2, value) {
112
+ const keys = path2.split(".");
113
+ let current = obj;
114
+ for (let i = 0; i < keys.length - 1; i++) {
115
+ const key = keys[i];
116
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
117
+ current[key] = {};
118
+ }
119
+ current = current[key];
120
+ }
121
+ current[keys[keys.length - 1]] = value;
122
+ }
123
+ function createConfigLoader(schema) {
124
+ return async (options = {}) => {
125
+ return loadConfig({
126
+ ...options,
127
+ schema
128
+ });
129
+ };
130
+ }
131
+ function validateConfig(config, schema) {
132
+ const result = schema.safeParse(config);
133
+ if (!result.success) {
134
+ throw new ConduithubError(
135
+ `${ERROR_CODE.INVALID_CONFIG}: ${result.error.message}`
136
+ );
137
+ }
138
+ return result.data;
139
+ }
140
+ function mergeConfigs(...configs) {
141
+ return configs.reduce((merged, config) => deepMerge(merged, config), {});
142
+ }
143
+ function deepMerge(target, source) {
144
+ if (!isObject(target) || !isObject(source)) {
145
+ return source;
146
+ }
147
+ const result = { ...target };
148
+ for (const [key, sourceValue] of Object.entries(source)) {
149
+ const targetValue = result[key];
150
+ if (isObject(sourceValue) && !Array.isArray(sourceValue)) {
151
+ result[key] = deepMerge(targetValue, sourceValue);
152
+ } else {
153
+ result[key] = sourceValue;
154
+ }
155
+ }
156
+ return result;
157
+ }
158
+ function isObject(value) {
159
+ return typeof value === "object" && value !== null;
160
+ }
161
+ function getConfigFilePath(configName, configDir = "./config") {
162
+ const possibleExtensions = [".json", ".js", ".ts"];
163
+ for (const ext of possibleExtensions) {
164
+ const filePath = path.join(configDir, `${configName}${ext}`);
165
+ if (existsSync(filePath)) {
166
+ return filePath;
167
+ }
168
+ }
169
+ return path.join(configDir, `${configName}.json`);
170
+ }
171
+
172
+ export { ConduithubError, ERROR_CODE, createConfigLoader, getConfigFilePath, loadConfig, logger, mergeConfigs, parseJson, validateConfig };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const plugin = require('../shared/conduithub.0FKJet8c.cjs');
4
+ const schema = require('../shared/conduithub.jH-df3Zd.cjs');
5
+ const client = require('../shared/conduithub.DhMIxMx2.cjs');
6
+ require('node:fs');
7
+ require('node:fs/promises');
8
+ require('node:path');
9
+ require('../shared/conduithub.BNQsddJO.cjs');
10
+ require('../core/conduit-hub/index.cjs');
11
+ require('process');
12
+ require('readline');
13
+ require('uuid');
14
+ require('../core/config-manager/index.cjs');
15
+ require('../shared/conduithub.CmZo_Vuc.cjs');
16
+ require('../shared/conduithub.DQO1dRnn.cjs');
17
+ require('../core/event-bus/index.cjs');
18
+ require('../error/index.cjs');
19
+ require('../shared/conduithub.Bq_7Xj0J.cjs');
20
+ require('../core/hook/index.cjs');
21
+ require('../shared/conduithub.DsOOeNwU.cjs');
22
+ require('../core/service-container/index.cjs');
23
+ require('../core/state-manager/index.cjs');
24
+ require('../core/plugin/index.cjs');
25
+ require('ioredis');
26
+ require('zod');
27
+
28
+
29
+
30
+ exports.KafkaPlugin = plugin.KafkaPlugin;
31
+ exports.getKafka = plugin.getKafka;
32
+ exports.initKafka = plugin.initKafka;
33
+ exports.kafka = plugin.kafka;
34
+ exports.shutdownKafka = plugin.shutdownKafka;
35
+ exports.KafkaPluginConfigSchema = schema.KafkaPluginConfigSchema;
36
+ exports.RedisPlugin = client.RedisPlugin;
37
+ exports.getRedis = client.getRedis;
38
+ exports.initRedis = client.initRedis;
39
+ exports.redis = client.redis;
40
+ exports.shutdownRedis = client.shutdownRedis;
@@ -0,0 +1,10 @@
1
+ export { KafkaConnectionInfo, KafkaConsumerInfo, KafkaMessage, KafkaPlugin, KafkaPluginConfig, KafkaPluginConfigSchema, KafkaStats, getKafka, initKafka, kafka, shutdownKafka } from './kafka/index.cjs';
2
+ export { RedisPlugin, getRedis, initRedis, redis, shutdownRedis } from './redis/index.cjs';
3
+ import 'kafkajs';
4
+ import '../shared/conduithub.BW-S7Bp_.cjs';
5
+ import 'zod';
6
+ import '../core/hook/index.cjs';
7
+ import '../shared/conduithub.B7aryjPG.cjs';
8
+ import '../shared/conduithub.BZQmkQy7.cjs';
9
+ import '../core/service-container/index.cjs';
10
+ import '../core/state-manager/index.cjs';
@@ -0,0 +1,10 @@
1
+ export { KafkaConnectionInfo, KafkaConsumerInfo, KafkaMessage, KafkaPlugin, KafkaPluginConfig, KafkaPluginConfigSchema, KafkaStats, getKafka, initKafka, kafka, shutdownKafka } from './kafka/index.mjs';
2
+ export { RedisPlugin, getRedis, initRedis, redis, shutdownRedis } from './redis/index.mjs';
3
+ import 'kafkajs';
4
+ import '../shared/conduithub.GrtzQn_7.mjs';
5
+ import 'zod';
6
+ import '../core/hook/index.mjs';
7
+ import '../shared/conduithub.B7aryjPG.mjs';
8
+ import '../shared/conduithub.BzLwccre.mjs';
9
+ import '../core/service-container/index.mjs';
10
+ import '../core/state-manager/index.mjs';
@@ -0,0 +1,10 @@
1
+ export { KafkaConnectionInfo, KafkaConsumerInfo, KafkaMessage, KafkaPlugin, KafkaPluginConfig, KafkaPluginConfigSchema, KafkaStats, getKafka, initKafka, kafka, shutdownKafka } from './kafka/index.js';
2
+ export { RedisPlugin, getRedis, initRedis, redis, shutdownRedis } from './redis/index.js';
3
+ import 'kafkajs';
4
+ import '../shared/conduithub.DSAmRivG.js';
5
+ import 'zod';
6
+ import '../core/hook/index.js';
7
+ import '../shared/conduithub.B7aryjPG.js';
8
+ import '../shared/conduithub.DQOWQ-Bx.js';
9
+ import '../core/service-container/index.js';
10
+ import '../core/state-manager/index.js';
@@ -0,0 +1,24 @@
1
+ export { K as KafkaPlugin, g as getKafka, i as initKafka, k as kafka, s as shutdownKafka } from '../shared/conduithub.BdX_BLza.mjs';
2
+ export { K as KafkaPluginConfigSchema } from '../shared/conduithub.B16qn6pY.mjs';
3
+ export { R as RedisPlugin, g as getRedis, i as initRedis, r as redis, s as shutdownRedis } from '../shared/conduithub.BzuAKyjY.mjs';
4
+ import 'node:fs';
5
+ import 'node:fs/promises';
6
+ import 'node:path';
7
+ import '../shared/conduithub.BNefRQsK.mjs';
8
+ import '../core/conduit-hub/index.mjs';
9
+ import 'process';
10
+ import 'readline';
11
+ import 'uuid';
12
+ import '../core/config-manager/index.mjs';
13
+ import '../shared/conduithub.G7ICpZIy.mjs';
14
+ import '../shared/conduithub.alPiaJax.mjs';
15
+ import '../core/event-bus/index.mjs';
16
+ import '../error/index.mjs';
17
+ import '../shared/conduithub.CkOQG3cD.mjs';
18
+ import '../core/hook/index.mjs';
19
+ import '../shared/conduithub.DyQQrHW9.mjs';
20
+ import '../core/service-container/index.mjs';
21
+ import '../core/state-manager/index.mjs';
22
+ import '../core/plugin/index.mjs';
23
+ import 'ioredis';
24
+ import 'zod';
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const plugin = require('../../shared/conduithub.0FKJet8c.cjs');
4
+ const schema = require('../../shared/conduithub.jH-df3Zd.cjs');
5
+ require('node:fs');
6
+ require('node:fs/promises');
7
+ require('node:path');
8
+ require('../../shared/conduithub.BNQsddJO.cjs');
9
+ require('../../core/conduit-hub/index.cjs');
10
+ require('process');
11
+ require('readline');
12
+ require('uuid');
13
+ require('../../core/config-manager/index.cjs');
14
+ require('../../shared/conduithub.CmZo_Vuc.cjs');
15
+ require('../../shared/conduithub.DQO1dRnn.cjs');
16
+ require('../../core/event-bus/index.cjs');
17
+ require('../../error/index.cjs');
18
+ require('../../shared/conduithub.Bq_7Xj0J.cjs');
19
+ require('../../core/hook/index.cjs');
20
+ require('../../shared/conduithub.DsOOeNwU.cjs');
21
+ require('../../core/service-container/index.cjs');
22
+ require('../../core/state-manager/index.cjs');
23
+ require('../../core/plugin/index.cjs');
24
+ require('ioredis');
25
+ require('zod');
26
+
27
+
28
+
29
+ exports.KafkaPlugin = plugin.KafkaPlugin;
30
+ exports.getKafka = plugin.getKafka;
31
+ exports.initKafka = plugin.initKafka;
32
+ exports.kafka = plugin.kafka;
33
+ exports.shutdownKafka = plugin.shutdownKafka;
34
+ exports.KafkaPluginConfigSchema = schema.KafkaPluginConfigSchema;
@@ -0,0 +1,250 @@
1
+ import { Admin, ResourceConfigQuery, IResourceConfig, Consumer } from 'kafkajs';
2
+ import { B as BasePlugin } from '../../shared/conduithub.BW-S7Bp_.cjs';
3
+ import { z } from 'zod';
4
+ import '../../core/hook/index.cjs';
5
+ import '../../shared/conduithub.B7aryjPG.cjs';
6
+ import '../../shared/conduithub.BZQmkQy7.cjs';
7
+ import '../../core/service-container/index.cjs';
8
+ import '../../core/state-manager/index.cjs';
9
+
10
+ declare function initKafka(override?: Partial<KafkaPluginConfig>): Promise<KafkaPlugin>;
11
+ declare function getKafka(): KafkaPlugin;
12
+ declare function shutdownKafka(): Promise<void>;
13
+ declare const kafka: {
14
+ init: typeof initKafka;
15
+ get: typeof getKafka;
16
+ shutdown: typeof shutdownKafka;
17
+ createTopic: (topic: string, numPartitions?: number, replicationFactor?: number) => Promise<void>;
18
+ createTopics: (topics: string[]) => Promise<void>;
19
+ deleteTopic: (topic: string) => Promise<void>;
20
+ sendMessage: (topic: string, message: unknown, options?: {
21
+ partition?: number;
22
+ key?: string;
23
+ headers?: Record<string, unknown>;
24
+ }) => Promise<void>;
25
+ sendBatch: (topic: string, messages: unknown[], options?: {
26
+ partition?: number;
27
+ key?: string;
28
+ headers?: Record<string, unknown>;
29
+ }[]) => Promise<void>;
30
+ createConsumer: (topics: string[], handler: Parameters<KafkaPlugin["createConsumer"]>[1], options?: {
31
+ fromBeginning?: boolean;
32
+ }) => Promise<void>;
33
+ stopConsumer: () => Promise<void>;
34
+ seek: (topic: string, partition: number, offset: string) => Promise<void>;
35
+ pause: (topics: string[]) => Promise<void>;
36
+ resume: (topics: string[]) => Promise<void>;
37
+ commitOffsets: (offsets: Parameters<KafkaPlugin["commitOffsets"]>[0]) => Promise<void>;
38
+ listTopics: () => Promise<string[]>;
39
+ getTopicMetadata: (topics?: string[]) => Promise<ReturnType<KafkaPlugin["getTopicMetadata"]>>;
40
+ describeCluster: () => Promise<ReturnType<KafkaPlugin["describeCluster"]>>;
41
+ describeConfigs: (resources: Parameters<KafkaPlugin["describeConfigs"]>[0]) => Promise<ReturnType<KafkaPlugin["describeConfigs"]>>;
42
+ alterConfigs: (resources: Parameters<KafkaPlugin["alterConfigs"]>[0]) => Promise<void>;
43
+ createPartitions: (topicPartitions: Parameters<KafkaPlugin["createPartitions"]>[0]) => Promise<void>;
44
+ deleteRecords: (topicPartitions: Parameters<KafkaPlugin["deleteRecords"]>[0]) => Promise<void>;
45
+ describeGroups: (groupIds: Parameters<KafkaPlugin["describeGroups"]>[0]) => Promise<ReturnType<KafkaPlugin["describeGroups"]>>;
46
+ listGroups: () => Promise<ReturnType<KafkaPlugin["listGroups"]>>;
47
+ deleteGroups: (groupIds: Parameters<KafkaPlugin["deleteGroups"]>[0]) => Promise<void>;
48
+ getConnectionInfo: () => Promise<ReturnType<KafkaPlugin["getConnectionInfo"]>>;
49
+ getStats: () => Promise<ReturnType<KafkaPlugin["getStats"]>>;
50
+ };
51
+
52
+ declare const KafkaPluginConfigSchema: z.ZodObject<{
53
+ clientId: z.ZodDefault<z.ZodString>;
54
+ brokers: z.ZodDefault<z.ZodArray<z.ZodString>>;
55
+ ssl: z.ZodDefault<z.ZodBoolean>;
56
+ sasl: z.ZodOptional<z.ZodObject<{
57
+ mechanism: z.ZodEnum<{
58
+ plain: "plain";
59
+ "scram-sha-256": "scram-sha-256";
60
+ "scram-sha-512": "scram-sha-512";
61
+ aws: "aws";
62
+ oauthbearer: "oauthbearer";
63
+ }>;
64
+ username: z.ZodOptional<z.ZodString>;
65
+ password: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strip>>;
67
+ connectionTimeout: z.ZodDefault<z.ZodNumber>;
68
+ requestTimeout: z.ZodDefault<z.ZodNumber>;
69
+ authenticationTimeout: z.ZodDefault<z.ZodNumber>;
70
+ reauthenticationThreshold: z.ZodDefault<z.ZodNumber>;
71
+ enforceRequestTimeout: z.ZodDefault<z.ZodBoolean>;
72
+ retry: z.ZodDefault<z.ZodObject<{
73
+ initialRetryTime: z.ZodDefault<z.ZodNumber>;
74
+ retries: z.ZodDefault<z.ZodNumber>;
75
+ maxRetryTime: z.ZodDefault<z.ZodNumber>;
76
+ factor: z.ZodDefault<z.ZodNumber>;
77
+ multiplier: z.ZodDefault<z.ZodNumber>;
78
+ }, z.core.$strip>>;
79
+ producer: z.ZodDefault<z.ZodObject<{
80
+ allowAutoTopicCreation: z.ZodDefault<z.ZodBoolean>;
81
+ idempotent: z.ZodDefault<z.ZodBoolean>;
82
+ maxInFlightRequests: z.ZodDefault<z.ZodNumber>;
83
+ acks: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodLiteral<0>, z.ZodLiteral<1>]>>;
84
+ compression: z.ZodDefault<z.ZodEnum<{
85
+ none: "none";
86
+ gzip: "gzip";
87
+ snappy: "snappy";
88
+ lz4: "lz4";
89
+ zstd: "zstd";
90
+ }>>;
91
+ maxBatchSize: z.ZodDefault<z.ZodNumber>;
92
+ linger: z.ZodDefault<z.ZodNumber>;
93
+ partitioner: z.ZodDefault<z.ZodEnum<{
94
+ random: "random";
95
+ murmur2: "murmur2";
96
+ murmur2_random: "murmur2_random";
97
+ consistent: "consistent";
98
+ }>>;
99
+ }, z.core.$strip>>;
100
+ consumer: z.ZodDefault<z.ZodObject<{
101
+ groupId: z.ZodDefault<z.ZodString>;
102
+ groupInstanceId: z.ZodOptional<z.ZodString>;
103
+ sessionTimeout: z.ZodDefault<z.ZodNumber>;
104
+ rebalanceTimeout: z.ZodDefault<z.ZodNumber>;
105
+ heartbeatInterval: z.ZodDefault<z.ZodNumber>;
106
+ maxBytesPerPartition: z.ZodDefault<z.ZodNumber>;
107
+ minBytes: z.ZodDefault<z.ZodNumber>;
108
+ maxBytes: z.ZodDefault<z.ZodNumber>;
109
+ maxWaitTimeInMs: z.ZodDefault<z.ZodNumber>;
110
+ retryBackoffMs: z.ZodDefault<z.ZodNumber>;
111
+ autoCommit: z.ZodDefault<z.ZodBoolean>;
112
+ autoCommitInterval: z.ZodDefault<z.ZodNumber>;
113
+ autoOffsetReset: z.ZodDefault<z.ZodEnum<{
114
+ none: "none";
115
+ earliest: "earliest";
116
+ latest: "latest";
117
+ }>>;
118
+ allowAutoTopicCreation: z.ZodDefault<z.ZodBoolean>;
119
+ maxPollRecords: z.ZodDefault<z.ZodNumber>;
120
+ maxPollIntervalMs: z.ZodDefault<z.ZodNumber>;
121
+ readUncommitted: z.ZodDefault<z.ZodBoolean>;
122
+ }, z.core.$strip>>;
123
+ admin: z.ZodDefault<z.ZodObject<{
124
+ clientTimeout: z.ZodDefault<z.ZodNumber>;
125
+ requestTimeout: z.ZodDefault<z.ZodNumber>;
126
+ retry: z.ZodDefault<z.ZodObject<{
127
+ initialRetryTime: z.ZodDefault<z.ZodNumber>;
128
+ retries: z.ZodDefault<z.ZodNumber>;
129
+ maxRetryTime: z.ZodDefault<z.ZodNumber>;
130
+ factor: z.ZodDefault<z.ZodNumber>;
131
+ multiplier: z.ZodDefault<z.ZodNumber>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>>;
134
+ kafkaLogLevel: z.ZodDefault<z.ZodEnum<{
135
+ NOTHING: "NOTHING";
136
+ ERROR: "ERROR";
137
+ WARN: "WARN";
138
+ INFO: "INFO";
139
+ DEBUG: "DEBUG";
140
+ }>>;
141
+ verboseLogging: z.ZodDefault<z.ZodBoolean>;
142
+ redactSensitiveLogs: z.ZodDefault<z.ZodBoolean>;
143
+ topics: z.ZodDefault<z.ZodArray<z.ZodString>>;
144
+ autoCreateTopics: z.ZodDefault<z.ZodBoolean>;
145
+ defaultTopicPartitions: z.ZodDefault<z.ZodNumber>;
146
+ defaultTopicReplicationFactor: z.ZodDefault<z.ZodNumber>;
147
+ }, z.core.$strip>;
148
+ type KafkaPluginConfig = z.infer<typeof KafkaPluginConfigSchema>;
149
+
150
+ interface KafkaMessage<T = unknown> {
151
+ topic: string;
152
+ partition: number;
153
+ offset: string;
154
+ key: string | null;
155
+ value: T;
156
+ headers: Record<string, string | Buffer | (string | Buffer)[]> | null;
157
+ timestamp: number;
158
+ }
159
+ interface KafkaConsumerInfo<T = unknown> {
160
+ topics: string[];
161
+ handler: (message: KafkaMessage<T>) => Promise<void>;
162
+ options?: {
163
+ fromBeginning?: boolean;
164
+ };
165
+ }
166
+ interface KafkaConnectionInfo {
167
+ clientId: string;
168
+ brokers: string[];
169
+ connected: boolean;
170
+ ssl: boolean;
171
+ timestamp: number;
172
+ }
173
+ interface KafkaStats {
174
+ totalMessagesProduced: number;
175
+ totalMessagesConsumed: number;
176
+ successfulMessages: number;
177
+ failedMessages: number;
178
+ averageProcessingTime: number;
179
+ activeTopics: number;
180
+ activeConsumers: number;
181
+ lastMessageTime?: number;
182
+ }
183
+
184
+ declare class KafkaPlugin extends BasePlugin<KafkaPluginConfig> {
185
+ private kafka;
186
+ private producer;
187
+ private consumer;
188
+ private admin;
189
+ private isConnected;
190
+ private consumers;
191
+ private isConsuming;
192
+ private stats;
193
+ private createKafkaLogCreator;
194
+ constructor(config?: Partial<KafkaPluginConfig>);
195
+ getMetadata(): {
196
+ name: string;
197
+ version: string;
198
+ description: string;
199
+ author: string;
200
+ dependencies: never[];
201
+ hooks: string[];
202
+ events: string[];
203
+ };
204
+ protected onInitialize(): Promise<void>;
205
+ protected onStart(): Promise<void>;
206
+ protected onStop(): Promise<void>;
207
+ protected onDestroy(): Promise<void>;
208
+ sendMessage(topic: string, message: unknown, options?: {
209
+ partition?: number;
210
+ key?: string;
211
+ headers?: Record<string, unknown>;
212
+ }): Promise<void>;
213
+ sendBatch(topic: string, messages: unknown[], options?: {
214
+ partition?: number;
215
+ key?: string;
216
+ headers?: Record<string, unknown>;
217
+ }[]): Promise<void>;
218
+ createConsumer(topics: string[], handler: (message: KafkaMessage) => Promise<void>, options?: {
219
+ fromBeginning?: boolean;
220
+ }): Promise<void>;
221
+ stopConsumer(): Promise<void>;
222
+ createTopic(topic: string, numPartitions?: number, replicationFactor?: number): Promise<void>;
223
+ createTopics(topics: string[]): Promise<void>;
224
+ deleteTopic(topic: string): Promise<void>;
225
+ listTopics(): Promise<string[]>;
226
+ getTopicMetadata(topics?: string[]): Promise<ReturnType<Admin["fetchTopicMetadata"]>>;
227
+ describeCluster(): Promise<ReturnType<Admin["describeCluster"]>>;
228
+ describeConfigs(resources: ResourceConfigQuery[]): Promise<ReturnType<Admin["describeConfigs"]>>;
229
+ alterConfigs(resources: IResourceConfig[]): Promise<void>;
230
+ createPartitions(topicPartitions: Parameters<Admin["createPartitions"]>[0]["topicPartitions"]): Promise<void>;
231
+ deleteRecords(topicPartitions: Array<{
232
+ topic: string;
233
+ partitions: Array<{
234
+ partition: number;
235
+ offset: string;
236
+ }>;
237
+ }>): Promise<void>;
238
+ describeGroups(groupIds: string[]): Promise<ReturnType<Admin["describeGroups"]>>;
239
+ listGroups(): Promise<ReturnType<Admin["listGroups"]>>;
240
+ deleteGroups(groupIds: string[]): Promise<void>;
241
+ getConnectionInfo(): KafkaConnectionInfo;
242
+ getStats(): KafkaStats;
243
+ seek(topic: string, partition: number, offset: string): Promise<void>;
244
+ pause(topics: string[]): Promise<void>;
245
+ resume(topics: string[]): Promise<void>;
246
+ commitOffsets(offsets: Parameters<Consumer["commitOffsets"]>[0]): Promise<void>;
247
+ }
248
+
249
+ export { KafkaPlugin, KafkaPluginConfigSchema, getKafka, initKafka, kafka, shutdownKafka };
250
+ export type { KafkaConnectionInfo, KafkaConsumerInfo, KafkaMessage, KafkaPluginConfig, KafkaStats };