From aebfc50e17e30fca0bf584825a1748939c97ac63 Mon Sep 17 00:00:00 2001 From: jableader Date: Tue, 21 Oct 2025 20:01:26 +1100 Subject: [PATCH] Hide internal-only helpers/types: decoders.decodeMealRecipe/decodeShoppingListItem made module-private; units.UnitKey/equivalentUnits/Quantity/Total are no longer exported. --- code-removal-and-consolodation-spec.md | 9 +++++++-- src/domain/decoders.ts | 4 ++-- src/units.ts | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/code-removal-and-consolodation-spec.md b/code-removal-and-consolodation-spec.md index dd042b3..afc1ee9 100644 --- a/code-removal-and-consolodation-spec.md +++ b/code-removal-and-consolodation-spec.md @@ -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 \ No newline at end of file + - [ ] 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 \ No newline at end of file diff --git a/src/domain/decoders.ts b/src/domain/decoders.ts index 31afcdd..a3ac419 100644 --- a/src/domain/decoders.ts +++ b/src/domain/decoders.ts @@ -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, diff --git a/src/units.ts b/src/units.ts index c7edf67..144c2d0 100644 --- a/src/units.ts +++ b/src/units.ts @@ -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> = { +const equivalentUnits: Record> = { 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 = {}