@conloca/content-api 0.1.13 → 0.1.15

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.
@@ -0,0 +1,18 @@
1
+ import { $ as ErrorCode, A as Site, B as ContentListResult, C as mapSiteNames, D as serializeMdxWithFrontmatter, E as resolvePublishDate, F as BlockFilters, G as CreateBlockInput, H as ContentMeta, I as ContentAPIOptions, J as CreateResult, K as CreateContentInput, L as ContentData, M as APIError, N as BatchOperationResult, O as Blocks, P as BatchResult, Q as DeleteResult, R as ContentEntry, S as mapLocales, T as parseDate, U as ContentProp, V as ContentManifest, W as ContentType, X as DataContext, Y as DataCollectionEntry, Z as DeleteLocaleInput, _ as isContentPublished, _t as VXJSONFile, a as analyzeUpdateScope, at as LocaleUpdateData, b as isValidPathname, c as shouldUpdateModifiedTimestamp, ct as LocalizedManifest, d as validateCreateContent, dt as MoveResult, et as ErrorCodes, f as extractBlockName, ft as PageReference, g as getMetadataSize, gt as UpdateResult, h as getCurrentISODate, ht as UpdateLocaleInput, i as ValidationResult, it as LocalePathData, j as Data, k as ContentAPI, l as updatePublishDates, lt as MDXCompileResponse, m as generateContentId, mt as SitesConfig, n as UPDATE_SCOPE, nt as GlobalFilters, o as buildLocaleVersion, ot as LocaleVersion, p as formatFileSize, pt as SiteFilters, q as CreatePageInput, r as UpdateScope, rt as LocaleFileData, s as buildPathnameHistory, st as LocalizedEntry, t as CreateValidationResult, tt as FindOptions, u as validateAndPrepareMetadata, ut as MDXFrontmatter, v as isMetadataTooLarge, vt as WriteResult, w as normalizePathname, x as localesOf, y as isValidBlockName, z as ContentIdentity } from "./content-operations-Dv67amz3.mjs";
2
+ import { t as FileSystemContentAPI } from "./filesystem-content-api-C1TM0GLo.mjs";
3
+
4
+ //#region src/content-reader.d.ts
5
+ interface ContentReaderOptions {
6
+ contentRoot: string;
7
+ canvasDir?: string;
8
+ }
9
+ /**
10
+ * Creates a read-oriented content API instance for build-time consumers.
11
+ *
12
+ * The filesystem implementation is loaded lazily so build tooling does not
13
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
14
+ */
15
+ declare function createContentAPI(options: ContentReaderOptions): Promise<FileSystemContentAPI>;
16
+ //#endregion
17
+ export { APIError, BatchOperationResult, BatchResult, BlockFilters, Blocks, type ContentAPI, ContentAPIOptions, ContentData, ContentEntry, ContentIdentity, ContentListResult, ContentManifest, ContentMeta, ContentProp, ContentType, CreateBlockInput, CreateContentInput, CreatePageInput, CreateResult, CreateValidationResult, Data, DataCollectionEntry, DataContext, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FindOptions, GlobalFilters, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXCompileResponse, MDXFrontmatter, MoveResult, PageReference, Site, SiteFilters, SitesConfig, UPDATE_SCOPE, UpdateLocaleInput, UpdateResult, UpdateScope, VXJSONFile, ValidationResult, WriteResult, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory, createContentAPI, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizePathname, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
18
+ //# sourceMappingURL=reader.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.mts","names":[],"sources":["../src/content-reader.ts"],"mappings":";;;;UAAiB,oBAAA;EACf,WAAA;EACA,SAAA;AAAA;AAFF;;;;;AAWA;AAXA,iBAWsB,gBAAA,CAAiB,OAAA,EAAS,oBAAA,GAAoB,OAAA,CAAA,oBAAA"}
@@ -0,0 +1,22 @@
1
+ import { C as parseDate, E as Blocks, S as normalizePathname, T as serializeMdxWithFrontmatter, _ as isValidBlockName, a as buildPathnameHistory, b as mapLocales, c as validateAndPrepareMetadata, d as formatFileSize, f as generateContentId, g as isMetadataTooLarge, h as isContentPublished, i as buildLocaleVersion, l as validateCreateContent, m as getMetadataSize, n as UPDATE_SCOPE, o as shouldUpdateModifiedTimestamp, p as getCurrentISODate, r as analyzeUpdateScope, s as updatePublishDates, t as Site, u as extractBlockName, v as isValidPathname, w as resolvePublishDate, x as mapSiteNames, y as localesOf } from "./site-vNtJ5jCh.mjs";
2
+ import { t as ErrorCodes } from "./types-DWt912tu.mjs";
3
+ import { t as Data } from "./data-Db1Iv9T0.mjs";
4
+
5
+ //#region src/content-reader.ts
6
+ /**
7
+ * Creates a read-oriented content API instance for build-time consumers.
8
+ *
9
+ * The filesystem implementation is loaded lazily so build tooling does not
10
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
11
+ */
12
+ async function createContentAPI(options) {
13
+ const { FileSystemContentAPI: ReaderAPI } = await import("./filesystem-content-api-kxKY5IUw.mjs").then((n) => n.n);
14
+ return ReaderAPI.create({
15
+ contentRoot: options.contentRoot,
16
+ canvasDir: options.canvasDir || "./canvas"
17
+ });
18
+ }
19
+
20
+ //#endregion
21
+ export { Blocks, Data, ErrorCodes, Site, UPDATE_SCOPE, analyzeUpdateScope, buildLocaleVersion, buildPathnameHistory, createContentAPI, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizePathname, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
22
+ //# sourceMappingURL=reader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.mjs","names":[],"sources":["../src/content-reader.ts"],"sourcesContent":["export interface ContentReaderOptions {\n contentRoot: string;\n canvasDir?: string;\n}\n\n/**\n * Creates a read-oriented content API instance for build-time consumers.\n *\n * The filesystem implementation is loaded lazily so build tooling does not\n * eagerly traverse native hashing dependencies through the reader entrypoint.\n */\nexport async function createContentAPI(options: ContentReaderOptions) {\n const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api');\n\n return ReaderAPI.create({\n contentRoot: options.contentRoot,\n canvasDir: options.canvasDir || './canvas',\n });\n}\n"],"mappings":";;;;;;;;;;;AAWA,eAAsB,iBAAiB,SAA+B;CACpE,MAAM,EAAE,sBAAsB,cAAc,MAAM,OAAO;AAEzD,QAAO,UAAU,OAAO;EACtB,aAAa,QAAQ;EACrB,WAAW,QAAQ,aAAa;EACjC,CAAC"}
@@ -534,35 +534,5 @@ var Site = class {
534
534
  };
535
535
 
536
536
  //#endregion
537
- //#region src/types.ts
538
- const ErrorCodes = {
539
- CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND",
540
- LOCALE_NOT_FOUND: "LOCALE_NOT_FOUND",
541
- COLLECTION_NOT_FOUND: "COLLECTION_NOT_FOUND",
542
- SITE_NOT_FOUND: "SITE_NOT_FOUND",
543
- STALE_WRITE: "STALE_WRITE",
544
- ALREADY_EXISTS: "ALREADY_EXISTS",
545
- PATHNAME_TAKEN: "PATHNAME_TAKEN",
546
- NAME_TAKEN: "NAME_TAKEN",
547
- METADATA_TOO_LARGE: "METADATA_TOO_LARGE",
548
- WRITE_ERROR: "WRITE_ERROR",
549
- MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD",
550
- INVALID_LOCALE: "INVALID_LOCALE",
551
- INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
552
- INVALID_REQUEST: "INVALID_REQUEST",
553
- INTERNAL_ERROR: "INTERNAL_ERROR",
554
- FETCH_ERROR: "FETCH_ERROR",
555
- GIT_NOT_REPO: "GIT_NOT_REPO",
556
- GIT_COMMIT_FAILED: "GIT_COMMIT_FAILED",
557
- GIT_PUSH_FAILED: "GIT_PUSH_FAILED",
558
- GIT_PULL_FAILED: "GIT_PULL_FAILED",
559
- GIT_STATUS_FAILED: "GIT_STATUS_FAILED",
560
- ASSET_NOT_FOUND: "ASSET_NOT_FOUND",
561
- ASSET_INVALID_FORMAT: "ASSET_INVALID_FORMAT",
562
- ASSET_TOO_LARGE: "ASSET_TOO_LARGE",
563
- ASSET_UPLOAD_FAILED: "ASSET_UPLOAD_FAILED"
564
- };
565
-
566
- //#endregion
567
- export { normalizePathname as C, Blocks as D, serializeMdxWithFrontmatter as E, mapSiteNames as S, resolvePublishDate as T, isMetadataTooLarge as _, buildLocaleVersion as a, localesOf as b, updatePublishDates as c, extractBlockName as d, formatFileSize as f, isContentPublished as g, getMetadataSize as h, analyzeUpdateScope as i, validateAndPrepareMetadata as l, getCurrentISODate as m, Site as n, buildPathnameHistory as o, generateContentId as p, UPDATE_SCOPE as r, shouldUpdateModifiedTimestamp as s, ErrorCodes as t, validateCreateContent as u, isValidBlockName as v, parseDate as w, mapLocales as x, isValidPathname as y };
568
- //# sourceMappingURL=types-BUG0Cfkg.mjs.map
537
+ export { parseDate as C, Blocks as E, normalizePathname as S, serializeMdxWithFrontmatter as T, isValidBlockName as _, buildPathnameHistory as a, mapLocales as b, validateAndPrepareMetadata as c, formatFileSize as d, generateContentId as f, isMetadataTooLarge as g, isContentPublished as h, buildLocaleVersion as i, validateCreateContent as l, getMetadataSize as m, UPDATE_SCOPE as n, shouldUpdateModifiedTimestamp as o, getCurrentISODate as p, analyzeUpdateScope as r, updatePublishDates as s, Site as t, extractBlockName as u, isValidPathname as v, resolvePublishDate as w, mapSiteNames as x, localesOf as y };
538
+ //# sourceMappingURL=site-vNtJ5jCh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-vNtJ5jCh.mjs","names":[],"sources":["../src/blocks.ts","../src/content-utils.ts","../src/content-operations.ts","../src/site.ts"],"sourcesContent":["import type { BlockIndex } from './block-index';\nimport type { ContentAPI } from './content-api.interface';\nimport type { BlockFilters, ContentManifest, CreateBlockInput, CreateResult } from './types';\n\nexport class Blocks {\n constructor(\n private api: ContentAPI,\n private blockIndex: BlockIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: BlockFilters): Generator<ContentManifest> {\n // Choose the most efficient method based on filters\n if (filters?.collection) {\n if (filters.locales && filters.locales.length > 0) {\n // Filter by locales after getting collection entries\n for (const manifest of this.blockIndex.getManifestsByCollection(filters.collection)) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getManifestsByCollection(filters.collection);\n }\n } else if (filters?.locales && filters.locales.length > 0) {\n // For multiple locales, we need to check each\n for (const manifest of this.blockIndex.getAllManifests()) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getAllManifests();\n }\n }\n\n // Get all block collections\n get collections(): Set<string> {\n return this.blockIndex.collections;\n }\n\n // Block operations (returns null if not found)\n getByName(collection: string, name: string, locale?: string): ContentManifest | null {\n return this.blockIndex.getByName(collection, name, locale);\n }\n\n // Check if block name is available\n isNameAvailable(collection: string, name: string, excludeId?: string): boolean {\n const existing = this.getByName(collection, name);\n return !existing || existing.id === excludeId;\n }\n\n // Get the ID of content that conflicts with a block name\n getNameConflict(collection: string, name: string, excludeId?: string): string | null {\n const existing = this.getByName(collection, name);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if block name is valid\n isBlockNameValid(blockName: string): boolean {\n // Block names must not be empty\n if (!blockName || blockName.trim() === '') {\n return false;\n }\n\n // Block names must not contain dots (would interfere with locale suffixes)\n if (blockName.includes('.')) {\n return false;\n }\n\n // Block names must not contain path separators\n if (blockName.includes('/') || blockName.includes('\\\\')) {\n return false;\n }\n\n // Block names should only contain alphanumeric, hyphens, underscores\n return /^[a-zA-Z0-9_-]+$/.test(blockName);\n }\n\n // Create block with name validation\n async create(data: CreateBlockInput): Promise<CreateResult> {\n // Validate block name\n if (!this.isBlockNameValid(data.name)) {\n return {\n success: false,\n reason: 'invalid_name',\n error: new Error(`Invalid block name: ${data.name}`),\n };\n }\n\n // Check if name is already taken in any locale\n const existing = this.getByName(data.collection, data.name);\n if (existing) {\n return {\n success: false,\n reason: 'name_taken',\n error: new Error(`Block name ${data.name} already exists in collection ${data.collection}`),\n };\n }\n\n // Create the content\n return this.api.createContent({\n kind: 'block',\n collection: data.collection,\n type: 'mdx',\n name: data.name,\n meta: data.meta,\n locales: data.locales,\n });\n }\n}\n","import { nanoid } from 'nanoid';\nimport yaml from 'yaml';\nimport type { ContentMeta, LocaleVersion } from './types';\n\nexport function* localesOf<T>(manifest: { locales: Record<string, T | undefined> }): Generator<T> {\n for (const value of Object.values(manifest.locales)) {\n if (value) yield value;\n }\n}\n\n/**\n * Pure utility functions for content operations\n * These functions don't depend on any class state and can be shared\n * between FileSystemContentAPI, InMemoryContentAPI, and other implementations\n */\n\n/**\n * Check if content is published based on publishAt/unpublishAt dates\n */\nexport function isContentPublished(\n localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>,\n now = new Date(),\n): boolean {\n if (localeVersion.publishAt) {\n const publishDate = new Date(localeVersion.publishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(publishDate.getTime()) && publishDate > now) return false;\n }\n\n if (localeVersion.unpublishAt) {\n const unpublishDate = new Date(localeVersion.unpublishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;\n }\n\n return true;\n}\n\n/**\n * Validate that metadata doesn't exceed 4KB when serialized\n * This ensures efficient indexing as per the specification\n */\nexport function isMetadataTooLarge(meta: ContentMeta): boolean {\n const size = new TextEncoder().encode(JSON.stringify(meta)).length;\n return size > 4096;\n}\n\n/**\n * Extract block name from various sources\n * Used when displaying blocks in the UI\n */\nexport function extractBlockName(source: string): string {\n // If it's a collection/name path, extract the name part\n if (source.includes('/') && !source.includes('.')) {\n const parts = source.split('/');\n return parts[parts.length - 1];\n }\n\n // If it's a filename, extract the base name\n if (source.includes('.')) {\n const match = source.match(/^(.+?)\\.([a-z]{2})?\\.(mdx|vxjson)$/);\n if (match) {\n return match[1];\n }\n // Fallback: remove any extension\n return source.replace(/\\.[^.]+$/, '');\n }\n\n // If it's an ID, create a simple name\n if (source.startsWith('vx-')) {\n return `block-${source.substring(3, 8)}`;\n }\n\n // Otherwise return as-is\n return source;\n}\n\n/**\n * Validate block name according to the specification\n * - Cannot contain dots (reserved for locale separator)\n * - Cannot contain slashes (would create subdirectories)\n * - Cannot contain spaces (for clean filenames)\n * - Must have at least one character\n */\nexport function isValidBlockName(name: string): boolean {\n if (!name || name.length === 0) return false;\n if (name.includes('.')) return false;\n if (name.includes('/')) return false;\n if (name.includes(' ')) return false;\n return true;\n}\n\n/**\n * Format file size for display with human-readable units\n * @example formatFileSize(1536) // \"1.5 KB\"\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Calculate metadata size in bytes\n */\nexport function getMetadataSize(meta: ContentMeta): number {\n return new TextEncoder().encode(JSON.stringify(meta)).length;\n}\n\n/**\n * Check if a pathname is valid\n * - Must start with /\n * - Cannot contain spaces (should be URL-encoded)\n * - Cannot contain special characters that would break URLs\n */\nexport function isValidPathname(pathname: string): boolean {\n if (!pathname || !pathname.startsWith('/')) return false;\n if (pathname.includes(' ')) return false;\n if (pathname.includes('?') || pathname.includes('#')) return false;\n return true;\n}\n\n/**\n * Normalize a pathname to ensure consistency\n * - Ensure it starts with /\n * - Remove trailing slashes (except for root)\n * - Collapse multiple slashes\n */\nexport function normalizePathname(pathname: string): string {\n if (!pathname) return '/';\n\n // Ensure it starts with /\n if (!pathname.startsWith('/')) {\n pathname = '/' + pathname;\n }\n\n // Collapse multiple slashes\n pathname = pathname.replace(/\\/+/g, '/');\n\n // Remove trailing slash unless it's the root\n if (pathname !== '/' && pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n\n return pathname;\n}\n\n/**\n * Generate a content ID in the standard format\n * IDs are prefixed with \"vx-\" followed by 8 random characters\n */\nexport function generateContentId(): string {\n return `vx-${nanoid(8)}`;\n}\n\n/**\n * Get the current date/time in ISO format\n * Used for timestamps in content files\n */\nexport function getCurrentISODate(): string {\n return new Date().toISOString();\n}\n\n/**\n * Parse a date string safely\n * Returns null if invalid\n */\nexport function parseDate(dateStr: string | undefined): Date | null {\n if (!dateStr) return null;\n\n try {\n const date = new Date(dateStr);\n if (isNaN(date.getTime())) return null;\n return date;\n } catch {\n return null;\n }\n}\n\n/**\n * Creates a V8-optimized object by mapping site names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param sitesConfig - Sites configuration containing site names\n * @param factory - Function that creates the value for each site\n * @returns Object with all sites initialized in alphabetical order\n */\nexport function mapSiteNames<T>(\n sitesConfig: { sites: Record<string, any> },\n factory: (siteName: string) => T,\n): Record<string, T> {\n const obj: Record<string, T> = {};\n // Object.keys returns keys in insertion order, which is stable for a given object\n for (const siteName of Object.keys(sitesConfig.sites)) {\n obj[siteName] = factory(siteName);\n }\n return obj;\n}\n\n/**\n * Creates a V8-optimized object by mapping locale names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param locales - Array of locale codes\n * @param factory - Function that creates the value for each locale\n * @returns Object with all locales initialized in array order\n */\nexport function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T> {\n const obj: Record<string, T> = {};\n for (const locale of locales) {\n obj[locale] = factory(locale);\n }\n return obj;\n}\n\n/**\n * Resolves a publish date value to a valid string or undefined.\n * Handles various input types including null, false, and empty strings.\n *\n * @param updateValue - The value being updated (string | null | false | undefined)\n * @param currentValue - The current value to fall back to if updateValue is undefined\n * @returns A valid date string or undefined\n */\nexport function resolvePublishDate(\n updateValue: string | null | false | undefined,\n currentValue: string | undefined,\n): string | undefined {\n // If updateValue is explicitly provided (including null/false), use it\n if (updateValue !== undefined) {\n // Only return string values, treat null/false/empty as undefined\n return updateValue && typeof updateValue === 'string' ? updateValue : undefined;\n }\n // Otherwise keep the current value\n return currentValue;\n}\n\n/**\n * Serializes MDX content with frontmatter.\n * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure\n * consistent MDX output that includes frontmatter for variable access.\n *\n * @param frontmatterData - The frontmatter data to serialize\n * @param mdxContent - The MDX content (without frontmatter)\n * @returns Complete MDX file content with frontmatter\n */\nexport function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string {\n // Use yaml library for proper serialization\n const yamlStr = yaml.stringify(frontmatterData);\n return `---\\n${yamlStr}---\\n\\n${mdxContent}`;\n}\n","import sortKeys from 'sort-keys';\nimport type { Blocks } from './blocks';\nimport { generateContentId, isContentPublished } from './content-utils';\nimport type { Site } from './site';\nimport type { ContentMeta, CreateContentInput, LocaleUpdateData, LocaleVersion } from './types';\n\n/**\n * Shared business logic for content operations\n * Used by both FileSystemContentAPI and InMemoryContentAPI\n */\n\n// Validation result types\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n sortedMeta?: ContentMeta;\n size?: number;\n}\n\nexport interface CreateValidationResult {\n valid: boolean;\n error?: string;\n reason?: 'metadata_too_large' | 'pathname_taken' | 'pathname_in_redirects' | 'invalid_name' | 'name_taken';\n existingId?: string;\n}\n\n/**\n * Validate and prepare metadata for storage\n * Ensures title exists and metadata doesn't exceed 4KB\n */\nexport function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult {\n // Ensure title is present\n if (!meta.title) {\n return {\n valid: false,\n error: 'Title is required in metadata',\n };\n }\n\n const sortedMeta = sortKeys(meta, { deep: true }) as ContentMeta; // We've validated title exists\n const metaJson = JSON.stringify(sortedMeta, null, 2);\n const metaSize = new TextEncoder().encode(metaJson).length;\n\n if (metaSize > 4088) {\n // Leave 8 bytes for safety\n return {\n valid: false,\n error: `Metadata exceeds 4KB limit (${metaSize} bytes)`,\n };\n }\n\n return {\n valid: true,\n sortedMeta,\n size: metaSize,\n };\n}\n\n/**\n * Build pathname history update\n */\nexport function buildPathnameHistory(\n oldPathname: string | undefined,\n newPathname: string | undefined,\n isPublished: boolean,\n now: string,\n): Record<string, string> {\n const history: Record<string, string> = {};\n\n if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) {\n history[oldPathname] = now;\n }\n\n return history;\n}\n\n/**\n * Build a locale manifest\n */\nexport function buildLocaleVersion(params: {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n meta: ContentMeta;\n kind: 'block' | 'page' | 'data';\n publishAt?: string;\n unpublishAt?: string;\n pathname?: string;\n name?: string;\n previousPathnames?: Record<string, string>;\n}): LocaleVersion {\n const manifest: LocaleVersion = {\n locale: params.locale,\n etag: params.etag,\n created: params.created,\n modified: params.modified,\n meta: params.meta,\n };\n\n // Add optional fields only if they exist\n if (params.publishAt) {\n manifest.publishAt = params.publishAt;\n }\n if (params.unpublishAt) {\n manifest.unpublishAt = params.unpublishAt;\n }\n if (params.pathname && params.kind === 'page') {\n manifest.pathname = params.pathname;\n }\n if (params.name && (params.kind === 'block' || params.kind === 'data')) {\n manifest.name = params.name;\n }\n if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) {\n manifest.previousPathnames = params.previousPathnames;\n }\n\n return manifest;\n}\n\n/**\n * Update publish dates on a locale manifest\n */\nexport function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void {\n // Handle publishAt\n if ('publishAt' in data) {\n if (data.publishAt && typeof data.publishAt === 'string') {\n manifest.publishAt = data.publishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.publishAt;\n }\n }\n\n // Handle unpublishAt\n if ('unpublishAt' in data) {\n if (data.unpublishAt && typeof data.unpublishAt === 'string') {\n manifest.unpublishAt = data.unpublishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.unpublishAt;\n }\n }\n}\n\n/**\n * Validate content creation data\n */\nexport function validateCreateContent(\n data: CreateContentInput,\n sites: Record<string, Site>,\n blocks: Blocks,\n dataApi?: {\n isDataNameValid: (name: string) => boolean;\n getNameConflict: (collection: string, name: string) => string | null;\n },\n): CreateValidationResult {\n // Validate metadata for all locales\n for (const localeData of Object.values(data.locales)) {\n const meta = { ...data.meta, ...localeData.meta };\n const validation = validateAndPrepareMetadata(meta);\n if (!validation.valid) {\n return {\n valid: false,\n error: validation.error,\n reason: 'metadata_too_large',\n };\n }\n }\n\n // Validate pathname for pages\n if (data.kind === 'page') {\n if (!data.site) {\n return {\n valid: false,\n error: 'Site is required for pages',\n };\n }\n\n const site = sites[data.site];\n if (!site) {\n return {\n valid: false,\n error: `Site ${data.site} not found`,\n };\n }\n\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const pathname = localeData.pathname;\n\n // Pathname is required for pages\n if (!pathname) {\n return {\n valid: false,\n error: `Pathname is required for pages (locale: ${locale})`,\n };\n }\n\n // Check if pathname is already taken\n const existingId = site.getPathnameConflict(pathname, locale);\n if (existingId) {\n return {\n valid: false,\n error: `Pathname ${pathname} already exists`,\n reason: 'pathname_taken',\n existingId,\n };\n }\n\n // Check if pathname is in redirects\n if (site.isPathnameInRedirects(pathname, locale)) {\n return {\n valid: false,\n error: `Pathname ${pathname} is already in use as a redirect`,\n reason: 'pathname_in_redirects',\n };\n }\n }\n }\n\n // Validate block name uniqueness\n if (data.kind === 'block') {\n if (!data.name) {\n return {\n valid: false,\n error: 'Block name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate block name format\n if (!blocks.isBlockNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = blocks.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Block name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n // Validate data entry name uniqueness\n if (data.kind === 'data' && dataApi) {\n if (!data.name) {\n return {\n valid: false,\n error: 'Data name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate data name format\n if (!dataApi.isDataNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = dataApi.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Data name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Generate a new content ID\n */\nexport { generateContentId };\n\n/**\n * Check if content is published\n */\nexport { isContentPublished };\n\n/**\n * Update scope bit flags\n * Can be combined with bitwise OR and checked with bitwise AND\n */\nexport const UPDATE_SCOPE = {\n NONE: 0, // 00\n META: 1 << 0, // 01\n CONTENT: 1 << 1, // 10\n BOTH: 3, // 11 (META | CONTENT)\n} as const;\n\nexport type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];\n\n/**\n * Determine what parts of content are being updated\n * Returns bit flags that can be checked with bitwise AND\n *\n * Example usage:\n * ```\n * const scope = analyzeUpdateScope(data);\n * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }\n * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }\n * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }\n * ```\n */\nexport function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope {\n let scope = UPDATE_SCOPE.NONE;\n\n // Note: pathname is NOT considered a metadata change because:\n // - For pages, pathname is derived from file path, not stored in metadata\n // - Pathname changes don't affect the metadata hash in the ETag\n if (data.meta !== undefined || data.publishAt !== undefined || data.unpublishAt !== undefined) {\n scope |= UPDATE_SCOPE.META;\n }\n\n if (data.content !== undefined) {\n scope |= UPDATE_SCOPE.CONTENT;\n }\n\n return scope;\n}\n\n/**\n * Determine whether the modified timestamp should be updated\n * Updates for ANY change - either metadata or content\n */\nexport function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean {\n const scope = analyzeUpdateScope(data);\n return scope !== UPDATE_SCOPE.NONE;\n}\n","import type { ContentAPI } from './content-api.interface';\nimport { localesOf } from './content-utils';\nimport type { SiteIndex } from './site-index';\nimport type { ContentManifest, CreatePageInput, CreateResult, MoveResult, SiteFilters } from './types';\n\nexport class Site {\n constructor(\n private siteName: string,\n private api: ContentAPI,\n private siteIndex: SiteIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: SiteFilters): Generator<ContentManifest> {\n // Get the base manifests using the most efficient method\n let manifests: Generator<ContentManifest>;\n\n if (filters?.locales && filters.locales.length === 1) {\n manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);\n } else {\n manifests = this.siteIndex.getAllManifests();\n }\n\n // Apply additional filters if needed\n if (filters?.collection || filters?.type || filters?.published !== undefined) {\n for (const manifest of manifests) {\n if (filters.collection && manifest.collection !== filters.collection) continue;\n if (filters.type && manifest.type !== filters.type) continue;\n if (filters.published !== undefined) {\n // Check if any locale is published\n let hasPublishedLocale = false;\n for (const locale of localesOf(manifest)) {\n if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {\n hasPublishedLocale = true;\n break;\n }\n }\n if (filters.published !== hasPublishedLocale) continue;\n }\n yield manifest;\n }\n } else {\n // No additional filters, yield all manifests\n yield* manifests;\n }\n }\n\n // List pages (convenience method for middleware)\n *listPages(locale?: string): Generator<ContentManifest> {\n const filters: SiteFilters = {};\n if (locale) filters.locales = [locale];\n\n yield* this.listContent(filters);\n }\n\n // Get all collections for this site\n get collections(): Set<string> {\n return this.siteIndex.collections;\n }\n\n // Pathname operations (returns null if available, ContentManifest if taken)\n getByPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPathname(pathname, locale);\n }\n\n // Get by previous pathname (for redirects)\n getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname, locale);\n }\n\n // Move content (handles rename + redirect tracking)\n async move(id: string, locale: string, newPathname: string): Promise<MoveResult> {\n // Check if new pathname is available\n const existing = this.getByPathname(newPathname, locale);\n if (existing && existing.id !== id) {\n return {\n moved: false,\n reason: 'already_exists',\n };\n }\n\n // Get current content\n const content = await this.api.getLocalized(id, locale);\n if (!content) {\n return {\n moved: false,\n reason: 'not_found',\n };\n }\n\n // Update with new pathname (this will handle previousPathnames)\n const updateResult = await this.api.updateLocalized({\n id,\n locale,\n data: {\n pathname: newPathname,\n meta: content.localized.meta,\n },\n etag: content.localized.etag,\n });\n\n if (!updateResult.success) {\n return {\n moved: false,\n reason: updateResult.reason,\n error: updateResult.error,\n };\n }\n\n return {\n moved: true,\n previousPathname: content.localized.pathname,\n etag: updateResult.etag,\n };\n }\n\n // Check if pathname is in redirect history\n getRedirect(pathname: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname);\n }\n\n // Validate pathname is available (not taken or in redirects)\n isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean {\n // Check if pathname is already taken\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return false;\n }\n\n // Check if pathname is in redirects\n const redirect = this.getByPreviousPathname(pathname, locale);\n if (redirect && redirect.id !== excludeId) {\n return false;\n }\n\n return true;\n }\n\n // Get the ID of content that conflicts with a pathname\n getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null {\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if pathname is in redirects\n isPathnameInRedirects(pathname: string, locale: string): boolean {\n return this.getByPreviousPathname(pathname, locale) !== null;\n }\n\n // Create page with validation\n async create(data: CreatePageInput): Promise<CreateResult> {\n // Validate pathname availability for all locales\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const existing = this.getByPathname(localeData.pathname, locale);\n if (existing) {\n return {\n success: false,\n reason: 'pathname_taken',\n error: new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`),\n };\n }\n\n // Check redirects too\n const redirect = this.getRedirect(localeData.pathname);\n if (redirect) {\n return {\n success: false,\n reason: 'pathname_in_redirects',\n error: new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`),\n };\n }\n }\n\n return this.api.createContent({\n kind: 'page',\n site: this.siteName,\n collection: data.collection,\n type: 'puck',\n locales: data.locales,\n });\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,SAAb,MAAoB;CAClB,YACE,AAAQ,KACR,AAAQ,YACR;EAFQ;EACA;;CAIV,CAAC,YAAY,SAAoD;AAE/D,MAAI,SAAS,WACX,KAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAE9C;QAAK,MAAM,YAAY,KAAK,WAAW,yBAAyB,QAAQ,WAAW,CACjF,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,WAAW,yBAAyB,QAAQ,WAAW;WAE5D,SAAS,WAAW,QAAQ,QAAQ,SAAS,GAEtD;QAAK,MAAM,YAAY,KAAK,WAAW,iBAAiB,CACtD,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,WAAW,iBAAiB;;CAK5C,IAAI,cAA2B;AAC7B,SAAO,KAAK,WAAW;;CAIzB,UAAU,YAAoB,MAAc,QAAyC;AACnF,SAAO,KAAK,WAAW,UAAU,YAAY,MAAM,OAAO;;CAI5D,gBAAgB,YAAoB,MAAc,WAA6B;EAC7E,MAAM,WAAW,KAAK,UAAU,YAAY,KAAK;AACjD,SAAO,CAAC,YAAY,SAAS,OAAO;;CAItC,gBAAgB,YAAoB,MAAc,WAAmC;EACnF,MAAM,WAAW,KAAK,UAAU,YAAY,KAAK;AACjD,MAAI,YAAY,SAAS,OAAO,UAC9B,QAAO,SAAS;AAElB,SAAO;;CAIT,iBAAiB,WAA4B;AAE3C,MAAI,CAAC,aAAa,UAAU,MAAM,KAAK,GACrC,QAAO;AAIT,MAAI,UAAU,SAAS,IAAI,CACzB,QAAO;AAIT,MAAI,UAAU,SAAS,IAAI,IAAI,UAAU,S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,UAAkB,QAAyB;AAC/D,SAAO,KAAK,sBAAsB,UAAU,OAAO,KAAK;;CAI1D,MAAM,OAAO,MAA8C;AAEzD,OAAK,MAAM,CAAC,QAAQ,eAAe,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAE/D,OADiB,KAAK,cAAc,WAAW,UAAU,OAAO,CAE9D,QAAO;IACL,SAAS;IACT,QAAQ;IACR,uBAAO,IAAI,MAAM,YAAY,WAAW,SAAS,gCAAgC,SAAS;IAC3F;AAKH,OADiB,KAAK,YAAY,WAAW,SAAS,CAEpD,QAAO;IACL,SAAS;IACT,QAAQ;IACR,uBAAO,IAAI,MAAM,YAAY,WAAW,SAAS,qCAAqC,SAAS;IAChG;;AAIL,SAAO,KAAK,IAAI,cAAc;GAC5B,MAAM;GACN,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,MAAM;GACN,SAAS,KAAK;GACf,CAAC"}
@@ -0,0 +1,33 @@
1
+ //#region src/types.ts
2
+ const ErrorCodes = {
3
+ CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND",
4
+ LOCALE_NOT_FOUND: "LOCALE_NOT_FOUND",
5
+ COLLECTION_NOT_FOUND: "COLLECTION_NOT_FOUND",
6
+ SITE_NOT_FOUND: "SITE_NOT_FOUND",
7
+ STALE_WRITE: "STALE_WRITE",
8
+ ALREADY_EXISTS: "ALREADY_EXISTS",
9
+ PATHNAME_TAKEN: "PATHNAME_TAKEN",
10
+ NAME_TAKEN: "NAME_TAKEN",
11
+ METADATA_TOO_LARGE: "METADATA_TOO_LARGE",
12
+ WRITE_ERROR: "WRITE_ERROR",
13
+ MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD",
14
+ INVALID_LOCALE: "INVALID_LOCALE",
15
+ INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
16
+ INVALID_REQUEST: "INVALID_REQUEST",
17
+ MDX_COMPILE_FAILED: "MDX_COMPILE_FAILED",
18
+ INTERNAL_ERROR: "INTERNAL_ERROR",
19
+ FETCH_ERROR: "FETCH_ERROR",
20
+ GIT_NOT_REPO: "GIT_NOT_REPO",
21
+ GIT_COMMIT_FAILED: "GIT_COMMIT_FAILED",
22
+ GIT_PUSH_FAILED: "GIT_PUSH_FAILED",
23
+ GIT_PULL_FAILED: "GIT_PULL_FAILED",
24
+ GIT_STATUS_FAILED: "GIT_STATUS_FAILED",
25
+ ASSET_NOT_FOUND: "ASSET_NOT_FOUND",
26
+ ASSET_INVALID_FORMAT: "ASSET_INVALID_FORMAT",
27
+ ASSET_TOO_LARGE: "ASSET_TOO_LARGE",
28
+ ASSET_UPLOAD_FAILED: "ASSET_UPLOAD_FAILED"
29
+ };
30
+
31
+ //#endregion
32
+ export { ErrorCodes as t };
33
+ //# sourceMappingURL=types-DWt912tu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DWt912tu.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export interface ContentAPIOptions {\n contentRoot: string;\n canvasDir?: string;\n}\n\n// Error response format for all API errors\nexport interface APIError {\n error: {\n code: string; // Machine-readable error code (e.g., 'CONTENT_NOT_FOUND', 'STALE_WRITE')\n message: string; // Human-readable error message\n details?: any; // Optional additional error details\n };\n}\n\nexport interface MDXCompileResponse {\n code: string;\n metadata: Record<string, unknown>;\n}\n\n// Common error codes\nexport const ErrorCodes = {\n // Content errors\n CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',\n LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',\n COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',\n SITE_NOT_FOUND: 'SITE_NOT_FOUND',\n\n // Write errors\n STALE_WRITE: 'STALE_WRITE',\n ALREADY_EXISTS: 'ALREADY_EXISTS',\n PATHNAME_TAKEN: 'PATHNAME_TAKEN',\n NAME_TAKEN: 'NAME_TAKEN',\n METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',\n WRITE_ERROR: 'WRITE_ERROR',\n\n // Validation errors\n MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',\n INVALID_LOCALE: 'INVALID_LOCALE',\n INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',\n INVALID_REQUEST: 'INVALID_REQUEST',\n MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED',\n\n // System errors\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n FETCH_ERROR: 'FETCH_ERROR',\n\n // Git errors\n GIT_NOT_REPO: 'GIT_NOT_REPO',\n GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',\n GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',\n GIT_PULL_FAILED: 'GIT_PULL_FAILED',\n GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',\n\n // Asset errors\n ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',\n ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',\n ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',\n ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n// Content type - the format of the content\nexport type ContentType = 'puck' | 'mdx' | 'json';\n\n// Content data - the actual content (puck, mdx, or json data)\nexport interface ContentData {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n}\n\n// Content property that extends manifests with actual content\nexport interface ContentProp {\n content: ContentData;\n}\n\n// Base identity fields shared by all content representations\nexport interface ContentIdentity {\n id: string;\n type: ContentType;\n kind: 'block' | 'page' | 'data';\n site?: string; // Only for pages\n collection: string;\n}\n\n// Locale file data derived from file path\nexport interface LocalePathData {\n locale: string;\n pathname?: string; // pages only - derived from file path\n name?: string; // blocks only - derived from filename\n}\n\n// Localized content manifest - metadata about translated content without the actual content\nexport interface LocaleVersion extends LocalePathData {\n etag: string; // Format: \"metaEtag.contentEtag\"\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>; // pages only\n meta: ContentMeta; // title, description, seo, etc.\n}\n\n// Manifest for all locales (what's in the index and returned in listings)\nexport interface ContentManifest extends ContentIdentity {\n locales: Record<string, LocaleVersion | undefined>;\n}\n\n// Single locale without content (used for updates/changes)\nexport interface LocalizedManifest extends ContentIdentity {\n localized: LocaleVersion;\n}\n\n// Single locale with content\nexport interface LocalizedEntry extends ContentIdentity {\n localized: LocaleVersion & ContentProp;\n}\n\n// All locales with content\nexport interface ContentEntry extends ContentManifest {\n locales: Record<string, LocaleVersion & ContentProp>;\n}\n\n// Result types\nexport interface UpdateResult {\n success: boolean;\n etag?: string;\n modified?: Date;\n reason?: 'not_found' | 'stale_write' | 'write_error';\n error?: Error;\n currentEtag?: string;\n conflictDetails?: {\n metaChanged: boolean;\n contentChanged: boolean;\n currentMeta?: ContentMeta;\n currentContent?: ContentData;\n localContent?: ContentData;\n };\n}\n\nexport interface MoveResult {\n moved: boolean;\n previousPathname?: string;\n files?: string[];\n reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error';\n error?: Error;\n etag?: string;\n}\n\nexport interface ContentListResult {\n items: ContentManifest[];\n total: number;\n hasMore?: boolean;\n}\n\n// Filter types\nexport interface GlobalFilters {\n site?: string;\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx' | 'json';\n published?: boolean;\n kind?: 'block' | 'page' | 'data';\n localization?: 'complete' | 'partial' | 'one';\n missingLocales?: string[];\n}\n\nexport interface SiteFilters {\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx';\n published?: boolean;\n}\n\nexport interface BlockFilters {\n collection?: string;\n locales?: string[];\n}\n\nexport interface FindOptions {\n excludeSites?: string[];\n includeUnpublished?: boolean;\n}\n\n// Input types\n\nexport interface CreateContentInput {\n kind: 'block' | 'page' | 'data';\n site?: string; // Required for pages, must be undefined for blocks and data\n collection: string;\n type: ContentType;\n created?: string; // Optional, will use current time if not provided\n name?: string; // Internal identifier for blocks and data (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults (applied to all locales)\n locales: {\n [locale: string]: {\n pathname?: string; // for pages (locale-specific route)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>;\n } & ContentProp;\n };\n}\n\nexport interface CreatePageInput {\n collection: string;\n locales: {\n [locale: string]: {\n pathname: string; // Required pathname for each locale\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta: ContentMeta; // Required metadata with title for each locale\n content: {\n puckData: any;\n };\n };\n };\n}\n\nexport interface CreateBlockInput {\n collection: string;\n type: 'mdx';\n name: string; // Internal identifier (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults\n locales: {\n [locale: string]: {\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>; // Locale-specific metadata overrides\n content: {\n mdx: string;\n };\n };\n };\n}\n\nexport interface UpdateLocaleInput {\n id: string;\n locale: string;\n data: LocaleUpdateData;\n etag: string;\n}\n\nexport interface LocaleUpdateData {\n pathname?: string; // for pages - update pathname\n name?: string; // for blocks - update name (filename)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n modified?: string; // Optional, will use current time if not provided\n meta?: Partial<ContentMeta>;\n content?: ContentData;\n}\n\nexport interface DeleteLocaleInput {\n id: string;\n locale: string;\n etag: string;\n}\n\n// Sites configuration\nexport interface SitesConfig {\n sites: {\n [siteName: string]: {\n locales: string[];\n defaultLocale: string;\n domains?: {\n [locale: string]: string;\n };\n };\n };\n globalLocales: string[];\n}\n\n// Batch operations\nexport interface BatchResult {\n operations: BatchOperationResult[];\n success: boolean; // true if all operations succeeded\n failed: number;\n updated: number; // number of successfully updated items\n}\n\n// Common metadata structure for all content types (stored in 'meta' field)\nexport interface ContentMeta {\n // Required\n title: string; // Display name for UI\n\n // Common optional fields\n description?: string;\n author?: string;\n tags?: string[];\n\n // SEO (mainly for pages)\n keywords?: string[];\n ogTitle?: string;\n ogDescription?: string;\n ogImage?: string;\n\n // Any additional fields from frontmatter/pageMeta\n [key: string]: any;\n}\n\n// File format types\n\n/**\n * VXJSON (Variant JSON) File Format\n *\n * VXJSON is a specialized JSON format that guarantees:\n * 1. The root is always an object (never an array or primitive)\n * 2. The \"content\" field always comes last in the object\n * 3. Field order is deterministic for consistent ETag calculation\n *\n * This format enables efficient streaming ETag calculation where metadata\n * can be hashed separately from content, supporting partial updates and\n * conflict resolution in CMS scenarios.\n *\n * Files using this format have the extension .vxjson\n */\nexport interface VXJSONFile {\n id: string;\n type: ContentType;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: ContentData; // Always last field in VXJSON\n}\n\nexport interface MDXFrontmatter {\n id: string;\n type: 'mdx';\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n meta: ContentMeta;\n}\n\n// All properties are declared in each variant to make destructuring safe and predictable\nexport type WriteResult =\n | { success: true; etag: string; modified?: Date; reason?: undefined; error?: undefined; currentEtag?: undefined }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'stale_write';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'already_exists';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'write_error';\n error: Error;\n currentEtag?: string;\n };\n\nexport interface DeleteResult {\n success: boolean;\n error?: Error;\n reason?: 'stale_write' | 'not_found' | 'delete_error';\n currentEtag?: string;\n}\n\nexport interface CreateResult {\n success: boolean;\n id?: string;\n etag?: string;\n created?: Date;\n reason?:\n | 'already_exists'\n | 'write_error'\n | 'invalid_name'\n | 'name_taken'\n | 'pathname_taken'\n | 'pathname_in_redirects'\n | 'metadata_too_large';\n error?: Error;\n existingId?: string;\n}\n\nexport interface BatchOperationResult {\n id: string;\n locale: string;\n updated: boolean;\n error?: Error;\n etag?: string;\n}\n\n// ===== Data Context Types =====\n\n/**\n * Minimal page reference for listing/navigation in data context.\n *\n * Used in dataBindings.pages for blog listing components\n * and getStaticPaths() to enumerate available pages.\n */\nexport interface PageReference {\n /** Page identifier. */\n id: string;\n /** URL pathname. */\n pathname: string;\n /** Page title (if available without full load). */\n title?: string;\n /** Content collection. */\n collection: string;\n /** Page metadata from content. */\n meta?: Record<string, unknown>;\n /** Page timestamps for sorting and display. */\n timestamps?: {\n created?: Date;\n modified?: Date;\n };\n}\n\n/**\n * A single entry from a data collection.\n *\n * Simplified representation of collection data for use in component resolvers.\n */\nexport interface DataCollectionEntry {\n /** Unique identifier for the entry. */\n id: string;\n /** Human-readable name of the entry. */\n name: string;\n /** The entry's data content. */\n data: Record<string, unknown>;\n /** Optional metadata for the entry. */\n meta?: Record<string, unknown>;\n}\n\n/**\n * Context object passed to Puck component resolvers via metadata.\n *\n * Contains fetched collection data and contextual information\n * for data-driven component rendering.\n */\nexport interface DataContext {\n /** Collection data keyed by collection name. */\n collections: Record<string, DataCollectionEntry[]>;\n /** Pages matching the dataBindings.pages filter. */\n pages?: PageReference[];\n /** Current locale used for data fetching. */\n locale: string;\n /** Site name from routing configuration. */\n siteName: string;\n}\n\n// Internal type for locale data returned by readLocaleFile\nexport interface LocaleFileData {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n };\n}\n"],"mappings":";AAoBA,MAAa,aAAa;CAExB,mBAAmB;CACnB,kBAAkB;CAClB,sBAAsB;CACtB,gBAAgB;CAGhB,aAAa;CACb,gBAAgB;CAChB,gBAAgB;CAChB,YAAY;CACZ,oBAAoB;CACpB,aAAa;CAGb,wBAAwB;CACxB,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,oBAAoB;CAGpB,gBAAgB;CAChB,aAAa;CAGb,cAAc;CACd,mBAAmB;CACnB,iBAAiB;CACjB,iBAAiB;CACjB,mBAAmB;CAGnB,iBAAiB;CACjB,sBAAsB;CACtB,iBAAiB;CACjB,qBAAqB;CACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conloca/content-api",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,6 +12,7 @@
12
12
  "main": "./dist/index.mjs",
13
13
  "module": "./dist/index.mjs",
14
14
  "dependencies": {
15
+ "@mdx-js/mdx": "^3.1.1",
15
16
  "@hono/node-server": "^1.19.9",
16
17
  "@node-rs/xxhash": "^1.7.6",
17
18
  "fast-glob": "^3.3.2",
@@ -20,6 +21,9 @@
20
21
  "image-size": "^2.0.2",
21
22
  "jose": "^6.1.3",
22
23
  "nanoid": "^5.1.6",
24
+ "remark-frontmatter": "^5.0.0",
25
+ "remark-gfm": "^4.0.0",
26
+ "remark-mdx-frontmatter": "^5.2.0",
23
27
  "sort-keys": "^6.0.0",
24
28
  "tslib": "^2.8.1",
25
29
  "yaml": "^2.8.1",
@@ -28,17 +32,22 @@
28
32
  "exports": {
29
33
  "./package.json": "./package.json",
30
34
  ".": {
31
- "types": "./dist/index.d.ts",
35
+ "types": "./dist/index.d.mts",
32
36
  "import": "./dist/index.mjs",
33
37
  "default": "./dist/index.mjs"
34
38
  },
35
39
  "./node": {
36
- "types": "./dist/node.d.ts",
40
+ "types": "./dist/node.d.mts",
37
41
  "import": "./dist/node.mjs",
38
42
  "default": "./dist/node.mjs"
39
43
  },
44
+ "./reader": {
45
+ "types": "./dist/reader.d.mts",
46
+ "import": "./dist/reader.mjs",
47
+ "default": "./dist/reader.mjs"
48
+ },
40
49
  "./schemas": {
41
- "types": "./dist/schemas/index.d.ts",
50
+ "types": "./dist/schemas/index.d.mts",
42
51
  "import": "./dist/schemas/index.mjs",
43
52
  "default": "./dist/schemas/index.mjs"
44
53
  }
@@ -49,7 +58,7 @@
49
58
  "test:watch": "bun test --watch"
50
59
  },
51
60
  "type": "module",
52
- "types": "./dist/index.d.ts",
61
+ "types": "./dist/index.d.mts",
53
62
  "files": [
54
63
  "dist",
55
64
  "!**/*.tsbuildinfo"
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-operations-CGGNiuJk.d.mts","names":[],"sources":["../src/asset-types.ts","../src/types.ts","../src/base-content-index.ts","../src/block-index.ts","../src/data-index.ts","../src/data.ts","../src/site-index.ts","../src/site.ts","../src/content-api.interface.ts","../src/blocks.ts","../src/component-registry.types.ts","../src/content-utils.ts","../src/content-operations.ts"],"mappings":";;AAOA;;;;;UAAiB,UAAA;EACf,QAAA;EACA,YAAA;EACA,QAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,GAAA;EACA,UAAA;EACA,UAAA;EAII;EAFJ,MAAA;EAMe;EAJf,IAAA;AAAA;;UAIe,UAAA;EACf,IAAA;EACA,KAAA;AAAA;;UAIe,aAAA;EACf,MAAA,EAAQ,UAAA;EACR,OAAA;IAAW,IAAA;IAAc,IAAA;EAAA;AAAA;AAI3B;AAAA,UAAiB,cAAA;EACf,IAAA;EACA,IAAA;EACA,UAAA;EACA,QAAA,EAAU,cAAA;AAAA;;UAIK,iBAAA;EACf,GAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,UAAA;EACA,UAAA;EACA,YAAA;AAAA;;UAIe,iBAAA;EAAA,CACd,YAAA,WAAuB,iBAAA;AAAA;;;UCxDT,iBAAA;EACf,WAAA;EACA,SAAA;AAAA;AAAA,UAIe,QAAA;EACf,KAAA;IACE,IAAA;IACA,OAAA;IACA,OAAA;EAAA;AAAA;AAAA,cAKS,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCD,SAAA,WAAoB,UAAA,eAAyB,UAAA;AAAA,KAG7C,WAAA;AAAA,UAGK,WAAA;EACf,QAAA;EACA,GAAA;EACA,IAAA,GAAO,MAAA;AAAA;AAAA,UAIQ,WAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAIM,eAAA;EACf,EAAA;EACA,IAAA,EAAM,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B,QAAA,EAAU,aAAA,EAAe,IAAA,EAAM,gBAAA;;;;iBAyBlD,qBAAA,CACd,IAAA,EAAM,kBAAA,EACN,KAAA,EAAO,MAAA,SAAe,IAAA,GACtB,MAAA,EAAQ,MAAA,EACR,OAAA;EACE,eAAA,GAAkB,IAAA;EAClB,eAAA,GAAkB,UAAA,UAAoB,IAAA;AAAA,IAEvC,sBAAA;;;AX5JH;;cW2Sa,YAAA;EAAA;;;;;KAOD,WAAA,WAAsB,YAAA,eAA2B,YAAA;;;;;;;AXnS7D;;;;;;iBWiTgB,kBAAA,CAAmB,IAAA,EAAM,gBAAA,GAAmB,WAAA;;;;;iBAqB5C,6BAAA,CAA8B,IAAA,EAAM,gBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-BUG0Cfkg.mjs","names":[],"sources":["../src/blocks.ts","../src/content-utils.ts","../src/content-operations.ts","../src/site.ts","../src/types.ts"],"sourcesContent":["import type { BlockIndex } from './block-index';\nimport type { ContentAPI } from './content-api.interface';\nimport type { BlockFilters, ContentManifest, CreateBlockInput, CreateResult } from './types';\n\nexport class Blocks {\n constructor(\n private api: ContentAPI,\n private blockIndex: BlockIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: BlockFilters): Generator<ContentManifest> {\n // Choose the most efficient method based on filters\n if (filters?.collection) {\n if (filters.locales && filters.locales.length > 0) {\n // Filter by locales after getting collection entries\n for (const manifest of this.blockIndex.getManifestsByCollection(filters.collection)) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getManifestsByCollection(filters.collection);\n }\n } else if (filters?.locales && filters.locales.length > 0) {\n // For multiple locales, we need to check each\n for (const manifest of this.blockIndex.getAllManifests()) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getAllManifests();\n }\n }\n\n // Get all block collections\n get collections(): Set<string> {\n return this.blockIndex.collections;\n }\n\n // Block operations (returns null if not found)\n getByName(collection: string, name: string, locale?: string): ContentManifest | null {\n return this.blockIndex.getByName(collection, name, locale);\n }\n\n // Check if block name is available\n isNameAvailable(collection: string, name: string, excludeId?: string): boolean {\n const existing = this.getByName(collection, name);\n return !existing || existing.id === excludeId;\n }\n\n // Get the ID of content that conflicts with a block name\n getNameConflict(collection: string, name: string, excludeId?: string): string | null {\n const existing = this.getByName(collection, name);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if block name is valid\n isBlockNameValid(blockName: string): boolean {\n // Block names must not be empty\n if (!blockName || blockName.trim() === '') {\n return false;\n }\n\n // Block names must not contain dots (would interfere with locale suffixes)\n if (blockName.includes('.')) {\n return false;\n }\n\n // Block names must not contain path separators\n if (blockName.includes('/') || blockName.includes('\\\\')) {\n return false;\n }\n\n // Block names should only contain alphanumeric, hyphens, underscores\n return /^[a-zA-Z0-9_-]+$/.test(blockName);\n }\n\n // Create block with name validation\n async create(data: CreateBlockInput): Promise<CreateResult> {\n // Validate block name\n if (!this.isBlockNameValid(data.name)) {\n return {\n success: false,\n reason: 'invalid_name',\n error: new Error(`Invalid block name: ${data.name}`),\n };\n }\n\n // Check if name is already taken in any locale\n const existing = this.getByName(data.collection, data.name);\n if (existing) {\n return {\n success: false,\n reason: 'name_taken',\n error: new Error(`Block name ${data.name} already exists in collection ${data.collection}`),\n };\n }\n\n // Create the content\n return this.api.createContent({\n kind: 'block',\n collection: data.collection,\n type: 'mdx',\n name: data.name,\n meta: data.meta,\n locales: data.locales,\n });\n }\n}\n","import { nanoid } from 'nanoid';\nimport yaml from 'yaml';\nimport type { ContentMeta, LocaleVersion } from './types';\n\nexport function* localesOf<T>(manifest: { locales: Record<string, T | undefined> }): Generator<T> {\n for (const value of Object.values(manifest.locales)) {\n if (value) yield value;\n }\n}\n\n/**\n * Pure utility functions for content operations\n * These functions don't depend on any class state and can be shared\n * between FileSystemContentAPI, InMemoryContentAPI, and other implementations\n */\n\n/**\n * Check if content is published based on publishAt/unpublishAt dates\n */\nexport function isContentPublished(\n localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>,\n now = new Date(),\n): boolean {\n if (localeVersion.publishAt) {\n const publishDate = new Date(localeVersion.publishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(publishDate.getTime()) && publishDate > now) return false;\n }\n\n if (localeVersion.unpublishAt) {\n const unpublishDate = new Date(localeVersion.unpublishAt);\n // Check for invalid dates (e.g., from empty strings or invalid values)\n if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;\n }\n\n return true;\n}\n\n/**\n * Validate that metadata doesn't exceed 4KB when serialized\n * This ensures efficient indexing as per the specification\n */\nexport function isMetadataTooLarge(meta: ContentMeta): boolean {\n const size = new TextEncoder().encode(JSON.stringify(meta)).length;\n return size > 4096;\n}\n\n/**\n * Extract block name from various sources\n * Used when displaying blocks in the UI\n */\nexport function extractBlockName(source: string): string {\n // If it's a collection/name path, extract the name part\n if (source.includes('/') && !source.includes('.')) {\n const parts = source.split('/');\n return parts[parts.length - 1];\n }\n\n // If it's a filename, extract the base name\n if (source.includes('.')) {\n const match = source.match(/^(.+?)\\.([a-z]{2})?\\.(mdx|vxjson)$/);\n if (match) {\n return match[1];\n }\n // Fallback: remove any extension\n return source.replace(/\\.[^.]+$/, '');\n }\n\n // If it's an ID, create a simple name\n if (source.startsWith('vx-')) {\n return `block-${source.substring(3, 8)}`;\n }\n\n // Otherwise return as-is\n return source;\n}\n\n/**\n * Validate block name according to the specification\n * - Cannot contain dots (reserved for locale separator)\n * - Cannot contain slashes (would create subdirectories)\n * - Cannot contain spaces (for clean filenames)\n * - Must have at least one character\n */\nexport function isValidBlockName(name: string): boolean {\n if (!name || name.length === 0) return false;\n if (name.includes('.')) return false;\n if (name.includes('/')) return false;\n if (name.includes(' ')) return false;\n return true;\n}\n\n/**\n * Format file size for display with human-readable units\n * @example formatFileSize(1536) // \"1.5 KB\"\n */\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n/**\n * Calculate metadata size in bytes\n */\nexport function getMetadataSize(meta: ContentMeta): number {\n return new TextEncoder().encode(JSON.stringify(meta)).length;\n}\n\n/**\n * Check if a pathname is valid\n * - Must start with /\n * - Cannot contain spaces (should be URL-encoded)\n * - Cannot contain special characters that would break URLs\n */\nexport function isValidPathname(pathname: string): boolean {\n if (!pathname || !pathname.startsWith('/')) return false;\n if (pathname.includes(' ')) return false;\n if (pathname.includes('?') || pathname.includes('#')) return false;\n return true;\n}\n\n/**\n * Normalize a pathname to ensure consistency\n * - Ensure it starts with /\n * - Remove trailing slashes (except for root)\n * - Collapse multiple slashes\n */\nexport function normalizePathname(pathname: string): string {\n if (!pathname) return '/';\n\n // Ensure it starts with /\n if (!pathname.startsWith('/')) {\n pathname = '/' + pathname;\n }\n\n // Collapse multiple slashes\n pathname = pathname.replace(/\\/+/g, '/');\n\n // Remove trailing slash unless it's the root\n if (pathname !== '/' && pathname.endsWith('/')) {\n pathname = pathname.slice(0, -1);\n }\n\n return pathname;\n}\n\n/**\n * Generate a content ID in the standard format\n * IDs are prefixed with \"vx-\" followed by 8 random characters\n */\nexport function generateContentId(): string {\n return `vx-${nanoid(8)}`;\n}\n\n/**\n * Get the current date/time in ISO format\n * Used for timestamps in content files\n */\nexport function getCurrentISODate(): string {\n return new Date().toISOString();\n}\n\n/**\n * Parse a date string safely\n * Returns null if invalid\n */\nexport function parseDate(dateStr: string | undefined): Date | null {\n if (!dateStr) return null;\n\n try {\n const date = new Date(dateStr);\n if (isNaN(date.getTime())) return null;\n return date;\n } catch {\n return null;\n }\n}\n\n/**\n * Creates a V8-optimized object by mapping site names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param sitesConfig - Sites configuration containing site names\n * @param factory - Function that creates the value for each site\n * @returns Object with all sites initialized in alphabetical order\n */\nexport function mapSiteNames<T>(\n sitesConfig: { sites: Record<string, any> },\n factory: (siteName: string) => T,\n): Record<string, T> {\n const obj: Record<string, T> = {};\n // Object.keys returns keys in insertion order, which is stable for a given object\n for (const siteName of Object.keys(sitesConfig.sites)) {\n obj[siteName] = factory(siteName);\n }\n return obj;\n}\n\n/**\n * Creates a V8-optimized object by mapping locale names to values.\n * Ensures all objects have the same hidden class by adding properties in consistent order.\n *\n * @param locales - Array of locale codes\n * @param factory - Function that creates the value for each locale\n * @returns Object with all locales initialized in array order\n */\nexport function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T> {\n const obj: Record<string, T> = {};\n for (const locale of locales) {\n obj[locale] = factory(locale);\n }\n return obj;\n}\n\n/**\n * Resolves a publish date value to a valid string or undefined.\n * Handles various input types including null, false, and empty strings.\n *\n * @param updateValue - The value being updated (string | null | false | undefined)\n * @param currentValue - The current value to fall back to if updateValue is undefined\n * @returns A valid date string or undefined\n */\nexport function resolvePublishDate(\n updateValue: string | null | false | undefined,\n currentValue: string | undefined,\n): string | undefined {\n // If updateValue is explicitly provided (including null/false), use it\n if (updateValue !== undefined) {\n // Only return string values, treat null/false/empty as undefined\n return updateValue && typeof updateValue === 'string' ? updateValue : undefined;\n }\n // Otherwise keep the current value\n return currentValue;\n}\n\n/**\n * Serializes MDX content with frontmatter.\n * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure\n * consistent MDX output that includes frontmatter for variable access.\n *\n * @param frontmatterData - The frontmatter data to serialize\n * @param mdxContent - The MDX content (without frontmatter)\n * @returns Complete MDX file content with frontmatter\n */\nexport function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string {\n // Use yaml library for proper serialization\n const yamlStr = yaml.stringify(frontmatterData);\n return `---\\n${yamlStr}---\\n\\n${mdxContent}`;\n}\n","import sortKeys from 'sort-keys';\nimport type { Blocks } from './blocks';\nimport { generateContentId, isContentPublished } from './content-utils';\nimport type { Site } from './site';\nimport type { ContentMeta, CreateContentInput, LocaleUpdateData, LocaleVersion } from './types';\n\n/**\n * Shared business logic for content operations\n * Used by both FileSystemContentAPI and InMemoryContentAPI\n */\n\n// Validation result types\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n sortedMeta?: ContentMeta;\n size?: number;\n}\n\nexport interface CreateValidationResult {\n valid: boolean;\n error?: string;\n reason?: 'metadata_too_large' | 'pathname_taken' | 'pathname_in_redirects' | 'invalid_name' | 'name_taken';\n existingId?: string;\n}\n\n/**\n * Validate and prepare metadata for storage\n * Ensures title exists and metadata doesn't exceed 4KB\n */\nexport function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult {\n // Ensure title is present\n if (!meta.title) {\n return {\n valid: false,\n error: 'Title is required in metadata',\n };\n }\n\n const sortedMeta = sortKeys(meta, { deep: true }) as ContentMeta; // We've validated title exists\n const metaJson = JSON.stringify(sortedMeta, null, 2);\n const metaSize = new TextEncoder().encode(metaJson).length;\n\n if (metaSize > 4088) {\n // Leave 8 bytes for safety\n return {\n valid: false,\n error: `Metadata exceeds 4KB limit (${metaSize} bytes)`,\n };\n }\n\n return {\n valid: true,\n sortedMeta,\n size: metaSize,\n };\n}\n\n/**\n * Build pathname history update\n */\nexport function buildPathnameHistory(\n oldPathname: string | undefined,\n newPathname: string | undefined,\n isPublished: boolean,\n now: string,\n): Record<string, string> {\n const history: Record<string, string> = {};\n\n if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) {\n history[oldPathname] = now;\n }\n\n return history;\n}\n\n/**\n * Build a locale manifest\n */\nexport function buildLocaleVersion(params: {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n meta: ContentMeta;\n kind: 'block' | 'page' | 'data';\n publishAt?: string;\n unpublishAt?: string;\n pathname?: string;\n name?: string;\n previousPathnames?: Record<string, string>;\n}): LocaleVersion {\n const manifest: LocaleVersion = {\n locale: params.locale,\n etag: params.etag,\n created: params.created,\n modified: params.modified,\n meta: params.meta,\n };\n\n // Add optional fields only if they exist\n if (params.publishAt) {\n manifest.publishAt = params.publishAt;\n }\n if (params.unpublishAt) {\n manifest.unpublishAt = params.unpublishAt;\n }\n if (params.pathname && params.kind === 'page') {\n manifest.pathname = params.pathname;\n }\n if (params.name && (params.kind === 'block' || params.kind === 'data')) {\n manifest.name = params.name;\n }\n if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) {\n manifest.previousPathnames = params.previousPathnames;\n }\n\n return manifest;\n}\n\n/**\n * Update publish dates on a locale manifest\n */\nexport function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void {\n // Handle publishAt\n if ('publishAt' in data) {\n if (data.publishAt && typeof data.publishAt === 'string') {\n manifest.publishAt = data.publishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.publishAt;\n }\n }\n\n // Handle unpublishAt\n if ('unpublishAt' in data) {\n if (data.unpublishAt && typeof data.unpublishAt === 'string') {\n manifest.unpublishAt = data.unpublishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.unpublishAt;\n }\n }\n}\n\n/**\n * Validate content creation data\n */\nexport function validateCreateContent(\n data: CreateContentInput,\n sites: Record<string, Site>,\n blocks: Blocks,\n dataApi?: {\n isDataNameValid: (name: string) => boolean;\n getNameConflict: (collection: string, name: string) => string | null;\n },\n): CreateValidationResult {\n // Validate metadata for all locales\n for (const localeData of Object.values(data.locales)) {\n const meta = { ...data.meta, ...localeData.meta };\n const validation = validateAndPrepareMetadata(meta);\n if (!validation.valid) {\n return {\n valid: false,\n error: validation.error,\n reason: 'metadata_too_large',\n };\n }\n }\n\n // Validate pathname for pages\n if (data.kind === 'page') {\n if (!data.site) {\n return {\n valid: false,\n error: 'Site is required for pages',\n };\n }\n\n const site = sites[data.site];\n if (!site) {\n return {\n valid: false,\n error: `Site ${data.site} not found`,\n };\n }\n\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const pathname = localeData.pathname;\n\n // Pathname is required for pages\n if (!pathname) {\n return {\n valid: false,\n error: `Pathname is required for pages (locale: ${locale})`,\n };\n }\n\n // Check if pathname is already taken\n const existingId = site.getPathnameConflict(pathname, locale);\n if (existingId) {\n return {\n valid: false,\n error: `Pathname ${pathname} already exists`,\n reason: 'pathname_taken',\n existingId,\n };\n }\n\n // Check if pathname is in redirects\n if (site.isPathnameInRedirects(pathname, locale)) {\n return {\n valid: false,\n error: `Pathname ${pathname} is already in use as a redirect`,\n reason: 'pathname_in_redirects',\n };\n }\n }\n }\n\n // Validate block name uniqueness\n if (data.kind === 'block') {\n if (!data.name) {\n return {\n valid: false,\n error: 'Block name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate block name format\n if (!blocks.isBlockNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = blocks.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Block name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n // Validate data entry name uniqueness\n if (data.kind === 'data' && dataApi) {\n if (!data.name) {\n return {\n valid: false,\n error: 'Data name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate data name format\n if (!dataApi.isDataNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = dataApi.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Data name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Generate a new content ID\n */\nexport { generateContentId };\n\n/**\n * Check if content is published\n */\nexport { isContentPublished };\n\n/**\n * Update scope bit flags\n * Can be combined with bitwise OR and checked with bitwise AND\n */\nexport const UPDATE_SCOPE = {\n NONE: 0, // 00\n META: 1 << 0, // 01\n CONTENT: 1 << 1, // 10\n BOTH: 3, // 11 (META | CONTENT)\n} as const;\n\nexport type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];\n\n/**\n * Determine what parts of content are being updated\n * Returns bit flags that can be checked with bitwise AND\n *\n * Example usage:\n * ```\n * const scope = analyzeUpdateScope(data);\n * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }\n * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }\n * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }\n * ```\n */\nexport function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope {\n let scope = UPDATE_SCOPE.NONE;\n\n // Note: pathname is NOT considered a metadata change because:\n // - For pages, pathname is derived from file path, not stored in metadata\n // - Pathname changes don't affect the metadata hash in the ETag\n if (data.meta !== undefined || data.publishAt !== undefined || data.unpublishAt !== undefined) {\n scope |= UPDATE_SCOPE.META;\n }\n\n if (data.content !== undefined) {\n scope |= UPDATE_SCOPE.CONTENT;\n }\n\n return scope;\n}\n\n/**\n * Determine whether the modified timestamp should be updated\n * Updates for ANY change - either metadata or content\n */\nexport function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean {\n const scope = analyzeUpdateScope(data);\n return scope !== UPDATE_SCOPE.NONE;\n}\n","import type { ContentAPI } from './content-api.interface';\nimport { localesOf } from './content-utils';\nimport type { SiteIndex } from './site-index';\nimport type { ContentManifest, CreatePageInput, CreateResult, MoveResult, SiteFilters } from './types';\n\nexport class Site {\n constructor(\n private siteName: string,\n private api: ContentAPI,\n private siteIndex: SiteIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: SiteFilters): Generator<ContentManifest> {\n // Get the base manifests using the most efficient method\n let manifests: Generator<ContentManifest>;\n\n if (filters?.locales && filters.locales.length === 1) {\n manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);\n } else {\n manifests = this.siteIndex.getAllManifests();\n }\n\n // Apply additional filters if needed\n if (filters?.collection || filters?.type || filters?.published !== undefined) {\n for (const manifest of manifests) {\n if (filters.collection && manifest.collection !== filters.collection) continue;\n if (filters.type && manifest.type !== filters.type) continue;\n if (filters.published !== undefined) {\n // Check if any locale is published\n let hasPublishedLocale = false;\n for (const locale of localesOf(manifest)) {\n if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {\n hasPublishedLocale = true;\n break;\n }\n }\n if (filters.published !== hasPublishedLocale) continue;\n }\n yield manifest;\n }\n } else {\n // No additional filters, yield all manifests\n yield* manifests;\n }\n }\n\n // List pages (convenience method for middleware)\n *listPages(locale?: string): Generator<ContentManifest> {\n const filters: SiteFilters = {};\n if (locale) filters.locales = [locale];\n\n yield* this.listContent(filters);\n }\n\n // Get all collections for this site\n get collections(): Set<string> {\n return this.siteIndex.collections;\n }\n\n // Pathname operations (returns null if available, ContentManifest if taken)\n getByPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPathname(pathname, locale);\n }\n\n // Get by previous pathname (for redirects)\n getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname, locale);\n }\n\n // Move content (handles rename + redirect tracking)\n async move(id: string, locale: string, newPathname: string): Promise<MoveResult> {\n // Check if new pathname is available\n const existing = this.getByPathname(newPathname, locale);\n if (existing && existing.id !== id) {\n return {\n moved: false,\n reason: 'already_exists',\n };\n }\n\n // Get current content\n const content = await this.api.getLocalized(id, locale);\n if (!content) {\n return {\n moved: false,\n reason: 'not_found',\n };\n }\n\n // Update with new pathname (this will handle previousPathnames)\n const updateResult = await this.api.updateLocalized({\n id,\n locale,\n data: {\n pathname: newPathname,\n meta: content.localized.meta,\n },\n etag: content.localized.etag,\n });\n\n if (!updateResult.success) {\n return {\n moved: false,\n reason: updateResult.reason,\n error: updateResult.error,\n };\n }\n\n return {\n moved: true,\n previousPathname: content.localized.pathname,\n etag: updateResult.etag,\n };\n }\n\n // Check if pathname is in redirect history\n getRedirect(pathname: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname);\n }\n\n // Validate pathname is available (not taken or in redirects)\n isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean {\n // Check if pathname is already taken\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return false;\n }\n\n // Check if pathname is in redirects\n const redirect = this.getByPreviousPathname(pathname, locale);\n if (redirect && redirect.id !== excludeId) {\n return false;\n }\n\n return true;\n }\n\n // Get the ID of content that conflicts with a pathname\n getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null {\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if pathname is in redirects\n isPathnameInRedirects(pathname: string, locale: string): boolean {\n return this.getByPreviousPathname(pathname, locale) !== null;\n }\n\n // Create page with validation\n async create(data: CreatePageInput): Promise<CreateResult> {\n // Validate pathname availability for all locales\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const existing = this.getByPathname(localeData.pathname, locale);\n if (existing) {\n return {\n success: false,\n reason: 'pathname_taken',\n error: new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`),\n };\n }\n\n // Check redirects too\n const redirect = this.getRedirect(localeData.pathname);\n if (redirect) {\n return {\n success: false,\n reason: 'pathname_in_redirects',\n error: new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`),\n };\n }\n }\n\n return this.api.createContent({\n kind: 'page',\n site: this.siteName,\n collection: data.collection,\n type: 'puck',\n locales: data.locales,\n });\n }\n}\n","export interface ContentAPIOptions {\n contentRoot: string;\n canvasDir?: string;\n}\n\n// Error response format for all API errors\nexport interface APIError {\n error: {\n code: string; // Machine-readable error code (e.g., 'CONTENT_NOT_FOUND', 'STALE_WRITE')\n message: string; // Human-readable error message\n details?: any; // Optional additional error details\n };\n}\n\n// Common error codes\nexport const ErrorCodes = {\n // Content errors\n CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',\n LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',\n COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',\n SITE_NOT_FOUND: 'SITE_NOT_FOUND',\n\n // Write errors\n STALE_WRITE: 'STALE_WRITE',\n ALREADY_EXISTS: 'ALREADY_EXISTS',\n PATHNAME_TAKEN: 'PATHNAME_TAKEN',\n NAME_TAKEN: 'NAME_TAKEN',\n METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',\n WRITE_ERROR: 'WRITE_ERROR',\n\n // Validation errors\n MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',\n INVALID_LOCALE: 'INVALID_LOCALE',\n INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',\n INVALID_REQUEST: 'INVALID_REQUEST',\n\n // System errors\n INTERNAL_ERROR: 'INTERNAL_ERROR',\n FETCH_ERROR: 'FETCH_ERROR',\n\n // Git errors\n GIT_NOT_REPO: 'GIT_NOT_REPO',\n GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',\n GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',\n GIT_PULL_FAILED: 'GIT_PULL_FAILED',\n GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',\n\n // Asset errors\n ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',\n ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',\n ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',\n ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n// Content type - the format of the content\nexport type ContentType = 'puck' | 'mdx' | 'json';\n\n// Content data - the actual content (puck, mdx, or json data)\nexport interface ContentData {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n}\n\n// Content property that extends manifests with actual content\nexport interface ContentProp {\n content: ContentData;\n}\n\n// Base identity fields shared by all content representations\nexport interface ContentIdentity {\n id: string;\n type: ContentType;\n kind: 'block' | 'page' | 'data';\n site?: string; // Only for pages\n collection: string;\n}\n\n// Locale file data derived from file path\nexport interface LocalePathData {\n locale: string;\n pathname?: string; // pages only - derived from file path\n name?: string; // blocks only - derived from filename\n}\n\n// Localized content manifest - metadata about translated content without the actual content\nexport interface LocaleVersion extends LocalePathData {\n etag: string; // Format: \"metaEtag.contentEtag\"\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>; // pages only\n meta: ContentMeta; // title, description, seo, etc.\n}\n\n// Manifest for all locales (what's in the index and returned in listings)\nexport interface ContentManifest extends ContentIdentity {\n locales: Record<string, LocaleVersion | undefined>;\n}\n\n// Single locale without content (used for updates/changes)\nexport interface LocalizedManifest extends ContentIdentity {\n localized: LocaleVersion;\n}\n\n// Single locale with content\nexport interface LocalizedEntry extends ContentIdentity {\n localized: LocaleVersion & ContentProp;\n}\n\n// All locales with content\nexport interface ContentEntry extends ContentManifest {\n locales: Record<string, LocaleVersion & ContentProp>;\n}\n\n// Result types\nexport interface UpdateResult {\n success: boolean;\n etag?: string;\n modified?: Date;\n reason?: 'not_found' | 'stale_write' | 'write_error';\n error?: Error;\n currentEtag?: string;\n conflictDetails?: {\n metaChanged: boolean;\n contentChanged: boolean;\n currentMeta?: ContentMeta;\n currentContent?: ContentData;\n localContent?: ContentData;\n };\n}\n\nexport interface MoveResult {\n moved: boolean;\n previousPathname?: string;\n files?: string[];\n reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error';\n error?: Error;\n etag?: string;\n}\n\nexport interface ContentListResult {\n items: ContentManifest[];\n total: number;\n hasMore?: boolean;\n}\n\n// Filter types\nexport interface GlobalFilters {\n site?: string;\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx' | 'json';\n published?: boolean;\n kind?: 'block' | 'page' | 'data';\n localization?: 'complete' | 'partial' | 'one';\n missingLocales?: string[];\n}\n\nexport interface SiteFilters {\n collection?: string;\n locales?: string[];\n type?: 'puck' | 'mdx';\n published?: boolean;\n}\n\nexport interface BlockFilters {\n collection?: string;\n locales?: string[];\n}\n\nexport interface FindOptions {\n excludeSites?: string[];\n includeUnpublished?: boolean;\n}\n\n// Input types\n\nexport interface CreateContentInput {\n kind: 'block' | 'page' | 'data';\n site?: string; // Required for pages, must be undefined for blocks and data\n collection: string;\n type: ContentType;\n created?: string; // Optional, will use current time if not provided\n name?: string; // Internal identifier for blocks and data (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults (applied to all locales)\n locales: {\n [locale: string]: {\n pathname?: string; // for pages (locale-specific route)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>;\n } & ContentProp;\n };\n}\n\nexport interface CreatePageInput {\n collection: string;\n locales: {\n [locale: string]: {\n pathname: string; // Required pathname for each locale\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta: ContentMeta; // Required metadata with title for each locale\n content: {\n puckData: any;\n };\n };\n };\n}\n\nexport interface CreateBlockInput {\n collection: string;\n type: 'mdx';\n name: string; // Internal identifier (same across all locales)\n meta?: Partial<ContentMeta>; // Shared metadata defaults\n locales: {\n [locale: string]: {\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: Partial<ContentMeta>; // Locale-specific metadata overrides\n content: {\n mdx: string;\n };\n };\n };\n}\n\nexport interface UpdateLocaleInput {\n id: string;\n locale: string;\n data: LocaleUpdateData;\n etag: string;\n}\n\nexport interface LocaleUpdateData {\n pathname?: string; // for pages - update pathname\n name?: string; // for blocks - update name (filename)\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n modified?: string; // Optional, will use current time if not provided\n meta?: Partial<ContentMeta>;\n content?: ContentData;\n}\n\nexport interface DeleteLocaleInput {\n id: string;\n locale: string;\n etag: string;\n}\n\n// Sites configuration\nexport interface SitesConfig {\n sites: {\n [siteName: string]: {\n locales: string[];\n defaultLocale: string;\n domains?: {\n [locale: string]: string;\n };\n };\n };\n globalLocales: string[];\n}\n\n// Batch operations\nexport interface BatchResult {\n operations: BatchOperationResult[];\n success: boolean; // true if all operations succeeded\n failed: number;\n updated: number; // number of successfully updated items\n}\n\n// Common metadata structure for all content types (stored in 'meta' field)\nexport interface ContentMeta {\n // Required\n title: string; // Display name for UI\n\n // Common optional fields\n description?: string;\n author?: string;\n tags?: string[];\n\n // SEO (mainly for pages)\n keywords?: string[];\n ogTitle?: string;\n ogDescription?: string;\n ogImage?: string;\n\n // Any additional fields from frontmatter/pageMeta\n [key: string]: any;\n}\n\n// File format types\n\n/**\n * VXJSON (Variant JSON) File Format\n *\n * VXJSON is a specialized JSON format that guarantees:\n * 1. The root is always an object (never an array or primitive)\n * 2. The \"content\" field always comes last in the object\n * 3. Field order is deterministic for consistent ETag calculation\n *\n * This format enables efficient streaming ETag calculation where metadata\n * can be hashed separately from content, supporting partial updates and\n * conflict resolution in CMS scenarios.\n *\n * Files using this format have the extension .vxjson\n */\nexport interface VXJSONFile {\n id: string;\n type: ContentType;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: ContentData; // Always last field in VXJSON\n}\n\nexport interface MDXFrontmatter {\n id: string;\n type: 'mdx';\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n meta: ContentMeta;\n}\n\n// All properties are declared in each variant to make destructuring safe and predictable\nexport type WriteResult =\n | { success: true; etag: string; modified?: Date; reason?: undefined; error?: undefined; currentEtag?: undefined }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'stale_write';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'already_exists';\n error?: undefined;\n currentEtag: string;\n }\n | {\n success: false;\n etag?: undefined;\n modified?: undefined;\n reason: 'write_error';\n error: Error;\n currentEtag?: string;\n };\n\nexport interface DeleteResult {\n success: boolean;\n error?: Error;\n reason?: 'stale_write' | 'not_found' | 'delete_error';\n currentEtag?: string;\n}\n\nexport interface CreateResult {\n success: boolean;\n id?: string;\n etag?: string;\n created?: Date;\n reason?:\n | 'already_exists'\n | 'write_error'\n | 'invalid_name'\n | 'name_taken'\n | 'pathname_taken'\n | 'pathname_in_redirects'\n | 'metadata_too_large';\n error?: Error;\n existingId?: string;\n}\n\nexport interface BatchOperationResult {\n id: string;\n locale: string;\n updated: boolean;\n error?: Error;\n etag?: string;\n}\n\n// Internal type for locale data returned by readLocaleFile\nexport interface LocaleFileData {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta: ContentMeta;\n content: {\n puckData?: any;\n mdx?: string;\n data?: Record<string, unknown>;\n };\n}\n"],"mappings":";;;;;AAIA,IAAa,SAAb,MAAoB;CAClB,YACE,AAAQ,KACR,AAAQ,YACR;EAFQ;EACA;;CAIV,CAAC,YAAY,SAAoD;AAE/D,MAAI,SAAS,WACX,KAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAE9C;QAAK,MAAM,YAAY,KAAK,WAAW,yBAAyB,QAAQ,WAAW,CACjF,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,WAAW,yBAAyB,QAAQ,WAAW;WAE5D,SAAS,WAAW,QAAQ,QAAQ,SAAS,GAEtD;QAAK,MAAM,YAAY,KAAK,WAAW,iBAAiB,CACtD,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,WAAW,iBAAiB;;CAK5C,IAAI,cAA2B;AAC7B,SAAO,KAAK,WAAW;;CAIzB,UAAU,YAAoB,MAAc,QAAyC;AACnF,SAAO,KAAK,WAAW,UAAU,YAAY,MAAM,OAAO;;CAI5D,gBAAgB,YAAoB,MAAc,WAA6B;EAC7E,MAAM,WAAW,KAAK,UAAU,YAAY,KAAK;AACjD,SAAO,CAAC,YAAY,SAAS,OAAO;;CAItC,gBAAgB,YAAoB,MAAc,WAAmC;EACnF,MAAM,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