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.
- 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.
- 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)
- 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.
- Follow-up result: Verified removal of core-js, node-fetch, undici did not impact tests/typecheck/build. Retained Vue CLI/Babel/coverage deps.
Scope
- In: TS/Vue app code, tests, configs, scripts; Python utilities if present.
@ -121,6 +123,8 @@ Acceptance
- [ ] Remove unused overloads/params; prefer narrower interfaces.
- [ ] Update re-exports; fix imports accordingly.
- [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
- [ ] ts-prune emits fewer/no unused export warnings.
@ -201,6 +205,7 @@ Next actions (clear, actionable)
5) Test suite consolidation
- [x] De-duplicate tests with .js and .ts counterparts (e.g., prefer TypeScript)
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
- [ ] 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')
return {
...mr,
@ -70,7 +70,7 @@ export function decodeIngredients(list: components['schemas']['Ingredient'][] |
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')
return {
...i,

View file

@ -1,7 +1,7 @@
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: {
kgs: 1,
kilograms: 1,
@ -124,8 +124,8 @@ export function getConversionFactor(unit: string): { unit: UnitKey | string; fac
return null
}
export type Quantity = { quantity: number; unit: string }
export type Total = { unit: string; quantity: number }
type Quantity = { quantity: number; unit: string }
type Total = { unit: string; quantity: number }
export function calculateTotals(quantityList: Quantity[]): Total[] {
const totals: Record<string, number> = {}