@taphealth/kafka 1.2.40 → 1.2.42
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 +68 -68
- package/dist/events/diet-created.d.ts +8 -0
- package/dist/events/diet-generate.d.ts +8 -0
- package/dist/events/profile-updated.d.ts +32 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/topics.d.ts +3 -3
- package/dist/topics.js +2 -2
- package/dist/types/profile.d.ts +27 -89
- package/package.json +1 -1
- package/dist/events/diet-cron.d.ts +0 -8
- package/dist/events/scheduler.d.ts +0 -8
- /package/dist/events/{diet-cron.js → diet-created.js} +0 -0
- /package/dist/events/{scheduler.js → diet-generate.js} +0 -0
package/README.md
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# Kafka Helper Library
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
This repository provides a Kafka helper library designed for seamless integration of Kafka messaging in tap-health-backend. It abstracts complexities of the KafkaJS library, offering simplified interfaces for both producing and consuming messages.
|
|
6
|
-
|
|
7
|
-
## Key Features
|
|
8
|
-
|
|
9
|
-
- **KafkaClient**: Manages Kafka connections and administrative operations such as topic creation.
|
|
10
|
-
- **KafkaProducer**: Facilitates easy production of messages to Kafka topics.
|
|
11
|
-
- **KafkaConsumer**: Simplifies consumption of messages from Kafka topics.
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
### Installation
|
|
16
|
-
|
|
17
|
-
Install the library using pnpm:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pnpm install @taphealth/kafka
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Connecting to Kafka
|
|
24
|
-
|
|
25
|
-
Initialize a KafkaClient instance to connect to Kafka brokers:
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { KafkaClient } from "@taphealth/kafka";
|
|
29
|
-
|
|
30
|
-
const kafkaClient = new KafkaClient();
|
|
31
|
-
await kafkaClient.connect(["localhost:9092"]);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Producing Messages
|
|
35
|
-
|
|
36
|
-
Use KafkaProducer to send messages to Kafka topics:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
import { KafkaProducer } from "@taphealth/kafka";
|
|
40
|
-
import { Topics } from "@taphealth/kafka";
|
|
41
|
-
import { YourEventInterface } from "./your-event-interface";
|
|
42
|
-
|
|
43
|
-
const producer = new KafkaProducer() < YourEventInterface > kafkaClient.client;
|
|
44
|
-
await producer.send({
|
|
45
|
-
// Your message payload
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Consuming Messages
|
|
50
|
-
|
|
51
|
-
Extend KafkaConsumer to implement message handling logic:
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import { KafkaConsumer } from "@taphealth/kafka";
|
|
55
|
-
import { Topics } from "@taphealth/kafka";
|
|
56
|
-
import { YourEventInterface } from "./your-event-interface";
|
|
57
|
-
|
|
58
|
-
export class YourEventConsumer extends KafkaConsumer<YourEventInterface> {
|
|
59
|
-
topic = Topics.YourTopic;
|
|
60
|
-
|
|
61
|
-
async onMessage(data: YourEventInterface["data"], message: any) {
|
|
62
|
-
// business logic
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const consumer = new YourEventConsumer(kafkaClient.client);
|
|
67
|
-
await consumer.consume();
|
|
68
|
-
```
|
|
1
|
+
# Kafka Helper Library
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This repository provides a Kafka helper library designed for seamless integration of Kafka messaging in tap-health-backend. It abstracts complexities of the KafkaJS library, offering simplified interfaces for both producing and consuming messages.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **KafkaClient**: Manages Kafka connections and administrative operations such as topic creation.
|
|
10
|
+
- **KafkaProducer**: Facilitates easy production of messages to Kafka topics.
|
|
11
|
+
- **KafkaConsumer**: Simplifies consumption of messages from Kafka topics.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
Install the library using pnpm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install @taphealth/kafka
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Connecting to Kafka
|
|
24
|
+
|
|
25
|
+
Initialize a KafkaClient instance to connect to Kafka brokers:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { KafkaClient } from "@taphealth/kafka";
|
|
29
|
+
|
|
30
|
+
const kafkaClient = new KafkaClient();
|
|
31
|
+
await kafkaClient.connect(["localhost:9092"]);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Producing Messages
|
|
35
|
+
|
|
36
|
+
Use KafkaProducer to send messages to Kafka topics:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { KafkaProducer } from "@taphealth/kafka";
|
|
40
|
+
import { Topics } from "@taphealth/kafka";
|
|
41
|
+
import { YourEventInterface } from "./your-event-interface";
|
|
42
|
+
|
|
43
|
+
const producer = new KafkaProducer() < YourEventInterface > kafkaClient.client;
|
|
44
|
+
await producer.send({
|
|
45
|
+
// Your message payload
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Consuming Messages
|
|
50
|
+
|
|
51
|
+
Extend KafkaConsumer to implement message handling logic:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { KafkaConsumer } from "@taphealth/kafka";
|
|
55
|
+
import { Topics } from "@taphealth/kafka";
|
|
56
|
+
import { YourEventInterface } from "./your-event-interface";
|
|
57
|
+
|
|
58
|
+
export class YourEventConsumer extends KafkaConsumer<YourEventInterface> {
|
|
59
|
+
topic = Topics.YourTopic;
|
|
60
|
+
|
|
61
|
+
async onMessage(data: YourEventInterface["data"], message: any) {
|
|
62
|
+
// business logic
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const consumer = new YourEventConsumer(kafkaClient.client);
|
|
67
|
+
await consumer.consume();
|
|
68
|
+
```
|
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import { Topics } from "../topics";
|
|
2
|
-
import {
|
|
2
|
+
import { settings } from "../types/profile";
|
|
3
|
+
interface ProfileUpdatedData {
|
|
4
|
+
id: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
patientId?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
relation?: string;
|
|
9
|
+
gender?: string;
|
|
10
|
+
age?: number;
|
|
11
|
+
location?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
deviceId?: string;
|
|
14
|
+
profileCompleted?: boolean;
|
|
15
|
+
smoking?: boolean;
|
|
16
|
+
drinking?: boolean;
|
|
17
|
+
pregnancy?: boolean;
|
|
18
|
+
diabetes?: boolean;
|
|
19
|
+
hypertension?: boolean;
|
|
20
|
+
followSymptom?: boolean;
|
|
21
|
+
metaQuestion?: boolean;
|
|
22
|
+
sharedOnWhatsApp?: boolean;
|
|
23
|
+
registeredOnMeradoc?: boolean;
|
|
24
|
+
sharedOnSMS?: boolean;
|
|
25
|
+
shareCount?: number;
|
|
26
|
+
preferredLanguage?: string;
|
|
27
|
+
createdAt?: Date;
|
|
28
|
+
updatedAt?: Date;
|
|
29
|
+
weight?: string;
|
|
30
|
+
height?: string;
|
|
31
|
+
settings?: settings;
|
|
32
|
+
}
|
|
3
33
|
export interface ProfileUpdatedEvent {
|
|
4
34
|
topic: Topics.ProfileUpdated;
|
|
5
35
|
data: ProfileUpdatedData;
|
|
6
36
|
}
|
|
37
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export * from "./events/dtx-created";
|
|
|
14
14
|
export * from "./events/expiration-complete";
|
|
15
15
|
export * from "./events/refund-initiate";
|
|
16
16
|
export * from "./events/refund-processed";
|
|
17
|
-
export * from "./events/diet-
|
|
18
|
-
export * from "./events/
|
|
17
|
+
export * from "./events/diet-created";
|
|
18
|
+
export * from "./events/diet-generate";
|
|
19
19
|
export * from "./events/dtx-created";
|
|
20
20
|
export * from "./events/profile-updated";
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ __exportStar(require("./events/dtx-created"), exports);
|
|
|
30
30
|
__exportStar(require("./events/expiration-complete"), exports);
|
|
31
31
|
__exportStar(require("./events/refund-initiate"), exports);
|
|
32
32
|
__exportStar(require("./events/refund-processed"), exports);
|
|
33
|
-
__exportStar(require("./events/diet-
|
|
34
|
-
__exportStar(require("./events/
|
|
33
|
+
__exportStar(require("./events/diet-created"), exports);
|
|
34
|
+
__exportStar(require("./events/diet-generate"), exports);
|
|
35
35
|
__exportStar(require("./events/dtx-created"), exports);
|
|
36
36
|
__exportStar(require("./events/profile-updated"), exports);
|
package/dist/topics.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export declare enum Topics {
|
|
|
4
4
|
AppointmentComplete = "appointment-complete",
|
|
5
5
|
AppointmentTimer = "appointment-timer",
|
|
6
6
|
DtxCreated = "dtx-created",
|
|
7
|
-
|
|
7
|
+
DietCreated = "diet-created",
|
|
8
|
+
DietGenerate = "diet-generate",
|
|
8
9
|
OfflineAppointmentCreated = "offline-appointment-created",
|
|
9
10
|
OfflineAppointmentUpdated = "offline-appointment-updated",
|
|
10
11
|
PaymentCaptured = "payment-captured",
|
|
@@ -12,6 +13,5 @@ export declare enum Topics {
|
|
|
12
13
|
ExpirationComplete = "expiration-complete",
|
|
13
14
|
RefundInitiate = "refund-initiate",
|
|
14
15
|
RefundProcessed = "refund-processed",
|
|
15
|
-
ProfileUpdated = "profile-updated"
|
|
16
|
-
Scheduler = "scheduler"
|
|
16
|
+
ProfileUpdated = "profile-updated"
|
|
17
17
|
}
|
package/dist/topics.js
CHANGED
|
@@ -8,7 +8,8 @@ var Topics;
|
|
|
8
8
|
Topics["AppointmentComplete"] = "appointment-complete";
|
|
9
9
|
Topics["AppointmentTimer"] = "appointment-timer";
|
|
10
10
|
Topics["DtxCreated"] = "dtx-created";
|
|
11
|
-
Topics["
|
|
11
|
+
Topics["DietCreated"] = "diet-created";
|
|
12
|
+
Topics["DietGenerate"] = "diet-generate";
|
|
12
13
|
Topics["OfflineAppointmentCreated"] = "offline-appointment-created";
|
|
13
14
|
Topics["OfflineAppointmentUpdated"] = "offline-appointment-updated";
|
|
14
15
|
Topics["PaymentCaptured"] = "payment-captured";
|
|
@@ -17,5 +18,4 @@ var Topics;
|
|
|
17
18
|
Topics["RefundInitiate"] = "refund-initiate";
|
|
18
19
|
Topics["RefundProcessed"] = "refund-processed";
|
|
19
20
|
Topics["ProfileUpdated"] = "profile-updated";
|
|
20
|
-
Topics["Scheduler"] = "scheduler";
|
|
21
21
|
})(Topics || (exports.Topics = Topics = {}));
|
package/dist/types/profile.d.ts
CHANGED
|
@@ -1,42 +1,23 @@
|
|
|
1
|
-
export interface ProfileUpdatedData {
|
|
2
|
-
id: string;
|
|
3
|
-
userId?: string;
|
|
4
|
-
patientId?: string;
|
|
5
|
-
name?: string;
|
|
6
|
-
relation?: string;
|
|
7
|
-
gender?: string;
|
|
8
|
-
age?: number;
|
|
9
|
-
location?: string;
|
|
10
|
-
email?: string;
|
|
11
|
-
deviceId?: string;
|
|
12
|
-
profileCompleted?: boolean;
|
|
13
|
-
smoking?: boolean;
|
|
14
|
-
drinking?: boolean;
|
|
15
|
-
pregnancy?: boolean;
|
|
16
|
-
diabetes?: boolean;
|
|
17
|
-
hypertension?: boolean;
|
|
18
|
-
followSymptom?: boolean;
|
|
19
|
-
metaQuestion?: boolean;
|
|
20
|
-
sharedOnWhatsApp?: boolean;
|
|
21
|
-
registeredOnMeradoc?: boolean;
|
|
22
|
-
sharedOnSMS?: boolean;
|
|
23
|
-
shareCount?: number;
|
|
24
|
-
preferredLanguage?: string;
|
|
25
|
-
createdAt?: Date;
|
|
26
|
-
updatedAt?: Date;
|
|
27
|
-
settings?: settings;
|
|
28
|
-
}
|
|
29
1
|
export interface settings {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
sleepTime: string;
|
|
3
|
+
hasBreakfast: boolean;
|
|
4
|
+
breakfastMealSize: string;
|
|
5
|
+
hasBeverageInBreakfast: boolean;
|
|
6
|
+
hasLunch: boolean;
|
|
7
|
+
hasVegetables: boolean;
|
|
8
|
+
vegetableIntake: string;
|
|
9
|
+
hasPulsesInLunch: boolean;
|
|
10
|
+
lunchPulseIntake: string;
|
|
11
|
+
hasMeatInLunch: boolean;
|
|
12
|
+
lunchMeatIntake: string;
|
|
13
|
+
hasRotiInLunch: boolean;
|
|
14
|
+
lunchRotiIntake: string;
|
|
15
|
+
medicalConditions: string[];
|
|
16
|
+
recentSurgery: boolean;
|
|
17
|
+
diet: DietPreferences;
|
|
18
|
+
diabetes: DiabetesPreferences;
|
|
38
19
|
}
|
|
39
|
-
export interface
|
|
20
|
+
export interface DiabetesPreferences {
|
|
40
21
|
programReason: string[];
|
|
41
22
|
motivation: string[];
|
|
42
23
|
goal: string[];
|
|
@@ -50,13 +31,20 @@ export interface DiabetesSettings {
|
|
|
50
31
|
hba1cLevel: string;
|
|
51
32
|
history: string[];
|
|
52
33
|
diabetesInFamily: boolean;
|
|
34
|
+
dietPreference: string;
|
|
35
|
+
cuisinePreferences: string[];
|
|
36
|
+
pulses: string[];
|
|
37
|
+
grains: string[];
|
|
38
|
+
vegetables: string[];
|
|
39
|
+
nonVegPreferences: string[];
|
|
40
|
+
nonVegDays: string[];
|
|
53
41
|
medications: string[];
|
|
54
42
|
}
|
|
55
|
-
export interface
|
|
43
|
+
export interface DietPreferences {
|
|
56
44
|
dietReason: string;
|
|
57
45
|
activityLevel: string;
|
|
58
46
|
allergies: string[];
|
|
59
|
-
|
|
47
|
+
dietPreference: string;
|
|
60
48
|
cuisinePreferences: string[];
|
|
61
49
|
pulses: string[];
|
|
62
50
|
grains: string[];
|
|
@@ -65,53 +53,3 @@ export interface DietSettings {
|
|
|
65
53
|
nonVegDays: string[];
|
|
66
54
|
medications: string[];
|
|
67
55
|
}
|
|
68
|
-
export interface LunchSettings {
|
|
69
|
-
hasLunch: boolean;
|
|
70
|
-
hasVegetablesInLunch: boolean;
|
|
71
|
-
hasPulsesInLunch: boolean;
|
|
72
|
-
hasMeatInLunch: boolean;
|
|
73
|
-
hasRotiInLunch: boolean;
|
|
74
|
-
hasRiceInLunch: boolean;
|
|
75
|
-
lunchVegetableIntake: string;
|
|
76
|
-
lunchPulseIntake: string;
|
|
77
|
-
lunchMeatIntake: string;
|
|
78
|
-
lunchRotiIntake: string;
|
|
79
|
-
lunchRiceIntake: string;
|
|
80
|
-
}
|
|
81
|
-
export interface BreakfastSettings {
|
|
82
|
-
hasBreakfast: boolean;
|
|
83
|
-
breakfastMealSize: string;
|
|
84
|
-
hasMealInBreakfast: boolean;
|
|
85
|
-
hasBeverageInBreakfast: boolean;
|
|
86
|
-
}
|
|
87
|
-
export interface DinnerSettings {
|
|
88
|
-
hasDinner: boolean;
|
|
89
|
-
hasVegetablesInDinner: boolean;
|
|
90
|
-
hasPulsesInDinner: boolean;
|
|
91
|
-
hasMeatInDinner: boolean;
|
|
92
|
-
hasRotiInDinner: boolean;
|
|
93
|
-
hasRiceInDinner: boolean;
|
|
94
|
-
dinnerVegetableIntake: string;
|
|
95
|
-
dinnerPulseIntake: string;
|
|
96
|
-
dinnerMeatIntake: string;
|
|
97
|
-
dinnerRotiIntake: string;
|
|
98
|
-
dinnerRiceIntake: string;
|
|
99
|
-
}
|
|
100
|
-
export interface MedicalSettings {
|
|
101
|
-
medicalConditions: string[];
|
|
102
|
-
recentSurgery: boolean;
|
|
103
|
-
}
|
|
104
|
-
export interface LifeStyleRoutineSettings {
|
|
105
|
-
currentFamilyStructure: string;
|
|
106
|
-
employmentStatus: string;
|
|
107
|
-
workType: string;
|
|
108
|
-
workTimings: string;
|
|
109
|
-
postWorkRoutine: string;
|
|
110
|
-
sleepStartTime: string;
|
|
111
|
-
sleepEndTime: string;
|
|
112
|
-
sleepQuality: string;
|
|
113
|
-
}
|
|
114
|
-
export interface PersonalSettings {
|
|
115
|
-
weight: string;
|
|
116
|
-
height: string;
|
|
117
|
-
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|