=== Session change log === Session started: 2026-09-02 Rule: Before changing any file that is not a .md or .txt file, write the current timestamp followed by the exact diff here first, then make the change. (no file changes made yet in this session) [2026-09-02 20:34:48] DELETE dead files per DEAD_CODE_REPORT.md §1 (28 files): Removed in packages/db_helper_sqlite/src/helper_methods/: - banner.ts (entire file — legacy duplicate, never imported) - complaint.ts (entire file — legacy duplicate, never imported) - const.ts (entire file — legacy duplicate, never imported) - coupon.ts (entire file — legacy duplicate, never imported) - order.ts (entire file — legacy duplicate, never imported) - product.ts (entire file — legacy duplicate, never imported) - slots.ts (entire file — legacy duplicate, never imported) - staff-user.ts (entire file — legacy duplicate, never imported) - store.ts (entire file — legacy duplicate, never imported) - user.ts (entire file — legacy duplicate, never imported) - vendor-snippets.ts (entire file — legacy duplicate, never imported) Removed in packages/db_helper_postgres/src/helper_methods/: (same 11 files as above) - banner.ts, complaint.ts, const.ts, coupon.ts, order.ts, product.ts, slots.ts, staff-user.ts, store.ts, user.ts, vendor-snippets.ts (entire files — legacy duplicates, never imported) Removed in both packages (db_helper_sqlite + db_helper_postgres): - src/user-apis/tags.ts (entire file — imported by no one) - src/common-apis/utils.ts (entire file — imported by no one; formatDate/generateCode/calculateDiscount unreferenced) - src/db/types.ts (entire file — imported by no one) Kept: helper_methods/upload-url.ts (alive — re-exported by index.ts, used by backend). Command: rm [2026-09-02 20:38:02] COMPLETED deletion of 28 dead files (DEAD_CODE_REPORT.md §1). Verification: - grep for 'helper_methods|user-apis/tags|common-apis/utils|db/types' across both packages + apps/backend: only remaining match is the live import of helper_methods/upload-url.ts in both index.ts files. - tsc --noEmit on both packages reports pre-existing errors only (in untouched live files: src/db/seed.ts, src/user-apis/order.ts, src/user-apis/product.ts, src/admin-apis/complaint.ts, src/admin-apis/product.ts). No errors reference any deleted module. [2026-09-02 20:45:45] DELETE dead exported methods per DEAD_CODE_REPORT.md §2a (8 symbols, both packages). === packages/db_helper_sqlite/src/admin-apis/product.ts === - removed getAllUnits (lines 650-657): export async function getAllUnits(): Promise { const allUnits = await db.query.units.findMany({ orderBy: units.shortNotation, }) return allUnits.map(mapUnit) } - removed addProductToGroup (lines 1032-1034): export async function addProductToGroup(groupId: number, productId: number): Promise { await db.insert(productGroupMembership).values({ groupId, productId }) } - removed removeProductFromGroup (lines 1036-1042): export async function removeProductFromGroup(groupId: number, productId: number): Promise { await db.delete(productGroupMembership) .where(and( eq(productGroupMembership.groupId, groupId), eq(productGroupMembership.productId, productId) )) } === packages/db_helper_postgres/src/admin-apis/product.ts === - identical removals (getAllUnits at 232-239, addProductToGroup at 496-498, removeProductFromGroup at 500-506) === packages/db_helper_sqlite/src/admin-apis/vendor-snippets.ts === - removed getOrderItemsByOrderIds (lines 196-209): export async function getOrderItemsByOrderIds(orderIds: number[]) { return await db.query.orderItems.findMany({ where: inArray(orderItems.orderId, orderIds), with: { sku: { with: { product: true, features: true } } }, }) } - removed getOrderStatusByOrderIds (lines 210-214): export async function getOrderStatusByOrderIds(orderIds: number[]) { return await db.query.orderStatus.findMany({ where: inArray(orderStatus.orderId, orderIds), }) } === packages/db_helper_postgres/src/admin-apis/vendor-snippets.ts === - removed getOrderItemsByOrderIds (lines 188-200) — same signature; body joins product.unit instead of sku: export async function getOrderItemsByOrderIds(orderIds: number[]) { return await db.query.orderItems.findMany({ where: inArray(orderItems.orderId, orderIds), with: { product: { with: { unit: true } } }, }) } - removed getOrderStatusByOrderIds (lines 201-205) — identical to sqlite === packages/db_helper_sqlite/src/admin-apis/staff-user.ts + packages/db_helper_postgres/src/admin-apis/staff-user.ts === - removed updateUserSuspensionStatus (lines 101-109 in both) — duplicate of live upsertUserSuspension: export async function updateUserSuspensionStatus(userId: number, isSuspended: boolean): Promise { await db .insert(userDetails) .values({ userId, isSuspended }) .onConflictDoUpdate({ target: userDetails.userId, set: { isSuspended }, }) } === packages/db_helper_sqlite/src/user-apis/user.ts + packages/db_helper_postgres/src/user-apis/user.ts === - removed getUserWithCreds (lines 15-28 in both): export async function getUserWithCreds(userId: number) { const result = await db .select() .from(users) .leftJoin(userCreds, eq(users.id, userCreds.userId)) .where(eq(users.id, userId)) .limit(1) if (result.length === 0) return null return { user: result[0].users, creds: result[0].user_creds } } === packages/db_helper_sqlite/src/user-apis/auth.ts + packages/db_helper_postgres/src/user-apis/auth.ts === - removed createUserWithCreds (lines 145-168 in both): export async function createUserWithCreds(input: { name; email; mobile; hashedPassword }) { return db.transaction(async (tx) => { ...insert user, insert userCreds, return user... }) } === packages/db_helper_sqlite/index.ts (export list cleanup) === - removed line: getAllUnits, - removed lines: addProductToGroup, removeProductFromGroup, - removed lines: getOrderItemsByOrderIds, getOrderStatusByOrderIds, - removed line: updateUserSuspensionStatus, - removed line: getUserWithCreds as getUserWithCreds, - removed line: createUserWithCreds as createUserAuthWithCreds, === packages/db_helper_postgres/index.ts (export list cleanup) === - same 8 export-line removals as sqlite index.ts === apps/backend/src/sqliteImporter.ts (re-export chain cleanup) === - removed line: getAllUnits, - removed lines: addProductToGroup, removeProductFromGroup, - removed lines: getOrderItemsByOrderIds, getOrderStatusByOrderIds, - removed line: updateUserSuspensionStatus, - removed line: createUserAuthWithCreds, - removed line: getUserWithCreds, Note: apps/backend/src/dbService.ts uses `export * from '@/src/sqliteImporter'` — no per-symbol change needed there. Any imports left unused by these deletions (e.g. productGroupMembership, inArray, userCreds) will be removed in a follow-up entry if tsc/grep confirms they are unused. [2026-09-02 20:49:23] FOLLOW-UP: remove imports/orphans left unused by §2a deletions. === packages/db_helper_sqlite/src/admin-apis/product.ts === - removed now-unused local type + mapper (only consumer was deleted getAllUnits): line 103: type UnitRow = InferSelectModel line 117: const mapUnit = (unit: UnitRow): AdminUnit => ({ id: unit.id, shortNotation: unit.shortNotation, fullName: unit.fullName, }) (postgres product.ts keeps mapUnit — still used there at lines 111, 142) === packages/db_helper_sqlite/src/user-apis/user.ts === - import line 2: removed 'userCreds' from import { notifCreds, unloggedUserTokens, userCreds, userDetails, users } from '../db/schema' === packages/db_helper_postgres/src/user-apis/user.ts === - same import fix as sqlite user.ts [2026-09-02 20:51:30] COMPLETED §2a deletion (8 dead exported methods, both packages + re-export chains). Removed: getAllUnits, addProductToGroup, removeProductFromGroup, getOrderItemsByOrderIds, getOrderStatusByOrderIds, updateUserSuspensionStatus, getUserWithCreds, createUserWithCreds (+ orphaned mapUnit/UnitRow in sqlite product.ts, orphaned userCreds imports in both user.ts). Verification: - grep across packages + apps: zero live references remain (only commented lines in postgresImporter.ts). - tsc --noEmit: sqlite = 4 errors (same as pre-change baseline), postgres = 40 errors (all pre-existing drizzle inference mismatches in untouched files), backend = 17 errors (all pre-existing, in untouched files). No error references any deleted symbol. [2026-09-02 20:54:32] DELETE §2b/§2c dead exports + PARITY RENAME + RESTORE two methods for future use. --- DELETIONS, packages/db_helper_sqlite/src/admin-apis/product.ts --- - removed createSpecialDealsForSku (lines 1124-1145): inserts specialDeals rows keyed by skuId, returns mapped AdminSpecialDeal[] - removed updateSkuDeals (lines 1147-1241): diff-based sync of specialDeals for a skuId (add/remove/update validTill) - removed mergeSkus (lines 1243-1366, end of file): merges fromSkuId into toSkuId across orderItems, specialDeals, cartItems, couponApplicableProducts, JSON skuIds columns (deliverySlotInfo, homeBanners, coupons, reservedCoupons, vendorSnippets), keyValStore popularItems, then deletes skuFeatures + sku + orphaned product --- DELETIONS, packages/db_helper_postgres/src/admin-apis/product.ts --- - removed toggleProductOutOfStock (lines 181-203): flips productInfo.isOutOfStock - removed createSpecialDealsForProduct (lines 677-698): postgres counterpart of createSpecialDealsForSku (keyed by productId) - removed updateProductDeals (lines 700-775): postgres counterpart of updateSkuDeals --- DELETION, packages/db_helper_postgres/src/lib/automated-jobs.ts --- - removed toggleFlashDeliveryForItems (lines 10-16): bulk productInfo.isFlashAvailable update - import line 2: removed 'productInfo' from import { productInfo, keyValStore } from '../db/schema' - import line 3: removed 'inArray' from import { inArray, eq } from 'drizzle-orm' --- EXPORT LIST, packages/db_helper_sqlite/index.ts --- - removed lines: createSpecialDealsForSku, updateSkuDeals, mergeSkus, --- EXPORT LIST, packages/db_helper_postgres/index.ts --- - removed lines: createSpecialDealsForProduct, updateProductDeals, toggleProductOutOfStock, - removed line: toggleFlashDeliveryForItems, --- EXPORT LIST, apps/backend/src/sqliteImporter.ts --- - removed lines: createSpecialDealsForSku, updateSkuDeals, mergeSkus, --- PARITY RENAME, packages/db_helper_postgres/src/user-apis/product.ts --- - renamed getSuspendedProductIds -> getSuspendedSkuIds (backend calls getSuspendedSkuIds; sqlite exports that name). NOTE: implementation unchanged (queries productInfo.isSuspended) — postgres schema has no sku/marketStats model, so this is the closest postgres equivalent of the sqlite query on productMarketStats.skuId. - packages/db_helper_postgres/index.ts: export line getSuspendedProductIds, -> getSuspendedSkuIds, --- RESTORE (user request: needed in future), both packages --- packages/db_helper_sqlite/src/user-apis/user.ts + packages/db_helper_postgres/src/user-apis/user.ts: - re-added getUserWithCreds: export async function getUserWithCreds(userId: number) { const result = await db .select() .from(users) .leftJoin(userCreds, eq(users.id, userCreds.userId)) .where(eq(users.id, userId)) .limit(1) if (result.length === 0) return null return { user: result[0].users, creds: result[0].user_creds, } } - re-added 'userCreds' to the schema import line in both files. packages/db_helper_sqlite/src/user-apis/auth.ts + packages/db_helper_postgres/src/user-apis/auth.ts: - re-added createUserWithCreds: export async function createUserWithCreds(input: { name: string email: string mobile: string hashedPassword: string }) { return db.transaction(async (tx) => { const [user] = await tx.insert(users).values({ name: input.name, email: input.email, mobile: input.mobile, }).returning() await tx.insert(userCreds).values({ userId: user.id, userPassword: input.hashedPassword, }) return user }) } packages/db_helper_sqlite/index.ts + packages/db_helper_postgres/index.ts: - re-added export lines: createUserWithCreds as createUserAuthWithCreds, (user auth block) getUserWithCreds as getUserWithCreds, (user profile block) apps/backend/src/sqliteImporter.ts: - re-added re-export lines: createUserAuthWithCreds, and getUserWithCreds, [2026-09-02 20:58:19] FOLLOW-UP: remove orphaned CreateSpecialDealInput (only consumers were the deleted deal functions; zero usages repo-wide). === packages/db_helper_sqlite/src/admin-apis/product.ts === - removed (line ~1118): export interface CreateSpecialDealInput { quantity: number price: number validTill: string | Date } === packages/db_helper_postgres/src/admin-apis/product.ts === - removed identical interface (line ~647) [2026-09-02 20:59:28] COMPLETED §2b/§2c deletions + parity rename + restoration of createUserWithCreds/getUserWithCreds. Verification: - grep: zero references to createSpecialDealsForSku, updateSkuDeals, mergeSkus, createSpecialDealsForProduct, updateProductDeals, toggleProductOutOfStock, toggleFlashDeliveryForItems, getSuspendedProductIds (only commented postgresImporter.ts lines excluded from check). - Restored methods present in both packages' src + index.ts + backend sqliteImporter.ts. - Postgres now exports getSuspendedSkuIds (renamed from getSuspendedProductIds) matching sqlite/backend usage. - tsc --noEmit baselines unchanged: sqlite 4, postgres 40, backend 17 errors — all pre-existing, none reference touched symbols. [2026-09-02 21:01:52] §3 EXPORT-ONLY DEAD cleanup: remove from index.ts (implementations kept), delete non-exported dead types. === packages/db_helper_sqlite/index.ts === - removed line 10 block: export { staffRoleEnum, staffPermissionEnum } from './src/db/schema' (these enum values still flow to consumers via the existing `export * from './src/db/schema'` — the explicit line was redundant) - user product block: removed type lines type SkuSummary, type OffersPageData, type OffersPageProductData, - store helpers block: removed line type AvailabilityCacheData, - user order block: removed type lines type OrderWithFullData, type OrderWithCancellationData, - SKU Features block: removed lines cleanFeatureValue, splitQuantityFeature, type SkuFeatureLike, (kept composeUnitNotation, composeSkuName — used by backend) === packages/db_helper_postgres/index.ts === - removed line 11 block: export { staffRoleEnum, staffPermissionEnum } from './src/db/schema'; - user order block: removed type lines type OrderWithFullData, type OrderWithCancellationData, === apps/backend/src/sqliteImporter.ts === - removed type lines type OrderWithFullData, type OrderWithCancellationData, - removed line getUserNotifCred, Note: getNotifCred index export line in both packages: getNotifCred as getUserNotifCred, — removed (see below). === packages/db_helper_sqlite/index.ts + packages/db_helper_postgres/index.ts === - user profile block: removed line getNotifCred as getUserNotifCred, (function getNotifCred kept in user.ts — called internally by upsertNotifCred) === packages/db_helper_sqlite/src/user-apis/order.ts === - removed dead interface (lines 33-40): export interface PlaceOrderInput { userId: number selectedItems: OrderItemInput[] addressId: number paymentMethod: 'online' | 'cod' couponId?: number userNotes?: string isFlash?: boolean } - removed dead interface (lines 43-51): export interface OrderGroupData { slotId: number | null items: Array<{ productId: number quantity: number slotId: number | null product: typeof productInfo.$inferSelect }> } === packages/db_helper_postgres/src/user-apis/order.ts === - removed identical PlaceOrderInput (lines 29-36) and OrderGroupData (lines 39-47) [2026-09-02 21:04:10] CORRECTION to previous entry: while editing packages/db_helper_sqlite/index.ts user product block I accidentally removed getAllSkusSummary, getOffersAndCombos and type ProductSummaryData (all three are USED by backend). Immediately restored them; final state of that block keeps: getAllProductsWithUnits, getAllSkusSummary, getOffersAndCombos, type ProductSummaryData. Only type SkuSummary, type OffersPageData, type OffersPageProductData were meant to be (and now are) removed. [2026-09-02 21:07:40] CORRECTION: while editing the user order block of packages/db_helper_sqlite/index.ts I accidentally removed getOrdersByIdsWithFullData and getOrderByIdWithFullData (both USED by backend post-order-handler). Immediately restored. Final state: those two functions kept; only type OrderWithFullData and type OrderWithCancellationData removed from that block. Also fixed an earlier accidental newline removal after the store-helpers export close brace. [2026-09-02 21:05:24] FOLLOW-UP: remove orphaned OrderItemInput from user-apis/order.ts in both packages (its only consumer, PlaceOrderInput, was deleted; definition-only now). === packages/db_helper_sqlite/src/user-apis/order.ts === - removed (lines 27-31): export interface OrderItemInput { productId: number quantity: number slotId: number | null } === packages/db_helper_postgres/src/user-apis/order.ts === - removed identical interface (lines 23-27) [2026-09-02 21:06:16] COMPLETED §3 export-only-dead cleanup. Removed from index.ts (implementations kept in src): - both packages: redundant staffRoleEnum/staffPermissionEnum export block (still exported via `export * from './src/db/schema'`), type OrderWithFullData, type OrderWithCancellationData, getNotifCred as getUserNotifCred - sqlite only: type SkuSummary, type OffersPageData, type OffersPageProductData, type AvailabilityCacheData, cleanFeatureValue, splitQuantityFeature, type SkuFeatureLike (kept composeUnitNotation/composeSkuName) Removed from apps/backend/src/sqliteImporter.ts: type OrderWithFullData, type OrderWithCancellationData, getUserNotifCred Deleted dead types in user-apis/order.ts (both packages): PlaceOrderInput, OrderGroupData, OrderItemInput Verification: - Backend-used exports confirmed intact: getAllSkusSummary, getOffersAndCombos, ProductSummaryData, getOrdersByIdsWithFullData, getOrderByIdWithFullData, getAvailabilityForCache, getAllProductCombosForCache, getUserWithCreds, createUserAuthWithCreds, composeSkuName, composeUnitNotation - tsc --noEmit baselines unchanged: sqlite 4 (seed.ts 1, order.ts 2, product.ts 1), postgres 40, backend 17 — all pre-existing, none reference touched symbols. [2026-09-02 21:21:13] §4: remove never-referenced schema tables — addressZones, addressAreas, userNotifications, productCategories (BOTH packages). NOTE: this only removes them from the drizzle schema (code). The actual DB tables/columns/FK constraints still exist in D1/Postgres — dropping them in the DB requires a migration, which the user will handle (per AGENTS.md). Both schema.ts files drift from the live DB until then; drizzle-kit push/generate must NOT be run by the agent. === packages/db_helper_sqlite/src/db/schema.ts === - removed addressZones table (lines 106-110): export const addressZones = sqliteTable('address_zones', { id: integer().primaryKey({ autoIncrement: true }), zoneName: text('zone_name').notNull(), addedAt: timestampText('added_at').notNull().default(sql`CURRENT_TIMESTAMP`), }) - removed addressAreas table (lines 112-117): export const addressAreas = sqliteTable('address_areas', { id: integer().primaryKey({ autoIncrement: true }), placeName: text('place_name').notNull(), zoneId: integer('zone_id').references(() => addressZones.id), createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), }) - addresses table: changed zoneId column to drop FK (column KEPT — shared UserAddress type and user-apis/address.ts mapUserAddress still expose zoneId): before: zoneId: integer('zone_id').references(() => addressZones.id), after: zoneId: integer('zone_id'), - removed productCategories table (lines 431-434): export const productCategories = sqliteTable('product_categories', { id: integer().primaryKey({ autoIncrement: true }), name: text().notNull(), description: text(), }) - removed userNotifications table (lines 545-551): export const userNotifications = sqliteTable('user_notifications', { id: integer().primaryKey({ autoIncrement: true }), title: text('title').notNull(), imageUrl: text('image_url'), createdAt: timestampText('created_at').notNull().default(sql`CURRENT_TIMESTAMP`), body: text('body').notNull(), applicableUsers: jsonText('applicable_users'), }) - addressesRelations: removed line zone: one(addressZones, { fields: [addresses.zoneId], references: [addressZones.id] }), - removed productCategoriesRelations (line 686): export const productCategoriesRelations = relations(productCategories, ({}) => ({})) - removed userNotificationsRelations (lines 720-722): export const userNotificationsRelations = relations(userNotifications, ({}) => ({ // No relations needed for now })) - removed addressZonesRelations (lines 749-752): export const addressZonesRelations = relations(addressZones, ({ many }) => ({ addresses: many(addresses), areas: many(addressAreas), })) - removed addressAreasRelations (lines 754-756): export const addressAreasRelations = relations(addressAreas, ({ one }) => ({ zone: one(addressZones, { fields: [addressAreas.zoneId], references: [addressZones.id] }), })) === packages/db_helper_postgres/src/db/schema.ts === (same removals, postgres style) - removed addressZones table (lines 58-62, mf.table('address_zones', ...)) - removed addressAreas table (lines 64-69, mf.table('address_areas', ...)) - addresses.zoneId (line 54): dropped .references(() => addressZones.id) — column kept - removed productCategories table (lines 318-322, mf.table('product_categories', ...)) - removed userNotifications table (lines 434-440, mf.table('user_notifications', ...)) - addressesRelations: removed zone relation line (line 496) - removed productCategoriesRelations (line 573) - removed userNotificationsRelations (lines 607-609) - removed addressZonesRelations (lines 636-639) and addressAreasRelations (lines 641-643) [2026-09-02 21:23:14] COMPLETED §4 schema table removal. - Removed from both packages' src/db/schema.ts: addressZones, addressAreas, productCategories, userNotifications tables + productCategoriesRelations, userNotificationsRelations, addressZonesRelations, addressAreasRelations. - addresses.zoneId column KEPT (FK reference + addressesRelations.zone relation removed) because shared UserAddress type and user-apis/address.ts still expose zoneId. - Verified: zero remaining references to the 4 tables anywhere; jsonText/jsonb/text imports still used by other tables; tsc baselines unchanged (sqlite 4, postgres 40, backend 17 — all pre-existing). - REMINDER: DB tables still exist in D1/Postgres until the user runs a drop migration (agent must not run drizzle migrations). [2026-09-02 21:24:48] §6: DELETE dead backend files (10 files) + clean commented references to them. DELETED (all verified: zero live imports — only commented mentions remain): - apps/backend/src/postgresImporter.ts (entirely commented-out swap scaffold; restore from git when swapping to postgres) - apps/backend/src/lib/signed-url-cache-old.ts - apps/backend/src/lib/signed-url-cache.ts - apps/backend/src/lib/disk-persisted-set.ts (body fully commented out) - apps/backend/src/lib/catch-async.ts - apps/backend/src/lib/axios.ts (phonepeAxios never imported) - apps/backend/src/lib/delete-image.ts (deleteS3Image never imported) - apps/backend/src/lib/event-queue.ts (enqueue never imported; queue-consumer.ts is the live path) - apps/backend/src/lib/notif-service.ts - apps/backend/src/types/db.types.ts COMMENT CLEANUP (files are .ts → logged here): === apps/backend/index.ts === - removed line 5: // import signedUrlCache from '@/src/lib/signed-url-cache'; - removed line 12: // signedUrlCache.loadFromDisk(); // Disabled for Workers compatibility Left untouched: s3-client.ts:141 prose comment (mentions the concept, not an import), dbService.ts prose header. KEPT (verified alive): jobs/cache-creator.ts (Durable Object), lib/queue-consumer.ts, lib/flash-delivery-cron.ts, lib/seed.ts, lib/init.ts, lib/worker-init.ts, src/apis/**, src/test-controller.ts, types/hono.d.ts (ambient). [2026-09-02 21:25:58] COMPLETED §6 backend dead-file deletion (10 files) + index.ts comment cleanup. Verification: backend tsc --noEmit now reports 11 errors (was 17) — the 6 that vanished were signed-url-cache-old.ts's own pre-existing errors; remaining 11 are the same pre-existing set in untouched files (app.ts, lib/init.ts, s3-client.ts, main-router.ts, trpc-index.ts, sqlite order.ts/product.ts). No new errors. Note: apps/backend/src/lib/s3-client.ts.txt (a .txt copy of s3-client) still exists — left alone, flagging as possible future cleanup. [2026-09-02 21:31:17] Remove 4 dead-code items missed by our report but caught by cmd_v4_dead.md. DELETED (3 files, verified zero live imports — only commented references): - apps/backend/src/lib/redis-client.ts (stubbed: createClient = (args:any) => {}; only '// import redisClient' comments remain elsewhere) - apps/backend/src/lib/redisKeyGetters.ts (only commented imports in trpc/apis/admin-apis/apis/slots.ts:7,613,694) - apps/backend/src/middleware/auth.ts (verifyToken/requireRole never imported; app uses middleware/auth.middleware.ts + staff-auth.ts) EDITED: === packages/shared/index.ts === - removed line 10 (dead type, definition-only): export type CacheFilename = typeof CACHE_FILENAMES[keyof typeof CACHE_FILENAMES] (CACHE_FILENAMES const itself is heavily used by backend cloud_cache.ts and web-ui/user-ui hooks — kept) [2026-09-02 21:32:23] COMPLETED removal of 4 missed dead-code items. - Deleted: apps/backend/src/lib/redis-client.ts, apps/backend/src/lib/redisKeyGetters.ts, apps/backend/src/middleware/auth.ts (middleware/ dir still has auth.middleware.ts + staff-auth.ts). - Removed CacheFilename type from packages/shared/index.ts (CACHE_FILENAMES const kept — used by cloud_cache.ts + web-ui/user-ui hooks). - Verified: zero remaining references (excluding comments); backend tsc --noEmit = 11 errors, same pre-existing baseline. [2026-09-02 21:45:00] CREATED analysis scripts (new .js files, read-only analysis): scripts/dead-code/user-ui-files.js, user-ui-symbols.js, user-ui-suspects.js, user-ui-store-actions.js, user-ui-store-final.js, user-ui-store-precise.js [2026-09-02 22:56:40] EXECUTE user_ui_glm.md cleanup: remove dead code, KEEP register.tsx, DO NOT touch npm dependencies. --- FILE DELETIONS --- - apps/user-ui/app/(drawer)/(tabs)/me/about/_layout.tsx (unreachable route, zero navigations) - apps/user-ui/app/(drawer)/(tabs)/me/about/index.tsx (unreachable route) KEPT: app/(auth)/register.tsx (user decision — keep for future sign-up wiring) - apps/user-ui/constants/Colors.ts (never imported; constants/ dir becomes empty) - apps/user-ui/components/BannerCarousel.tsx (never imported) - apps/user-ui/src/components/google-sign-in.tsx (never imported; login uses common-ui's copy) - apps/user-ui/app/api/auth/authorize+api.ts (unreferenced Google OAuth endpoints; ⚠️ no caller in repo — - apps/user-ui/app/api/auth/callback+api.ts restore from git if an external Google redirect URI was configured) - apps/user-ui/app/api/auth/token+api.ts - UNUSED ASSETS (zero references in code/app.json/eas.json): assets/images/adaptive-icon.png, farm2door-logo.png, freshyo-logoo.png, freshyo-logoo.svg, logo_mini.jpg, partial-react-logo.png, react-logo.png, react-logo@2x.png, react-logo@3x.png, splash-icon.png, symbuyote.png (assets/images/logo.png, icon.png, favicon.png, freshyo-logo.png, fonts/SpaceMono-Regular.ttf KEPT — referenced) --- EDITS --- === apps/user-ui/src/hooks/prominent-api-hooks.ts === - remove dead chain: useBanners() hook + BannersResponse type (only consumer was deleted BannerCarousel) (CACHE_FILENAMES import stays — used by other cache hooks in the file) === apps/user-ui/hooks/useJWT.ts === - removed saveRoles, getRoles, deleteRoles (never called) + ROLES_KEY const (only used by the dead trio) (AUTH_TOKEN_KEY, USER_ID_KEY, saveUserId, getUserId, saveAuthToken, getAuthToken, deleteAuthToken kept — live) === apps/user-ui/services/toaster.tsx === - removed InfoToast, ErrorToast, SuccessToast (never imported; NotificationToast + default Toast are live) === apps/user-ui/src/store/centralProductStore.ts === - removed clearProducts (interface field + implementation; nothing ever clears the product store) === apps/user-ui/src/store/addressStore.ts === - removed clearSelectedAddress (interface field + implementation) === apps/user-ui/src/store/centralSlotStore.ts === - removed clearSlotsData (interface field + implementation) === apps/user-ui/src/store/quickDeliveryStore.ts === - removed setDrawerHidden (never called; isDrawerHidden state + readers kept — flag is permanently false today) === apps/user-ui/components/PaymentAndOrderComponent.tsx === - removed commented createRazorpayOrderMutation block (~lines 97-104) - removed commented initiateRazorpayPayment block (~lines 170-210) (live COD/verify-payment flow untouched; react-native-razorpay dependency KEPT per instruction) === apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx === - removed commented initiateRazorpayPayment block (~lines 564-585) (live handleRetryPayment + createRazorpayOrderMutation untouched) === apps/user-ui/app/_layout.tsx === - removed line 40: console.log('from layout') - line 11 import: removed unused Dimensions → import { Appearance, StatusBar, View } from "react-native"; NOT TOUCHED (per instruction): all npm dependencies in package.json (incl. react-native-razorpay, expo-image-picker, etc.) NOT TOUCHED (left as-is): scripts/reset-project.js (template helper wired to npm script — user call), dist/ build artifacts [2026-09-02 23:02:51] COMPLETED user_ui_glm.md cleanup (register.tsx KEPT, npm dependencies NOT touched). Deleted: me/about route (2 files + dir), constants/Colors.ts (+ empty constants/ dir), components/BannerCarousel.tsx, src/components/google-sign-in.tsx, app/api/auth/{authorize,callback,token}+api.ts (+ empty dirs), 11 unused assets. Edited: prominent-api-hooks.ts (useBanners + BannersResponse + BannersApiType import removed), useJWT.ts (saveRoles/getRoles/deleteRoles/ROLES_KEY removed), toaster.tsx (InfoToast/ErrorToast/SuccessToast removed), 4 stores (clearProducts, clearSelectedAddress, clearSlotsData, setDrawerHidden removed), PaymentAndOrderComponent.tsx + my-orders/index.tsx (commented Razorpay blocks removed), _layout.tsx (console.log + unused Dimensions import removed). Verification: zero leftover references; tsc --noEmit total unchanged at 106 (all pre-existing, in ../backend files via @backend types; 0 errors in user-ui's own files). [2026-09-02 23:45:00] EXECUTE admin_ui_dpsk.md cleanup: delete dead code; KEEP §4 (single-source routes + dead affordances); DO NOT touch npm dependencies. PLANNED FILE DELETIONS (verified zero live references via grep across apps/admin-ui + packages): - app/(drawer)/dashboard/coupons/reserved-coupons/index.tsx (orphaned route; feature duplicated inline as ReservedTab in coupons/index.tsx) - components/context/auth-context.tsx (100% commented-out legacy auth; no live exports) - components/context/roles-context.tsx (imports non-export AuthContext → broken; useRoles/useIsAdmin zero importers) - components/dashboard-header.tsx (zero importers; replaced by drawer header) - components/TabNavigation.tsx, components/day-account-view.tsx, components/HorizontalImageScroller.tsx (zero importers) - components/AddressPlaceForm.tsx, components/AddressZoneForm.tsx, components/app-container.tsx (zero importers) - components/ui/IconSymbol.ios.tsx, IconSymbol.tsx, TabBarBackground.ios.tsx, TabBarBackground.tsx (expo-template tab files; zero importers) - components/UserIncidentDialog.tsx (zero importers; live UserIncidentsView.tsx holds private duplicate) - components/date-time-picker.tsx (zero importers; duplicate of common-ui's live DateTimePickerMod) - src/api-hooks/banner.api.ts (zero importers) - hooks/useHideDrawerHeader.ts, hooks/useCurrentUserId.ts, hooks/usePhonepeSdk.ts (zero importers) - hooks/useThemeColor.ts, hooks/useColorScheme.ts, hooks/useColorScheme.web.ts, constants/Colors.ts (template trio; sole consumer = deleted dashboard-header) - utils/getCurrentUserId.ts (zero live importers) - services/axios-admin-ui.ts (zero importers) - services/notif-service/notif-checker.tsx, notif-context.tsx, notif-register.ts (never mounted in app/_layout; notif-checker imports nonexistent @/api-hooks/user.api) - scripts/reset-project.js + e2e/jest.config.js + e2e/starter.test.js + .detoxrc.js (expo-template leftovers; no detox dep/script) PLANNED EDITS (with false-positive corrections verified by reading live callers): === apps/admin-ui/app/(drawer)/dashboard/index.tsx === - remove unused import: LinearGradient (theme import KEPT — used by menu items; only the LinearGradient JSX block is commented out) === apps/admin-ui/app/(drawer)/dashboard/send-notifications/index.tsx === - remove commented-out ImageUploader UI block; remove now-unused ImageUploader/usePickImage imports, handleImagePick/handleRemoveImage handlers, selectedImage/displayImage state, and their reset lines in sendNotification.onSuccess (image-upload feature is commented out/unreachable; useUploadToObjectStorage.uploadSingle KEPT — still used in handleSend) === apps/admin-ui/app/(drawer)/dashboard/manage-orders/delivery-sequences/index.tsx === - remove commented-out hint-banner JSX block inside the DraggableFlatList === apps/admin-ui/hooks/useJWT.ts === - prune to live exports only: saveJWT, getJWT, deleteJWT (+ JWT_KEY const). Remove: saveUserId, getUserId, saveRoles, getRoles, deleteRoles, ROLES_KEY, USER_ID_KEY === apps/admin-ui/src/components/CouponForm.tsx === - remove console.log('Toggling user:', ...) debug line (keep setFieldValue) === apps/admin-ui/components/StoreForm.tsx === - remove StoreFormRef interface + forwardRef wrapper + unused ref param + displayName (ref never attached by stores/add.tsx or stores/edit.tsx) - KEPT: ProductForm's ProductFormRef/clearImages (genuinely used by products/edit.tsx via productFormRef.current?.clearImages()) - KEPT: SlotForm's dateTestID/timeTestID props (common-ui DateTimePickerMod accepts them — verified in packages/ui/src/components/date-time-picker.tsx) - KEPT: OrderOptionsMenu onWhatsApp/onDial props and no-op callers (§4 dead-affordance zone — not deleting) NOT TOUCHED (per instruction): - §4: rebalance-orders route, slots/slot-details route, customize-app/product-tags home-grid entries, vendor-snippets "View Slot" no-op button, orders/index packaged-checkbox no-op onPress - All npm dependencies in package.json (incl. react-native-phonepe-pg, expo-notifications, material-top-tabs, toaster dep, buffer, jwt-decode) - components/SnippetMenu.tsx SuccessToast call + services/toaster.tsx (product decision — no host mounted) - user-ui counterparts (LIVE there; e.g. user-ui's useColorScheme/Colors/notif-service are wired and in use) [2026-09-02 23:58:00] COMPLETED admin_ui_dpsk.md cleanup. Deleted 34 dead files + emptied dirs: - Route: app/(drawer)/dashboard/coupons/reserved-coupons/index.tsx (+ emptied dir) - Components: context/auth-context.tsx, context/roles-context.tsx, dashboard-header.tsx, TabNavigation.tsx, day-account-view.tsx, HorizontalImageScroller.tsx, AddressPlaceForm.tsx, AddressZoneForm.tsx, app-container.tsx, UserIncidentDialog.tsx, date-time-picker.tsx, ui/{IconSymbol,IconSymbol.ios,TabBarBackground,TabBarBackground.ios}.tsx (+ emptied components/ui dir) - src/api-hooks/banner.api.ts (+ emptied dir) - Hooks: useHideDrawerHeader.ts, useCurrentUserId.ts, usePhonepeSdk.ts, useThemeColor.ts, useColorScheme.ts, useColorScheme.web.ts - constants/Colors.ts (+ emptied dir), utils/getCurrentUserId.ts, services/axios-admin-ui.ts, services/notif-service/{notif-checker,notif-context,notif-register} (+ emptied dir) - scripts/reset-project.js (+ emptied dir), e2e/{jest.config.js,starter.test.js} (+ emptied dir), .detoxrc.js - components/context/ dir kept (staff-auth-context.tsx is live) Edited: - app/(drawer)/dashboard/index.tsx: removed unused LinearGradient import (theme kept — used by menu items; commented gradient JSX block left as comment) - app/(drawer)/dashboard/send-notifications/index.tsx: removed commented-out image-upload UI + dead image state (selectedImage/displayImage), handleImagePick/handleRemoveImage handlers, ImageUploader/usePickImage/useUploadToObjectStorage imports, and image upload path in handleSend (UI is disabled; uploadSingle had no reachable caller left) - app/(drawer)/dashboard/manage-orders/delivery-sequences/index.tsx: removed commented-out hint-banner JSX block - hooks/useJWT.ts: pruned to saveJWT/getJWT/deleteJWT + JWT_KEY (removed saveUserId/getUserId/saveRoles/getRoles/deleteRoles/ROLES_KEY/USER_ID_KEY) - src/components/CouponForm.tsx: removed debug console.log in toggleUserSelection - components/StoreForm.tsx: removed unused StoreFormRef interface + forwardRef wrapper + ref param + displayName (now plain function component; StoreFormData export kept) - Regenerated .expo/types/router.d.ts via brief expo start (removed stale reserved-coupons route types); dev server killed KEPT (per instruction / verification): §4 routes & affordances (rebalance-orders, slot-details, customize-app/product-tags, vendor-snippets "View Slot" no-op, orders packaged-checkbox no-op); ProductForm ProductFormRef/clearImages (USED by products/edit.tsx); SlotForm dateTestID/timeTestID (common-ui DateTimePickerMod accepts them); OrderOptionsMenu onWhatsApp/onDial props; SnippetMenu SuccessToast + services/toaster.tsx (no Toast host — product decision); all npm dependencies untouched; user-ui counterparts untouched (live there). Verification: - grep across apps/admin-ui: zero remaining references to any deleted file/symbol (only generated .expo cache regenerated clean). - tsc --noEmit: no errors in any file I edited. Remaining 19 admin-ui-local errors + backend errors are pre-existing (in untouched files: complaints, coupons/edit, customize-app, products, user-management, delivery-sequences lines 343/398 implicit-any, ProductGroupForm, ProductsSelector, ProductForm) — verified none are in modified regions. [2026-09-02 23:20:00] CREATED analysis script: scripts/dead-code/repeat-types.js (read-only type-declaration scanner, outputs scripts/dead-code/repeat-types-raw.json) [2026-09-03 00:10:00] EXECUTE repeat_types_dpsk.md cleanup — remove legacy doctor/hospital/token types (not relevant to meat-farmer app). PLANNED CHANGES: === packages/ui/shared-types.ts === - DELETE all legacy doctor/hospital/token types (zero external references — verified by grep across apps + packages): Person, User (hospital-era), Hospital, DoctorSpecialization, DoctorInfo, Doctor, DoctorDetails, DashboardDoctor, TokenDoctor, UpcomingToken, PastToken, UpcomingAppointment, MyTokensResponse, PastTokensResponse, BookTokenPayload, BookTokenResponse, DoctorAvailability, DoctorAvailabilityWithDate, DoctorAvailabilityResponse, DoctorAvailabilityPayload, token_user, PatientHistoryToken, PatientHistory, GetHospitalPatientHistoryResponse, PatientHistoryFilters - DELETE shadowed meat-farmer duplicates that collide with packages/shared (also zero importers): Order, Slot, Coupon (canonical copies live in packages/shared/types/{user.ts, admin.ts}) - KEEP: CreateCouponPayload (only live export — imported by apps/admin-ui coupons via 'common-ui/shared-types') - REMOVE trailing `export * from './token-types'` === packages/ui/token-types.ts === - DELETE entire file (DoctorTokenSummary, HospitalTodaysTokensResponse, DoctorTodayToken, DoctorTodaysTokensResponse — only re-exported by shared-types.ts:333, no external consumers) [2026-09-03 00:15:00] COMPLETED legacy doctor/hospital/token type removal. - packages/ui/shared-types.ts: rewritten to contain ONLY CreateCouponPayload (the single live export). Removed 28 legacy doctor/hospital/token types + 3 shadowed meat-farmer duplicates (Order, Slot, Coupon — canonical copies live in packages/shared) + trailing `export * from './token-types'`. - packages/ui/token-types.ts: deleted (4 token-summary types, zero external consumers). Verification: - grep across apps + packages: zero references to any removed legacy type name or the token-types module. - CreateCouponPayload intact; its only importers (admin-ui coupons/edit/[id].tsx + src/components/CouponForm.tsx) unchanged. - Pre-existing tsc error in coupons/edit/[id].tsx:92 (`skuIds` not in CreateCouponPayload) untouched and unrelated (predates this change; CreateCouponPayload body preserved byte-for-byte). [2026-09-03 20:03:29] DELETE unused types (no consumers repo-wide; scanner: scripts/dead-code/unused-types.js; ambient .d.ts declarations excluded by design). NOTE: date rollover — this entry and deletions performed 2026-09-03. === apps/backend/src/middleware/auth.middleware.ts === - removed interface UserContext (lines 7-12): interface UserContext { userId: number; name?: string; email?: string; mobile?: string; } - removed interface StaffContext (lines 14-17): interface StaffContext { id: number; name: string; } (file types context vars via hono's ContextVariableMap augmentation in types/hono.d.ts — those ambient declarations KEPT, they are consumed by hono's type system, not by name) === packages/shared/types/coupon.types.ts === - removed interface ReservedCoupon (lines 21-25): export interface ReservedCoupon extends Coupon { secretCode: string; redeemedUserId: number | null; redeemedAt: Date | null; } === packages/shared/types/user.ts === - removed interface UserAvailabilityEntry (lines 339-345) — transitively dead (only consumer was UserAvailabilityResponse): export interface UserAvailabilityEntry { id: number; price: string; marketPrice: string | null; flashPrice: string | null; isFlashAvailable: boolean; isOutOfStock: boolean; isSuspended: boolean; } - removed interface UserAvailabilityResponse (lines 347-350): export interface UserAvailabilityResponse { availability: UserAvailabilityEntry[]; count: number; } === packages/ui/src/components/use-pick-image.tsx === - removed interface BaseProps (lines 5-8): interface BaseProps { label?: string; multiple: boolean; } - removed interface ImageInfo (lines 22-36) — 15-field expo ImagePicker asset mirror, never referenced (picker assets are spread as any) (live hook + its Props type kept; file has 7 consumers) [2026-09-03 20:06:30] COMPLETED unused-type deletion: 7 types removed across 4 files. - auth.middleware.ts: UserContext, StaffContext (kept hono.d.ts ContextVariableMap — ambient module augmentation, consumed by hono's type system) - shared/coupon.types.ts: ReservedCoupon - shared/user.ts: UserAvailabilityResponse + UserAvailabilityEntry (transitively dead — only consumer was the removed response type) - ui/use-pick-image.tsx: BaseProps, ImageInfo Verification: zero leftover references repo-wide; tsc baselines unchanged — backend 11, packages/ui 924, user-ui 106, admin-ui 122 (all pre-existing). Scanner limitation noted: same-name declarations across files (e.g. Props, Order) can mask per-copy deadness via word-boundary matching; those require import-graph resolution and were not touched.