Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef7927e38 | ||
|
|
a7846d9770 | ||
|
|
015092e773 | ||
|
|
f4d969ad29 | ||
|
|
fad5d778e8 | ||
|
|
0f073b963e | ||
|
|
54c2d64cce | ||
|
|
e29c919e5e |
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
+56
-56
@@ -1,74 +1,74 @@
|
|||||||
export type { AccessOption, Role } from './modules/access/index.js';
|
export { ipalKit } from './plugin.js';
|
||||||
export { adminOnly, adminOnlyField, adminOrEditor, adminOrEditorField, adminOrSelf, authenticated, hasMinimumRole, isAdmin, isEditor, requireRole, requireRoleField, ROLE_HIERARCHY, } from './modules/access/index.js';
|
export type { IpalOptions } from './types.js';
|
||||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js';
|
|
||||||
export type { A11yState } from './modules/accessibility/index.js';
|
|
||||||
export { rowLabel } from './modules/admin-ui/index.js';
|
|
||||||
export type { RowLabelProps } from './modules/admin-ui/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 type { I18nConfig, LocaleDefinition, LocalizedSlugs } from './modules/i18n/index.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 { buildLocalizedPath, getDefaultLocale, getLocaleCodes, getLocaleDefinition, getLocalizedSlugs, isValidLocale, LOCALE_COOKIE_NAME, matchAcceptLanguage, negotiateLocale, switchLocalePath, } from './modules/i18n/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, 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 type { LocaleMiddlewareResult } from './modules/i18n/index.js';
|
||||||
export { createLocaleMiddleware, DEFAULT_MIDDLEWARE_MATCHER, } 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 { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js';
|
||||||
export { resolveLocalized } from './modules/i18n/index.js';
|
export { resolveLocalized } from './modules/i18n/index.js';
|
||||||
export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/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 { BuildLinkFieldOptions, BuildLinksFieldOptions, LinkAppearance, LinkValue, ResolveLinkHrefOptions, } from './modules/links/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 { createMcpRoute } from './modules/mcp/index.js';
|
||||||
export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||||
export type { OptimizeUploadOptions } from './modules/media/index.js';
|
export type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js';
|
||||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js';
|
export type { AnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js';
|
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export type { PagesOption, SystemPageRole } from './modules/pages/index.js';
|
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js';
|
||||||
export type { GlobalQueryOptions } from './modules/payload/index.js';
|
export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js';
|
||||||
export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG, } from './modules/payload/index.js';
|
|
||||||
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
|
||||||
export { buildSecurityHeaders } from './modules/security/index.js';
|
export { buildSecurityHeaders } from './modules/security/index.js';
|
||||||
export { buildCsp } from './modules/security/index.js';
|
export { buildCsp } from './modules/security/index.js';
|
||||||
export type { BuildCspArgs } 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, readSiteMetaConfig, slugsAcrossLocales, } from './modules/seo/index.js';
|
|
||||||
export type { SiteMetaConfig } from './modules/seo/index.js';
|
|
||||||
export type { AutoFillMapping, RobotsOptions, 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 { 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 { buildSpeakableJsonLd } from './modules/seo/index.js';
|
||||||
export { buildSummaryField } 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';
|
||||||
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 { buildArticleJsonLd } from './modules/seo/index.js';
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||||
export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/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 type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js';
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
|
||||||
export { buildR2Storage } from './modules/storage/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 type { IpalOptions } from './types.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
-34
@@ -1,59 +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 { 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 { getGlobal, getSiteSettings, getSiteIntegrations, SITE_SETTINGS_SLUG, SITE_INTEGRATIONS_SLUG } from './modules/payload/index.js';
|
||||||
export { rowLabel } from './modules/admin-ui/index.js';
|
export { composeTitle, buildHreflangAlternates, buildMetadata, readSiteMetaConfig, slugsAcrossLocales } from './modules/seo/index.js';
|
||||||
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
export { createContentHelpers } from './modules/frontend/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 { resolveRoute, resolveRedirect, resolveNotFoundPage, blocksToMarkdown, createMarkdownRenderer, markdownResponse, prefersMarkdown, markdownHref, MARKDOWN_PREFIX, searchContent, createSearchRoute, archiveFieldName, getArchiveEntries, buildArchivePath, buildEntryPath, parsePageParam } 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';
|
// Lexical → Markdown (pure, no React) — for AI-readable output.
|
||||||
export { graphAdapter } from './modules/email/graphAdapter.js';
|
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
||||||
export { mailAdapter } from './modules/email/mailAdapter.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
|
// Imported straight from the file, NOT from ./modules/email/index.js — that
|
||||||
// barrel re-exports sendEmail, which imports 'server-only' and would crash when
|
// 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.
|
// Payload loads the config (or runs generate:importmap) as a plain Node script.
|
||||||
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js';
|
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js';
|
||||||
// Boot-time environment validation (fail fast on misconfigured deploys).
|
export { graphAdapter } from './modules/email/graphAdapter.js';
|
||||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
export { mailAdapter } from './modules/email/mailAdapter.js';
|
||||||
// Panel-managed form analytics (config-time field builder).
|
|
||||||
export { buildFormAnalyticsFields } from './modules/forms/formAnalyticsFields.js';
|
|
||||||
export { buildFormsPlugin } from './modules/forms/formsPluginConfig.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
|
// Validation rules are pure — exported server-side too, for re-validating a
|
||||||
// submission inside a server action. (useForm/useContactForm are client-only →
|
// submission inside a server action. (useForm/useContactForm are client-only →
|
||||||
// '@intecion/ipal-kit/client'.)
|
// '@intecion/ipal-kit/client'.)
|
||||||
export { buildValidator, checked, custom, email, isEmail, maxLength, minLength, pattern, required } from './modules/forms/validators.js';
|
export { buildValidator, isEmail, required, email, minLength, maxLength, checked, pattern, custom } from './modules/forms/validators.js';
|
||||||
export { createContentHelpers } from './modules/frontend/index.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).
|
// Healthcheck route (Coolify/Docker liveness with a real DB round-trip).
|
||||||
export { createHealthRoute } from './modules/health/index.js';
|
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';
|
|
||||||
export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/index.js';
|
|
||||||
// Read-only MCP server (Claude/agents connect to the site and query it).
|
// Read-only MCP server (Claude/agents connect to the site and query it).
|
||||||
export { createMcpRoute } from './modules/mcp/index.js';
|
export { createMcpRoute } from './modules/mcp/index.js';
|
||||||
export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js';
|
// Boot-time environment validation (fail fast on misconfigured deploys).
|
||||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js';
|
export { assertEnv, ipalEnvRules } from './modules/env/index.js';
|
||||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js';
|
export { getAnalyticsConfig } from './modules/analytics/index.js';
|
||||||
export { getGlobal, getSiteIntegrations, getSiteSettings, SITE_INTEGRATIONS_SLUG, SITE_SETTINGS_SLUG } from './modules/payload/index.js';
|
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
||||||
// Lexical → Markdown (pure, no React) — for AI-readable output.
|
export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js';
|
||||||
export { lexicalToMarkdown } from './modules/richtext/index.js';
|
export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js';
|
||||||
export { buildSecurityHeaders } from './modules/security/index.js';
|
export { buildSecurityHeaders } from './modules/security/index.js';
|
||||||
export { buildCsp } from './modules/security/index.js';
|
export { buildCsp } from './modules/security/index.js';
|
||||||
export { buildHreflangAlternates, buildMetadata, composeTitle, readSiteMetaConfig, slugsAcrossLocales } 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 { 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 { buildSpeakableJsonLd } from './modules/seo/index.js';
|
||||||
export { buildSummaryField } 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.
|
// 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 { buildArticleJsonLd } from './modules/seo/index.js';
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js';
|
export { buildLlmsTxt } from './modules/seo/index.js';
|
||||||
export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/index.js';
|
export { buildSitemapXml, buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './modules/seo/index.js';
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js';
|
|
||||||
export { buildR2Storage } from './modules/storage/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
|
//# sourceMappingURL=index.js.map
|
||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+8
@@ -11,6 +11,14 @@ type CreateSearchRouteArgs = {
|
|||||||
getCachedPayload: () => Promise<BasePayload>;
|
getCachedPayload: () => Promise<BasePayload>;
|
||||||
/** Home slug map/string so the home result collapses to root. */
|
/** Home slug map/string so the home result collapses to root. */
|
||||||
homeSlug?: Record<string, string> | string;
|
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. */
|
/** Field holding a richer AI summary (buildSummaryField) to prefer as description. */
|
||||||
summaryField?: string;
|
summaryField?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
+22
@@ -1,3 +1,4 @@
|
|||||||
|
import { checkRateLimit, clientIp, tooManyRequests } from '../shared/rateLimit.js';
|
||||||
import { searchContent } from './searchContent.js';
|
import { searchContent } from './searchContent.js';
|
||||||
/**
|
/**
|
||||||
* A JSON content-search endpoint. Powers both the site's own search UI and
|
* 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.
|
* Uses the global Request/Response — no next/server import.
|
||||||
*/ export function createSearchRoute(args) {
|
*/ export function createSearchRoute(args) {
|
||||||
const { baseUrl, collection = 'pages', config, defaultLimit = 10, getCachedPayload, homeSlug, summaryField } = 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)=>{
|
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 url = new URL(req.url);
|
||||||
const query = url.searchParams.get('q')?.trim() ?? '';
|
const query = url.searchParams.get('q')?.trim() ?? '';
|
||||||
const locale = url.searchParams.get('locale') ?? undefined;
|
const locale = url.searchParams.get('locale') ?? undefined;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
}
|
}
|
||||||
switch(kind){
|
switch(kind){
|
||||||
case 'boolean':
|
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}")`;
|
return `${name} must be a boolean (true/false/1/0/yes/no, got "${value}")`;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+13
-2
@@ -59,8 +59,19 @@
|
|||||||
kind: 'url'
|
kind: 'url'
|
||||||
}, {
|
}, {
|
||||||
name: 'R2_PUBLIC_URL',
|
name: 'R2_PUBLIC_URL',
|
||||||
description: 'Public base URL media is served from',
|
description: 'Public base URL media is served from (custom domain of the bucket)',
|
||||||
kind: 'url'
|
// 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) {
|
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 = {
|
export { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js';
|
||||||
/** Identifier to limit on — typically the client IP. */
|
export type { RateLimitArgs } from '../shared/rateLimit.js';
|
||||||
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;
|
|
||||||
|
|||||||
Vendored
+2
-49
@@ -1,51 +1,4 @@
|
|||||||
/**
|
// Moved to modules/shared/rateLimit.ts (shared with search and MCP routes).
|
||||||
* Per-IP sliding window, in memory.
|
export { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js';
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//# sourceMappingURL=rateLimit.js.map
|
//# 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"}
|
||||||
+3
-8
@@ -33,14 +33,9 @@ type CreateContentHelpersArgs = {
|
|||||||
settingsSlug?: string;
|
settingsSlug?: string;
|
||||||
/**
|
/**
|
||||||
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
||||||
* header = Site Settings `siteName` (default locale), credit "Technology by
|
* header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
|
||||||
* Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line.
|
|
||||||
*/
|
*/
|
||||||
sitemapStyle?: {
|
sitemapStyle?: false | SitemapStyleOptions;
|
||||||
title?: string;
|
|
||||||
} & Omit<SitemapStyleOptions, 'title'> | false;
|
|
||||||
/** Site Settings field with the site name (sitemap header). Default 'siteName'. */
|
|
||||||
siteNameField?: string;
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Bundles the per-request data helpers a frontend needs — the same cached
|
* Bundles the per-request data helpers a frontend needs — the same cached
|
||||||
@@ -68,7 +63,7 @@ type CreateContentHelpersArgs = {
|
|||||||
* a URL is, fetching gets the listing. Metadata generation needs the first and
|
* 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.
|
* not the second, and a page component composes them in two obvious lines.
|
||||||
*/
|
*/
|
||||||
export declare function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug, robots: robotsOptions, settingsSlug, sitemapStyle, siteNameField, }: 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>;
|
generatePageMetadata: (locale: string, segments: string[] | undefined, page?: number) => Promise<PageMetadata>;
|
||||||
generateStaticParams: () => Promise<Array<{
|
generateStaticParams: () => Promise<Array<{
|
||||||
locale: string;
|
locale: string;
|
||||||
|
|||||||
+2
-13
@@ -27,7 +27,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRout
|
|||||||
* `resolveRoute` and `getEntries` are separate on purpose: routing decides what
|
* `resolveRoute` and `getEntries` are separate on purpose: routing decides what
|
||||||
* a URL is, fetching gets the listing. Metadata generation needs the first and
|
* 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.
|
* not the second, and a page component composes them in two obvious lines.
|
||||||
*/ export function createContentHelpers({ baseUrl, config, content, i18n, pagesSlug = 'pages', robots: robotsOptions, settingsSlug = 'site-settings', sitemapStyle, siteNameField = 'siteName' }) {
|
*/ 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 origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? '';
|
||||||
const getCachedPayload = cache(async ()=>getPayload({
|
const getCachedPayload = cache(async ()=>getPayload({
|
||||||
config: await config
|
config: await config
|
||||||
@@ -318,18 +318,7 @@ import { buildRobots, buildSitemapEntries, createPageMetadata, createSitemapRout
|
|||||||
* export { sitemapRoute as GET } from '@/lib/content'
|
* export { sitemapRoute as GET } from '@/lib/content'
|
||||||
* export const dynamic = 'force-dynamic'
|
* export const dynamic = 'force-dynamic'
|
||||||
*/ const sitemapRoute = createSitemapRouteHandler(sitemap, {
|
*/ const sitemapRoute = createSitemapRouteHandler(sitemap, {
|
||||||
style: sitemapStyle === false ? false : {
|
style: sitemapStyle ?? {}
|
||||||
...sitemapStyle,
|
|
||||||
title: sitemapStyle?.title ?? (async ()=>{
|
|
||||||
const locale = i18n?.defaultLocale;
|
|
||||||
if (!locale) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const s = await getSettings(locale);
|
|
||||||
const name = s?.[siteNameField];
|
|
||||||
return typeof name === 'string' ? name : undefined;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
generatePageMetadata,
|
generatePageMetadata,
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+10
@@ -10,6 +10,16 @@ type CreateMcpRouteArgs = {
|
|||||||
/** Archive-backed collections (same as the plugin option) for get_page. */
|
/** Archive-backed collections (same as the plugin option) for get_page. */
|
||||||
content?: ContentOption;
|
content?: ContentOption;
|
||||||
getCachedPayload: () => Promise<BasePayload>;
|
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'. */
|
/** Server name advertised in `initialize`. Default 'ipal-site'. */
|
||||||
serverName?: string;
|
serverName?: string;
|
||||||
/** Server version advertised in `initialize`. Default '1.0.0'. */
|
/** Server version advertised in `initialize`. Default '1.0.0'. */
|
||||||
|
|||||||
Vendored
+26
-1
@@ -1,5 +1,6 @@
|
|||||||
import { createMarkdownRenderer, searchContent } from '../content/index.js';
|
import { createMarkdownRenderer, searchContent } from '../content/index.js';
|
||||||
import { getDefaultLocale, isValidLocale } from '../i18n/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
|
* 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
|
* 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) {
|
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 origin = baseUrl?.replace(/\/$/, '') ?? '';
|
||||||
const renderMarkdown = createMarkdownRenderer({
|
const renderMarkdown = createMarkdownRenderer({
|
||||||
collection,
|
collection,
|
||||||
@@ -217,6 +223,25 @@ export function createMcpRoute(args) {
|
|||||||
status: 400
|
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.
|
// Batch or single.
|
||||||
if (Array.isArray(body)) {
|
if (Array.isArray(body)) {
|
||||||
const out = (await Promise.all(body.map((m)=>handleOne(m)))).filter((r)=>r !== null);
|
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
@@ -68,7 +68,8 @@
|
|||||||
"'none'"
|
"'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);
|
src['img-src'].push(r2Url);
|
||||||
}
|
}
|
||||||
if (turnstile) {
|
if (turnstile) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -61,6 +61,8 @@ import { buildSitemapCss, SITEMAP_STYLE_PARAM } from './sitemapStyle.js';
|
|||||||
* Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.
|
* Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.
|
||||||
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
||||||
const style = opts.cssUrl ? false : opts.style === false ? false : opts.style ?? {};
|
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)=>{
|
return async (req)=>{
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
if (style && url.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
if (style && url.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -12,7 +12,7 @@ export type SitemapStyleOptions = {
|
|||||||
* "Technology by Intecion.com". `false` hides it.
|
* "Technology by Intecion.com". `false` hides it.
|
||||||
*/
|
*/
|
||||||
credit?: false | string;
|
credit?: false | string;
|
||||||
/** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */
|
/** Header line. Default "XML Sitemap". */
|
||||||
title?: string;
|
title?: string;
|
||||||
};
|
};
|
||||||
/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */
|
/** Query parameter on the sitemap URL that returns the stylesheet instead of XML. */
|
||||||
|
|||||||
Vendored
+1
-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
+5
-1
@@ -45,8 +45,12 @@
|
|||||||
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
||||||
// pointing there. Without it, uploads work but images don't display publicly.
|
// pointing there. Without it, uploads work but images don't display publicly.
|
||||||
// See docs/storage.md.
|
// 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
|
// 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
|
// 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`
|
// instead of the private S3 endpoint. Each collection gets either `true`
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
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 */
|
||||||
|
}
|
||||||
+7
-3
@@ -168,7 +168,7 @@ src/
|
|||||||
sitemap.xml/route.ts # sitemapRoute z lib/content + force-dynamic (wygląd z pluginu)
|
sitemap.xml/route.ts # sitemapRoute z lib/content + force-dynamic (wygląd z pluginu)
|
||||||
robots.ts # z lib/content
|
robots.ts # z lib/content
|
||||||
api/health/route.ts # createHealthRoute
|
api/health/route.ts # createHealthRoute
|
||||||
instrumentation.ts # assertEnv(ipalEnvRules({...}))
|
instrumentation.ts # assertEnv(ipalEnvRules({...})) z '@intecion/ipal-kit/env'
|
||||||
fields/ # sectionHeader.ts, sectionSettings.ts (linki: z pluginu)
|
fields/ # sectionHeader.ts, sectionSettings.ts (linki: z pluginu)
|
||||||
components/
|
components/
|
||||||
ui/ # prymitywy: CMSLink, Button, Media, Section, SectionHeader
|
ui/ # prymitywy: CMSLink, Button, Media, Section, SectionHeader
|
||||||
@@ -221,7 +221,7 @@ Bez skrótów (`HeroSection`, nie `HeroSec`). Nie twórz `lib/pages.ts`,
|
|||||||
7. **`export const dynamic = 'force-dynamic'`** na trasach czytających bazę:
|
7. **`export const dynamic = 'force-dynamic'`** na trasach czytających bazę:
|
||||||
`manifest.ts`, `sitemap.xml/route.ts`, `llms.txt`, `api/health`. Handlery
|
`manifest.ts`, `sitemap.xml/route.ts`, `llms.txt`, `api/health`. Handlery
|
||||||
pluginu mają try/catch, ale `dynamic` musi być w pliku trasy.
|
pluginu mają try/catch, ale `dynamic` musi być w pliku trasy.
|
||||||
8. **`instrumentation.ts`** z `assertEnv(ipalEnvRules({...}))` (env.md).
|
8. **`instrumentation.ts`** z `assertEnv(ipalEnvRules({...}))` importowanym z **`@intecion/ipal-kit/env`** (root ciągnie Payload → crash Edge/Turbopack), w `if (process.env.NEXT_RUNTIME === 'nodejs')` (env.md).
|
||||||
9. **RSC domyślnie.** `'use client'` tylko dla stanu/interakcji, w osobnym pliku;
|
9. **RSC domyślnie.** `'use client'` tylko dla stanu/interakcji, w osobnym pliku;
|
||||||
sekcja zostaje serwerowa i podaje mu dane. Sekrety: `import 'server-only'`.
|
sekcja zostaje serwerowa i podaje mu dane. Sekrety: `import 'server-only'`.
|
||||||
10. **Bloki nie importują `lib/*`** (cykl). Dane server-side → `enhanceProps`.
|
10. **Bloki nie importują `lib/*`** (cykl). Dane server-side → `enhanceProps`.
|
||||||
@@ -535,6 +535,10 @@ bloku nie importował Reacta). Kod: [kod-sekcji.md](./skills/ipal-block/resource
|
|||||||
ze źródła `DESIGN.md`. W komponentach tylko tokeny (`bg-primary`), **nigdy**
|
ze źródła `DESIGN.md`. W komponentach tylko tokeny (`bg-primary`), **nigdy**
|
||||||
`bg-[#ff6600]` ani hex.
|
`bg-[#ff6600]` ani hex.
|
||||||
- Tokeny pluginu mapuj na projekt: `--ipal-primary: var(--color-primary)`.
|
- Tokeny pluginu mapuj na projekt: `--ipal-primary: var(--color-primary)`.
|
||||||
|
- Płynna typografia i odstępy: `@import "@intecion/ipal-kit/fluid.css"` + mapowanie w
|
||||||
|
`@theme` (`text-h1`, `py-section`, `px-gutter` — PROGRAMISTA §2.5). Nie pisz `clamp()`
|
||||||
|
w komponentach; inne wartości z `DESIGN.md` → nadpisz zmienne `--ipal-*` w `:root`.
|
||||||
|
- JSON-LD tylko przez `<JsonLdGraph>` z `/rsc` — nigdy własny `<script dangerouslySetInnerHTML>`.
|
||||||
- Fonty przez `next/font`, podpięte zmienną CSS do `@theme`.
|
- Fonty przez `next/font`, podpięte zmienną CSS do `@theme`.
|
||||||
- Bez CSS Modules i `style={{…}}` — wyjątek: wartość dynamiczna z danych.
|
- Bez CSS Modules i `style={{…}}` — wyjątek: wartość dynamiczna z danych.
|
||||||
- Warianty → `Record<Variant, string>`, nie łańcuchy ternary.
|
- Warianty → `Record<Variant, string>`, nie łańcuchy ternary.
|
||||||
@@ -581,7 +585,7 @@ Przykładowy `styles.css`: [kod-sekcji.md](./skills/ipal-block/resources/kod-sek
|
|||||||
| Nagłówki, CSP, 2FA | `buildSecurityHeaders`, `buildCsp`, `twoFactor` (wstrzyknięty `payloadTotp`) | security.md |
|
| Nagłówki, CSP, 2FA | `buildSecurityHeaders`, `buildCsp`, `twoFactor` (wstrzyknięty `payloadTotp`) | security.md |
|
||||||
| Media, R2 | `buildR2Storage(['media'], { s3Storage })` (adapter wstrzyknięty), `normalizeFilenameHook`, `buildOptimizeUploadHook` + `buildOptimizeUploadField`, `MediaPreconnect` | storage.md |
|
| Media, R2 | `buildR2Storage(['media'], { s3Storage })` (adapter wstrzyknięty), `normalizeFilenameHook`, `buildOptimizeUploadHook` + `buildOptimizeUploadField`, `MediaPreconnect` | storage.md |
|
||||||
| Email | `email: mailAdapter()` | email.md |
|
| Email | `email: mailAdapter()` | email.md |
|
||||||
| Walidacja env | `assertEnv(ipalEnvRules({...}))` | env.md |
|
| Walidacja env | `assertEnv(ipalEnvRules({...}))` z `@intecion/ipal-kit/env` | env.md |
|
||||||
|
|
||||||
**Compliance (PL/EU) — mechanizm z pluginu, treść od klienta:** strony polityk
|
**Compliance (PL/EU) — mechanizm z pluginu, treść od klienta:** strony polityk
|
||||||
jako System Pages, `CookieBanner` + `CookieButton`, checkbox `consent` w
|
jako System Pages, `CookieBanner` + `CookieButton`, checkbox `consent` w
|
||||||
|
|||||||
@@ -167,7 +167,13 @@ report WARNING "files that usually duplicate the plugin" "§3 plugin has resolve
|
|||||||
report ERROR "project copy of link fields" "links.md — use buildLinkField / buildLinksField / resolveLinkHref from the plugin" \
|
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)"
|
"$(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" \
|
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 ---
|
# --- Compile & build ---
|
||||||
if [ "$QUICK" -eq 0 ]; then
|
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}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,6 +43,8 @@ tej procedury. Pytasz tylko, gdy brakuje czegoś, czego nie możesz uzyskać sam
|
|||||||
| build pada `ENOTFOUND` / Mongoose | trasa czyta bazę w buildzie bez bazy | sitemap/robots/llms: `export const dynamic = 'force-dynamic'` (tylko one) |
|
| build pada `ENOTFOUND` / Mongoose | trasa czyta bazę w buildzie bez bazy | sitemap/robots/llms: `export const dynamic = 'force-dynamic'` (tylko one) |
|
||||||
| `slug.join is not a function` | `[slug]` zamiast `[[...slug]]` | zmień nazwę folderu |
|
| `slug.join is not a function` | `[slug]` zamiast `[[...slug]]` | zmień nazwę folderu |
|
||||||
| `Missing <html> and <body>` | layout `[locale]` bez `<html>` po usunięciu root layoutu | `<html lang>` i `<body>` w `[locale]/layout.tsx` |
|
| `Missing <html> and <body>` | layout `[locale]` bez `<html>` po usunięciu root layoutu | `<html lang>` i `<body>` w `[locale]/layout.tsx` |
|
||||||
|
| `Export fileTypeFromFile doesn't exist in target module` (Turbopack, start dev) | `instrumentation.ts` importuje z roota pakietu → Payload w bundlu Edge | import z `@intecion/ipal-kit/env` + `NEXT_RUNTIME === 'nodejs'` (env.md) |
|
||||||
|
| `R2_PUBLIC_URL must be a valid URL (got "/media")` | stara wersja reguły / produkcja ze ścieżką względną | dev: `/media` dozwolone od nowej wersji; produkcja: pełny URL domeny bucketu |
|
||||||
| `server-only` w kliencie | import z `@intecion/ipal-kit/server` w `'use client'` | wywołuj przez server action |
|
| `server-only` w kliencie | import z `@intecion/ipal-kit/server` w `'use client'` | wywołuj przez server action |
|
||||||
|
|
||||||
### Panel (`/admin`)
|
### Panel (`/admin`)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ tylko, gdy użytkownik o to poprosi. Pełna budowa strony: skill **ipal-site**.
|
|||||||
`not-found.tsx` z `LocaleView` — bez `headers()`, wersja na każdy język (PROGRAMISTA §2.6–2.8, pages.md).
|
`not-found.tsx` z `LocaleView` — bez `headers()`, wersja na każdy język (PROGRAMISTA §2.6–2.8, pages.md).
|
||||||
7. **SEO i bezpieczeństwo** — sitemap (`sitemap.xml/route.ts` = `sitemapRoute`, bez CSS w `public/`), robots, manifest, llms.txt, health
|
7. **SEO i bezpieczeństwo** — sitemap (`sitemap.xml/route.ts` = `sitemapRoute`, bez CSS w `public/`), robots, manifest, llms.txt, health
|
||||||
(wszystkie z `force-dynamic`), `htmlLimitedBots`, `buildSecurityHeaders`,
|
(wszystkie z `force-dynamic`), `htmlLimitedBots`, `buildSecurityHeaders`,
|
||||||
`instrumentation.ts` z `assertEnv` (PROGRAMISTA §2.8–2.9).
|
`instrumentation.ts` z `assertEnv` z `@intecion/ipal-kit/env` (PROGRAMISTA §2.8–2.9, env.md).
|
||||||
8. **Nawigacja** — skill **ipal-nav**.
|
8. **Nawigacja** — skill **ipal-nav**.
|
||||||
9. `pnpm generate:types`, `pnpm payload generate:importmap`, skill **ipal-audit**
|
9. `pnpm generate:types`, `pnpm payload generate:importmap`, skill **ipal-audit**
|
||||||
(pełny), lista kroków w panelu dla użytkownika (PROGRAMISTA §2.11).
|
(pełny), lista kroków w panelu dla użytkownika (PROGRAMISTA §2.11).
|
||||||
|
|||||||
+6
-2
@@ -315,8 +315,12 @@ Query: `?q=` (wymagane), `?locale=`, `?limit=`. Odpowiedź:
|
|||||||
"results": [{ "title": "O nas", "url": "https://x/pl/o-nas", "description": "…", "slug": "o-nas" }] }
|
"results": [{ "title": "O nas", "url": "https://x/pl/o-nas", "description": "…", "slug": "o-nas" }] }
|
||||||
```
|
```
|
||||||
|
|
||||||
Brak `q` → 400. Tylko opublikowane, bez `noindex`. Błąd/baza offline → pusty
|
Brak `q` → 400. Tylko opublikowane, bez `noindex`, maks. 50 wyników. Błąd/baza
|
||||||
wynik (200), nie 500. Niska wartość `s-maxage` (60s) — wyniki świeże, ale z
|
offline → pusty wynik (200), nie 500. **Limit zapytań:** 120/min na IP (w pamięci,
|
||||||
|
per instancja) → `429` z `Retry-After`; zmiana: `rateLimit: { max, windowMs }`,
|
||||||
|
wyłączenie (limiter z przodu, np. Cloudflare WAF): `rateLimit: false`.
|
||||||
|
Kolizja z `@payloadcms/plugin-search` (kolekcja `search` → REST pod `/api/search/...`):
|
||||||
|
przenieś route, np. `app/api/site-search/route.ts`. Niska wartość `s-maxage` (60s) — wyniki świeże, ale z
|
||||||
cache'em CDN.
|
cache'em CDN.
|
||||||
|
|
||||||
Sam helper (do własnej wyszukiwarki po stronie serwera):
|
Sam helper (do własnej wyszukiwarki po stronie serwera):
|
||||||
|
|||||||
+20
-2
@@ -158,8 +158,23 @@ export default { plugins: { '@tailwindcss/postcss': {} } }
|
|||||||
```css
|
```css
|
||||||
/* src/app/(frontend)/styles.css */
|
/* src/app/(frontend)/styles.css */
|
||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
@import "@intecion/ipal-kit/fluid.css"; /* opcjonalnie: płynna skala typografii i odstępów */
|
||||||
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
|
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
`fluid.css` to same zmienne `clamp()` (360 → 1280 px, w `rem`) — klasy `text-h1`,
|
||||||
|
`py-section`, `px-gutter`. Liczby z `DESIGN.md` nadpisujesz w `:root` projektu
|
||||||
|
(`--ipal-fs-h1: clamp(…)`); formuł nie piszesz od zera.
|
||||||
Bez `@source` komponenty pluginu (baner cookies, Turnstile) są bez stylów.
|
Bez `@source` komponenty pluginu (baner cookies, Turnstile) są bez stylów.
|
||||||
Kolory komponentów pluginu: `--ipal-primary`, `--ipal-radius` (consent.md).
|
Kolory komponentów pluginu: `--ipal-primary`, `--ipal-radius` (consent.md).
|
||||||
|
|
||||||
@@ -305,7 +320,7 @@ export const dynamic = 'force-dynamic'
|
|||||||
export const GET = createHealthRoute({ getCachedPayload })
|
export const GET = createHealthRoute({ getCachedPayload })
|
||||||
```
|
```
|
||||||
Jeden sitemap: `sitemap.xml/route.ts` **albo** `sitemap.ts` — nigdy oba. Nagłówek
|
Jeden sitemap: `sitemap.xml/route.ts` **albo** `sitemap.ts` — nigdy oba. Nagłówek
|
||||||
sitemapy = `siteName` z Site Settings, pod nim „Technology by Intecion.com”; zmiana
|
sitemapy = „XML Sitemap”, pod nim „Technology by Intecion.com”; zmiana
|
||||||
przez `createContentHelpers({ sitemapStyle })` (seo.md).
|
przez `createContentHelpers({ sitemapStyle })` (seo.md).
|
||||||
|
|
||||||
### 2.9 next.config.ts i instrumentation.ts
|
### 2.9 next.config.ts i instrumentation.ts
|
||||||
@@ -325,7 +340,7 @@ export default withPayload({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
CSP (`buildCsp`) — najpierw `report-only`, po sprawdzeniu konsoli `enforce`
|
CSP (`buildCsp`) — najpierw `report-only`, po sprawdzeniu konsoli `enforce`
|
||||||
(security.md). `src/instrumentation.ts`: `assertEnv(ipalEnvRules({...}))` (env.md).
|
(security.md). `src/instrumentation.ts`: `assertEnv(ipalEnvRules({...}))` z **`@intecion/ipal-kit/env`**, tylko gdy `NEXT_RUNTIME === 'nodejs'` (env.md).
|
||||||
|
|
||||||
### 2.10 Generowanie i start
|
### 2.10 Generowanie i start
|
||||||
```bash
|
```bash
|
||||||
@@ -472,6 +487,9 @@ Rób po jednej pozycji, buduj, sprawdzaj. Kolejność wg wagi:
|
|||||||
| 15d | brak limitów na za duże obrazy / wideo w Media | `buildOptimizeUploadHook()` + `buildOptimizeUploadField()`, migracja pola | storage.md |
|
| 15d | brak limitów na za duże obrazy / wideo w Media | `buildOptimizeUploadHook()` + `buildOptimizeUploadField()`, migracja pola | storage.md |
|
||||||
| 15e | tablice „Add Row”, wiersze „Item 01”, `cta1`/`cta2`, etykiety PL w panelu | `labels` + `rowLabel()` na tablicach, sloty → tablica (z migracją!), etykiety EN — AGENT.md §6.5a; po aktualizacji pluginu **`pnpm payload generate:importmap`** (buildLinksField używa `RowLabel`) | links.md |
|
| 15e | tablice „Add Row”, wiersze „Item 01”, `cta1`/`cta2`, etykiety PL w panelu | `labels` + `rowLabel()` na tablicach, sloty → tablica (z migracją!), etykiety EN — AGENT.md §6.5a; po aktualizacji pluginu **`pnpm payload generate:importmap`** (buildLinksField używa `RowLabel`) | links.md |
|
||||||
| 15f | `public/sitemap.css` + własna trasa / `app/sitemap.ts` | `app/sitemap.xml/route.ts`: `export { sitemapRoute as GET } from '@/lib/content'` + `force-dynamic`; usuń `public/sitemap.css` i `app/sitemap.ts` | seo.md |
|
| 15f | `public/sitemap.css` + własna trasa / `app/sitemap.ts` | `app/sitemap.xml/route.ts`: `export { sitemapRoute as GET } from '@/lib/content'` + `force-dynamic`; usuń `public/sitemap.css` i `app/sitemap.ts` | seo.md |
|
||||||
|
| 15g | `instrumentation.ts` importuje z roota (crash Edge/Turbopack: `fileTypeFromFile`) | `import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'` + `if (process.env.NEXT_RUNTIME !== 'nodejs') return`; usuń dynamiczny `await import` | env.md |
|
||||||
|
| 15h | `<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(…) }}>` | `<JsonLdGraph schemas={[…]} />` z `@intecion/ipal-kit/rsc` (escapuje `<` — bez tego `</script>` w panelu = XSS) | seo.md |
|
||||||
|
| 15i | własne formuły `clamp()` w `styles.css` | `@import "@intecion/ipal-kit/fluid.css"` + mapowanie w `@theme` (§2.5) | — |
|
||||||
| 16 | 404 na sztywno | rola 404 w System Pages + `getNotFoundPage` | pages.md |
|
| 16 | 404 na sztywno | rola 404 w System Pages + `getNotFoundPage` | pages.md |
|
||||||
| 16a | `privacyPolicy: { label: 'Polityka prywatności', … }` w layoucie | usuń cały parametr; tekst wpisz w Cookie Settings → Privacy link label | consent.md |
|
| 16a | `privacyPolicy: { label: 'Polityka prywatności', … }` w layoucie | usuń cały parametr; tekst wpisz w Cookie Settings → Privacy link label | consent.md |
|
||||||
| 17 | Opcjonalnie — AI/GEO | Markdown per strona, llms-full, boty AI w robots, MCP, wyszukiwarka, speakable, aiSummary | content.md, seo.md, mcp.md |
|
| 17 | Opcjonalnie — AI/GEO | Markdown per strona, llms-full, boty AI w robots, MCP, wyszukiwarka, speakable, aiSummary | content.md, seo.md, mcp.md |
|
||||||
|
|||||||
+1
-1
@@ -189,7 +189,7 @@ Zrób wg PROGRAMISTA.md §2.8–2.9 i seo.md:
|
|||||||
- next.config.ts: htmlLimitedBots, buildSecurityHeaders,
|
- next.config.ts: htmlLimitedBots, buildSecurityHeaders,
|
||||||
- metadata strony przez generatePageMetadata z lib/content (wspólny cache), favicon przez buildIconsMetadata,
|
- metadata strony przez generatePageMetadata z lib/content (wspólny cache), favicon przez buildIconsMetadata,
|
||||||
- JSON-LD w root layoucie: Organization + WebSite (seo.md) z danych z panelu,
|
- JSON-LD w root layoucie: Organization + WebSite (seo.md) z danych z panelu,
|
||||||
- src/instrumentation.ts z assertEnv(ipalEnvRules(...)) (env.md).
|
- src/instrumentation.ts z assertEnv(ipalEnvRules(...)) importowanym z @intecion/ipal-kit/env (env.md).
|
||||||
CSP jeszcze nie — będzie w kroku 14.
|
CSP jeszcze nie — będzie w kroku 14.
|
||||||
Plan najpierw.
|
Plan najpierw.
|
||||||
```
|
```
|
||||||
|
|||||||
+19
-4
@@ -20,14 +20,21 @@ Najlepsze miejsce to `instrumentation.ts` (Next woła `register()` raz przy
|
|||||||
starcie serwera):
|
starcie serwera):
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// instrumentation.ts
|
// src/instrumentation.ts
|
||||||
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit'
|
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
|
||||||
|
|
||||||
export function register() {
|
export function register() {
|
||||||
|
if (process.env.NEXT_RUNTIME !== 'nodejs') return // Edge: brak process.env serwera
|
||||||
assertEnv(ipalEnvRules({ storage: true, emailGraph: true, turnstile: true }))
|
assertEnv(ipalEnvRules({ storage: true, emailGraph: true, turnstile: true }))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **Import z `@intecion/ipal-kit/env`, nie z roota.** Next kompiluje
|
||||||
|
> `instrumentation.ts` także dla Edge. Root pakietu ciągnie Payload, `file-type`,
|
||||||
|
> `fs` — Turbopack pada (`Export fileTypeFromFile doesn't exist in target module`).
|
||||||
|
> `/env` to tylko walidator, zero zależności. Root nadal eksportuje `assertEnv`
|
||||||
|
> (np. dla `payload.config.ts`).
|
||||||
|
|
||||||
Alternatywnie na górze `payload.config.ts` (ładuje się i w buildzie, i w
|
Alternatywnie na górze `payload.config.ts` (ładuje się i w buildzie, i w
|
||||||
runtime). Działa tylko po stronie serwera (czyta `process.env`) — NIE importuj
|
runtime). Działa tylko po stronie serwera (czyta `process.env`) — NIE importuj
|
||||||
do komponentu klienckiego.
|
do komponentu klienckiego.
|
||||||
@@ -114,6 +121,14 @@ redeployów.
|
|||||||
## Eksport
|
## Eksport
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit'
|
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
|
||||||
import type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from '@intecion/ipal-kit'
|
import type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from '@intecion/ipal-kit/env'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `R2_PUBLIC_URL` — produkcja vs dev
|
||||||
|
|
||||||
|
`ipalEnvRules({ storage: true })` wymaga w **produkcji** pełnego URL-a
|
||||||
|
(`https://media.klient.pl`). Poza produkcją dopuszcza ścieżkę względną
|
||||||
|
(`/media`) — `buildR2Storage` dokleja do niej `NEXT_PUBLIC_SERVER_URL`, CSP jej nie
|
||||||
|
dodaje (to `'self'`), `MediaPreconnect` ją pomija. Dev bez bucketu: nie ustawiaj
|
||||||
|
`R2_*` wcale i nie włączaj `storage` — media lądują na dysku.
|
||||||
|
|||||||
+9
-2
@@ -58,7 +58,8 @@ wykona `initialize` → `tools/list` → i będzie mógł wołać `search_conten
|
|||||||
|
|
||||||
`getCachedPayload`, `config` (wymagane); `baseUrl` (URL-e w wynikach), `collection`
|
`getCachedPayload`, `config` (wymagane); `baseUrl` (URL-e w wynikach), `collection`
|
||||||
(`'pages'`), `settingsSlug`, `content` (kolekcje-archiwa dla `get_page`),
|
(`'pages'`), `settingsSlug`, `content` (kolekcje-archiwa dla `get_page`),
|
||||||
`serverName` (`'ipal-site'`), `serverVersion` (`'1.0.0'`).
|
`serverName` (`'ipal-site'`), `serverVersion` (`'1.0.0'`), `rateLimit`
|
||||||
|
(`{ max: 60, windowMs: 60_000 }` na IP, `false` = wyłączony), `maxBatch` (`10`).
|
||||||
|
|
||||||
## Bezpieczeństwo
|
## Bezpieczeństwo
|
||||||
|
|
||||||
@@ -66,10 +67,16 @@ wykona `initialize` → `tools/list` → i będzie mógł wołać `search_conten
|
|||||||
- `search_content` używa `like` i odpada bezpiecznie (komunikat), gdy pole nie
|
- `search_content` używa `like` i odpada bezpiecznie (komunikat), gdy pole nie
|
||||||
jest odpytywalne — nie wywala route'a.
|
jest odpytywalne — nie wywala route'a.
|
||||||
- Nie wystawiaj tu niczego spoza publicznej treści strony.
|
- Nie wystawiaj tu niczego spoza publicznej treści strony.
|
||||||
|
- **Limit zapytań:** 60 wiadomości JSON-RPC/min na IP (batch liczy się jako tyle
|
||||||
|
wiadomości, ile zawiera) → `429` z `Retry-After`. Batch > 10 → `400`. Limit jest w
|
||||||
|
pamięci, per instancja — za Cloudflare dołóż regułę Rate limiting w WAF.
|
||||||
|
- Za Cloudflare Access route musi mieć Bypass (klienci MCP nie wyślą Service Token)
|
||||||
|
— patrz instrukcja Cloudflare Access.
|
||||||
|
|
||||||
## Protokół (dla debugowania)
|
## Protokół (dla debugowania)
|
||||||
|
|
||||||
Pojedynczy obiekt JSON-RPC albo batch (tablica). Notyfikacje (`notifications/*`,
|
Pojedynczy obiekt JSON-RPC albo batch (tablica). Notyfikacje (`notifications/*`,
|
||||||
bez `id`) → HTTP 202 bez ciała. Żądania → `{ jsonrpc:'2.0', id, result }` albo
|
bez `id`) → HTTP 202 bez ciała. Żądania → `{ jsonrpc:'2.0', id, result }` albo
|
||||||
`error` (`-32601` nieznana metoda, `-32700` parse error). `initialize` odbija
|
`error` (`-32601` nieznana metoda, `-32700` parse error, `-32600` batch za duży,
|
||||||
|
`-32000` limit zapytań). `initialize` odbija
|
||||||
`protocolVersion` klienta (fallback `2025-06-18`).
|
`protocolVersion` klienta (fallback `2025-06-18`).
|
||||||
|
|||||||
+1
-3
@@ -1079,7 +1079,7 @@ export { sitemapRoute as GET } from '@/lib/content'
|
|||||||
export const dynamic = 'force-dynamic'
|
export const dynamic = 'force-dynamic'
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Nagłówek** = `siteName` z Site Settings (język domyślny); brak → „XML Sitemap”.
|
- **Nagłówek** = „XML Sitemap” (bez nazwy firmy/strony).
|
||||||
- **Linia pod nagłówkiem** = dostawca technologii: „Technology by Intecion.com”.
|
- **Linia pod nagłówkiem** = dostawca technologii: „Technology by Intecion.com”.
|
||||||
- To CSS na XML (`<?xml-stylesheet type="text/css"?>`, standard W3C) — **nie XSLT**,
|
- To CSS na XML (`<?xml-stylesheet type="text/css"?>`, standard W3C) — **nie XSLT**,
|
||||||
które przeglądarki wycofują. Google ignoruje dyrektywę; zero wpływu na SEO.
|
które przeglądarki wycofują. Google ignoruje dyrektywę; zero wpływu na SEO.
|
||||||
@@ -1090,9 +1090,7 @@ createContentHelpers({
|
|||||||
config, content, i18n: i18nConfig,
|
config, content, i18n: i18nConfig,
|
||||||
sitemapStyle: { accent: '#0f766e' }, // kolor akcentu
|
sitemapStyle: { accent: '#0f766e' }, // kolor akcentu
|
||||||
// sitemapStyle: { credit: false }, // bez linii dostawcy
|
// sitemapStyle: { credit: false }, // bez linii dostawcy
|
||||||
// sitemapStyle: { title: 'Sitemap' }, // stały nagłówek zamiast siteName
|
|
||||||
// sitemapStyle: false, // surowy XML (natywny widok przeglądarki)
|
// sitemapStyle: false, // surowy XML (natywny widok przeglądarki)
|
||||||
// siteNameField: 'name', // gdy pole nazwy w Site Settings ma inną nazwę
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ S3. Dodaj zmienną i przekaż ją do adaptera:
|
|||||||
```bash
|
```bash
|
||||||
# .env
|
# .env
|
||||||
R2_PUBLIC_URL=https://media.klient.pl
|
R2_PUBLIC_URL=https://media.klient.pl
|
||||||
|
# dev z rewrite /media → bucket: R2_PUBLIC_URL=/media (tylko poza produkcją; env.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
Adapter `buildR2Storage` czyta ją i ustawia jako bazowy URL mediów (jeśli
|
Adapter `buildR2Storage` czyta ją i ustawia jako bazowy URL mediów (jeśli
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@intecion/ipal-kit",
|
"name": "@intecion/ipal-kit",
|
||||||
"version": "1.8.7",
|
"version": "1.8.11",
|
||||||
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
"description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -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'
|
||||||
+137
-137
@@ -1,3 +1,20 @@
|
|||||||
|
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 { 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 type { AccessOption, Role } from './modules/access/index.js'
|
||||||
export {
|
export {
|
||||||
adminOnly,
|
adminOnly,
|
||||||
@@ -13,102 +30,58 @@ export {
|
|||||||
requireRoleField,
|
requireRoleField,
|
||||||
ROLE_HIERARCHY,
|
ROLE_HIERARCHY,
|
||||||
} from './modules/access/index.js'
|
} from './modules/access/index.js'
|
||||||
export { A11Y_COOKIE, A11Y_DEFAULT, a11yAttributes, parseA11y, serializeA11y } from './modules/accessibility/index.js'
|
export type { GlobalQueryOptions } from './modules/payload/index.js'
|
||||||
export type { A11yState } from './modules/accessibility/index.js'
|
|
||||||
export { rowLabel } from './modules/admin-ui/index.js'
|
|
||||||
export type { RowLabelProps } from './modules/admin-ui/index.js'
|
|
||||||
export type { AnalyticsConfig } from './modules/analytics/index.js'
|
|
||||||
export { getAnalyticsConfig } from './modules/analytics/index.js'
|
|
||||||
export {
|
export {
|
||||||
ACCEPT_ALL_CONSENT,
|
getGlobal,
|
||||||
CONSENT_CATEGORIES,
|
getSiteSettings,
|
||||||
CONSENT_COOKIE,
|
getSiteIntegrations,
|
||||||
CONSENT_MAX_AGE,
|
SITE_SETTINGS_SLUG,
|
||||||
CONSENT_VERSION,
|
SITE_INTEGRATIONS_SLUG,
|
||||||
DEFAULT_CONSENT,
|
} from './modules/payload/index.js'
|
||||||
getConsentTexts,
|
export type { SeoOption, SeoMeta, PageMetadata } from './modules/seo/index.js'
|
||||||
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 {
|
export {
|
||||||
archiveFieldName,
|
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,
|
blocksToMarkdown,
|
||||||
|
createMarkdownRenderer,
|
||||||
|
markdownResponse,
|
||||||
|
prefersMarkdown,
|
||||||
|
markdownHref,
|
||||||
|
MARKDOWN_PREFIX,
|
||||||
|
searchContent,
|
||||||
|
createSearchRoute,
|
||||||
|
archiveFieldName,
|
||||||
|
getArchiveEntries,
|
||||||
buildArchivePath,
|
buildArchivePath,
|
||||||
buildEntryPath,
|
buildEntryPath,
|
||||||
createMarkdownRenderer,
|
|
||||||
createSearchRoute,
|
|
||||||
getArchiveEntries,
|
|
||||||
MARKDOWN_PREFIX,
|
|
||||||
markdownHref,
|
|
||||||
markdownResponse,
|
|
||||||
parsePageParam,
|
parsePageParam,
|
||||||
prefersMarkdown,
|
|
||||||
resolveNotFoundPage,
|
|
||||||
resolveRedirect,
|
|
||||||
resolveRoute,
|
|
||||||
searchContent,
|
|
||||||
} from './modules/content/index.js'
|
} from './modules/content/index.js'
|
||||||
export type { ArchiveEntries } from './modules/content/index.js'
|
export type { ArchiveEntries } from './modules/content/index.js'
|
||||||
export type { SearchResult } from './modules/content/index.js'
|
export type { SearchResult } from './modules/content/index.js'
|
||||||
export { graphAdapter } from './modules/email/graphAdapter.js'
|
// Lexical → Markdown (pure, no React) — for AI-readable output.
|
||||||
export type { GraphAdapterArgs } from './modules/email/graphAdapter.js'
|
export { lexicalToMarkdown } from './modules/richtext/index.js'
|
||||||
export { mailAdapter } from './modules/email/mailAdapter.js'
|
export type { AutoFillMapping, SitemapEntry, RobotsRules, RobotsOptions } from './modules/seo/index.js'
|
||||||
export type { MailAdapterArgs } from './modules/email/mailAdapter.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'
|
|
||||||
export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'
|
|
||||||
// Boot-time environment validation (fail fast on misconfigured deploys).
|
|
||||||
export { assertEnv, ipalEnvRules } from './modules/env/index.js'
|
|
||||||
export type { AssertEnvOptions, EnvKind, EnvRule, IpalEnvFeatures } from './modules/env/index.js'
|
|
||||||
// Panel-managed form analytics (config-time field builder).
|
|
||||||
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'
|
|
||||||
// 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 {
|
export {
|
||||||
buildValidator,
|
buildAutoFillMetaHook,
|
||||||
checked,
|
injectAutoFillMeta,
|
||||||
custom,
|
createMetadataGenerator,
|
||||||
email,
|
createPageMetadata,
|
||||||
isEmail,
|
buildSitemapEntries,
|
||||||
maxLength,
|
buildRobots,
|
||||||
minLength,
|
AI_ASSISTANT_BOTS,
|
||||||
pattern,
|
AI_TRAINING_BOTS,
|
||||||
required,
|
} from './modules/seo/index.js'
|
||||||
} from './modules/forms/validators.js'
|
|
||||||
export type { Rule } from './modules/forms/validators.js'
|
|
||||||
export { createContentHelpers } from './modules/frontend/index.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 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 type { LocaleMiddlewareResult } from './modules/i18n/index.js'
|
||||||
export {
|
export {
|
||||||
createLocaleMiddleware,
|
createLocaleMiddleware,
|
||||||
@@ -116,70 +89,97 @@ export {
|
|||||||
} from './modules/i18n/index.js'
|
} from './modules/i18n/index.js'
|
||||||
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'
|
export { createProxy, DEFAULT_PROXY_MATCHER } from './modules/i18n/index.js'
|
||||||
export { resolveLocalized } from './modules/i18n/index.js'
|
export { resolveLocalized } from './modules/i18n/index.js'
|
||||||
export { buildLinkField, buildLinksField, resolveLinkHref } from './modules/links/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'
|
||||||
|
// 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'
|
||||||
|
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 {
|
export type {
|
||||||
BuildLinkFieldOptions,
|
FormsOption,
|
||||||
BuildLinksFieldOptions,
|
FormsCollectionOverrides,
|
||||||
LinkAppearance,
|
FormsFieldsOverride,
|
||||||
LinkValue,
|
} from './modules/forms/types.js'
|
||||||
ResolveLinkHrefOptions,
|
// Validation rules are pure — exported server-side too, for re-validating a
|
||||||
} from './modules/links/index.js'
|
// submission inside a server action. (useForm/useContactForm are client-only →
|
||||||
|
// '@intecion/ipal-kit/client'.)
|
||||||
|
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'
|
||||||
|
// 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'
|
||||||
// Read-only MCP server (Claude/agents connect to the site and query it).
|
// Read-only MCP server (Claude/agents connect to the site and query it).
|
||||||
export { createMcpRoute } from './modules/mcp/index.js'
|
export { createMcpRoute } from './modules/mcp/index.js'
|
||||||
export { buildOptimizeUploadField, buildOptimizeUploadHook, normalizeFilename, normalizeFilenameHook } from './modules/media/index.js'
|
// Boot-time environment validation (fail fast on misconfigured deploys).
|
||||||
export type { OptimizeUploadOptions } from './modules/media/index.js'
|
export { assertEnv, ipalEnvRules } from './modules/env/index.js'
|
||||||
export { getNotificationTexts, NOTIFICATION_FALLBACK, resolveFormMessage } from './modules/notifications/index.js'
|
export type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from './modules/env/index.js'
|
||||||
export type { FormNotificationTexts, NotificationTexts } from './modules/notifications/index.js'
|
export type { AnalyticsConfig } from './modules/analytics/index.js'
|
||||||
export type { PagesOption, SystemPageRole } from './modules/pages/index.js'
|
export { getAnalyticsConfig } from './modules/analytics/index.js'
|
||||||
export { ALL_SYSTEM_PAGE_ROLES, getSystemPagePath } from './modules/pages/index.js'
|
export { buildSlugField, toSlug } from './modules/slug/index.js'
|
||||||
export type { GlobalQueryOptions } from './modules/payload/index.js'
|
export { createLlmsTxtRoute, createSitemapRouteHandler, createManifestHandler } from './modules/seo/index.js'
|
||||||
|
|
||||||
export {
|
export { getNotificationTexts, resolveFormMessage, NOTIFICATION_FALLBACK } from './modules/notifications/index.js'
|
||||||
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'
|
|
||||||
export { buildSecurityHeaders } from './modules/security/index.js'
|
export { buildSecurityHeaders } from './modules/security/index.js'
|
||||||
export { buildCsp } from './modules/security/index.js'
|
export { buildCsp } from './modules/security/index.js'
|
||||||
export type { BuildCspArgs } 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,
|
|
||||||
readSiteMetaConfig,
|
|
||||||
slugsAcrossLocales,
|
|
||||||
} from './modules/seo/index.js'
|
|
||||||
export type { SiteMetaConfig } from './modules/seo/index.js'
|
|
||||||
export type { AutoFillMapping, RobotsOptions, 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 { 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 { buildSpeakableJsonLd } from './modules/seo/index.js'
|
||||||
export { buildSummaryField } 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.
|
// 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 { buildArticleJsonLd } from './modules/seo/index.js'
|
||||||
export { buildLlmsTxt } from './modules/seo/index.js'
|
export { buildLlmsTxt } from './modules/seo/index.js'
|
||||||
export { buildSitemapCss, buildSitemapXml, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './modules/seo/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 type { SitemapRouteOptions, SitemapStyleOptions } from './modules/seo/index.js'
|
||||||
export { buildSlugField, toSlug } from './modules/slug/index.js'
|
|
||||||
export { buildR2Storage } from './modules/storage/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 type { IpalOptions } from './types.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'
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { BasePayload } from 'payload'
|
|||||||
|
|
||||||
import type { I18nConfig } from '../i18n/index.js'
|
import type { I18nConfig } from '../i18n/index.js'
|
||||||
|
|
||||||
|
import { checkRateLimit, clientIp, tooManyRequests } from '../shared/rateLimit.js'
|
||||||
import { searchContent } from './searchContent.js'
|
import { searchContent } from './searchContent.js'
|
||||||
|
|
||||||
type CreateSearchRouteArgs = {
|
type CreateSearchRouteArgs = {
|
||||||
@@ -15,6 +16,11 @@ type CreateSearchRouteArgs = {
|
|||||||
getCachedPayload: () => Promise<BasePayload>
|
getCachedPayload: () => Promise<BasePayload>
|
||||||
/** Home slug map/string so the home result collapses to root. */
|
/** Home slug map/string so the home result collapses to root. */
|
||||||
homeSlug?: Record<string, string> | string
|
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. */
|
/** Field holding a richer AI summary (buildSummaryField) to prefer as description. */
|
||||||
summaryField?: string
|
summaryField?: string
|
||||||
}
|
}
|
||||||
@@ -37,20 +43,18 @@ type CreateSearchRouteArgs = {
|
|||||||
*
|
*
|
||||||
* Uses the global Request/Response — no next/server import.
|
* Uses the global Request/Response — no next/server import.
|
||||||
*/
|
*/
|
||||||
export function createSearchRoute(
|
export function createSearchRoute(args: CreateSearchRouteArgs): (req: Request) => Promise<Response> {
|
||||||
args: CreateSearchRouteArgs,
|
const { baseUrl, collection = 'pages', config, defaultLimit = 10, getCachedPayload, homeSlug, summaryField } = args
|
||||||
): (req: Request) => Promise<Response> {
|
// 120/min: a debounced search-as-you-type box stays well under it; a scraper doesn't.
|
||||||
const {
|
const rl = args.rateLimit === false ? null : { max: 120, windowMs: 60_000, ...args.rateLimit }
|
||||||
baseUrl,
|
|
||||||
collection = 'pages',
|
|
||||||
config,
|
|
||||||
defaultLimit = 10,
|
|
||||||
getCachedPayload,
|
|
||||||
homeSlug,
|
|
||||||
summaryField,
|
|
||||||
} = args
|
|
||||||
|
|
||||||
return async (req: Request) => {
|
return async (req: Request) => {
|
||||||
|
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 url = new URL(req.url)
|
||||||
const query = url.searchParams.get('q')?.trim() ?? ''
|
const query = url.searchParams.get('q')?.trim() ?? ''
|
||||||
const locale = url.searchParams.get('locale') ?? undefined
|
const locale = url.searchParams.get('locale') ?? undefined
|
||||||
@@ -79,11 +83,7 @@ export function createSearchRoute(
|
|||||||
})
|
})
|
||||||
return Response.json(
|
return Response.json(
|
||||||
{ count: results.length, locale: locale ?? config.defaultLocale, query, results },
|
{ count: results.length, locale: locale ?? config.defaultLocale, query, results },
|
||||||
{
|
{ headers: { 'cache-control': 'public, max-age=0, s-maxage=60, stale-while-revalidate=600' } },
|
||||||
headers: {
|
|
||||||
'cache-control': 'public, max-age=0, s-maxage=60, stale-while-revalidate=600',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// DB unreachable (build) or unexpected — empty result rather than 500.
|
// DB unreachable (build) or unexpected — empty result rather than 500.
|
||||||
|
|||||||
Vendored
+1
-1
@@ -43,7 +43,7 @@ function checkValue(rule: EnvRule, value: string): null | string {
|
|||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case 'boolean':
|
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}")`
|
return `${name} must be a boolean (true/false/1/0/yes/no, got "${value}")`
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
Vendored
+15
-6
@@ -53,11 +53,7 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
|
|||||||
const rules: EnvRule[] = [
|
const rules: EnvRule[] = [
|
||||||
{ name: databaseVar, description: 'Database connection string (e.g. MongoDB URI)' },
|
{ name: databaseVar, description: 'Database connection string (e.g. MongoDB URI)' },
|
||||||
{ name: secretVar, description: 'Payload secret used to sign tokens' },
|
{ name: secretVar, description: 'Payload secret used to sign tokens' },
|
||||||
{
|
{ name: serverUrlVar, description: 'Public site origin, e.g. https://example.com', kind: 'url' },
|
||||||
name: serverUrlVar,
|
|
||||||
description: 'Public site origin, e.g. https://example.com',
|
|
||||||
kind: 'url',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'NODE_ENV',
|
name: 'NODE_ENV',
|
||||||
description: 'Node environment',
|
description: 'Node environment',
|
||||||
@@ -72,7 +68,20 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
|
|||||||
{ name: 'R2_ACCESS_KEY_ID', description: 'R2 access key id' },
|
{ name: 'R2_ACCESS_KEY_ID', description: 'R2 access key id' },
|
||||||
{ name: 'R2_SECRET_ACCESS_KEY', description: 'R2 secret access key' },
|
{ name: 'R2_SECRET_ACCESS_KEY', description: 'R2 secret access key' },
|
||||||
{ name: 'R2_ENDPOINT', description: 'R2 S3 API endpoint URL', kind: 'url' },
|
{ name: 'R2_ENDPOINT', description: 'R2 S3 API endpoint URL', kind: 'url' },
|
||||||
{ name: 'R2_PUBLIC_URL', description: 'Public base URL media is served from', kind: 'url' },
|
{
|
||||||
|
name: 'R2_PUBLIC_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}")`
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,3 @@
|
|||||||
type Bucket = { count: number; resetAt: number }
|
// Moved to modules/shared/rateLimit.ts (shared with search and MCP routes).
|
||||||
|
export { checkRateLimit, clientIp, retryAfterSeconds, tooManyRequests } from '../shared/rateLimit.js'
|
||||||
/**
|
export type { RateLimitArgs } from '../shared/rateLimit.js'
|
||||||
* 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<string, Bucket>()
|
|
||||||
|
|
||||||
/** Sweep expired buckets occasionally so the map doesn't grow unbounded. */
|
|
||||||
let lastSweep = Date.now()
|
|
||||||
const SWEEP_INTERVAL = 60_000
|
|
||||||
|
|
||||||
function sweep(now: number) {
|
|
||||||
if (now - lastSweep < SWEEP_INTERVAL) {return}
|
|
||||||
lastSweep = now
|
|
||||||
for (const [key, bucket] of buckets) {
|
|
||||||
if (bucket.resetAt <= now) {buckets.delete(key)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 function checkRateLimit({ key, max = 5, windowMs = 60_000 }: RateLimitArgs): boolean {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -41,12 +41,9 @@ type CreateContentHelpersArgs = {
|
|||||||
settingsSlug?: string
|
settingsSlug?: string
|
||||||
/**
|
/**
|
||||||
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
* Browser look of `sitemapRoute` (/sitemap.xml). Default: built-in style,
|
||||||
* header = Site Settings `siteName` (default locale), credit "Technology by
|
* header "XML Sitemap", credit "Technology by Intecion.com". `false` = raw XML.
|
||||||
* Intecion.com". `false` = raw XML. `{ credit: false }` hides the credit line.
|
|
||||||
*/
|
*/
|
||||||
sitemapStyle?: { title?: string } & Omit<SitemapStyleOptions, 'title'> | false
|
sitemapStyle?: false | SitemapStyleOptions
|
||||||
/** Site Settings field with the site name (sitemap header). Default 'siteName'. */
|
|
||||||
siteNameField?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +81,6 @@ export function createContentHelpers({
|
|||||||
robots: robotsOptions,
|
robots: robotsOptions,
|
||||||
settingsSlug = 'site-settings',
|
settingsSlug = 'site-settings',
|
||||||
sitemapStyle,
|
sitemapStyle,
|
||||||
siteNameField = 'siteName',
|
|
||||||
}: CreateContentHelpersArgs) {
|
}: CreateContentHelpersArgs) {
|
||||||
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
|
const origin = baseUrl ?? process.env.NEXT_PUBLIC_SERVER_URL ?? ''
|
||||||
const getCachedPayload = cache(
|
const getCachedPayload = cache(
|
||||||
@@ -401,23 +397,7 @@ export function createContentHelpers({
|
|||||||
* export { sitemapRoute as GET } from '@/lib/content'
|
* export { sitemapRoute as GET } from '@/lib/content'
|
||||||
* export const dynamic = 'force-dynamic'
|
* export const dynamic = 'force-dynamic'
|
||||||
*/
|
*/
|
||||||
const sitemapRoute = createSitemapRouteHandler(sitemap, {
|
const sitemapRoute = createSitemapRouteHandler(sitemap, { style: sitemapStyle ?? {} })
|
||||||
style:
|
|
||||||
sitemapStyle === false
|
|
||||||
? false
|
|
||||||
: {
|
|
||||||
...sitemapStyle,
|
|
||||||
title:
|
|
||||||
sitemapStyle?.title ??
|
|
||||||
(async () => {
|
|
||||||
const locale = i18n?.defaultLocale
|
|
||||||
if (!locale) {return undefined}
|
|
||||||
const s = (await getSettings(locale)) as Record<string, unknown>
|
|
||||||
const name = s?.[siteNameField]
|
|
||||||
return typeof name === 'string' ? name : undefined
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
generatePageMetadata,
|
generatePageMetadata,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { I18nConfig } from '../i18n/index.js'
|
|||||||
|
|
||||||
import { createMarkdownRenderer, searchContent } from '../content/index.js'
|
import { createMarkdownRenderer, searchContent } from '../content/index.js'
|
||||||
import { getDefaultLocale, isValidLocale } from '../i18n/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
|
* A read-only MCP (Model Context Protocol) server for the client site, as a Next
|
||||||
@@ -46,6 +47,13 @@ type CreateMcpRouteArgs = {
|
|||||||
/** Archive-backed collections (same as the plugin option) for get_page. */
|
/** Archive-backed collections (same as the plugin option) for get_page. */
|
||||||
content?: ContentOption
|
content?: ContentOption
|
||||||
getCachedPayload: () => Promise<BasePayload>
|
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'. */
|
/** Server name advertised in `initialize`. Default 'ipal-site'. */
|
||||||
serverName?: string
|
serverName?: string
|
||||||
/** Server version advertised in `initialize`. Default '1.0.0'. */
|
/** Server version advertised in `initialize`. Default '1.0.0'. */
|
||||||
@@ -77,11 +85,13 @@ export function createMcpRoute(args: CreateMcpRouteArgs) {
|
|||||||
config,
|
config,
|
||||||
content,
|
content,
|
||||||
getCachedPayload,
|
getCachedPayload,
|
||||||
|
maxBatch = 10,
|
||||||
serverName = 'ipal-site',
|
serverName = 'ipal-site',
|
||||||
serverVersion = '1.0.0',
|
serverVersion = '1.0.0',
|
||||||
settingsSlug = 'site-settings',
|
settingsSlug = 'site-settings',
|
||||||
summaryField,
|
summaryField,
|
||||||
} = args
|
} = args
|
||||||
|
const rl = args.rateLimit === false ? null : { max: 60, windowMs: 60_000, ...args.rateLimit }
|
||||||
|
|
||||||
const origin = baseUrl?.replace(/\/$/, '') ?? ''
|
const origin = baseUrl?.replace(/\/$/, '') ?? ''
|
||||||
const renderMarkdown = createMarkdownRenderer({ collection, content, settingsSlug })
|
const renderMarkdown = createMarkdownRenderer({ collection, content, settingsSlug })
|
||||||
@@ -145,10 +155,7 @@ export function createMcpRoute(args: CreateMcpRouteArgs) {
|
|||||||
async function getPage(params: Record<string, unknown>): Promise<string> {
|
async function getPage(params: Record<string, unknown>): Promise<string> {
|
||||||
const raw = typeof params.path === 'string' ? params.path.trim() : ''
|
const raw = typeof params.path === 'string' ? params.path.trim() : ''
|
||||||
if (!raw) {return 'No path provided.'}
|
if (!raw) {return 'No path provided.'}
|
||||||
const segments = raw
|
const segments = raw.replace(/^\/+|\/+$/g, '').split('/').filter(Boolean)
|
||||||
.replace(/^\/+|\/+$/g, '')
|
|
||||||
.split('/')
|
|
||||||
.filter(Boolean)
|
|
||||||
let locale = getDefaultLocale(config)
|
let locale = getDefaultLocale(config)
|
||||||
let slug = segments
|
let slug = segments
|
||||||
if (segments.length && isValidLocale(segments[0], config)) {
|
if (segments.length && isValidLocale(segments[0], config)) {
|
||||||
@@ -210,6 +217,19 @@ export function createMcpRoute(args: CreateMcpRouteArgs) {
|
|||||||
return Response.json(rpcError(null, -32700, 'Parse error'), { status: 400 })
|
return Response.json(rpcError(null, -32700, 'Parse error'), { 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.
|
// Batch or single.
|
||||||
if (Array.isArray(body)) {
|
if (Array.isArray(body)) {
|
||||||
const out = (await Promise.all(body.map((m) => handleOne(m as JsonRpcRequest)))).filter(
|
const out = (await Promise.all(body.map((m) => handleOne(m as JsonRpcRequest)))).filter(
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ export function buildCsp(args: BuildCspArgs = {}): { key: string; value: string
|
|||||||
'object-src': ["'none'"], // block <object>/<embed> (Flash-era attack surface)
|
'object-src': ["'none'"], // block <object>/<embed> (Flash-era attack surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r2Url) {src['img-src'].push(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) {
|
if (turnstile) {
|
||||||
src['script-src'].push('https://challenges.cloudflare.com')
|
src['script-src'].push('https://challenges.cloudflare.com')
|
||||||
@@ -110,7 +111,6 @@ export function buildCsp(args: BuildCspArgs = {}): { key: string; value: string
|
|||||||
.map(([dir, values]) => `${dir} ${values.join(' ')}`)
|
.map(([dir, values]) => `${dir} ${values.join(' ')}`)
|
||||||
.join('; ')
|
.join('; ')
|
||||||
|
|
||||||
const key =
|
const key = mode === 'report-only' ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
|
||||||
mode === 'report-only' ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
|
|
||||||
return { key, value }
|
return { key, value }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ export function createSitemapRouteHandler(
|
|||||||
): (req: Request) => Promise<Response> {
|
): (req: Request) => Promise<Response> {
|
||||||
const style = opts.cssUrl ? false : opts.style === false ? false : (opts.style ?? {})
|
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: Request) => {
|
return async (req: Request) => {
|
||||||
const url = new URL(req.url)
|
const url = new URL(req.url)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export type SitemapStyleOptions = {
|
|||||||
* "Technology by Intecion.com". `false` hides it.
|
* "Technology by Intecion.com". `false` hides it.
|
||||||
*/
|
*/
|
||||||
credit?: false | string
|
credit?: false | string
|
||||||
/** Header line. Default: the site name from Site Settings (sitemapRoute), else "XML Sitemap". */
|
/** Header line. Default "XML Sitemap". */
|
||||||
title?: string
|
title?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
type Bucket = { count: number; resetAt: number }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<string, Bucket>()
|
||||||
|
|
||||||
|
/** Sweep expired buckets occasionally so the map doesn't grow unbounded. */
|
||||||
|
let lastSweep = Date.now()
|
||||||
|
const SWEEP_INTERVAL = 60_000
|
||||||
|
|
||||||
|
function sweep(now: number) {
|
||||||
|
if (now - lastSweep < SWEEP_INTERVAL) {return}
|
||||||
|
lastSweep = now
|
||||||
|
for (const [key, bucket] of buckets) {
|
||||||
|
if (bucket.resetAt <= now) {buckets.delete(key)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 function checkRateLimit({ cost = 1, key, max = 5, scope = 'form', windowMs = 60_000 }: { cost?: number } & RateLimitArgs): boolean {
|
||||||
|
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: string, scope = 'form'): number {
|
||||||
|
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: Request): string {
|
||||||
|
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: string, scope: string, body: unknown): Response {
|
||||||
|
return Response.json(body, {
|
||||||
|
headers: { 'cache-control': 'no-store', 'retry-after': String(retryAfterSeconds(key, scope)) },
|
||||||
|
status: 429,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -77,7 +77,12 @@ export const buildR2Storage = (
|
|||||||
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
||||||
// pointing there. Without it, uploads work but images don't display publicly.
|
// pointing there. Without it, uploads work but images don't display publicly.
|
||||||
// See docs/storage.md.
|
// 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
|
// 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
|
// top-level one) — R2 needs it to point served URLs at the custom domain
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user