@usamir/healthy-meals-core 0.0.8 → 0.0.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/dist/src/bmr.js CHANGED
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateBMR = calculateBMR;
4
- exports.calculateTDEE = calculateTDEE;
3
+ exports.calculateTDEE = exports.calculateBMR = void 0;
5
4
  function calculateBMR(profile) {
6
5
  const { weightKg, heightCm, age, gender } = profile;
7
6
  return gender === 'male'
8
7
  ? 10 * weightKg + 6.25 * heightCm - 5 * age + 5
9
8
  : 10 * weightKg + 6.25 * heightCm - 5 * age - 161;
10
9
  }
10
+ exports.calculateBMR = calculateBMR;
11
11
  function calculateTDEE(profile) {
12
12
  return calculateBMR(profile) * profile.activityLevel;
13
13
  }
14
+ exports.calculateTDEE = calculateTDEE;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDailyMealPlan = generateDailyMealPlan;
3
+ exports.generateDailyMealPlan = void 0;
4
4
  const foodConversion_1 = require("./foodConversion");
5
5
  // Mock food data - in a real app, this would come from Open Food Facts search
6
6
  const mockFoods = {
@@ -127,9 +127,9 @@ function calculateDailyNeeds(profile) {
127
127
  dailyCalories += 500;
128
128
  }
129
129
  return {
130
- calories: Math.round(Math.max(dailyCalories, 1200)), // Minimum 1200 calories
131
- protein: Math.round(Math.max(dailyCalories * 0.3 / 4, 50)), // Minimum 50g protein
132
- carbs: Math.round(Math.max(dailyCalories * 0.4 / 4, 100)), // Minimum 100g carbs
130
+ calories: Math.round(Math.max(dailyCalories, 1200)),
131
+ protein: Math.round(Math.max(dailyCalories * 0.3 / 4, 50)),
132
+ carbs: Math.round(Math.max(dailyCalories * 0.4 / 4, 100)),
133
133
  fat: Math.round(Math.max(dailyCalories * 0.3 / 9, 30)) // Minimum 30g fat
134
134
  };
135
135
  }
@@ -208,3 +208,4 @@ function generateDailyMealPlan(profile, userId) {
208
208
  updatedAt: new Date()
209
209
  };
210
210
  }
211
+ exports.generateDailyMealPlan = generateDailyMealPlan;
@@ -1,12 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertFoodItemToIngredient = convertFoodItemToIngredient;
4
- exports.calculateTotalNutrition = calculateTotalNutrition;
5
- exports.createMealFromFoodItems = createMealFromFoodItems;
6
- exports.getNutritionDensityScore = getNutritionDensityScore;
7
- exports.checkDietaryRestrictions = checkDietaryRestrictions;
8
- exports.getRecommendedServingSize = getRecommendedServingSize;
9
- exports.filterFoodsByHealthGoals = filterFoodsByHealthGoals;
3
+ exports.filterFoodsByHealthGoals = exports.getRecommendedServingSize = exports.checkDietaryRestrictions = exports.getNutritionDensityScore = exports.createMealFromFoodItems = exports.calculateTotalNutrition = exports.convertFoodItemToIngredient = void 0;
10
4
  /**
11
5
  * Convert Open Food Facts item to Ingredient for meal planning
12
6
  */
@@ -27,6 +21,7 @@ function convertFoodItemToIngredient(foodItem, amount = 100, unit = 'g') {
27
21
  sodium: Math.round(((foodItem.nutritionPer100g?.sodium || 0) * multiplier * 10)) / 10 || 0,
28
22
  };
29
23
  }
24
+ exports.convertFoodItemToIngredient = convertFoodItemToIngredient;
30
25
  /**
31
26
  * Calculate total nutrition for a list of ingredients
32
27
  */
@@ -41,6 +36,7 @@ function calculateTotalNutrition(ingredients) {
41
36
  sodium: Math.round((total.sodium + (ingredient.sodium || 0)) * 10) / 10,
42
37
  }), { calories: 0, protein: 0, carbs: 0, fat: 0, fiber: 0, sugar: 0, sodium: 0 });
43
38
  }
39
+ exports.calculateTotalNutrition = calculateTotalNutrition;
44
40
  /**
45
41
  * Create a meal from selected food items
46
42
  */
@@ -71,6 +67,7 @@ function createMealFromFoodItems(name, type, foodItems) {
71
67
  updatedAt: new Date(),
72
68
  };
73
69
  }
70
+ exports.createMealFromFoodItems = createMealFromFoodItems;
74
71
  /**
75
72
  * Get nutrition density score (protein per calorie ratio)
76
73
  */
@@ -79,6 +76,7 @@ function getNutritionDensityScore(foodItem) {
79
76
  return 0;
80
77
  return foodItem.nutritionPer100g.protein / foodItem.nutritionPer100g.calories;
81
78
  }
79
+ exports.getNutritionDensityScore = getNutritionDensityScore;
82
80
  /**
83
81
  * Check if food item meets dietary restrictions
84
82
  */
@@ -126,6 +124,7 @@ function checkDietaryRestrictions(foodItem, restrictions) {
126
124
  violations
127
125
  };
128
126
  }
127
+ exports.checkDietaryRestrictions = checkDietaryRestrictions;
129
128
  /**
130
129
  * Get recommended serving size based on meal type and nutrition goals
131
130
  */
@@ -147,9 +146,9 @@ function getRecommendedServingSize(foodItem, mealType, targetCalories) {
147
146
  }
148
147
  // Default serving sizes by meal type
149
148
  const defaultServings = {
150
- breakfast: 150, // g
151
- lunch: 200, // g
152
- dinner: 200, // g
149
+ breakfast: 150,
150
+ lunch: 200,
151
+ dinner: 200,
153
152
  snack: 50 // g
154
153
  };
155
154
  return {
@@ -157,6 +156,7 @@ function getRecommendedServingSize(foodItem, mealType, targetCalories) {
157
156
  unit: 'g'
158
157
  };
159
158
  }
159
+ exports.getRecommendedServingSize = getRecommendedServingSize;
160
160
  /**
161
161
  * Filter foods by health goals
162
162
  */
@@ -197,3 +197,4 @@ function filterFoodsByHealthGoals(foods, healthGoals) {
197
197
  return true;
198
198
  });
199
199
  }
200
+ exports.filterFoodsByHealthGoals = filterFoodsByHealthGoals;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDailyPlan = generateDailyPlan;
3
+ exports.generateDailyPlan = void 0;
4
4
  const bmr_1 = require("./bmr");
5
5
  const rules_1 = require("./rules");
6
6
  function generateDailyPlan(profile, recipes) {
@@ -21,3 +21,4 @@ function generateDailyPlan(profile, recipes) {
21
21
  meals
22
22
  };
23
23
  }
24
+ exports.generateDailyPlan = generateDailyPlan;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDailyMealPlanWithRecipes = generateDailyMealPlanWithRecipes;
4
- exports.generateWeeklyMealPlanWithRecipes = generateWeeklyMealPlanWithRecipes;
5
- exports.getRecipeForMeal = getRecipeForMeal;
3
+ exports.getRecipeForMeal = exports.generateWeeklyMealPlanWithRecipes = exports.generateDailyMealPlanWithRecipes = void 0;
6
4
  const recipeService_1 = require("./recipeService");
7
5
  function calculateDailyNeeds(profile) {
8
6
  const age = profile.age || 30;
@@ -152,6 +150,7 @@ function generateDailyMealPlanWithRecipes(profile, userId) {
152
150
  updatedAt: new Date()
153
151
  };
154
152
  }
153
+ exports.generateDailyMealPlanWithRecipes = generateDailyMealPlanWithRecipes;
155
154
  /**
156
155
  * Generate a weekly meal plan using recipes from the recipe database
157
156
  * Each day will have 4 meals with complete ingredients and cooking instructions
@@ -238,6 +237,7 @@ function generateWeeklyMealPlanWithRecipes(profile, userId) {
238
237
  updatedAt: new Date()
239
238
  };
240
239
  }
240
+ exports.generateWeeklyMealPlanWithRecipes = generateWeeklyMealPlanWithRecipes;
241
241
  /**
242
242
  * Get recipe details for a meal in a meal plan
243
243
  * This allows you to retrieve the full recipe with instructions for any meal
@@ -252,3 +252,4 @@ function getRecipeForMeal(meal) {
252
252
  const cleanName = meal.name.replace(/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday) - /, '');
253
253
  return recipeService_1.recipeService.searchRecipes(cleanName)[0];
254
254
  }
255
+ exports.getRecipeForMeal = getRecipeForMeal;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterCholesterol = filterCholesterol;
3
+ exports.filterCholesterol = void 0;
4
4
  function filterCholesterol(recipes) {
5
5
  return recipes.filter(r => r.tags.includes('cholesterol'));
6
6
  }
7
+ exports.filterCholesterol = filterCholesterol;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterDiabetes = filterDiabetes;
3
+ exports.filterDiabetes = void 0;
4
4
  function filterDiabetes(recipes) {
5
5
  return recipes.filter(r => r.tags.includes('diabetes'));
6
6
  }
7
+ exports.filterDiabetes = filterDiabetes;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterFattyLiver = filterFattyLiver;
3
+ exports.filterFattyLiver = void 0;
4
4
  function filterFattyLiver(recipes) {
5
5
  return recipes.filter(r => r.tags.includes('fatty_liver'));
6
6
  }
7
+ exports.filterFattyLiver = filterFattyLiver;
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.applyHealthRules = applyHealthRules;
17
+ exports.applyHealthRules = void 0;
18
18
  const cholesterol_1 = require("./cholesterol");
19
19
  const triglycerides_1 = require("./triglycerides");
20
20
  const fattyLiver_1 = require("./fattyLiver");
@@ -39,6 +39,7 @@ function applyHealthRules(recipes, conditions) {
39
39
  }
40
40
  return result;
41
41
  }
42
+ exports.applyHealthRules = applyHealthRules;
42
43
  __exportStar(require("./cholesterol"), exports);
43
44
  __exportStar(require("./triglycerides"), exports);
44
45
  __exportStar(require("./fattyLiver"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterLowCarb = filterLowCarb;
3
+ exports.filterLowCarb = void 0;
4
4
  function filterLowCarb(recipes) {
5
5
  return recipes.filter(r => r.tags.includes('low_carb'));
6
6
  }
7
+ exports.filterLowCarb = filterLowCarb;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterTriglycerides = filterTriglycerides;
3
+ exports.filterTriglycerides = void 0;
4
4
  function filterTriglycerides(recipes) {
5
5
  return recipes.filter(r => r.tags.includes('triglycerides'));
6
6
  }
7
+ exports.filterTriglycerides = filterTriglycerides;
@@ -1,14 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shuffleArray = shuffleArray;
4
- exports.preventConsecutiveRepeats = preventConsecutiveRepeats;
5
- exports.ensureMealVariety = ensureMealVariety;
6
- exports.calculateMealDiversity = calculateMealDiversity;
7
- exports.getMealCategory = getMealCategory;
8
- exports.calculateCategoryDiversity = calculateCategoryDiversity;
9
- exports.hasConsecutiveRepeats = hasConsecutiveRepeats;
10
- exports.scoreMealPlan = scoreMealPlan;
11
- exports.selectDiverseMeals = selectDiverseMeals;
3
+ exports.selectDiverseMeals = exports.scoreMealPlan = exports.hasConsecutiveRepeats = exports.calculateCategoryDiversity = exports.getMealCategory = exports.calculateMealDiversity = exports.ensureMealVariety = exports.preventConsecutiveRepeats = exports.shuffleArray = void 0;
12
4
  function shuffleArray(array) {
13
5
  const shuffled = [...array];
14
6
  for (let i = shuffled.length - 1; i > 0; i--) {
@@ -17,6 +9,7 @@ function shuffleArray(array) {
17
9
  }
18
10
  return shuffled;
19
11
  }
12
+ exports.shuffleArray = shuffleArray;
20
13
  function preventConsecutiveRepeats(meals) {
21
14
  const result = [];
22
15
  const used = new Set();
@@ -29,6 +22,7 @@ function preventConsecutiveRepeats(meals) {
29
22
  }
30
23
  return result;
31
24
  }
25
+ exports.preventConsecutiveRepeats = preventConsecutiveRepeats;
32
26
  function ensureMealVariety(meals, minVariety = 3) {
33
27
  const mealCounts = new Map();
34
28
  meals.forEach(meal => {
@@ -50,10 +44,12 @@ function ensureMealVariety(meals, minVariety = 3) {
50
44
  return previousOccurrences < minVariety;
51
45
  });
52
46
  }
47
+ exports.ensureMealVariety = ensureMealVariety;
53
48
  function calculateMealDiversity(meals) {
54
49
  const uniqueMeals = new Set(meals.map(m => m.id));
55
50
  return uniqueMeals.size / meals.length;
56
51
  }
52
+ exports.calculateMealDiversity = calculateMealDiversity;
57
53
  function getMealCategory(recipe) {
58
54
  if (recipe.protein > 30)
59
55
  return 'high-protein';
@@ -63,11 +59,13 @@ function getMealCategory(recipe) {
63
59
  return 'high-fat';
64
60
  return 'balanced';
65
61
  }
62
+ exports.getMealCategory = getMealCategory;
66
63
  function calculateCategoryDiversity(meals) {
67
64
  const categories = meals.map(m => getMealCategory(m));
68
65
  const uniqueCategories = new Set(categories);
69
66
  return uniqueCategories.size / 4;
70
67
  }
68
+ exports.calculateCategoryDiversity = calculateCategoryDiversity;
71
69
  function hasConsecutiveRepeats(meals) {
72
70
  for (let i = 1; i < meals.length; i++) {
73
71
  if (meals[i].id === meals[i - 1].id) {
@@ -76,6 +74,7 @@ function hasConsecutiveRepeats(meals) {
76
74
  }
77
75
  return false;
78
76
  }
77
+ exports.hasConsecutiveRepeats = hasConsecutiveRepeats;
79
78
  function scoreMealPlan(meals) {
80
79
  const diversity = calculateMealDiversity(meals);
81
80
  const categoryDiversity = calculateCategoryDiversity(meals);
@@ -100,6 +99,7 @@ function scoreMealPlan(meals) {
100
99
  overallScore
101
100
  };
102
101
  }
102
+ exports.scoreMealPlan = scoreMealPlan;
103
103
  function selectDiverseMeals(availableRecipes, targetCalories, previousMeals = []) {
104
104
  const shuffled = shuffleArray([...availableRecipes]);
105
105
  const recentMealIds = new Set(previousMeals.slice(-3).map(m => m.id));
@@ -127,3 +127,4 @@ function selectDiverseMeals(availableRecipes, targetCalories, previousMeals = []
127
127
  }
128
128
  return selected;
129
129
  }
130
+ exports.selectDiverseMeals = selectDiverseMeals;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateWeeklyMealPlan = generateWeeklyMealPlan;
3
+ exports.generateWeeklyMealPlan = void 0;
4
4
  const foodConversion_1 = require("./foodConversion");
5
5
  // Extended mock food data for weekly variety
6
6
  const mockFoods = {
@@ -485,3 +485,4 @@ function generateWeeklyMealPlan(profile, userId) {
485
485
  updatedAt: new Date()
486
486
  };
487
487
  }
488
+ exports.generateWeeklyMealPlan = generateWeeklyMealPlan;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateWeeklyPlan = generateWeeklyPlan;
3
+ exports.generateWeeklyPlan = void 0;
4
4
  const bmr_1 = require("./bmr");
5
5
  const rules_1 = require("./rules");
6
6
  const variety_1 = require("./variety");
@@ -29,3 +29,4 @@ function generateWeeklyPlan(profile, recipes) {
29
29
  diversityScore: weekScore.overallScore
30
30
  };
31
31
  }
32
+ exports.generateWeeklyPlan = generateWeeklyPlan;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usamir/healthy-meals-core",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {