@forklaunch/implementation-worker-kafka 0.2.2 → 0.3.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 (47) hide show
  1. package/lib/consumers/index.d.mts +21 -0
  2. package/lib/consumers/index.d.ts +21 -2
  3. package/lib/consumers/index.js +173 -1
  4. package/lib/consumers/{kafkaWorker.consumer.js → index.mjs} +16 -17
  5. package/lib/producers/index.d.mts +13 -0
  6. package/lib/producers/index.d.ts +13 -2
  7. package/lib/producers/index.js +57 -1
  8. package/lib/producers/{kafkaWorker.producer.js → index.mjs} +8 -6
  9. package/lib/schemas/index.d.mts +24 -0
  10. package/lib/schemas/index.d.ts +24 -2
  11. package/lib/schemas/index.js +1377 -1
  12. package/lib/schemas/index.mjs +1381 -0
  13. package/lib/types/index.d.mts +10 -0
  14. package/lib/types/index.d.ts +10 -2
  15. package/lib/types/index.js +18 -1
  16. package/lib/types/index.mjs +0 -0
  17. package/package.json +6 -5
  18. package/lib/__test__/schemaEquality.test.d.ts +0 -2
  19. package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
  20. package/lib/__test__/schemaEquality.test.js +0 -24
  21. package/lib/consumers/index.d.ts.map +0 -1
  22. package/lib/consumers/kafkaWorker.consumer.d.ts +0 -32
  23. package/lib/consumers/kafkaWorker.consumer.d.ts.map +0 -1
  24. package/lib/jest.config.d.ts +0 -4
  25. package/lib/jest.config.d.ts.map +0 -1
  26. package/lib/jest.config.js +0 -19
  27. package/lib/producers/index.d.ts.map +0 -1
  28. package/lib/producers/kafkaWorker.producer.d.ts +0 -14
  29. package/lib/producers/kafkaWorker.producer.d.ts.map +0 -1
  30. package/lib/schemas/index.d.ts.map +0 -1
  31. package/lib/schemas/kafka.schema.d.ts +0 -72
  32. package/lib/schemas/kafka.schema.d.ts.map +0 -1
  33. package/lib/schemas/kafka.schema.js +0 -7
  34. package/lib/schemas/typebox/kafkaWorker.schema.d.ts +0 -47
  35. package/lib/schemas/typebox/kafkaWorker.schema.d.ts.map +0 -1
  36. package/lib/schemas/typebox/kafkaWorker.schema.js +0 -9
  37. package/lib/schemas/zod/kafkaWorker.schema.d.ts +0 -9
  38. package/lib/schemas/zod/kafkaWorker.schema.d.ts.map +0 -1
  39. package/lib/schemas/zod/kafkaWorker.schema.js +0 -9
  40. package/lib/tsconfig.tsbuildinfo +0 -1
  41. package/lib/types/index.d.ts.map +0 -1
  42. package/lib/types/kafkaWorker.types.d.ts +0 -9
  43. package/lib/types/kafkaWorker.types.d.ts.map +0 -1
  44. package/lib/types/kafkaWorker.types.js +0 -1
  45. package/lib/vitest.config.d.ts +0 -3
  46. package/lib/vitest.config.d.ts.map +0 -1
  47. package/lib/vitest.config.js +0 -7
@@ -0,0 +1,10 @@
1
+ type KafkaWorkerOptions = {
2
+ brokers: string[];
3
+ clientId: string;
4
+ groupId: string;
5
+ retries: number;
6
+ interval: number;
7
+ peekCount: number;
8
+ };
9
+
10
+ export type { KafkaWorkerOptions };
@@ -1,2 +1,10 @@
1
- export * from './kafkaWorker.types';
2
- //# sourceMappingURL=index.d.ts.map
1
+ type KafkaWorkerOptions = {
2
+ brokers: string[];
3
+ clientId: string;
4
+ groupId: string;
5
+ retries: number;
6
+ interval: number;
7
+ peekCount: number;
8
+ };
9
+
10
+ export type { KafkaWorkerOptions };
@@ -1 +1,18 @@
1
- export * from './kafkaWorker.types';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // types/index.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-worker-kafka",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Kafka implementation for forklaunch workers",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -38,13 +38,14 @@
38
38
  "lib/**"
39
39
  ],
40
40
  "dependencies": {
41
- "@forklaunch/core": "^0.9.10",
41
+ "@forklaunch/core": "^0.9.13",
42
42
  "@sinclair/typebox": "^0.34.33",
43
43
  "kafkajs": "^2.2.4",
44
- "zod": "^3.25.61",
45
- "@forklaunch/interfaces-worker": "0.1.10"
44
+ "zod": "^3.25.62",
45
+ "@forklaunch/interfaces-worker": "0.2.0"
46
46
  },
47
47
  "devDependencies": {
48
+ "@typescript/native-preview": "7.0.0-dev.20250611.1",
48
49
  "depcheck": "^1.4.7",
49
50
  "eslint": "^9.28.0",
50
51
  "prettier": "^3.5.3",
@@ -52,7 +53,7 @@
52
53
  "typescript-eslint": "^8.34.0"
53
54
  },
54
55
  "scripts": {
55
- "build": "tsc && if [ -f eject-package.bash ]; then pnpm package:eject; fi",
56
+ "build": "tsc --noEmit && tsup producers/index.ts consumers/index.ts schemas/index.ts types/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean && if [ -f eject-package.bash ]; then pnpm package:eject; fi",
56
57
  "clean": "rm -rf lib pnpm.lock.yaml node_modules",
57
58
  "docs": "typedoc --out docs *",
58
59
  "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=schemaEquality.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemaEquality.test.d.ts","sourceRoot":"","sources":["../../__test__/schemaEquality.test.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { isTrue } from '@forklaunch/common';
2
- import { testSchemaEquality } from '@forklaunch/core/test';
3
- import { KafkaWorkerOptionsSchema as TypeboxKafkaWorkerOptionsSchema } from '../schemas/typebox/kafkaWorker.schema';
4
- import { KafkaWorkerOptionsSchema as ZodKafkaWorkerOptionsSchema } from '../schemas/zod/kafkaWorker.schema';
5
- describe('schema equality', () => {
6
- it('should be equal for bullmq worker', () => {
7
- expect(
8
- isTrue(
9
- testSchemaEquality(
10
- ZodKafkaWorkerOptionsSchema,
11
- TypeboxKafkaWorkerOptionsSchema,
12
- {
13
- brokers: ['localhost:9092'],
14
- clientId: 'test',
15
- groupId: 'test',
16
- retries: 1,
17
- interval: 1000,
18
- peekCount: 1
19
- }
20
- )
21
- )
22
- ).toBeTruthy();
23
- });
24
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -1,32 +0,0 @@
1
- import { WorkerConsumer } from '@forklaunch/interfaces-worker/interfaces';
2
- import {
3
- WorkerEventEntity,
4
- WorkerFailureHandler,
5
- WorkerProcessFunction
6
- } from '@forklaunch/interfaces-worker/types';
7
- import { KafkaWorkerOptions } from '../types/kafkaWorker.types';
8
- export declare class KafkaWorkerConsumer<
9
- EventEntity extends WorkerEventEntity,
10
- Options extends KafkaWorkerOptions
11
- > implements WorkerConsumer<EventEntity>
12
- {
13
- protected readonly queueName: string;
14
- protected readonly options: Options;
15
- protected readonly processEventsFunction: WorkerProcessFunction<EventEntity>;
16
- protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
17
- private kafka;
18
- private producer;
19
- private consumer;
20
- private processedMessages;
21
- constructor(
22
- queueName: string,
23
- options: Options,
24
- processEventsFunction: WorkerProcessFunction<EventEntity>,
25
- failureHandler: WorkerFailureHandler<EventEntity>
26
- );
27
- private setupConsumer;
28
- peekEvents(): Promise<EventEntity[]>;
29
- start(): Promise<void>;
30
- close(): Promise<void>;
31
- }
32
- //# sourceMappingURL=kafkaWorker.consumer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kafkaWorker.consumer.d.ts","sourceRoot":"","sources":["../../consumers/kafkaWorker.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,qBAAa,mBAAmB,CAC9B,WAAW,SAAS,iBAAiB,EACrC,OAAO,SAAS,kBAAkB,CAClC,YAAW,cAAc,CAAC,WAAW,CAAC;IAQpC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM;IACpC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACnC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,WAAW,CAAC;IAC5E,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;IATtE,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,iBAAiB,CAA0B;gBAG9B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,CAAC,WAAW,CAAC,EACzD,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC;YAaxD,aAAa;IA4DrB,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IA4EpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
@@ -1,4 +0,0 @@
1
- import type { JestConfigWithTsJest } from 'ts-jest';
2
- declare const jestConfig: JestConfigWithTsJest;
3
- export default jestConfig;
4
- //# sourceMappingURL=jest.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,QAAA,MAAM,UAAU,EAAE,oBAiBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,19 +0,0 @@
1
- const jestConfig = {
2
- preset: 'ts-jest/presets/default-esm', // or other ESM presets
3
- moduleNameMapper: {
4
- '^(\\.{1,2}/.*)\\.js$': '$1'
5
- },
6
- transform: {
7
- // '^.+\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`
8
- // '^.+\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`
9
- '^.+\\.[tj]sx?$': [
10
- 'ts-jest',
11
- {
12
- useESM: true
13
- }
14
- ],
15
- '^.+\\.js$': 'babel-jest'
16
- },
17
- testPathIgnorePatterns: ['.*dist/', '.*node_modules/']
18
- };
19
- export default jestConfig;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -1,14 +0,0 @@
1
- import { WorkerEventEntity } from '@forklaunch/interfaces-worker/types';
2
- import { KafkaWorkerOptions } from '../types/kafkaWorker.types';
3
- export declare class KafkaWorkerProducer<
4
- EventEntity extends WorkerEventEntity,
5
- Options extends KafkaWorkerOptions
6
- > {
7
- private readonly queueName;
8
- private readonly options;
9
- private producer;
10
- constructor(queueName: string, options: Options);
11
- enqueueJob(event: EventEntity): Promise<void>;
12
- enqueueBatchJobs(events: EventEntity[]): Promise<void>;
13
- }
14
- //# sourceMappingURL=kafkaWorker.producer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kafkaWorker.producer.d.ts","sourceRoot":"","sources":["../../producers/kafkaWorker.producer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,qBAAa,mBAAmB,CAC9B,WAAW,SAAS,iBAAiB,EACrC,OAAO,SAAS,kBAAkB;IAKhC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC;gBAGE,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO;IAU7B,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -1,72 +0,0 @@
1
- export declare const KafkaWorkerSchemas: <
2
- SchemaValidator extends import('@forklaunch/validator').AnySchemaValidator
3
- >(
4
- options: Record<string, unknown> & {
5
- validator: SchemaValidator;
6
- }
7
- ) => import('@forklaunch/core/mappers').SchemasByValidator<
8
- SchemaValidator,
9
- (options: Record<string, unknown>) => {
10
- brokers: import('@sinclair/typebox').TArray<
11
- import('@sinclair/typebox').TString
12
- >;
13
- clientId: import('@sinclair/typebox').TString;
14
- groupId: import('@sinclair/typebox').TString;
15
- retries: import('@sinclair/typebox').TTransform<
16
- import('@sinclair/typebox').TUnion<
17
- [
18
- import('@sinclair/typebox').TNumber,
19
- import('@sinclair/typebox').TString,
20
- import('@sinclair/typebox').TBoolean,
21
- import('@sinclair/typebox').TNull,
22
- import('@sinclair/typebox').TBigInt,
23
- import('@sinclair/typebox').TDate
24
- ]
25
- >,
26
- number
27
- >;
28
- interval: import('@sinclair/typebox').TTransform<
29
- import('@sinclair/typebox').TUnion<
30
- [
31
- import('@sinclair/typebox').TNumber,
32
- import('@sinclair/typebox').TString,
33
- import('@sinclair/typebox').TBoolean,
34
- import('@sinclair/typebox').TNull,
35
- import('@sinclair/typebox').TBigInt,
36
- import('@sinclair/typebox').TDate
37
- ]
38
- >,
39
- number
40
- >;
41
- peekCount: import('@sinclair/typebox').TTransform<
42
- import('@sinclair/typebox').TUnion<
43
- [
44
- import('@sinclair/typebox').TNumber,
45
- import('@sinclair/typebox').TString,
46
- import('@sinclair/typebox').TBoolean,
47
- import('@sinclair/typebox').TNull,
48
- import('@sinclair/typebox').TBigInt,
49
- import('@sinclair/typebox').TDate
50
- ]
51
- >,
52
- number
53
- >;
54
- },
55
- (options: Record<string, unknown>) => {
56
- brokers: import('zod').ZodArray<import('zod').ZodString, 'many'>;
57
- clientId: import('zod').ZodString;
58
- groupId: import('zod').ZodString;
59
- retries: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
60
- interval: import('zod').ZodEffects<
61
- import('zod').ZodNumber,
62
- number,
63
- unknown
64
- >;
65
- peekCount: import('zod').ZodEffects<
66
- import('zod').ZodNumber,
67
- number,
68
- unknown
69
- >;
70
- }
71
- >;
72
- //# sourceMappingURL=kafka.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kafka.schema.d.ts","sourceRoot":"","sources":["../../schemas/kafka.schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;EAG9B,CAAC"}
@@ -1,7 +0,0 @@
1
- import { serviceSchemaResolver } from '@forklaunch/core/mappers';
2
- import { KafkaWorkerOptionsSchema as TypeBoxSchemas } from './typebox/kafkaWorker.schema';
3
- import { KafkaWorkerOptionsSchema as ZodSchemas } from './zod/kafkaWorker.schema';
4
- export const KafkaWorkerSchemas = serviceSchemaResolver(
5
- () => TypeBoxSchemas,
6
- () => ZodSchemas
7
- );
@@ -1,47 +0,0 @@
1
- export declare const KafkaWorkerOptionsSchema: {
2
- brokers: import('@sinclair/typebox').TArray<
3
- import('@sinclair/typebox').TString
4
- >;
5
- clientId: import('@sinclair/typebox').TString;
6
- groupId: import('@sinclair/typebox').TString;
7
- retries: import('@sinclair/typebox').TTransform<
8
- import('@sinclair/typebox').TUnion<
9
- [
10
- import('@sinclair/typebox').TNumber,
11
- import('@sinclair/typebox').TString,
12
- import('@sinclair/typebox').TBoolean,
13
- import('@sinclair/typebox').TNull,
14
- import('@sinclair/typebox').TBigInt,
15
- import('@sinclair/typebox').TDate
16
- ]
17
- >,
18
- number
19
- >;
20
- interval: import('@sinclair/typebox').TTransform<
21
- import('@sinclair/typebox').TUnion<
22
- [
23
- import('@sinclair/typebox').TNumber,
24
- import('@sinclair/typebox').TString,
25
- import('@sinclair/typebox').TBoolean,
26
- import('@sinclair/typebox').TNull,
27
- import('@sinclair/typebox').TBigInt,
28
- import('@sinclair/typebox').TDate
29
- ]
30
- >,
31
- number
32
- >;
33
- peekCount: import('@sinclair/typebox').TTransform<
34
- import('@sinclair/typebox').TUnion<
35
- [
36
- import('@sinclair/typebox').TNumber,
37
- import('@sinclair/typebox').TString,
38
- import('@sinclair/typebox').TBoolean,
39
- import('@sinclair/typebox').TNull,
40
- import('@sinclair/typebox').TBigInt,
41
- import('@sinclair/typebox').TDate
42
- ]
43
- >,
44
- number
45
- >;
46
- };
47
- //# sourceMappingURL=kafkaWorker.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kafkaWorker.schema.d.ts","sourceRoot":"","sources":["../../../schemas/typebox/kafkaWorker.schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB;;;;;;;CAOpC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { array, number, string } from '@forklaunch/validator/typebox';
2
- export const KafkaWorkerOptionsSchema = {
3
- brokers: array(string),
4
- clientId: string,
5
- groupId: string,
6
- retries: number,
7
- interval: number,
8
- peekCount: number
9
- };
@@ -1,9 +0,0 @@
1
- export declare const KafkaWorkerOptionsSchema: {
2
- brokers: import('zod').ZodArray<import('zod').ZodString, 'many'>;
3
- clientId: import('zod').ZodString;
4
- groupId: import('zod').ZodString;
5
- retries: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
6
- interval: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
7
- peekCount: import('zod').ZodEffects<import('zod').ZodNumber, number, unknown>;
8
- };
9
- //# sourceMappingURL=kafkaWorker.schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kafkaWorker.schema.d.ts","sourceRoot":"","sources":["../../../schemas/zod/kafkaWorker.schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB;;;;;;;CAOpC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { array, number, string } from '@forklaunch/validator/zod';
2
- export const KafkaWorkerOptionsSchema = {
3
- brokers: array(string),
4
- clientId: string,
5
- groupId: string,
6
- retries: number,
7
- interval: number,
8
- peekCount: number
9
- };