cms-renderer 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-G22U6UHQ.js +45 -0
- package/dist/chunk-G22U6UHQ.js.map +1 -0
- package/dist/chunk-HVKFEZBT.js +116 -0
- package/dist/chunk-HVKFEZBT.js.map +1 -0
- package/dist/chunk-RPM73PQZ.js +17 -0
- package/dist/chunk-RPM73PQZ.js.map +1 -0
- package/dist/lib/block-renderer.d.ts +32 -0
- package/dist/lib/block-renderer.js +7 -0
- package/dist/lib/block-renderer.js.map +1 -0
- package/dist/lib/cms-api.d.ts +24 -0
- package/dist/lib/cms-api.js +7 -0
- package/dist/lib/cms-api.js.map +1 -0
- package/dist/lib/data-utils.d.ts +218 -0
- package/dist/lib/data-utils.js +247 -0
- package/dist/lib/data-utils.js.map +1 -0
- package/dist/lib/image/lazy-load.d.ts +75 -0
- package/dist/lib/image/lazy-load.js +83 -0
- package/dist/lib/image/lazy-load.js.map +1 -0
- package/dist/lib/markdown-utils.d.ts +172 -0
- package/dist/lib/markdown-utils.js +137 -0
- package/dist/lib/markdown-utils.js.map +1 -0
- package/dist/lib/renderer.d.ts +36 -0
- package/dist/lib/renderer.js +343 -0
- package/dist/lib/renderer.js.map +1 -0
- package/{lib/result.ts → dist/lib/result.d.ts} +32 -146
- package/dist/lib/result.js +37 -0
- package/dist/lib/result.js.map +1 -0
- package/dist/lib/schema.d.ts +15 -0
- package/dist/lib/schema.js +35 -0
- package/dist/lib/schema.js.map +1 -0
- package/{lib/trpc.ts → dist/lib/trpc.d.ts} +6 -4
- package/dist/lib/trpc.js +7 -0
- package/dist/lib/trpc.js.map +1 -0
- package/dist/lib/types.d.ts +163 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/types.js.map +1 -0
- package/package.json +50 -11
- package/.turbo/turbo-check-types.log +0 -2
- package/lib/__tests__/enrich-block-images.test.ts +0 -394
- package/lib/block-renderer.tsx +0 -60
- package/lib/cms-api.ts +0 -86
- package/lib/data-utils.ts +0 -572
- package/lib/image/lazy-load.ts +0 -209
- package/lib/markdown-utils.ts +0 -368
- package/lib/renderer.tsx +0 -189
- package/lib/schema.ts +0 -74
- package/lib/types.ts +0 -201
- package/next.config.ts +0 -39
- package/postcss.config.mjs +0 -5
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
err,
|
|
3
|
+
ok
|
|
4
|
+
} from "../chunk-HVKFEZBT.js";
|
|
5
|
+
|
|
6
|
+
// lib/markdown-utils.ts
|
|
7
|
+
import { mdToJSON } from "md4w";
|
|
8
|
+
var ParseErrorCode = {
|
|
9
|
+
INVALID_INPUT: "INVALID_INPUT",
|
|
10
|
+
EMPTY_CONTENT: "EMPTY_CONTENT",
|
|
11
|
+
PARSE_FAILED: "PARSE_FAILED",
|
|
12
|
+
CONTENT_TOO_LONG: "CONTENT_TOO_LONG",
|
|
13
|
+
NESTED_TOO_DEEP: "NESTED_TOO_DEEP"
|
|
14
|
+
};
|
|
15
|
+
var DEFAULT_MAX_LENGTH = 5e5;
|
|
16
|
+
var XSS_PATTERNS = [
|
|
17
|
+
/<script\b/i,
|
|
18
|
+
/javascript:/i,
|
|
19
|
+
/on\w+\s*=/i,
|
|
20
|
+
// onclick=, onerror=, etc.
|
|
21
|
+
/data:/i,
|
|
22
|
+
// data: URIs can be dangerous
|
|
23
|
+
/vbscript:/i
|
|
24
|
+
];
|
|
25
|
+
function parseMarkdownV1(content) {
|
|
26
|
+
return mdToJSON(content);
|
|
27
|
+
}
|
|
28
|
+
function parseMarkdownV2(content) {
|
|
29
|
+
try {
|
|
30
|
+
if (content == null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return mdToJSON(content);
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function createParseError(code, message, cause) {
|
|
39
|
+
return { code, message, cause };
|
|
40
|
+
}
|
|
41
|
+
function detectXssPattern(content) {
|
|
42
|
+
for (const pattern of XSS_PATTERNS) {
|
|
43
|
+
if (pattern.test(content)) {
|
|
44
|
+
return pattern;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function sanitizeContent(content) {
|
|
50
|
+
let sanitized = content;
|
|
51
|
+
sanitized = sanitized.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
|
|
52
|
+
sanitized = sanitized.replace(/javascript:/gi, "removed:");
|
|
53
|
+
sanitized = sanitized.replace(/vbscript:/gi, "removed:");
|
|
54
|
+
sanitized = sanitized.replace(/\bon\w+\s*=\s*["'][^"']*["']/gi, "");
|
|
55
|
+
sanitized = sanitized.replace(/\bon\w+\s*=\s*\S+/gi, "");
|
|
56
|
+
return sanitized;
|
|
57
|
+
}
|
|
58
|
+
function parseMarkdownV3(content, options = {}) {
|
|
59
|
+
const { maxLength = DEFAULT_MAX_LENGTH, sanitize = true, allowEmpty = false } = options;
|
|
60
|
+
if (content === null || content === void 0) {
|
|
61
|
+
return err(
|
|
62
|
+
createParseError(
|
|
63
|
+
ParseErrorCode.INVALID_INPUT,
|
|
64
|
+
`Content must be a string, received ${content === null ? "null" : "undefined"}`
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (typeof content !== "string") {
|
|
69
|
+
return err(
|
|
70
|
+
createParseError(
|
|
71
|
+
ParseErrorCode.INVALID_INPUT,
|
|
72
|
+
`Content must be a string, received ${typeof content}`
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const trimmed = content.trim();
|
|
77
|
+
if (trimmed.length === 0 && !allowEmpty) {
|
|
78
|
+
return err(
|
|
79
|
+
createParseError(ParseErrorCode.EMPTY_CONTENT, "Content is empty or contains only whitespace")
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (content.length > maxLength) {
|
|
83
|
+
return err(
|
|
84
|
+
createParseError(
|
|
85
|
+
ParseErrorCode.CONTENT_TOO_LONG,
|
|
86
|
+
`Content exceeds maximum length of ${maxLength.toLocaleString()} characters (received ${content.length.toLocaleString()})`
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
const xssPattern = detectXssPattern(content);
|
|
91
|
+
if (xssPattern) {
|
|
92
|
+
if (process.env.NODE_ENV === "development") {
|
|
93
|
+
console.warn(
|
|
94
|
+
`[parseMarkdownV3] XSS pattern detected: ${xssPattern.toString()}`,
|
|
95
|
+
sanitize ? "Content will be sanitized." : "Sanitization is disabled!"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const processedContent = sanitize ? sanitizeContent(content) : content;
|
|
100
|
+
try {
|
|
101
|
+
const ast = mdToJSON(processedContent);
|
|
102
|
+
return ok(ast);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
105
|
+
return err(
|
|
106
|
+
createParseError(
|
|
107
|
+
ParseErrorCode.PARSE_FAILED,
|
|
108
|
+
`Failed to parse markdown: ${cause.message}`,
|
|
109
|
+
cause
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var parseMarkdown = parseMarkdownV3;
|
|
115
|
+
function isSafeMarkdown(content) {
|
|
116
|
+
return detectXssPattern(content) === null;
|
|
117
|
+
}
|
|
118
|
+
function estimateWordCount(content) {
|
|
119
|
+
const plainText = content.replace(/#+\s/g, "").replace(/\*\*|__|~~|`/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/!\[([^\]]*)\]\([^)]+\)/g, "").replace(/```[\s\S]*?```/g, "").replace(/`[^`]+`/g, "");
|
|
120
|
+
const words = plainText.trim().split(/\s+/).filter(Boolean);
|
|
121
|
+
return words.length;
|
|
122
|
+
}
|
|
123
|
+
function estimateReadingTime(content, wordsPerMinute = 200) {
|
|
124
|
+
const wordCount = estimateWordCount(content);
|
|
125
|
+
return Math.ceil(wordCount / wordsPerMinute);
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
ParseErrorCode,
|
|
129
|
+
estimateReadingTime,
|
|
130
|
+
estimateWordCount,
|
|
131
|
+
isSafeMarkdown,
|
|
132
|
+
parseMarkdown,
|
|
133
|
+
parseMarkdownV1,
|
|
134
|
+
parseMarkdownV2,
|
|
135
|
+
parseMarkdownV3
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=markdown-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../lib/markdown-utils.ts"],"sourcesContent":["/**\n * Markdown Parsing Utilities\n *\n * Three implementations showing the progression from naive to production-ready:\n * - v1 (Naive): Direct call, crashes on bad input\n * - v2 (Defensive): Try-catch with null fallback\n * - v3 (Robust): Result type, validation, sanitization\n *\n * The robust version (v3) is exported as the default `parseMarkdown`.\n */\n\nimport type { MDTree } from 'md4w';\nimport { mdToJSON } from 'md4w';\n\nimport { err, ok, type Result } from './result';\n\n// -----------------------------------------------------------------------------\n// Types\n// -----------------------------------------------------------------------------\n\n/**\n * Error codes for markdown parsing failures.\n */\nexport const ParseErrorCode = {\n INVALID_INPUT: 'INVALID_INPUT',\n EMPTY_CONTENT: 'EMPTY_CONTENT',\n PARSE_FAILED: 'PARSE_FAILED',\n CONTENT_TOO_LONG: 'CONTENT_TOO_LONG',\n NESTED_TOO_DEEP: 'NESTED_TOO_DEEP',\n} as const;\n\nexport type ParseErrorCode = (typeof ParseErrorCode)[keyof typeof ParseErrorCode];\n\n/**\n * Structured error for markdown parsing failures.\n */\nexport interface ParseError {\n code: ParseErrorCode;\n message: string;\n cause?: Error;\n}\n\n/**\n * Options for robust markdown parsing.\n */\nexport interface ParseOptions {\n /**\n * Maximum content length in characters.\n * @default 500000 (500KB of text, ~100K words)\n */\n maxLength?: number;\n\n /**\n * Whether to sanitize XSS attempts in the output.\n * @default true\n */\n sanitize?: boolean;\n\n /**\n * Whether to allow empty content.\n * @default false\n */\n allowEmpty?: boolean;\n}\n\n// -----------------------------------------------------------------------------\n// Constants\n// -----------------------------------------------------------------------------\n\nconst DEFAULT_MAX_LENGTH = 500_000; // 500KB of text\n\n/**\n * Patterns that indicate potential XSS attempts in markdown.\n * These are checked in raw content before parsing.\n */\nconst XSS_PATTERNS = [\n /<script\\b/i,\n /javascript:/i,\n /on\\w+\\s*=/i, // onclick=, onerror=, etc.\n /data:/i, // data: URIs can be dangerous\n /vbscript:/i,\n] as const;\n\n// -----------------------------------------------------------------------------\n// V1: Naive Implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Naive markdown parser - crashes on bad input.\n *\n * DO NOT USE IN PRODUCTION. This is for demonstration only.\n *\n * Problems:\n * - No input validation\n * - No error handling\n * - Will crash the entire app on malformed input\n * - No protection against XSS\n * - No content limits\n *\n * @example\n * ```ts\n * // This crashes if content is null, undefined, or malformed\n * const ast = parseMarkdownV1(userInput);\n * ```\n */\nexport function parseMarkdownV1(content: string): MDTree {\n return mdToJSON(content);\n}\n\n// -----------------------------------------------------------------------------\n// V2: Defensive Implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Defensive markdown parser - catches errors but loses context.\n *\n * Better than v1 but still problematic:\n * - Returns null on any error (loses error details)\n * - Caller can't distinguish between empty content and parse failure\n * - Still no XSS protection\n * - Still no content limits\n *\n * @example\n * ```ts\n * const ast = parseMarkdownV2(userInput);\n * if (!ast) {\n * // What went wrong? We don't know.\n * return <ErrorFallback />;\n * }\n * ```\n */\nexport function parseMarkdownV2(content: string): MDTree | null {\n try {\n // Basic null check\n if (content == null) {\n return null;\n }\n return mdToJSON(content);\n } catch {\n return null;\n }\n}\n\n// -----------------------------------------------------------------------------\n// V3: Robust Implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Creates a ParseError with the given code and message.\n */\nfunction createParseError(code: ParseErrorCode, message: string, cause?: Error): ParseError {\n return { code, message, cause };\n}\n\n/**\n * Checks content for potential XSS patterns.\n * Returns the first matched pattern or null if clean.\n */\nfunction detectXssPattern(content: string): RegExp | null {\n for (const pattern of XSS_PATTERNS) {\n if (pattern.test(content)) {\n return pattern;\n }\n }\n return null;\n}\n\n/**\n * Sanitizes content by removing dangerous patterns.\n * This is a basic sanitizer; production should use DOMPurify.\n */\nfunction sanitizeContent(content: string): string {\n let sanitized = content;\n\n // Remove script tags\n sanitized = sanitized.replace(/<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi, '');\n\n // Remove javascript: and vbscript: URLs\n sanitized = sanitized.replace(/javascript:/gi, 'removed:');\n sanitized = sanitized.replace(/vbscript:/gi, 'removed:');\n\n // Remove event handlers (onclick, onerror, etc.)\n sanitized = sanitized.replace(/\\bon\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi, '');\n sanitized = sanitized.replace(/\\bon\\w+\\s*=\\s*\\S+/gi, '');\n\n return sanitized;\n}\n\n/**\n * Robust markdown parser - production-ready with full error context.\n *\n * Features:\n * - Input validation with specific error codes\n * - Result type for explicit error handling\n * - XSS pattern detection and optional sanitization\n * - Content length limits\n * - Preserves error context for debugging\n *\n * @param content - Markdown string to parse\n * @param options - Parsing options\n * @returns Result containing the AST or a structured error\n *\n * @example\n * ```ts\n * const result = parseMarkdownV3(userInput);\n *\n * if (!result.ok) {\n * switch (result.error.code) {\n * case 'INVALID_INPUT':\n * return <InvalidInputError message={result.error.message} />;\n * case 'CONTENT_TOO_LONG':\n * return <ContentTooLongError />;\n * case 'PARSE_FAILED':\n * console.error('Parse error:', result.error.cause);\n * return <ParseError />;\n * default:\n * return <GenericError />;\n * }\n * }\n *\n * return <MarkdownRenderer ast={result.value} />;\n * ```\n */\nexport function parseMarkdownV3(\n content: string,\n options: ParseOptions = {}\n): Result<MDTree, ParseError> {\n const { maxLength = DEFAULT_MAX_LENGTH, sanitize = true, allowEmpty = false } = options;\n\n // 1. Validate input type\n if (content === null || content === undefined) {\n return err(\n createParseError(\n ParseErrorCode.INVALID_INPUT,\n `Content must be a string, received ${content === null ? 'null' : 'undefined'}`\n )\n );\n }\n\n if (typeof content !== 'string') {\n return err(\n createParseError(\n ParseErrorCode.INVALID_INPUT,\n `Content must be a string, received ${typeof content}`\n )\n );\n }\n\n // 2. Handle empty content\n const trimmed = content.trim();\n if (trimmed.length === 0 && !allowEmpty) {\n return err(\n createParseError(ParseErrorCode.EMPTY_CONTENT, 'Content is empty or contains only whitespace')\n );\n }\n\n // 3. Check content length\n if (content.length > maxLength) {\n return err(\n createParseError(\n ParseErrorCode.CONTENT_TOO_LONG,\n `Content exceeds maximum length of ${maxLength.toLocaleString()} characters ` +\n `(received ${content.length.toLocaleString()})`\n )\n );\n }\n\n // 4. Check for XSS patterns\n const xssPattern = detectXssPattern(content);\n if (xssPattern) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `[parseMarkdownV3] XSS pattern detected: ${xssPattern.toString()}`,\n sanitize ? 'Content will be sanitized.' : 'Sanitization is disabled!'\n );\n }\n }\n\n // 5. Optionally sanitize content\n const processedContent = sanitize ? sanitizeContent(content) : content;\n\n // 6. Parse markdown with error handling\n try {\n const ast = mdToJSON(processedContent);\n return ok(ast);\n } catch (error) {\n const cause = error instanceof Error ? error : new Error(String(error));\n return err(\n createParseError(\n ParseErrorCode.PARSE_FAILED,\n `Failed to parse markdown: ${cause.message}`,\n cause\n )\n );\n }\n}\n\n// -----------------------------------------------------------------------------\n// Default Export\n// -----------------------------------------------------------------------------\n\n/**\n * Production-ready markdown parser.\n *\n * This is an alias for `parseMarkdownV3` - the robust implementation\n * with validation, sanitization, and Result-based error handling.\n *\n * @example\n * ```ts\n * import { parseMarkdown } from '@/lib/markdown-utils';\n *\n * const result = parseMarkdown(content);\n * if (!result.ok) {\n * // Handle error with full context\n * console.error(`[${result.error.code}] ${result.error.message}`);\n * return null;\n * }\n * return result.value;\n * ```\n */\nexport const parseMarkdown = parseMarkdownV3;\n\n// -----------------------------------------------------------------------------\n// Utility Functions\n// -----------------------------------------------------------------------------\n\n/**\n * Checks if content is safe markdown (no XSS patterns detected).\n *\n * @param content - Markdown string to check\n * @returns true if no XSS patterns detected\n */\nexport function isSafeMarkdown(content: string): boolean {\n return detectXssPattern(content) === null;\n}\n\n/**\n * Estimates the word count of markdown content.\n * Useful for content length limits and reading time estimates.\n *\n * @param content - Markdown string to count\n * @returns Estimated word count\n */\nexport function estimateWordCount(content: string): number {\n // Remove markdown syntax for more accurate count\n const plainText = content\n .replace(/#+\\s/g, '') // Remove headings\n .replace(/\\*\\*|__|~~|`/g, '') // Remove formatting\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1') // Convert links to text\n .replace(/!\\[([^\\]]*)\\]\\([^)]+\\)/g, '') // Remove images\n .replace(/```[\\s\\S]*?```/g, '') // Remove code blocks\n .replace(/`[^`]+`/g, ''); // Remove inline code\n\n const words = plainText.trim().split(/\\s+/).filter(Boolean);\n return words.length;\n}\n\n/**\n * Estimates reading time for markdown content.\n *\n * @param content - Markdown string\n * @param wordsPerMinute - Reading speed (default 200 WPM)\n * @returns Reading time in minutes\n */\nexport function estimateReadingTime(content: string, wordsPerMinute = 200): number {\n const wordCount = estimateWordCount(content);\n return Math.ceil(wordCount / wordsPerMinute);\n}\n"],"mappings":";;;;;;AAYA,SAAS,gBAAgB;AAWlB,IAAM,iBAAiB;AAAA,EAC5B,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;AAwCA,IAAM,qBAAqB;AAM3B,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AACF;AAwBO,SAAS,gBAAgB,SAAyB;AACvD,SAAO,SAAS,OAAO;AACzB;AAwBO,SAAS,gBAAgB,SAAgC;AAC9D,MAAI;AAEF,QAAI,WAAW,MAAM;AACnB,aAAO;AAAA,IACT;AACA,W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Ae,CAAC;AAAA,MAChD;AAAA,IACF;AAAA,EACF;AAGA,QAAM,aAAa,iBAAiB,OAAO;AAC3C,MAAI,YAAY;AACd,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,cAAQ;AAAA,QACN,2CAA2C,WAAW,SAAS,CAAC;AAAA,QAChE,WAAW,+BAA+B;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AAGA,QAAM,mBAAmB,WAAW,gBAAgB,OAAO,IAAI;AAG/D,MAAI;AACF,UAAM,MAAM,SAAS,gBAAgB;AACrC,WAAO,GAAG,GAAG;AAAA,EACf,SAAS,OAAO;AACd,UAAM,QAAQ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACtE,WAAO;AAAA,MACL;AAAA,QACE,eAAe;AAAA,QACf,6BAA6B,MAAM,OAAO;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAyBO,IAAM,gBAAgB;AAYtB,SAAS,eAAe,SAA0B;AACvD,SAAO,iBAAiB,OAAO,MAAM;AACvC;AASO,SAAS,kBAAkB,SAAyB;AAEzD,QAAM,YAAY,QACf,QAAQ,SAAS,EAAE,EACnB,QAAQ,iBAAiB,EAAE,EAC3B,QAAQ,0BAA0B,IAAI,EACtC,QAAQ,2BAA2B,EAAE,EACrC,QAAQ,mBAAmB,EAAE,EAC7B,QAAQ,YAAY,EAAE;AAEzB,QAAM,QAAQ,UAAU,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO;AAC1D,SAAO,MAAM;AACf;AASO,SAAS,oBAAoB,SAAiB,iBAAiB,KAAa;AACjF,QAAM,YAAY,kBAAkB,OAAO;AAC3C,SAAO,KAAK,KAAK,YAAY,cAAc;AAC7C;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Metadata } from 'next';
|
|
3
|
+
import { BlockComponentRegistry } from './types.js';
|
|
4
|
+
import '@repo/cms-schema/blocks';
|
|
5
|
+
|
|
6
|
+
type PageProps = {
|
|
7
|
+
params: Promise<{
|
|
8
|
+
slug: string[];
|
|
9
|
+
}>;
|
|
10
|
+
registry?: Partial<BlockComponentRegistry>;
|
|
11
|
+
/** API key for CMS API authentication */
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Force dynamic rendering to ensure routes are always fresh.
|
|
16
|
+
* This prevents Next.js from caching pages when routes are published.
|
|
17
|
+
*/
|
|
18
|
+
declare const dynamic = "force-dynamic";
|
|
19
|
+
/**
|
|
20
|
+
* Catch-all route handler for parametric routes.
|
|
21
|
+
*
|
|
22
|
+
* Handles paths like:
|
|
23
|
+
* - /us/en/products -> slug = ['us', 'en', 'products']
|
|
24
|
+
* - /about -> slug = ['about']
|
|
25
|
+
*
|
|
26
|
+
* Reconstructs the full path and fetches route via tRPC.
|
|
27
|
+
*/
|
|
28
|
+
declare function ParametricRoutePage({ params, registry, apiKey }: PageProps): Promise<react.JSX.Element>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate metadata for the page.
|
|
31
|
+
* Uses Next.js 15+ async params pattern.
|
|
32
|
+
*/
|
|
33
|
+
declare function generateMetadata({ params, apiKey }: PageProps): Promise<Metadata>;
|
|
34
|
+
declare function normalizePath(path: string): string;
|
|
35
|
+
|
|
36
|
+
export { ParametricRoutePage as default, dynamic, generateMetadata, normalizePath };
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockRenderer
|
|
3
|
+
} from "../chunk-RPM73PQZ.js";
|
|
4
|
+
import {
|
|
5
|
+
getCmsClient
|
|
6
|
+
} from "../chunk-G22U6UHQ.js";
|
|
7
|
+
|
|
8
|
+
// ../../packages/cms-schema/src/blocks/article.ts
|
|
9
|
+
function normalizeArticleContent(payload) {
|
|
10
|
+
if (!payload || typeof payload !== "object") {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const record = payload;
|
|
14
|
+
const headline = typeof record.headline === "string" ? record.headline : null;
|
|
15
|
+
const body = typeof record.body === "string" ? record.body : null;
|
|
16
|
+
if (!headline || !body) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const author = typeof record.author === "string" ? record.author : void 0;
|
|
20
|
+
const publishedAt = typeof record.publishedAt === "string" ? record.publishedAt : void 0;
|
|
21
|
+
const tags = Array.isArray(record.tags) ? record.tags.map((tag) => String(tag)) : void 0;
|
|
22
|
+
const statusRaw = typeof record.status === "string" ? record.status.trim() : void 0;
|
|
23
|
+
return {
|
|
24
|
+
headline,
|
|
25
|
+
body,
|
|
26
|
+
author,
|
|
27
|
+
publishedAt,
|
|
28
|
+
tags,
|
|
29
|
+
status: statusRaw || void 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function isArticlePublished(article) {
|
|
33
|
+
const now = /* @__PURE__ */ new Date();
|
|
34
|
+
const publishedAt = article.publishedAt ? new Date(article.publishedAt) : null;
|
|
35
|
+
return article.status === "published" && publishedAt !== null && !Number.isNaN(publishedAt.getTime()) && publishedAt <= now;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ../../packages/cms-schema/src/validation/image.ts
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
var ALLOWED_MIME_TYPES = ["image/jpeg", "image/png", "image/webp"];
|
|
41
|
+
var MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
42
|
+
var MIN_FILE_SIZE = 1024;
|
|
43
|
+
var MAX_DIMENSION = 8192;
|
|
44
|
+
var MIN_DIMENSION = 10;
|
|
45
|
+
var MimeTypeSchema = z.enum(ALLOWED_MIME_TYPES);
|
|
46
|
+
var FileSizeSchema = z.number().int().min(MIN_FILE_SIZE, `File too small. Minimum: ${MIN_FILE_SIZE} bytes`).max(MAX_FILE_SIZE, `File too large. Maximum: ${MAX_FILE_SIZE / 1024 / 1024}MB`);
|
|
47
|
+
var DimensionSchema = z.number().int().min(MIN_DIMENSION, `Dimension too small. Minimum: ${MIN_DIMENSION}px`).max(MAX_DIMENSION, `Dimension too large. Maximum: ${MAX_DIMENSION}px`);
|
|
48
|
+
var UploadRequestSchema = z.object({
|
|
49
|
+
filename: z.string().min(1, "Filename is required").max(255, "Filename too long").regex(/^[^<>:"/\\|?*]+$/, "Filename contains invalid characters"),
|
|
50
|
+
mimeType: MimeTypeSchema,
|
|
51
|
+
fileSize: FileSizeSchema
|
|
52
|
+
});
|
|
53
|
+
var ConfirmUploadSchema = z.object({
|
|
54
|
+
assetId: z.uuid().optional(),
|
|
55
|
+
width: DimensionSchema,
|
|
56
|
+
height: DimensionSchema
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ../../packages/cms-schema/src/blocks/schemas/article-block.ts
|
|
60
|
+
import { z as z2 } from "zod";
|
|
61
|
+
var ArticleBlockContentSchema = z2.object({
|
|
62
|
+
headline: z2.string().min(1, "Article headline is required").max(300, "Headline too long").trim(),
|
|
63
|
+
author: z2.string().max(100, "Article author too long").trim().optional(),
|
|
64
|
+
publishedAt: z2.iso.datetime({ message: "Article publishedAt must be a valid ISO 8601 datetime string." }).optional(),
|
|
65
|
+
body: z2.string().min(1, "Article body content is required"),
|
|
66
|
+
tags: z2.array(z2.string()).optional(),
|
|
67
|
+
status: z2.enum(["draft", "review", "published"])
|
|
68
|
+
});
|
|
69
|
+
var ARTICLE_BLOCK_SCHEMA_NAME = "article";
|
|
70
|
+
|
|
71
|
+
// ../../packages/cms-schema/src/blocks/schemas/cta-block.ts
|
|
72
|
+
import { z as z3 } from "zod";
|
|
73
|
+
var CTAButtonSchema = z3.object({
|
|
74
|
+
text: z3.string().min(1, "Button text is required").max(50, "Button text too long"),
|
|
75
|
+
url: z3.string().refine(
|
|
76
|
+
(val) => {
|
|
77
|
+
if (val.startsWith("http://") || val.startsWith("https://")) {
|
|
78
|
+
try {
|
|
79
|
+
new URL(val);
|
|
80
|
+
return true;
|
|
81
|
+
} catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (val.startsWith("/")) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (val.startsWith("#")) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
message: "URL must be a valid full URL (http://... or https://...), relative path (/path), or anchor (#anchor)"
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
});
|
|
98
|
+
var CTABlockContentSchema = z3.object({
|
|
99
|
+
headline: z3.string().min(1, "Headline is required").max(100, "Headline too long"),
|
|
100
|
+
description: z3.string().max(500, "Description too long").optional(),
|
|
101
|
+
primaryButton: CTAButtonSchema,
|
|
102
|
+
secondaryButton: CTAButtonSchema.optional()
|
|
103
|
+
});
|
|
104
|
+
var CTA_BLOCK_SCHEMA_NAME = "cta-block";
|
|
105
|
+
|
|
106
|
+
// ../../packages/cms-schema/src/blocks/schemas/features-block.ts
|
|
107
|
+
import { z as z4 } from "zod";
|
|
108
|
+
var FeaturesLayout = ["grid", "list", "carousel"];
|
|
109
|
+
var FeatureItemSchema = z4.object({
|
|
110
|
+
icon: z4.string().max(50, "Icon name too long").optional(),
|
|
111
|
+
title: z4.string().min(1, "Title is required").max(100, "Title too long"),
|
|
112
|
+
description: z4.string().max(500, "Description too long").optional()
|
|
113
|
+
});
|
|
114
|
+
var FeaturesBlockContentSchema = z4.object({
|
|
115
|
+
title: z4.string().min(1, "Section title is required").max(100, "Title too long"),
|
|
116
|
+
subtitle: z4.string().max(200, "Subtitle too long").optional(),
|
|
117
|
+
features: z4.array(FeatureItemSchema).min(1, "At least one feature is required").max(6, "Maximum 6 features allowed"),
|
|
118
|
+
layout: z4.enum(FeaturesLayout).default("grid")
|
|
119
|
+
});
|
|
120
|
+
var FEATURES_BLOCK_SCHEMA_NAME = "features-block";
|
|
121
|
+
|
|
122
|
+
// ../../packages/cms-schema/src/blocks/schemas/hero-block.ts
|
|
123
|
+
import { z as z6 } from "zod";
|
|
124
|
+
|
|
125
|
+
// ../../packages/cms-schema/src/fields/complex/media.ts
|
|
126
|
+
import { z as z5 } from "zod";
|
|
127
|
+
var ImageAssetSchema = z5.object({
|
|
128
|
+
/** UUID primary key */
|
|
129
|
+
id: z5.uuid(),
|
|
130
|
+
/** R2/S3 storage URL for the original file */
|
|
131
|
+
url: z5.url(),
|
|
132
|
+
/** Image width in pixels */
|
|
133
|
+
width: DimensionSchema,
|
|
134
|
+
/** Image height in pixels */
|
|
135
|
+
height: DimensionSchema,
|
|
136
|
+
/** Original filename from upload */
|
|
137
|
+
originalFilename: z5.string().min(1).max(255),
|
|
138
|
+
/** MIME type (only web-safe formats allowed) */
|
|
139
|
+
mimeType: MimeTypeSchema,
|
|
140
|
+
/** File size in bytes */
|
|
141
|
+
fileSize: FileSizeSchema,
|
|
142
|
+
/** Base64-encoded tiny preview for blur-up loading */
|
|
143
|
+
lqip: z5.string().optional()
|
|
144
|
+
});
|
|
145
|
+
var HotspotSchema = z5.object({
|
|
146
|
+
x: z5.number().min(0).max(1),
|
|
147
|
+
y: z5.number().min(0).max(1)
|
|
148
|
+
});
|
|
149
|
+
var CropSchema = z5.object({
|
|
150
|
+
/** X coordinate of top-left corner in pixels */
|
|
151
|
+
x: z5.number().int().nonnegative(),
|
|
152
|
+
/** Y coordinate of top-left corner in pixels */
|
|
153
|
+
y: z5.number().int().nonnegative(),
|
|
154
|
+
/** Width of crop region in pixels (must be > 0) */
|
|
155
|
+
width: z5.number().int().positive(),
|
|
156
|
+
/** Height of crop region in pixels (must be > 0) */
|
|
157
|
+
height: z5.number().int().positive()
|
|
158
|
+
});
|
|
159
|
+
var ImageReferenceSchema = z5.object({
|
|
160
|
+
// Alt text is REQUIRED for accessibility
|
|
161
|
+
alt: z5.string().min(1, "Alt text is required for accessibility"),
|
|
162
|
+
// Optional metadata
|
|
163
|
+
caption: z5.string().max(500).optional(),
|
|
164
|
+
attribution: z5.string().max(255).optional(),
|
|
165
|
+
// Reference to the ImageAsset with stored transformation
|
|
166
|
+
_asset: z5.object({
|
|
167
|
+
id: z5.uuid(),
|
|
168
|
+
transformation: z5.string().nullable().optional()
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
var fileSchema = z5.object({
|
|
172
|
+
url: z5.url(),
|
|
173
|
+
name: z5.string(),
|
|
174
|
+
size: z5.number().int().positive(),
|
|
175
|
+
type: z5.string()
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// ../../packages/cms-schema/src/blocks/schemas/hero-block.ts
|
|
179
|
+
var HeroAlignment = ["left", "center", "right"];
|
|
180
|
+
var HeroBlockContentSchema = z6.object({
|
|
181
|
+
headline: z6.string().min(1, "Headline is required").max(100, "Headline too long"),
|
|
182
|
+
subheadline: z6.string().max(200, "Subheadline too long").optional(),
|
|
183
|
+
ctaText: z6.string().max(50, "CTA text too long").optional(),
|
|
184
|
+
ctaUrl: z6.string().refine(
|
|
185
|
+
(val) => {
|
|
186
|
+
if (val === "") return true;
|
|
187
|
+
if (val.startsWith("http://") || val.startsWith("https://")) {
|
|
188
|
+
try {
|
|
189
|
+
new URL(val);
|
|
190
|
+
return true;
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (val.startsWith("/")) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (val.startsWith("#")) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
message: "URL must be a valid full URL (http://... or https://...), relative path (/path), anchor (#anchor), or empty string"
|
|
205
|
+
}
|
|
206
|
+
).optional().or(z6.literal("")),
|
|
207
|
+
backgroundImage: ImageReferenceSchema.optional(),
|
|
208
|
+
alignment: z6.enum(HeroAlignment).default("center")
|
|
209
|
+
});
|
|
210
|
+
var HERO_BLOCK_SCHEMA_NAME = "hero-block";
|
|
211
|
+
|
|
212
|
+
// ../../packages/cms-schema/src/blocks/schemas/logo-trust-block.ts
|
|
213
|
+
import { z as z7 } from "zod";
|
|
214
|
+
var LogoItemSchema = z7.object({
|
|
215
|
+
/** Unique ID for this logo item */
|
|
216
|
+
id: z7.uuid(),
|
|
217
|
+
/** Image reference (alt + _asset with transformation) */
|
|
218
|
+
image: ImageReferenceSchema,
|
|
219
|
+
/** Optional company/brand name to display */
|
|
220
|
+
name: z7.string().max(100, "Name too long").optional()
|
|
221
|
+
});
|
|
222
|
+
var LegacyLogoItemSchema = z7.object({
|
|
223
|
+
/** Direct URL to the logo image */
|
|
224
|
+
url: z7.string(),
|
|
225
|
+
/** Alt text for the image */
|
|
226
|
+
alt: z7.string(),
|
|
227
|
+
/** Optional company/brand name */
|
|
228
|
+
name: z7.string().optional()
|
|
229
|
+
});
|
|
230
|
+
var LogoTrustBlockContentSchema = z7.object({
|
|
231
|
+
title: z7.string().max(100, "Title too long").optional(),
|
|
232
|
+
logos: z7.array(LogoItemSchema).max(20, "Maximum 20 logos allowed")
|
|
233
|
+
});
|
|
234
|
+
var LOGO_TRUST_BLOCK_SCHEMA_NAME = "logo-trust-block";
|
|
235
|
+
|
|
236
|
+
// ../../packages/cms-schema/src/blocks/registry.ts
|
|
237
|
+
var BLOCK_SCHEMA_NAMES = [
|
|
238
|
+
ARTICLE_BLOCK_SCHEMA_NAME,
|
|
239
|
+
HERO_BLOCK_SCHEMA_NAME,
|
|
240
|
+
FEATURES_BLOCK_SCHEMA_NAME,
|
|
241
|
+
CTA_BLOCK_SCHEMA_NAME,
|
|
242
|
+
LOGO_TRUST_BLOCK_SCHEMA_NAME
|
|
243
|
+
];
|
|
244
|
+
function isValidBlockSchemaName(name) {
|
|
245
|
+
return BLOCK_SCHEMA_NAMES.includes(name);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// lib/renderer.tsx
|
|
249
|
+
import { unstable_noStore } from "next/cache";
|
|
250
|
+
import { notFound } from "next/navigation";
|
|
251
|
+
import { jsx } from "react/jsx-runtime";
|
|
252
|
+
var dynamic = "force-dynamic";
|
|
253
|
+
async function ParametricRoutePage({ params, registry, apiKey }) {
|
|
254
|
+
unstable_noStore();
|
|
255
|
+
const { slug } = await params;
|
|
256
|
+
const rawPath = `/${slug.join("/")}`;
|
|
257
|
+
const path = normalizePath(rawPath);
|
|
258
|
+
const client = getCmsClient({ apiKey });
|
|
259
|
+
try {
|
|
260
|
+
const { route } = await client.route.getByPath.query({ path });
|
|
261
|
+
if (route.state !== "Live") {
|
|
262
|
+
console.error(`Route found but not Live. Path: ${path}, State: ${route.state}`);
|
|
263
|
+
notFound();
|
|
264
|
+
}
|
|
265
|
+
const blockPromises = route.block_ids.map(async (blockId) => {
|
|
266
|
+
try {
|
|
267
|
+
const result = await client.block.getById.query({ id: blockId });
|
|
268
|
+
return result.block;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.error(`Failed to fetch block ${blockId}:`, error);
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
const blockResults = await Promise.all(blockPromises);
|
|
275
|
+
const blocks = [];
|
|
276
|
+
for (const block of blockResults) {
|
|
277
|
+
if (!block || block.published_content === null) continue;
|
|
278
|
+
const content = block.published_content;
|
|
279
|
+
if (!content) continue;
|
|
280
|
+
if (block.schema_name === "article") {
|
|
281
|
+
const article = normalizeArticleContent(content);
|
|
282
|
+
const isPublished = article ? isArticlePublished(article) : null;
|
|
283
|
+
if (article && isPublished) {
|
|
284
|
+
blocks.push({ id: block.id, type: "article", content: article });
|
|
285
|
+
}
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (!isValidBlockSchemaName(block.schema_name)) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
blocks.push({
|
|
292
|
+
id: block.id,
|
|
293
|
+
type: block.schema_name,
|
|
294
|
+
content
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
return /* @__PURE__ */ jsx("main", { children: blocks.map((block) => /* @__PURE__ */ jsx(BlockRenderer, { registry: registry ?? {}, block }, block.id)) });
|
|
298
|
+
} catch (error) {
|
|
299
|
+
console.error(`Route fetch error for path: ${path}`, error);
|
|
300
|
+
const errorCode = error instanceof Error && "data" in error ? error.data?.code : error instanceof Error && "code" in error ? error.code : void 0;
|
|
301
|
+
if (errorCode === "NOT_FOUND" || errorCode === "P0002") {
|
|
302
|
+
notFound();
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async function generateMetadata({ params, apiKey }) {
|
|
308
|
+
const { slug } = await params;
|
|
309
|
+
const rawPath = `/${slug.join("/")}`;
|
|
310
|
+
const path = normalizePath(rawPath);
|
|
311
|
+
const client = getCmsClient({ apiKey });
|
|
312
|
+
try {
|
|
313
|
+
const { route } = await client.route.getByPath.query({ path });
|
|
314
|
+
return {
|
|
315
|
+
title: `${route.path} | Website`,
|
|
316
|
+
description: `Content page: ${route.path}`
|
|
317
|
+
};
|
|
318
|
+
} catch {
|
|
319
|
+
return {
|
|
320
|
+
title: "Page Not Found | Website",
|
|
321
|
+
description: "The requested page could not be found."
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function normalizePath(path) {
|
|
326
|
+
if (!path || path === "/") {
|
|
327
|
+
return "/";
|
|
328
|
+
}
|
|
329
|
+
let normalized = path.trim();
|
|
330
|
+
normalized = normalized.replace(/\/+$/, "");
|
|
331
|
+
if (!normalized.startsWith("/")) {
|
|
332
|
+
normalized = `/${normalized}`;
|
|
333
|
+
}
|
|
334
|
+
normalized = normalized.replace(/\/+/g, "/");
|
|
335
|
+
return normalized;
|
|
336
|
+
}
|
|
337
|
+
export {
|
|
338
|
+
ParametricRoutePage as default,
|
|
339
|
+
dynamic,
|
|
340
|
+
generateMetadata,
|
|
341
|
+
normalizePath
|
|
342
|
+
};
|
|
343
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cms-schema/src/blocks/article.ts","../../../../packages/cms-schema/src/validation/image.ts","../../../../packages/cms-schema/src/blocks/schemas/article-block.ts","../../../../packages/cms-schema/src/blocks/schemas/cta-block.ts","../../../../packages/cms-schema/src/blocks/schemas/features-block.ts","../../../../packages/cms-schema/src/blocks/schemas/hero-block.ts","../../../../packages/cms-schema/src/fields/complex/media.ts","../../../../packages/cms-schema/src/blocks/schemas/logo-trust-block.ts","../../../../packages/cms-schema/src/blocks/registry.ts","../../lib/renderer.tsx"],"sourcesContent":["/**\n * Article block normalization helpers shared across CMS and website apps.\n */\n\nexport interface ArticleContent {\n headline: string;\n author?: string;\n publishedAt?: string;\n body: string;\n tags?: readonly string[];\n status?: string;\n}\n\nexport interface ArticleRow {\n id: string;\n published_content: unknown;\n}\n\nexport interface NormalizedArticleRow extends ArticleContent {\n id: string;\n tags: string[];\n status: string;\n}\n\n/**\n * Normalize article content coming from Supabase blocks.\n * Returns null when required fields are missing or invalid.\n */\nexport function normalizeArticleContent(payload: unknown): ArticleContent | null {\n if (!payload || typeof payload !== 'object') {\n return null;\n }\n\n const record = payload as Record<string, unknown>;\n const headline = typeof record.headline === 'string' ? record.headline : null;\n const body = typeof record.body === 'string' ? record.body : null;\n\n if (!headline || !body) {\n return null;\n }\n\n const author = typeof record.author === 'string' ? record.author : undefined;\n const publishedAt = typeof record.publishedAt === 'string' ? record.publishedAt : undefined;\n const tags = Array.isArray(record.tags) ? record.tags.map((tag) => String(tag)) : undefined;\n const statusRaw = typeof record.status === 'string' ? record.status.trim() : undefined;\n\n return {\n headline,\n body,\n author,\n publishedAt,\n tags,\n status: statusRaw || undefined,\n };\n}\n\n/**\n * Normalize an article block row, applying defaults for tags/status.\n */\nexport function normalizeArticleRow(row: ArticleRow): NormalizedArticleRow | null {\n const article = normalizeArticleContent(row.published_content);\n if (!article) {\n return null;\n }\n\n return {\n ...article,\n id: row.id,\n tags: article.tags ? [...article.tags] : [],\n status: article.status ?? 'published',\n };\n}\n\n/**\n * Ensure the article is published.\n */\nexport function isArticlePublished(article: ArticleContent): boolean {\n const now = new Date();\n const publishedAt = article.publishedAt ? new Date(article.publishedAt) : null;\n\n return (\n article.status === 'published' &&\n publishedAt !== null &&\n !Number.isNaN(publishedAt.getTime()) &&\n publishedAt <= now\n );\n}\n","/**\n * Image Validation Utilities\n *\n * Provides validation for:\n * - File type (MIME type checking)\n * - File size (configurable limits)\n * - Image dimensions (width/height constraints)\n */\n\nimport { z } from 'zod';\n\n// =============================================================================\n// Constants\n// =============================================================================\n\nexport const ALLOWED_MIME_TYPES = ['image/jpeg', 'image/png', 'image/webp'] as const;\nexport type ImageMimeType = (typeof ALLOWED_MIME_TYPES)[number];\n\nexport const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB\nexport const MIN_FILE_SIZE = 1024; // 1KB (avoid empty/corrupt files)\n\nexport const MAX_DIMENSION = 8192; // 8K resolution\nexport const MIN_DIMENSION = 10; // Minimum useful size\n\n// =============================================================================\n// Zod Schemas\n// =============================================================================\n\nexport const MimeTypeSchema = z.enum(ALLOWED_MIME_TYPES);\n\nexport const FileSizeSchema = z\n .number()\n .int()\n .min(MIN_FILE_SIZE, `File too small. Minimum: ${MIN_FILE_SIZE} bytes`)\n .max(MAX_FILE_SIZE, `File too large. Maximum: ${MAX_FILE_SIZE / 1024 / 1024}MB`);\n\nexport const DimensionSchema = z\n .number()\n .int()\n .min(MIN_DIMENSION, `Dimension too small. Minimum: ${MIN_DIMENSION}px`)\n .max(MAX_DIMENSION, `Dimension too large. Maximum: ${MAX_DIMENSION}px`);\n\n/**\n * Schema for upload request validation.\n */\nexport const UploadRequestSchema = z.object({\n filename: z\n .string()\n .min(1, 'Filename is required')\n .max(255, 'Filename too long')\n .regex(/^[^<>:\"/\\\\|?*]+$/, 'Filename contains invalid characters'),\n mimeType: MimeTypeSchema,\n fileSize: FileSizeSchema,\n});\n\nexport type UploadRequest = z.infer<typeof UploadRequestSchema>;\n\n/**\n * Schema for confirming upload with dimensions.\n * assetId is optional - if not provided, the server will generate a UUID.\n */\nexport const ConfirmUploadSchema = z.object({\n assetId: z.uuid().optional(),\n width: DimensionSchema,\n height: DimensionSchema,\n});\n\nexport type ConfirmUpload = z.infer<typeof ConfirmUploadSchema>;\n\n// =============================================================================\n// Validation Functions\n// =============================================================================\n\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n}\n\n/**\n * Validate file type by MIME type.\n */\nexport function validateMimeType(mimeType: string): ValidationResult {\n const result = MimeTypeSchema.safeParse(mimeType);\n if (result.success) {\n return { valid: true };\n }\n return {\n valid: false,\n error: `File type not supported. Use JPEG, PNG, or WebP.`,\n };\n}\n\n/**\n * Validate file size.\n */\nexport function validateFileSize(size: number): ValidationResult {\n if (size < MIN_FILE_SIZE) {\n return {\n valid: false,\n error: `File appears to be empty or corrupt.`,\n };\n }\n if (size > MAX_FILE_SIZE) {\n const sizeMB = (size / 1024 / 1024).toFixed(1);\n return {\n valid: false,\n error: `File too large (${sizeMB}MB). Maximum: 10 MB.`,\n };\n }\n return { valid: true };\n}\n\n/**\n * Validate image dimensions.\n */\nexport function validateDimensions(width: number, height: number): ValidationResult {\n if (width < MIN_DIMENSION || height < MIN_DIMENSION) {\n return {\n valid: false,\n error: `Image too small. Minimum: ${MIN_DIMENSION}x${MIN_DIMENSION}px.`,\n };\n }\n if (width > MAX_DIMENSION || height > MAX_DIMENSION) {\n return {\n valid: false,\n error: `Image too large. Maximum: ${MAX_DIMENSION}x${MAX_DIMENSION}px.`,\n };\n }\n return { valid: true };\n}\n\n/**\n * Validate complete upload request.\n */\nexport function validateUploadRequest(\n request: unknown\n): { valid: true; data: UploadRequest } | { valid: false; error: string } {\n const result = UploadRequestSchema.safeParse(request);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n const firstIssue = result.error.issues[0];\n return {\n valid: false,\n error: firstIssue?.message ?? 'Invalid upload request',\n };\n}\n\n// =============================================================================\n// File Extension Utilities\n// =============================================================================\n\nconst MIME_TO_EXT: Record<ImageMimeType, string> = {\n 'image/jpeg': 'jpg',\n 'image/png': 'png',\n 'image/webp': 'webp',\n};\n\nconst EXT_TO_MIME: Record<string, ImageMimeType> = {\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n png: 'image/png',\n webp: 'image/webp',\n};\n\n/**\n * Get file extension from MIME type.\n */\nexport function getExtensionFromMime(mimeType: ImageMimeType | string): string {\n return MIME_TO_EXT[mimeType as ImageMimeType] ?? 'bin';\n}\n\n/**\n * Get MIME type from file extension.\n */\nexport function getMimeFromExtension(ext: string): ImageMimeType | undefined {\n return EXT_TO_MIME[ext.toLowerCase()];\n}\n\n/**\n * Extract extension from filename.\n */\nexport function getExtensionFromFilename(filename: string): string {\n const parts = filename.split('.');\n return parts.pop()?.toLowerCase?.() ?? '';\n}\n\n/**\n * Sanitize filename for storage.\n * Removes special characters, preserves extension.\n */\nexport function sanitizeFilename(filename: string): string {\n // Get extension\n const ext = getExtensionFromFilename(filename);\n\n // Get base name without extension\n const base = filename.slice(0, filename.length - ext.length - 1);\n\n // Sanitize: lowercase, replace spaces and special chars\n const sanitized = base\n .toLowerCase()\n .replace(/[^a-z0-9]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n .slice(0, 50); // Limit length\n\n return ext ? `${sanitized}.${ext}` : sanitized;\n}\n","/**\n * ArticleBlock Schema.\n *\n * Defines the structure and validation for ArticleBlock content.\n *\n * ArticleBlock represents a block of content focused on articles,\n * including fields such as headline, author, publication date, body content, tags, and status.\n *\n * Includes:\n * - Zod schema for validation\n * - TypeScript type inference\n * - Default values\n * - Validation function\n * - Function to create default content\n */\nimport { z } from 'zod';\n\n// Article block content schema with validation rules\nexport const ArticleBlockContentSchema = z.object({\n headline: z.string().min(1, 'Article headline is required').max(300, 'Headline too long').trim(),\n author: z.string().max(100, 'Article author too long').trim().optional(),\n publishedAt: z.iso\n .datetime({ message: 'Article publishedAt must be a valid ISO 8601 datetime string.' })\n .optional(),\n body: z.string().min(1, 'Article body content is required'),\n tags: z.array(z.string()).optional(),\n status: z.enum(['draft', 'review', 'published']),\n});\n\n// Inferred type for components\nexport type ArticleBlockContent = z.infer<typeof ArticleBlockContentSchema>;\n\n// Schema name constant\nexport const ARTICLE_BLOCK_SCHEMA_NAME = 'article';\n\n// Default values for a new ArticleBlock\nexport const ArticleBlockDefaults: Partial<ArticleBlockContent> = {\n status: 'draft',\n};\n\n// Validate ArticleBlock content\nexport function validateArticleBlockContent(content: unknown): {\n valid: boolean;\n data?: ArticleBlockContent;\n errors?: z.ZodError;\n} {\n const result = ArticleBlockContentSchema.safeParse(content);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n return { valid: false, errors: result.error };\n}\n\n// Create default ArticleBlock content\nexport function createDefaultArticleContent(): ArticleBlockContent {\n return {\n headline: 'untitled article',\n author: '',\n publishedAt: new Date().toISOString(),\n body: '',\n tags: [],\n status: 'draft',\n };\n}\n","/**\n * CTABlock Schema.\n *\n * A call-to-action section with headline, description, and action buttons.\n * Supports primary and optional secondary CTA buttons.\n */\n\nimport { z } from 'zod';\n\n// CTA button schema\n// URL can be either a full URL (http://...) or a relative path (/path)\nconst CTAButtonSchema = z.object({\n text: z.string().min(1, 'Button text is required').max(50, 'Button text too long'),\n url: z.string().refine(\n (val) => {\n // Accept full URLs\n if (val.startsWith('http://') || val.startsWith('https://')) {\n try {\n new URL(val);\n return true;\n } catch {\n return false;\n }\n }\n // Accept relative paths starting with /\n if (val.startsWith('/')) {\n return true;\n }\n // Accept hash/anchor links\n if (val.startsWith('#')) {\n return true;\n }\n return false;\n },\n {\n message:\n 'URL must be a valid full URL (http://... or https://...), relative path (/path), or anchor (#anchor)',\n }\n ),\n});\n\nexport type CTAButton = z.infer<typeof CTAButtonSchema>;\n\n// CTABlock content schema with validation rules\nexport const CTABlockContentSchema = z.object({\n headline: z.string().min(1, 'Headline is required').max(100, 'Headline too long'),\n description: z.string().max(500, 'Description too long').optional(),\n primaryButton: CTAButtonSchema,\n secondaryButton: CTAButtonSchema.optional(),\n});\n\n// Inferred type for components\nexport type CTABlockContent = z.infer<typeof CTABlockContentSchema>;\n\n// Schema name constant\nexport const CTA_BLOCK_SCHEMA_NAME = 'cta-block';\n\n// Default values for a new CTABlock\nexport const CTABlockDefaults: Partial<CTABlockContent> = {\n primaryButton: {\n text: 'Get Started',\n url: '#',\n },\n};\n\n// Validate CTABlock content\nexport function validateCTABlockContent(content: unknown): {\n valid: boolean;\n data?: CTABlockContent;\n errors?: z.ZodError;\n} {\n const result = CTABlockContentSchema.safeParse(content);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n return { valid: false, errors: result.error };\n}\n\n// Create default CTABlock content\nexport function createDefaultCTAContent(): CTABlockContent {\n return {\n headline: '',\n description: undefined,\n primaryButton: {\n text: 'Get Started',\n url: '#',\n },\n secondaryButton: undefined,\n };\n}\n","/**\n * FeaturesBlock Schema.\n *\n * A section displaying a list of features with icons, titles, and descriptions.\n * Supports different layouts (grid, list, carousel).\n */\n\nimport { z } from 'zod';\n\n// Layout options for features display\nexport const FeaturesLayout = ['grid', 'list', 'carousel'] as const;\nexport type FeaturesLayoutType = (typeof FeaturesLayout)[number];\n\n// Single feature item schema\nexport const FeatureItemSchema = z.object({\n icon: z.string().max(50, 'Icon name too long').optional(),\n title: z.string().min(1, 'Title is required').max(100, 'Title too long'),\n description: z.string().max(500, 'Description too long').optional(),\n});\n\nexport type FeatureItem = z.infer<typeof FeatureItemSchema>;\n\n// FeaturesBlock content schema with array validation\nexport const FeaturesBlockContentSchema = z.object({\n title: z.string().min(1, 'Section title is required').max(100, 'Title too long'),\n subtitle: z.string().max(200, 'Subtitle too long').optional(),\n features: z\n .array(FeatureItemSchema)\n .min(1, 'At least one feature is required')\n .max(6, 'Maximum 6 features allowed'),\n layout: z.enum(FeaturesLayout).default('grid'),\n});\n\n// Inferred type for components\nexport type FeaturesBlockContent = z.infer<typeof FeaturesBlockContentSchema>;\n\n// Schema name constant\nexport const FEATURES_BLOCK_SCHEMA_NAME = 'features-block';\n\n// Default values for a new FeaturesBlock\nexport const FeaturesBlockDefaults: Partial<FeaturesBlockContent> = {\n layout: 'grid',\n features: [\n {\n icon: 'star',\n title: 'Feature Title',\n description: 'Describe this feature',\n },\n ],\n};\n\n// Validate FeaturesBlock content\nexport function validateFeaturesBlockContent(content: unknown): {\n valid: boolean;\n data?: FeaturesBlockContent;\n errors?: z.ZodError;\n} {\n const result = FeaturesBlockContentSchema.safeParse(content);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n return { valid: false, errors: result.error };\n}\n\n// Create default FeaturesBlock content\nexport function createDefaultFeaturesContent(): FeaturesBlockContent {\n return {\n title: '',\n subtitle: undefined,\n features: [],\n layout: 'grid',\n };\n}\n\n// Add a feature to the content\nexport function addFeature(\n content: FeaturesBlockContent,\n feature: FeatureItem\n): FeaturesBlockContent {\n if (content.features.length >= 6) {\n throw new Error('Maximum 6 features allowed');\n }\n return {\n ...content,\n features: [...content.features, feature],\n };\n}\n\n// Remove a feature by index\nexport function removeFeature(content: FeaturesBlockContent, index: number): FeaturesBlockContent {\n if (index < 0 || index >= content.features.length) {\n throw new Error('Invalid feature index');\n }\n if (content.features.length <= 1) {\n throw new Error('At least one feature is required');\n }\n return {\n ...content,\n features: content.features.filter((_, i) => i !== index),\n };\n}\n\n// Update a feature by index\nexport function updateFeature(\n content: FeaturesBlockContent,\n index: number,\n updates: Partial<FeatureItem>\n): FeaturesBlockContent {\n if (index < 0 || index >= content.features.length) {\n throw new Error('Invalid feature index');\n }\n return {\n ...content,\n features: content.features.map((feature, i) =>\n i === index ? { ...feature, ...updates } : feature\n ),\n };\n}\n","/**\n * HeroBlock Schema.\n *\n * A full-width hero section typically used at the top of pages.\n * Supports headline, subheadline, CTA button, background image, and alignment.\n */\n\nimport { z } from 'zod';\nimport { ImageReferenceSchema } from '../../fields/complex/media';\n\n// Alignment options for the hero content\nexport const HeroAlignment = ['left', 'center', 'right'] as const;\nexport type HeroAlignmentType = (typeof HeroAlignment)[number];\n\n// HeroBlock content schema with validation rules\nexport const HeroBlockContentSchema = z.object({\n headline: z.string().min(1, 'Headline is required').max(100, 'Headline too long'),\n subheadline: z.string().max(200, 'Subheadline too long').optional(),\n ctaText: z.string().max(50, 'CTA text too long').optional(),\n ctaUrl: z\n .string()\n .refine(\n (val) => {\n // Empty string is valid\n if (val === '') return true;\n // Accept full URLs\n if (val.startsWith('http://') || val.startsWith('https://')) {\n try {\n new URL(val);\n return true;\n } catch {\n return false;\n }\n }\n // Accept relative paths starting with /\n if (val.startsWith('/')) {\n return true;\n }\n // Accept hash/anchor links\n if (val.startsWith('#')) {\n return true;\n }\n return false;\n },\n {\n message:\n 'URL must be a valid full URL (http://... or https://...), relative path (/path), anchor (#anchor), or empty string',\n }\n )\n .optional()\n .or(z.literal('')),\n backgroundImage: ImageReferenceSchema.optional(),\n alignment: z.enum(HeroAlignment).default('center'),\n});\n\n// Inferred type for components\nexport type HeroBlockContent = z.infer<typeof HeroBlockContentSchema>;\n\n// Schema name constant\nexport const HERO_BLOCK_SCHEMA_NAME = 'hero-block';\n\n// Default values for a new HeroBlock\nexport const HeroBlockDefaults: Partial<HeroBlockContent> = {\n alignment: 'center',\n};\n\n// Validate HeroBlock content\nexport function validateHeroBlockContent(content: unknown): {\n valid: boolean;\n data?: HeroBlockContent;\n errors?: z.ZodError;\n} {\n const result = HeroBlockContentSchema.safeParse(content);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n return { valid: false, errors: result.error };\n}\n\n// Create default HeroBlock content\nexport function createDefaultHeroContent(): HeroBlockContent {\n return {\n headline: '',\n subheadline: undefined,\n ctaText: undefined,\n ctaUrl: undefined,\n backgroundImage: undefined,\n alignment: 'center',\n };\n}\n","/**\n * Image and file field factories.\n *\n * The image() factory creates an ImageReference schema that:\n * - References an ImageAsset by ID\n * - Stores context-specific alt text (required for accessibility)\n * - Supports optional hotspot (focal point) and crop settings\n */\n\nimport { z } from 'zod';\n\nimport type { FieldMeta } from '../../types';\nimport {\n DimensionSchema,\n FileSizeSchema,\n MAX_DIMENSION,\n MAX_FILE_SIZE,\n MIN_DIMENSION,\n MimeTypeSchema,\n} from '../../validation/image';\n\n// =============================================================================\n// ImageAsset Schema (Public API type)\n// =============================================================================\n\n/**\n * Public API schema for image assets.\n *\n * This is the camelCase API representation. The database uses snake_case\n * (ImageAssetRow in db/image-asset-types.ts). Conversion between formats\n * should happen at the API boundary.\n *\n * Reuses validation schemas from validation/image.ts to ensure consistency.\n */\nexport const ImageAssetSchema = z.object({\n /** UUID primary key */\n id: z.uuid(),\n /** R2/S3 storage URL for the original file */\n url: z.url(),\n /** Image width in pixels */\n width: DimensionSchema,\n /** Image height in pixels */\n height: DimensionSchema,\n /** Original filename from upload */\n originalFilename: z.string().min(1).max(255),\n /** MIME type (only web-safe formats allowed) */\n mimeType: MimeTypeSchema,\n /** File size in bytes */\n fileSize: FileSizeSchema,\n /** Base64-encoded tiny preview for blur-up loading */\n lqip: z.string().optional(),\n});\n\nexport type ImageAsset = z.infer<typeof ImageAssetSchema>;\n\n// =============================================================================\n// ImageReference Schema (Asset-reference model)\n// =============================================================================\n\n/**\n * Hotspot defines the focal point of an image.\n * Coordinates are fractions (0-1) from top-left.\n */\nexport const HotspotSchema = z.object({\n x: z.number().min(0).max(1),\n y: z.number().min(0).max(1),\n});\n\nexport type Hotspot = z.infer<typeof HotspotSchema>;\n\n/**\n * Crop defines the region to extract from the image.\n * - x, y: Top-left coordinate of the crop region in pixels\n * - width, height: Size of the crop region in pixels\n * All values are positive integers representing pixel coordinates/dimensions.\n */\nexport const CropSchema = z.object({\n /** X coordinate of top-left corner in pixels */\n x: z.number().int().nonnegative(),\n /** Y coordinate of top-left corner in pixels */\n y: z.number().int().nonnegative(),\n /** Width of crop region in pixels (must be > 0) */\n width: z.number().int().positive(),\n /** Height of crop region in pixels (must be > 0) */\n height: z.number().int().positive(),\n});\n\nexport type Crop = z.infer<typeof CropSchema>;\n\n/**\n * ImageReference is what blocks store.\n * It points to an ImageAsset and adds context-specific metadata.\n */\nexport const ImageReferenceSchema = z.object({\n // Alt text is REQUIRED for accessibility\n alt: z.string().min(1, 'Alt text is required for accessibility'),\n\n // Optional metadata\n caption: z.string().max(500).optional(),\n attribution: z.string().max(255).optional(),\n\n // Reference to the ImageAsset with stored transformation\n _asset: z.object({\n id: z.uuid(),\n transformation: z.string().nullable().optional(),\n }),\n});\n\nexport type ImageReference = z.infer<typeof ImageReferenceSchema>;\n\n// =============================================================================\n// Image Field Factory\n// =============================================================================\n\nexport interface ImageFieldOptions {\n label: string;\n description?: string;\n required?: boolean;\n accept?: string;\n maxSize?: number;\n minWidth?: number;\n minHeight?: number;\n maxWidth?: number;\n maxHeight?: number;\n aspectRatio?: number;\n}\n\n/**\n * Create an image field with metadata.\n *\n * @example\n * const featuredImage = image({\n * label: 'Featured Image',\n * required: true,\n * accept: 'image/jpeg, image/png',\n * maxSize: 5 * 1024 * 1024,\n * });\n *\n * // Type of the value:\n * // {\n * // alt: string;\n * // caption?: string;\n * // attribution?: string;\n * // _asset: { id: string; transformation?: string | null };\n * // }\n */\nexport function image(options: ImageFieldOptions) {\n const meta: FieldMeta = {\n label: options.label,\n component: 'image-uploader',\n required: options.required,\n description: options.description,\n options: {\n accept: options.accept ?? 'image/jpeg, image/png, image/webp',\n maxSize: options.maxSize ?? MAX_FILE_SIZE, // 10MB default\n minWidth: options.minWidth ?? MIN_DIMENSION,\n minHeight: options.minHeight ?? MIN_DIMENSION,\n maxWidth: options.maxWidth ?? MAX_DIMENSION,\n maxHeight: options.maxHeight ?? MAX_DIMENSION,\n aspectRatio: options.aspectRatio,\n },\n };\n\n // Use the new ImageReferenceSchema instead of URL-only\n const result = options.required ? ImageReferenceSchema : ImageReferenceSchema.optional();\n\n return result.meta(meta);\n}\n\n// =============================================================================\n// File Field\n// =============================================================================\n\nexport interface FileFieldOptions {\n label: string;\n description?: string;\n required?: boolean;\n accept?: string;\n maxSize?: number;\n}\n\nconst fileSchema = z.object({\n url: z.url(),\n name: z.string(),\n size: z.number().int().positive(),\n type: z.string(),\n});\n\n/**\n * Create a file field with metadata.\n */\nexport function file(options: FileFieldOptions) {\n const meta: FieldMeta = {\n label: options.label,\n component: 'file-uploader',\n required: options.required,\n description: options.description,\n options: {\n accept: options.accept ?? '*/*',\n maxSize: options.maxSize,\n },\n };\n\n const result = options.required ? fileSchema : fileSchema.optional();\n return result.meta(meta);\n}\n","/**\n * LogoTrustBlock Schema.\n *\n * A section displaying customer/partner logos for trust and credibility.\n * Supports an optional title and an array of logo images.\n *\n * Each logo uses ImageReference to integrate with the image manager.\n */\n\nimport { z } from 'zod';\n\nimport { ImageReferenceSchema } from '../../fields/complex/media';\n\n// Logo item schema - uses ImageReference for image manager integration\nexport const LogoItemSchema = z.object({\n /** Unique ID for this logo item */\n id: z.uuid(),\n /** Image reference (alt + _asset with transformation) */\n image: ImageReferenceSchema,\n /** Optional company/brand name to display */\n name: z.string().max(100, 'Name too long').optional(),\n});\n\nexport type LogoItem = z.infer<typeof LogoItemSchema>;\n\n/**\n * Legacy logo format schema for backwards compatibility.\n * Used for logos stored with direct URL before the ImageReference migration.\n */\nexport const LegacyLogoItemSchema = z.object({\n /** Direct URL to the logo image */\n url: z.string(),\n /** Alt text for the image */\n alt: z.string(),\n /** Optional company/brand name */\n name: z.string().optional(),\n});\n\nexport type LegacyLogoItem = z.infer<typeof LegacyLogoItemSchema>;\n\n// LogoTrustBlock content schema with validation rules\nexport const LogoTrustBlockContentSchema = z.object({\n title: z.string().max(100, 'Title too long').optional(),\n logos: z.array(LogoItemSchema).max(20, 'Maximum 20 logos allowed'),\n});\n\n// Inferred type for components\nexport type LogoTrustBlockContent = z.infer<typeof LogoTrustBlockContentSchema>;\n\n// Schema name constant\nexport const LOGO_TRUST_BLOCK_SCHEMA_NAME = 'logo-trust-block';\n\n// Default values for a new LogoTrustBlock\nexport const LogoTrustBlockDefaults: Partial<LogoTrustBlockContent> = {\n logos: [],\n};\n\n// Validate LogoTrustBlock content\nexport function validateLogoTrustBlockContent(content: unknown): {\n valid: boolean;\n data?: LogoTrustBlockContent;\n errors?: z.ZodError;\n} {\n const result = LogoTrustBlockContentSchema.safeParse(content);\n if (result.success) {\n return { valid: true, data: result.data };\n }\n return { valid: false, errors: result.error };\n}\n\n// Create default LogoTrustBlock content\nexport function createDefaultLogoTrustContent(): LogoTrustBlockContent {\n return {\n title: undefined,\n logos: [],\n };\n}\n","/**\n * Block Schema Registry.\n *\n * Centralizes registration for all block schemas.\n * Call registerAllBlockSchemas() during application initialization.\n */\n\nimport { clearSchemaRegistry, registerBlockSchema } from '../validation';\nimport { ARTICLE_BLOCK_SCHEMA_NAME, ArticleBlockContentSchema } from './schemas/article-block';\nimport { CTA_BLOCK_SCHEMA_NAME, CTABlockContentSchema } from './schemas/cta-block';\nimport { FEATURES_BLOCK_SCHEMA_NAME, FeaturesBlockContentSchema } from './schemas/features-block';\nimport { HERO_BLOCK_SCHEMA_NAME, HeroBlockContentSchema } from './schemas/hero-block';\nimport {\n LOGO_TRUST_BLOCK_SCHEMA_NAME,\n LogoTrustBlockContentSchema,\n} from './schemas/logo-trust-block';\n\n// All registered block schema names\nexport const BLOCK_SCHEMA_NAMES = [\n ARTICLE_BLOCK_SCHEMA_NAME,\n HERO_BLOCK_SCHEMA_NAME,\n FEATURES_BLOCK_SCHEMA_NAME,\n CTA_BLOCK_SCHEMA_NAME,\n LOGO_TRUST_BLOCK_SCHEMA_NAME,\n] as const;\n\n// Union type for type-safe schema name usage\nexport type BlockSchemaName = (typeof BLOCK_SCHEMA_NAMES)[number];\n\n// Register all block schemas\nexport function registerAllBlockSchemas(): void {\n registerBlockSchema(ARTICLE_BLOCK_SCHEMA_NAME, ArticleBlockContentSchema);\n registerBlockSchema(HERO_BLOCK_SCHEMA_NAME, HeroBlockContentSchema);\n registerBlockSchema(FEATURES_BLOCK_SCHEMA_NAME, FeaturesBlockContentSchema);\n registerBlockSchema(CTA_BLOCK_SCHEMA_NAME, CTABlockContentSchema);\n registerBlockSchema(LOGO_TRUST_BLOCK_SCHEMA_NAME, LogoTrustBlockContentSchema);\n}\n\n// Clear and re-register all block schemas (for testing)\nexport function resetBlockSchemas(): void {\n clearSchemaRegistry();\n registerAllBlockSchemas();\n}\n\n// Type guard for schema names\nexport function isValidBlockSchemaName(name: string): name is BlockSchemaName {\n return BLOCK_SCHEMA_NAMES.includes(name as BlockSchemaName);\n}\n","/**\n * Catch-all Route Handler for Parametric Routes\n *\n * Handles routes with multiple segments like /us/en/products.\n * Uses the CMS API to fetch and render blocks.\n */\n\nimport {\n isArticlePublished,\n isValidBlockSchemaName,\n normalizeArticleContent,\n} from '@repo/cms-schema/blocks';\nimport type { Metadata } from 'next';\nimport { unstable_noStore } from 'next/cache';\nimport { notFound } from 'next/navigation';\nimport { BlockRenderer } from './block-renderer';\nimport { getCmsClient } from './cms-api';\nimport type { BlockComponentRegistry, BlockData } from './types';\n\ntype PageProps = {\n params: Promise<{ slug: string[] }>;\n registry?: Partial<BlockComponentRegistry>;\n /** API key for CMS API authentication */\n apiKey?: string;\n};\n\n/**\n * Force dynamic rendering to ensure routes are always fresh.\n * This prevents Next.js from caching pages when routes are published.\n */\nexport const dynamic = 'force-dynamic';\n\n/**\n * Catch-all route handler for parametric routes.\n *\n * Handles paths like:\n * - /us/en/products -> slug = ['us', 'en', 'products']\n * - /about -> slug = ['about']\n *\n * Reconstructs the full path and fetches route via tRPC.\n */\nexport default async function ParametricRoutePage({ params, registry, apiKey }: PageProps) {\n // Prevent any caching - ensure we always fetch fresh route data\n unstable_noStore();\n\n const { slug } = await params;\n\n // Reconstruct full path from slug segments and normalize it\n const rawPath = `/${slug.join('/')}`;\n const path = normalizePath(rawPath);\n\n // Get CMS API client with optional API key\n const client = getCmsClient({ apiKey });\n\n try {\n // Fetch route by path via CMS API\n const { route } = await client.route.getByPath.query({ path });\n\n // Only show Live routes on public website\n if (route.state !== 'Live') {\n console.error(`Route found but not Live. Path: ${path}, State: ${route.state}`);\n notFound();\n }\n\n // Fetch all blocks by ID via CMS API (skip any that fail)\n const blockPromises = route.block_ids.map(async (blockId) => {\n try {\n const result = await client.block.getById.query({ id: blockId });\n return result.block;\n } catch (error) {\n // Log error but don't fail the entire page\n console.error(`Failed to fetch block ${blockId}:`, error);\n return null;\n }\n });\n const blockResults = await Promise.all(blockPromises);\n\n // Transform blocks to BlockData format for BlockRenderer\n // Filter out any blocks that failed to load\n const blocks: BlockData[] = [];\n\n for (const block of blockResults) {\n if (!block || block.published_content === null) continue;\n\n const content = block.published_content as Record<string, unknown> | null;\n if (!content) continue;\n\n // Handle 'article' blocks separately before checking schema type\n if (block.schema_name === 'article') {\n const article = normalizeArticleContent(content);\n const isPublished = article ? isArticlePublished(article) : null;\n if (article && isPublished) {\n blocks.push({ id: block.id, type: 'article', content: article });\n }\n continue;\n }\n\n // Skip blocks with invalid schema names (after handling 'article')\n if (!isValidBlockSchemaName(block.schema_name)) {\n continue;\n }\n\n // For all block types, map schema_name to type and include content\n // Image references are automatically resolved by block.getById\n blocks.push({\n id: block.id,\n type: block.schema_name,\n content,\n } as BlockData);\n }\n\n return (\n <main>\n {blocks.map((block) => (\n <BlockRenderer registry={registry ?? {}} key={block.id} block={block} />\n ))}\n </main>\n );\n } catch (error) {\n // Log error for debugging\n console.error(`Route fetch error for path: ${path}`, error);\n\n // If route not found or param validation fails, show 404\n // TRPCClientError has data.code for the error code\n const errorCode =\n error instanceof Error && 'data' in error\n ? (error as { data?: { code?: string } }).data?.code\n : error instanceof Error && 'code' in error\n ? (error as { code: string }).code\n : undefined;\n\n if (errorCode === 'NOT_FOUND' || errorCode === 'P0002') {\n notFound();\n }\n\n // Re-throw other errors\n throw error;\n }\n}\n\n// -----------------------------------------------------------------------------\n// Metadata\n// -----------------------------------------------------------------------------\n\n/**\n * Generate metadata for the page.\n * Uses Next.js 15+ async params pattern.\n */\nexport async function generateMetadata({ params, apiKey }: PageProps): Promise<Metadata> {\n const { slug } = await params;\n const rawPath = `/${slug.join('/')}`;\n const path = normalizePath(rawPath);\n const client = getCmsClient({ apiKey });\n\n try {\n const { route } = await client.route.getByPath.query({ path });\n return {\n title: `${route.path} | Website`,\n description: `Content page: ${route.path}`,\n };\n } catch {\n return {\n title: 'Page Not Found | Website',\n description: 'The requested page could not be found.',\n };\n }\n}\n\nexport function normalizePath(path: string): string {\n if (!path || path === '/') {\n return '/';\n }\n\n // Remove trailing slashes, ensure leading slash\n let normalized = path.trim();\n\n // Remove trailing slashes (but keep root \"/\")\n normalized = normalized.replace(/\\/+$/, '');\n\n // Ensure leading slash\n if (!normalized.startsWith('/')) {\n normalized = `/${normalized}`;\n }\n\n // Collapse multiple consecutive slashes to single slash\n normalized = normalized.replace(/\\/+/g, '/');\n\n return normalized;\n}\n"],"mappings":";;;;;;;;AA4BO,SAAS,wBAAwB,SAAyC;AAC/E,MAAI,CAAC,WAAW,OAAO,YAAY,UAAU;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,QAAM,WAAW,OAAO,OAAO,aAAa,WAAW,OAAO,WAAW;AACzE,QAAM,OAAO,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;AAE7D,MAAI,CAAC,YAAY,CAAC,MAAM;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AACnE,QAAM,cAAc,OAAO,OAAO,gBAAgB,WAAW,OAAO,cAAc;AAClF,QAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,IAAI,OAAO,KAAK,IAAI,CAAC,QAAQ,OAAO,GAAG,CAAC,IAAI;AAClF,QAAM,YAAY,OAAO,OAAO,WAAW,WAAW,OAAO,OAAO,KAAK,IAAI;AAE7E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,aAAa;AAAA,EACvB;AACF;AAsBO,SAAS,mBAAmB,SAAkC;AACnE,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,cAAc,QAAQ,cAAc,IAAI,KAAK,QAAQ,WAAW,IAAI;AAE1E,SACE,QAAQ,WAAW,eACnB,g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