Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef7927e38 | ||
|
|
a7846d9770 | ||
|
|
015092e773 | ||
|
|
f4d969ad29 | ||
|
|
fad5d778e8 | ||
|
|
0f073b963e | ||
|
|
54c2d64cce | ||
|
|
e29c919e5e | ||
|
|
0f6bbd597b | ||
|
|
65437a144b | ||
|
|
e7ad64230a | ||
|
|
5af5033148 | ||
|
|
7572ec0c04 | ||
|
|
a24777b915 | ||
|
|
562e7f2244 | ||
|
|
80d8b7102c | ||
|
|
0ccc7e5064 | ||
|
|
3d467d7350 | ||
|
|
db05fe814b | ||
|
|
42df05af28 | ||
|
|
089b3a29ba | ||
|
|
ab16d459ed | ||
|
|
786dd346a9 |
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env node
|
||||
// ipal-skills — copies the ipal-kit agent skills into the project.
|
||||
// pnpm ipal-skills → ./.agents/skills/ipal-*
|
||||
// pnpm ipal-skills --dry-run → show what would change
|
||||
// pnpm ipal-skills --dest .claude/skills
|
||||
// Only folders named ipal-* are touched; the project's own skills stay as they are.
|
||||
// ipal-* folders that no longer exist in the package are removed (renamed/retired skills).
|
||||
|
||||
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs'
|
||||
import { dirname, join, relative, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
if (args.includes('--help') || args.includes('-h')) {
|
||||
console.log('Usage: ipal-skills [--dest <dir>] [--dry-run]\nDefault dest: .agents/skills')
|
||||
process.exit(0)
|
||||
}
|
||||
const dryRun = args.includes('--dry-run')
|
||||
const destArg = args.indexOf('--dest')
|
||||
const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] ?? '' : '.agents/skills')
|
||||
|
||||
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const src = join(pkgRoot, 'docs', 'agent', 'skills')
|
||||
if (!existsSync(src)) {
|
||||
console.error(`ipal-skills: no skills found in ${src} — is @intecion/ipal-kit installed with docs?`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory()
|
||||
const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
|
||||
const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
|
||||
const retired = existing.filter((n) => !shipped.includes(n))
|
||||
|
||||
if (!dryRun) mkdirSync(dest, { recursive: true })
|
||||
for (const name of shipped) {
|
||||
const action = existing.includes(name) ? 'update' : 'add '
|
||||
console.log(`${action} ${name}`)
|
||||
if (!dryRun) {
|
||||
rmSync(join(dest, name), { recursive: true, force: true }) // drop files removed upstream
|
||||
cpSync(join(src, name), join(dest, name), { recursive: true })
|
||||
}
|
||||
}
|
||||
for (const name of retired) {
|
||||
console.log(`remove ${name} (no longer in ipal-kit)`)
|
||||
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
|
||||
}
|
||||
console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
|
||||
|
||||
// Skills ship .ts/.tsx templates and scripts. A Next tsconfig ("include": ["**/*.tsx"]) would
|
||||
// type-check them as project code and break `tsc` / `next build` → they must be excluded.
|
||||
const tsconfig = join(process.cwd(), 'tsconfig.json')
|
||||
const top = relative(process.cwd(), dest).split(/[\\/]/)[0]
|
||||
if (existsSync(tsconfig) && top && !top.startsWith('..')) {
|
||||
const text = readFileSync(tsconfig, 'utf8')
|
||||
const exclude = text.match(/"exclude"\s*:\s*\[([^\]]*)\]/)?.[1] ?? ''
|
||||
if (!exclude.includes(top)) {
|
||||
console.warn(`\n⚠ tsconfig.json does not exclude "${top}" — skill templates would be type-checked and break the build.`)
|
||||
console.warn(` Add it: "exclude": ["node_modules", "${top}"]`)
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
Vendored
+2
-1
@@ -1,7 +1,8 @@
|
||||
export { RowLabel } from '../modules/admin-ui/RowLabelComponent.js';
|
||||
/**
|
||||
* Entry point: @intecion/ipal-kit/admin
|
||||
*
|
||||
* Admin-panel UI components (white-label branding). Separate export so Payload's
|
||||
* Admin-panel UI components (white-label branding, array row labels). Separate export so Payload's
|
||||
* importMap can resolve them by a stable path when ipalKit injects
|
||||
* admin.components.graphics.Logo/Icon.
|
||||
*/
|
||||
|
||||
Vendored
+2
-1
@@ -1,7 +1,8 @@
|
||||
export { RowLabel } from '../modules/admin-ui/RowLabelComponent.js';
|
||||
/**
|
||||
* Entry point: @intecion/ipal-kit/admin
|
||||
*
|
||||
* Admin-panel UI components (white-label branding). Separate export so Payload's
|
||||
* Admin-panel UI components (white-label branding, array row labels). Separate export so Payload's
|
||||
* importMap can resolve them by a stable path when ipalKit injects
|
||||
* admin.components.graphics.Logo/Icon.
|
||||
*/ export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js';
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/exports/admin.ts"],"sourcesContent":["/**\n * Entry point: @intecion/ipal-kit/admin\n *\n * Admin-panel UI components (white-label branding). Separate export so Payload's\n * importMap can resolve them by a stable path when ipalKit injects\n * admin.components.graphics.Logo/Icon.\n */\nexport { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'\n"],"names":["AdminIcon","AdminLogo","IntecionCredit"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,SAAS,EAAEC,SAAS,EAAEC,cAAc,QAAQ,+BAA8B"}
|
||||
{"version":3,"sources":["../../src/exports/admin.ts"],"sourcesContent":["export { RowLabel } from '../modules/admin-ui/RowLabelComponent.js'\n/**\n * Entry point: @intecion/ipal-kit/admin\n *\n * Admin-panel UI components (white-label branding, array row labels). Separate export so Payload's\n * importMap can resolve them by a stable path when ipalKit injects\n * admin.components.graphics.Logo/Icon.\n */\nexport { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'\n"],"names":["RowLabel","AdminIcon","AdminLogo","IntecionCredit"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2CAA0C;AACnE;;;;;;CAMC,GACD,SAASC,SAAS,EAAEC,SAAS,EAAEC,cAAc,QAAQ,+BAA8B"}
|
||||
Vendored
+4
-3
@@ -1,11 +1,11 @@
|
||||
export { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js';
|
||||
export { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js';
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility, } from '../modules/accessibility/client.js';
|
||||
export { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js';
|
||||
export type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js';
|
||||
export { Analytics } from '../modules/analytics/client.js';
|
||||
export type { AnalyticsProps } from '../modules/analytics/client.js';
|
||||
export { pushDataLayer } from '../modules/analytics/client.js';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok, } from '../modules/analytics/client.js';
|
||||
export { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from '../modules/analytics/client.js';
|
||||
/**
|
||||
* Entry point: ipal-kit/client
|
||||
*
|
||||
@@ -19,7 +19,7 @@ export { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js';
|
||||
export type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js';
|
||||
export { useContactForm } from '../modules/forms/useContactForm.js';
|
||||
export type { ContactFormErrors, ContactFormValues, SubmitAction, } from '../modules/forms/useContactForm.js';
|
||||
export type { ContactFormErrors, ContactFormValues, SubmitAction } from '../modules/forms/useContactForm.js';
|
||||
export { useForm } from '../modules/forms/useForm.js';
|
||||
export type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js';
|
||||
export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required, } from '../modules/forms/validators.js';
|
||||
@@ -28,6 +28,7 @@ export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath
|
||||
export type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js';
|
||||
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks, } from '../modules/i18n/index.js';
|
||||
export type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js';
|
||||
export { LocaleView } from '../modules/pages/LocaleView.js';
|
||||
export { Turnstile } from '../modules/turnstile/client.js';
|
||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||
export type { TurnstileProps } from '../modules/turnstile/client.js';
|
||||
|
||||
Vendored
+1
@@ -21,6 +21,7 @@ export { buildValidator, checked, custom, email, isEmail, maxLength, minLength,
|
||||
// components (e.g. a LanguageSwitcher that computes locale URLs on the client).
|
||||
export { buildLocalizedPath, getLocaleCodes, getLocalizedSlugs, switchLocalePath } from '../modules/i18n/index.js';
|
||||
export { AlternateLinksProvider, AlternateLinksUpdater, LanguageSwitcher, useAlternateLinks, useSetAlternateLinks } from '../modules/i18n/index.js';
|
||||
export { LocaleView } from '../modules/pages/LocaleView.js';
|
||||
export { Turnstile } from '../modules/turnstile/client.js';
|
||||
export { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport {\n AccessibilityProvider,\n AccessibilityWidget,\n useAccessibility,\n} from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\nexport { Analytics } from '../modules/analytics/client.js'\nexport type { AnalyticsProps } from '../modules/analytics/client.js'\n\nexport { pushDataLayer } from '../modules/analytics/client.js'\nexport {\n loadClarity,\n loadLinkedIn,\n loadMetaPixel,\n loadTikTok,\n} from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n ConsentScript,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\nexport { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'\nexport type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'\nexport { useContactForm } from '../modules/forms/useContactForm.js'\nexport type {\n ContactFormErrors,\n ContactFormValues,\n SubmitAction,\n} from '../modules/forms/useContactForm.js'\nexport { useForm } from '../modules/forms/useForm.js'\nexport type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js'\nexport {\n buildValidator,\n checked,\n custom,\n email,\n isEmail,\n maxLength,\n minLength,\n pattern,\n required,\n} from '../modules/forms/validators.js'\nexport type { Rule } from '../modules/forms/validators.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport {\n AlternateLinksProvider,\n AlternateLinksUpdater,\n LanguageSwitcher,\n useAlternateLinks,\n useSetAlternateLinks,\n} from '../modules/i18n/index.js'\nexport type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","pushDataLayer","loadClarity","loadLinkedIn","loadMetaPixel","loadTikTok","ConsentProvider","ConsentScript","CookieBanner","CookieButton","useConsent","useConsentContext","formAnalyticsOnSuccess","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","useContactForm","useForm","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","AlternateLinksProvider","AlternateLinksUpdater","LanguageSwitcher","useAlternateLinks","useSetAlternateLinks","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SACEC,qBAAqB,EACrBC,mBAAmB,EACnBC,gBAAgB,QACX,qCAAoC;AAE3C,SAASC,SAAS,QAAQ,iCAAgC;AAG1D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SACEC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,UAAU,QACL,iCAAgC;AACvC;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,SAASC,sBAAsB,QAAQ,oCAAmC;AAE1E,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,+BAA8B;AACpG,SAASC,cAAc,QAAQ,qCAAoC;AAMnE,SAASC,OAAO,QAAQ,8BAA6B;AAErD,SACEC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,iCAAgC;AAEvC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,QACf,2BAA0B;AAEjC,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["'use client'\nexport { MaskedField } from '../globals/SiteIntegrations/components/MaskedField.js'\nexport { TestEmailButton } from '../globals/SiteIntegrations/components/TestEmailButton.js'\nexport { AccessibilityProvider, AccessibilityWidget, useAccessibility } from '../modules/accessibility/client.js'\nexport type { A11yClassNames, A11yState, A11yTexts } from '../modules/accessibility/client.js'\nexport { Analytics } from '../modules/analytics/client.js'\nexport type { AnalyticsProps } from '../modules/analytics/client.js'\n\nexport { pushDataLayer } from '../modules/analytics/client.js'\nexport { loadClarity, loadLinkedIn, loadMetaPixel, loadTikTok } from '../modules/analytics/client.js'\n/**\n * Entry point: ipal-kit/client\n *\n * Client-side ('use client') exports — React hooks, providers, and UI\n * components. Kept separate from the main entry so server bundles don't pull in\n * client-only code.\n */\nexport {\n ConsentProvider,\n ConsentScript,\n CookieBanner,\n CookieButton,\n useConsent,\n useConsentContext,\n} from '../modules/consent/client.js'\nexport type { CookieBannerClassNames } from '../modules/consent/client.js'\nexport { formAnalyticsOnSuccess } from '../modules/forms/formAnalytics.js'\nexport type { FormAnalyticsConfig } from '../modules/forms/formAnalytics.js'\nexport { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from '../modules/forms/honeypot.js'\nexport { useContactForm } from '../modules/forms/useContactForm.js'\nexport type { ContactFormErrors, ContactFormValues, SubmitAction } from '../modules/forms/useContactForm.js'\nexport { useForm } from '../modules/forms/useForm.js'\nexport type { FormErrors, FormSubmitAction, Validator } from '../modules/forms/useForm.js'\nexport {\n buildValidator,\n checked,\n custom,\n email,\n isEmail,\n maxLength,\n minLength,\n pattern,\n required,\n} from '../modules/forms/validators.js'\nexport type { Rule } from '../modules/forms/validators.js'\n// Pure i18n path helpers — no server/RSC deps, safe to import in client\n// components (e.g. a LanguageSwitcher that computes locale URLs on the client).\nexport {\n buildLocalizedPath,\n getLocaleCodes,\n getLocalizedSlugs,\n switchLocalePath,\n} from '../modules/i18n/index.js'\nexport type { I18nConfig, LocalizedSlugs } from '../modules/i18n/index.js'\nexport {\n AlternateLinksProvider,\n AlternateLinksUpdater,\n LanguageSwitcher,\n useAlternateLinks,\n useSetAlternateLinks,\n} from '../modules/i18n/index.js'\nexport type { AlternateLinks, LanguageSwitcherClassNames } from '../modules/i18n/index.js'\nexport { LocaleView } from '../modules/pages/LocaleView.js'\nexport { Turnstile } from '../modules/turnstile/client.js'\nexport { TurnstileProvider, useTurnstile } from '../modules/turnstile/client.js'\nexport type { TurnstileProps } from '../modules/turnstile/client.js'\n"],"names":["MaskedField","TestEmailButton","AccessibilityProvider","AccessibilityWidget","useAccessibility","Analytics","pushDataLayer","loadClarity","loadLinkedIn","loadMetaPixel","loadTikTok","ConsentProvider","ConsentScript","CookieBanner","CookieButton","useConsent","useConsentContext","formAnalyticsOnSuccess","HONEYPOT_FIELD","honeypotInputProps","isHoneypotTripped","useContactForm","useForm","buildValidator","checked","custom","email","isEmail","maxLength","minLength","pattern","required","buildLocalizedPath","getLocaleCodes","getLocalizedSlugs","switchLocalePath","AlternateLinksProvider","AlternateLinksUpdater","LanguageSwitcher","useAlternateLinks","useSetAlternateLinks","LocaleView","Turnstile","TurnstileProvider","useTurnstile"],"mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,wDAAuD;AACnF,SAASC,eAAe,QAAQ,4DAA2D;AAC3F,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,gBAAgB,QAAQ,qCAAoC;AAEjH,SAASC,SAAS,QAAQ,iCAAgC;AAG1D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,WAAW,EAAEC,YAAY,EAAEC,aAAa,EAAEC,UAAU,QAAQ,iCAAgC;AACrG;;;;;;CAMC,GACD,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACZ,+BAA8B;AAErC,SAASC,sBAAsB,QAAQ,oCAAmC;AAE1E,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,+BAA8B;AACpG,SAASC,cAAc,QAAQ,qCAAoC;AAEnE,SAASC,OAAO,QAAQ,8BAA6B;AAErD,SACEC,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,iCAAgC;AAEvC,wEAAwE;AACxE,gFAAgF;AAChF,SACEC,kBAAkB,EAClBC,cAAc,EACdC,iBAAiB,EACjBC,gBAAgB,QACX,2BAA0B;AAEjC,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,QACf,2BAA0B;AAEjC,SAASC,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,iCAAgC"}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Entry point: @intecion/ipal-kit/env
|
||||
*
|
||||
* Environment validation ONLY — zero imports beyond this module, no Payload,
|
||||
* no Node built-ins, no React. Safe for Next's instrumentation.ts, which Next
|
||||
* also compiles for the Edge runtime: importing the package root there drags in
|
||||
* Payload / file-type / fs and crashes Turbopack ("Export fileTypeFromFile
|
||||
* doesn't exist in target module").
|
||||
*
|
||||
* // src/instrumentation.ts
|
||||
* import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
|
||||
* export function register() {
|
||||
* if (process.env.NEXT_RUNTIME === 'nodejs') assertEnv(ipalEnvRules({ storage: true }))
|
||||
* }
|
||||
*/
|
||||
export { assertEnv, ipalEnvRules } from '../modules/env/index.js';
|
||||
export type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from '../modules/env/index.js';
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Entry point: @intecion/ipal-kit/env
|
||||
*
|
||||
* Environment validation ONLY — zero imports beyond this module, no Payload,
|
||||
* no Node built-ins, no React. Safe for Next's instrumentation.ts, which Next
|
||||
* also compiles for the Edge runtime: importing the package root there drags in
|
||||
* Payload / file-type / fs and crashes Turbopack ("Export fileTypeFromFile
|
||||
* doesn't exist in target module").
|
||||
*
|
||||
* // src/instrumentation.ts
|
||||
* import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
|
||||
* export function register() {
|
||||
* if (process.env.NEXT_RUNTIME === 'nodejs') assertEnv(ipalEnvRules({ storage: true }))
|
||||
* }
|
||||
*/ export { assertEnv, ipalEnvRules } from '../modules/env/index.js';
|
||||
|
||||
//# sourceMappingURL=env.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/exports/env.ts"],"sourcesContent":["/**\n * Entry point: @intecion/ipal-kit/env\n *\n * Environment validation ONLY — zero imports beyond this module, no Payload,\n * no Node built-ins, no React. Safe for Next's instrumentation.ts, which Next\n * also compiles for the Edge runtime: importing the package root there drags in\n * Payload / file-type / fs and crashes Turbopack (\"Export fileTypeFromFile\n * doesn't exist in target module\").\n *\n * // src/instrumentation.ts\n * import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'\n * export function register() {\n * if (process.env.NEXT_RUNTIME === 'nodejs') assertEnv(ipalEnvRules({ storage: true }))\n * }\n */\nexport { assertEnv, ipalEnvRules } from '../modules/env/index.js'\nexport type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from '../modules/env/index.js'\n"],"names":["assertEnv","ipalEnvRules"],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GACD,SAASA,SAAS,EAAEC,YAAY,QAAQ,0BAAyB"}
|
||||
Vendored
+59
-52
@@ -1,67 +1,74 @@
|
||||
export type { AccessOption, Role } from './modules/access/index.js';
|
||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js';
|
||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y, } from './modules/accessibility/index.js';
|
||||
export type { A11yState } from './modules/accessibility/index.js';
|
||||
export type { AnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent, } from './modules/consent/index.js';
|
||||
export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js';
|
||||
export type { ContentCollectionOption, ContentOption, ResolvedRoute, } from './modules/content/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent, } from './modules/content/index.js';
|
||||
export type { ArchiveEntries } from './modules/content/index.js';
|
||||
export type { SearchResult } from './modules/content/index.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
export type { GraphAdapterArgs } from './modules/email/graphAdapter.js';
|
||||
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||
export type { MailAdapterArgs } from './modules/email/mailAdapter.js';
|
||||
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js';
|
||||
export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js';
|
||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||
export type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js';
|
||||
export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js';
|
||||
export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js';
|
||||
export type { FormsCollectionOverrides, FormsFieldsOverride, FormsOption, } from './modules/forms/types.js';
|
||||
export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js';
|
||||
export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required, } from './modules/forms/validators.js';
|
||||
export type { Rule } from './modules/forms/validators.js';
|
||||
export { createContentHelpers } from './modules/frontend/index.js';
|
||||
export { createHealthRoute } from './modules/health/index.js';
|
||||
export { buildCrossLocaleFieldSync, buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook, } from './modules/hooks/index.js';
|
||||
export { ipalKit } from './plugin.js';
|
||||
export type { IpalOptions } from './types.js';
|
||||
export type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.js';
|
||||
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath, } from './modules/i18n/index.js';
|
||||
export type { LocaleMiddlewareResult } from './modules/i18n/index.js';
|
||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js';
|
||||
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
|
||||
export { resolveLocalized } from './modules/i18n/index.js';
|
||||
export { createMcpRoute } from './modules/mcp/index.js';
|
||||
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage, } from './modules/notifications/index.js';
|
||||
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js';
|
||||
export type { PagesOption, SystemPageRole } from './modules/pages/index.js';
|
||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
||||
export type { AccessOption, Role } from './modules/access/index.js';
|
||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js';
|
||||
export type { GlobalQueryOptions } from './modules/payload/index.js';
|
||||
export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG, } from './modules/payload/index.js';
|
||||
export { getGlobal, getSiteSettings, getSiteIntegrations, SITE_SETTINGS_SLUG, SITE_INTEGRATIONS_SLUG, } from './modules/payload/index.js';
|
||||
export type { SeoOption, SeoMeta, PageMetadata } from './modules/seo/index.js';
|
||||
export { composeTitle, buildHreflangAlternates, buildMetadata, readSiteMetaConfig, slugsAcrossLocales, } from './modules/seo/index.js';
|
||||
export type { SiteMetaConfig } from './modules/seo/index.js';
|
||||
export type { ContentOption, ContentCollectionOption, ResolvedRoute } from './modules/content/index.js';
|
||||
export { createContentHelpers } from './modules/frontend/index.js';
|
||||
export { resolveRoute, resolveRedirect, resolveNotFoundPage, blocksToMarkdown, createMarkdownRenderer, markdownResponse, prefersMarkdown, markdownHref, MARKDOWN_PREFIX, searchContent, createSearchRoute, archiveFieldName, getArchiveEntries, buildArchivePath, buildEntryPath, parsePageParam, } from './modules/content/index.js';
|
||||
export type { ArchiveEntries } from './modules/content/index.js';
|
||||
export type { SearchResult } from './modules/content/index.js';
|
||||
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
||||
export type { AutoFillMapping, SitemapEntry, RobotsRules, RobotsOptions } from './modules/seo/index.js';
|
||||
export { buildAutoFillMetaHook, injectAutoFillMeta, createMetadataGenerator, createPageMetadata, buildSitemapEntries, buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, } from './modules/seo/index.js';
|
||||
export type { LocaleMiddlewareResult } from './modules/i18n/index.js';
|
||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER, } from './modules/i18n/index.js';
|
||||
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
|
||||
export { resolveLocalized } from './modules/i18n/index.js';
|
||||
export { CONSENT_CATEGORIES, DEFAULT_CONSENT, ACCEPT_ALL_CONSENT, REJECT_ALL_CONSENT, CONSENT_COOKIE, CONSENT_VERSION, CONSENT_MAX_AGE, serializeConsent, parseConsent, setDefaultConsent, updateConsent, getConsentTexts, } from './modules/consent/index.js';
|
||||
export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js';
|
||||
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||
export type { MailAdapterArgs } from './modules/email/mailAdapter.js';
|
||||
export type { GraphAdapterArgs } from './modules/email/graphAdapter.js';
|
||||
export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js';
|
||||
export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js';
|
||||
export type { FormsOption, FormsCollectionOverrides, FormsFieldsOverride, } from './modules/forms/types.js';
|
||||
export { buildValidator, isEmail, required, email, minLength, maxLength, checked, pattern, custom, } from './modules/forms/validators.js';
|
||||
export type { Rule } from './modules/forms/validators.js';
|
||||
export type { FormErrors, FormSubmitAction, Validator } from './modules/forms/useForm.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js';
|
||||
export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js';
|
||||
export { createHealthRoute } from './modules/health/index.js';
|
||||
export { createMcpRoute } from './modules/mcp/index.js';
|
||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||
export type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js';
|
||||
export type { AnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||
export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js';
|
||||
export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js';
|
||||
export { buildSecurityHeaders } from './modules/security/index.js';
|
||||
export { buildCsp } from './modules/security/index.js';
|
||||
export type { BuildCspArgs } from './modules/security/index.js';
|
||||
export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/security/index.js';
|
||||
export type { PageMetadata, SeoMeta, SeoOption } from './modules/seo/index.js';
|
||||
export { buildHreflangAlternates, buildMetadata, composeTitle } from './modules/seo/index.js';
|
||||
export type { AutoFillMapping, RobotsRules, SitemapEntry } from './modules/seo/index.js';
|
||||
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta, } from './modules/seo/index.js';
|
||||
export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler, } from './modules/seo/index.js';
|
||||
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField, } from './modules/seo/index.js';
|
||||
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js';
|
||||
export { buildNoindexField } from './modules/seo/index.js';
|
||||
export { rowLabel } from './modules/admin-ui/index.js';
|
||||
export type { RowLabelProps } from './modules/admin-ui/index.js';
|
||||
export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js';
|
||||
export type { LinkAppearance, LinkValue, BuildLinkFieldOptions, BuildLinksFieldOptions, ResolveLinkHrefOptions, } from './modules/links/index.js';
|
||||
export { buildSpeakableJsonLd } from './modules/seo/index.js';
|
||||
export { buildSummaryField } from './modules/seo/index.js';
|
||||
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd, } from './modules/seo/index.js';
|
||||
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd, } from './modules/seo/index.js';
|
||||
export { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js';
|
||||
export { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js';
|
||||
export { buildArticleJsonLd } from './modules/seo/index.js';
|
||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||
export { buildSitemapXml } from './modules/seo/index.js';
|
||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||
export { buildSitemapXml, buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './modules/seo/index.js';
|
||||
export type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js';
|
||||
export { buildR2Storage } from './modules/storage/index.js';
|
||||
export { ipalKit } from './plugin.js';
|
||||
export type { IpalOptions } from './types.js';
|
||||
export { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js';
|
||||
export type { OptimizeUploadOptions } from './modules/media/index.js';
|
||||
export { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js';
|
||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
||||
export type { A11yState } from './modules/accessibility/index.js';
|
||||
export type { SecurityHeader, BuildSecurityHeadersArgs } from './modules/security/index.js';
|
||||
export type { NotificationTexts, FormNotificationTexts } from './modules/notifications/index.js';
|
||||
|
||||
Vendored
+34
-32
@@ -1,57 +1,59 @@
|
||||
export { ipalKit } from './plugin.js';
|
||||
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath } from './modules/i18n/index.js';
|
||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY } from './modules/access/index.js';
|
||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { ACCEPT_ALL_CONSENT, CONSENT_CATEGORIES, CONSENT_COOKIE, CONSENT_MAX_AGE, CONSENT_VERSION, DEFAULT_CONSENT, getConsentTexts, parseConsent, REJECT_ALL_CONSENT, serializeConsent, setDefaultConsent, updateConsent } from './modules/consent/index.js';
|
||||
export { archiveFieldName, blocksToMarkdown, buildArchivePath, buildEntryPath, createMarkdownRenderer, createSearchRoute, getArchiveEntries, MARKDOWN_PREFIX, markdownHref, markdownResponse, parsePageParam, prefersMarkdown, resolveNotFoundPage, resolveRedirect, resolveRoute, searchContent } from './modules/content/index.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||
export { getGlobal, getSiteSettings, getSiteIntegrations, SITE_SETTINGS_SLUG, SITE_INTEGRATIONS_SLUG } from './modules/payload/index.js';
|
||||
export { composeTitle, buildHreflangAlternates, buildMetadata, readSiteMetaConfig, slugsAcrossLocales } from './modules/seo/index.js';
|
||||
export { createContentHelpers } from './modules/frontend/index.js';
|
||||
export { resolveRoute, resolveRedirect, resolveNotFoundPage, blocksToMarkdown, createMarkdownRenderer, markdownResponse, prefersMarkdown, markdownHref, MARKDOWN_PREFIX, searchContent, createSearchRoute, archiveFieldName, getArchiveEntries, buildArchivePath, buildEntryPath, parsePageParam } from './modules/content/index.js';
|
||||
// Lexical → Markdown (pure, no React) — for AI-readable output.
|
||||
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
||||
export { buildAutoFillMetaHook, injectAutoFillMeta, createMetadataGenerator, createPageMetadata, buildSitemapEntries, buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './modules/seo/index.js';
|
||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js';
|
||||
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
|
||||
export { resolveLocalized } from './modules/i18n/index.js';
|
||||
export { CONSENT_CATEGORIES, DEFAULT_CONSENT, ACCEPT_ALL_CONSENT, REJECT_ALL_CONSENT, CONSENT_COOKIE, CONSENT_VERSION, CONSENT_MAX_AGE, serializeConsent, parseConsent, setDefaultConsent, updateConsent, getConsentTexts } from './modules/consent/index.js';
|
||||
// Imported straight from the file, NOT from ./modules/email/index.js — that
|
||||
// barrel re-exports sendEmail, which imports 'server-only' and would crash when
|
||||
// Payload loads the config (or runs generate:importmap) as a plain Node script.
|
||||
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js';
|
||||
// Boot-time environment validation (fail fast on misconfigured deploys).
|
||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||
// Panel-managed form analytics (config-time field builder).
|
||||
export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js';
|
||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||
export { buildFormsPlugin } from './modules/forms/formsPluginConfig.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js';
|
||||
// Validation rules are pure — exported server-side too, for re-validating a
|
||||
// submission inside a server action. (useForm/useContactForm are client-only →
|
||||
// '@intecion/ipal-kit/client'.)
|
||||
export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required } from './modules/forms/validators.js';
|
||||
export { createContentHelpers } from './modules/frontend/index.js';
|
||||
export { buildValidator, isEmail, required, email, minLength, maxLength, checked, pattern, custom } from './modules/forms/validators.js';
|
||||
export { HONEYPOT_FIELD, honeypotInputProps, isHoneypotTripped } from './modules/forms/honeypot.js';
|
||||
// Panel-managed form analytics (config-time field builder).
|
||||
export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js';
|
||||
// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).
|
||||
export { createHealthRoute } from './modules/health/index.js';
|
||||
export { buildCrossLocaleFieldSync, buildPreventDeleteSystemPage, buildRevalidateHook, buildValidateUniqueRole, setPublishedAtHook, trackSlugHistoryHook } from './modules/hooks/index.js';
|
||||
export { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath } from './modules/i18n/index.js';
|
||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER } from './modules/i18n/index.js';
|
||||
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
|
||||
export { resolveLocalized } from './modules/i18n/index.js';
|
||||
// Read-only MCP server (Claude/agents connect to the site and query it).
|
||||
export { createMcpRoute } from './modules/mcp/index.js';
|
||||
export { normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js';
|
||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
||||
export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG } from './modules/payload/index.js';
|
||||
// Lexical → Markdown (pure, no React) — for AI-readable output.
|
||||
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
||||
// Boot-time environment validation (fail fast on misconfigured deploys).
|
||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||
export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js';
|
||||
export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js';
|
||||
export { buildSecurityHeaders } from './modules/security/index.js';
|
||||
export { buildCsp } from './modules/security/index.js';
|
||||
export { buildHreflangAlternates, buildMetadata, composeTitle } from './modules/seo/index.js';
|
||||
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildAutoFillMetaHook, buildRobots, buildSitemapEntries, createMetadataGenerator, createPageMetadata, injectAutoFillMeta } from './modules/seo/index.js';
|
||||
export { createLlmsTxtRoute, createManifestHandler, createSitemapRouteHandler } from './modules/seo/index.js';
|
||||
export { buildIconsMetadata, buildOrganizationJsonLd, validateFaviconField } from './modules/seo/index.js';
|
||||
export { buildNoindexField } from './modules/seo/index.js';
|
||||
export { rowLabel } from './modules/admin-ui/index.js';
|
||||
export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js';
|
||||
export { buildSpeakableJsonLd } from './modules/seo/index.js';
|
||||
export { buildSummaryField } from './modules/seo/index.js';
|
||||
export { buildBreadcrumbJsonLd, buildSiteNavigationJsonLd, buildWebSiteJsonLd } from './modules/seo/index.js';
|
||||
export { buildWebSiteJsonLd, buildBreadcrumbJsonLd, buildSiteNavigationJsonLd } from './modules/seo/index.js';
|
||||
// Local SEO structured data — LocalBusiness (map pack), Service (offering), FAQPage.
|
||||
export { buildFaqJsonLd, buildLocalBusinessJsonLd, buildServiceJsonLd } from './modules/seo/index.js';
|
||||
export { buildLocalBusinessJsonLd, buildFaqJsonLd, buildServiceJsonLd } from './modules/seo/index.js';
|
||||
export { buildArticleJsonLd } from './modules/seo/index.js';
|
||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||
export { buildSitemapXml } from './modules/seo/index.js';
|
||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||
export { buildSitemapXml, buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './modules/seo/index.js';
|
||||
export { buildR2Storage } from './modules/storage/index.js';
|
||||
export { ipalKit } from './plugin.js';
|
||||
export { normalizeFilename, normalizeFilenameHook, buildOptimizeUploadHook, buildOptimizeUploadField } from './modules/media/index.js';
|
||||
export { buildRevalidateHook, setPublishedAtHook, buildPreventDeleteSystemPage, buildValidateUniqueRole, trackSlugHistoryHook, buildCrossLocaleFieldSync } from './modules/hooks/index.js';
|
||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+12
@@ -0,0 +1,12 @@
|
||||
export type RowLabelProps = {
|
||||
/** Shown with the row number when every path is empty, e.g. "Button" → "Button 02". */
|
||||
fallback?: string;
|
||||
/** Dot paths inside the row, tried in order — the first non-empty text wins. */
|
||||
fields?: string[];
|
||||
};
|
||||
/**
|
||||
* Array row title in the admin panel: shows the row's own content ("Contact us",
|
||||
* "Fast delivery") instead of "Item 01", so an editor finds the right row
|
||||
* without expanding every one. Wire it with `rowLabel()`.
|
||||
*/
|
||||
export declare function RowLabel({ fallback, fields }: RowLabelProps): import("react/jsx-runtime").JSX.Element;
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
'use client';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { useRowLabel } from '@payloadcms/ui';
|
||||
const at = (obj, path)=>path.split('.').reduce((o, k)=>o && typeof o === 'object' ? o[k] : undefined, obj);
|
||||
const toText = (v)=>{
|
||||
if (typeof v === 'string') {
|
||||
return v.trim();
|
||||
}
|
||||
if (typeof v === 'number') {
|
||||
return String(v);
|
||||
}
|
||||
// populated relationship / upload → its title, name, filename or alt
|
||||
if (v && typeof v === 'object') {
|
||||
for (const k of [
|
||||
'title',
|
||||
'name',
|
||||
'label',
|
||||
'alt',
|
||||
'filename'
|
||||
]){
|
||||
const t = v[k];
|
||||
if (typeof t === 'string' && t.trim()) {
|
||||
return t.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
/**
|
||||
* Array row title in the admin panel: shows the row's own content ("Contact us",
|
||||
* "Fast delivery") instead of "Item 01", so an editor finds the right row
|
||||
* without expanding every one. Wire it with `rowLabel()`.
|
||||
*/ export function RowLabel({ fallback = 'Item', fields = [
|
||||
'heading',
|
||||
'title',
|
||||
'label',
|
||||
'link.label',
|
||||
'name'
|
||||
] }) {
|
||||
const { data, rowNumber } = useRowLabel();
|
||||
for (const f of fields){
|
||||
const text = toText(at(data, f));
|
||||
if (text) {
|
||||
return /*#__PURE__*/ _jsx("span", {
|
||||
children: text.length > 60 ? `${text.slice(0, 57)}…` : text
|
||||
});
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/ _jsx("span", {
|
||||
children: `${fallback} ${String((rowNumber ?? 0) + 1).padStart(2, '0')}`
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=RowLabelComponent.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/admin-ui/RowLabelComponent.tsx"],"sourcesContent":["'use client'\nimport { useRowLabel } from '@payloadcms/ui'\n\nexport type RowLabelProps = {\n /** Shown with the row number when every path is empty, e.g. \"Button\" → \"Button 02\". */\n fallback?: string\n /** Dot paths inside the row, tried in order — the first non-empty text wins. */\n fields?: string[]\n}\n\nconst at = (obj: unknown, path: string): unknown =>\n path.split('.').reduce<unknown>((o, k) => (o && typeof o === 'object' ? (o as Record<string, unknown>)[k] : undefined), obj)\n\nconst toText = (v: unknown): string => {\n if (typeof v === 'string') {return v.trim()}\n if (typeof v === 'number') {return String(v)}\n // populated relationship / upload → its title, name, filename or alt\n if (v && typeof v === 'object') {\n for (const k of ['title', 'name', 'label', 'alt', 'filename']) {\n const t = (v as Record<string, unknown>)[k]\n if (typeof t === 'string' && t.trim()) {return t.trim()}\n }\n }\n return ''\n}\n\n/**\n * Array row title in the admin panel: shows the row's own content (\"Contact us\",\n * \"Fast delivery\") instead of \"Item 01\", so an editor finds the right row\n * without expanding every one. Wire it with `rowLabel()`.\n */\nexport function RowLabel({ fallback = 'Item', fields = ['heading', 'title', 'label', 'link.label', 'name'] }: RowLabelProps) {\n const { data, rowNumber } = useRowLabel<Record<string, unknown>>()\n for (const f of fields) {\n const text = toText(at(data, f))\n if (text) {return <span>{text.length > 60 ? `${text.slice(0, 57)}…` : text}</span>}\n }\n return <span>{`${fallback} ${String((rowNumber ?? 0) + 1).padStart(2, '0')}`}</span>\n}\n"],"names":["useRowLabel","at","obj","path","split","reduce","o","k","undefined","toText","v","trim","String","t","RowLabel","fallback","fields","data","rowNumber","f","text","span","length","slice","padStart"],"mappings":"AAAA;;AACA,SAASA,WAAW,QAAQ,iBAAgB;AAS5C,MAAMC,KAAK,CAACC,KAAcC,OACxBA,KAAKC,KAAK,CAAC,KAAKC,MAAM,CAAU,CAACC,GAAGC,IAAOD,KAAK,OAAOA,MAAM,WAAW,AAACA,CAA6B,CAACC,EAAE,GAAGC,WAAYN;AAE1H,MAAMO,SAAS,CAACC;IACd,IAAI,OAAOA,MAAM,UAAU;QAAC,OAAOA,EAAEC,IAAI;IAAE;IAC3C,IAAI,OAAOD,MAAM,UAAU;QAAC,OAAOE,OAAOF;IAAE;IAC5C,qEAAqE;IACrE,IAAIA,KAAK,OAAOA,MAAM,UAAU;QAC9B,KAAK,MAAMH,KAAK;YAAC;YAAS;YAAQ;YAAS;YAAO;SAAW,CAAE;YAC7D,MAAMM,IAAI,AAACH,CAA6B,CAACH,EAAE;YAC3C,IAAI,OAAOM,MAAM,YAAYA,EAAEF,IAAI,IAAI;gBAAC,OAAOE,EAAEF,IAAI;YAAE;QACzD;IACF;IACA,OAAO;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASG,SAAS,EAAEC,WAAW,MAAM,EAAEC,SAAS;IAAC;IAAW;IAAS;IAAS;IAAc;CAAO,EAAiB;IACzH,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGlB;IAC5B,KAAK,MAAMmB,KAAKH,OAAQ;QACtB,MAAMI,OAAOX,OAAOR,GAAGgB,MAAME;QAC7B,IAAIC,MAAM;YAAC,qBAAO,KAACC;0BAAMD,KAAKE,MAAM,GAAG,KAAK,GAAGF,KAAKG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,GAAGH;;QAAY;IACpF;IACA,qBAAO,KAACC;kBAAM,GAAGN,SAAS,CAAC,EAAEH,OAAO,AAACM,CAAAA,aAAa,CAAA,IAAK,GAAGM,QAAQ,CAAC,GAAG,MAAM;;AAC9E"}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export { rowLabel } from './rowLabel.js';
|
||||
export type { RowLabelProps } from './RowLabelComponent.js';
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export { rowLabel } from './rowLabel.js';
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/admin-ui/index.ts"],"sourcesContent":["export { rowLabel } from './rowLabel.js'\nexport type { RowLabelProps } from './RowLabelComponent.js'\n"],"names":["rowLabel"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe"}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import type { RowLabelProps } from './RowLabelComponent.js';
|
||||
/**
|
||||
* Readable array rows in the panel. Spread into an array field's `admin.components`:
|
||||
*
|
||||
* { name: 'items', type: 'array', labels: { singular: 'Feature', plural: 'Features' },
|
||||
* admin: { initCollapsed: true, components: rowLabel(['heading'], 'Feature') }, fields: [...] }
|
||||
*
|
||||
* Rows then read "Fast delivery", "24/7 support"… instead of "Feature 01, Feature 02".
|
||||
* After adding it to a project: `pnpm payload generate:importmap`.
|
||||
*/
|
||||
export declare function rowLabel(fields: string | string[], fallback?: string): {
|
||||
RowLabel: {
|
||||
path: string;
|
||||
clientProps: RowLabelProps;
|
||||
};
|
||||
};
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Readable array rows in the panel. Spread into an array field's `admin.components`:
|
||||
*
|
||||
* { name: 'items', type: 'array', labels: { singular: 'Feature', plural: 'Features' },
|
||||
* admin: { initCollapsed: true, components: rowLabel(['heading'], 'Feature') }, fields: [...] }
|
||||
*
|
||||
* Rows then read "Fast delivery", "24/7 support"… instead of "Feature 01, Feature 02".
|
||||
* After adding it to a project: `pnpm payload generate:importmap`.
|
||||
*/ export function rowLabel(fields, fallback = 'Item') {
|
||||
const clientProps = {
|
||||
fields: Array.isArray(fields) ? fields : [
|
||||
fields
|
||||
],
|
||||
fallback
|
||||
};
|
||||
return {
|
||||
RowLabel: {
|
||||
path: '@intecion/ipal-kit/admin#RowLabel',
|
||||
clientProps
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=rowLabel.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/admin-ui/rowLabel.ts"],"sourcesContent":["import type { RowLabelProps } from './RowLabelComponent.js'\n\n/**\n * Readable array rows in the panel. Spread into an array field's `admin.components`:\n *\n * { name: 'items', type: 'array', labels: { singular: 'Feature', plural: 'Features' },\n * admin: { initCollapsed: true, components: rowLabel(['heading'], 'Feature') }, fields: [...] }\n *\n * Rows then read \"Fast delivery\", \"24/7 support\"… instead of \"Feature 01, Feature 02\".\n * After adding it to a project: `pnpm payload generate:importmap`.\n */\nexport function rowLabel(fields: string | string[], fallback = 'Item') {\n const clientProps: RowLabelProps = { fields: Array.isArray(fields) ? fields : [fields], fallback }\n return { RowLabel: { path: '@intecion/ipal-kit/admin#RowLabel', clientProps } }\n}\n"],"names":["rowLabel","fields","fallback","clientProps","Array","isArray","RowLabel","path"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,SAASC,MAAyB,EAAEC,WAAW,MAAM;IACnE,MAAMC,cAA6B;QAAEF,QAAQG,MAAMC,OAAO,CAACJ,UAAUA,SAAS;YAACA;SAAO;QAAEC;IAAS;IACjG,OAAO;QAAEI,UAAU;YAAEC,MAAM;YAAqCJ;QAAY;IAAE;AAChF"}
|
||||
Vendored
+6
-1
@@ -68,7 +68,7 @@ export function CookieBanner({ classNames } = {}) {
|
||||
const primaryClass = classNames?.primaryButton ?? defaults.primaryButton;
|
||||
const secondaryClass = classNames?.secondaryButton ?? defaults.secondaryButton;
|
||||
return /*#__PURE__*/ _jsx("div", {
|
||||
"aria-label": "Cookie consent",
|
||||
"aria-label": texts.settingsTitle,
|
||||
className: rootClass,
|
||||
"data-ipal": "banner",
|
||||
role: "dialog",
|
||||
@@ -107,16 +107,19 @@ export function CookieBanner({ classNames } = {}) {
|
||||
children: [
|
||||
/*#__PURE__*/ _jsx("button", {
|
||||
className: secondaryClass,
|
||||
"data-ipal": "settings",
|
||||
onClick: ()=>setShowSettings(true),
|
||||
children: texts.buttons.settings
|
||||
}),
|
||||
/*#__PURE__*/ _jsx("button", {
|
||||
className: secondaryClass,
|
||||
"data-ipal": "reject",
|
||||
onClick: rejectAll,
|
||||
children: texts.buttons.reject
|
||||
}),
|
||||
/*#__PURE__*/ _jsx("button", {
|
||||
className: primaryClass,
|
||||
"data-ipal": "accept",
|
||||
onClick: acceptAll,
|
||||
children: texts.buttons.acceptAll
|
||||
})
|
||||
@@ -168,11 +171,13 @@ export function CookieBanner({ classNames } = {}) {
|
||||
children: [
|
||||
/*#__PURE__*/ _jsx("button", {
|
||||
className: secondaryClass,
|
||||
"data-ipal": "back",
|
||||
onClick: ()=>setShowSettings(false),
|
||||
children: texts.buttons.back
|
||||
}),
|
||||
/*#__PURE__*/ _jsx("button", {
|
||||
className: primaryClass,
|
||||
"data-ipal": "save",
|
||||
onClick: ()=>savePreferences(choices),
|
||||
children: texts.buttons.save
|
||||
})
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+3
-2
@@ -14,7 +14,7 @@ import { useIsMounted } from './useIsMounted.js';
|
||||
* replace the styling outright.
|
||||
*/ export function CookieButton({ className } = {}) {
|
||||
const isMounted = useIsMounted();
|
||||
const { decided, reopen } = useConsentContext();
|
||||
const { decided, reopen, texts } = useConsentContext();
|
||||
// Render nothing until mounted — prevents hydration mismatch (no project
|
||||
// ConsentWrapper workaround needed).
|
||||
if (!isMounted) {
|
||||
@@ -25,7 +25,8 @@ import { useIsMounted } from './useIsMounted.js';
|
||||
}
|
||||
const cls = className ?? 'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' + 'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' + 'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]';
|
||||
return /*#__PURE__*/ _jsx("button", {
|
||||
"aria-label": "Cookie settings",
|
||||
// a11y label per locale: the panel's "settings title" (Cookie Settings global)
|
||||
"aria-label": texts.settingsTitle,
|
||||
className: cls,
|
||||
"data-ipal": "cookie-button",
|
||||
onClick: reopen,
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/consent/CookieButton.tsx"],"sourcesContent":["'use client'\nimport { Cookie } from 'lucide-react'\n\nimport { useConsentContext } from './ConsentContext.js'\nimport { useIsMounted } from './useIsMounted.js'\n\n/**\n * Floating \"cookie settings\" button — lets visitors reopen the consent panel\n * after deciding (GDPR: withdrawing consent must be as easy as giving it).\n * Hidden while the banner is showing.\n *\n * Colours follow the same CSS custom properties as CookieBanner\n * (--ipal-surface, --ipal-border, --ipal-hover, --ipal-text), so a client's\n * palette applies to both without touching either component. Pass className to\n * replace the styling outright.\n */\nexport function CookieButton({ className }: { className?: string } = {}) {\n const isMounted = useIsMounted()\n const { decided, reopen } = useConsentContext()\n\n // Render nothing until mounted — prevents hydration mismatch (no project\n // ConsentWrapper workaround needed).\n if (!isMounted) {return null}\n if (!decided) {return null}\n\n const cls =\n className ??\n 'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' +\n 'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' +\n 'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]'\n\n return (\n <button aria-label=\"Cookie settings\" className={cls} data-ipal=\"cookie-button\" onClick={reopen}>\n <Cookie\n aria-hidden=\"true\"\n className=\"h-5 w-5 text-[var(--ipal-text,#525252)] dark:text-[var(--ipal-text-dark,#d4d4d4)]\"\n />\n </button>\n )\n}\n"],"names":["Cookie","useConsentContext","useIsMounted","CookieButton","className","isMounted","decided","reopen","cls","button","aria-label","data-ipal","onClick","aria-hidden"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,eAAc;AAErC,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD;;;;;;;;;CASC,GACD,OAAO,SAASC,aAAa,EAAEC,SAAS,EAA0B,GAAG,CAAC,CAAC;IACrE,MAAMC,YAAYH;IAClB,MAAM,EAAEI,OAAO,EAAEC,MAAM,EAAE,GAAGN;IAE5B,yEAAyE;IACzE,qCAAqC;IACrC,IAAI,CAACI,WAAW;QAAC,OAAO;IAAI;IAC5B,IAAI,CAACC,SAAS;QAAC,OAAO;IAAI;IAE1B,MAAME,MACJJ,aACA,2HACE,4GACA;IAEJ,qBACE,KAACK;QAAOC,cAAW;QAAkBN,WAAWI;QAAKG,aAAU;QAAgBC,SAASL;kBACtF,cAAA,KAACP;YACCa,eAAY;YACZT,WAAU;;;AAIlB"}
|
||||
{"version":3,"sources":["../../../src/modules/consent/CookieButton.tsx"],"sourcesContent":["'use client'\nimport { Cookie } from 'lucide-react'\n\nimport { useConsentContext } from './ConsentContext.js'\nimport { useIsMounted } from './useIsMounted.js'\n\n/**\n * Floating \"cookie settings\" button — lets visitors reopen the consent panel\n * after deciding (GDPR: withdrawing consent must be as easy as giving it).\n * Hidden while the banner is showing.\n *\n * Colours follow the same CSS custom properties as CookieBanner\n * (--ipal-surface, --ipal-border, --ipal-hover, --ipal-text), so a client's\n * palette applies to both without touching either component. Pass className to\n * replace the styling outright.\n */\nexport function CookieButton({ className }: { className?: string } = {}) {\n const isMounted = useIsMounted()\n const { decided, reopen, texts } = useConsentContext()\n\n // Render nothing until mounted — prevents hydration mismatch (no project\n // ConsentWrapper workaround needed).\n if (!isMounted) {return null}\n if (!decided) {return null}\n\n const cls =\n className ??\n 'fixed bottom-4 left-4 z-40 flex h-11 w-11 items-center justify-center rounded-full border shadow-md transition-colors ' +\n 'bg-[var(--ipal-surface,#fff)] border-[var(--ipal-border,#e5e5e5)] hover:bg-[var(--ipal-hover,#f5f5f5)] ' +\n 'dark:bg-[var(--ipal-surface-dark,#171717)] dark:border-[var(--ipal-border-dark,#262626)] dark:hover:bg-[var(--ipal-hover-dark,#262626)]'\n\n return (\n <button\n // a11y label per locale: the panel's \"settings title\" (Cookie Settings global)\n aria-label={texts.settingsTitle}\n className={cls}\n data-ipal=\"cookie-button\"\n onClick={reopen}\n >\n <Cookie\n aria-hidden=\"true\"\n className=\"h-5 w-5 text-[var(--ipal-text,#525252)] dark:text-[var(--ipal-text-dark,#d4d4d4)]\"\n />\n </button>\n )\n}\n"],"names":["Cookie","useConsentContext","useIsMounted","CookieButton","className","isMounted","decided","reopen","texts","cls","button","aria-label","settingsTitle","data-ipal","onClick","aria-hidden"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,eAAc;AAErC,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,YAAY,QAAQ,oBAAmB;AAEhD;;;;;;;;;CASC,GACD,OAAO,SAASC,aAAa,EAAEC,SAAS,EAA0B,GAAG,CAAC,CAAC;IACrE,MAAMC,YAAYH;IAClB,MAAM,EAAEI,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAEnC,yEAAyE;IACzE,qCAAqC;IACrC,IAAI,CAACI,WAAW;QAAC,OAAO;IAAI;IAC5B,IAAI,CAACC,SAAS;QAAC,OAAO;IAAI;IAE1B,MAAMG,MACJL,aACA,2HACE,4GACA;IAEJ,qBACE,KAACM;QACC,+EAA+E;QAC/EC,cAAYH,MAAMI,aAAa;QAC/BR,WAAWK;QACXI,aAAU;QACVC,SAASP;kBAET,cAAA,KAACP;YACCe,eAAY;YACZX,WAAU;;;AAIlB"}
|
||||
+8
@@ -11,6 +11,14 @@ type CreateSearchRouteArgs = {
|
||||
getCachedPayload: () => Promise<BasePayload>;
|
||||
/** Home slug map/string so the home result collapses to root. */
|
||||
homeSlug?: Record<string, string> | string;
|
||||
/**
|
||||
* Per-IP limit (in memory, per instance). Default { max: 120, windowMs: 60_000 }.
|
||||
* `false` = off (a limiter in front, e.g. Cloudflare WAF rate limiting).
|
||||
*/
|
||||
rateLimit?: {
|
||||
max?: number;
|
||||
windowMs?: number;
|
||||
} | false;
|
||||
/** Field holding a richer AI summary (buildSummaryField) to prefer as description. */
|
||||
summaryField?: string;
|
||||
};
|
||||
|
||||
+22
@@ -1,3 +1,4 @@
|
||||
import { checkRateLimit, clientIp, tooManyRequests } from '../shared/rateLimit.js';
|
||||
import { searchContent } from './searchContent.js';
|
||||
/**
|
||||
* A JSON content-search endpoint. Powers both the site's own search UI and
|
||||
@@ -18,7 +19,28 @@ import { searchContent } from './searchContent.js';
|
||||
* Uses the global Request/Response — no next/server import.
|
||||
*/ export function createSearchRoute(args) {
|
||||
const { baseUrl, collection = 'pages', config, defaultLimit = 10, getCachedPayload, homeSlug, summaryField } = args;
|
||||
// 120/min: a debounced search-as-you-type box stays well under it; a scraper doesn't.
|
||||
const rl = args.rateLimit === false ? null : {
|
||||
max: 120,
|
||||
windowMs: 60_000,
|
||||
...args.rateLimit
|
||||
};
|
||||
return async (req)=>{
|
||||
if (rl) {
|
||||
const ip = clientIp(req);
|
||||
if (!checkRateLimit({
|
||||
key: ip,
|
||||
scope: 'search',
|
||||
...rl
|
||||
})) {
|
||||
return tooManyRequests(ip, 'search', {
|
||||
count: 0,
|
||||
error: 'Too many requests',
|
||||
query: '',
|
||||
results: []
|
||||
});
|
||||
}
|
||||
}
|
||||
const url = new URL(req.url);
|
||||
const query = url.searchParams.get('q')?.trim() ?? '';
|
||||
const locale = url.searchParams.get('locale') ?? undefined;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+7
-1
@@ -38,6 +38,12 @@ type ResolveRouteArgs = {
|
||||
payload: BasePayload;
|
||||
/** Route segments after the locale, e.g. ['artykuly', 'moj-post']. */
|
||||
segments?: string[];
|
||||
/**
|
||||
* SiteSettings already read for this locale (depth ≥ 1). Pass it to skip the
|
||||
* read — createContentHelpers does, so layout, metadata and page share ONE
|
||||
* settings query per request.
|
||||
*/
|
||||
settings?: null | Record<string, unknown>;
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
};
|
||||
@@ -64,5 +70,5 @@ type ResolveRouteArgs = {
|
||||
* make canonical and hreflang ambiguous (the same entry reachable under several
|
||||
* URLs).
|
||||
*/
|
||||
export declare function resolveRoute({ content, locale, page, pagesSlug, payload, segments, settingsSlug, }: ResolveRouteArgs): Promise<null | ResolvedRoute>;
|
||||
export declare function resolveRoute({ content, locale, page, pagesSlug, payload, segments, settings: preloaded, settingsSlug, }: ResolveRouteArgs): Promise<null | ResolvedRoute>;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-2
@@ -21,8 +21,8 @@ import { archiveFieldName } from './types.js';
|
||||
* Depth beyond {archive}/{entry} isn't supported — categories in the path would
|
||||
* make canonical and hreflang ambiguous (the same entry reachable under several
|
||||
* URLs).
|
||||
*/ export async function resolveRoute({ content, locale, page = 1, pagesSlug = 'pages', payload, segments, settingsSlug = 'site-settings' }) {
|
||||
const settings = await payload.findGlobal({
|
||||
*/ export async function resolveRoute({ content, locale, page = 1, pagesSlug = 'pages', payload, segments, settings: preloaded, settingsSlug = 'site-settings' }) {
|
||||
const settings = preloaded ?? await payload.findGlobal({
|
||||
slug: settingsSlug,
|
||||
depth: 1,
|
||||
locale: locale
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
}
|
||||
switch(kind){
|
||||
case 'boolean':
|
||||
if (!/^(true|false|1|0|yes|no)$/i.test(value)) {
|
||||
if (!/^(?:true|false|1|0|yes|no)$/i.test(value)) {
|
||||
return `${name} must be a boolean (true/false/1/0/yes/no, got "${value}")`;
|
||||
}
|
||||
break;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+13
-2
@@ -59,8 +59,19 @@
|
||||
kind: 'url'
|
||||
}, {
|
||||
name: 'R2_PUBLIC_URL',
|
||||
description: 'Public base URL media is served from',
|
||||
kind: 'url'
|
||||
description: 'Public base URL media is served from (custom domain of the bucket)',
|
||||
// Production: absolute URL (https://media.example.com). Outside production a
|
||||
// site-relative path ('/media') is accepted — buildR2Storage prefixes it with
|
||||
// NEXT_PUBLIC_SERVER_URL (e.g. a dev rewrite /media → bucket).
|
||||
validate: (v)=>{
|
||||
if (/^https?:\/\/[^/\s]+/i.test(v)) {
|
||||
return true;
|
||||
}
|
||||
if (v.startsWith('/') && process.env.NODE_ENV !== 'production') {
|
||||
return true;
|
||||
}
|
||||
return v.startsWith('/') ? `R2_PUBLIC_URL must be an absolute URL in production (got "${v}") — e.g. https://media.example.com` : `R2_PUBLIC_URL must be an absolute URL (https://…) or, outside production, a path starting with "/" (got "${v}")`;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (emailGraph) {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-14
@@ -1,14 +1,2 @@
|
||||
export type RateLimitArgs = {
|
||||
/** Identifier to limit on — typically the client IP. */
|
||||
key: string;
|
||||
/** Max submissions allowed per window. Defaults to 5. */
|
||||
max?: number;
|
||||
/** Window length in ms. Defaults to 60_000 (one minute). */
|
||||
windowMs?: number;
|
||||
};
|
||||
/**
|
||||
* Returns true when the request is within the limit, false when it should be
|
||||
* rejected. A missing key (no IP) is allowed through — better to accept a
|
||||
* submission than to block everyone behind a proxy that strips the header.
|
||||
*/
|
||||
export declare function checkRateLimit({ key, max, windowMs }: RateLimitArgs): boolean;
|
||||
export { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js';
|
||||
export type { RateLimitArgs } from '../shared/rateLimit.js';
|
||||
|
||||
Vendored
+2
-49
@@ -1,51 +1,4 @@
|
||||
/**
|
||||
* Per-IP sliding window, in memory.
|
||||
*
|
||||
* Deliberately simple: no Redis, no dependency. The trade-off is that the
|
||||
* counter lives in one process — with several instances behind a load balancer
|
||||
* each keeps its own, so the effective limit is per-instance, not global. For a
|
||||
* contact form that's fine (it raises the cost of flooding without pretending
|
||||
* to be airtight); a high-security form should put a real limiter in front.
|
||||
*
|
||||
* State is module-level, so it survives between requests but resets on redeploy
|
||||
* — acceptable for abuse throttling.
|
||||
*/ const buckets = new Map();
|
||||
/** Sweep expired buckets occasionally so the map doesn't grow unbounded. */ let lastSweep = Date.now();
|
||||
const SWEEP_INTERVAL = 60_000;
|
||||
function sweep(now) {
|
||||
if (now - lastSweep < SWEEP_INTERVAL) {
|
||||
return;
|
||||
}
|
||||
lastSweep = now;
|
||||
for (const [key, bucket] of buckets){
|
||||
if (bucket.resetAt <= now) {
|
||||
buckets.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns true when the request is within the limit, false when it should be
|
||||
* rejected. A missing key (no IP) is allowed through — better to accept a
|
||||
* submission than to block everyone behind a proxy that strips the header.
|
||||
*/ export function checkRateLimit({ key, max = 5, windowMs = 60_000 }) {
|
||||
if (!key) {
|
||||
return true;
|
||||
}
|
||||
const now = Date.now();
|
||||
sweep(now);
|
||||
const bucket = buckets.get(key);
|
||||
if (!bucket || bucket.resetAt <= now) {
|
||||
buckets.set(key, {
|
||||
count: 1,
|
||||
resetAt: now + windowMs
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (bucket.count >= max) {
|
||||
return false;
|
||||
}
|
||||
bucket.count += 1;
|
||||
return true;
|
||||
}
|
||||
// Moved to modules/shared/rateLimit.ts (shared with search and MCP routes).
|
||||
export { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js';
|
||||
|
||||
//# sourceMappingURL=rateLimit.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/forms/rateLimit.ts"],"sourcesContent":["type Bucket = { count: number; resetAt: number }\n\n/**\n * Per-IP sliding window, in memory.\n *\n * Deliberately simple: no Redis, no dependency. The trade-off is that the\n * counter lives in one process — with several instances behind a load balancer\n * each keeps its own, so the effective limit is per-instance, not global. For a\n * contact form that's fine (it raises the cost of flooding without pretending\n * to be airtight); a high-security form should put a real limiter in front.\n *\n * State is module-level, so it survives between requests but resets on redeploy\n * — acceptable for abuse throttling.\n */\nconst buckets = new Map<string, Bucket>()\n\n/** Sweep expired buckets occasionally so the map doesn't grow unbounded. */\nlet lastSweep = Date.now()\nconst SWEEP_INTERVAL = 60_000\n\nfunction sweep(now: number) {\n if (now - lastSweep < SWEEP_INTERVAL) {return}\n lastSweep = now\n for (const [key, bucket] of buckets) {\n if (bucket.resetAt <= now) {buckets.delete(key)}\n }\n}\n\nexport type RateLimitArgs = {\n /** Identifier to limit on — typically the client IP. */\n key: string\n /** Max submissions allowed per window. Defaults to 5. */\n max?: number\n /** Window length in ms. Defaults to 60_000 (one minute). */\n windowMs?: number\n}\n\n/**\n * Returns true when the request is within the limit, false when it should be\n * rejected. A missing key (no IP) is allowed through — better to accept a\n * submission than to block everyone behind a proxy that strips the header.\n */\nexport function checkRateLimit({ key, max = 5, windowMs = 60_000 }: RateLimitArgs): boolean {\n if (!key) {return true}\n\n const now = Date.now()\n sweep(now)\n\n const bucket = buckets.get(key)\n\n if (!bucket || bucket.resetAt <= now) {\n buckets.set(key, { count: 1, resetAt: now + windowMs })\n return true\n }\n\n if (bucket.count >= max) {\n return false\n }\n\n bucket.count += 1\n return true\n}\n"],"names":["buckets","Map","lastSweep","Date","now","SWEEP_INTERVAL","sweep","key","bucket","resetAt","delete","checkRateLimit","max","windowMs","get","set","count"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,MAAMA,UAAU,IAAIC;AAEpB,0EAA0E,GAC1E,IAAIC,YAAYC,KAAKC,GAAG;AACxB,MAAMC,iBAAiB;AAEvB,SAASC,MAAMF,GAAW;IACxB,IAAIA,MAAMF,YAAYG,gBAAgB;QAAC;IAAM;IAC7CH,YAAYE;IACZ,KAAK,MAAM,CAACG,KAAKC,OAAO,IAAIR,QAAS;QACnC,IAAIQ,OAAOC,OAAO,IAAIL,KAAK;YAACJ,QAAQU,MAAM,CAACH;QAAI;IACjD;AACF;AAWA;;;;CAIC,GACD,OAAO,SAASI,eAAe,EAAEJ,GAAG,EAAEK,MAAM,CAAC,EAAEC,WAAW,MAAM,EAAiB;IAC/E,IAAI,CAACN,KAAK;QAAC,OAAO;IAAI;IAEtB,MAAMH,MAAMD,KAAKC,GAAG;IACpBE,MAAMF;IAEN,MAAMI,SAASR,QAAQc,GAAG,CAACP;IAE3B,IAAI,CAACC,UAAUA,OAAOC,OAAO,IAAIL,KAAK;QACpCJ,QAAQe,GAAG,CAACR,KAAK;YAAES,OAAO;YAAGP,SAASL,MAAMS;QAAS;QACrD,OAAO;IACT;IAEA,IAAIL,OAAOQ,KAAK,IAAIJ,KAAK;QACvB,OAAO;IACT;IAEAJ,OAAOQ,KAAK,IAAI;IAChB,OAAO;AACT"}
|
||||
{"version":3,"sources":["../../../src/modules/forms/rateLimit.ts"],"sourcesContent":["// Moved to modules/shared/rateLimit.ts (shared with search and MCP routes).\nexport { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js'\nexport type { RateLimitArgs } from '../shared/rateLimit.js'\n"],"names":["checkRateLimit","clientIp","retryAfterSeconds","tooManyRequests"],"mappings":"AAAA,4EAA4E;AAC5E,SAASA,cAAc,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,eAAe,QAAQ,yBAAwB"}
|
||||
Vendored
+1
-1
@@ -76,7 +76,7 @@ export type SubmitFormResult = {
|
||||
*
|
||||
* Emails aren't sent here. The form-builder sends whatever an editor configured
|
||||
* under the form's "Emails" tab (form-submissions hook → payload.sendEmail),
|
||||
* which goes out over panelSmtpAdapter. Storing the submission is enough.
|
||||
* which goes out over the configured email adapter (mailAdapter). Storing the submission is enough.
|
||||
*
|
||||
* server-only: touches the Turnstile secret.
|
||||
*/
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ import { validateSubmission } from './validateSubmission.js';
|
||||
*
|
||||
* Emails aren't sent here. The form-builder sends whatever an editor configured
|
||||
* under the form's "Emails" tab (form-submissions hook → payload.sendEmail),
|
||||
* which goes out over panelSmtpAdapter. Storing the submission is enough.
|
||||
* which goes out over the configured email adapter (mailAdapter). Storing the submission is enough.
|
||||
*
|
||||
* server-only: touches the Turnstile secret.
|
||||
*/ export async function submitForm({ consentFieldName, data, formId, ip, maxPerMinute = 5, payload, turnstileToken }) {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+15
-2
@@ -1,7 +1,7 @@
|
||||
import type { BasePayload, SanitizedConfig } from 'payload';
|
||||
import type { ArchiveEntries, ContentOption, ResolvedRoute } from '../content/index.js';
|
||||
import type { I18nConfig } from '../i18n/index.js';
|
||||
import type { RobotsRules, SitemapEntry } from '../seo/index.js';
|
||||
import type { PageMetadata, RobotsOptions, RobotsRules, SitemapEntry, SitemapStyleOptions } from '../seo/index.js';
|
||||
type CreateContentHelpersArgs = {
|
||||
/**
|
||||
* Absolute site origin for sitemap/robots URLs. Falls back to
|
||||
@@ -23,8 +23,19 @@ type CreateContentHelpersArgs = {
|
||||
i18n?: I18nConfig;
|
||||
/** Pages collection slug. Defaults to 'pages'. */
|
||||
pagesSlug?: string;
|
||||
/**
|
||||
* Options for the ready-made `robots` handler, e.g.
|
||||
* `{ disallowParams: ['s', 'meter'], aiBots: 'block-training' }`, or
|
||||
* `{ adminRoute: false }` when the admin path is hidden (ipalKit adminRoute).
|
||||
*/
|
||||
robots?: RobotsOptions;
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
/**
|
||||
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
||||
* header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
|
||||
*/
|
||||
sitemapStyle?: false | SitemapStyleOptions;
|
||||
};
|
||||
/**
|
||||
* Bundles the per-request data helpers a frontend needs — the same cached
|
||||
@@ -52,7 +63,8 @@ type CreateContentHelpersArgs = {
|
||||
* a URL is, fetching gets the listing. Metadata generation needs the first and
|
||||
* not the second, and a page component composes them in two obvious lines.
|
||||
*/
|
||||
export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, settingsSlug, }: CreateContentHelpersArgs): {
|
||||
export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, sitemapStyle, }: CreateContentHelpersArgs): {
|
||||
generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise<PageMetadata>;
|
||||
generateStaticParams: () => Promise<Array<{
|
||||
locale: string;
|
||||
slug: string[];
|
||||
@@ -67,5 +79,6 @@ export declare function createContentHelpers({ baseUrl, config, content, i18n, p
|
||||
resolveRoute: (locale: string, segments: string[] | undefined, page: number) => Promise<null | ResolvedRoute>;
|
||||
robots: () => RobotsRules;
|
||||
sitemap: () => Promise<SitemapEntry[]>;
|
||||
sitemapRoute: (req: Request) => Promise<Response>;
|
||||
};
|
||||
export {};
|
||||
|
||||
+87
-13
@@ -1,7 +1,7 @@
|
||||
import { getPayload } from 'payload';
|
||||
import { cache } from 'react';
|
||||
import { getArchiveEntries, resolveNotFoundPage, resolveRoute as resolveRouteRaw } from '../content/index.js';
|
||||
import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
import { getArchiveEntries, resolveRoute as resolveRouteRaw } from '../content/index.js';
|
||||
import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRouteHandler } from '../seo/index.js';
|
||||
/**
|
||||
* Bundles the per-request data helpers a frontend needs — the same cached
|
||||
* wrappers every project was writing by hand (getPayload, settings, locale
|
||||
@@ -27,7 +27,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
* `resolveRoute` and `getEntries` are separate on purpose: routing decides what
|
||||
* a URL is, fetching gets the listing. Metadata generation needs the first and
|
||||
* not the second, and a page component composes them in two obvious lines.
|
||||
*/ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', settingsSlug = 'site-settings' }) {
|
||||
*/ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', sitemapStyle }) {
|
||||
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '';
|
||||
const getCachedPayload = cache(async ()=>getPayload({
|
||||
config: await config
|
||||
@@ -36,7 +36,10 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
const c = await config;
|
||||
return c.localization ? c.localization.locales.map((l)=>l.code) : [];
|
||||
});
|
||||
const getSettings = cache(async (locale)=>{
|
||||
/**
|
||||
* SiteSettings for a locale — ONE query per locale per request, shared by the
|
||||
* layout, generatePageMetadata, resolveRoute and anything else that asks.
|
||||
*/ const getSettings = cache(async (locale)=>{
|
||||
const payload = await getCachedPayload();
|
||||
return payload.findGlobal({
|
||||
slug: settingsSlug,
|
||||
@@ -46,6 +49,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
});
|
||||
/** What does this URL point at? Routing only — no listing data. */ const resolveRoute = cache(async (locale, segments, page)=>{
|
||||
const payload = await getCachedPayload();
|
||||
const settings = await getSettings(locale);
|
||||
return resolveRouteRaw({
|
||||
content,
|
||||
locale,
|
||||
@@ -53,24 +57,82 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
pagesSlug,
|
||||
payload,
|
||||
segments,
|
||||
settings,
|
||||
settingsSlug
|
||||
});
|
||||
});
|
||||
/**
|
||||
* generateMetadata for the catch-all page, sharing the request cache with
|
||||
* the page component: the same settings read and the same resolveRoute call
|
||||
* (React cache spans generateMetadata and the page within one request), so
|
||||
* metadata costs no extra route/settings queries.
|
||||
*
|
||||
* export async function generateMetadata({ params }) {
|
||||
* const { locale, slug } = await params
|
||||
* return generatePageMetadata(locale, slug)
|
||||
* }
|
||||
*/ let pageMetadata;
|
||||
const generatePageMetadata = async (locale, segments, page = 1)=>{
|
||||
if (!i18n) {
|
||||
throw new Error('[ipal] createContentHelpers: pass `i18n` to use generatePageMetadata.');
|
||||
}
|
||||
pageMetadata ??= createPageMetadata({
|
||||
baseUrl: origin || undefined,
|
||||
collection: pagesSlug,
|
||||
config: i18n,
|
||||
content,
|
||||
loaders: {
|
||||
getSettings: async (l)=>await getSettings(l),
|
||||
resolveRoute
|
||||
},
|
||||
settingsSlug
|
||||
});
|
||||
return pageMetadata({
|
||||
slug: segments,
|
||||
locale,
|
||||
page,
|
||||
payload: await getCachedPayload()
|
||||
});
|
||||
};
|
||||
/** ID of the page assigned as 404 — the relation isn't localized, so one read serves every locale. */ const getNotFoundPageId = cache(async ()=>{
|
||||
const payload = await getCachedPayload();
|
||||
const settings = await payload.findGlobal({
|
||||
slug: settingsSlug,
|
||||
depth: 0
|
||||
});
|
||||
const rel = settings.notFound;
|
||||
if (typeof rel === 'string' || typeof rel === 'number') {
|
||||
return rel;
|
||||
}
|
||||
if (rel && typeof rel === 'object') {
|
||||
const id = rel.id;
|
||||
if (typeof id === 'string' || typeof id === 'number') {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
/**
|
||||
* The page assigned as 404 in System Pages (or null → built-in fallback).
|
||||
* For app/not-found.tsx; never throws. Locale comes from the x-locale header
|
||||
* set by createProxy (not-found.tsx receives no params).
|
||||
* For app/not-found.tsx; never throws. not-found.tsx receives no params and
|
||||
* must NOT read headers() (breaks SSG/ISR) — call this for every configured
|
||||
* locale and let <LocaleView> (client) pick the one from the URL. See pages.md.
|
||||
*/ const getNotFoundPage = cache(async (locale)=>{
|
||||
try {
|
||||
const id = await getNotFoundPageId();
|
||||
if (id === null) {
|
||||
return null;
|
||||
}
|
||||
const payload = await getCachedPayload();
|
||||
return await resolveNotFoundPage({
|
||||
locale,
|
||||
pagesSlug,
|
||||
payload,
|
||||
settingsSlug
|
||||
const doc = await payload.findByID({
|
||||
id,
|
||||
collection: pagesSlug,
|
||||
depth: 2,
|
||||
locale: locale
|
||||
});
|
||||
return doc ?? null;
|
||||
} catch {
|
||||
return null // DB unreachable (container build) — fallback view
|
||||
return null // DB unreachable (container build) or page deleted — fallback view
|
||||
;
|
||||
}
|
||||
});
|
||||
@@ -133,6 +195,7 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
* export { robots as default } from '@/lib/content'
|
||||
* ```
|
||||
*/ const robots = ()=>buildRobots({
|
||||
...robotsOptions,
|
||||
baseUrl: origin
|
||||
});
|
||||
/**
|
||||
@@ -248,7 +311,17 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
return [];
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Route handler for app/sitemap.xml/route.ts — XML for crawlers, styled for
|
||||
* people (`?style` serves the CSS from the plugin; nothing in /public):
|
||||
*
|
||||
* export { sitemapRoute as GET } from '@/lib/content'
|
||||
* export const dynamic = 'force-dynamic'
|
||||
*/ const sitemapRoute = createSitemapRouteHandler(sitemap, {
|
||||
style: sitemapStyle ?? {}
|
||||
});
|
||||
return {
|
||||
generatePageMetadata,
|
||||
generateStaticParams,
|
||||
getCachedPayload,
|
||||
getConfiguredLocales,
|
||||
@@ -257,7 +330,8 @@ import { buildRobots, buildSitemapEntries } from '../seo/index.js';
|
||||
getSettings,
|
||||
resolveRoute,
|
||||
robots,
|
||||
sitemap
|
||||
sitemap,
|
||||
sitemapRoute
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+47
@@ -0,0 +1,47 @@
|
||||
import type { ArrayField, GroupField } from 'payload';
|
||||
export type LinkAppearance = 'link' | 'primary' | 'secondary';
|
||||
export type BuildLinkFieldOptions = {
|
||||
/** Visual styles the editor may pick. `false` → no appearance select. Default all three. */
|
||||
appearances?: false | LinkAppearance[];
|
||||
/** Hide the label — for links that wrap something (a whole card, an image). */
|
||||
disableLabel?: boolean;
|
||||
/** Field name. Default 'link'. */
|
||||
name?: string;
|
||||
/** Collection the "Page" option points at. Default 'pages'. */
|
||||
relationTo?: string;
|
||||
required?: boolean;
|
||||
/** Upload collection for "File" links (PDF, documents). Default 'media'. */
|
||||
uploadTo?: string;
|
||||
};
|
||||
/**
|
||||
* The ONE link shape for a project: a page, an external URL (also mailto:,
|
||||
* tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual
|
||||
* style. Every CTA, card link and download in every block uses this field, so
|
||||
* there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer
|
||||
* (resolveLinkHref + the project's CMSLink) handles them all.
|
||||
*
|
||||
* Generates a named TypeScript type `CmsLink` in payload-types.ts.
|
||||
*
|
||||
* fields: [buildLinkField()] // single link
|
||||
* fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card
|
||||
*/
|
||||
export declare function buildLinkField({ name, appearances, disableLabel, relationTo, required, uploadTo, }?: BuildLinkFieldOptions): GroupField;
|
||||
export type BuildLinksFieldOptions = {
|
||||
/**
|
||||
* What one row is called in the panel — the add button reads "Add <singular>".
|
||||
* Default { singular: 'Button', plural: 'Buttons' }; e.g. { singular: 'Link', plural: 'Links' } for a link list.
|
||||
*/
|
||||
labels?: {
|
||||
plural: string;
|
||||
singular: string;
|
||||
};
|
||||
/** Max number of buttons. Default 2. */
|
||||
maxRows?: number;
|
||||
/** Field name. Default 'links'. */
|
||||
name?: string;
|
||||
} & Omit<BuildLinkFieldOptions, 'disableLabel' | 'name'>;
|
||||
/**
|
||||
* 0..N buttons — use for every "CTA(s)" of a section. Each row holds one
|
||||
* `link` (buildLinkField). Render: `links.map(({ id, link }) => <CMSLink … />)`.
|
||||
*/
|
||||
export declare function buildLinksField({ name, labels, maxRows, ...linkOptions }?: BuildLinksFieldOptions): ArrayField;
|
||||
Vendored
+145
@@ -0,0 +1,145 @@
|
||||
import { rowLabel } from '../admin-ui/rowLabel.js';
|
||||
const URL_PATTERN = /^(?:https?:\/\/|mailto:|tel:|#)/;
|
||||
/**
|
||||
* The ONE link shape for a project: a page, an external URL (also mailto:,
|
||||
* tel:, #anchor) or an uploaded file — plus label, new-tab flag and visual
|
||||
* style. Every CTA, card link and download in every block uses this field, so
|
||||
* there is no zoo of ctaLabel / buttonUrl / pdfUrl fields and one renderer
|
||||
* (resolveLinkHref + the project's CMSLink) handles them all.
|
||||
*
|
||||
* Generates a named TypeScript type `CmsLink` in payload-types.ts.
|
||||
*
|
||||
* fields: [buildLinkField()] // single link
|
||||
* fields: [buildLinkField({ disableLabel: true, appearances: false })] // clickable card
|
||||
*/ export function buildLinkField({ name = 'link', appearances = [
|
||||
'primary',
|
||||
'secondary',
|
||||
'link'
|
||||
], disableLabel = false, relationTo = 'pages', required = false, uploadTo = 'media' } = {}) {
|
||||
const fields = [
|
||||
{
|
||||
type: 'row',
|
||||
fields: [
|
||||
{
|
||||
name: 'type',
|
||||
type: 'radio',
|
||||
admin: {
|
||||
layout: 'horizontal',
|
||||
width: '50%'
|
||||
},
|
||||
defaultValue: 'internal',
|
||||
options: [
|
||||
{
|
||||
label: 'Page',
|
||||
value: 'internal'
|
||||
},
|
||||
{
|
||||
label: 'URL',
|
||||
value: 'external'
|
||||
},
|
||||
{
|
||||
label: 'File',
|
||||
value: 'file'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'newTab',
|
||||
type: 'checkbox',
|
||||
admin: {
|
||||
style: {
|
||||
alignSelf: 'flex-end'
|
||||
},
|
||||
width: '50%'
|
||||
},
|
||||
label: 'Open in new tab'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'page',
|
||||
type: 'relationship',
|
||||
admin: {
|
||||
condition: (_, s)=>s?.type === 'internal'
|
||||
},
|
||||
relationTo,
|
||||
required
|
||||
},
|
||||
{
|
||||
name: 'url',
|
||||
type: 'text',
|
||||
admin: {
|
||||
condition: (_, s)=>s?.type === 'external',
|
||||
description: 'Full URL (https://…), mailto:, tel: or #section-anchor.'
|
||||
},
|
||||
required,
|
||||
validate: (v)=>!v || URL_PATTERN.test(v) || 'Use https://…, mailto:, tel: or #anchor'
|
||||
},
|
||||
{
|
||||
name: 'file',
|
||||
type: 'upload',
|
||||
admin: {
|
||||
condition: (_, s)=>s?.type === 'file',
|
||||
description: 'Upload a PDF / document / image. Never paste a file URL.'
|
||||
},
|
||||
relationTo: uploadTo,
|
||||
required
|
||||
}
|
||||
];
|
||||
if (!disableLabel) {
|
||||
fields.push({
|
||||
name: 'label',
|
||||
type: 'text',
|
||||
localized: true,
|
||||
required
|
||||
});
|
||||
}
|
||||
if (appearances && appearances.length) {
|
||||
fields.push({
|
||||
name: 'appearance',
|
||||
type: 'select',
|
||||
defaultValue: appearances[0],
|
||||
options: appearances.map((a)=>({
|
||||
label: a,
|
||||
value: a
|
||||
}))
|
||||
});
|
||||
}
|
||||
return {
|
||||
name,
|
||||
type: 'group',
|
||||
admin: {
|
||||
hideGutter: true
|
||||
},
|
||||
fields,
|
||||
interfaceName: 'CmsLink'
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 0..N buttons — use for every "CTA(s)" of a section. Each row holds one
|
||||
* `link` (buildLinkField). Render: `links.map(({ id, link }) => <CMSLink … />)`.
|
||||
*/ export function buildLinksField({ name = 'links', labels = {
|
||||
plural: 'Buttons',
|
||||
singular: 'Button'
|
||||
}, maxRows = 2, ...linkOptions } = {}) {
|
||||
return {
|
||||
name,
|
||||
type: 'array',
|
||||
admin: {
|
||||
initCollapsed: true,
|
||||
// Rows read "Contact us" / "Download catalogue", not "Button 01". Needs the importMap entry.
|
||||
components: rowLabel([
|
||||
'link.label',
|
||||
'link.url'
|
||||
], labels.singular)
|
||||
},
|
||||
fields: [
|
||||
buildLinkField(linkOptions)
|
||||
],
|
||||
label: labels.plural,
|
||||
labels,
|
||||
maxRows
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=buildLinkField.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export { buildLinkField, buildLinksField } from './buildLinkField.js';
|
||||
export type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance } from './buildLinkField.js';
|
||||
export { resolveLinkHref } from './resolveLinkHref.js';
|
||||
export type { LinkValue, ResolveLinkHrefOptions } from './resolveLinkHref.js';
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export { buildLinkField, buildLinksField } from './buildLinkField.js';
|
||||
export { resolveLinkHref } from './resolveLinkHref.js';
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/links/index.ts"],"sourcesContent":["export { buildLinkField, buildLinksField } from './buildLinkField.js'\nexport type { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance } from './buildLinkField.js'\nexport { resolveLinkHref } from './resolveLinkHref.js'\nexport type { LinkValue, ResolveLinkHrefOptions } from './resolveLinkHref.js'\n"],"names":["buildLinkField","buildLinksField","resolveLinkHref"],"mappings":"AAAA,SAASA,cAAc,EAAEC,eAAe,QAAQ,sBAAqB;AAErE,SAASC,eAAe,QAAQ,uBAAsB"}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import type { I18nConfig } from '../i18n/index.js';
|
||||
/**
|
||||
* Minimal shape of a link value (the project's generated `CmsLink` fits it).
|
||||
* The plugin doesn't know the project's types — only this contract.
|
||||
*/
|
||||
export type LinkValue = {
|
||||
appearance?: null | string;
|
||||
file?: unknown;
|
||||
label?: null | string;
|
||||
newTab?: boolean | null;
|
||||
page?: unknown;
|
||||
type?: 'external' | 'file' | 'internal' | null;
|
||||
url?: null | string;
|
||||
};
|
||||
export type ResolveLinkHrefOptions = {
|
||||
config: I18nConfig;
|
||||
/**
|
||||
* Slug(s) of the homepage so it collapses to /{locale}. A per-locale map or a
|
||||
* string. Usually from SiteSettings.homepage.
|
||||
*/
|
||||
homeSlug?: Record<string, string> | string;
|
||||
locale: string;
|
||||
};
|
||||
/**
|
||||
* Turns a link value (buildLinkField) into an href — the single place that
|
||||
* knows the link types. Returns null when the link is empty or its target is
|
||||
* missing in this locale (deleted page, page not populated, no file).
|
||||
*
|
||||
* Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID
|
||||
* resolves to null.
|
||||
*
|
||||
* resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
|
||||
* // internal → '/en/about' · external → 'https://…' · file → media URL
|
||||
*/
|
||||
export declare function resolveLinkHref(link: LinkValue | null | undefined, { config, homeSlug, locale }: ResolveLinkHrefOptions): null | string;
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import { buildLocalizedPath } from '../i18n/index.js';
|
||||
/**
|
||||
* Turns a link value (buildLinkField) into an href — the single place that
|
||||
* knows the link types. Returns null when the link is empty or its target is
|
||||
* missing in this locale (deleted page, page not populated, no file).
|
||||
*
|
||||
* Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID
|
||||
* resolves to null.
|
||||
*
|
||||
* resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })
|
||||
* // internal → '/en/about' · external → 'https://…' · file → media URL
|
||||
*/ export function resolveLinkHref(link, { config, homeSlug, locale }) {
|
||||
if (!link) {
|
||||
return null;
|
||||
}
|
||||
if (link.type === 'external') {
|
||||
return link.url?.trim() || null;
|
||||
}
|
||||
if (link.type === 'file') {
|
||||
const file = link.file;
|
||||
if (file && typeof file === 'object' && 'url' in file) {
|
||||
const url = file.url;
|
||||
return typeof url === 'string' && url ? url : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// internal (default)
|
||||
const page = link.page;
|
||||
if (!page || typeof page !== 'object') {
|
||||
return null;
|
||||
}
|
||||
const slug = page.slug;
|
||||
if (typeof slug !== 'string' || !slug) {
|
||||
return null;
|
||||
}
|
||||
return buildLocalizedPath({
|
||||
config,
|
||||
locale,
|
||||
slugs: {
|
||||
[locale]: slug
|
||||
},
|
||||
...homeSlug ? {
|
||||
homeSlug
|
||||
} : {}
|
||||
}) ?? null;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=resolveLinkHref.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/links/resolveLinkHref.ts"],"sourcesContent":["import type { I18nConfig } from '../i18n/index.js'\n\nimport { buildLocalizedPath } from '../i18n/index.js'\n\n/**\n * Minimal shape of a link value (the project's generated `CmsLink` fits it).\n * The plugin doesn't know the project's types — only this contract.\n */\nexport type LinkValue = {\n appearance?: null | string\n file?: unknown\n label?: null | string\n newTab?: boolean | null\n page?: unknown\n type?: 'external' | 'file' | 'internal' | null\n url?: null | string\n}\n\nexport type ResolveLinkHrefOptions = {\n config: I18nConfig\n /**\n * Slug(s) of the homepage so it collapses to /{locale}. A per-locale map or a\n * string. Usually from SiteSettings.homepage.\n */\n homeSlug?: Record<string, string> | string\n locale: string\n}\n\n/**\n * Turns a link value (buildLinkField) into an href — the single place that\n * knows the link types. Returns null when the link is empty or its target is\n * missing in this locale (deleted page, page not populated, no file).\n *\n * Internal links need the related page POPULATED (block depth ≥ 2) — a bare ID\n * resolves to null.\n *\n * resolveLinkHref(link, { locale, config: i18nConfig, homeSlug })\n * // internal → '/en/about' · external → 'https://…' · file → media URL\n */\nexport function resolveLinkHref(\n link: LinkValue | null | undefined,\n { config, homeSlug, locale }: ResolveLinkHrefOptions,\n): null | string {\n if (!link) {return null}\n\n if (link.type === 'external') {return link.url?.trim() || null}\n\n if (link.type === 'file') {\n const file = link.file\n if (file && typeof file === 'object' && 'url' in file) {\n const url = (file as { url?: unknown }).url\n return typeof url === 'string' && url ? url : null\n }\n return null\n }\n\n // internal (default)\n const page = link.page\n if (!page || typeof page !== 'object') {return null}\n const slug = (page as { slug?: unknown }).slug\n if (typeof slug !== 'string' || !slug) {return null}\n\n return (\n buildLocalizedPath({\n config,\n locale,\n slugs: { [locale]: slug },\n ...(homeSlug ? { homeSlug } : {}),\n }) ?? null\n )\n}\n"],"names":["buildLocalizedPath","resolveLinkHref","link","config","homeSlug","locale","type","url","trim","file","page","slug","slugs"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,mBAAkB;AA0BrD;;;;;;;;;;CAUC,GACD,OAAO,SAASC,gBACdC,IAAkC,EAClC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAA0B;IAEpD,IAAI,CAACH,MAAM;QAAC,OAAO;IAAI;IAEvB,IAAIA,KAAKI,IAAI,KAAK,YAAY;QAAC,OAAOJ,KAAKK,GAAG,EAAEC,UAAU;IAAI;IAE9D,IAAIN,KAAKI,IAAI,KAAK,QAAQ;QACxB,MAAMG,OAAOP,KAAKO,IAAI;QACtB,IAAIA,QAAQ,OAAOA,SAAS,YAAY,SAASA,MAAM;YACrD,MAAMF,MAAM,AAACE,KAA2BF,GAAG;YAC3C,OAAO,OAAOA,QAAQ,YAAYA,MAAMA,MAAM;QAChD;QACA,OAAO;IACT;IAEA,qBAAqB;IACrB,MAAMG,OAAOR,KAAKQ,IAAI;IACtB,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU;QAAC,OAAO;IAAI;IACnD,MAAMC,OAAO,AAACD,KAA4BC,IAAI;IAC9C,IAAI,OAAOA,SAAS,YAAY,CAACA,MAAM;QAAC,OAAO;IAAI;IAEnD,OACEX,mBAAmB;QACjBG;QACAE;QACAO,OAAO;YAAE,CAACP,OAAO,EAAEM;QAAK;QACxB,GAAIP,WAAW;YAAEA;QAAS,IAAI,CAAC,CAAC;IAClC,MAAM;AAEV"}
|
||||
Vendored
+10
@@ -10,6 +10,16 @@ type CreateMcpRouteArgs = {
|
||||
/** Archive-backed collections (same as the plugin option) for get_page. */
|
||||
content?: ContentOption;
|
||||
getCachedPayload: () => Promise<BasePayload>;
|
||||
/** Max messages in one JSON-RPC batch. Default 10. */
|
||||
maxBatch?: number;
|
||||
/**
|
||||
* Per-IP limit on JSON-RPC messages (a batch counts every message) (in memory, per instance). Default { max: 60, windowMs: 60_000 }.
|
||||
* `false` = off (a limiter in front, e.g. Cloudflare WAF rate limiting).
|
||||
*/
|
||||
rateLimit?: {
|
||||
max?: number;
|
||||
windowMs?: number;
|
||||
} | false;
|
||||
/** Server name advertised in `initialize`. Default 'ipal-site'. */
|
||||
serverName?: string;
|
||||
/** Server version advertised in `initialize`. Default '1.0.0'. */
|
||||
|
||||
Vendored
+26
-1
@@ -1,5 +1,6 @@
|
||||
import { createMarkdownRenderer, searchContent } from '../content/index.js';
|
||||
import { getDefaultLocale, isValidLocale } from '../i18n/index.js';
|
||||
import { checkRateLimit, clientIp, tooManyRequests } from '../shared/rateLimit.js';
|
||||
/**
|
||||
* A read-only MCP (Model Context Protocol) server for the client site, as a Next
|
||||
* route handler. Lets Claude / any MCP client CONNECT to the site and query it
|
||||
@@ -59,7 +60,12 @@ function toolText(text, isError = false) {
|
||||
};
|
||||
}
|
||||
export function createMcpRoute(args) {
|
||||
const { baseUrl, collection = 'pages', config, content, getCachedPayload, serverName = 'ipal-site', serverVersion = '1.0.0', settingsSlug = 'site-settings', summaryField } = args;
|
||||
const { baseUrl, collection = 'pages', config, content, getCachedPayload, maxBatch = 10, serverName = 'ipal-site', serverVersion = '1.0.0', settingsSlug = 'site-settings', summaryField } = args;
|
||||
const rl = args.rateLimit === false ? null : {
|
||||
max: 60,
|
||||
windowMs: 60_000,
|
||||
...args.rateLimit
|
||||
};
|
||||
const origin = baseUrl?.replace(/\/$/, '') ?? '';
|
||||
const renderMarkdown = createMarkdownRenderer({
|
||||
collection,
|
||||
@@ -217,6 +223,25 @@ export function createMcpRoute(args) {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
// Limits: a batch counts as many requests as it has messages, and is capped —
|
||||
// otherwise one POST could carry hundreds of tool calls (DB queries).
|
||||
const messages = Array.isArray(body) ? body.length : 1;
|
||||
if (Array.isArray(body) && body.length > maxBatch) {
|
||||
return Response.json(rpcError(null, -32600, `Batch too large (max ${maxBatch})`), {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
if (rl) {
|
||||
const ip = clientIp(req);
|
||||
if (!checkRateLimit({
|
||||
cost: messages,
|
||||
key: ip,
|
||||
scope: 'mcp',
|
||||
...rl
|
||||
})) {
|
||||
return tooManyRequests(ip, 'mcp', rpcError(null, -32000, 'Too many requests'));
|
||||
}
|
||||
}
|
||||
// Batch or single.
|
||||
if (Array.isArray(body)) {
|
||||
const out = (await Promise.all(body.map((m)=>handleOne(m)))).filter((r)=>r !== null);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -1 +1,3 @@
|
||||
export { normalizeFilename, normalizeFilenameHook } from './normalizeFilename.js';
|
||||
export { buildOptimizeUploadField, buildOptimizeUploadHook } from './optimizeUpload.js';
|
||||
export type { OptimizeUploadOptions } from './optimizeUpload.js';
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
export { normalizeFilename, normalizeFilenameHook } from './normalizeFilename.js';
|
||||
export { buildOptimizeUploadField, buildOptimizeUploadHook } from './optimizeUpload.js';
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/media/index.ts"],"sourcesContent":["export { normalizeFilename, normalizeFilenameHook } from './normalizeFilename.js'\n"],"names":["normalizeFilename","normalizeFilenameHook"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,qBAAqB,QAAQ,yBAAwB"}
|
||||
{"version":3,"sources":["../../../src/modules/media/index.ts"],"sourcesContent":["export { normalizeFilename, normalizeFilenameHook } from './normalizeFilename.js'\nexport { buildOptimizeUploadField, buildOptimizeUploadHook } from './optimizeUpload.js'\nexport type { OptimizeUploadOptions } from './optimizeUpload.js'\n"],"names":["normalizeFilename","normalizeFilenameHook","buildOptimizeUploadField","buildOptimizeUploadHook"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,qBAAqB,QAAQ,yBAAwB;AACjF,SAASC,wBAAwB,EAAEC,uBAAuB,QAAQ,sBAAqB"}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import type { CheckboxField, CollectionBeforeOperationHook } from 'payload';
|
||||
/**
|
||||
* Safety net for oversized uploads — NOT an image pipeline. The developer and
|
||||
* editor are expected to upload prepared files; this only catches the 8 MB
|
||||
* phone photo or the raw 300 MB video, and asks before touching anything.
|
||||
*
|
||||
* - JPG / PNG over the limits → upload is stopped with an explanation; the
|
||||
* editor ticks "Optimize this upload" and saves again → converted to WebP,
|
||||
* resized to maxImageWidth, auto-rotated, metadata (EXIF/GPS) removed.
|
||||
* - Video over maxVideoBytes → stopped with export instructions (never
|
||||
* transcoded — that needs ffmpeg and minutes of CPU per file).
|
||||
* - Everything else (GIF, SVG, WebP, AVIF, PDF, animated images) → untouched.
|
||||
*
|
||||
* Uses the `sharp` instance passed to buildConfig({ sharp }) — the plugin
|
||||
* never imports sharp itself.
|
||||
*/
|
||||
export type OptimizeUploadOptions = {
|
||||
/** Name of the consent checkbox (buildOptimizeUploadField). Default 'optimizeOnUpload'. */
|
||||
consentField?: string;
|
||||
/** Image size limit in bytes. Default 1.5 MB. */
|
||||
maxImageBytes?: number;
|
||||
/** Image width limit in px — also the target width after optimizing. Default 2560. */
|
||||
maxImageWidth?: number;
|
||||
/** Video size limit in bytes. Default 20 MB. `false` = no video limit. */
|
||||
maxVideoBytes?: false | number;
|
||||
/**
|
||||
* PNG handling: 'lossless' (default — safe for screenshots, logos, text) or
|
||||
* 'lossy' (much smaller, may soften fine text).
|
||||
*/
|
||||
png?: 'lossless' | 'lossy';
|
||||
/** WebP quality for lossy output (JPG, and PNG when png: 'lossy'). Default 82. */
|
||||
quality?: number;
|
||||
};
|
||||
/**
|
||||
* Consent checkbox for the upload collection's sidebar. Unticked by default;
|
||||
* only read when a file exceeds the limits.
|
||||
*/
|
||||
export declare function buildOptimizeUploadField(name?: string): CheckboxField;
|
||||
/**
|
||||
* beforeOperation hook for an upload collection (e.g. Media):
|
||||
*
|
||||
* hooks: { beforeOperation: [normalizeFilenameHook, buildOptimizeUploadHook()] },
|
||||
* fields: [..., buildOptimizeUploadField()],
|
||||
*/
|
||||
export declare function buildOptimizeUploadHook(options?: OptimizeUploadOptions): CollectionBeforeOperationHook;
|
||||
Vendored
+107
@@ -0,0 +1,107 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { APIError } from 'payload';
|
||||
const OPTIMIZABLE = new Set([
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
]);
|
||||
const MB = 1024 * 1024;
|
||||
const fmt = (bytes)=>`${(bytes / MB).toFixed(1)} MB`;
|
||||
/**
|
||||
* Consent checkbox for the upload collection's sidebar. Unticked by default;
|
||||
* only read when a file exceeds the limits.
|
||||
*/ export function buildOptimizeUploadField(name = 'optimizeOnUpload') {
|
||||
return {
|
||||
name,
|
||||
type: 'checkbox',
|
||||
admin: {
|
||||
description: 'Only used when an image is too large: converts it to WebP, resizes it and removes metadata (EXIF/GPS). Prepared files are never changed.',
|
||||
position: 'sidebar'
|
||||
},
|
||||
defaultValue: false,
|
||||
label: 'Optimize this upload'
|
||||
};
|
||||
}
|
||||
/**
|
||||
* beforeOperation hook for an upload collection (e.g. Media):
|
||||
*
|
||||
* hooks: { beforeOperation: [normalizeFilenameHook, buildOptimizeUploadHook()] },
|
||||
* fields: [..., buildOptimizeUploadField()],
|
||||
*/ export function buildOptimizeUploadHook(options = {}) {
|
||||
const { consentField = 'optimizeOnUpload', maxImageBytes = 1.5 * MB, maxImageWidth = 2560, maxVideoBytes = 20 * MB, png = 'lossless', quality = 82 } = options;
|
||||
return async ({ args, operation, req })=>{
|
||||
if (operation !== 'create' && operation !== 'update') {
|
||||
return;
|
||||
}
|
||||
const file = req.file;
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
const data = args.data;
|
||||
const consent = Boolean(data?.[consentField]);
|
||||
const size = file.size || file.data?.length || 0;
|
||||
// --- Video: limit only, never transcoded ---
|
||||
if (file.mimetype.startsWith('video/')) {
|
||||
if (maxVideoBytes !== false && size > maxVideoBytes) {
|
||||
throw new APIError(`Video is ${fmt(size)} (limit ${fmt(maxVideoBytes)}). Export it before uploading: ` + 'MP4 (H.264), 720p–1080p, about 2–4 Mbit/s, no audio track for background videos, ' + '"web optimized" / fast start enabled (e.g. HandBrake preset "Web").', 400, undefined, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!OPTIMIZABLE.has(file.mimetype)) {
|
||||
return;
|
||||
} // GIF, SVG, WebP, AVIF, PDF… untouched
|
||||
const sharp = req.payload.config.sharp;
|
||||
const buffer = file.data && file.data.length > 0 ? file.data : file.tempFilePath ? await readFile(file.tempFilePath) : undefined;
|
||||
if (!buffer) {
|
||||
return;
|
||||
}
|
||||
let width;
|
||||
let animated = false;
|
||||
if (sharp) {
|
||||
const meta = await sharp(buffer).metadata();
|
||||
width = meta.width;
|
||||
animated = (meta.pages ?? 1) > 1;
|
||||
}
|
||||
if (animated) {
|
||||
return;
|
||||
} // APNG — converting would drop the animation
|
||||
const tooHeavy = size > maxImageBytes;
|
||||
const tooWide = width !== undefined && width > maxImageWidth;
|
||||
if (!tooHeavy && !tooWide) {
|
||||
return;
|
||||
}
|
||||
const problem = [
|
||||
tooHeavy ? `${fmt(size)} (limit ${fmt(maxImageBytes)})` : null,
|
||||
tooWide ? `${width} px wide (limit ${maxImageWidth} px)` : null
|
||||
].filter(Boolean).join(', ');
|
||||
if (!consent) {
|
||||
throw new APIError(`Image is ${problem}. Tick "Optimize this upload" in the sidebar and save again to convert it ` + `to WebP (max ${maxImageWidth} px wide, metadata removed), or upload a smaller file.`, 400, undefined, true);
|
||||
}
|
||||
if (!sharp) {
|
||||
throw new APIError('Image optimization needs sharp: pass it to buildConfig({ sharp }) in payload.config.ts.', 500, undefined, true);
|
||||
}
|
||||
const lossless = file.mimetype === 'image/png' && png === 'lossless';
|
||||
const output = await sharp(buffer).rotate() // apply EXIF orientation before metadata is dropped
|
||||
.resize({
|
||||
width: maxImageWidth,
|
||||
withoutEnlargement: true
|
||||
}).webp(lossless ? {
|
||||
lossless: true
|
||||
} : {
|
||||
quality
|
||||
}).toBuffer();
|
||||
// Conversion didn't help (rare) and the width was fine → keep the original.
|
||||
if (output.length >= size && !tooWide) {
|
||||
return;
|
||||
}
|
||||
file.data = output;
|
||||
file.size = output.length;
|
||||
file.mimetype = 'image/webp';
|
||||
file.name = `${file.name.replace(/\.[^.]+$/, '')}.webp`;
|
||||
delete file.tempFilePath; // Payload must read the new buffer, not the temp file
|
||||
if (data) {
|
||||
data[consentField] = false;
|
||||
} // next oversized upload asks again
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=optimizeUpload.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import type { ReactNode } from 'react';
|
||||
type LocaleViewProps = {
|
||||
/** Used when the URL has no locale segment (single-locale site) or an unknown one. */
|
||||
defaultLocale: string;
|
||||
/**
|
||||
* One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.
|
||||
* Rendered on the SERVER (RSC) and passed in as props — this component only
|
||||
* picks one, so the content can come from the panel and the route stays static.
|
||||
*/
|
||||
views: Record<string, ReactNode>;
|
||||
};
|
||||
/**
|
||||
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
|
||||
*
|
||||
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
|
||||
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
|
||||
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
|
||||
* it also runs during SSR, so the HTML already contains the right language.
|
||||
*/
|
||||
export declare function LocaleView({ defaultLocale, views }: LocaleViewProps): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
'use client';
|
||||
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
// '.js' is required: `next` has no package.json "exports", so NodeNext resolution
|
||||
// (this plugin's tsconfig) can't find 'next/navigation' without the extension.
|
||||
// Bundlers in the project resolve the same file either way.
|
||||
import { usePathname } from 'next/navigation.js';
|
||||
/**
|
||||
* Shows the view matching the locale in the current URL (`/en/...` → `en`).
|
||||
*
|
||||
* Made for `not-found.tsx`, which receives no `params`: reading the locale with
|
||||
* `headers()` there turns an SSG/ISR route dynamic ("Page changed from static
|
||||
* to dynamic at runtime"). `usePathname()` is client-side and static-safe, and
|
||||
* it also runs during SSR, so the HTML already contains the right language.
|
||||
*/ export function LocaleView({ defaultLocale, views }) {
|
||||
const pathname = usePathname() ?? '';
|
||||
const segment = pathname.split('/').filter(Boolean)[0] ?? '';
|
||||
const locale = segment in views ? segment : defaultLocale;
|
||||
return /*#__PURE__*/ _jsx(_Fragment, {
|
||||
children: views[locale] ?? views[defaultLocale] ?? null
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=LocaleView.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/pages/LocaleView.tsx"],"sourcesContent":["'use client'\nimport type { ReactNode } from 'react'\n// '.js' is required: `next` has no package.json \"exports\", so NodeNext resolution\n// (this plugin's tsconfig) can't find 'next/navigation' without the extension.\n// Bundlers in the project resolve the same file either way.\nimport { usePathname } from 'next/navigation.js'\n\ntype LocaleViewProps = {\n /** Used when the URL has no locale segment (single-locale site) or an unknown one. */\n defaultLocale: string\n /**\n * One pre-rendered view per locale, e.g. { pl: <RenderBlocks …/>, en: … }.\n * Rendered on the SERVER (RSC) and passed in as props — this component only\n * picks one, so the content can come from the panel and the route stays static.\n */\n views: Record<string, ReactNode>\n}\n\n/**\n * Shows the view matching the locale in the current URL (`/en/...` → `en`).\n *\n * Made for `not-found.tsx`, which receives no `params`: reading the locale with\n * `headers()` there turns an SSG/ISR route dynamic (\"Page changed from static\n * to dynamic at runtime\"). `usePathname()` is client-side and static-safe, and\n * it also runs during SSR, so the HTML already contains the right language.\n */\nexport function LocaleView({ defaultLocale, views }: LocaleViewProps) {\n const pathname = usePathname() ?? ''\n const segment = pathname.split('/').filter(Boolean)[0] ?? ''\n const locale = segment in views ? segment : defaultLocale\n return <>{views[locale] ?? views[defaultLocale] ?? null}</>\n}\n"],"names":["usePathname","LocaleView","defaultLocale","views","pathname","segment","split","filter","Boolean","locale"],"mappings":"AAAA;;AAEA,kFAAkF;AAClF,+EAA+E;AAC/E,4DAA4D;AAC5D,SAASA,WAAW,QAAQ,qBAAoB;AAahD;;;;;;;CAOC,GACD,OAAO,SAASC,WAAW,EAAEC,aAAa,EAAEC,KAAK,EAAmB;IAClE,MAAMC,WAAWJ,iBAAiB;IAClC,MAAMK,UAAUD,SAASE,KAAK,CAAC,KAAKC,MAAM,CAACC,QAAQ,CAAC,EAAE,IAAI;IAC1D,MAAMC,SAASJ,WAAWF,QAAQE,UAAUH;IAC5C,qBAAO;kBAAGC,KAAK,CAACM,OAAO,IAAIN,KAAK,CAACD,cAAc,IAAI;;AACrD"}
|
||||
Vendored
+2
-1
@@ -68,7 +68,8 @@
|
||||
"'none'"
|
||||
]
|
||||
};
|
||||
if (r2Url) {
|
||||
// Site-relative R2_PUBLIC_URL ('/media', dev) is same-origin — already covered by 'self'.
|
||||
if (r2Url && /^https?:\/\//i.test(r2Url)) {
|
||||
src['img-src'].push(r2Url);
|
||||
}
|
||||
if (turnstile) {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+28
-7
@@ -14,7 +14,13 @@ type RobotRule = {
|
||||
export declare const AI_ASSISTANT_BOTS: readonly ["ClaudeBot", "Claude-Web", "Claude-SearchBot", "ChatGPT-User", "OAI-SearchBot", "PerplexityBot", "Perplexity-User"];
|
||||
export declare const AI_TRAINING_BOTS: readonly ["GPTBot", "Google-Extended", "CCBot", "anthropic-ai", "Applebot-Extended", "Bytespider", "Meta-ExternalAgent"];
|
||||
type AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false;
|
||||
type BuildRobotsArgs = {
|
||||
export type RobotsOptions = {
|
||||
/**
|
||||
* Admin path to disallow. Default '/admin'. With a hidden panel
|
||||
* (ipalKit adminRoute) pass `false`: robots.txt is public, so listing the
|
||||
* path would reveal it — the admin is noindex anyway.
|
||||
*/
|
||||
adminRoute?: false | string;
|
||||
/** Override the assistant/search bot list. */
|
||||
aiAssistantAgents?: readonly string[];
|
||||
/**
|
||||
@@ -31,13 +37,27 @@ type BuildRobotsArgs = {
|
||||
aiBots?: AiBotsPolicy;
|
||||
/** Override the training crawler list. */
|
||||
aiTrainingAgents?: readonly string[];
|
||||
/** Absolute origin, e.g. 'https://example.com'. */
|
||||
baseUrl: string;
|
||||
/** Paths to disallow. Defaults to Payload's admin and API. */
|
||||
/**
|
||||
* Full disallow list — REPLACES the defaults ([adminRoute, '/api']). Prefer
|
||||
* `extraDisallow` / `disallowParams`, which add to the defaults instead.
|
||||
*/
|
||||
disallow?: string[];
|
||||
/**
|
||||
* Query parameters whose URLs crawlers should skip (thin/duplicate pages that
|
||||
* waste crawl budget), e.g. ['s', 'meter', 'utm_source']. Each becomes
|
||||
* `/*?name=` and `/*&name=` (the parameter may not be first).
|
||||
* Don't list `page` — paginated archives are real, canonical-to-self pages.
|
||||
*/
|
||||
disallowParams?: string[];
|
||||
/** Paths added to the default disallow list, e.g. ['/koszyk']. */
|
||||
extraDisallow?: string[];
|
||||
/** Whether to advertise the sitemap. Defaults to true. */
|
||||
sitemap?: boolean;
|
||||
};
|
||||
type BuildRobotsArgs = {
|
||||
/** Absolute origin, e.g. 'https://example.com'. */
|
||||
baseUrl: string;
|
||||
} & RobotsOptions;
|
||||
/**
|
||||
* Shape for Next's `app/robots.ts`. `rules` may be a single rule or an array
|
||||
* (Next accepts both) — it becomes an array when AI-bot rules are added.
|
||||
@@ -68,10 +88,11 @@ export type RobotsRules = {
|
||||
* PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of
|
||||
* model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.
|
||||
*
|
||||
* Pass custom disallow to block parametrized/thin URLs that waste crawl budget:
|
||||
* Block parametrized/thin URLs that waste crawl budget — added to the defaults:
|
||||
* ```ts
|
||||
* buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })
|
||||
* buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })
|
||||
* // Disallow: /admin, /api, /*?s=, /*&s=, /*?meter=, /*&meter=
|
||||
* ```
|
||||
*/
|
||||
export declare function buildRobots({ aiAssistantAgents, aiBots, aiTrainingAgents, baseUrl, disallow, sitemap, }: BuildRobotsArgs): RobotsRules;
|
||||
export declare function buildRobots({ adminRoute, aiAssistantAgents, aiBots, aiTrainingAgents, baseUrl, disallow: disallowOverride, disallowParams, extraDisallow, sitemap, }: BuildRobotsArgs): RobotsRules;
|
||||
export {};
|
||||
|
||||
Vendored
+21
-6
@@ -44,15 +44,30 @@ export const AI_TRAINING_BOTS = [
|
||||
* PerplexityBot, Google-Extended and friends. To keep AI answers but opt out of
|
||||
* model training, use `aiBots: 'block-training'`. To block them all, 'disallow'.
|
||||
*
|
||||
* Pass custom disallow to block parametrized/thin URLs that waste crawl budget:
|
||||
* Block parametrized/thin URLs that waste crawl budget — added to the defaults:
|
||||
* ```ts
|
||||
* buildRobots({ baseUrl, disallow: ['/admin', '/api', '/*?meter=*', '/*?s=*'] })
|
||||
* buildRobots({ baseUrl, disallowParams: ['s', 'meter'] })
|
||||
* // Disallow: /admin, /api, /*?s=, /*&s=, /*?meter=, /*&meter=
|
||||
* ```
|
||||
*/ export function buildRobots({ aiAssistantAgents = AI_ASSISTANT_BOTS, aiBots = 'allow', aiTrainingAgents = AI_TRAINING_BOTS, baseUrl, disallow = [
|
||||
'/admin',
|
||||
'/api'
|
||||
], sitemap = true }) {
|
||||
*/ export function buildRobots({ adminRoute = '/admin', aiAssistantAgents = AI_ASSISTANT_BOTS, aiBots = 'allow', aiTrainingAgents = AI_TRAINING_BOTS, baseUrl, disallow: disallowOverride, disallowParams = [], extraDisallow = [], sitemap = true }) {
|
||||
const origin = baseUrl.replace(/\/$/, '');
|
||||
const defaults = [
|
||||
...adminRoute ? [
|
||||
adminRoute
|
||||
] : [],
|
||||
'/api'
|
||||
];
|
||||
const paramRules = disallowParams.map((p)=>p.trim()).filter(Boolean).flatMap((p)=>[
|
||||
`/*?${p}=`,
|
||||
`/*&${p}=`
|
||||
]);
|
||||
const disallow = [
|
||||
...new Set([
|
||||
...disallowOverride ?? defaults,
|
||||
...extraDisallow,
|
||||
...paramRules
|
||||
])
|
||||
];
|
||||
const baseRule = {
|
||||
allow: '/',
|
||||
disallow,
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+10
-1
@@ -1,5 +1,5 @@
|
||||
import type { BasePayload } from 'payload';
|
||||
import type { ContentOption } from '../content/index.js';
|
||||
import type { ContentOption, ResolvedRoute } from '../content/index.js';
|
||||
import type { I18nConfig } from '../i18n/index.js';
|
||||
import type { PageMetadata } from './buildMetadata.js';
|
||||
type CreatePageMetadataArgs = {
|
||||
@@ -14,6 +14,15 @@ type CreatePageMetadataArgs = {
|
||||
* omit it and only pages are handled.
|
||||
*/
|
||||
content?: ContentOption;
|
||||
/**
|
||||
* Request-cached loaders (createContentHelpers passes its own), so metadata
|
||||
* reuses the SAME settings read and route resolution as the layout and the
|
||||
* page component instead of querying again. Omit → plain queries.
|
||||
*/
|
||||
loaders?: {
|
||||
getSettings?: (locale: string) => Promise<null | Record<string, unknown>>;
|
||||
resolveRoute?: (locale: string, segments: string[] | undefined, page: number) => Promise<null | ResolvedRoute>;
|
||||
};
|
||||
/** SiteSettings global slug. Defaults to 'site-settings'. */
|
||||
settingsSlug?: string;
|
||||
/** Field on SiteSettings holding the site name. Defaults to 'siteName'. */
|
||||
|
||||
+6
-2
@@ -34,11 +34,14 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
* }
|
||||
* ```
|
||||
*/ export function createPageMetadata(args) {
|
||||
const { baseUrl, collection = 'pages', config, content, settingsSlug = 'site-settings', siteNameField = 'siteName' } = args;
|
||||
const { baseUrl, collection = 'pages', config, content, loaders, settingsSlug = 'site-settings', siteNameField = 'siteName' } = args;
|
||||
return async function pageMetadata({ slug, locale, page, payload }) {
|
||||
const settings = loaders?.getSettings ? await loaders.getSettings(locale) : undefined;
|
||||
const site = await readSiteMetaConfig({
|
||||
locale,
|
||||
pagesSlug: collection,
|
||||
payload,
|
||||
settings,
|
||||
settingsSlug,
|
||||
siteNameField
|
||||
});
|
||||
@@ -51,13 +54,14 @@ import { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
separator: site.separator,
|
||||
siteName: site.siteName
|
||||
};
|
||||
const route = await resolveRoute({
|
||||
const route = loaders?.resolveRoute ? await loaders.resolveRoute(locale, slug, page ?? 1) : await resolveRoute({
|
||||
content,
|
||||
locale,
|
||||
page,
|
||||
pagesSlug: collection,
|
||||
payload,
|
||||
segments: slug,
|
||||
settings,
|
||||
settingsSlug
|
||||
});
|
||||
// Unknown route (the page component will 404) — still return something
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+33
-30
@@ -1,38 +1,41 @@
|
||||
export { buildAutoFillMetaHook } from './autoFillMeta.js';
|
||||
export type { AutoFillMapping } from './autoFillMeta.js';
|
||||
export { buildArticleJsonLd } from './buildArticleJsonLd.js';
|
||||
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js';
|
||||
export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||
export { createManifestHandler } from './buildManifest.js';
|
||||
export type { SeoOption, SeoMeta } from './types.js';
|
||||
export { composeTitle } from './composeTitle.js';
|
||||
export type { TitleOrder } from './composeTitle.js';
|
||||
export { buildHreflangAlternates } from './hreflang.js';
|
||||
export { buildMetadata } from './buildMetadata.js';
|
||||
export type { PageMetadata } from './buildMetadata.js';
|
||||
export { buildNoindexField } from './buildNoindexField.js';
|
||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js';
|
||||
export type { RobotsRules } from './buildRobots.js';
|
||||
export { buildServiceJsonLd } from './buildServiceJsonLd.js';
|
||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||
export { buildAutoFillMetaHook } from './autoFillMeta.js';
|
||||
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||
export type { AutoFillMapping } from './autoFillMeta.js';
|
||||
export { createMetadataGenerator } from './createMetadataGenerator.js';
|
||||
export { createPageMetadata } from './createPageMetadata.js';
|
||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export type { SiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
export { buildSitemapEntries } from './buildSitemapEntries.js';
|
||||
export type { SitemapEntry } from './buildSitemapEntries.js';
|
||||
export { buildSitemapXml } from './buildSitemapXml.js';
|
||||
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js';
|
||||
export type { SitemapEntry } from './buildSitemapEntries.js';
|
||||
export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js';
|
||||
export type { RobotsRules, RobotsOptions } from './buildRobots.js';
|
||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||
export { validateFaviconField } from './validateFavicon.js';
|
||||
export { buildNoindexField } from './buildNoindexField.js';
|
||||
export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js';
|
||||
export { buildSummaryField } from './buildSummaryField.js';
|
||||
export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js';
|
||||
export { composeTitle } from './composeTitle.js';
|
||||
export type { TitleOrder } from './composeTitle.js';
|
||||
export { createMetadataGenerator } from './createMetadataGenerator.js';
|
||||
export { createPageMetadata } from './createPageMetadata.js';
|
||||
export { buildHreflangAlternates } from './hreflang.js';
|
||||
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||
export { JsonLdGraph } from './JsonLdGraph.js';
|
||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export type { SiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js';
|
||||
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js';
|
||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||
export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
||||
export { buildServiceJsonLd } from './buildServiceJsonLd.js';
|
||||
export { buildArticleJsonLd } from './buildArticleJsonLd.js';
|
||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js';
|
||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
export type { SeoMeta, SeoOption } from './types.js';
|
||||
export { validateFaviconField } from './validateFavicon.js';
|
||||
export type { SitemapRouteOptions } from './routeHandlers.js';
|
||||
export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js';
|
||||
export type { SitemapStyleOptions } from './sitemapStyle.js';
|
||||
export { createManifestHandler } from './buildManifest.js';
|
||||
export { JsonLdGraph } from './JsonLdGraph.js';
|
||||
|
||||
Vendored
+25
-24
@@ -1,33 +1,34 @@
|
||||
export { buildAutoFillMetaHook } from './autoFillMeta.js';
|
||||
export { buildArticleJsonLd } from './buildArticleJsonLd.js';
|
||||
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js';
|
||||
export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||
export { createManifestHandler } from './buildManifest.js';
|
||||
export { composeTitle } from './composeTitle.js';
|
||||
export { buildHreflangAlternates } from './hreflang.js';
|
||||
export { buildMetadata } from './buildMetadata.js';
|
||||
export { buildNoindexField } from './buildNoindexField.js';
|
||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js';
|
||||
export { buildServiceJsonLd } from './buildServiceJsonLd.js';
|
||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||
export { buildAutoFillMetaHook } from './autoFillMeta.js';
|
||||
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||
export { createMetadataGenerator } from './createMetadataGenerator.js';
|
||||
export { createPageMetadata } from './createPageMetadata.js';
|
||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
export { buildSitemapEntries } from './buildSitemapEntries.js';
|
||||
export { buildSitemapXml } from './buildSitemapXml.js';
|
||||
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js';
|
||||
export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js';
|
||||
export { buildIconsMetadata } from './buildIconsMetadata.js';
|
||||
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js';
|
||||
export { validateFaviconField } from './validateFavicon.js';
|
||||
export { buildNoindexField } from './buildNoindexField.js';
|
||||
export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js';
|
||||
export { buildSummaryField } from './buildSummaryField.js';
|
||||
export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js';
|
||||
export { composeTitle } from './composeTitle.js';
|
||||
export { createMetadataGenerator } from './createMetadataGenerator.js';
|
||||
export { createPageMetadata } from './createPageMetadata.js';
|
||||
export { buildHreflangAlternates } from './hreflang.js';
|
||||
export { injectAutoFillMeta } from './injectAutoFillMeta.js';
|
||||
export { injectSeoTabs } from './injectSeoTabs.js';
|
||||
export { JsonLdGraph } from './JsonLdGraph.js';
|
||||
export { readSiteMetaConfig } from './readSiteMetaConfig.js';
|
||||
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js';
|
||||
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js';
|
||||
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js';
|
||||
export { buildFaqJsonLd } from './buildFaqJsonLd.js';
|
||||
export { buildServiceJsonLd } from './buildServiceJsonLd.js';
|
||||
export { buildArticleJsonLd } from './buildArticleJsonLd.js';
|
||||
export { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js';
|
||||
export { buildSeoPlugin } from './seoPluginConfig.js';
|
||||
export { slugsAcrossLocales } from './slugsAcrossLocales.js';
|
||||
export { validateFaviconField } from './validateFavicon.js';
|
||||
export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js';
|
||||
export { createManifestHandler } from './buildManifest.js';
|
||||
export { JsonLdGraph } from './JsonLdGraph.js';
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/seo/index.ts"],"sourcesContent":["export { buildAutoFillMetaHook } from './autoFillMeta.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'\nexport type { RobotsRules } from './buildRobots.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport type { SeoMeta, SeoOption } from './types.js'\nexport { validateFaviconField } from './validateFavicon.js'\n"],"names":["buildAutoFillMetaHook","buildArticleJsonLd","buildBreadcrumbJsonLd","buildFaqJsonLd","buildIconsMetadata","buildLlmsTxt","buildLocalBusinessJsonLd","createManifestHandler","buildMetadata","buildNoindexField","buildOrganizationJsonLd","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildRobots","buildServiceJsonLd","buildSitemapEntries","buildSitemapXml","buildSiteNavigationJsonLd","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","composeTitle","createMetadataGenerator","createPageMetadata","buildHreflangAlternates","injectAutoFillMeta","injectSeoTabs","JsonLdGraph","readSiteMetaConfig","createLlmsTxtRoute","createSitemapRouteHandler","buildSeoPlugin","slugsAcrossLocales","validateFaviconField"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,oBAAmB;AAEzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,iBAAiB,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,mBAAkB;AAEnF,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,kBAAkB,EAAEC,yBAAyB,QAAQ,qBAAoB;AAClF,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,oBAAoB,QAAQ,uBAAsB"}
|
||||
{"version":3,"sources":["../../../src/modules/seo/index.ts"],"sourcesContent":["export type { SeoOption, SeoMeta } from './types.js'\nexport { composeTitle } from './composeTitle.js'\nexport type { TitleOrder } from './composeTitle.js'\nexport { buildHreflangAlternates } from './hreflang.js'\nexport { buildMetadata } from './buildMetadata.js'\nexport type { PageMetadata } from './buildMetadata.js'\nexport { buildSeoPlugin } from './seoPluginConfig.js'\nexport { buildAutoFillMetaHook } from './autoFillMeta.js'\nexport { injectAutoFillMeta } from './injectAutoFillMeta.js'\nexport { injectSeoTabs } from './injectSeoTabs.js'\nexport type { AutoFillMapping } from './autoFillMeta.js'\nexport { createMetadataGenerator } from './createMetadataGenerator.js'\nexport { createPageMetadata } from './createPageMetadata.js'\nexport { readSiteMetaConfig } from './readSiteMetaConfig.js'\nexport type { SiteMetaConfig } from './readSiteMetaConfig.js'\nexport { slugsAcrossLocales } from './slugsAcrossLocales.js'\nexport { buildSitemapEntries } from './buildSitemapEntries.js'\nexport { buildSitemapXml } from './buildSitemapXml.js'\nexport type { SitemapEntry } from './buildSitemapEntries.js'\nexport { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js'\nexport type { RobotsRules, RobotsOptions } from './buildRobots.js'\nexport { buildIconsMetadata } from './buildIconsMetadata.js'\nexport { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'\nexport { validateFaviconField } from './validateFavicon.js'\nexport { buildNoindexField } from './buildNoindexField.js'\nexport { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'\nexport { buildSummaryField } from './buildSummaryField.js'\nexport { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'\nexport { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'\nexport { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'\nexport { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'\nexport { buildFaqJsonLd } from './buildFaqJsonLd.js'\nexport { buildServiceJsonLd } from './buildServiceJsonLd.js'\nexport { buildArticleJsonLd } from './buildArticleJsonLd.js'\nexport { buildLlmsTxt } from './buildLlmsTxt.js'\nexport { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'\nexport type { SitemapRouteOptions } from './routeHandlers.js'\nexport { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js'\nexport type { SitemapStyleOptions } from './sitemapStyle.js'\nexport { createManifestHandler } from './buildManifest.js'\nexport { JsonLdGraph } from './JsonLdGraph.js'\n"],"names":["composeTitle","buildHreflangAlternates","buildMetadata","buildSeoPlugin","buildAutoFillMetaHook","injectAutoFillMeta","injectSeoTabs","createMetadataGenerator","createPageMetadata","readSiteMetaConfig","slugsAcrossLocales","buildSitemapEntries","buildSitemapXml","buildRobots","AI_ASSISTANT_BOTS","AI_TRAINING_BOTS","buildIconsMetadata","buildOrganizationJsonLd","validateFaviconField","buildNoindexField","buildSpeakableJsonLd","buildSummaryField","buildWebSiteJsonLd","buildBreadcrumbJsonLd","buildSiteNavigationJsonLd","buildLocalBusinessJsonLd","buildFaqJsonLd","buildServiceJsonLd","buildArticleJsonLd","buildLlmsTxt","createLlmsTxtRoute","createSitemapRouteHandler","buildSitemapCss","SITEMAP_STYLE_PARAM","DEFAULT_SITEMAP_CREDIT","createManifestHandler","JsonLdGraph"],"mappings":"AACA,SAASA,YAAY,QAAQ,oBAAmB;AAEhD,SAASC,uBAAuB,QAAQ,gBAAe;AACvD,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,qBAAqB,QAAQ,oBAAmB;AACzD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,aAAa,QAAQ,qBAAoB;AAElD,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,SAASC,WAAW,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,mBAAkB;AAEnF,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,oBAAoB,QAAQ,uBAAsB;AAC3D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,kBAAkB,EAAEC,yBAAyB,QAAQ,qBAAoB;AAElF,SAASC,eAAe,EAAEC,mBAAmB,EAAEC,sBAAsB,QAAQ,oBAAmB;AAEhG,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,WAAW,QAAQ,mBAAkB"}
|
||||
+5
-1
@@ -23,9 +23,13 @@ export type SiteMetaConfig = {
|
||||
* that the separator arrives unpadded, or that the home slug hides inside a
|
||||
* relationship — it should receive a resolved config.
|
||||
*/
|
||||
export declare function readSiteMetaConfig({ locale, payload, settingsSlug, siteNameField, }: {
|
||||
export declare function readSiteMetaConfig({ locale, pagesSlug, payload, settings: preloaded, settingsSlug, siteNameField, }: {
|
||||
locale: string;
|
||||
/** Collection holding the homepage. Default 'pages'. */
|
||||
pagesSlug?: string;
|
||||
payload: BasePayload;
|
||||
/** SiteSettings already read for this locale (depth ≥ 1) — skips the read. */
|
||||
settings?: null | Record<string, unknown>;
|
||||
settingsSlug?: string;
|
||||
siteNameField?: string;
|
||||
}): Promise<SiteMetaConfig>;
|
||||
|
||||
+3
-3
@@ -5,10 +5,10 @@
|
||||
* whatever an editor set in the panel. Metadata generation shouldn't also know
|
||||
* that the separator arrives unpadded, or that the home slug hides inside a
|
||||
* relationship — it should receive a resolved config.
|
||||
*/ export async function readSiteMetaConfig({ locale, payload, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
|
||||
*/ export async function readSiteMetaConfig({ locale, pagesSlug = 'pages', payload, settings: preloaded, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
|
||||
// depth 1 populates the homepage relationship, so its slug is available
|
||||
// without a second query.
|
||||
const settings = await payload.findGlobal({
|
||||
const settings = preloaded ?? await payload.findGlobal({
|
||||
slug: settingsSlug,
|
||||
depth: 1,
|
||||
locale: locale
|
||||
@@ -23,7 +23,7 @@
|
||||
try {
|
||||
const homeDoc = await payload.findByID({
|
||||
id: homepage.id,
|
||||
collection: 'pages',
|
||||
collection: pagesSlug,
|
||||
depth: 0,
|
||||
locale: 'all'
|
||||
});
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+25
-16
@@ -1,6 +1,7 @@
|
||||
import type { BasePayload } from 'payload';
|
||||
import type { I18nConfig } from '../i18n/index.js';
|
||||
import type { SitemapEntry } from './buildSitemapEntries.js';
|
||||
import { type SitemapStyleOptions } from './sitemapStyle.js';
|
||||
/**
|
||||
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
||||
* every project was copying. buildLlmsTxt already handles collections without
|
||||
@@ -31,20 +32,28 @@ export declare function createLlmsTxtRoute(opts: {
|
||||
/** Field holding a richer AI summary (buildSummaryField) to prefer as description. */
|
||||
summaryField?: string;
|
||||
}): () => Promise<Response>;
|
||||
/**
|
||||
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
||||
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
||||
* helper (from createContentHelpers) and optionally a cssUrl.
|
||||
*
|
||||
* // app/sitemap.xml/route.ts
|
||||
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
||||
* import { sitemap } from '@/lib/content'
|
||||
* export const dynamic = 'force-dynamic'
|
||||
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
||||
*
|
||||
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
||||
* confuse crawlers).
|
||||
*/
|
||||
export declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: {
|
||||
export type SitemapRouteOptions = {
|
||||
/** Legacy: your own stylesheet URL (e.g. '/sitemap.css'). Overrides `style`. */
|
||||
cssUrl?: string;
|
||||
}): () => Promise<Response>;
|
||||
/**
|
||||
* Built-in browser look (default ON): the XML points at `<this route>?style`
|
||||
* and the same handler serves the CSS — nothing to copy into /public.
|
||||
* `false` = raw XML. Object = header/credit/accent (SitemapStyleOptions);
|
||||
* `title` may be async (sitemapRoute passes the Site Settings name).
|
||||
*/
|
||||
style?: ({
|
||||
title?: (() => Promise<string | undefined>) | string;
|
||||
} & Omit<SitemapStyleOptions, 'title'>) | false;
|
||||
};
|
||||
/**
|
||||
* Ready-made Next route handler for /sitemap.xml, styled for humans out of the box.
|
||||
* Usually you don't call this — `createContentHelpers` returns `sitemapRoute`:
|
||||
*
|
||||
* // app/sitemap.xml/route.ts — the whole file
|
||||
* export { sitemapRoute as GET } from '@/lib/content'
|
||||
* export const dynamic = 'force-dynamic'
|
||||
*
|
||||
* `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS.
|
||||
* Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.
|
||||
*/
|
||||
export declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: SitemapRouteOptions): (req: Request) => Promise<Response>;
|
||||
|
||||
Vendored
+32
-11
@@ -1,5 +1,6 @@
|
||||
import { buildLlmsTxt } from './buildLlmsTxt.js';
|
||||
import { buildSitemapXml } from './buildSitemapXml.js';
|
||||
import { buildSitemapCss, SITEMAP_STYLE_PARAM } from './sitemapStyle.js';
|
||||
/**
|
||||
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
||||
* every project was copying. buildLlmsTxt already handles collections without
|
||||
@@ -49,24 +50,44 @@ import { buildSitemapXml } from './buildSitemapXml.js';
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
||||
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
||||
* helper (from createContentHelpers) and optionally a cssUrl.
|
||||
* Ready-made Next route handler for /sitemap.xml, styled for humans out of the box.
|
||||
* Usually you don't call this — `createContentHelpers` returns `sitemapRoute`:
|
||||
*
|
||||
* // app/sitemap.xml/route.ts
|
||||
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
||||
* import { sitemap } from '@/lib/content'
|
||||
* // app/sitemap.xml/route.ts — the whole file
|
||||
* export { sitemapRoute as GET } from '@/lib/content'
|
||||
* export const dynamic = 'force-dynamic'
|
||||
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
||||
*
|
||||
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
||||
* confuse crawlers).
|
||||
* `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS.
|
||||
* Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.
|
||||
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
||||
return async ()=>{
|
||||
const style = opts.cssUrl ? false : opts.style === false ? false : opts.style ?? {};
|
||||
// `req` is required: Next 16 type-checks the first argument of a route handler
|
||||
// (`Request | undefined` fails the build). A zero-argument call is not supported.
|
||||
return async (req)=>{
|
||||
const url = new URL(req.url);
|
||||
if (style && url.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||
let title;
|
||||
try {
|
||||
title = typeof style.title === 'function' ? await style.title() : style.title;
|
||||
} catch {
|
||||
title = undefined; // DB down → generic heading, never a broken stylesheet
|
||||
}
|
||||
return new Response(buildSitemapCss({
|
||||
...style,
|
||||
title
|
||||
}), {
|
||||
headers: {
|
||||
'Cache-Control': 'public, max-age=3600',
|
||||
'Content-Type': 'text/css; charset=utf-8',
|
||||
'X-Robots-Tag': 'noindex'
|
||||
}
|
||||
});
|
||||
}
|
||||
const cssUrl = opts.cssUrl ?? (style ? `${url.pathname}?${SITEMAP_STYLE_PARAM}` : undefined);
|
||||
try {
|
||||
const entries = await sitemap();
|
||||
const xml = buildSitemapXml(entries, {
|
||||
cssUrl: opts.cssUrl
|
||||
cssUrl
|
||||
});
|
||||
return new Response(xml, {
|
||||
headers: {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Built-in look of /sitemap.xml in a browser — served by the sitemap route itself
|
||||
* (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing.
|
||||
* Plain CSS on XML (W3C "Associating Style Sheets with XML", type="text/css") —
|
||||
* not XSLT, which browsers are removing. Crawlers ignore it.
|
||||
*/
|
||||
export type SitemapStyleOptions = {
|
||||
/** Accent colour (card hover). Default '#027bd0'. Any plain CSS colour. */
|
||||
accent?: string;
|
||||
/**
|
||||
* Line under the header — the technology provider. Default
|
||||
* "Technology by Intecion.com". `false` hides it.
|
||||
*/
|
||||
credit?: false | string;
|
||||
/** Header line. Default "XML Sitemap". */
|
||||
title?: string;
|
||||
};
|
||||
/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */
|
||||
export declare const SITEMAP_STYLE_PARAM = "style";
|
||||
export declare const DEFAULT_SITEMAP_CREDIT = "Technology by Intecion.com";
|
||||
export declare function buildSitemapCss({ accent, credit, title }?: SitemapStyleOptions): string;
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Built-in look of /sitemap.xml in a browser — served by the sitemap route itself
|
||||
* (`/sitemap.xml?style`), so projects ship NO sitemap.css and copy nothing.
|
||||
* Plain CSS on XML (W3C "Associating Style Sheets with XML", type="text/css") —
|
||||
* not XSLT, which browsers are removing. Crawlers ignore it.
|
||||
*/ /** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */ export const SITEMAP_STYLE_PARAM = 'style';
|
||||
export const DEFAULT_SITEMAP_CREDIT = 'Technology by Intecion.com';
|
||||
/** CSS `content: "…"` value — escapes backslashes, quotes and newlines. */ const cssString = (s)=>`"${s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/[\r\n]+/g, ' ')}"`;
|
||||
/** Only plain colour values — the option ends up inside a stylesheet. */ const safeColor = (c, fallback)=>c && /^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgb|hsl|oklch)a?\([\d\s.,%/-]+\))$/i.test(c.trim()) ? c.trim() : fallback;
|
||||
export function buildSitemapCss({ accent, credit, title } = {}) {
|
||||
const heading = title?.trim() || 'XML Sitemap';
|
||||
const note = credit === false ? '' : (credit ?? DEFAULT_SITEMAP_CREDIT).trim();
|
||||
const acc = safeColor(accent, '#027bd0');
|
||||
const divider = 'padding-bottom: 1.25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border);';
|
||||
return `:root {
|
||||
--bg: #fafafa; --card: #ffffff; --border: #e5e7eb; --border-hover: #d1d5db;
|
||||
--text-main: #111827; --text-secondary: #4b5563; --text-muted: #9ca3af; --url-color: #1e293b;
|
||||
--badge-bg: #f3f4f6; --badge-border: #e5e7eb; --badge-text: #4b5563; --accent: ${acc};
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: #090a0f; --card: #12131a; --border: #1e202e; --border-hover: #2e3247;
|
||||
--text-main: #f9fafb; --text-secondary: #9ca3af; --text-muted: #6b7280; --url-color: #f3f4f6;
|
||||
--badge-bg: #1a1c26; --badge-border: #282b3d; --badge-text: #9ca3af;
|
||||
}
|
||||
}
|
||||
urlset {
|
||||
display: flex; flex-direction: column; box-sizing: border-box; min-height: 100vh;
|
||||
max-width: 1040px; margin: 0 auto; padding: 3rem 1.5rem; line-height: 1.5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
|
||||
background-color: var(--bg); color: var(--text-main);
|
||||
}
|
||||
urlset::before {
|
||||
content: ${cssString(heading)};
|
||||
display: block; order: -2; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em;
|
||||
color: var(--text-main); ${note ? 'padding-bottom: 0.4rem;' : divider}
|
||||
}
|
||||
${note ? `urlset::after {
|
||||
content: ${cssString(note)};
|
||||
display: block; order: -1; font-size: 0.8rem; color: var(--text-muted); ${divider}
|
||||
}
|
||||
` : ''}url {
|
||||
display: block; width: 100%; order: 0; box-sizing: border-box;
|
||||
background-color: var(--card); border: 1px solid var(--border); border-radius: 8px;
|
||||
padding: 1rem 1.25rem; margin-bottom: 0.65rem;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
url:hover { border-color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); }
|
||||
loc {
|
||||
display: block; margin-bottom: 0.45rem; word-break: break-all; line-height: 1.45;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
||||
font-size: 0.875rem; font-weight: 500; color: var(--url-color);
|
||||
}
|
||||
lastmod, changefreq, priority {
|
||||
display: inline-block; font-size: 0.775rem; color: var(--text-secondary);
|
||||
margin-right: 1.25rem; margin-top: 0.15rem;
|
||||
}
|
||||
lastmod::before { content: "Updated: "; color: var(--text-muted); }
|
||||
changefreq::before { content: "Frequency: "; color: var(--text-muted); }
|
||||
priority::before { content: "Priority: "; color: var(--text-muted); }
|
||||
link {
|
||||
display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
|
||||
background-color: var(--badge-bg); border: 1px solid var(--badge-border); color: var(--badge-text);
|
||||
padding: 0.1rem 0.45rem; border-radius: 4px; margin-right: 0.3rem; margin-top: 0.35rem;
|
||||
}
|
||||
link::before { content: attr(hreflang); }
|
||||
`;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=sitemapStyle.js.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
export type RateLimitArgs = {
|
||||
/** Identifier to limit on — typically the client IP. */
|
||||
key: string;
|
||||
/** Max submissions allowed per window. Defaults to 5. */
|
||||
max?: number;
|
||||
/** Separate counter space per feature, e.g. 'form', 'search', 'mcp'. Default 'form'. */
|
||||
scope?: string;
|
||||
/** Window length in ms. Defaults to 60_000 (one minute). */
|
||||
windowMs?: number;
|
||||
};
|
||||
/**
|
||||
* Returns true when the request is within the limit, false when it should be
|
||||
* rejected. A missing key (no IP) is allowed through — better to accept a
|
||||
* submission than to block everyone behind a proxy that strips the header.
|
||||
*/
|
||||
export declare function checkRateLimit({ cost, key, max, scope, windowMs }: {
|
||||
cost?: number;
|
||||
} & RateLimitArgs): boolean;
|
||||
/** Seconds until the key's window resets — for a Retry-After header. */
|
||||
export declare function retryAfterSeconds(key: string, scope?: string): number;
|
||||
/**
|
||||
* Client IP from a Request. Cloudflare's `cf-connecting-ip` first (set by the
|
||||
* edge, the real visitor), then the first `x-forwarded-for` hop, then
|
||||
* `x-real-ip`. Empty string when none — the limiter then lets the request through.
|
||||
*/
|
||||
export declare function clientIp(req: Request): string;
|
||||
/** Standard 429 for route handlers. */
|
||||
export declare function tooManyRequests(key: string, scope: string, body: unknown): Response;
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Per-key fixed window, in memory. Shared by submitForm, createSearchRoute and
|
||||
* createMcpRoute — each uses its own `scope`, so a busy search box never eats
|
||||
* into the contact form's budget.
|
||||
*
|
||||
* Deliberately simple: no Redis, no dependency. The trade-off is that the
|
||||
* counter lives in one process — with several instances behind a load balancer
|
||||
* each keeps its own, so the effective limit is per-instance, not global. For a
|
||||
* contact form that's fine (it raises the cost of flooding without pretending
|
||||
* to be airtight); a high-security form should put a real limiter in front.
|
||||
*
|
||||
* State is module-level, so it survives between requests but resets on redeploy
|
||||
* — acceptable for abuse throttling.
|
||||
*/ const buckets = new Map();
|
||||
/** Sweep expired buckets occasionally so the map doesn't grow unbounded. */ let lastSweep = Date.now();
|
||||
const SWEEP_INTERVAL = 60_000;
|
||||
function sweep(now) {
|
||||
if (now - lastSweep < SWEEP_INTERVAL) {
|
||||
return;
|
||||
}
|
||||
lastSweep = now;
|
||||
for (const [key, bucket] of buckets){
|
||||
if (bucket.resetAt <= now) {
|
||||
buckets.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns true when the request is within the limit, false when it should be
|
||||
* rejected. A missing key (no IP) is allowed through — better to accept a
|
||||
* submission than to block everyone behind a proxy that strips the header.
|
||||
*/ export function checkRateLimit({ cost = 1, key, max = 5, scope = 'form', windowMs = 60_000 }) {
|
||||
if (!key) {
|
||||
return true;
|
||||
}
|
||||
const now = Date.now();
|
||||
sweep(now);
|
||||
const id = `${scope}:${key}`;
|
||||
const bucket = buckets.get(id);
|
||||
if (!bucket || bucket.resetAt <= now) {
|
||||
if (cost > max) {
|
||||
return false;
|
||||
}
|
||||
buckets.set(id, {
|
||||
count: cost,
|
||||
resetAt: now + windowMs
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (bucket.count + cost > max) {
|
||||
return false;
|
||||
}
|
||||
bucket.count += cost;
|
||||
return true;
|
||||
}
|
||||
/** Seconds until the key's window resets — for a Retry-After header. */ export function retryAfterSeconds(key, scope = 'form') {
|
||||
const bucket = buckets.get(`${scope}:${key}`);
|
||||
return bucket ? Math.max(1, Math.ceil((bucket.resetAt - Date.now()) / 1000)) : 1;
|
||||
}
|
||||
/**
|
||||
* Client IP from a Request. Cloudflare's `cf-connecting-ip` first (set by the
|
||||
* edge, the real visitor), then the first `x-forwarded-for` hop, then
|
||||
* `x-real-ip`. Empty string when none — the limiter then lets the request through.
|
||||
*/ export function clientIp(req) {
|
||||
const h = req.headers;
|
||||
return h.get('cf-connecting-ip')?.trim() || h.get('x-forwarded-for')?.split(',')[0]?.trim() || h.get('x-real-ip')?.trim() || '';
|
||||
}
|
||||
/** Standard 429 for route handlers. */ export function tooManyRequests(key, scope, body) {
|
||||
return Response.json(body, {
|
||||
headers: {
|
||||
'cache-control': 'no-store',
|
||||
'retry-after': String(retryAfterSeconds(key, scope))
|
||||
},
|
||||
status: 429
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=rateLimit.js.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
+40
-1
@@ -1,4 +1,32 @@
|
||||
import type { Plugin } from 'payload';
|
||||
type GenerateFileURL = (args: {
|
||||
filename: string;
|
||||
prefix?: string;
|
||||
}) => string;
|
||||
/**
|
||||
* Minimal shape of `s3Storage` from @payloadcms/storage-s3 — the plugin never
|
||||
* imports that package (it's optional: projects on local disk don't install it).
|
||||
* The project injects the real function; TypeScript checks it fits this shape.
|
||||
*/
|
||||
export type S3StorageFactory = (options: {
|
||||
bucket: string;
|
||||
collections: Record<string, {
|
||||
generateFileURL: GenerateFileURL;
|
||||
} | true>;
|
||||
config: {
|
||||
credentials: {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
};
|
||||
endpoint: string;
|
||||
forcePathStyle: boolean;
|
||||
region: string;
|
||||
};
|
||||
}) => Plugin;
|
||||
export type BuildR2StorageDeps = {
|
||||
/** `import { s3Storage } from '@payloadcms/storage-s3'` — required when R2 env is set. */
|
||||
s3Storage?: S3StorageFactory;
|
||||
};
|
||||
/**
|
||||
* Cloudflare R2 media storage — configured from environment variables (agency
|
||||
* infrastructure, not per-project panel data). R2 is S3-compatible, so we use
|
||||
@@ -13,6 +41,17 @@ import type { Plugin } from 'payload';
|
||||
* storage (useful in dev without R2). This mirrors how mailAdapter degrades
|
||||
* gracefully when a transport isn't configured.
|
||||
*
|
||||
* The S3 adapter is INJECTED by the project (same pattern as 2FA / NextResponse):
|
||||
*
|
||||
* import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* plugins: [buildR2Storage(['media'], { s3Storage })]
|
||||
*
|
||||
* A static import here would make @payloadcms/storage-s3 mandatory for every
|
||||
* project — including ones on local disk — because this module is exported
|
||||
* from the package's main entry.
|
||||
*
|
||||
* @param collections - slugs of upload collections to offload to R2 (e.g. ['media'])
|
||||
* @param deps - `{ s3Storage }` from @payloadcms/storage-s3 (needed only when R2 env is set)
|
||||
*/
|
||||
export declare const buildR2Storage: (collections?: string[]) => Plugin;
|
||||
export declare const buildR2Storage: (collections?: string[], deps?: BuildR2StorageDeps) => Plugin;
|
||||
export {};
|
||||
|
||||
+22
-3
@@ -1,4 +1,3 @@
|
||||
import { s3Storage } from '@payloadcms/storage-s3';
|
||||
/**
|
||||
* Cloudflare R2 media storage — configured from environment variables (agency
|
||||
* infrastructure, not per-project panel data). R2 is S3-compatible, so we use
|
||||
@@ -13,10 +12,20 @@ import { s3Storage } from '@payloadcms/storage-s3';
|
||||
* storage (useful in dev without R2). This mirrors how mailAdapter degrades
|
||||
* gracefully when a transport isn't configured.
|
||||
*
|
||||
* The S3 adapter is INJECTED by the project (same pattern as 2FA / NextResponse):
|
||||
*
|
||||
* import { s3Storage } from '@payloadcms/storage-s3'
|
||||
* plugins: [buildR2Storage(['media'], { s3Storage })]
|
||||
*
|
||||
* A static import here would make @payloadcms/storage-s3 mandatory for every
|
||||
* project — including ones on local disk — because this module is exported
|
||||
* from the package's main entry.
|
||||
*
|
||||
* @param collections - slugs of upload collections to offload to R2 (e.g. ['media'])
|
||||
* @param deps - `{ s3Storage }` from @payloadcms/storage-s3 (needed only when R2 env is set)
|
||||
*/ export const buildR2Storage = (collections = [
|
||||
'media'
|
||||
])=>{
|
||||
], deps = {})=>{
|
||||
const bucket = process.env.R2_BUCKET;
|
||||
const endpoint = process.env.R2_ENDPOINT;
|
||||
const accessKeyId = process.env.R2_ACCESS_KEY_ID;
|
||||
@@ -36,8 +45,12 @@ import { s3Storage } from '@payloadcms/storage-s3';
|
||||
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
||||
// pointing there. Without it, uploads work but images don't display publicly.
|
||||
// See docs/storage.md.
|
||||
const publicUrl = process.env.R2_PUBLIC_URL?.replace(/\/$/, '') // strip trailing slash
|
||||
// Site-relative value ('/media', dev only — ipalEnvRules rejects it in production)
|
||||
// → prefixed with NEXT_PUBLIC_SERVER_URL so Payload still stores absolute URLs.
|
||||
const rawPublicUrl = process.env.R2_PUBLIC_URL?.trim().replace(/\/$/, '') // strip trailing slash
|
||||
;
|
||||
const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL?.trim().replace(/\/$/, '');
|
||||
const publicUrl = rawPublicUrl?.startsWith('/') && serverUrl ? `${serverUrl}${rawPublicUrl}` : rawPublicUrl;
|
||||
// generateFileURL is a PER-COLLECTION option in @payloadcms/storage-s3 (not a
|
||||
// top-level one) — R2 needs it to point served URLs at the custom domain
|
||||
// instead of the private S3 endpoint. Each collection gets either `true`
|
||||
@@ -47,6 +60,12 @@ import { s3Storage } from '@payloadcms/storage-s3';
|
||||
prefix,
|
||||
filename
|
||||
].filter(Boolean).join('/') : undefined;
|
||||
// R2 env is complete → the adapter is required. Fail loudly at boot rather
|
||||
// than silently storing media on the container disk (lost on redeploy).
|
||||
const { s3Storage } = deps;
|
||||
if (!s3Storage) {
|
||||
throw new Error('[ipal] R2 storage: R2_* env is set but the S3 adapter was not injected. ' + "Install @payloadcms/storage-s3 and pass it: buildR2Storage(['media'], { s3Storage }) " + "with `import { s3Storage } from '@payloadcms/storage-s3'`. See docs/storage.md.");
|
||||
}
|
||||
const collectionsConfig = {};
|
||||
for (const slug of collections){
|
||||
collectionsConfig[slug] = generateFileURL ? {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -1 +1,2 @@
|
||||
export { buildR2Storage } from './buildR2Storage.js';
|
||||
export type { BuildR2StorageDeps, S3StorageFactory } from './buildR2Storage.js';
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../../src/modules/storage/index.ts"],"sourcesContent":["export { buildR2Storage } from './buildR2Storage.js'\n"],"names":["buildR2Storage"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB"}
|
||||
{"version":3,"sources":["../../../src/modules/storage/index.ts"],"sourcesContent":["export { buildR2Storage } from './buildR2Storage.js'\nexport type { BuildR2StorageDeps, S3StorageFactory } from './buildR2Storage.js'\n"],"names":["buildR2Storage"],"mappings":"AAAA,SAASA,cAAc,QAAQ,sBAAqB"}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* @intecion/ipal-kit/fluid.css — fluid type & spacing scale (variables only, no classes).
|
||||
* Scales smoothly from a 360px to a 1280px viewport; rem-based, so browser zoom and
|
||||
* user font size still work (WCAG 1.4.4). Opt-in:
|
||||
*
|
||||
* @import "tailwindcss";
|
||||
* @import "@intecion/ipal-kit/fluid.css";
|
||||
* @theme inline {
|
||||
* --text-display: var(--ipal-fs-display);
|
||||
* --text-h1: var(--ipal-fs-h1);
|
||||
* --text-h2: var(--ipal-fs-h2);
|
||||
* --text-h3: var(--ipal-fs-h3);
|
||||
* --text-lead: var(--ipal-fs-lg);
|
||||
* --spacing-section: var(--ipal-space-section);
|
||||
* --spacing-gutter: var(--ipal-space-gutter);
|
||||
* --spacing-gap: var(--ipal-space-gap);
|
||||
* }
|
||||
* → text-h1, text-display, py-section, px-gutter, gap-gap
|
||||
*
|
||||
* The design (DESIGN.md) decides the numbers: override any variable in the project's
|
||||
* :root — the plugin only removes the clamp() maths from every project.
|
||||
*/
|
||||
:root {
|
||||
--ipal-fs-sm: clamp(0.875rem, 0.8505rem + 0.1087vw, 0.9375rem); /* 0.875→0.9375rem · small print, captions */
|
||||
--ipal-fs-base: clamp(1rem, 0.9511rem + 0.2174vw, 1.125rem); /* 1→1.125rem · body text */
|
||||
--ipal-fs-lg: clamp(1.125rem, 1.0272rem + 0.4348vw, 1.375rem); /* 1.125→1.375rem · lead / intro */
|
||||
--ipal-fs-h3: clamp(1.25rem, 1.0543rem + 0.8696vw, 1.75rem); /* 1.25→1.75rem · h3 */
|
||||
--ipal-fs-h2: clamp(1.5rem, 1.1087rem + 1.7391vw, 2.5rem); /* 1.5→2.5rem · h2 — section headings */
|
||||
--ipal-fs-h1: clamp(2rem, 1.413rem + 2.6087vw, 3.5rem); /* 2→3.5rem · h1 — page heading */
|
||||
--ipal-fs-display: clamp(2.5rem, 1.7174rem + 3.4783vw, 4.5rem); /* 2.5→4.5rem · hero / display */
|
||||
--ipal-space-gap: clamp(1rem, 0.6087rem + 1.7391vw, 2rem); /* 1→2rem · gap between items in a section */
|
||||
--ipal-space-gutter: clamp(1rem, 0.413rem + 2.6087vw, 2.5rem); /* 1→2.5rem · container side padding */
|
||||
--ipal-space-section: clamp(3rem, 1.2391rem + 7.8261vw, 7.5rem); /* 3→7.5rem · vertical padding of a section */
|
||||
}
|
||||
+3
-2
@@ -3,9 +3,9 @@
|
||||
| Kim jesteś | Czytaj |
|
||||
|---|---|
|
||||
| **Agent AI** pracujący w projekcie | [AGENT.md](./agent/AGENT.md) — reguły, struktura, budowa sekcji, kontrole przed „gotowe” |
|
||||
| **Agent AI — skille** | [agent/skills/](./agent/skills) — 7 skilli `ipal-*` dla Antigravity/Claude Code (kopiowane do projektu: `pnpm ipal:skills`, AGENT.md §14) |
|
||||
| **Agent AI — skille** | [agent/skills/](./agent/skills) — 14 skilli `ipal-*` dla Antigravity/Claude Code, w tym `ipal-site` (strona od briefu do raportu) i skrypty kontrolne (kopiowane do projektu: `pnpm ipal:skills`, AGENT.md §14) |
|
||||
| **Programista** | [PROGRAMISTA.md](./dev/PROGRAMISTA.md) — instalacja, nowy projekt, env, wdrożenie, aktualizacja, publikacja pluginu, Gitea |
|
||||
| **Osoba prowadząca agenta AI** | [vibe.md](./dev/vibe.md) — gotowe polecenia do wklejenia, krok po kroku, moduł po module |
|
||||
| **Osoba prowadząca agenta AI** | [vibe.md](./dev/vibe.md) — tryb autonomiczny (`/ipal-site`) i gotowe polecenia krok po kroku |
|
||||
|
||||
Szczegóły API — jeden plik na moduł:
|
||||
|
||||
@@ -22,6 +22,7 @@ Szczegóły API — jeden plik na moduł:
|
||||
| Formularze, useForm, honeypot | [forms.md](./forms.md) |
|
||||
| Hooki | [hooks.md](./hooks.md) |
|
||||
| i18n, proxy, przełącznik języka | [i18n.md](./i18n.md) |
|
||||
| Linki / CTA: buildLinkField, buildLinksField, resolveLinkHref, rowLabel | [links.md](./links.md) |
|
||||
| Serwer MCP strony | [mcp.md](./mcp.md) |
|
||||
| Komunikaty formularzy | [notifications.md](./notifications.md) |
|
||||
| Strony systemowe, 404, generateStaticParams | [pages.md](./pages.md) |
|
||||
|
||||
+230
-645
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,21 @@ UI=$(dirs src/blocks src/components)
|
||||
|
||||
echo "ipal-audit — $(pwd)"
|
||||
|
||||
# --- Skill templates must not be compiled as project code ---
|
||||
if [ -d .agents ] && [ -f tsconfig.json ]; then
|
||||
report ERROR "tsconfig.json does not exclude .agents" "skill templates (.ts/.tsx) break tsc / next build — \"exclude\": [\"node_modules\", \".agents\"]" \
|
||||
"$(grep -qE '"exclude"[^]]*\.agents' tsconfig.json || echo tsconfig.json)"
|
||||
fi
|
||||
|
||||
# --- Sitemap: one route, look from the plugin (seo.md) ---
|
||||
SM_TS=$(ls src/app/sitemap.ts 2>/dev/null)
|
||||
SM_ROUTE=$(ls src/app/sitemap.xml/route.ts 2>/dev/null)
|
||||
if [ -n "$SM_TS" ] && [ -n "$SM_ROUTE" ]; then
|
||||
report ERROR "two sitemaps" "seo.md — keep src/app/sitemap.xml/route.ts (sitemapRoute), delete src/app/sitemap.ts" "$(printf '%s\n%s' "$SM_TS" "$SM_ROUTE")"
|
||||
fi
|
||||
report WARNING "project copy of the sitemap stylesheet" "seo.md — sitemapRoute serves the look from the plugin; delete it (and cssUrl)" \
|
||||
"$(ls public/sitemap.css 2>/dev/null)"
|
||||
|
||||
# --- Architecture (AGENT.md §4) ---
|
||||
report ERROR "middleware.ts exists" "§4.1 Next 16 uses proxy.ts only" \
|
||||
"$(ls src/middleware.ts middleware.ts 2>/dev/null)"
|
||||
@@ -69,9 +84,12 @@ for r in src/app/sitemap.ts src/app/manifest.ts src/app/llms.txt/route.ts src/ap
|
||||
report ERROR "DB route without force-dynamic" "§4.7 build without DB will crash" "$r"
|
||||
done
|
||||
|
||||
report ERROR "headers() in blocks/components" "§4.6 forces dynamic rendering — pass locale via enhanceProps" \
|
||||
report ERROR "headers()/cookies() in blocks/components" "§4.6 forces dynamic rendering — pass locale via enhanceProps" \
|
||||
"$( [ -n "$UI" ] && g "from 'next/headers'" $UI)"
|
||||
|
||||
report ERROR "headers()/cookies() in static page tree" "§4.6 SSG/ISR → 'Page changed from static to dynamic' — not-found: LocaleView (pages.md)" \
|
||||
"$(g "from 'next/headers'" src/app --include=page.tsx --include=layout.tsx --include=not-found.tsx --include=template.tsx | grep -v '/api/\|(payload)')"
|
||||
|
||||
# --- Hardcoding & types (§2, §8) ---
|
||||
report ERROR "hardcoded locale map / any / ts-ignore" "§2, §8" \
|
||||
"$(g 'localizedRoutes|as any\b|@ts-ignore|: any\b' src --include=*.ts --include=*.tsx | grep -v '/payload-types.ts:')"
|
||||
@@ -90,6 +108,9 @@ if [ -n "$BLOCKS" ]; then
|
||||
report ERROR "raw <a>/<Link> in blocks" "§6.3 links from the panel render via CMSLink" \
|
||||
"$(g '<(a|Link)[ >]' $BLOCKS --include=*.tsx)"
|
||||
|
||||
report ERROR "hardcoded text in blocks" "§2 every visible text comes from the panel (localized field)" \
|
||||
"$(node "$(dirname "$0")/jsx-text.mjs" $BLOCKS 2>/dev/null)"
|
||||
|
||||
report WARNING "inline <svg> in blocks" "§6.10 icons via media upload or Icon map" \
|
||||
"$(g '<svg[ >]' $BLOCKS --include=*.tsx)"
|
||||
|
||||
@@ -100,6 +121,11 @@ if [ -n "$BLOCKS" ]; then
|
||||
"$(g "from '\./Component'|/Component'" $BLOCKS --include=config.ts)"
|
||||
fi
|
||||
|
||||
if [ -d src/components ]; then
|
||||
report WARNING "hardcoded text in components/layout" "§2 texts and a11y labels from the panel — keep only symbols/numbers in code" \
|
||||
"$(node "$(dirname "$0")/jsx-text.mjs" src/components 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [ -n "$UI" ]; then
|
||||
report ERROR "hex colors in classes" "§6.11 use design tokens (bg-primary…)" \
|
||||
"$(g '(bg|text|border|from|to|via|fill|stroke)-\[#' $UI --include=*.tsx)"
|
||||
@@ -122,13 +148,32 @@ if [ -d src/collections ]; then
|
||||
"$(ls src/collections | grep -viE '^(pages|media|users|user|settings|navigation|nav|footer|header|faq|hero|company|danefirmy)\.ts$')"
|
||||
fi
|
||||
|
||||
# --- Editor panel clarity (§6.5a) ---
|
||||
SCHEMA=$(dirs src/blocks src/collections src/globals src/fields)
|
||||
if [ -n "$SCHEMA" ]; then
|
||||
PANEL=$(node "$(dirname "$0")/panel-check.mjs" $SCHEMA)
|
||||
while IFS= read -r rule; do
|
||||
[ -z "$rule" ] && continue
|
||||
level=${rule%%|*}; rest=${rule#*|}
|
||||
report "$level" "panel: ${rest%%|*}" "§6.5a editor panel" "$(printf '%s\n' "$PANEL" | grep -F "$level|${rest%%|*}|" | cut -d'|' -f3-)"
|
||||
done <<< "$(printf '%s\n' "$PANEL" | cut -d'|' -f1-2 | sort -u)"
|
||||
fi
|
||||
|
||||
# --- Plugin duplicates (§1, §7) ---
|
||||
report ERROR "own block renderer switch" "§7 use RenderBlocks + registry" \
|
||||
"$(g 'switch *\(.*blockType' src --include=*.tsx --include=*.ts)"
|
||||
report WARNING "files that usually duplicate the plugin" "§3 plugin has resolveRoute / getConfiguredLocales" \
|
||||
"$(ls src/lib/pages.ts src/lib/locales.ts 2>/dev/null)"
|
||||
report ERROR "project copy of link fields" "links.md — use buildLinkField / buildLinksField / resolveLinkHref from the plugin" \
|
||||
"$(ls src/fields/link.ts src/lib/links.ts 2>/dev/null; g "from '@/fields/link'|from '@/lib/links'" src --include=*.ts --include=*.tsx)"
|
||||
report ERROR "manual Lexical rendering" "§7 use RenderRichText" \
|
||||
"$(g 'node\.type *===|dangerouslySetInnerHTML' src --include=*.tsx)"
|
||||
"$(g 'node\.type *===' src --include=*.tsx | nc 'node')"
|
||||
HTML=$(node "$(dirname "$0")/html-check.mjs" src)
|
||||
while IFS= read -r rule; do
|
||||
[ -z "$rule" ] && continue
|
||||
level=${rule%%|*}; title=${rule#*|}
|
||||
report "$level" "$title" "§7 / seo.md" "$(printf '%s\n' "$HTML" | grep -F "$rule|" | cut -d'|' -f3-)"
|
||||
done <<< "$(printf '%s\n' "$HTML" | cut -d'|' -f1-2 | sort -u)"
|
||||
|
||||
# --- Compile & build ---
|
||||
if [ "$QUICK" -eq 0 ]; then
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
// Raw HTML in JSX (dangerouslySetInnerHTML), classified — prints "LEVEL|rule|file:line", exit 0.
|
||||
// node html-check.mjs src
|
||||
// - inline JSON-LD (<script type="application/ld+json">) without '<' escaping → ERROR (XSS:
|
||||
// a "</script>" typed in the panel breaks out of the tag) → JsonLdGraph from /rsc
|
||||
// - inline JSON-LD with escaping → WARNING (works; JsonLdGraph is the shared version)
|
||||
// - anything else → WARNING (rich text → RenderRichText; other HTML must be sanitized)
|
||||
import { readFileSync, readdirSync, statSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const files = []
|
||||
const walk = (p) => {
|
||||
let st
|
||||
try { st = statSync(p) } catch { return }
|
||||
if (st.isDirectory()) { if (!/node_modules|\.next/.test(p)) for (const n of readdirSync(p)) walk(join(p, n)) }
|
||||
else if (/\.(tsx|jsx)$/.test(p)) files.push(p)
|
||||
}
|
||||
process.argv.slice(2).forEach(walk)
|
||||
|
||||
for (const file of files) {
|
||||
// blank out comments (keeps offsets/line numbers)
|
||||
const src = readFileSync(file, 'utf8')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, ' '))
|
||||
.replace(/(^|[^:'"`])\/\/.*$/gm, (c, p) => p + ' '.repeat(c.length - p.length))
|
||||
for (const m of src.matchAll(/dangerouslySetInnerHTML/g)) {
|
||||
// the element this prop belongs to: from its opening "<tag" to the end of the prop's {{ … }}
|
||||
const open = src.lastIndexOf('<', m.index)
|
||||
const close = src.indexOf('}}', m.index)
|
||||
const el = src.slice(open, close < 0 ? m.index + 400 : close + 2)
|
||||
const at = `${file}:${src.slice(0, m.index).split('\n').length}`
|
||||
if (/^<script\b/.test(el) && /application\/ld\+json/.test(el)) {
|
||||
if (/u003c|replace\(\/</.test(el)) console.log(`WARNING|inline JSON-LD — use <JsonLdGraph schemas={[…]}/> from @intecion/ipal-kit/rsc (seo.md)|${at}`)
|
||||
else console.log(`ERROR|unescaped JSON-LD in <script> — XSS via "</script>" in panel text; use <JsonLdGraph/> from @intecion/ipal-kit/rsc|${at}`)
|
||||
} else {
|
||||
console.log(`WARNING|raw HTML (dangerouslySetInnerHTML) — rich text → RenderRichText; other HTML must be sanitized|${at}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
// Finds user-visible text hardcoded in JSX (AGENT.md §2: everything visible comes from the panel).
|
||||
// node jsx-text.mjs <dir> [<dir> …] → prints "file:line: text" per finding, exit 0
|
||||
// Detects:
|
||||
// - text between HTML text tags: <h2>Nasze usługi</h2>, <p>\n Lorem…\n</p>, </strong> więcej <
|
||||
// - text attributes with words: alt="Logo firmy", placeholder="Twój e-mail", aria-label="Zamknij"
|
||||
// Ignores comments, {expressions}, digits/punctuation/symbols only (404, →, ☰, ·).
|
||||
import { readFileSync, readdirSync, statSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const TEXT_TAGS =
|
||||
'h1|h2|h3|h4|h5|h6|p|span|a|button|li|label|strong|em|b|i|small|div|section|article|header|footer|main|nav|td|th|dt|dd|figcaption|blockquote|option|legend|summary|caption|q|cite|time|mark'
|
||||
// Opening tags: HTML text tags or Capitalized components (<Link …>), never preceded by an
|
||||
// identifier char — that excludes TS generics like useState<Boolean>( … ).
|
||||
const OPEN_OR_CLOSE = new RegExp(
|
||||
`(?:(?<![\\w.$])<(?:${TEXT_TAGS}|[A-Z][\\w.]*)(?:\\s[^<>]*)?>|</[A-Za-z][\\w.]*>)([^<>{}]*)(?=<|\\{)`,
|
||||
'g',
|
||||
)
|
||||
const ATTR = /\b(alt|title|placeholder|aria-label|label)=("([^"]*)"|'([^']*)')/g
|
||||
const WORD = /\p{L}{2,}/u
|
||||
// Text right after a closing/self-closing tag may be the JS that follows the JSX
|
||||
// expression (`<X /> : null`, `</div>) }`, `</p>\n const id = …`) — not visible text.
|
||||
const JS_CODE = /(^|\s)(return|const|let|var|if|else|export|import|await|typeof)\b|=>|[=;`]|^\s*[:?)\]}]|&&|\|\|/
|
||||
|
||||
const files = []
|
||||
const walk = (p) => {
|
||||
let st
|
||||
try { st = statSync(p) } catch { return }
|
||||
if (st.isDirectory()) for (const n of readdirSync(p)) walk(join(p, n))
|
||||
else if (p.endsWith('.tsx')) files.push(p)
|
||||
}
|
||||
process.argv.slice(2).forEach(walk)
|
||||
|
||||
// Blank out comments but keep line numbers.
|
||||
const stripComments = (src) =>
|
||||
src
|
||||
.replace(/\{\/\*[\s\S]*?\*\/\}/g, (m) => m.replace(/[^\n]/g, ' '))
|
||||
.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' '))
|
||||
.replace(/(^|[^:"'`])\/\/.*$/gm, (m, p) => p + ' '.repeat(m.length - p.length))
|
||||
|
||||
const lineOf = (src, idx) => src.slice(0, idx).split('\n').length
|
||||
|
||||
for (const file of files) {
|
||||
const src = stripComments(readFileSync(file, 'utf8'))
|
||||
for (const m of src.matchAll(OPEN_OR_CLOSE)) {
|
||||
const text = m[1].replace(/\s+/g, ' ').trim()
|
||||
if (!text || !WORD.test(text) || JS_CODE.test(text)) continue
|
||||
if (/&[a-z]+;/.test(text) && !WORD.test(text.replace(/&[a-z]+;/g, ''))) continue
|
||||
console.log(`${file}:${lineOf(src, m.index + m[0].length - m[1].length)}: ${text.slice(0, 80)}`)
|
||||
}
|
||||
for (const m of src.matchAll(ATTR)) {
|
||||
const value = m[3] ?? m[4] ?? ''
|
||||
if (!WORD.test(value)) continue
|
||||
console.log(`${file}:${lineOf(src, m.index)}: ${m[1]}="${value.slice(0, 60)}"`)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user