@infineit-nestjs/core 1.0.12 → 1.0.14

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 (42) hide show
  1. package/dist/cjs/index.d.ts +2 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/kafka/constants/error.status-code.constant.d.ts +5 -0
  4. package/dist/cjs/kafka/constants/kafka.constant.d.ts +1 -0
  5. package/dist/cjs/kafka/constants/kafka.topic.constant.d.ts +4 -0
  6. package/dist/cjs/kafka/constants/request.status-code.constant.d.ts +7 -0
  7. package/dist/cjs/kafka/decorators/kafka.decorator.d.ts +7 -0
  8. package/dist/cjs/kafka/errors/filters/kafka-exceptions.filter.d.ts +11 -0
  9. package/dist/cjs/kafka/errors/filters/kafka.error.filter.d.ts +8 -0
  10. package/dist/cjs/kafka/interceptors/kafka.commit-offset-first.interceptor.d.ts +8 -0
  11. package/dist/cjs/kafka/interceptors/kafka.module.filter.interceptor.d.ts +7 -0
  12. package/dist/cjs/kafka/interceptors/kafka.response.interceptor.d.ts +5 -0
  13. package/dist/cjs/kafka/interceptors/kafka.response.timeout.interceptor.d.ts +9 -0
  14. package/dist/cjs/kafka/interfaces/kafka.interface.d.ts +29 -0
  15. package/dist/cjs/kafka/interfaces/kafka.service.interface.d.ts +10 -0
  16. package/dist/cjs/kafka/kafka.module.d.ts +8 -0
  17. package/dist/cjs/kafka/kafka.service.d.ts +24 -0
  18. package/dist/cjs/kafka/pipes/kafka.validation.pipe.d.ts +4 -0
  19. package/dist/es/index.d.ts +2 -0
  20. package/dist/es/index.js +1 -1
  21. package/dist/es/kafka/constants/error.status-code.constant.d.ts +5 -0
  22. package/dist/es/kafka/constants/kafka.constant.d.ts +1 -0
  23. package/dist/es/kafka/constants/kafka.topic.constant.d.ts +4 -0
  24. package/dist/es/kafka/constants/request.status-code.constant.d.ts +7 -0
  25. package/dist/es/kafka/decorators/kafka.decorator.d.ts +7 -0
  26. package/dist/es/kafka/errors/filters/kafka-exceptions.filter.d.ts +11 -0
  27. package/dist/es/kafka/errors/filters/kafka.error.filter.d.ts +8 -0
  28. package/dist/es/kafka/interceptors/kafka.commit-offset-first.interceptor.d.ts +8 -0
  29. package/dist/es/kafka/interceptors/kafka.module.filter.interceptor.d.ts +7 -0
  30. package/dist/es/kafka/interceptors/kafka.response.interceptor.d.ts +5 -0
  31. package/dist/es/kafka/interceptors/kafka.response.timeout.interceptor.d.ts +9 -0
  32. package/dist/es/kafka/interfaces/kafka.interface.d.ts +29 -0
  33. package/dist/es/kafka/interfaces/kafka.service.interface.d.ts +10 -0
  34. package/dist/es/kafka/kafka.module.d.ts +8 -0
  35. package/dist/es/kafka/kafka.service.d.ts +24 -0
  36. package/dist/es/kafka/pipes/kafka.validation.pipe.d.ts +4 -0
  37. package/dist/types/index.d.ts +2 -0
  38. package/dist/types/kafka/interfaces/kafka.interface.d.ts +16 -0
  39. package/dist/types/kafka/interfaces/kafka.service.interface.d.ts +13 -0
  40. package/dist/types/kafka/kafka.module.d.ts +12 -0
  41. package/dist/types/kafka/kafka.service.d.ts +27 -0
  42. package/package.json +4 -3
@@ -4,3 +4,5 @@ export * from './errors';
4
4
  export * from './exceptions';
5
5
  export * from './filters';
6
6
  export * from './validators';
7
+ export * from './kafka/kafka.module';
8
+ export * from './kafka/kafka.service';
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r=require("tslib");r.__exportStar(require("./constants"),exports),r.__exportStar(require("./decorators"),exports),r.__exportStar(require("./errors"),exports),r.__exportStar(require("./exceptions"),exports),r.__exportStar(require("./filters"),exports),r.__exportStar(require("./validators"),exports);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r=require("tslib");r.__exportStar(require("./constants"),exports),r.__exportStar(require("./decorators"),exports),r.__exportStar(require("./errors"),exports),r.__exportStar(require("./exceptions"),exports),r.__exportStar(require("./filters"),exports),r.__exportStar(require("./validators"),exports),r.__exportStar(require("./kafka/kafka.module"),exports),r.__exportStar(require("./kafka/kafka.service"),exports);
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ export declare enum ENUM_ERROR_STATUS_CODE_ERROR {
2
+ ERROR_UNKNOWN = 5050,
3
+ ERROR_SERVICE_UNAVAILABLE = 5051,
4
+ ERROR_REQUEST_TIMEOUT = 5052
5
+ }
@@ -0,0 +1 @@
1
+ export declare const KAFKA_SERVICE_NAME = "KAFKA_SERVICE";
@@ -0,0 +1,4 @@
1
+ export declare enum ENUM_KAFKA_TOPICS {
2
+ ACK_SUCCESS = "nestjs.ack.success",
3
+ ACK_ERROR = "nestjs.ack.error"
4
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum ENUM_REQUEST_STATUS_CODE_ERROR {
2
+ REQUEST_VALIDATION_ERROR = 5070,
3
+ REQUEST_TIMESTAMP_INVALID_ERROR = 5071,
4
+ REQUEST_USER_AGENT_INVALID_ERROR = 5072,
5
+ REQUEST_USER_AGENT_OS_INVALID_ERROR = 5073,
6
+ REQUEST_USER_AGENT_BROWSER_INVALID_ERROR = 5074
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Type } from '@nestjs/common';
2
+ import { Payload } from '@nestjs/microservices';
3
+ export declare function MessageTopic(topic: string, moduleName: string, useRetryFilter?: boolean, retryFilterInstance?: Type<any> | any, enableValidation?: boolean): MethodDecorator;
4
+ export declare const MessageValue: typeof Payload;
5
+ export declare const MessageHeader: (...dataOrPipes: any[]) => ParameterDecorator;
6
+ export declare const MessageKey: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
7
+ export declare function MessageCommitOffsetInFirstRunning(): any;
@@ -0,0 +1,11 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { BaseExceptionFilter } from '@nestjs/core';
3
+ export declare class KafkaMaxRetryExceptionFilter extends BaseExceptionFilter {
4
+ private readonly maxRetries;
5
+ private readonly skipHandler?;
6
+ private readonly logger;
7
+ constructor(maxRetries: number, skipHandler?: ((message: any) => Promise<void>) | undefined);
8
+ catch(exception: unknown, host: ArgumentsHost): Promise<void>;
9
+ private getRetryCountFromContext;
10
+ private commitOffset;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { RpcExceptionFilter } from '@nestjs/common/interfaces';
3
+ import { RpcException } from '@nestjs/microservices';
4
+ import { Observable } from 'rxjs';
5
+ export declare class KafkaErrorFilter implements RpcExceptionFilter<RpcException> {
6
+ private readonly logger;
7
+ catch(exception: RpcException, host: ArgumentsHost): Observable<any>;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ import { KafkaService } from '../kafka.service';
4
+ export declare class KafkaCommitOffsetFirstInterceptor implements NestInterceptor<Promise<any>> {
5
+ private readonly kafkaService;
6
+ constructor(kafkaService: KafkaService);
7
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<Promise<any> | string>>;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ export declare class KafkaModuleFilterInterceptor implements NestInterceptor {
4
+ private readonly expectedModule;
5
+ constructor(expectedModule: string);
6
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ export declare class KafkaResponseInterceptor implements NestInterceptor {
4
+ intercept(context: ExecutionContext, next: CallHandler): Observable<string>;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { Observable } from 'rxjs';
4
+ export declare class KafkaResponseTimeoutInterceptor implements NestInterceptor<Promise<any>> {
5
+ private readonly configService;
6
+ private readonly timeout;
7
+ constructor(configService: ConfigService);
8
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<Promise<any> | string>>;
9
+ }
@@ -0,0 +1,29 @@
1
+ import { HttpStatus } from '@nestjs/common';
2
+ import { ValidationError } from 'class-validator';
3
+ export type IKafkaResponse = Record<string, any>;
4
+ export interface IKafkaMessageHeader {
5
+ [key: string]: string | undefined;
6
+ }
7
+ export interface IKafkaProducerMessageOptions {
8
+ headers?: IKafkaMessageHeader;
9
+ }
10
+ export interface IKafkaProducerSendMessageOptions extends IKafkaProducerMessageOptions {
11
+ raw?: boolean;
12
+ }
13
+ export interface IKafkaMessage<T = Record<string, string>> {
14
+ key: string;
15
+ value: T;
16
+ headers?: IKafkaMessageHeader;
17
+ }
18
+ export interface IKafkaErrorException {
19
+ statusCode: number;
20
+ message: string;
21
+ errors: ValidationError;
22
+ statusHttp: HttpStatus;
23
+ }
24
+ export interface IKafkaCreateTopic {
25
+ topic: string;
26
+ topicReply: string;
27
+ partition?: number;
28
+ replicationFactor?: number;
29
+ }
@@ -0,0 +1,10 @@
1
+ import { KafkaContext } from '@nestjs/microservices';
2
+ import { IKafkaMessage, IKafkaProducerMessageOptions, IKafkaProducerSendMessageOptions } from './kafka.interface';
3
+ export interface IKafkaService {
4
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
5
+ produceEmit<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
6
+ produceSendSequential<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
7
+ produceEmitSequential<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
8
+ createId(): string;
9
+ commitOffsets(context: KafkaContext): Promise<void>;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export interface IKafkaModuleOptions {
3
+ subscribeTopics?: string[];
4
+ enableConsumer?: boolean;
5
+ }
6
+ export declare class KafkaModule {
7
+ static forRoot(options?: IKafkaModuleOptions): DynamicModule;
8
+ }
@@ -0,0 +1,24 @@
1
+ import { OnApplicationBootstrap, OnApplicationShutdown, OnModuleInit } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { ClientKafka, KafkaContext } from '@nestjs/microservices';
4
+ import { Observable } from 'rxjs';
5
+ import { IKafkaMessage, IKafkaProducerMessageOptions, IKafkaProducerSendMessageOptions } from './interfaces/kafka.interface';
6
+ import { IKafkaService } from './interfaces/kafka.service.interface';
7
+ export declare class KafkaService implements IKafkaService, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown {
8
+ private readonly clientKafka;
9
+ private readonly topics;
10
+ private readonly configService;
11
+ private readonly timeout;
12
+ private readonly logger;
13
+ constructor(clientKafka: ClientKafka, topics: string[], configService: ConfigService);
14
+ onApplicationBootstrap(): Promise<void>;
15
+ onModuleInit(): Promise<void>;
16
+ onApplicationShutdown(signal?: string): Promise<void>;
17
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
18
+ produceEmit<T, N>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
19
+ produceSendSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<N>;
20
+ produceEmitSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
21
+ createId(): string;
22
+ generateRandomString(length: number): string;
23
+ commitOffsets(context: KafkaContext): Promise<void>;
24
+ }
@@ -0,0 +1,4 @@
1
+ import { ValidationPipe } from '@nestjs/common';
2
+ export declare class KafkaValidationPipe extends ValidationPipe {
3
+ constructor();
4
+ }
@@ -4,3 +4,5 @@ export * from './errors';
4
4
  export * from './exceptions';
5
5
  export * from './filters';
6
6
  export * from './validators';
7
+ export * from './kafka/kafka.module';
8
+ export * from './kafka/kafka.service';
package/dist/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});const r=require("tslib");r.__exportStar(require("./constants"),exports),r.__exportStar(require("./decorators"),exports),r.__exportStar(require("./errors"),exports),r.__exportStar(require("./exceptions"),exports),r.__exportStar(require("./filters"),exports),r.__exportStar(require("./validators"),exports);
1
+ Object.defineProperty(exports,"__esModule",{value:!0});const r=require("tslib");r.__exportStar(require("./constants"),exports),r.__exportStar(require("./decorators"),exports),r.__exportStar(require("./errors"),exports),r.__exportStar(require("./exceptions"),exports),r.__exportStar(require("./filters"),exports),r.__exportStar(require("./validators"),exports),r.__exportStar(require("./kafka/kafka.module"),exports),r.__exportStar(require("./kafka/kafka.service"),exports);
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ export declare enum ENUM_ERROR_STATUS_CODE_ERROR {
2
+ ERROR_UNKNOWN = 5050,
3
+ ERROR_SERVICE_UNAVAILABLE = 5051,
4
+ ERROR_REQUEST_TIMEOUT = 5052
5
+ }
@@ -0,0 +1 @@
1
+ export declare const KAFKA_SERVICE_NAME = "KAFKA_SERVICE";
@@ -0,0 +1,4 @@
1
+ export declare enum ENUM_KAFKA_TOPICS {
2
+ ACK_SUCCESS = "nestjs.ack.success",
3
+ ACK_ERROR = "nestjs.ack.error"
4
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum ENUM_REQUEST_STATUS_CODE_ERROR {
2
+ REQUEST_VALIDATION_ERROR = 5070,
3
+ REQUEST_TIMESTAMP_INVALID_ERROR = 5071,
4
+ REQUEST_USER_AGENT_INVALID_ERROR = 5072,
5
+ REQUEST_USER_AGENT_OS_INVALID_ERROR = 5073,
6
+ REQUEST_USER_AGENT_BROWSER_INVALID_ERROR = 5074
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Type } from '@nestjs/common';
2
+ import { Payload } from '@nestjs/microservices';
3
+ export declare function MessageTopic(topic: string, moduleName: string, useRetryFilter?: boolean, retryFilterInstance?: Type<any> | any, enableValidation?: boolean): MethodDecorator;
4
+ export declare const MessageValue: typeof Payload;
5
+ export declare const MessageHeader: (...dataOrPipes: any[]) => ParameterDecorator;
6
+ export declare const MessageKey: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
7
+ export declare function MessageCommitOffsetInFirstRunning(): any;
@@ -0,0 +1,11 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { BaseExceptionFilter } from '@nestjs/core';
3
+ export declare class KafkaMaxRetryExceptionFilter extends BaseExceptionFilter {
4
+ private readonly maxRetries;
5
+ private readonly skipHandler?;
6
+ private readonly logger;
7
+ constructor(maxRetries: number, skipHandler?: ((message: any) => Promise<void>) | undefined);
8
+ catch(exception: unknown, host: ArgumentsHost): Promise<void>;
9
+ private getRetryCountFromContext;
10
+ private commitOffset;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { RpcExceptionFilter } from '@nestjs/common/interfaces';
3
+ import { RpcException } from '@nestjs/microservices';
4
+ import { Observable } from 'rxjs';
5
+ export declare class KafkaErrorFilter implements RpcExceptionFilter<RpcException> {
6
+ private readonly logger;
7
+ catch(exception: RpcException, host: ArgumentsHost): Observable<any>;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ import { KafkaService } from '../kafka.service';
4
+ export declare class KafkaCommitOffsetFirstInterceptor implements NestInterceptor<Promise<any>> {
5
+ private readonly kafkaService;
6
+ constructor(kafkaService: KafkaService);
7
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<Promise<any> | string>>;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ export declare class KafkaModuleFilterInterceptor implements NestInterceptor {
4
+ private readonly expectedModule;
5
+ constructor(expectedModule: string);
6
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ export declare class KafkaResponseInterceptor implements NestInterceptor {
4
+ intercept(context: ExecutionContext, next: CallHandler): Observable<string>;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { Observable } from 'rxjs';
4
+ export declare class KafkaResponseTimeoutInterceptor implements NestInterceptor<Promise<any>> {
5
+ private readonly configService;
6
+ private readonly timeout;
7
+ constructor(configService: ConfigService);
8
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<Promise<any> | string>>;
9
+ }
@@ -0,0 +1,29 @@
1
+ import { HttpStatus } from '@nestjs/common';
2
+ import { ValidationError } from 'class-validator';
3
+ export type IKafkaResponse = Record<string, any>;
4
+ export interface IKafkaMessageHeader {
5
+ [key: string]: string | undefined;
6
+ }
7
+ export interface IKafkaProducerMessageOptions {
8
+ headers?: IKafkaMessageHeader;
9
+ }
10
+ export interface IKafkaProducerSendMessageOptions extends IKafkaProducerMessageOptions {
11
+ raw?: boolean;
12
+ }
13
+ export interface IKafkaMessage<T = Record<string, string>> {
14
+ key: string;
15
+ value: T;
16
+ headers?: IKafkaMessageHeader;
17
+ }
18
+ export interface IKafkaErrorException {
19
+ statusCode: number;
20
+ message: string;
21
+ errors: ValidationError;
22
+ statusHttp: HttpStatus;
23
+ }
24
+ export interface IKafkaCreateTopic {
25
+ topic: string;
26
+ topicReply: string;
27
+ partition?: number;
28
+ replicationFactor?: number;
29
+ }
@@ -0,0 +1,10 @@
1
+ import { KafkaContext } from '@nestjs/microservices';
2
+ import { IKafkaMessage, IKafkaProducerMessageOptions, IKafkaProducerSendMessageOptions } from './kafka.interface';
3
+ export interface IKafkaService {
4
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
5
+ produceEmit<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
6
+ produceSendSequential<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
7
+ produceEmitSequential<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
8
+ createId(): string;
9
+ commitOffsets(context: KafkaContext): Promise<void>;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export interface IKafkaModuleOptions {
3
+ subscribeTopics?: string[];
4
+ enableConsumer?: boolean;
5
+ }
6
+ export declare class KafkaModule {
7
+ static forRoot(options?: IKafkaModuleOptions): DynamicModule;
8
+ }
@@ -0,0 +1,24 @@
1
+ import { OnApplicationBootstrap, OnApplicationShutdown, OnModuleInit } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { ClientKafka, KafkaContext } from '@nestjs/microservices';
4
+ import { Observable } from 'rxjs';
5
+ import { IKafkaMessage, IKafkaProducerMessageOptions, IKafkaProducerSendMessageOptions } from './interfaces/kafka.interface';
6
+ import { IKafkaService } from './interfaces/kafka.service.interface';
7
+ export declare class KafkaService implements IKafkaService, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown {
8
+ private readonly clientKafka;
9
+ private readonly topics;
10
+ private readonly configService;
11
+ private readonly timeout;
12
+ private readonly logger;
13
+ constructor(clientKafka: ClientKafka, topics: string[], configService: ConfigService);
14
+ onApplicationBootstrap(): Promise<void>;
15
+ onModuleInit(): Promise<void>;
16
+ onApplicationShutdown(signal?: string): Promise<void>;
17
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
18
+ produceEmit<T, N>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
19
+ produceSendSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<N>;
20
+ produceEmitSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
21
+ createId(): string;
22
+ generateRandomString(length: number): string;
23
+ commitOffsets(context: KafkaContext): Promise<void>;
24
+ }
@@ -0,0 +1,4 @@
1
+ import { ValidationPipe } from '@nestjs/common';
2
+ export declare class KafkaValidationPipe extends ValidationPipe {
3
+ constructor();
4
+ }
@@ -22,3 +22,5 @@ export { Query } from './filters/query.js';
22
22
  export { UnprocessableEntityFilter } from './filters/unprocessable-entity.filter.js';
23
23
  export { IsValidField } from './validators/field.validator.js';
24
24
  export { CommaSeparated, SortBy } from './validators/filter.validator.js';
25
+ export { IKafkaModuleOptions, KafkaModule } from './kafka/kafka.module.js';
26
+ export { KafkaService } from './kafka/kafka.service.js';
@@ -0,0 +1,16 @@
1
+ interface IKafkaMessageHeader {
2
+ [key: string]: string | undefined;
3
+ }
4
+ interface IKafkaProducerMessageOptions {
5
+ headers?: IKafkaMessageHeader;
6
+ }
7
+ interface IKafkaProducerSendMessageOptions extends IKafkaProducerMessageOptions {
8
+ raw?: boolean;
9
+ }
10
+ interface IKafkaMessage<T = Record<string, string>> {
11
+ key: string;
12
+ value: T;
13
+ headers?: IKafkaMessageHeader;
14
+ }
15
+
16
+ export type { IKafkaMessage, IKafkaMessageHeader, IKafkaProducerMessageOptions, IKafkaProducerSendMessageOptions };
@@ -0,0 +1,13 @@
1
+ import { KafkaContext } from '@nestjs/microservices';
2
+ import { IKafkaProducerSendMessageOptions, IKafkaMessage, IKafkaProducerMessageOptions } from './kafka.interface.js';
3
+
4
+ interface IKafkaService {
5
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
6
+ produceEmit<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
7
+ produceSendSequential<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
8
+ produceEmitSequential<T>(topic: string, data: T, options?: IKafkaProducerMessageOptions): void;
9
+ createId(): string;
10
+ commitOffsets(context: KafkaContext): Promise<void>;
11
+ }
12
+
13
+ export type { IKafkaService };
@@ -0,0 +1,12 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+
3
+ interface IKafkaModuleOptions {
4
+ subscribeTopics?: string[];
5
+ enableConsumer?: boolean;
6
+ }
7
+ declare class KafkaModule {
8
+ static forRoot(options?: IKafkaModuleOptions): DynamicModule;
9
+ }
10
+
11
+ export { KafkaModule };
12
+ export type { IKafkaModuleOptions };
@@ -0,0 +1,27 @@
1
+ import { OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { ClientKafka, KafkaContext } from '@nestjs/microservices';
4
+ import { Observable } from 'rxjs';
5
+ import { IKafkaProducerSendMessageOptions, IKafkaMessage, IKafkaProducerMessageOptions } from './interfaces/kafka.interface.js';
6
+ import { IKafkaService } from './interfaces/kafka.service.interface.js';
7
+
8
+ declare class KafkaService implements IKafkaService, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown {
9
+ private readonly clientKafka;
10
+ private readonly topics;
11
+ private readonly configService;
12
+ private readonly timeout;
13
+ private readonly logger;
14
+ constructor(clientKafka: ClientKafka, topics: string[], configService: ConfigService);
15
+ onApplicationBootstrap(): Promise<void>;
16
+ onModuleInit(): Promise<void>;
17
+ onApplicationShutdown(signal?: string): Promise<void>;
18
+ produceSend<T, N>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<IKafkaMessage<N> | N>;
19
+ produceEmit<T, N>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
20
+ produceSendSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerSendMessageOptions): Promise<N>;
21
+ produceEmitSequential<T, N = any>(topic: string, data: T, options?: IKafkaProducerMessageOptions): Observable<N>;
22
+ createId(): string;
23
+ generateRandomString(length: number): string;
24
+ commitOffsets(context: KafkaContext): Promise<void>;
25
+ }
26
+
27
+ export { KafkaService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infineit-nestjs/core",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/es/index.mjs",
6
6
  "exports": {
@@ -84,7 +84,8 @@
84
84
  "dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\""
85
85
  },
86
86
  "dependencies": {
87
- "@infineit-nestjs/services": "1.0.21",
87
+ "@infineit-nestjs/services": "1.0.23",
88
+ "@infineit-nestjs/types": "1.0.6",
88
89
  "@nestjs/swagger": "^11.0.7"
89
90
  },
90
91
  "devDependencies": {
@@ -117,5 +118,5 @@
117
118
  "publishConfig": {
118
119
  "access": "public"
119
120
  },
120
- "gitHead": "4130b02564fd907e1b20cfdff876133d9f273509"
121
+ "gitHead": "8c13163bc583b9cb122a717ec86b45da1db88df3"
121
122
  }