mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 22:04:10 +00:00
Video Feature Implementation: - Add Videos and VideoCategories collections with multi-tenant support - Extend VideoBlock with library/upload/embed sources and playback options - Add featuredVideo group to Posts collection with processed embed URLs Hooks & Validation: - Add processFeaturedVideo hook for URL parsing and privacy mode embedding - Add createSlugValidationHook for tenant-scoped slug uniqueness - Add video-utils library (parseVideoUrl, generateEmbedUrl, formatDuration) Testing: - Add 84 unit tests for video-utils (URL parsing, duration, embed generation) - Add 14 integration tests for Videos collection CRUD and slug validation Database: - Migration for videos, video_categories tables with locales - Migration for Posts featuredVideo processed fields - Update payload internal tables for new collections 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
348 lines
10 KiB
TypeScript
348 lines
10 KiB
TypeScript
import { buildConfig } from 'payload'
|
|
import { postgresAdapter } from '@payloadcms/db-postgres'
|
|
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
|
|
import { seoPlugin } from '@payloadcms/plugin-seo'
|
|
import { nestedDocsPlugin } from '@payloadcms/plugin-nested-docs'
|
|
import { formBuilderPlugin } from '@payloadcms/plugin-form-builder'
|
|
import { redirectsPlugin } from '@payloadcms/plugin-redirects'
|
|
import { openapi, swaggerUI } from 'payload-oapi'
|
|
import { de } from '@payloadcms/translations/languages/de'
|
|
import { en } from '@payloadcms/translations/languages/en'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import sharp from 'sharp'
|
|
|
|
// Security: Validate required environment variables at startup
|
|
import { env } from './lib/envValidation'
|
|
|
|
import { Users } from './collections/Users'
|
|
import { Media } from './collections/Media'
|
|
import { Tenants } from './collections/Tenants'
|
|
import { Pages } from './collections/Pages'
|
|
import { Posts } from './collections/Posts'
|
|
import { Categories } from './collections/Categories'
|
|
import { SocialLinks } from './collections/SocialLinks'
|
|
import { Testimonials } from './collections/Testimonials'
|
|
import { FAQs } from './collections/FAQs'
|
|
import { Team } from './collections/Team'
|
|
import { ServiceCategories } from './collections/ServiceCategories'
|
|
import { Services } from './collections/Services'
|
|
import { NewsletterSubscribers } from './collections/NewsletterSubscribers'
|
|
|
|
// Portfolio Collections
|
|
import { PortfolioCategories } from './collections/PortfolioCategories'
|
|
import { Portfolios } from './collections/Portfolios'
|
|
|
|
// Video Collections
|
|
import { VideoCategories } from './collections/VideoCategories'
|
|
import { Videos } from './collections/Videos'
|
|
|
|
// Product Collections
|
|
import { ProductCategories } from './collections/ProductCategories'
|
|
import { Products } from './collections/Products'
|
|
|
|
// Timeline Collection
|
|
import { Timelines } from './collections/Timelines'
|
|
|
|
// Workflow Collection
|
|
import { Workflows } from './collections/Workflows'
|
|
|
|
// Blogging Collections
|
|
import { Tags } from './collections/Tags'
|
|
import { Authors } from './collections/Authors'
|
|
|
|
// New Feature Collections
|
|
import { Locations } from './collections/Locations'
|
|
import { Partners } from './collections/Partners'
|
|
import { Jobs } from './collections/Jobs'
|
|
import { Downloads } from './collections/Downloads'
|
|
import { Events } from './collections/Events'
|
|
|
|
// Tenant-specific Collections
|
|
import { Bookings } from './collections/Bookings'
|
|
import { Certifications } from './collections/Certifications'
|
|
import { Projects } from './collections/Projects'
|
|
|
|
// Consent Management Collections
|
|
import { CookieConfigurations } from './collections/CookieConfigurations'
|
|
import { CookieInventory } from './collections/CookieInventory'
|
|
import { ConsentLogs } from './collections/ConsentLogs'
|
|
import { PrivacyPolicySettings } from './collections/PrivacyPolicySettings'
|
|
|
|
import { SiteSettings } from './globals/SiteSettings'
|
|
import { Navigation } from './globals/Navigation'
|
|
import { SEOSettings } from './globals/SEOSettings'
|
|
|
|
// Hooks
|
|
import { sendFormNotification } from './hooks/sendFormNotification'
|
|
import { formSubmissionBeforeChange } from './hooks/formSubmissionHooks'
|
|
|
|
// Form Submissions Overrides
|
|
import { formSubmissionOverrides } from './collections/FormSubmissionsOverrides'
|
|
|
|
// Email
|
|
import { multiTenantEmailAdapter } from './lib/email/payload-email-adapter'
|
|
|
|
// Email Logs
|
|
import { EmailLogs } from './collections/EmailLogs'
|
|
|
|
// Audit Logs
|
|
import { AuditLogs } from './collections/AuditLogs'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfig({
|
|
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL || 'https://pl.c2sgmbh.de',
|
|
admin: {
|
|
user: Users.slug,
|
|
components: {
|
|
// Tenant-Kontext in der Admin-Header-Leiste anzeigen
|
|
afterNavLinks: ['@/components/admin/TenantBreadcrumb#TenantBreadcrumb'],
|
|
// Custom Views
|
|
views: {
|
|
// Tenant Self-Service Dashboard
|
|
tenantDashboard: {
|
|
Component: '@/components/admin/TenantDashboardView#TenantDashboardView',
|
|
path: '/tenant-dashboard',
|
|
meta: {
|
|
title: 'Tenant Dashboard',
|
|
description: 'E-Mail-Statistiken und Übersicht für Ihren Tenant',
|
|
},
|
|
},
|
|
},
|
|
// Navigation um Dashboard-Link zu ergänzen
|
|
beforeNavLinks: ['@/components/admin/DashboardNavLink#DashboardNavLink'],
|
|
},
|
|
},
|
|
// Multi-Tenant Email Adapter
|
|
email: multiTenantEmailAdapter,
|
|
// Admin Panel Internationalization (UI translations)
|
|
i18n: {
|
|
supportedLanguages: { de, en },
|
|
fallbackLanguage: 'de',
|
|
},
|
|
// Content Localization (multilingual content)
|
|
localization: {
|
|
locales: [
|
|
{
|
|
label: 'Deutsch',
|
|
code: 'de',
|
|
},
|
|
{
|
|
label: 'English',
|
|
code: 'en',
|
|
},
|
|
],
|
|
defaultLocale: 'de',
|
|
fallback: true,
|
|
},
|
|
// CORS Konfiguration für externe Frontends
|
|
cors: [
|
|
'http://localhost:3000',
|
|
'http://localhost:3001',
|
|
'http://10.10.180.153:3000',
|
|
'http://10.10.180.153:3001',
|
|
'https://dev.zh3.de',
|
|
'https://porwoll.de',
|
|
'https://www.porwoll.de',
|
|
],
|
|
// CSRF Protection
|
|
csrf: [
|
|
'http://localhost:3000',
|
|
'http://localhost:3001',
|
|
'http://10.10.180.153:3000',
|
|
'http://10.10.180.153:3001',
|
|
'https://dev.zh3.de',
|
|
'https://porwoll.de',
|
|
'https://www.porwoll.de',
|
|
],
|
|
collections: [
|
|
Users,
|
|
Media,
|
|
Tenants,
|
|
Pages,
|
|
Posts,
|
|
Categories,
|
|
SocialLinks,
|
|
Testimonials,
|
|
FAQs,
|
|
Team,
|
|
ServiceCategories,
|
|
Services,
|
|
NewsletterSubscribers,
|
|
// Portfolio
|
|
PortfolioCategories,
|
|
Portfolios,
|
|
// Videos
|
|
VideoCategories,
|
|
Videos,
|
|
// Products
|
|
ProductCategories,
|
|
Products,
|
|
// Timelines & Workflows
|
|
Timelines,
|
|
Workflows,
|
|
// Blogging
|
|
Tags,
|
|
Authors,
|
|
// New Feature Collections
|
|
Locations,
|
|
Partners,
|
|
Jobs,
|
|
Downloads,
|
|
Events,
|
|
// Tenant-specific Collections
|
|
Bookings,
|
|
Certifications,
|
|
Projects,
|
|
// Consent Management
|
|
CookieConfigurations,
|
|
CookieInventory,
|
|
ConsentLogs,
|
|
PrivacyPolicySettings,
|
|
// System
|
|
EmailLogs,
|
|
AuditLogs,
|
|
],
|
|
globals: [SiteSettings, Navigation, SEOSettings],
|
|
editor: lexicalEditor(),
|
|
secret: env.PAYLOAD_SECRET,
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
db: postgresAdapter({
|
|
pool: {
|
|
connectionString: env.DATABASE_URI,
|
|
},
|
|
// push: false - Schema-Änderungen nur via Migrationen
|
|
push: false,
|
|
}),
|
|
// Sharp für Bildoptimierung
|
|
sharp,
|
|
plugins: [
|
|
multiTenantPlugin({
|
|
tenantsSlug: 'tenants',
|
|
collections: {
|
|
media: {},
|
|
pages: {},
|
|
posts: {},
|
|
categories: {},
|
|
'social-links': {},
|
|
// Type assertion für neue Collections bis payload-types.ts regeneriert wird
|
|
...({
|
|
testimonials: {},
|
|
faqs: {},
|
|
team: {},
|
|
'service-categories': {},
|
|
services: {},
|
|
'newsletter-subscribers': {},
|
|
// Portfolio Collections
|
|
'portfolio-categories': {},
|
|
portfolios: {},
|
|
// Video Collections
|
|
'video-categories': {},
|
|
videos: {},
|
|
// Product Collections
|
|
'product-categories': {},
|
|
products: {},
|
|
// Timeline & Workflow Collections
|
|
timelines: {},
|
|
workflows: {},
|
|
// Blogging Collections
|
|
tags: {},
|
|
authors: {},
|
|
// New Feature Collections
|
|
locations: {},
|
|
partners: {},
|
|
jobs: {},
|
|
downloads: {},
|
|
events: {},
|
|
// Tenant-specific Collections
|
|
bookings: {},
|
|
certifications: {},
|
|
projects: {},
|
|
// Consent Management Collections - customTenantField: true weil sie bereits ein tenant-Feld haben
|
|
'cookie-configurations': { customTenantField: true },
|
|
'cookie-inventory': { customTenantField: true },
|
|
'consent-logs': { customTenantField: true },
|
|
'privacy-policy-settings': { customTenantField: true },
|
|
} as Record<string, { customTenantField?: boolean }>),
|
|
},
|
|
// Super Admins haben Zugriff auf alle Tenants
|
|
userHasAccessToAllTenants: (user) => Boolean(user?.isSuperAdmin),
|
|
debug: true,
|
|
// Deutsche Übersetzungen für den Tenant-Selector
|
|
i18n: {
|
|
translations: {
|
|
de: {
|
|
'nav-tenantSelector-label': 'Nach Tenant filtern',
|
|
'assign-tenant-button-label': 'Tenant zuweisen',
|
|
'assign-tenant-modal-title': '"{{title}}" zuweisen',
|
|
'field-assignedTenant-label': 'Zugewiesener Tenant',
|
|
},
|
|
en: {
|
|
'nav-tenantSelector-label': 'Filter by Tenant',
|
|
'assign-tenant-button-label': 'Assign Tenant',
|
|
'assign-tenant-modal-title': 'Assign "{{title}}"',
|
|
'field-assignedTenant-label': 'Assigned Tenant',
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
seoPlugin({
|
|
collections: [],
|
|
uploadsCollection: 'media',
|
|
generateTitle: ({ doc }) => `${doc?.title || ''} | Website`,
|
|
generateDescription: ({ doc }) => doc?.excerpt || '',
|
|
}),
|
|
nestedDocsPlugin({
|
|
collections: [],
|
|
generateLabel: (_, doc) => doc.title as string,
|
|
generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''),
|
|
}),
|
|
formBuilderPlugin({
|
|
fields: {
|
|
text: true,
|
|
textarea: true,
|
|
select: true,
|
|
email: true,
|
|
state: false,
|
|
country: false,
|
|
checkbox: true,
|
|
number: true,
|
|
message: true,
|
|
payment: false,
|
|
},
|
|
// Fix für TypeScript Types Generation - das Plugin braucht explizite relationTo Angaben
|
|
redirectRelationships: ['pages'],
|
|
formSubmissionOverrides: {
|
|
...(formSubmissionOverrides as Record<string, unknown>),
|
|
hooks: {
|
|
beforeChange: [formSubmissionBeforeChange],
|
|
afterChange: [sendFormNotification],
|
|
},
|
|
} as Parameters<typeof formBuilderPlugin>[0]['formSubmissionOverrides'],
|
|
}),
|
|
redirectsPlugin({
|
|
collections: ['pages'],
|
|
overrides: {
|
|
admin: {
|
|
group: 'Einstellungen',
|
|
},
|
|
},
|
|
}),
|
|
// OpenAPI Documentation
|
|
openapi({
|
|
openapiVersion: '3.1',
|
|
metadata: {
|
|
title: 'Payload CMS API',
|
|
version: '1.0.0',
|
|
description: 'Multi-Tenant CMS API für porwoll.de, complexcaresolutions.de, gunshin.de und zweitmein.ng',
|
|
},
|
|
}),
|
|
// Swagger UI unter /api/docs
|
|
swaggerUI({}),
|
|
],
|
|
})
|