@mondart/nestjs-common-module-kafka 3.1.5 → 3.1.9
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.
- package/README.md +153 -0
- package/dist/constant/kafka-module-options-token.const.d.ts +2 -0
- package/dist/constant/kafka-module-options-token.const.d.ts.map +1 -0
- package/dist/constant/kafka-module-options-token.const.js +5 -0
- package/dist/constant/kafka-module-options-token.const.js.map +1 -0
- package/dist/dto/base/base-kafka-event.dto.d.ts +12 -0
- package/dist/dto/base/base-kafka-event.dto.d.ts.map +1 -0
- package/dist/dto/base/base-kafka-event.dto.js +54 -0
- package/dist/dto/base/base-kafka-event.dto.js.map +1 -0
- package/dist/dto/base/index.d.ts +2 -0
- package/dist/dto/base/index.d.ts.map +1 -0
- package/dist/dto/base/index.js +18 -0
- package/dist/dto/base/index.js.map +1 -0
- package/dist/dto/index.d.ts +4 -0
- package/dist/dto/index.d.ts.map +1 -0
- package/dist/dto/index.js +20 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/request/index.d.ts +2 -0
- package/dist/dto/request/index.d.ts.map +1 -0
- package/dist/dto/request/index.js +18 -0
- package/dist/dto/request/index.js.map +1 -0
- package/dist/dto/request/kafka-request.dto.d.ts +6 -0
- package/dist/dto/request/kafka-request.dto.d.ts.map +1 -0
- package/dist/dto/request/kafka-request.dto.js +24 -0
- package/dist/dto/request/kafka-request.dto.js.map +1 -0
- package/dist/dto/response/index.d.ts +3 -0
- package/dist/dto/response/index.d.ts.map +1 -0
- package/dist/dto/response/index.js +19 -0
- package/dist/dto/response/index.js.map +1 -0
- package/dist/dto/response/kafka-failed-response.dto.d.ts +10 -0
- package/dist/dto/response/kafka-failed-response.dto.d.ts.map +1 -0
- package/dist/dto/response/kafka-failed-response.dto.js +50 -0
- package/dist/dto/response/kafka-failed-response.dto.js.map +1 -0
- package/dist/dto/response/kafka-success-response.dto.d.ts +8 -0
- package/dist/dto/response/kafka-success-response.dto.d.ts.map +1 -0
- package/dist/dto/response/kafka-success-response.dto.js +25 -0
- package/dist/dto/response/kafka-success-response.dto.js.map +1 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +21 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/kafka-language-message.helper.d.ts +10 -0
- package/dist/helpers/kafka-language-message.helper.d.ts.map +1 -0
- package/dist/helpers/kafka-language-message.helper.js +48 -0
- package/dist/helpers/kafka-language-message.helper.js.map +1 -0
- package/dist/helpers/kafka-language-propagation.helper.d.ts +6 -0
- package/dist/helpers/kafka-language-propagation.helper.d.ts.map +1 -0
- package/dist/helpers/kafka-language-propagation.helper.js +18 -0
- package/dist/helpers/kafka-language-propagation.helper.js.map +1 -0
- package/dist/helpers/rxjs-catch-error.helper.d.ts +6 -0
- package/dist/helpers/rxjs-catch-error.helper.d.ts.map +1 -0
- package/dist/helpers/rxjs-catch-error.helper.js +81 -0
- package/dist/helpers/rxjs-catch-error.helper.js.map +1 -0
- package/dist/helpers/rxjs-custom-timeout.helper.d.ts +5 -0
- package/dist/helpers/rxjs-custom-timeout.helper.d.ts.map +1 -0
- package/dist/helpers/rxjs-custom-timeout.helper.js +19 -0
- package/dist/helpers/rxjs-custom-timeout.helper.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +9 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +25 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/kafka-event-metadata.interface.d.ts +5 -0
- package/dist/interfaces/kafka-event-metadata.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-event-metadata.interface.js +3 -0
- package/dist/interfaces/kafka-event-metadata.interface.js.map +1 -0
- package/dist/interfaces/kafka-failed-response.interface.d.ts +11 -0
- package/dist/interfaces/kafka-failed-response.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-failed-response.interface.js +3 -0
- package/dist/interfaces/kafka-failed-response.interface.js.map +1 -0
- package/dist/interfaces/kafka-language-client.interface.d.ts +5 -0
- package/dist/interfaces/kafka-language-client.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-language-client.interface.js +3 -0
- package/dist/interfaces/kafka-language-client.interface.js.map +1 -0
- package/dist/interfaces/kafka-language-message.interface.d.ts +8 -0
- package/dist/interfaces/kafka-language-message.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-language-message.interface.js +3 -0
- package/dist/interfaces/kafka-language-message.interface.js.map +1 -0
- package/dist/interfaces/kafka-module-async-options.interface.d.ts +10 -0
- package/dist/interfaces/kafka-module-async-options.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-module-async-options.interface.js +3 -0
- package/dist/interfaces/kafka-module-async-options.interface.js.map +1 -0
- package/dist/interfaces/kafka-module-factory.interface.d.ts +5 -0
- package/dist/interfaces/kafka-module-factory.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-module-factory.interface.js +3 -0
- package/dist/interfaces/kafka-module-factory.interface.js.map +1 -0
- package/dist/interfaces/kafka-module-options.interface.d.ts +5 -0
- package/dist/interfaces/kafka-module-options.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-module-options.interface.js +3 -0
- package/dist/interfaces/kafka-module-options.interface.js.map +1 -0
- package/dist/interfaces/kafka-success-response.interface.d.ts +13 -0
- package/dist/interfaces/kafka-success-response.interface.d.ts.map +1 -0
- package/dist/interfaces/kafka-success-response.interface.js +3 -0
- package/dist/interfaces/kafka-success-response.interface.js.map +1 -0
- package/dist/kafka-admin.service.d.ts.map +1 -1
- package/dist/kafka-admin.service.js.map +1 -1
- package/dist/kafka-consumer.service.d.ts.map +1 -1
- package/dist/kafka-consumer.service.js.map +1 -1
- package/dist/kafka-instance.const.d.ts.map +1 -1
- package/dist/kafka-instance.const.js.map +1 -1
- package/dist/kafka-producer.service.d.ts.map +1 -1
- package/dist/kafka-producer.service.js.map +1 -1
- package/dist/kafka.interface.d.ts +4 -15
- package/dist/kafka.interface.d.ts.map +1 -1
- package/dist/kafka.interface.js +19 -1
- package/dist/kafka.interface.js.map +1 -1
- package/dist/kafka.module.d.ts.map +1 -1
- package/dist/kafka.module.js.map +1 -1
- package/dist/kafka.provider.d.ts.map +1 -1
- package/dist/kafka.provider.js.map +1 -1
- package/dist/resolvers/index.d.ts +2 -0
- package/dist/resolvers/index.d.ts.map +1 -0
- package/dist/resolvers/index.js +18 -0
- package/dist/resolvers/index.js.map +1 -0
- package/dist/resolvers/kafka-language.resolver.d.ts +7 -0
- package/dist/resolvers/kafka-language.resolver.d.ts.map +1 -0
- package/dist/resolvers/kafka-language.resolver.js +36 -0
- package/dist/resolvers/kafka-language.resolver.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/kafka-language-headers.type.d.ts +2 -0
- package/dist/types/kafka-language-headers.type.d.ts.map +1 -0
- package/dist/types/kafka-language-headers.type.js +3 -0
- package/dist/types/kafka-language-headers.type.js.map +1 -0
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @mondart/nestjs-common-module-kafka
|
|
2
|
+
|
|
3
|
+
Kafka integration for NestJS: a `KafkaModule`/`KafkaService` pair for
|
|
4
|
+
producing, consuming, and administering topics on top of `kafkajs`, plus
|
|
5
|
+
shared DTOs, RxJS operators, and the language-propagation helpers used to
|
|
6
|
+
carry `nestjs-i18n` language across service boundaries.
|
|
7
|
+
|
|
8
|
+
## Registration
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { KafkaModule } from '@mondart/nestjs-common-module-kafka';
|
|
12
|
+
|
|
13
|
+
@Module({
|
|
14
|
+
imports: [
|
|
15
|
+
KafkaModule.forRoot({
|
|
16
|
+
clientId: 'my-service',
|
|
17
|
+
brokers: ['kafka:9092'],
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
})
|
|
21
|
+
export class AppModule {}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or asynchronously:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
KafkaModule.forRootAsync({
|
|
28
|
+
imports: [ConfigModule],
|
|
29
|
+
inject: [ConfigService],
|
|
30
|
+
useFactory: (config: ConfigService) => ({
|
|
31
|
+
clientId: config.get('KAFKA_CLIENT_ID'),
|
|
32
|
+
brokers: config.get('KAFKA_BROKERS').split(','),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`KafkaModule` is `@Global()`, so `KafkaService` is available for injection
|
|
38
|
+
anywhere without re-importing the module.
|
|
39
|
+
|
|
40
|
+
## KafkaService
|
|
41
|
+
|
|
42
|
+
`KafkaService` owns one producer, one admin client, and any number of named
|
|
43
|
+
consumers (keyed by consumer group id) for the `clientId`/`brokers` given at
|
|
44
|
+
registration.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
constructor(private readonly kafkaService: KafkaService) {}
|
|
48
|
+
|
|
49
|
+
async onModuleInit() {
|
|
50
|
+
await this.kafkaService.startProducer();
|
|
51
|
+
await this.kafkaService.sendProducerEvent('user.created', { id: 1 });
|
|
52
|
+
|
|
53
|
+
await this.kafkaService.setConsumer({
|
|
54
|
+
groupIdKey: 'USER_CONSUMER_GROUP_ID',
|
|
55
|
+
groupIdDefaultValue: 'user-consumer',
|
|
56
|
+
topics: ['user.created'],
|
|
57
|
+
});
|
|
58
|
+
await this.kafkaService.startAllConsumers();
|
|
59
|
+
|
|
60
|
+
const topics = await this.kafkaService.getAvailableTopics();
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- `setConsumer`/`setBulkConsumer` register one or more consumer groups
|
|
65
|
+
(`groupIdKey` is resolved through the environment via `env()`, falling
|
|
66
|
+
back to `groupIdDefaultValue`) without connecting them yet.
|
|
67
|
+
- `startAllConsumers` / `startConsumerByGroupId` connect and subscribe;
|
|
68
|
+
`stopAllConsumers` / `stopConsumerByGroupId` disconnect.
|
|
69
|
+
- `healthCheck(groupId)` reports the consumer group's rebalance state
|
|
70
|
+
(`Stable`, `Dead`, `Pause`, ...) via `KafkaHealthState`.
|
|
71
|
+
|
|
72
|
+
For lower-level access, `KafkaAdminService`, `KafkaConsumerService`, and
|
|
73
|
+
`KafkaProducerService` (each a thin wrapper around the matching `kafkajs`
|
|
74
|
+
client) are also exported for cases that don't go through `KafkaModule`.
|
|
75
|
+
|
|
76
|
+
## Kafka DTOs
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import {
|
|
80
|
+
BaseKafkaEventDto,
|
|
81
|
+
KafkaRequestDto,
|
|
82
|
+
KafkaSuccessResponse,
|
|
83
|
+
KafkaFailedResponseDto,
|
|
84
|
+
} from '@mondart/nestjs-common-module-kafka';
|
|
85
|
+
|
|
86
|
+
const success = new KafkaSuccessResponse({
|
|
87
|
+
event_source: 'user-service',
|
|
88
|
+
data: user,
|
|
89
|
+
message: 'USER_CREATED',
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const failure = new KafkaFailedResponseDto({
|
|
93
|
+
event_source: 'user-service',
|
|
94
|
+
}).notFound('user');
|
|
95
|
+
|
|
96
|
+
success.stringify(); // JSON string ready to publish
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`KafkaRequestDto` and `KafkaSuccessResponse` both stamp `metadata.lang` from
|
|
100
|
+
the current `I18nContext` when the caller doesn't supply one.
|
|
101
|
+
`KafkaFailedResponseDto` exposes `notFound` / `badRequest` / `internalServer`
|
|
102
|
+
helpers that set the status and a translated `ErrorResponse` body, each
|
|
103
|
+
returning `this` for chaining.
|
|
104
|
+
|
|
105
|
+
## RxJS helpers
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import {
|
|
109
|
+
RxjsCatchErrorHelper,
|
|
110
|
+
RxjsCustomTimeoutHelper,
|
|
111
|
+
} from '@mondart/nestjs-common-module-kafka';
|
|
112
|
+
|
|
113
|
+
kafkaClient
|
|
114
|
+
.send(topic, request)
|
|
115
|
+
.pipe(
|
|
116
|
+
RxjsCustomTimeoutHelper.create(30, UserService.name, 'findOne'),
|
|
117
|
+
RxjsCatchErrorHelper.create(),
|
|
118
|
+
);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- `RxjsCustomTimeoutHelper.create` throws a `GatewayTimeoutException`
|
|
122
|
+
(naming the service/method) instead of RxJS's default `TimeoutError` once
|
|
123
|
+
a request/reply call exceeds `timeoutSeconds`.
|
|
124
|
+
- `RxjsCatchErrorHelper.create` maps errors coming back from the remote
|
|
125
|
+
handler to the matching Nest exception class, so a microservice error is
|
|
126
|
+
rethrown the same way a local one would be.
|
|
127
|
+
|
|
128
|
+
## Kafka language propagation
|
|
129
|
+
|
|
130
|
+
Enable language propagation once for each `ClientKafka` instance before
|
|
131
|
+
sending requests or events:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { KafkaLanguagePropagationHelper } from '@mondart/nestjs-common-module-kafka';
|
|
135
|
+
|
|
136
|
+
KafkaLanguagePropagationHelper.enable(clientKafka);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This adds the language resolved by the current `I18nContext` to the
|
|
140
|
+
`accept-language` Kafka header for both `send` and `emit`. On the receiving
|
|
141
|
+
side, keep `KafkaLanguageResolver` in your i18n resolver configuration:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
I18nModule.forRoot({
|
|
145
|
+
fallbackLanguage: 'en',
|
|
146
|
+
resolvers: [AcceptLanguageResolver, KafkaLanguageResolver],
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Use `KafkaLanguageMessageHelper.withLanguage(value)` directly only when an
|
|
151
|
+
individual message must be wrapped manually. See the root
|
|
152
|
+
[README](../../README.md#kafka-language-propagation) for the full
|
|
153
|
+
rationale and header-forwarding behavior.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-module-options-token.const.d.ts","sourceRoot":"","sources":["../../src/constant/kafka-module-options-token.const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-module-options-token.const.js","sourceRoot":"","sources":["../../src/constant/kafka-module-options-token.const.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { KafkaEventMetadata } from '../../interfaces';
|
|
2
|
+
export declare class BaseKafkaEventDto<T> {
|
|
3
|
+
topic?: string;
|
|
4
|
+
event_source: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
event_key?: string;
|
|
7
|
+
data?: T;
|
|
8
|
+
metadata?: KafkaEventMetadata;
|
|
9
|
+
partition?: number;
|
|
10
|
+
status?: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=base-kafka-event.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-kafka-event.dto.d.ts","sourceRoot":"","sources":["../../../src/dto/base/base-kafka-event.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,iBAAiB,CAAC,CAAC;IAG9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,YAAY,EAAE,MAAM,CAAC;IAIrB,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,IAAI,CAAC,EAAE,CAAC,CAAC;IAGT,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAI9B,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaseKafkaEventDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class BaseKafkaEventDto {
|
|
15
|
+
}
|
|
16
|
+
exports.BaseKafkaEventDto = BaseKafkaEventDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsOptional)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], BaseKafkaEventDto.prototype, "topic", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], BaseKafkaEventDto.prototype, "event_source", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsString)(),
|
|
28
|
+
(0, class_validator_1.IsOptional)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], BaseKafkaEventDto.prototype, "model", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], BaseKafkaEventDto.prototype, "event_key", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, class_validator_1.IsOptional)(),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], BaseKafkaEventDto.prototype, "data", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], BaseKafkaEventDto.prototype, "metadata", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, class_validator_1.IsNumber)(),
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], BaseKafkaEventDto.prototype, "partition", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, class_validator_1.IsNumber)(),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], BaseKafkaEventDto.prototype, "status", void 0);
|
|
54
|
+
//# sourceMappingURL=base-kafka-event.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-kafka-event.dto.js","sourceRoot":"","sources":["../../../src/dto/base/base-kafka-event.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiE;AAGjE,MAAa,iBAAiB;CA6B7B;AA7BD,8CA6BC;AA1BC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;gDACE;AAGf;IADC,IAAA,0BAAQ,GAAE;;uDACU;AAIrB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;gDACE;AAIf;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oDACM;AAGnB;IADC,IAAA,4BAAU,GAAE;;+CACJ;AAGT;IADC,IAAA,4BAAU,GAAE;;mDACiB;AAI9B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oDACM;AAInB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;iDACG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base-kafka-event.dto"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dto/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base"), exports);
|
|
18
|
+
__exportStar(require("./request"), exports);
|
|
19
|
+
__exportStar(require("./response"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B;AAC1B,6CAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/request/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./kafka-request.dto"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseKafkaEventDto } from '../base';
|
|
2
|
+
export declare class KafkaRequestDto<T> extends BaseKafkaEventDto<T> {
|
|
3
|
+
constructor({ data, event_source, topic, model, event_key, metadata, partition, status, }: BaseKafkaEventDto<T>);
|
|
4
|
+
stringify(): string;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=kafka-request.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-request.dto.d.ts","sourceRoot":"","sources":["../../../src/dto/request/kafka-request.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAM5C,qBAAa,eAAe,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;gBAC9C,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,MAAY,GACb,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAcvB,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaRequestDto = void 0;
|
|
4
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
5
|
+
const base_1 = require("../base");
|
|
6
|
+
class KafkaRequestDto extends base_1.BaseKafkaEventDto {
|
|
7
|
+
constructor({ data, event_source, topic, model, event_key, metadata, partition, status = 200, }) {
|
|
8
|
+
super();
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.topic = topic;
|
|
11
|
+
this.event_source = event_source;
|
|
12
|
+
this.model = model;
|
|
13
|
+
this.event_key = event_key;
|
|
14
|
+
const lang = metadata?.lang ?? nestjs_i18n_1.I18nContext.current()?.lang;
|
|
15
|
+
this.metadata = lang ? { ...metadata, lang } : metadata;
|
|
16
|
+
this.partition = partition;
|
|
17
|
+
this.status = status;
|
|
18
|
+
}
|
|
19
|
+
stringify() {
|
|
20
|
+
return JSON.stringify(this);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.KafkaRequestDto = KafkaRequestDto;
|
|
24
|
+
//# sourceMappingURL=kafka-request.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-request.dto.js","sourceRoot":"","sources":["../../../src/dto/request/kafka-request.dto.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,kCAA4C;AAM5C,MAAa,eAAmB,SAAQ,wBAAoB;IAC1D,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,MAAM,GAAG,GAAG,GACS;QACrB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,IAAI,yBAAW,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC;QAC3D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QACxD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AA3BD,0CA2BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dto/response/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./kafka-failed-response.dto"), exports);
|
|
18
|
+
__exportStar(require("./kafka-success-response.dto"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,+DAA6C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KafkaFailedResponseInterface } from '../../interfaces';
|
|
2
|
+
import { BaseKafkaEventDto } from '../base';
|
|
3
|
+
export declare class KafkaFailedResponseDto<T> extends BaseKafkaEventDto<T | any> {
|
|
4
|
+
constructor({ data, event_source, topic, model, event_key, partition, status, }: KafkaFailedResponseInterface);
|
|
5
|
+
notFound(message?: string): this;
|
|
6
|
+
badRequest(message?: string): this;
|
|
7
|
+
internalServer(message?: string): this;
|
|
8
|
+
stringify(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=kafka-failed-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-failed-response.dto.d.ts","sourceRoot":"","sources":["../../../src/dto/response/kafka-failed-response.dto.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQ5C,qBAAa,sBAAsB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,GAAG,GAAG,CAAC;gBAC3D,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,MAA+B,GAChC,EAAE,4BAA4B;IAY/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAahC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAalC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAatC,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaFailedResponseDto = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const nestjs_common_module_core_1 = require("@mondart/nestjs-common-module-core");
|
|
6
|
+
const base_1 = require("../base");
|
|
7
|
+
class KafkaFailedResponseDto extends base_1.BaseKafkaEventDto {
|
|
8
|
+
constructor({ data, event_source, topic, model, event_key, partition, status = common_1.HttpStatus.BAD_REQUEST, }) {
|
|
9
|
+
super();
|
|
10
|
+
this.data = data;
|
|
11
|
+
this.topic = topic;
|
|
12
|
+
this.event_source = event_source;
|
|
13
|
+
this.model = model;
|
|
14
|
+
this.event_key = event_key;
|
|
15
|
+
this.partition = partition;
|
|
16
|
+
this.status = status;
|
|
17
|
+
}
|
|
18
|
+
notFound(message) {
|
|
19
|
+
this.status = common_1.HttpStatus.NOT_FOUND;
|
|
20
|
+
this.data = new nestjs_common_module_core_1.ErrorResponse({
|
|
21
|
+
name: common_1.NotFoundException.name,
|
|
22
|
+
message: nestjs_common_module_core_1.MessageFormatter.replace(nestjs_common_module_core_1.SharedMessages.RESOURCE_NOT_FOUND, message),
|
|
23
|
+
status: this.status,
|
|
24
|
+
});
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
badRequest(message) {
|
|
28
|
+
this.status = common_1.HttpStatus.BAD_REQUEST;
|
|
29
|
+
this.data = new nestjs_common_module_core_1.ErrorResponse({
|
|
30
|
+
name: common_1.BadRequestException.name,
|
|
31
|
+
message: nestjs_common_module_core_1.MessageFormatter.replace(nestjs_common_module_core_1.SharedMessages.PARAMETER_VALIDATION_FAILED, message),
|
|
32
|
+
status: this.status,
|
|
33
|
+
});
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
internalServer(message) {
|
|
37
|
+
this.status = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
38
|
+
this.data = new nestjs_common_module_core_1.ErrorResponse({
|
|
39
|
+
name: common_1.InternalServerErrorException.name,
|
|
40
|
+
message: nestjs_common_module_core_1.MessageFormatter.replace(nestjs_common_module_core_1.SharedMessages.INTERNAL_SERVER_ERROR, message),
|
|
41
|
+
status: this.status,
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
stringify() {
|
|
46
|
+
return JSON.stringify(this);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.KafkaFailedResponseDto = KafkaFailedResponseDto;
|
|
50
|
+
//# sourceMappingURL=kafka-failed-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-failed-response.dto.js","sourceRoot":"","sources":["../../../src/dto/response/kafka-failed-response.dto.ts"],"names":[],"mappings":";;;AAAA,2CAKwB;AACxB,kFAI4C;AAE5C,kCAA4C;AAQ5C,MAAa,sBAA0B,SAAQ,wBAA0B;IACvE,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,MAAM,GAAG,mBAAU,CAAC,WAAW,GACF;QAC7B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ,CAAC,OAAgB;QACvB,IAAI,CAAC,MAAM,GAAG,mBAAU,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,yCAAa,CAAC;YAC5B,IAAI,EAAE,0BAAiB,CAAC,IAAI;YAC5B,OAAO,EAAE,4CAAgB,CAAC,OAAO,CAC/B,0CAAc,CAAC,kBAAkB,EACjC,OAAO,CACR;YACD,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,MAAM,GAAG,mBAAU,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,yCAAa,CAAC;YAC5B,IAAI,EAAE,4BAAmB,CAAC,IAAI;YAC9B,OAAO,EAAE,4CAAgB,CAAC,OAAO,CAC/B,0CAAc,CAAC,2BAA2B,EAC1C,OAAO,CACR;YACD,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,OAAgB;QAC7B,IAAI,CAAC,MAAM,GAAG,mBAAU,CAAC,qBAAqB,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,yCAAa,CAAC;YAC5B,IAAI,EAAE,qCAA4B,CAAC,IAAI;YACvC,OAAO,EAAE,4CAAgB,CAAC,OAAO,CAC/B,0CAAc,CAAC,qBAAqB,EACpC,OAAO,CACR;YACD,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AA/DD,wDA+DC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KafkaSuccessResponseInterface } from '../../interfaces';
|
|
2
|
+
import { BaseKafkaEventDto } from '../base';
|
|
3
|
+
export declare class KafkaSuccessResponse<T> extends BaseKafkaEventDto<T> {
|
|
4
|
+
message?: string;
|
|
5
|
+
constructor({ data, metadata, event_source, topic, model, event_key, message, partition, status, }: KafkaSuccessResponseInterface<T>);
|
|
6
|
+
stringify(): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=kafka-success-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-success-response.dto.d.ts","sourceRoot":"","sources":["../../../src/dto/response/kafka-success-response.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQ5C,qBAAa,oBAAoB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEL,EACV,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,MAAY,GACb,EAAE,6BAA6B,CAAC,CAAC,CAAC;IAkBnC,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaSuccessResponse = void 0;
|
|
4
|
+
const base_1 = require("../base");
|
|
5
|
+
const nestjs_common_module_core_1 = require("@mondart/nestjs-common-module-core");
|
|
6
|
+
class KafkaSuccessResponse extends base_1.BaseKafkaEventDto {
|
|
7
|
+
constructor({ data, metadata, event_source, topic, model, event_key, message, partition, status = 200, }) {
|
|
8
|
+
super();
|
|
9
|
+
const translated = nestjs_common_module_core_1.SuccessResponseTranslationHelper.translate(message, metadata);
|
|
10
|
+
this.data = data;
|
|
11
|
+
this.metadata = translated.metadata;
|
|
12
|
+
this.topic = topic;
|
|
13
|
+
this.event_source = event_source;
|
|
14
|
+
this.model = model;
|
|
15
|
+
this.event_key = event_key;
|
|
16
|
+
this.message = translated.message;
|
|
17
|
+
this.partition = partition;
|
|
18
|
+
this.status = status;
|
|
19
|
+
}
|
|
20
|
+
stringify() {
|
|
21
|
+
return JSON.stringify(this);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.KafkaSuccessResponse = KafkaSuccessResponse;
|
|
25
|
+
//# sourceMappingURL=kafka-success-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-success-response.dto.js","sourceRoot":"","sources":["../../../src/dto/response/kafka-success-response.dto.ts"],"names":[],"mappings":";;;AACA,kCAA4C;AAC5C,kFAAsF;AAOtF,MAAa,oBAAwB,SAAQ,wBAAoB;IAG/D,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,MAAM,GAAG,GAAG,GACqB;QACjC,KAAK,EAAE,CAAC;QACR,MAAM,UAAU,GAAG,4DAAgC,CAAC,SAAS,CAC3D,OAAO,EACP,QAAQ,CACT,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AAlCD,oDAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./kafka-language-message.helper"), exports);
|
|
18
|
+
__exportStar(require("./kafka-language-propagation.helper"), exports);
|
|
19
|
+
__exportStar(require("./rxjs-catch-error.helper"), exports);
|
|
20
|
+
__exportStar(require("./rxjs-custom-timeout.helper"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,sEAAoD;AACpD,4DAA0C;AAC1C,+DAA6C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KafkaLanguageMessage } from '../interfaces';
|
|
2
|
+
export declare class KafkaLanguageMessageHelper {
|
|
3
|
+
static readonly HEADER = "accept-language";
|
|
4
|
+
static readonly DEFAULT_LANGUAGE = "en";
|
|
5
|
+
static withLanguage<T>(data: T, fallbackLanguage?: string): KafkaLanguageMessage<T> | T;
|
|
6
|
+
static resolve(existingHeader?: unknown, fallbackLanguage?: string): string;
|
|
7
|
+
private static isKafkaMessage;
|
|
8
|
+
private static headerToString;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=kafka-language-message.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka-language-message.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/kafka-language-message.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,qBAAa,0BAA0B;IACrC,MAAM,CAAC,QAAQ,CAAC,MAAM,qBAAqB;IAC3C,MAAM,CAAC,QAAQ,CAAC,gBAAgB,QAAQ;IAUxC,MAAM,CAAC,YAAY,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC,EACP,gBAAgB,SAAwB,GACvC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC;IA8B9B,MAAM,CAAC,OAAO,CACZ,cAAc,CAAC,EAAE,OAAO,EACxB,gBAAgB,SAAwB,GACvC,MAAM;IAQT,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B,OAAO,CAAC,MAAM,CAAC,cAAc;CAO9B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaLanguageMessageHelper = void 0;
|
|
4
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
5
|
+
class KafkaLanguageMessageHelper {
|
|
6
|
+
static withLanguage(data, fallbackLanguage = this.DEFAULT_LANGUAGE) {
|
|
7
|
+
if (this.isKafkaMessage(data)) {
|
|
8
|
+
const message = data;
|
|
9
|
+
const language = this.resolve(message.headers?.[this.HEADER], fallbackLanguage);
|
|
10
|
+
return {
|
|
11
|
+
...message,
|
|
12
|
+
headers: {
|
|
13
|
+
...(message.headers ?? {}),
|
|
14
|
+
[this.HEADER]: language,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
value: data,
|
|
20
|
+
headers: {
|
|
21
|
+
[this.HEADER]: this.resolve(undefined, fallbackLanguage),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
static resolve(existingHeader, fallbackLanguage = this.DEFAULT_LANGUAGE) {
|
|
26
|
+
return (nestjs_i18n_1.I18nContext.current()?.lang ??
|
|
27
|
+
this.headerToString(existingHeader) ??
|
|
28
|
+
fallbackLanguage);
|
|
29
|
+
}
|
|
30
|
+
static isKafkaMessage(value) {
|
|
31
|
+
return (value !== null &&
|
|
32
|
+
typeof value === 'object' &&
|
|
33
|
+
('value' in value || 'key' in value));
|
|
34
|
+
}
|
|
35
|
+
static headerToString(value) {
|
|
36
|
+
if (Buffer.isBuffer(value))
|
|
37
|
+
return value.toString('utf8');
|
|
38
|
+
if (typeof value === 'string')
|
|
39
|
+
return value;
|
|
40
|
+
if (Array.isArray(value))
|
|
41
|
+
return this.headerToString(value[0]);
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.KafkaLanguageMessageHelper = KafkaLanguageMessageHelper;
|
|
46
|
+
KafkaLanguageMessageHelper.HEADER = 'accept-language';
|
|
47
|
+
KafkaLanguageMessageHelper.DEFAULT_LANGUAGE = 'en';
|
|
48
|
+
//# sourceMappingURL=kafka-language-message.helper.js.map
|