enh
This commit is contained in:
parent
fe05769343
commit
9137b5e1e6
2 changed files with 228 additions and 213 deletions
|
|
@ -1,221 +1,15 @@
|
|||
// Database Service - Central export for all database-related imports
|
||||
// This file re-exports everything from postgresService to provide a clean abstraction layer
|
||||
// Implementation is the responsibility of postgresService package
|
||||
// This file re-exports everything from postgresImporter to provide a clean abstraction layer
|
||||
|
||||
import { getOrderDetails as getOrderDetailsFromDb } from 'postgresService'
|
||||
import type { AdminOrderDetails } from '@packages/shared'
|
||||
import { getOrderDetails } from '@/src/postgresImporter'
|
||||
|
||||
// Re-export database connection
|
||||
export { db } from 'postgresService'
|
||||
// Re-export everything from postgresImporter
|
||||
export * from '@/src/postgresImporter'
|
||||
|
||||
// Re-export all schema exports
|
||||
export * from 'postgresService'
|
||||
|
||||
// Re-export methods from postgresService (implementation lives there)
|
||||
|
||||
export {
|
||||
// Banner methods
|
||||
getBanners,
|
||||
getBannerById,
|
||||
createBanner,
|
||||
updateBanner,
|
||||
deleteBanner,
|
||||
// Complaint methods
|
||||
getComplaints,
|
||||
resolveComplaint,
|
||||
// Constants methods
|
||||
getAllConstants,
|
||||
upsertConstants,
|
||||
// Coupon methods
|
||||
getAllCoupons,
|
||||
getCouponById,
|
||||
invalidateCoupon,
|
||||
validateCoupon,
|
||||
getReservedCoupons,
|
||||
getUsersForCoupon,
|
||||
createCouponWithRelations,
|
||||
updateCouponWithRelations,
|
||||
generateCancellationCoupon,
|
||||
createReservedCouponWithProducts,
|
||||
createCouponForUser,
|
||||
checkUsersExist,
|
||||
checkCouponExists,
|
||||
checkReservedCouponExists,
|
||||
getOrderWithUser,
|
||||
// Store methods
|
||||
getAllStores,
|
||||
getStoreById,
|
||||
createStore,
|
||||
updateStore,
|
||||
deleteStore,
|
||||
// Staff-user methods
|
||||
getStaffUserByName,
|
||||
getAllStaff,
|
||||
getAllUsers,
|
||||
getUserWithDetails,
|
||||
updateUserSuspensionStatus,
|
||||
checkStaffUserExists,
|
||||
checkStaffRoleExists,
|
||||
createStaffUser,
|
||||
getAllRoles,
|
||||
// User methods
|
||||
createUserByMobile,
|
||||
getUserByMobile,
|
||||
getUnresolvedComplaintsCount,
|
||||
getAllUsersWithFilters,
|
||||
getOrderCountsByUserIds,
|
||||
getLastOrdersByUserIds,
|
||||
getSuspensionStatusesByUserIds,
|
||||
getUserBasicInfo,
|
||||
getUserSuspensionStatus,
|
||||
getUserOrders,
|
||||
getOrderStatusesByOrderIds,
|
||||
getItemCountsByOrderIds,
|
||||
upsertUserSuspension,
|
||||
searchUsers,
|
||||
getAllNotifCreds,
|
||||
getAllUnloggedTokens,
|
||||
getNotifTokensByUserIds,
|
||||
getUserIncidentsWithRelations,
|
||||
createUserIncident,
|
||||
// Vendor-snippets methods
|
||||
checkVendorSnippetExists,
|
||||
getVendorSnippetById,
|
||||
getVendorSnippetByCode,
|
||||
getAllVendorSnippets,
|
||||
createVendorSnippet,
|
||||
updateVendorSnippet,
|
||||
deleteVendorSnippet,
|
||||
getProductsByIds,
|
||||
getVendorSlotById,
|
||||
getVendorOrdersBySlotId,
|
||||
getOrderItemsByOrderIds,
|
||||
getOrderStatusByOrderIds,
|
||||
updateVendorOrderItemPackaging,
|
||||
getVendorOrders,
|
||||
// Product methods
|
||||
getAllProducts,
|
||||
getProductById,
|
||||
deleteProduct,
|
||||
createProduct,
|
||||
updateProduct,
|
||||
toggleProductOutOfStock,
|
||||
updateSlotProducts,
|
||||
getSlotProductIds,
|
||||
getSlotsProductIds,
|
||||
getAllUnits,
|
||||
getAllProductTags,
|
||||
getProductReviews,
|
||||
respondToReview,
|
||||
getAllProductGroups,
|
||||
createProductGroup,
|
||||
updateProductGroup,
|
||||
deleteProductGroup,
|
||||
addProductToGroup,
|
||||
removeProductFromGroup,
|
||||
updateProductPrices,
|
||||
// Slots methods
|
||||
getActiveSlotsWithProducts,
|
||||
getActiveSlots,
|
||||
getSlotsAfterDate,
|
||||
getSlotByIdWithRelations,
|
||||
createSlotWithRelations,
|
||||
updateSlotWithRelations,
|
||||
deleteSlotById,
|
||||
updateSlotCapacity,
|
||||
getSlotDeliverySequence,
|
||||
updateSlotDeliverySequence,
|
||||
// User address methods
|
||||
getUserDefaultAddress,
|
||||
getUserAddresses,
|
||||
getUserAddressById,
|
||||
clearUserDefaultAddress,
|
||||
createUserAddress,
|
||||
updateUserAddress,
|
||||
deleteUserAddress,
|
||||
hasOngoingOrdersForAddress,
|
||||
getUserActiveBanners,
|
||||
getUserCartItemsWithProducts,
|
||||
getUserProductById,
|
||||
getUserCartItemByUserProduct,
|
||||
incrementUserCartItemQuantity,
|
||||
insertUserCartItem,
|
||||
updateUserCartItemQuantity,
|
||||
deleteUserCartItem,
|
||||
clearUserCart,
|
||||
getUserComplaints,
|
||||
createUserComplaint,
|
||||
getUserStoreSummaries,
|
||||
getUserStoreDetail,
|
||||
getUserProductDetailById,
|
||||
getUserProductReviews,
|
||||
getUserProductByIdBasic,
|
||||
createUserProductReview,
|
||||
getUserActiveSlotsList,
|
||||
getUserProductAvailability,
|
||||
getUserPaymentOrderById,
|
||||
getUserPaymentByOrderId,
|
||||
getUserPaymentByMerchantOrderId,
|
||||
updateUserPaymentSuccess,
|
||||
updateUserOrderPaymentStatus,
|
||||
markUserPaymentFailed,
|
||||
getUserAuthByEmail,
|
||||
getUserAuthByMobile,
|
||||
getUserAuthById,
|
||||
getUserAuthCreds,
|
||||
getUserAuthDetails,
|
||||
createUserAuthWithCreds,
|
||||
createUserAuthWithMobile,
|
||||
upsertUserAuthPassword,
|
||||
deleteUserAuthAccount,
|
||||
getUserActiveCouponsWithRelations,
|
||||
getUserAllCouponsWithRelations,
|
||||
getUserReservedCouponByCode,
|
||||
redeemUserReservedCoupon,
|
||||
getUserProfileById,
|
||||
getUserProfileDetailById,
|
||||
getUserWithCreds,
|
||||
getUserNotifCred,
|
||||
upsertUserNotifCred,
|
||||
deleteUserUnloggedToken,
|
||||
getUserUnloggedToken,
|
||||
upsertUserUnloggedToken,
|
||||
// Order methods
|
||||
updateOrderNotes,
|
||||
updateOrderPackaged,
|
||||
updateOrderDelivered,
|
||||
updateOrderItemPackaging,
|
||||
removeDeliveryCharge,
|
||||
getSlotOrders,
|
||||
updateAddressCoords,
|
||||
getAllOrders,
|
||||
rebalanceSlots,
|
||||
cancelOrder,
|
||||
deleteOrderById,
|
||||
// User Order helpers
|
||||
validateAndGetUserCoupon,
|
||||
applyDiscountToUserOrder,
|
||||
getUserAddressByIdAndUser,
|
||||
getOrderProductById,
|
||||
checkUserSuspended,
|
||||
getUserSlotCapacityStatus,
|
||||
placeUserOrderTransaction,
|
||||
deleteUserCartItemsForOrder,
|
||||
recordUserCouponUsage,
|
||||
getUserOrdersWithRelations,
|
||||
getUserOrderCount,
|
||||
getUserOrderByIdWithRelations,
|
||||
getUserCouponUsageForOrder,
|
||||
getUserOrderBasic,
|
||||
cancelUserOrderTransaction,
|
||||
updateUserOrderNotes,
|
||||
getUserRecentlyDeliveredOrderIds,
|
||||
getUserProductIdsFromOrders,
|
||||
getUserProductsForRecentOrders,
|
||||
} from 'postgresService'
|
||||
|
||||
export async function getOrderDetails(orderId: number): Promise<AdminOrderDetails | null> {
|
||||
return getOrderDetailsFromDb(orderId)
|
||||
// Re-export getOrderDetails with the correct signature
|
||||
export async function getOrderDetailsWrapper(orderId: number): Promise<AdminOrderDetails | null> {
|
||||
return getOrderDetails(orderId)
|
||||
}
|
||||
|
||||
// Re-export all types from shared package
|
||||
|
|
|
|||
221
apps/backend/src/postgresImporter.ts
Normal file
221
apps/backend/src/postgresImporter.ts
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
// Postgres Importer - Intermediate layer to avoid direct postgresService imports in dbService
|
||||
// This file re-exports everything from postgresService
|
||||
|
||||
// Re-export database connection
|
||||
export { db } from 'postgresService'
|
||||
|
||||
// Re-export all schema exports
|
||||
export * from 'postgresService'
|
||||
|
||||
// Re-export all helper methods from postgresService
|
||||
export {
|
||||
// Admin - Banner
|
||||
getBanners,
|
||||
getBannerById,
|
||||
createBanner,
|
||||
updateBanner,
|
||||
deleteBanner,
|
||||
// Admin - Complaint
|
||||
getComplaints,
|
||||
resolveComplaint,
|
||||
// Admin - Constants
|
||||
getAllConstants,
|
||||
upsertConstants,
|
||||
// Admin - Coupon
|
||||
getAllCoupons,
|
||||
getCouponById,
|
||||
invalidateCoupon,
|
||||
validateCoupon,
|
||||
getReservedCoupons,
|
||||
getUsersForCoupon,
|
||||
createCouponWithRelations,
|
||||
updateCouponWithRelations,
|
||||
generateCancellationCoupon,
|
||||
createReservedCouponWithProducts,
|
||||
createCouponForUser,
|
||||
checkUsersExist,
|
||||
checkCouponExists,
|
||||
checkReservedCouponExists,
|
||||
getOrderWithUser,
|
||||
// Admin - Order
|
||||
updateOrderNotes,
|
||||
getOrderDetails,
|
||||
updateOrderPackaged,
|
||||
updateOrderDelivered,
|
||||
updateOrderItemPackaging,
|
||||
removeDeliveryCharge,
|
||||
getSlotOrders,
|
||||
updateAddressCoords,
|
||||
getAllOrders,
|
||||
rebalanceSlots,
|
||||
cancelOrder,
|
||||
deleteOrderById,
|
||||
// Admin - Product
|
||||
getAllProducts,
|
||||
getProductById,
|
||||
deleteProduct,
|
||||
createProduct,
|
||||
updateProduct,
|
||||
toggleProductOutOfStock,
|
||||
updateSlotProducts,
|
||||
getSlotProductIds,
|
||||
getSlotsProductIds,
|
||||
getAllUnits,
|
||||
getAllProductTags,
|
||||
getProductReviews,
|
||||
respondToReview,
|
||||
getAllProductGroups,
|
||||
createProductGroup,
|
||||
updateProductGroup,
|
||||
deleteProductGroup,
|
||||
addProductToGroup,
|
||||
removeProductFromGroup,
|
||||
updateProductPrices,
|
||||
// Admin - Slots
|
||||
getActiveSlotsWithProducts,
|
||||
getActiveSlots,
|
||||
getSlotsAfterDate,
|
||||
getSlotByIdWithRelations,
|
||||
createSlotWithRelations,
|
||||
updateSlotWithRelations,
|
||||
deleteSlotById,
|
||||
updateSlotCapacity,
|
||||
getSlotDeliverySequence,
|
||||
updateSlotDeliverySequence,
|
||||
// Admin - Staff User
|
||||
getStaffUserByName,
|
||||
getAllStaff,
|
||||
getAllUsers,
|
||||
getUserWithDetails,
|
||||
updateUserSuspensionStatus,
|
||||
checkStaffUserExists,
|
||||
checkStaffRoleExists,
|
||||
createStaffUser,
|
||||
getAllRoles,
|
||||
// Admin - Store
|
||||
getAllStores,
|
||||
getStoreById,
|
||||
createStore,
|
||||
updateStore,
|
||||
deleteStore,
|
||||
// Admin - User
|
||||
createUserByMobile,
|
||||
getUserByMobile,
|
||||
getUnresolvedComplaintsCount,
|
||||
getAllUsersWithFilters,
|
||||
getOrderCountsByUserIds,
|
||||
getLastOrdersByUserIds,
|
||||
getSuspensionStatusesByUserIds,
|
||||
getUserBasicInfo,
|
||||
getUserSuspensionStatus,
|
||||
getUserOrders,
|
||||
getOrderStatusesByOrderIds,
|
||||
getItemCountsByOrderIds,
|
||||
upsertUserSuspension,
|
||||
searchUsers,
|
||||
getAllNotifCreds,
|
||||
getAllUnloggedTokens,
|
||||
getNotifTokensByUserIds,
|
||||
getUserIncidentsWithRelations,
|
||||
createUserIncident,
|
||||
// Admin - Vendor Snippets
|
||||
checkVendorSnippetExists,
|
||||
getVendorSnippetById,
|
||||
getVendorSnippetByCode,
|
||||
getAllVendorSnippets,
|
||||
createVendorSnippet,
|
||||
updateVendorSnippet,
|
||||
deleteVendorSnippet,
|
||||
getProductsByIds,
|
||||
getVendorSlotById,
|
||||
getVendorOrdersBySlotId,
|
||||
getOrderItemsByOrderIds,
|
||||
getOrderStatusByOrderIds,
|
||||
updateVendorOrderItemPackaging,
|
||||
getVendorOrders,
|
||||
// User - Address
|
||||
getUserDefaultAddress,
|
||||
getUserAddresses,
|
||||
getUserAddressById,
|
||||
clearUserDefaultAddress,
|
||||
createUserAddress,
|
||||
updateUserAddress,
|
||||
deleteUserAddress,
|
||||
hasOngoingOrdersForAddress,
|
||||
// User - Banners
|
||||
getUserActiveBanners,
|
||||
// User - Cart
|
||||
getUserCartItemsWithProducts,
|
||||
getUserProductById,
|
||||
getUserCartItemByUserProduct,
|
||||
incrementUserCartItemQuantity,
|
||||
insertUserCartItem,
|
||||
updateUserCartItemQuantity,
|
||||
deleteUserCartItem,
|
||||
clearUserCart,
|
||||
// User - Complaint
|
||||
getUserComplaints,
|
||||
createUserComplaint,
|
||||
// User - Stores
|
||||
getUserStoreSummaries,
|
||||
getUserStoreDetail,
|
||||
// User - Product
|
||||
getUserProductDetailById,
|
||||
getUserProductReviews,
|
||||
getUserProductByIdBasic,
|
||||
createUserProductReview,
|
||||
// User - Slots
|
||||
getUserActiveSlotsList,
|
||||
getUserProductAvailability,
|
||||
// User - Payments
|
||||
getUserPaymentOrderById,
|
||||
getUserPaymentByOrderId,
|
||||
getUserPaymentByMerchantOrderId,
|
||||
updateUserPaymentSuccess,
|
||||
updateUserOrderPaymentStatus,
|
||||
markUserPaymentFailed,
|
||||
// User - Auth
|
||||
getUserAuthByEmail,
|
||||
getUserAuthByMobile,
|
||||
getUserAuthById,
|
||||
getUserAuthCreds,
|
||||
getUserAuthDetails,
|
||||
createUserAuthWithCreds,
|
||||
createUserAuthWithMobile,
|
||||
upsertUserAuthPassword,
|
||||
deleteUserAuthAccount,
|
||||
// User - Coupon
|
||||
getUserActiveCouponsWithRelations,
|
||||
getUserAllCouponsWithRelations,
|
||||
getUserReservedCouponByCode,
|
||||
redeemUserReservedCoupon,
|
||||
// User - Profile
|
||||
getUserProfileById,
|
||||
getUserProfileDetailById,
|
||||
getUserWithCreds,
|
||||
getUserNotifCred,
|
||||
upsertUserNotifCred,
|
||||
deleteUserUnloggedToken,
|
||||
getUserUnloggedToken,
|
||||
upsertUserUnloggedToken,
|
||||
// User - Order
|
||||
validateAndGetUserCoupon,
|
||||
applyDiscountToUserOrder,
|
||||
getUserAddressByIdAndUser,
|
||||
getOrderProductById,
|
||||
checkUserSuspended,
|
||||
getUserSlotCapacityStatus,
|
||||
placeUserOrderTransaction,
|
||||
deleteUserCartItemsForOrder,
|
||||
recordUserCouponUsage,
|
||||
getUserOrdersWithRelations,
|
||||
getUserOrderCount,
|
||||
getUserOrderByIdWithRelations,
|
||||
getUserCouponUsageForOrder,
|
||||
getUserOrderBasic,
|
||||
cancelUserOrderTransaction,
|
||||
updateUserOrderNotes,
|
||||
getUserRecentlyDeliveredOrderIds,
|
||||
getUserProductIdsFromOrders,
|
||||
getUserProductsForRecentOrders,
|
||||
} from 'postgresService'
|
||||
Loading…
Add table
Reference in a new issue