From d449da69152f293deba3dbc693b41ce56b9b9356 Mon Sep 17 00:00:00 2001 From: Martin Porwoll Date: Tue, 16 Dec 2025 11:50:32 +0000 Subject: [PATCH] fix: resolve TypeScript and lint errors in video feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix slug-validation.ts: Use proper Where type from Payload - Fix processFeaturedVideo.ts: Remove TypeWithID constraint, use type casting - Fix retention-worker.ts: Remove unused import cleanupExpiredConsentLogs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/hooks/processFeaturedVideo.ts | 13 ++++++----- src/lib/queue/workers/retention-worker.ts | 1 - src/lib/validation/slug-validation.ts | 28 +++++++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/hooks/processFeaturedVideo.ts b/src/hooks/processFeaturedVideo.ts index a4f50ef..7676427 100644 --- a/src/hooks/processFeaturedVideo.ts +++ b/src/hooks/processFeaturedVideo.ts @@ -25,7 +25,7 @@ interface FeaturedVideoData { thumbnailUrl?: string } -interface PostData { +interface PostDataInput { featuredVideo?: FeaturedVideoData [key: string]: unknown } @@ -37,16 +37,17 @@ interface PostData { * - Generiert normalisierte Embed-URL mit Privacy-Mode (youtube-nocookie) * - Speichert Thumbnail-URL für Fallback */ -export const processFeaturedVideo: CollectionBeforeChangeHook = async ({ +export const processFeaturedVideo: CollectionBeforeChangeHook = async ({ data, - operation, }) => { + const postData = data as PostDataInput | undefined + // Nur wenn featuredVideo existiert und aktiviert ist - if (!data?.featuredVideo?.enabled) { + if (!postData?.featuredVideo?.enabled) { return data } - const featuredVideo = data.featuredVideo + const featuredVideo = postData.featuredVideo // Nur für embed source verarbeiten if (featuredVideo.source !== 'embed' || !featuredVideo.embedUrl) { @@ -82,7 +83,7 @@ export const processFeaturedVideo: CollectionBeforeChangeHook = async } return { - ...data, + ...postData, featuredVideo, } } diff --git a/src/lib/queue/workers/retention-worker.ts b/src/lib/queue/workers/retention-worker.ts index 6f91165..a968d51 100644 --- a/src/lib/queue/workers/retention-worker.ts +++ b/src/lib/queue/workers/retention-worker.ts @@ -11,7 +11,6 @@ import { QUEUE_NAMES, getQueueRedisConnection } from '../queue-service' import type { RetentionJobData, RetentionJobResult } from '../jobs/retention-job' import { cleanupCollection, - cleanupExpiredConsentLogs, cleanupOrphanedMedia, runFullRetention, } from '../../retention/cleanup-service' diff --git a/src/lib/validation/slug-validation.ts b/src/lib/validation/slug-validation.ts index 3002737..fd0352f 100644 --- a/src/lib/validation/slug-validation.ts +++ b/src/lib/validation/slug-validation.ts @@ -4,10 +4,11 @@ * Stellt sicher, dass Slugs innerhalb eines Tenants eindeutig sind. */ -import type { Payload } from 'payload' +import type { Payload, Where } from 'payload' import type { Config } from '@/payload-types' type CollectionSlug = keyof Config['collections'] +type LocaleType = 'de' | 'en' | 'all' | undefined export interface SlugValidationOptions { /** Collection slug */ @@ -51,27 +52,30 @@ export async function validateUniqueSlug( } // Build where clause - const where: Record = { - [slugField]: { equals: slug }, - } + const conditions: Where[] = [{ [slugField]: { equals: slug } }] // Add tenant filter if tenant is set if (tenantId) { - where[tenantField] = { equals: tenantId } + conditions.push({ [tenantField]: { equals: tenantId } }) } // Exclude current document when updating if (existingId) { - where.id = { not_equals: existingId } + conditions.push({ id: { not_equals: existingId } }) } + const where: Where = conditions.length > 1 ? { and: conditions } : conditions[0] + + // Determine locale for query + const queryLocale: LocaleType = perLocale && locale ? (locale as LocaleType) : undefined + // Check for existing documents with same slug const existing = await payload.find({ collection, where, limit: 1, depth: 0, - locale: perLocale ? locale : undefined, + locale: queryLocale, }) if (existing.totalDocs > 0) { @@ -125,18 +129,18 @@ export async function generateUniqueSlug( let isUnique = false while (!isUnique && counter < 100) { - const where: Record = { - [slugField]: { equals: slug }, - } + const conditions: Where[] = [{ [slugField]: { equals: slug } }] if (tenantId) { - where[tenantField] = { equals: tenantId } + conditions.push({ [tenantField]: { equals: tenantId } }) } if (existingId) { - where.id = { not_equals: existingId } + conditions.push({ id: { not_equals: existingId } }) } + const where: Where = conditions.length > 1 ? { and: conditions } : conditions[0] + const existing = await payload.find({ collection, where,