From 5d2e33e3699e0e69b018d7869e3dc0269f449505 Mon Sep 17 00:00:00 2001 From: Rob Walsh Date: Mon, 9 Mar 2026 13:52:18 -0600 Subject: [PATCH] feat: Add user ID parameter to shelf synchronization jobs and improve Prisma query type safety for shelf where clauses. --- src/lib/hooks/useShelves.ts | 2 ++ src/lib/services/goodreads-sync.service.ts | 3 ++- src/lib/services/hardcover-sync.service.ts | 4 ++-- src/lib/services/job-queue.service.ts | 8 +++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/hooks/useShelves.ts b/src/lib/hooks/useShelves.ts index d47e0e5..20e8060 100644 --- a/src/lib/hooks/useShelves.ts +++ b/src/lib/hooks/useShelves.ts @@ -2,6 +2,8 @@ * Component: Shelves Hook * Documentation: documentation/frontend/components.md */ +'use client'; + import { useState } from 'react'; import useSWR, { mutate } from 'swr'; import { useAuth } from '@/contexts/AuthContext'; diff --git a/src/lib/services/goodreads-sync.service.ts b/src/lib/services/goodreads-sync.service.ts index 564a3b1..b59382e 100644 --- a/src/lib/services/goodreads-sync.service.ts +++ b/src/lib/services/goodreads-sync.service.ts @@ -9,6 +9,7 @@ import axios from 'axios'; import { XMLParser } from 'fast-xml-parser'; import { prisma } from '@/lib/db'; +import { Prisma } from '@/generated/prisma/client'; import { RMABLogger } from '@/lib/utils/logger'; import { ShelfBook, @@ -118,7 +119,7 @@ export async function processGoodreadsShelves( const stats = createEmptyStats(); const maxLookups = resolveMaxLookups(options); - const whereClause: any = {}; + const whereClause: Prisma.GoodreadsShelfWhereInput = {}; if (options.shelfId) whereClause.id = options.shelfId; if (options.userId) whereClause.userId = options.userId; diff --git a/src/lib/services/hardcover-sync.service.ts b/src/lib/services/hardcover-sync.service.ts index 0aab48e..56fc9da 100644 --- a/src/lib/services/hardcover-sync.service.ts +++ b/src/lib/services/hardcover-sync.service.ts @@ -7,6 +7,7 @@ */ import { prisma } from '@/lib/db'; +import { Prisma } from '@/generated/prisma/client'; import { getEncryptionService } from '@/lib/services/encryption.service'; import { RMABLogger } from '@/lib/utils/logger'; import { fetchHardcoverList, HardcoverApiBook } from '@/lib/services/hardcover-api.service'; @@ -38,8 +39,7 @@ export async function processHardcoverShelves( const log = jobLogger || logger; const stats = createEmptyStats(); const maxLookups = resolveMaxLookups(options); - - const whereClause: any = {}; + const whereClause: Prisma.HardcoverShelfWhereInput = {}; if (options.shelfId) whereClause.id = options.shelfId; if (options.userId) whereClause.userId = options.userId; diff --git a/src/lib/services/job-queue.service.ts b/src/lib/services/job-queue.service.ts index 6303195..6a905e6 100644 --- a/src/lib/services/job-queue.service.ts +++ b/src/lib/services/job-queue.service.ts @@ -771,7 +771,13 @@ export class JobQueueService { /** * Add sync reading shelves job */ - async addSyncShelvesJob(scheduledJobId?: string, shelfId?: string, shelfType?: 'goodreads' | 'hardcover', maxLookupsPerShelf?: number): Promise { + async addSyncShelvesJob( + scheduledJobId?: string, + shelfId?: string, + shelfType?: 'goodreads' | 'hardcover', + maxLookupsPerShelf?: number, + userId?: string + ): Promise { return await this.addJob( 'sync_reading_shelves', {