@taphealth/kafka 2.0.0 → 2.0.3
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const topics_1 = require("../topics");
|
|
4
|
+
const daily_plan_1 = require("../types/daily-plan");
|
|
5
|
+
const assert = (condition, message) => {
|
|
6
|
+
if (!condition) {
|
|
7
|
+
throw new Error(message);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const dailyPlanCreatedEvent = {
|
|
11
|
+
topic: topics_1.Topics.DailyPlanCreated,
|
|
12
|
+
data: {
|
|
13
|
+
userId: "user-1",
|
|
14
|
+
timezone: "Asia/Kolkata",
|
|
15
|
+
date: "2026-05-11",
|
|
16
|
+
tasks: {
|
|
17
|
+
nutrition: [
|
|
18
|
+
{
|
|
19
|
+
type: daily_plan_1.DailyTaskType.DIET_LOGGING,
|
|
20
|
+
description: "Log breakfast",
|
|
21
|
+
target: {
|
|
22
|
+
unit: "meals",
|
|
23
|
+
initial: 1,
|
|
24
|
+
current: 0,
|
|
25
|
+
},
|
|
26
|
+
habitKey: daily_plan_1.HabitKey.DIET_LOG_BREAKFAST,
|
|
27
|
+
isMicroChallenge: false,
|
|
28
|
+
currentProgress: 0,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
plan: {
|
|
33
|
+
nutrition: {
|
|
34
|
+
targetCalories: 1800,
|
|
35
|
+
targetMacros: {
|
|
36
|
+
protein: 120,
|
|
37
|
+
carbs: 180,
|
|
38
|
+
fats: 60,
|
|
39
|
+
fibre: 30,
|
|
40
|
+
},
|
|
41
|
+
targetCalorieDistribution: {
|
|
42
|
+
carbs: 40,
|
|
43
|
+
protein: 30,
|
|
44
|
+
fat: 30,
|
|
45
|
+
fibre: 0,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
glucose: {
|
|
49
|
+
fasting: true,
|
|
50
|
+
postprandial: true,
|
|
51
|
+
night: false,
|
|
52
|
+
preWorkout: false,
|
|
53
|
+
},
|
|
54
|
+
activity: {
|
|
55
|
+
steps: 8000,
|
|
56
|
+
},
|
|
57
|
+
education: {
|
|
58
|
+
topic: "sleep",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const roundTrippedEvent = JSON.parse(JSON.stringify(dailyPlanCreatedEvent));
|
|
64
|
+
assert(dailyPlanCreatedEvent.topic === topics_1.Topics.DailyPlanCreated, "Daily-plan-created event topic must be daily-plan-created");
|
|
65
|
+
assert(!Object.prototype.hasOwnProperty.call(dailyPlanCreatedEvent.data, "nudgePlan"), "Daily-plan-created contract must not include nudgePlan");
|
|
66
|
+
assert(!Object.prototype.hasOwnProperty.call(roundTrippedEvent.data, "nudgePlan"), "Round-trip should preserve absence of nudgePlan");
|
|
67
|
+
assert(roundTrippedEvent.data.plan.activity.steps === 8000, "Round-trip should preserve plan payload");
|
|
@@ -9,25 +9,6 @@ export interface DailyPlanCreatedEvent {
|
|
|
9
9
|
tasks: {
|
|
10
10
|
[module: string]: DailyTask[];
|
|
11
11
|
};
|
|
12
|
-
nudgePlan: {
|
|
13
|
-
dayNumber: number;
|
|
14
|
-
date: string;
|
|
15
|
-
userId: string;
|
|
16
|
-
planSummary: string;
|
|
17
|
-
nudges: Array<{
|
|
18
|
-
module: string;
|
|
19
|
-
time: string;
|
|
20
|
-
priority: number;
|
|
21
|
-
channel: string;
|
|
22
|
-
context: {
|
|
23
|
-
summary: string;
|
|
24
|
-
logPatterns: string[];
|
|
25
|
-
planSummary: string;
|
|
26
|
-
};
|
|
27
|
-
name: string;
|
|
28
|
-
}>;
|
|
29
|
-
warnings: string[];
|
|
30
|
-
};
|
|
31
12
|
plan: {
|
|
32
13
|
nutrition: {
|
|
33
14
|
targetCalories: number;
|
package/dist/types/profile.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taphealth/kafka",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"build": "pnpm clean && tsc",
|
|
28
28
|
"test:producer": "ts-node ./src/__tests__/producer-behavior.test.ts",
|
|
29
29
|
"test:consumer": "ts-node ./src/__tests__/consumer-behavior.test.ts",
|
|
30
|
+
"test:contracts": "ts-node ./src/__tests__/weekly-command-contract.test.ts && ts-node ./src/__tests__/daily-plan-created-contract.test.ts",
|
|
30
31
|
"test": "pnpm test:contracts && pnpm test:producer && pnpm test:consumer",
|
|
31
|
-
"test:contracts": "ts-node ./src/__tests__/weekly-command-contract.test.ts",
|
|
32
32
|
"pub": "pnpm version patch --no-git-checks && pnpm build && pnpm publish --no-git-checks"
|
|
33
33
|
}
|
|
34
34
|
}
|