CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
- Products collection (interim mirror of the PLATFM-14 catalogue contract): lifecycle status, product type, required whole-forint net price, yearly billing, service definition, per-product English gate - HostingPlans global: page copy, comparison labels, VAT rate (27%) - Gate: production shows only active plans, staging all but retired; with no showable plan the page is 404 and left out of the menu and the sitemap - /hu/tarhely-csomagok <-> /en/hosting-plans via PAGE_SLUGS (hreflang, language switcher, CTA page picker) - Seed migration 20260929_hosting_plans: mIT Start (14 900 Ft/yr, 5 mailboxes) and mIT Mid (23 900 Ft/yr) as drafts, English AI draft; idempotent - Production SEO suite expects at least 12 sitemap URLs; new SMOKE-10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
152 lines
5.5 KiB
TypeScript
152 lines
5.5 KiB
TypeScript
/**
|
|
* MITHOME-91: Payload Local API adat-adapter réteg.
|
|
*
|
|
* WHY adapterek: a Payload Globals/Collections mezői (stringArrayField,
|
|
* lásd src/globals/fields/stringArray.ts) `{ value: string }[]` alakban
|
|
* tárolják azt, ami a JSON content rendszerben egyszerű `string[]` volt.
|
|
* Ezek a getterek visszaadaptálják az eredeti alakra, hogy a page
|
|
* komponensek JSX-e (ami a régi content/types.ts formát várja) NE
|
|
* változzon — csak az adatforrás.
|
|
*
|
|
* MITHOME-113: minden olvasás a fordítási kapun megy át (readGated) — az
|
|
* angol oldal csak jóváhagyott angol fordítást mutat, különben a magyart.
|
|
* A `locale` paraméter a linkfeloldáshoz (CTA) változatlanul a kért nyelv.
|
|
*/
|
|
import { getPayload } from 'payload'
|
|
import config from '@payload-config'
|
|
import { DEFAULT_LOCALE, type Locale } from './i18n'
|
|
import { resolveCtaHref, type CtaLink } from './cta-link'
|
|
import { readGated } from './translation-gate'
|
|
import { publicPartners, type PartnerView } from './partner-references'
|
|
import { hostingPlanViews, showableStatuses, type HostingPlanView, type ProductDoc } from './products'
|
|
|
|
let cached: ReturnType<typeof getPayload> | undefined
|
|
|
|
function payloadClient() {
|
|
cached ??= getPayload({ config })
|
|
return cached
|
|
}
|
|
|
|
/** MITHOME-123: internal CTA targets are stored as a page, resolved per locale. */
|
|
function withHref<T extends CtaLink>(link: T, locale: Locale): T & { href: string } {
|
|
return { ...link, href: resolveCtaHref(link, locale) }
|
|
}
|
|
|
|
function unwrap(items: readonly { value: string }[] | null | undefined): string[] {
|
|
return (items ?? []).map((item) => item.value)
|
|
}
|
|
|
|
export async function getCommonContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
return readGated(locale, (l) => payload.findGlobal({ slug: 'common', locale: l }))
|
|
}
|
|
|
|
export async function getHomeContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
const home = await readGated(locale, (l) => payload.findGlobal({ slug: 'home', locale: l }))
|
|
return {
|
|
...home,
|
|
hero: {
|
|
...home.hero,
|
|
trustBullets: unwrap(home.hero?.trustBullets),
|
|
cta: {
|
|
primary: withHref(home.hero.cta.primary, locale),
|
|
secondary: withHref(home.hero.cta.secondary, locale),
|
|
},
|
|
},
|
|
services: {
|
|
...home.services,
|
|
items: (home.services?.items ?? []).map((item) => ({
|
|
...item,
|
|
features: unwrap(item.features),
|
|
})),
|
|
},
|
|
}
|
|
}
|
|
|
|
export async function getAboutContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
const about = await readGated(locale, (l) => payload.findGlobal({ slug: 'about', locale: l }))
|
|
return {
|
|
...about,
|
|
story: { ...about.story, paragraphs: unwrap(about.story?.paragraphs) },
|
|
team: { ...about.team, paragraphs: unwrap(about.team?.paragraphs) },
|
|
}
|
|
}
|
|
|
|
export async function getServicesContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
const services = await readGated(locale, (l) => payload.findGlobal({ slug: 'services', locale: l }))
|
|
return {
|
|
...services,
|
|
details: {
|
|
...services.details,
|
|
services: (services.details?.services ?? []).map((service) => ({
|
|
...service,
|
|
specs: { ...service.specs, items: unwrap(service.specs?.items) },
|
|
})),
|
|
},
|
|
}
|
|
}
|
|
|
|
export async function getContactContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
return readGated(locale, (l) => payload.findGlobal({ slug: 'contact', locale: l }))
|
|
}
|
|
|
|
export async function getLegalPage(slug: 'adatvedelem' | 'hasznalati-feltetelek', locale: Locale) {
|
|
const payload = await payloadClient()
|
|
return readGated(locale, async (l) => {
|
|
const result = await payload.find({
|
|
collection: 'legal-pages',
|
|
where: { slug: { equals: slug } },
|
|
locale: l,
|
|
limit: 1,
|
|
})
|
|
return result.docs[0]
|
|
})
|
|
}
|
|
|
|
export type { PartnerView } from './partner-references'
|
|
|
|
/** MITHOME-131: only entries with a written permission, a category and a logo. */
|
|
export async function getPartners(): Promise<PartnerView[]> {
|
|
const payload = await payloadClient()
|
|
const result = await payload.find({ collection: 'partners', limit: 100, sort: 'name', depth: 1 })
|
|
return publicPartners(result.docs)
|
|
}
|
|
|
|
export type { HostingPlanView } from './products'
|
|
|
|
/** MITHOME-130: raw hosting products in one locale, lifecycle-gated in the query. */
|
|
async function findHostingProducts(locale: Locale): Promise<ProductDoc[]> {
|
|
const payload = await payloadClient()
|
|
const result = await payload.find({
|
|
collection: 'products',
|
|
where: { productType: { equals: 'hosting' }, status: { in: showableStatuses() } },
|
|
sort: 'sortOrder',
|
|
locale,
|
|
limit: 50,
|
|
depth: 0,
|
|
})
|
|
return result.docs as unknown as ProductDoc[]
|
|
}
|
|
|
|
/** MITHOME-130: showable hosting plans; the English gate works per product. */
|
|
export async function getHostingPlans(locale: Locale): Promise<HostingPlanView[]> {
|
|
const requested = await findHostingProducts(locale)
|
|
const needsFallback = locale !== DEFAULT_LOCALE && requested.some((doc) => doc.enTranslationStatus !== 'approved')
|
|
const fallback = needsFallback ? await findHostingProducts(DEFAULT_LOCALE) : []
|
|
return hostingPlanViews(locale, requested, fallback)
|
|
}
|
|
|
|
/** The page, the menu item and the sitemap entry all follow this one gate. */
|
|
export async function hasHostingPlans(): Promise<boolean> {
|
|
return (await getHostingPlans(DEFAULT_LOCALE)).length > 0
|
|
}
|
|
|
|
export async function getHostingPlansContent(locale: Locale) {
|
|
const payload = await payloadClient()
|
|
return readGated(locale, (l) => payload.findGlobal({ slug: 'hosting-plans', locale: l }))
|
|
}
|