@taphealth/kafka 1.6.46 → 1.6.49
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/dist/events/meal-logged.d.ts +1 -0
- package/dist/events/plan-update.d.ts +10 -7
- package/dist/events/plan-updated.d.ts +47 -7
- package/dist/events/plan-updated.js +8 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tests/weekly-command-contract.test.d.ts +1 -0
- package/dist/tests/weekly-command-contract.test.js +65 -0
- package/dist/topics.d.ts +1 -1
- package/dist/topics.js +1 -1
- package/dist/types/plan.d.ts +34 -2
- package/dist/types/plan.js +22 -7
- package/package.json +2 -1
- package/dist/events/weekly-plan-updated.d.ts +0 -11
- package/dist/events/weekly-plan-updated.js +0 -2
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Topics } from "../topics";
|
|
2
|
-
import {
|
|
2
|
+
import { ClinicalContext, Guidelines, PlanUpdateTrigger, PlanUpdateTarget } from "../types/plan";
|
|
3
|
+
export interface PlanUpdateData {
|
|
4
|
+
userId: string;
|
|
5
|
+
trigger: PlanUpdateTrigger;
|
|
6
|
+
target?: PlanUpdateTarget;
|
|
7
|
+
guidelines?: Guidelines;
|
|
8
|
+
clinicalContext?: ClinicalContext;
|
|
9
|
+
reason?: string;
|
|
10
|
+
}
|
|
3
11
|
export interface PlanUpdateEvent {
|
|
4
12
|
topic: Topics.PlanUpdate;
|
|
5
|
-
data:
|
|
6
|
-
userId: string;
|
|
7
|
-
guidelines?: Record<string, string>;
|
|
8
|
-
trigger: PlanUpdatedTrigger;
|
|
9
|
-
target?: PlanUpdateTarget;
|
|
10
|
-
};
|
|
13
|
+
data: PlanUpdateData;
|
|
11
14
|
}
|
|
@@ -1,11 +1,51 @@
|
|
|
1
1
|
import { Topics } from "../topics";
|
|
2
|
+
import { PlanUpdateTrigger, PlanUpdateTarget } from "../types/plan";
|
|
3
|
+
export declare enum PlanUpdatedType {
|
|
4
|
+
PLAN_UPDATED = "PLAN_UPDATED",
|
|
5
|
+
PROFILE_MEDICAL_UPDATED = "PROFILE_MEDICAL_UPDATED",
|
|
6
|
+
REVIEW_AVAILABLE = "REVIEW_AVAILABLE",
|
|
7
|
+
MEAL_ADJUSTED = "MEAL_ADJUSTED"
|
|
8
|
+
}
|
|
9
|
+
export interface ChangeLogEntry {
|
|
10
|
+
module: "nutrition" | "steps" | "exercise" | "glucose";
|
|
11
|
+
changeType: "TARGET_CHANGED" | "SCHEDULE_CHANGED" | "STRATEGY_CHANGED" | "CONTENT_CHANGED";
|
|
12
|
+
changeDetail: {
|
|
13
|
+
field?: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
};
|
|
16
|
+
changeRationale: ChangeRationale;
|
|
17
|
+
impactWindow: "CURRENT_WEEK" | "NEXT_WEEK";
|
|
18
|
+
}
|
|
19
|
+
export interface ChangeRationale {
|
|
20
|
+
trigger: string;
|
|
21
|
+
rationale?: string;
|
|
22
|
+
guidelineSource?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ReviewAvailableMetadata {
|
|
25
|
+
reviewType: string;
|
|
26
|
+
reviewId?: string;
|
|
27
|
+
availableAt?: string;
|
|
28
|
+
trigger: PlanUpdateTrigger;
|
|
29
|
+
target: PlanUpdateTarget;
|
|
30
|
+
changeLog: ChangeLogEntry[];
|
|
31
|
+
}
|
|
32
|
+
export interface MealAdjustedMetadata {
|
|
33
|
+
date: string;
|
|
34
|
+
slotsAdjusted: string[];
|
|
35
|
+
isRecoverable: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PlanUpdatedEventData {
|
|
38
|
+
occurredAt: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
type: PlanUpdatedType;
|
|
41
|
+
source: string;
|
|
42
|
+
correlationId?: string;
|
|
43
|
+
trigger: PlanUpdateTrigger;
|
|
44
|
+
target: PlanUpdateTarget;
|
|
45
|
+
changeLog: ChangeLogEntry[];
|
|
46
|
+
metadata?: MealAdjustedMetadata | ReviewAvailableMetadata;
|
|
47
|
+
}
|
|
2
48
|
export interface PlanUpdatedEvent {
|
|
3
49
|
topic: Topics.PlanUpdated;
|
|
4
|
-
data:
|
|
5
|
-
userId: string;
|
|
6
|
-
type: string;
|
|
7
|
-
message: string;
|
|
8
|
-
date: string;
|
|
9
|
-
metadata?: any;
|
|
10
|
-
};
|
|
50
|
+
data: PlanUpdatedEventData;
|
|
11
51
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlanUpdatedType = void 0;
|
|
4
|
+
var PlanUpdatedType;
|
|
5
|
+
(function (PlanUpdatedType) {
|
|
6
|
+
PlanUpdatedType["PLAN_UPDATED"] = "PLAN_UPDATED";
|
|
7
|
+
PlanUpdatedType["PROFILE_MEDICAL_UPDATED"] = "PROFILE_MEDICAL_UPDATED";
|
|
8
|
+
PlanUpdatedType["REVIEW_AVAILABLE"] = "REVIEW_AVAILABLE";
|
|
9
|
+
PlanUpdatedType["MEAL_ADJUSTED"] = "MEAL_ADJUSTED";
|
|
10
|
+
})(PlanUpdatedType || (exports.PlanUpdatedType = PlanUpdatedType = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,6 @@ export * from "./events/subscription-renewed";
|
|
|
45
45
|
export * from "./events/plan-created";
|
|
46
46
|
export * from "./events/plan-generate";
|
|
47
47
|
export * from "./events/plan-update";
|
|
48
|
-
export * from "./events/weekly-plan-updated";
|
|
49
48
|
export * from "./events/notification";
|
|
50
49
|
export * from "./events/medication-reminder";
|
|
51
50
|
export * from "./events/medication-reminder-updated";
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,6 @@ __exportStar(require("./events/subscription-renewed"), exports);
|
|
|
61
61
|
__exportStar(require("./events/plan-created"), exports);
|
|
62
62
|
__exportStar(require("./events/plan-generate"), exports);
|
|
63
63
|
__exportStar(require("./events/plan-update"), exports);
|
|
64
|
-
__exportStar(require("./events/weekly-plan-updated"), exports);
|
|
65
64
|
__exportStar(require("./events/notification"), exports);
|
|
66
65
|
__exportStar(require("./events/medication-reminder"), exports);
|
|
67
66
|
__exportStar(require("./events/medication-reminder-updated"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const plan_updated_1 = require("../events/plan-updated");
|
|
5
|
+
const topics_1 = require("../topics");
|
|
6
|
+
const plan_1 = require("../types/plan");
|
|
7
|
+
const assert = (condition, message) => {
|
|
8
|
+
if (!condition) {
|
|
9
|
+
throw new Error(message);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const commandEvent = {
|
|
13
|
+
topic: topics_1.Topics.PlanUpdate,
|
|
14
|
+
data: {
|
|
15
|
+
userId: "user-1",
|
|
16
|
+
trigger: plan_1.PlanUpdateTrigger.Routine,
|
|
17
|
+
target: plan_1.PlanUpdateTarget.NextWeek,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const planUpdatedEvent = {
|
|
21
|
+
topic: topics_1.Topics.PlanUpdated,
|
|
22
|
+
data: {
|
|
23
|
+
occurredAt: "2026-03-30T10:00:00.000Z",
|
|
24
|
+
userId: "user-1",
|
|
25
|
+
type: plan_updated_1.PlanUpdatedType.PLAN_UPDATED,
|
|
26
|
+
source: "dtx",
|
|
27
|
+
trigger: plan_1.PlanUpdateTrigger.Routine,
|
|
28
|
+
target: plan_1.PlanUpdateTarget.NextWeek,
|
|
29
|
+
changeLog: [],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const extendedCommandEvent = {
|
|
33
|
+
topic: topics_1.Topics.PlanUpdate,
|
|
34
|
+
data: {
|
|
35
|
+
userId: "user-2",
|
|
36
|
+
trigger: plan_1.PlanUpdateTrigger.UserRequest,
|
|
37
|
+
target: plan_1.PlanUpdateTarget.CurrentWeek,
|
|
38
|
+
guidelines: {
|
|
39
|
+
nutrition: "Lower dinner carbs",
|
|
40
|
+
},
|
|
41
|
+
clinicalContext: {
|
|
42
|
+
symptoms: [
|
|
43
|
+
{
|
|
44
|
+
name: "fatigue",
|
|
45
|
+
severity: plan_1.SymptomSeverity.MODERATE,
|
|
46
|
+
description: "Persistent afternoon fatigue",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
affectedModules: [plan_1.AffectedModule.NUTRITION, plan_1.AffectedModule.STEPS],
|
|
50
|
+
conversationId: "conv-123",
|
|
51
|
+
mealChanges: ["reduce rice at dinner"],
|
|
52
|
+
source: "ai-coach",
|
|
53
|
+
},
|
|
54
|
+
reason: "Patient requested a mid-week tweak",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
const roundTrippedExtendedEvent = JSON.parse(JSON.stringify(extendedCommandEvent));
|
|
58
|
+
assert(commandEvent.topic === topics_1.Topics.PlanUpdate, "Plan-update command topic must be plan-update");
|
|
59
|
+
assert(planUpdatedEvent.topic === topics_1.Topics.PlanUpdated, "Plan-updated event topic must be plan-updated");
|
|
60
|
+
assert(planUpdatedEvent.data.type === plan_updated_1.PlanUpdatedType.PLAN_UPDATED, "Plan-updated event type must carry canonical plan updated value");
|
|
61
|
+
assert(roundTrippedExtendedEvent.data.trigger === plan_1.PlanUpdateTrigger.UserRequest, "Round-trip should preserve new trigger value");
|
|
62
|
+
assert(!!roundTrippedExtendedEvent.data.clinicalContext, "Round-trip should preserve clinicalContext");
|
|
63
|
+
assert(((_a = roundTrippedExtendedEvent.data.clinicalContext) === null || _a === void 0 ? void 0 : _a.symptoms[0].severity) ===
|
|
64
|
+
plan_1.SymptomSeverity.MODERATE, "Round-trip should preserve symptom severity");
|
|
65
|
+
assert(!Object.prototype.hasOwnProperty.call(roundTrippedExtendedEvent.data, "clinical_context"), "Contract must keep payload keys in camelCase");
|
package/dist/topics.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare enum Topics {
|
|
|
31
31
|
SubscriptionRenewed = "subscription-renewed",
|
|
32
32
|
PlanCreated = "plan-created",
|
|
33
33
|
PlanGenerate = "plan-generate",
|
|
34
|
-
PlanUpdate = "plan-update",
|
|
35
34
|
WeeklyPlanUpdated = "weekly-plan-updated",
|
|
35
|
+
PlanUpdate = "plan-update",
|
|
36
36
|
Notification = "notification",
|
|
37
37
|
MedicationReminder = "medication-reminder",
|
|
38
38
|
MedicationReminderUpdated = "medication-reminder-updated",
|
package/dist/topics.js
CHANGED
|
@@ -35,8 +35,8 @@ var Topics;
|
|
|
35
35
|
Topics["SubscriptionRenewed"] = "subscription-renewed";
|
|
36
36
|
Topics["PlanCreated"] = "plan-created";
|
|
37
37
|
Topics["PlanGenerate"] = "plan-generate";
|
|
38
|
-
Topics["PlanUpdate"] = "plan-update";
|
|
39
38
|
Topics["WeeklyPlanUpdated"] = "weekly-plan-updated";
|
|
39
|
+
Topics["PlanUpdate"] = "plan-update";
|
|
40
40
|
Topics["Notification"] = "notification";
|
|
41
41
|
Topics["MedicationReminder"] = "medication-reminder";
|
|
42
42
|
Topics["MedicationReminderUpdated"] = "medication-reminder-updated";
|
package/dist/types/plan.d.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum PlanUpdateTrigger {
|
|
2
2
|
LabReport = "LabReport",
|
|
3
3
|
Symptom = "Symptom",
|
|
4
|
-
Routine = "Routine"
|
|
4
|
+
Routine = "Routine",
|
|
5
|
+
UserRequest = "UserRequest"
|
|
5
6
|
}
|
|
6
7
|
export declare enum PlanUpdateTarget {
|
|
7
8
|
NextWeek = "NextWeek",
|
|
8
9
|
CurrentWeek = "CurrentWeek"
|
|
9
10
|
}
|
|
11
|
+
export interface Guidelines {
|
|
12
|
+
exercise?: string;
|
|
13
|
+
nutrition?: string;
|
|
14
|
+
steps?: string;
|
|
15
|
+
glucose?: string;
|
|
16
|
+
supplement?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare enum AffectedModule {
|
|
19
|
+
NUTRITION = "NUTRITION",
|
|
20
|
+
EXERCISE = "EXERCISE",
|
|
21
|
+
STEPS = "STEPS",
|
|
22
|
+
GLUCOSE = "GLUCOSE",
|
|
23
|
+
SUPPLEMENT = "SUPPLEMENT"
|
|
24
|
+
}
|
|
25
|
+
export declare enum SymptomSeverity {
|
|
26
|
+
MILD = "MILD",
|
|
27
|
+
MODERATE = "MODERATE",
|
|
28
|
+
SEVERE = "SEVERE"
|
|
29
|
+
}
|
|
30
|
+
export interface ClinicalSymptom {
|
|
31
|
+
name: string;
|
|
32
|
+
severity: SymptomSeverity;
|
|
33
|
+
description?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ClinicalContext {
|
|
36
|
+
symptoms: ClinicalSymptom[];
|
|
37
|
+
affectedModules: AffectedModule[];
|
|
38
|
+
conversationId?: string;
|
|
39
|
+
mealChanges?: string[];
|
|
40
|
+
source?: string;
|
|
41
|
+
}
|
package/dist/types/plan.js
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlanUpdateTarget = exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
exports.SymptomSeverity = exports.AffectedModule = exports.PlanUpdateTarget = exports.PlanUpdateTrigger = void 0;
|
|
4
|
+
var PlanUpdateTrigger;
|
|
5
|
+
(function (PlanUpdateTrigger) {
|
|
6
|
+
PlanUpdateTrigger["LabReport"] = "LabReport";
|
|
7
|
+
PlanUpdateTrigger["Symptom"] = "Symptom";
|
|
8
|
+
PlanUpdateTrigger["Routine"] = "Routine";
|
|
9
|
+
PlanUpdateTrigger["UserRequest"] = "UserRequest";
|
|
10
|
+
})(PlanUpdateTrigger || (exports.PlanUpdateTrigger = PlanUpdateTrigger = {}));
|
|
10
11
|
var PlanUpdateTarget;
|
|
11
12
|
(function (PlanUpdateTarget) {
|
|
12
13
|
PlanUpdateTarget["NextWeek"] = "NextWeek";
|
|
13
14
|
PlanUpdateTarget["CurrentWeek"] = "CurrentWeek";
|
|
14
15
|
})(PlanUpdateTarget || (exports.PlanUpdateTarget = PlanUpdateTarget = {}));
|
|
16
|
+
var AffectedModule;
|
|
17
|
+
(function (AffectedModule) {
|
|
18
|
+
AffectedModule["NUTRITION"] = "NUTRITION";
|
|
19
|
+
AffectedModule["EXERCISE"] = "EXERCISE";
|
|
20
|
+
AffectedModule["STEPS"] = "STEPS";
|
|
21
|
+
AffectedModule["GLUCOSE"] = "GLUCOSE";
|
|
22
|
+
AffectedModule["SUPPLEMENT"] = "SUPPLEMENT";
|
|
23
|
+
})(AffectedModule || (exports.AffectedModule = AffectedModule = {}));
|
|
24
|
+
var SymptomSeverity;
|
|
25
|
+
(function (SymptomSeverity) {
|
|
26
|
+
SymptomSeverity["MILD"] = "MILD";
|
|
27
|
+
SymptomSeverity["MODERATE"] = "MODERATE";
|
|
28
|
+
SymptomSeverity["SEVERE"] = "SEVERE";
|
|
29
|
+
})(SymptomSeverity || (exports.SymptomSeverity = SymptomSeverity = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taphealth/kafka",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"clean": "del-cli ./dist/*",
|
|
24
24
|
"build": "pnpm clean && tsc",
|
|
25
|
+
"test:contracts": "ts-node ./src/tests/weekly-command-contract.test.ts",
|
|
25
26
|
"pub": "pnpm version patch --no-git-checks && pnpm build && pnpm publish --no-git-checks"
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Topics } from "../topics";
|
|
2
|
-
import { PlanUpdatedTrigger, PlanUpdateTarget } from "../types/plan";
|
|
3
|
-
export interface WeeklyPlanUpdatedEvent {
|
|
4
|
-
topic: Topics.WeeklyPlanUpdated;
|
|
5
|
-
data: {
|
|
6
|
-
userId: string;
|
|
7
|
-
guidelines?: Record<string, string>;
|
|
8
|
-
trigger: PlanUpdatedTrigger;
|
|
9
|
-
target?: PlanUpdateTarget;
|
|
10
|
-
};
|
|
11
|
-
}
|