pruning #3

Merged
jacob merged 11 commits from pruning into master 2025-10-25 02:18:30 +00:00
3 changed files with 13 additions and 8 deletions
Showing only changes of commit aebfc50e17 - Show all commits

View file

@ -42,10 +42,12 @@ Status update (2025-10-21)
- Reduced nullability in public SDK APIs where safe: getRecipe/getMeal/markMealConsumed/getCurrentShoppingList now return non-null and throw on errors; updated call sites accordingly. - Reduced nullability in public SDK APIs where safe: getRecipe/getMeal/markMealConsumed/getCurrentShoppingList now return non-null and throw on errors; updated call sites accordingly.
- Domain decoders now return non-null and throw on invalid input (decodeRecipe/decodeMeal/decodeMealRecipe/decodeIngredient/decodeShoppingListItem/decodeShoppingList); list decoders return arrays. - Domain decoders now return non-null and throw on invalid input (decodeRecipe/decodeMeal/decodeMealRecipe/decodeIngredient/decodeShoppingListItem/decodeShoppingList); list decoders return arrays.
- Lint/typecheck/vue-tsc/tests: all PASS after decoder contract tightening. - Lint/typecheck/vue-tsc/tests: all PASS after decoder contract tightening.
- Aggressive dependency cleanup: removed node-fetch and undici (unused in Node 18+), removed core-js (build and tests still PASS under current browserslist targets), and dropped Vite types from tsconfig. All checks and build PASS post-removal.
Latest analysis artifacts (2025-10-21) Latest analysis artifacts (2025-10-21)
- ts-prune (current): saved to ts-prune.current.txt; notable false-positives include dateformats.ago and units functions used inside SFCs. - ts-prune (current): saved to ts-prune.current.txt; notable false-positives include dateformats.ago and units functions used inside SFCs.
- depcheck (current): saved to depcheck.current.json; flags core-js and several dev deps as unused. These are likely required by Vue CLI/babel/coverage tooling; defer removal pending deeper validation. - depcheck (current): saved to depcheck.current.json; flags core-js and several dev deps as unused. These are likely required by Vue CLI/babel/coverage tooling; defer removal pending deeper validation.
- Follow-up result: Verified removal of core-js, node-fetch, undici did not impact tests/typecheck/build. Retained Vue CLI/Babel/coverage deps.
Scope Scope
- In: TS/Vue app code, tests, configs, scripts; Python utilities if present. - In: TS/Vue app code, tests, configs, scripts; Python utilities if present.
@ -121,6 +123,8 @@ Acceptance
- [ ] Remove unused overloads/params; prefer narrower interfaces. - [ ] Remove unused overloads/params; prefer narrower interfaces.
- [ ] Update re-exports; fix imports accordingly. - [ ] Update re-exports; fix imports accordingly.
- [x] Reduce unnecessary null/undefined on public SDK returns (getRecipe/getMeal/markMealConsumed/getCurrentShoppingList). - [x] Reduce unnecessary null/undefined on public SDK returns (getRecipe/getMeal/markMealConsumed/getCurrentShoppingList).
- [x] Narrowed visibility of internal helpers/types (listPersons made internal; PurchaseExisting/PurchaseRefs internal, union type exported).
- [x] Hide internal-only helpers/types: decoders.decodeMealRecipe/decodeShoppingListItem made module-private; units.UnitKey/equivalentUnits/Quantity/Total are no longer exported.
Acceptance Acceptance
- [ ] ts-prune emits fewer/no unused export warnings. - [ ] ts-prune emits fewer/no unused export warnings.
@ -201,6 +205,7 @@ Next actions (clear, actionable)
5) Test suite consolidation 5) Test suite consolidation
- [x] De-duplicate tests with .js and .ts counterparts (e.g., prefer TypeScript) - [x] De-duplicate tests with .js and .ts counterparts (e.g., prefer TypeScript)
6) Dependency cleanup 6) Dependency cleanup
- [ ] Remove unused npm deps/scripts per depcheck; npm prune; verify build (defer core-js and Vue CLI toolchain deps) - [x] Remove unused npm deps (depcheck) and scripts (removed core-js, node-fetch, undici). Verified tests/typecheck/build PASS.
7) Final verification 7) Final verification
- [ ] Re-run cloc/tests/build; record deltas vs. baseline; sanity test user flows - [ ] Re-run cloc/tests/build; record deltas vs. baseline; sanity test user flows
- [x] Interim verification after dep cleanup: tests/typecheck/vue-tsc/lint/build PASS

View file

@ -51,7 +51,7 @@ export function decodeMeal(m: MealOut | null | undefined): Meal {
} }
} }
export function decodeMealRecipe(mr: components['schemas']['MealRecipe-Output'] | null | undefined): MealRecipe { function decodeMealRecipe(mr: components['schemas']['MealRecipe-Output'] | null | undefined): MealRecipe {
if (!mr) throw new Error('Invalid meal recipe payload') if (!mr) throw new Error('Invalid meal recipe payload')
return { return {
...mr, ...mr,
@ -70,7 +70,7 @@ export function decodeIngredients(list: components['schemas']['Ingredient'][] |
return list.map((i) => decodeIngredient(i)) return list.map((i) => decodeIngredient(i))
} }
export function decodeShoppingListItem(i: components['schemas']['ShoppingListItem'] | null | undefined): ShoppingListItem { function decodeShoppingListItem(i: components['schemas']['ShoppingListItem'] | null | undefined): ShoppingListItem {
if (!i) throw new Error('Invalid shopping list item payload') if (!i) throw new Error('Invalid shopping list item payload')
return { return {
...i, ...i,

View file

@ -1,7 +1,7 @@
const UNIT_KEYS_ARRAY: readonly ['kg', 'litres', 'items'] = ['kg', 'litres', 'items'] const UNIT_KEYS_ARRAY: readonly ['kg', 'litres', 'items'] = ['kg', 'litres', 'items']
export type UnitKey = typeof UNIT_KEYS_ARRAY[number] type UnitKey = typeof UNIT_KEYS_ARRAY[number]
export const equivalentUnits: Record<UnitKey, Record<string, number>> = { const equivalentUnits: Record<UnitKey, Record<string, number>> = {
kg: { kg: {
kgs: 1, kgs: 1,
kilograms: 1, kilograms: 1,
@ -124,8 +124,8 @@ export function getConversionFactor(unit: string): { unit: UnitKey | string; fac
return null return null
} }
export type Quantity = { quantity: number; unit: string } type Quantity = { quantity: number; unit: string }
export type Total = { unit: string; quantity: number } type Total = { unit: string; quantity: number }
export function calculateTotals(quantityList: Quantity[]): Total[] { export function calculateTotals(quantityList: Quantity[]): Total[] {
const totals: Record<string, number> = {} const totals: Record<string, number> = {}