@conloca/content-api 0.1.14 → 0.1.16
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/asset-manifest.d.ts +23 -0
- package/dist/asset-manifest.d.ts.map +1 -0
- package/dist/asset-manifest.js +73 -0
- package/dist/asset-operations.d.ts +159 -0
- package/dist/asset-operations.d.ts.map +1 -0
- package/dist/asset-operations.js +736 -0
- package/dist/asset-types.d.ts +56 -0
- package/dist/asset-types.d.ts.map +1 -0
- package/dist/asset-types.js +7 -0
- package/dist/base-content-index.d.ts +57 -0
- package/dist/base-content-index.d.ts.map +1 -0
- package/dist/base-content-index.js +179 -0
- package/dist/block-index.d.ts +9 -0
- package/dist/block-index.d.ts.map +1 -0
- package/dist/block-index.js +11 -0
- package/dist/blocks.d.ts +16 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +103 -0
- package/dist/cf-access.d.ts +31 -0
- package/dist/cf-access.d.ts.map +1 -0
- package/dist/cf-access.js +66 -0
- package/dist/component-registry.d.ts +50 -0
- package/dist/component-registry.d.ts.map +1 -0
- package/dist/component-registry.js +120 -0
- package/dist/component-registry.types-C0ctF9nh.d.mts +71 -0
- package/dist/component-registry.types-C0ctF9nh.d.mts.map +1 -0
- package/dist/component-registry.types.d.ts +11 -0
- package/dist/component-registry.types.d.ts.map +1 -0
- package/dist/component-registry.types.js +1 -0
- package/dist/content-api.interface.d.ts +64 -0
- package/dist/content-api.interface.d.ts.map +1 -0
- package/dist/content-api.interface.js +1 -0
- package/dist/content-filters.d.ts +31 -0
- package/dist/content-filters.d.ts.map +1 -0
- package/dist/content-filters.js +246 -0
- package/dist/content-index-D092_vk1.mjs +629 -0
- package/dist/content-index-D092_vk1.mjs.map +1 -0
- package/dist/content-index-D6IVMmAB.d.mts +127 -0
- package/dist/content-index-D6IVMmAB.d.mts.map +1 -0
- package/dist/content-index.d.ts +126 -0
- package/dist/content-index.d.ts.map +1 -0
- package/dist/content-index.js +418 -0
- package/dist/content-operations-DIbsxG5A.d.mts +354 -0
- package/dist/content-operations-DIbsxG5A.d.mts.map +1 -0
- package/dist/content-operations.d.ts +93 -0
- package/dist/content-operations.d.ts.map +1 -0
- package/dist/content-operations.js +275 -0
- package/dist/content-reader.d.ts +10 -0
- package/dist/content-reader.d.ts.map +1 -0
- package/dist/content-reader.js +13 -0
- package/dist/content-utils-fWNHTrPy.mjs +280 -0
- package/dist/content-utils-fWNHTrPy.mjs.map +1 -0
- package/dist/content-utils.d.ts +132 -0
- package/dist/content-utils.d.ts.map +1 -0
- package/dist/content-utils.js +352 -0
- package/dist/content-watcher.d.ts +43 -0
- package/dist/content-watcher.d.ts.map +1 -0
- package/dist/content-watcher.js +83 -0
- package/dist/data-DquNIEnQ.mjs +62 -0
- package/dist/data-DquNIEnQ.mjs.map +1 -0
- package/dist/data-index.d.ts +8 -0
- package/dist/data-index.d.ts.map +1 -0
- package/dist/data-index.js +7 -0
- package/dist/data.d.ts +43 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +103 -0
- package/dist/etag-utils.d.ts +77 -0
- package/dist/etag-utils.d.ts.map +1 -0
- package/dist/etag-utils.js +160 -0
- package/dist/filesystem-content-api-B1KIQJfk.mjs +2 -0
- package/dist/filesystem-content-api-C0HIhqZi.mjs +1620 -0
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
- package/dist/filesystem-content-api-DCdNi-co.d.mts +134 -0
- package/dist/filesystem-content-api-DCdNi-co.d.mts.map +1 -0
- package/dist/filesystem-content-api.d.ts +135 -0
- package/dist/filesystem-content-api.d.ts.map +1 -0
- package/dist/filesystem-content-api.js +2181 -0
- package/dist/git-operations.d.ts +49 -0
- package/dist/git-operations.d.ts.map +1 -0
- package/dist/git-operations.js +252 -0
- package/dist/header-parser.d.ts +37 -0
- package/dist/header-parser.d.ts.map +1 -0
- package/dist/header-parser.js +286 -0
- package/dist/in-memory-content-api.d.ts +35 -0
- package/dist/in-memory-content-api.d.ts.map +1 -0
- package/dist/in-memory-content-api.js +591 -0
- package/dist/index-DxVTFK66.d.mts +105 -0
- package/dist/index-DxVTFK66.d.mts.map +1 -0
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.mjs +37 -5
- package/dist/index.mjs.map +1 -1
- package/dist/indexing.d.mts +152 -0
- package/dist/indexing.d.mts.map +1 -0
- package/dist/indexing.d.ts +5 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +7 -0
- package/dist/indexing.mjs +255 -0
- package/dist/indexing.mjs.map +1 -0
- package/dist/json-whitespace-view.d.ts +32 -0
- package/dist/json-whitespace-view.d.ts.map +1 -0
- package/dist/json-whitespace-view.js +152 -0
- package/dist/middleware.d.ts +20 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +1031 -0
- package/dist/node.d.mts +28 -126
- package/dist/node.d.mts.map +1 -1
- package/dist/node.d.ts +25 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +24 -0
- package/dist/node.mjs +199 -2890
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +15 -0
- package/dist/reader.d.mts.map +1 -0
- package/dist/reader.d.ts +15 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +13 -0
- package/dist/reader.mjs +22 -0
- package/dist/reader.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2 -90
- package/dist/schemas/index.d.ts +102 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +87 -0
- package/dist/schemas/index.mjs +2 -70
- package/dist/schemas-CFRD0FIQ.mjs +84 -0
- package/dist/schemas-CFRD0FIQ.mjs.map +1 -0
- package/dist/{types-BUG0Cfkg.mjs → site-8oaj1Q60.mjs} +20 -222
- package/dist/site-8oaj1Q60.mjs.map +1 -0
- package/dist/site-index-B_254bCc.d.mts +136 -0
- package/dist/site-index-B_254bCc.d.mts.map +1 -0
- package/dist/site-index.d.ts +60 -0
- package/dist/site-index.d.ts.map +1 -0
- package/dist/site-index.js +287 -0
- package/dist/site.d.ts +21 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +168 -0
- package/dist/types-DOdldbfD.mjs +34 -0
- package/dist/types-DOdldbfD.mjs.map +1 -0
- package/dist/types-DjfhS272.d.mts +456 -0
- package/dist/types-DjfhS272.d.mts.map +1 -0
- package/dist/types.d.ts +453 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +36 -0
- package/dist/url-safe-base64.d.ts +12 -0
- package/dist/url-safe-base64.d.ts.map +1 -0
- package/dist/url-safe-base64.js +40 -0
- package/dist/url-validation.d.ts +14 -0
- package/dist/url-validation.d.ts.map +1 -0
- package/dist/url-validation.js +81 -0
- package/dist/utils/atomic-write.d.ts +6 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +20 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/vite-plugin.d.ts +12 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +29 -0
- package/dist/vxjson-qHrgLGip.mjs +555 -0
- package/dist/vxjson-qHrgLGip.mjs.map +1 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs +34 -0
- package/dist/vxjson-serialize-geF6qvpn.mjs.map +1 -0
- package/dist/vxjson-serialize.d.mts +17 -0
- package/dist/vxjson-serialize.d.mts.map +1 -0
- package/dist/vxjson-serialize.d.ts +14 -0
- package/dist/vxjson-serialize.d.ts.map +1 -0
- package/dist/vxjson-serialize.js +50 -0
- package/dist/vxjson-serialize.mjs +2 -0
- package/dist/vxjson.d.ts +112 -0
- package/dist/vxjson.d.ts.map +1 -0
- package/dist/vxjson.js +391 -0
- package/dist/xxhash.d.ts +10 -0
- package/dist/xxhash.d.ts.map +1 -0
- package/dist/xxhash.js +31 -0
- package/package.json +88 -17
- package/dist/content-operations-BZLfJWqT.d.mts +0 -916
- package/dist/content-operations-BZLfJWqT.d.mts.map +0 -1
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/types-BUG0Cfkg.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DxVTFK66.d.mts","names":[],"sources":["../src/schemas/index.ts"],"mappings":";;;;;;;cASa,oBAAkB,EAAA;;;;;;;;GAQ7B,EAAA,KAAA;KAEU,eAAe,EAAE,aAAa;;;;;cAM7B,gBAAc,EAAA;;;;;;;;;;GAGzB,EAAA,KAAA;KAEU,WAAW,EAAE,aAAa;;;;;;cASzB,qBAAmB,EAAA;;;;;GAK9B,EAAA,KAAA;KAEU,gBAAgB,EAAE,aAAa;;;;;cAM9B,iBAAe,EAAA;;;;;;;;GAI1B,EAAA,KAAA;KAEU,YAAY,EAAE,aAAa;;;;;;;;;;;cAc1B,0BAAwB,EAAA;;;;GAMrB,EAAA,KAAA;KAEJ,qBAAqB,EAAE,aAAa;;;;;;cASnC,oBAAkB,EAAA;;;;;GAK7B,EAAA,KAAA;KAEU,eAAe,EAAE,aAAa;;;;;cAM7B,gBAAc,EAAA;;;;;;;;;GAQzB,EAAA,KAAA;KAEU,WAAW,EAAE,aAAa"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { a as AssetManifestData, c as FolderTreeNode, i as AssetEntry, l as ManifestEntryData, n as ComponentEntryWithId, o as AssetUsage, r as ComponentRegistry, s as FolderListing, t as ComponentEntry } from "./component-registry.types-C0ctF9nh.mjs";
|
|
2
|
+
import { A as LocalizedEntry, B as VXJSONFile, C as ErrorCodes, D as LocalePathData, E as LocaleFileData, F as PageReference, I as SiteFilters, L as SitesConfig, M as MDXCompileResponse, N as MDXFrontmatter, O as LocaleUpdateData, P as MoveResult, R as UpdateLocaleInput, S as ErrorCode, T as GlobalFilters, V as WriteResult, _ as CreateResult, a as ContentAPIOptions, b as DeleteLocaleInput, c as ContentIdentity, d as ContentMeta, f as ContentProp, g as CreatePageInput, h as CreateContentInput, i as BlockFilters, j as LocalizedManifest, k as LocaleVersion, l as ContentListResult, m as CreateBlockInput, n as BatchOperationResult, o as ContentData, p as ContentType, r as BatchResult, s as ContentEntry, t as APIError, u as ContentManifest, v as DataCollectionEntry, w as FindOptions, x as DeleteResult, y as DataContext, z as UpdateResult } from "./types-DjfhS272.mjs";
|
|
3
|
+
import { A as serializeMdxWithFrontmatter, C as localesOf, D as normalizePathname, E as normalizeAndValidatePathname, M as ContentAPI, N as Site, O as parseDate, S as isValidPathname, T as mapSiteNames, _ as getCurrentISODate, a as analyzeUpdateScope, b as isMetadataTooLarge, c as shouldUpdateModifiedTimestamp, d as validateCreateContent, f as PathnameValidationReason, g as generateContentId, h as formatFileSize, i as ValidationResult, j as Blocks, k as resolvePublishDate, l as updatePublishDates, m as extractBlockName, n as UPDATE_SCOPE, o as buildLocaleVersion, p as PathnameValidationResult, r as UpdateScope, s as buildPathnameHistory, t as CreateValidationResult, u as validateAndPrepareMetadata, v as getMetadataSize, w as mapLocales, x as isValidBlockName, y as isContentPublished } from "./content-operations-DIbsxG5A.mjs";
|
|
4
|
+
import { t as ContentIndex } from "./content-index-D6IVMmAB.mjs";
|
|
5
|
+
import { a as MdxPageFrontmatter, c as blockEditableSchema, d as dataMetaSchema, f as mdxPageFrontmatterSchema, i as DataMeta, l as blockMetaSchema, m as pageMetaSchema, n as BlockMeta, o as PageEditable, p as pageEditableSchema, r as DataEditable, s as PageMeta, t as BlockEditable, u as dataEditableSchema } from "./index-DxVTFK66.mjs";
|
|
4
6
|
//#region src/git-operations.d.ts
|
|
5
7
|
interface GitStatus {
|
|
6
8
|
isRepo: boolean;
|
|
@@ -74,5 +76,5 @@ declare const ContentUtils: {
|
|
|
74
76
|
};
|
|
75
77
|
};
|
|
76
78
|
//#endregion
|
|
77
|
-
export { APIError, type AssetEntry, type AssetManifestData, type AssetUsage, BatchOperationResult, BatchResult, BlockEditable, BlockFilters, BlockMeta, Blocks, ComponentEntry, ComponentEntryWithId, ComponentRegistry, type ContentAPI, ContentAPIOptions, ContentData, ContentEntry, ContentIdentity, ContentListResult, ContentManifest, ContentMeta, ContentProp, ContentType, ContentUtils, CreateBlockInput, CreateContentInput, CreatePageInput, CreateResult, CreateValidationResult, DataCollectionEntry, DataContext, DataEditable, DataMeta, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FindOptions, type FolderListing, type FolderTreeNode, type GitCommitResult, type GitPullResult, type GitPushResult, type GitStatus, GlobalFilters, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXFrontmatter, type ManifestEntryData, MoveResult, PageEditable, PageMeta, PageReference, Site, SiteFilters, SitesConfig, UPDATE_SCOPE, UpdateLocaleInput, UpdateResult, UpdateScope, VXJSONFile, ValidationResult, WriteResult, analyzeUpdateScope, blockEditableSchema, blockMetaSchema, buildLocaleVersion, buildPathnameHistory, dataEditableSchema, dataMetaSchema, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizePathname, pageEditableSchema, pageMetaSchema, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
|
|
79
|
+
export { APIError, type AssetEntry, type AssetManifestData, type AssetUsage, BatchOperationResult, BatchResult, BlockEditable, BlockFilters, BlockMeta, Blocks, ComponentEntry, ComponentEntryWithId, ComponentRegistry, type ContentAPI, ContentAPIOptions, ContentData, ContentEntry, ContentIdentity, ContentIndex, ContentListResult, ContentManifest, ContentMeta, ContentProp, ContentType, ContentUtils, CreateBlockInput, CreateContentInput, CreatePageInput, CreateResult, CreateValidationResult, DataCollectionEntry, DataContext, DataEditable, DataMeta, DeleteLocaleInput, DeleteResult, ErrorCode, ErrorCodes, FindOptions, type FolderListing, type FolderTreeNode, type GitCommitResult, type GitPullResult, type GitPushResult, type GitStatus, GlobalFilters, LocaleFileData, LocalePathData, LocaleUpdateData, LocaleVersion, LocalizedEntry, LocalizedManifest, MDXCompileResponse, MDXFrontmatter, type ManifestEntryData, MdxPageFrontmatter, MoveResult, PageEditable, PageMeta, PageReference, PathnameValidationReason, PathnameValidationResult, Site, SiteFilters, SitesConfig, UPDATE_SCOPE, UpdateLocaleInput, UpdateResult, UpdateScope, VXJSONFile, ValidationResult, WriteResult, analyzeUpdateScope, blockEditableSchema, blockMetaSchema, buildLocaleVersion, buildPathnameHistory, dataEditableSchema, dataMetaSchema, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, mdxPageFrontmatterSchema, normalizeAndValidatePathname, normalizePathname, pageEditableSchema, pageMetaSchema, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
|
|
78
80
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/git-operations.ts","../src/utils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/git-operations.ts","../src/utils.ts"],"mappings":";;;;;;UAIiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;;;;;;;cC1BW;;;;;;;;;EASa,cAAA;;;;;;;;EAYE,gBAAA;;;;;;;EAUF,cAAA,kBAAM,gBAAgB;;;;EAUpB,eAAA,sBAAW,YAAY;;;;EAqBzB,cAAA;;;;EAOA,cAAA;IACtB;IACA;IACA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe exports for @conloca/content-api
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for browser environments.
|
|
5
|
+
* For Node.js-specific APIs (filesystem, in-memory, middleware, etc.), import from '@conloca/content-api/node'
|
|
6
|
+
*/
|
|
7
|
+
export type { AssetEntry, AssetManifestData, AssetUsage, FolderListing, FolderTreeNode, ManifestEntryData, } from './asset-types';
|
|
8
|
+
export { Blocks } from './blocks';
|
|
9
|
+
export * from './component-registry.types';
|
|
10
|
+
export type { ContentAPI } from './content-api.interface';
|
|
11
|
+
export { ContentIndex } from './content-index';
|
|
12
|
+
export * from './content-operations';
|
|
13
|
+
export * from './content-utils';
|
|
14
|
+
export type { GitCommitResult, GitPullResult, GitPushResult, GitStatus } from './git-operations';
|
|
15
|
+
export * from './schemas';
|
|
16
|
+
export { Site } from './site';
|
|
17
|
+
export * from './types';
|
|
18
|
+
export { ContentUtils } from './utils';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAEhC,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjG,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe exports for @conloca/content-api
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for browser environments.
|
|
5
|
+
* For Node.js-specific APIs (filesystem, in-memory, middleware, etc.), import from '@conloca/content-api/node'
|
|
6
|
+
*/
|
|
7
|
+
// Browser-safe exports
|
|
8
|
+
export { Blocks } from './blocks';
|
|
9
|
+
export * from './component-registry.types';
|
|
10
|
+
export { ContentIndex } from './content-index';
|
|
11
|
+
export * from './content-operations';
|
|
12
|
+
export * from './content-utils';
|
|
13
|
+
export * from './schemas';
|
|
14
|
+
export { Site } from './site';
|
|
15
|
+
export * from './types';
|
|
16
|
+
export { ContentUtils } from './utils';
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { a as buildPathnameHistory, c as validateAndPrepareMetadata, i as buildLocaleVersion, l as validateCreateContent, n as UPDATE_SCOPE, o as shouldUpdateModifiedTimestamp, r as analyzeUpdateScope, s as updatePublishDates, t as Site, u as Blocks } from "./site-8oaj1Q60.mjs";
|
|
2
|
+
import { _ as serializeMdxWithFrontmatter, a as getMetadataSize, c as isValidBlockName, d as mapLocales, f as mapSiteNames, g as resolvePublishDate, h as parseDate, i as getCurrentISODate, l as isValidPathname, m as normalizePathname, n as formatFileSize, o as isContentPublished, p as normalizeAndValidatePathname, r as generateContentId, s as isMetadataTooLarge, t as extractBlockName, u as localesOf } from "./content-utils-fWNHTrPy.mjs";
|
|
3
|
+
import { t as ContentIndex } from "./content-index-D092_vk1.mjs";
|
|
4
|
+
import { a as mdxPageFrontmatterSchema, i as dataMetaSchema, n as blockMetaSchema, o as pageEditableSchema, r as dataEditableSchema, s as pageMetaSchema, t as blockEditableSchema } from "./schemas-CFRD0FIQ.mjs";
|
|
5
|
+
import { t as ErrorCodes } from "./types-DOdldbfD.mjs";
|
|
4
6
|
//#region src/utils.ts
|
|
5
7
|
/**
|
|
6
8
|
* Utilities for working with suffix pattern as specified in 04-cms-api.md
|
|
7
9
|
*/
|
|
8
10
|
const ContentUtils = {
|
|
11
|
+
/**
|
|
12
|
+
* Extract locale from filename
|
|
13
|
+
* @example
|
|
14
|
+
* - about.en.vxjson → 'en'
|
|
15
|
+
* - about.nl.vxjson → 'nl'
|
|
16
|
+
* - hero-main.mdx → 'en' (default)
|
|
17
|
+
* - hero-main.nl.mdx → 'nl'
|
|
18
|
+
*/
|
|
9
19
|
extractLocale(filename) {
|
|
10
20
|
return filename.match(/\.([a-z]{2})\.(vxjson|mdx)$/)?.[1] || "en";
|
|
11
21
|
},
|
|
22
|
+
/**
|
|
23
|
+
* Get base path without locale and extension
|
|
24
|
+
* @example
|
|
25
|
+
* - about.en.vxjson → 'about'
|
|
26
|
+
* - about.nl.vxjson → 'about'
|
|
27
|
+
* - hero-main.mdx → 'hero-main'
|
|
28
|
+
*/
|
|
12
29
|
extractBasePath(filename) {
|
|
13
30
|
return filename.replace(/\.([a-z]{2})?\.(vxjson|mdx)$/, "").replace(/\.(vxjson|mdx)$/, "");
|
|
14
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* Build filename from base path and locale
|
|
34
|
+
* @example
|
|
35
|
+
* - ('about', 'en') → 'about.en.vxjson'
|
|
36
|
+
* - ('about', 'nl') → 'about.nl.vxjson'
|
|
37
|
+
*/
|
|
15
38
|
buildFilename(basePath, locale, extension = "vxjson") {
|
|
16
39
|
if (locale === "en" && extension === "vxjson") return `${basePath}.${extension}`;
|
|
17
40
|
return `${basePath}.${locale}.${extension}`;
|
|
18
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* Group files by base path for i18n
|
|
44
|
+
*/
|
|
19
45
|
groupByContent(filenames) {
|
|
20
46
|
const groups = /* @__PURE__ */ new Map();
|
|
21
47
|
for (const filename of filenames) {
|
|
@@ -27,9 +53,15 @@ const ContentUtils = {
|
|
|
27
53
|
}
|
|
28
54
|
return groups;
|
|
29
55
|
},
|
|
56
|
+
/**
|
|
57
|
+
* Check if a file is a content file (vxjson or mdx)
|
|
58
|
+
*/
|
|
30
59
|
isContentFile(filename) {
|
|
31
60
|
return /\.(vxjson|mdx)$/.test(filename);
|
|
32
61
|
},
|
|
62
|
+
/**
|
|
63
|
+
* Parse filename to get all components
|
|
64
|
+
*/
|
|
33
65
|
parseFilename(filename) {
|
|
34
66
|
const extension = filename.match(/\.(vxjson|mdx)$/)?.[1] || "";
|
|
35
67
|
const locale = this.extractLocale(filename);
|
|
@@ -40,7 +72,7 @@ const ContentUtils = {
|
|
|
40
72
|
};
|
|
41
73
|
}
|
|
42
74
|
};
|
|
43
|
-
|
|
44
75
|
//#endregion
|
|
45
|
-
export { Blocks, ContentUtils, ErrorCodes, Site, UPDATE_SCOPE, analyzeUpdateScope, blockEditableSchema, blockMetaSchema, buildLocaleVersion, buildPathnameHistory, dataEditableSchema, dataMetaSchema, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, normalizePathname, pageEditableSchema, pageMetaSchema, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
|
|
76
|
+
export { Blocks, ContentIndex, ContentUtils, ErrorCodes, Site, UPDATE_SCOPE, analyzeUpdateScope, blockEditableSchema, blockMetaSchema, buildLocaleVersion, buildPathnameHistory, dataEditableSchema, dataMetaSchema, extractBlockName, formatFileSize, generateContentId, getCurrentISODate, getMetadataSize, isContentPublished, isMetadataTooLarge, isValidBlockName, isValidPathname, localesOf, mapLocales, mapSiteNames, mdxPageFrontmatterSchema, normalizeAndValidatePathname, normalizePathname, pageEditableSchema, pageMetaSchema, parseDate, resolvePublishDate, serializeMdxWithFrontmatter, shouldUpdateModifiedTimestamp, updatePublishDates, validateAndPrepareMetadata, validateCreateContent };
|
|
77
|
+
|
|
46
78
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Utilities for working with suffix pattern as specified in 04-cms-api.md\n */\nexport const ContentUtils = {\n /**\n * Extract locale from filename\n * @example\n * - about.en.vxjson → 'en'\n * - about.nl.vxjson → 'nl'\n * - hero-main.mdx → 'en' (default)\n * - hero-main.nl.mdx → 'nl'\n */\n extractLocale(filename: string): string {\n const match = filename.match(/\\.([a-z]{2})\\.(vxjson|mdx)$/);\n return match?.[1] || 'en';\n },\n\n /**\n * Get base path without locale and extension\n * @example\n * - about.en.vxjson → 'about'\n * - about.nl.vxjson → 'about'\n * - hero-main.mdx → 'hero-main'\n */\n extractBasePath(filename: string): string {\n return filename.replace(/\\.([a-z]{2})?\\.(vxjson|mdx)$/, '').replace(/\\.(vxjson|mdx)$/, '');\n },\n\n /**\n * Build filename from base path and locale\n * @example\n * - ('about', 'en') → 'about.en.vxjson'\n * - ('about', 'nl') → 'about.nl.vxjson'\n */\n buildFilename(basePath: string, locale: string, extension = 'vxjson'): string {\n if (locale === 'en' && extension === 'vxjson') {\n return `${basePath}.${extension}`;\n }\n return `${basePath}.${locale}.${extension}`;\n },\n\n /**\n * Group files by base path for i18n\n */\n groupByContent(filenames: string[]): Map<string, Record<string, string>> {\n const groups = new Map<string, Record<string, string>>();\n\n for (const filename of filenames) {\n const base = this.extractBasePath(filename);\n const locale = this.extractLocale(filename);\n\n if (!groups.has(base)) {\n groups.set(base, {});\n }\n\n const localeFiles = groups.get(base)!;\n localeFiles[locale] = filename;\n }\n\n return groups;\n },\n\n /**\n * Check if a file is a content file (vxjson or mdx)\n */\n isContentFile(filename: string): boolean {\n return /\\.(vxjson|mdx)$/.test(filename);\n },\n\n /**\n * Parse filename to get all components\n */\n parseFilename(filename: string): {\n basePath: string;\n locale: string;\n extension: string;\n } {\n const extension = filename.match(/\\.(vxjson|mdx)$/)?.[1] || '';\n const locale = this.extractLocale(filename);\n const basePath = this.extractBasePath(filename);\n\n return { basePath, locale, extension };\n },\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Utilities for working with suffix pattern as specified in 04-cms-api.md\n */\nexport const ContentUtils = {\n /**\n * Extract locale from filename\n * @example\n * - about.en.vxjson → 'en'\n * - about.nl.vxjson → 'nl'\n * - hero-main.mdx → 'en' (default)\n * - hero-main.nl.mdx → 'nl'\n */\n extractLocale(filename: string): string {\n const match = filename.match(/\\.([a-z]{2})\\.(vxjson|mdx)$/);\n return match?.[1] || 'en';\n },\n\n /**\n * Get base path without locale and extension\n * @example\n * - about.en.vxjson → 'about'\n * - about.nl.vxjson → 'about'\n * - hero-main.mdx → 'hero-main'\n */\n extractBasePath(filename: string): string {\n return filename.replace(/\\.([a-z]{2})?\\.(vxjson|mdx)$/, '').replace(/\\.(vxjson|mdx)$/, '');\n },\n\n /**\n * Build filename from base path and locale\n * @example\n * - ('about', 'en') → 'about.en.vxjson'\n * - ('about', 'nl') → 'about.nl.vxjson'\n */\n buildFilename(basePath: string, locale: string, extension = 'vxjson'): string {\n if (locale === 'en' && extension === 'vxjson') {\n return `${basePath}.${extension}`;\n }\n return `${basePath}.${locale}.${extension}`;\n },\n\n /**\n * Group files by base path for i18n\n */\n groupByContent(filenames: string[]): Map<string, Record<string, string>> {\n const groups = new Map<string, Record<string, string>>();\n\n for (const filename of filenames) {\n const base = this.extractBasePath(filename);\n const locale = this.extractLocale(filename);\n\n if (!groups.has(base)) {\n groups.set(base, {});\n }\n\n const localeFiles = groups.get(base)!;\n localeFiles[locale] = filename;\n }\n\n return groups;\n },\n\n /**\n * Check if a file is a content file (vxjson or mdx)\n */\n isContentFile(filename: string): boolean {\n return /\\.(vxjson|mdx)$/.test(filename);\n },\n\n /**\n * Parse filename to get all components\n */\n parseFilename(filename: string): {\n basePath: string;\n locale: string;\n extension: string;\n } {\n const extension = filename.match(/\\.(vxjson|mdx)$/)?.[1] || '';\n const locale = this.extractLocale(filename);\n const basePath = this.extractBasePath(filename);\n\n return { basePath, locale, extension };\n },\n};\n"],"mappings":";;;;;;;;;AAGA,MAAa,eAAe;;;;;;;;;CAS1B,cAAc,UAA0B;EAEtC,OADc,SAAS,MAAM,6BAClB,CAAC,GAAG,MAAM;CACvB;;;;;;;;CASA,gBAAgB,UAA0B;EACxC,OAAO,SAAS,QAAQ,gCAAgC,EAAE,CAAC,CAAC,QAAQ,mBAAmB,EAAE;CAC3F;;;;;;;CAQA,cAAc,UAAkB,QAAgB,YAAY,UAAkB;EAC5E,IAAI,WAAW,QAAQ,cAAc,UACnC,OAAO,GAAG,SAAS,GAAG;EAExB,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG;CAClC;;;;CAKA,eAAe,WAA0D;EACvE,MAAM,yBAAS,IAAI,IAAoC;EAEvD,KAAK,MAAM,YAAY,WAAW;GAChC,MAAM,OAAO,KAAK,gBAAgB,QAAQ;GAC1C,MAAM,SAAS,KAAK,cAAc,QAAQ;GAE1C,IAAI,CAAC,OAAO,IAAI,IAAI,GAClB,OAAO,IAAI,MAAM,CAAC,CAAC;GAGrB,MAAM,cAAc,OAAO,IAAI,IAAI;GACnC,YAAY,UAAU;EACxB;EAEA,OAAO;CACT;;;;CAKA,cAAc,UAA2B;EACvC,OAAO,kBAAkB,KAAK,QAAQ;CACxC;;;;CAKA,cAAc,UAIZ;EACA,MAAM,YAAY,SAAS,MAAM,iBAAiB,CAAC,GAAG,MAAM;EAC5D,MAAM,SAAS,KAAK,cAAc,QAAQ;EAG1C,OAAO;GAAE,UAFQ,KAAK,gBAAgB,QAEtB;GAAG;GAAQ;EAAU;CACvC;AACF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { B as VXJSONFile, d as ContentMeta, k as LocaleVersion, o as ContentData, u as ContentManifest } from "./types-DjfhS272.mjs";
|
|
2
|
+
import { t as ContentIndex } from "./content-index-D6IVMmAB.mjs";
|
|
3
|
+
//#region src/header-parser.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Result of parsing a content blob's header.
|
|
6
|
+
*
|
|
7
|
+
* `repaired === true` means the bytes parsed but were not in canonical form;
|
|
8
|
+
* the manifest reflects the canonical interpretation. The hydrator never
|
|
9
|
+
* writes back; spec 03 may opt to rewrite the file via the FS API's own
|
|
10
|
+
* write path, but that decision lives outside this pure parser.
|
|
11
|
+
*/
|
|
12
|
+
type ParseHeaderResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
manifest: ContentManifest;
|
|
15
|
+
locale: string;
|
|
16
|
+
localeVersion: LocaleVersion;
|
|
17
|
+
content?: ContentData;
|
|
18
|
+
repaired: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: 'unknown-format' | 'malformed-vxjson' | 'malformed-mdx' | 'unsupported-locale-path';
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Parse a content blob's header bytes (default 4 KB) into a manifest entry.
|
|
26
|
+
*
|
|
27
|
+
* Pure: no I/O, no clock, no FS. The `repaired` flag means "header bytes
|
|
28
|
+
* were not canonical, so we computed the canonical manifest entry from a
|
|
29
|
+
* repaired in-memory copy" — actual writes (e.g., FS rename) happen in
|
|
30
|
+
* the caller, not here. The Branch DO never writes-on-read; it just records
|
|
31
|
+
* the canonical form for the next commit.
|
|
32
|
+
*/
|
|
33
|
+
declare function parseContentHeader(input: {
|
|
34
|
+
path: string;
|
|
35
|
+
header: Uint8Array;
|
|
36
|
+
size: number;
|
|
37
|
+
complete: boolean;
|
|
38
|
+
}): ParseHeaderResult;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/vxjson.d.ts
|
|
41
|
+
/**
|
|
42
|
+
* Calculate both ETags from a VXJSON buffer using views
|
|
43
|
+
* Finds the "content" field position and validates it's the last field
|
|
44
|
+
* @param buffer - The complete file buffer
|
|
45
|
+
* @returns Result with ETags or validation error
|
|
46
|
+
*/
|
|
47
|
+
declare function calculateEtagsFromVXJSONBuffer(buffer: Uint8Array, allowTruncated?: boolean): {
|
|
48
|
+
success: true;
|
|
49
|
+
metaEtag: string;
|
|
50
|
+
contentEtag?: string;
|
|
51
|
+
contentStartPos: number;
|
|
52
|
+
} | {
|
|
53
|
+
success: false;
|
|
54
|
+
error: 'content_not_last' | 'invalid_json';
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* VXJSON (Variant JSON) module for parsing and serializing VXJSON files
|
|
58
|
+
*
|
|
59
|
+
* VXJSON is a specialized JSON format that guarantees:
|
|
60
|
+
* 1. The root is always an object (never an array or primitive)
|
|
61
|
+
* 2. The "content" field always comes last in the object
|
|
62
|
+
* 3. Field order is deterministic for consistent ETag calculation
|
|
63
|
+
* 4. Metadata fits within 4085 bytes, ensuring "content" field is found within first 4KB
|
|
64
|
+
* 5. First 4KB must either be complete JSON OR end exactly with '"content":'
|
|
65
|
+
*
|
|
66
|
+
* This format enables efficient 4KB parsing where only the first 4KB of a file
|
|
67
|
+
* needs to be read to extract all metadata and locate the content position.
|
|
68
|
+
* The constraint that 4KB reads must end with '"content":' ensures reliable parsing.
|
|
69
|
+
*
|
|
70
|
+
* This module centralizes all VXJSON-specific logic including:
|
|
71
|
+
* - Parsing partial buffers (first 4KB for indexing)
|
|
72
|
+
* - Finding content position for ETag calculation
|
|
73
|
+
* - Serializing with proper field ordering and size validation
|
|
74
|
+
* - Calculating ETags from buffers
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* VXJSON static utilities for parsing and validating VXJSON files
|
|
78
|
+
*/
|
|
79
|
+
declare class VXJSON {
|
|
80
|
+
/**
|
|
81
|
+
* Parse first 4KB of VXJSON content from buffer
|
|
82
|
+
* Used during indexing to extract metadata without loading full content
|
|
83
|
+
*
|
|
84
|
+
* VXJSON format requirement: first 4KB must either be complete JSON OR end with '"content":'
|
|
85
|
+
* This ensures reliable parsing and validation.
|
|
86
|
+
*/
|
|
87
|
+
static parse4KB(buffer: Uint8Array, bytesRead: number): {
|
|
88
|
+
id?: string;
|
|
89
|
+
created?: string;
|
|
90
|
+
modified?: string;
|
|
91
|
+
publishAt?: string;
|
|
92
|
+
unpublishAt?: string;
|
|
93
|
+
previousPathnames?: Record<string, string>;
|
|
94
|
+
pathname?: string;
|
|
95
|
+
name?: string;
|
|
96
|
+
meta: ContentMeta;
|
|
97
|
+
content?: ContentData;
|
|
98
|
+
contentStartPos?: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Find the position of the "content" field in a VXJSON buffer
|
|
102
|
+
* Returns -1 if not found
|
|
103
|
+
*/
|
|
104
|
+
static findContentPosition(buffer: Uint8Array): number;
|
|
105
|
+
/**
|
|
106
|
+
* Calculate ETags for a VXJSON buffer
|
|
107
|
+
* Returns null if the buffer is not valid VXJSON
|
|
108
|
+
*/
|
|
109
|
+
static calculateEtagsOnly(buffer: Uint8Array): {
|
|
110
|
+
metaEtag: string;
|
|
111
|
+
contentEtag?: string;
|
|
112
|
+
} | null;
|
|
113
|
+
/**
|
|
114
|
+
* Create a dual ETag string from a VXJSON buffer
|
|
115
|
+
* Returns null if the buffer is not valid VXJSON
|
|
116
|
+
*/
|
|
117
|
+
static createEtag(buffer: Uint8Array): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Validate that a VXJSON buffer has the correct structure
|
|
120
|
+
* (content field must be last)
|
|
121
|
+
*/
|
|
122
|
+
static isValid(buffer: Uint8Array): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Parse a complete VXJSON file from string
|
|
125
|
+
*/
|
|
126
|
+
static parse(content: string): VXJSONFile;
|
|
127
|
+
/**
|
|
128
|
+
* Parse a complete VXJSON file from buffer
|
|
129
|
+
*/
|
|
130
|
+
static parseBuffer(buffer: Uint8Array): VXJSONFile;
|
|
131
|
+
/**
|
|
132
|
+
* Calculate both ETags from a VXJSON buffer using views
|
|
133
|
+
* Finds the "content" field position and validates it's the last field
|
|
134
|
+
* @param buffer - The complete file buffer
|
|
135
|
+
* @returns Result with ETags or validation error
|
|
136
|
+
*/
|
|
137
|
+
static calculateETags: typeof calculateEtagsFromVXJSONBuffer;
|
|
138
|
+
/**
|
|
139
|
+
* Calculate a simple single etag from the entire buffer
|
|
140
|
+
* Used for data files that don't follow the content-last convention
|
|
141
|
+
*/
|
|
142
|
+
static calculateSimpleEtag(buffer: Uint8Array): string;
|
|
143
|
+
/**
|
|
144
|
+
* Serialize a VXJSONFile to VXJSON format string. Delegates to the pure
|
|
145
|
+
* vxjson-serialize module — kept apart so spec-14 cores can import the
|
|
146
|
+
* serializer without this module's crypto/WASM ETag imports.
|
|
147
|
+
*/
|
|
148
|
+
static serialize(data: VXJSONFile): string;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { ContentIndex, type ParseHeaderResult, VXJSON, parseContentHeader };
|
|
152
|
+
//# sourceMappingURL=indexing.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexing.d.mts","names":[],"sources":["../src/header-parser.ts","../src/vxjson.ts"],"mappings":";;;;;;;;;;;KAgBY;EAEN;EACA,UAAU;EACV;EACA,eAAe;EACf,UAAU;EACV;;EAGA;EACA;EACA;;;;;;;;;;;iBAoNU,mBAAmB;EACjC;EACA,QAAQ;EACR;EACA;IACE;;;;;;;;;iBClNK,+BACP,QAAQ,YACR;EAEI;EAAe;EAAkB;EAAsB;;EACvD;EAAgB;;;;;;;;;;;;;;;;;;;;;;;;;cAgOT;;;;;;;;SAQJ,SACL,QAAQ,YACR;IAEA;IACA;IACA;IACA;IACA;IACA,oBAAoB;IACpB;IACA;IACA,MAAM;IACN,UAAU;IACV;;;;;;SAoFK,oBAAoB,QAAQ;;;;;SAY5B,mBAAmB,QAAQ;IAAe;IAAkB;;;;;;SAgB5D,WAAW,QAAQ;;;;;SAanB,QAAQ,QAAQ;;;;SAQhB,MAAM,kBAAkB;;;;SAOxB,YAAY,QAAQ,aAAa;;;;;;;SAWjC,uBAAc;;;;;SAMd,oBAAoB,QAAQ;;;;;;SAS5B,UAAU,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../src/indexing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/indexing.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ContentIndex } from './content-index';
|
|
2
|
+
export { parseContentHeader } from './header-parser';
|
|
3
|
+
// The canonical VXJSON serializer/parser for readers inside the effectful
|
|
4
|
+
// indexing world. Pure writers (the SaaS Branch DO's commit-plan core) use
|
|
5
|
+
// the dedicated `./vxjson-serialize` subpath instead — this chunk evaluates
|
|
6
|
+
// crypto/xxhash at import time, which spec 14 §A90 bans inside cores.
|
|
7
|
+
export { VXJSON } from './vxjson';
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { t as ContentIndex } from "./content-index-D092_vk1.mjs";
|
|
2
|
+
import { n as calculateEtagsFromMdxBuffer, r as findMdxContentStartPosition, t as VXJSON } from "./vxjson-qHrgLGip.mjs";
|
|
3
|
+
import matter from "gray-matter";
|
|
4
|
+
//#region src/header-parser.ts
|
|
5
|
+
const textDecoder = new TextDecoder();
|
|
6
|
+
const textEncoder = new TextEncoder();
|
|
7
|
+
/**
|
|
8
|
+
* Pure path → identity mapper. Returns null when the path doesn't match any
|
|
9
|
+
* supported layout or lacks an explicit locale suffix; the caller maps null
|
|
10
|
+
* to a `unsupported-locale-path` ParseHeaderResult.
|
|
11
|
+
*
|
|
12
|
+
* Layouts honoured here mirror filesystem-content-api.ts:137-144 and
|
|
13
|
+
* 00-overview.md "Commit Flow":
|
|
14
|
+
*
|
|
15
|
+
* - `blocks/<collection>/<name>.<locale>.{mdx,vxjson}` (collection required;
|
|
16
|
+
* `blocks/<name>.<locale>.ext` is a legacy form that FileSystemContentAPI
|
|
17
|
+
* repairs by renaming. The pure parser refuses it.)
|
|
18
|
+
* - `data/<collection>/<name>.<locale>.json`
|
|
19
|
+
* - `<site>/<collection>/<path...>/<file>.<locale>.vxjson` (pages; `index`
|
|
20
|
+
* basename maps to the parent path).
|
|
21
|
+
*/
|
|
22
|
+
function parsePathLayout(path) {
|
|
23
|
+
const parts = path.split("/").filter(Boolean);
|
|
24
|
+
if (parts.length < 3) return null;
|
|
25
|
+
const filename = parts[parts.length - 1];
|
|
26
|
+
if (parts[0] === "blocks") {
|
|
27
|
+
if (parts.length !== 3) return null;
|
|
28
|
+
const match = filename.match(/^(.+)\.([a-zA-Z]{2}(?:-[A-Z]{2})?)\.(mdx|vxjson)$/);
|
|
29
|
+
if (!match) return null;
|
|
30
|
+
return {
|
|
31
|
+
kind: "block",
|
|
32
|
+
collection: parts[1],
|
|
33
|
+
name: match[1],
|
|
34
|
+
locale: match[2]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (parts[0] === "data") {
|
|
38
|
+
if (parts.length !== 3) return null;
|
|
39
|
+
const match = filename.match(/^(.+)\.([a-z]{2}(?:-[A-Z]{2})?)\.json$/);
|
|
40
|
+
if (!match) return null;
|
|
41
|
+
return {
|
|
42
|
+
kind: "data",
|
|
43
|
+
collection: parts[1],
|
|
44
|
+
name: match[1],
|
|
45
|
+
locale: match[2]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const match = filename.match(/^(.+)\.([a-zA-Z]{2}(?:-[A-Z]{2})?)\.(mdx|vxjson)$/);
|
|
49
|
+
if (!match) return null;
|
|
50
|
+
const site = parts[0];
|
|
51
|
+
const collection = parts[1];
|
|
52
|
+
const pathParts = parts.slice(2);
|
|
53
|
+
pathParts[pathParts.length - 1] = match[1];
|
|
54
|
+
const pathname = pathParts[pathParts.length - 1] === "index" ? `/${pathParts.slice(0, -1).join("/")}` || "/" : `/${pathParts.join("/")}`;
|
|
55
|
+
return {
|
|
56
|
+
kind: "page",
|
|
57
|
+
site,
|
|
58
|
+
collection,
|
|
59
|
+
locale: match[2],
|
|
60
|
+
pathname
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function parseHeaderMetadataMdx(bytes) {
|
|
64
|
+
const partial = textDecoder.decode(bytes);
|
|
65
|
+
let frontmatter;
|
|
66
|
+
try {
|
|
67
|
+
({data: frontmatter} = matter(partial, {}));
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const contentStartPos = findMdxContentStartPosition(bytes);
|
|
72
|
+
const { id, created, modified, publishAt, unpublishAt, name: _name, ...rest } = frontmatter;
|
|
73
|
+
return {
|
|
74
|
+
id,
|
|
75
|
+
created,
|
|
76
|
+
modified,
|
|
77
|
+
publishAt,
|
|
78
|
+
unpublishAt,
|
|
79
|
+
meta: rest,
|
|
80
|
+
contentStartPos
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function parseHeaderMetadataJson(bytes) {
|
|
84
|
+
try {
|
|
85
|
+
const data = JSON.parse(textDecoder.decode(bytes));
|
|
86
|
+
return {
|
|
87
|
+
id: data.id,
|
|
88
|
+
type: "json",
|
|
89
|
+
created: data.created,
|
|
90
|
+
modified: data.modified,
|
|
91
|
+
publishAt: data.publishAt,
|
|
92
|
+
unpublishAt: data.unpublishAt,
|
|
93
|
+
meta: data.meta
|
|
94
|
+
};
|
|
95
|
+
} catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function parseHeaderMetadataVxjson(bytes, complete) {
|
|
100
|
+
try {
|
|
101
|
+
return VXJSON.parse4KB(bytes, bytes.length);
|
|
102
|
+
} catch {
|
|
103
|
+
if (!complete) return null;
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function canonicalizeVxjsonBytes(bytes) {
|
|
108
|
+
try {
|
|
109
|
+
const parsed = JSON.parse(textDecoder.decode(bytes));
|
|
110
|
+
const canonical = {
|
|
111
|
+
id: parsed.id,
|
|
112
|
+
type: parsed.type,
|
|
113
|
+
created: parsed.created,
|
|
114
|
+
modified: parsed.modified,
|
|
115
|
+
publishAt: parsed.publishAt,
|
|
116
|
+
unpublishAt: parsed.unpublishAt,
|
|
117
|
+
previousPathnames: parsed.previousPathnames,
|
|
118
|
+
meta: parsed.meta || {},
|
|
119
|
+
content: parsed.content || {}
|
|
120
|
+
};
|
|
121
|
+
return textEncoder.encode(VXJSON.serialize(canonical));
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function bytesEqual(a, b) {
|
|
127
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
128
|
+
for (let i = 0; i < a.byteLength; i++) if (a[i] !== b[i]) return false;
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
function deriveType(path, parsed) {
|
|
132
|
+
if (parsed.type) return parsed.type;
|
|
133
|
+
if (path.endsWith(".mdx")) return "mdx";
|
|
134
|
+
if (path.endsWith(".json")) return "json";
|
|
135
|
+
return "puck";
|
|
136
|
+
}
|
|
137
|
+
function parseFullContent(path, bytes) {
|
|
138
|
+
try {
|
|
139
|
+
if (path.endsWith(".mdx")) {
|
|
140
|
+
const { content } = matter(textDecoder.decode(bytes), {});
|
|
141
|
+
return { mdx: content };
|
|
142
|
+
}
|
|
143
|
+
const data = JSON.parse(textDecoder.decode(bytes));
|
|
144
|
+
if (path.endsWith(".json")) return { data: data.data || {} };
|
|
145
|
+
return data.content || {};
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function etagFor(path, bytes, contentStartPos) {
|
|
151
|
+
if (path.endsWith(".mdx")) {
|
|
152
|
+
const etags = calculateEtagsFromMdxBuffer(bytes, contentStartPos ?? findMdxContentStartPosition(bytes));
|
|
153
|
+
return `${etags.metaEtag}.${etags.contentEtag}`;
|
|
154
|
+
}
|
|
155
|
+
if (path.endsWith(".json")) return VXJSON.calculateSimpleEtag(bytes);
|
|
156
|
+
const result = VXJSON.calculateETags(bytes);
|
|
157
|
+
if (!result.success) return null;
|
|
158
|
+
return result.contentEtag ? `${result.metaEtag}.${result.contentEtag}` : result.metaEtag;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parse a content blob's header bytes (default 4 KB) into a manifest entry.
|
|
162
|
+
*
|
|
163
|
+
* Pure: no I/O, no clock, no FS. The `repaired` flag means "header bytes
|
|
164
|
+
* were not canonical, so we computed the canonical manifest entry from a
|
|
165
|
+
* repaired in-memory copy" — actual writes (e.g., FS rename) happen in
|
|
166
|
+
* the caller, not here. The Branch DO never writes-on-read; it just records
|
|
167
|
+
* the canonical form for the next commit.
|
|
168
|
+
*/
|
|
169
|
+
function parseContentHeader(input) {
|
|
170
|
+
const { path, header, complete } = input;
|
|
171
|
+
const layout = parsePathLayout(path);
|
|
172
|
+
if (!layout) return {
|
|
173
|
+
ok: false,
|
|
174
|
+
reason: "unsupported-locale-path",
|
|
175
|
+
message: `Path does not match any known content layout: ${path}`
|
|
176
|
+
};
|
|
177
|
+
let parsedMeta;
|
|
178
|
+
let bytes = header;
|
|
179
|
+
let repaired = false;
|
|
180
|
+
if (path.endsWith(".mdx")) {
|
|
181
|
+
parsedMeta = parseHeaderMetadataMdx(bytes);
|
|
182
|
+
if (!parsedMeta) return {
|
|
183
|
+
ok: false,
|
|
184
|
+
reason: "malformed-mdx",
|
|
185
|
+
message: `Could not parse MDX header for ${path}`
|
|
186
|
+
};
|
|
187
|
+
} else if (path.endsWith(".json")) {
|
|
188
|
+
parsedMeta = parseHeaderMetadataJson(bytes);
|
|
189
|
+
if (!parsedMeta) return {
|
|
190
|
+
ok: false,
|
|
191
|
+
reason: "malformed-vxjson",
|
|
192
|
+
message: `Could not parse JSON header for ${path}`
|
|
193
|
+
};
|
|
194
|
+
} else if (path.endsWith(".vxjson")) {
|
|
195
|
+
if (complete) {
|
|
196
|
+
const canonical = canonicalizeVxjsonBytes(bytes);
|
|
197
|
+
if (canonical) {
|
|
198
|
+
if (!bytesEqual(canonical, bytes)) {
|
|
199
|
+
bytes = canonical;
|
|
200
|
+
repaired = true;
|
|
201
|
+
}
|
|
202
|
+
parsedMeta = parseHeaderMetadataVxjson(bytes, true);
|
|
203
|
+
} else parsedMeta = null;
|
|
204
|
+
} else parsedMeta = parseHeaderMetadataVxjson(bytes, false);
|
|
205
|
+
if (!parsedMeta) return {
|
|
206
|
+
ok: false,
|
|
207
|
+
reason: "malformed-vxjson",
|
|
208
|
+
message: `Could not parse VXJSON header for ${path}`
|
|
209
|
+
};
|
|
210
|
+
} else return {
|
|
211
|
+
ok: false,
|
|
212
|
+
reason: "unknown-format",
|
|
213
|
+
message: `Unknown file extension for ${path}`
|
|
214
|
+
};
|
|
215
|
+
const type = deriveType(path, parsedMeta);
|
|
216
|
+
const localeVersion = {
|
|
217
|
+
locale: layout.locale,
|
|
218
|
+
etag: "",
|
|
219
|
+
created: parsedMeta.created || "",
|
|
220
|
+
modified: parsedMeta.modified || "",
|
|
221
|
+
...parsedMeta.publishAt ? { publishAt: parsedMeta.publishAt } : {},
|
|
222
|
+
...parsedMeta.unpublishAt ? { unpublishAt: parsedMeta.unpublishAt } : {},
|
|
223
|
+
...layout.pathname ? { pathname: layout.pathname } : {},
|
|
224
|
+
...parsedMeta.previousPathnames ? { previousPathnames: parsedMeta.previousPathnames } : {},
|
|
225
|
+
...layout.name ? { name: layout.name } : {},
|
|
226
|
+
meta: parsedMeta.meta || { title: layout.name || "Untitled" }
|
|
227
|
+
};
|
|
228
|
+
const manifest = {
|
|
229
|
+
id: parsedMeta.id || "",
|
|
230
|
+
type,
|
|
231
|
+
kind: layout.kind,
|
|
232
|
+
site: layout.site,
|
|
233
|
+
collection: layout.collection,
|
|
234
|
+
locales: { [layout.locale]: localeVersion }
|
|
235
|
+
};
|
|
236
|
+
let content;
|
|
237
|
+
if (complete || repaired) {
|
|
238
|
+
const full = parseFullContent(path, bytes);
|
|
239
|
+
if (full) content = full;
|
|
240
|
+
const etag = etagFor(path, bytes, parsedMeta.contentStartPos);
|
|
241
|
+
if (etag) localeVersion.etag = etag;
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
ok: true,
|
|
245
|
+
manifest,
|
|
246
|
+
locale: layout.locale,
|
|
247
|
+
localeVersion,
|
|
248
|
+
content,
|
|
249
|
+
repaired
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
export { ContentIndex, VXJSON, parseContentHeader };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=indexing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexing.mjs","names":[],"sources":["../src/header-parser.ts"],"sourcesContent":["import matter from 'gray-matter';\nimport { calculateEtagsFromMdxBuffer, findMdxContentStartPosition } from './etag-utils';\nimport type { ContentData, ContentManifest, ContentMeta, LocaleVersion, VXJSONFile } from './types';\nimport { VXJSON } from './vxjson';\n\nconst textDecoder = new TextDecoder();\nconst textEncoder = new TextEncoder();\n\n/**\n * Result of parsing a content blob's header.\n *\n * `repaired === true` means the bytes parsed but were not in canonical form;\n * the manifest reflects the canonical interpretation. The hydrator never\n * writes back; spec 03 may opt to rewrite the file via the FS API's own\n * write path, but that decision lives outside this pure parser.\n */\nexport type ParseHeaderResult =\n | {\n ok: true;\n manifest: ContentManifest;\n locale: string;\n localeVersion: LocaleVersion;\n content?: ContentData;\n repaired: boolean;\n }\n | {\n ok: false;\n reason: 'unknown-format' | 'malformed-vxjson' | 'malformed-mdx' | 'unsupported-locale-path';\n message: string;\n };\n\ninterface PathParseSuccess {\n kind: 'block' | 'page' | 'data';\n site?: string;\n collection: string;\n locale: string;\n pathname?: string;\n name?: string;\n}\n\n/**\n * Pure path → identity mapper. Returns null when the path doesn't match any\n * supported layout or lacks an explicit locale suffix; the caller maps null\n * to a `unsupported-locale-path` ParseHeaderResult.\n *\n * Layouts honoured here mirror filesystem-content-api.ts:137-144 and\n * 00-overview.md \"Commit Flow\":\n *\n * - `blocks/<collection>/<name>.<locale>.{mdx,vxjson}` (collection required;\n * `blocks/<name>.<locale>.ext` is a legacy form that FileSystemContentAPI\n * repairs by renaming. The pure parser refuses it.)\n * - `data/<collection>/<name>.<locale>.json`\n * - `<site>/<collection>/<path...>/<file>.<locale>.vxjson` (pages; `index`\n * basename maps to the parent path).\n */\nfunction parsePathLayout(path: string): PathParseSuccess | null {\n const parts = path.split('/').filter(Boolean);\n if (parts.length < 3) return null;\n\n const filename = parts[parts.length - 1];\n\n if (parts[0] === 'blocks') {\n // blocks/<collection>/<name>.<locale>.<ext>\n if (parts.length !== 3) return null;\n const match = filename.match(/^(.+)\\.([a-zA-Z]{2}(?:-[A-Z]{2})?)\\.(mdx|vxjson)$/);\n if (!match) return null;\n return { kind: 'block', collection: parts[1], name: match[1], locale: match[2] };\n }\n\n if (parts[0] === 'data') {\n // data/<collection>/<name>.<locale>.json\n if (parts.length !== 3) return null;\n const match = filename.match(/^(.+)\\.([a-z]{2}(?:-[A-Z]{2})?)\\.json$/);\n if (!match) return null;\n return { kind: 'data', collection: parts[1], name: match[1], locale: match[2] };\n }\n\n // <site>/<collection>/<path...>/<file>.<locale>.{vxjson,mdx}\n // Reads accept .mdx pages even though the OSS filesystem writer emits\n // main-layout pages as .vxjson only (its mdx pages live under the separate\n // mdxPagesRoot): the SaaS commit pipeline derives the extension from the\n // content type, so an mdx-typed page lands here as <site>/pages/<f>.<l>.mdx\n // and must re-parse — dropping it made written pages unreadable.\n const match = filename.match(/^(.+)\\.([a-zA-Z]{2}(?:-[A-Z]{2})?)\\.(mdx|vxjson)$/);\n if (!match) return null;\n\n const site = parts[0];\n const collection = parts[1];\n const pathParts = parts.slice(2);\n pathParts[pathParts.length - 1] = match[1];\n const pathname =\n pathParts[pathParts.length - 1] === 'index'\n ? `/${pathParts.slice(0, -1).join('/')}` || '/'\n : `/${pathParts.join('/')}`;\n\n return { kind: 'page', site, collection, locale: match[2], pathname };\n}\n\ninterface ParsedHeaderMetadata {\n id?: string;\n created?: string;\n modified?: string;\n publishAt?: string;\n unpublishAt?: string;\n previousPathnames?: Record<string, string>;\n meta?: ContentMeta;\n type?: 'puck' | 'mdx' | 'json';\n contentStartPos?: number;\n}\n\nfunction parseHeaderMetadataMdx(bytes: Uint8Array): ParsedHeaderMetadata | null {\n const partial = textDecoder.decode(bytes);\n // Empty options opt out of gray-matter's module-level memo cache — a plain\n // object keyed by the raw input, so inputs naming an Object.prototype member\n // ('valueOf', 'toString', …) return the inherited member instead of a parse.\n // Errors as data, like the JSON/VXJSON siblings: a leading delimiter with\n // unparseable YAML ('---\\n[') makes js-yaml throw, and that used to escape\n // straight through parseContentHeader instead of its malformed-mdx result.\n let frontmatter: ReturnType<typeof matter>['data'];\n try {\n ({ data: frontmatter } = matter(partial, {}));\n } catch {\n return null;\n }\n const contentStartPos = findMdxContentStartPosition(bytes);\n const { id, created, modified, publishAt, unpublishAt, name: _name, ...rest } = frontmatter;\n return {\n id,\n created,\n modified,\n publishAt,\n unpublishAt,\n meta: rest as ContentMeta,\n contentStartPos,\n };\n}\n\nfunction parseHeaderMetadataJson(bytes: Uint8Array): ParsedHeaderMetadata | null {\n try {\n const data = JSON.parse(textDecoder.decode(bytes));\n return {\n id: data.id,\n type: 'json',\n created: data.created,\n modified: data.modified,\n publishAt: data.publishAt,\n unpublishAt: data.unpublishAt,\n meta: data.meta,\n };\n } catch {\n return null;\n }\n}\n\nfunction parseHeaderMetadataVxjson(bytes: Uint8Array, complete: boolean): ParsedHeaderMetadata | null {\n // VXJSON.parse4KB throws on malformed headers; we want errors-as-data here.\n try {\n return VXJSON.parse4KB(bytes, bytes.length);\n } catch {\n if (!complete) {\n // Could be a thinly truncated header that doesn't yet contain enough\n // metadata to parse. Caller will report malformed-vxjson.\n return null;\n }\n return null;\n }\n}\n\nfunction canonicalizeVxjsonBytes(bytes: Uint8Array): Uint8Array | null {\n try {\n const parsed: VXJSONFile = JSON.parse(textDecoder.decode(bytes));\n const canonical: VXJSONFile = {\n id: parsed.id,\n type: parsed.type,\n created: parsed.created,\n modified: parsed.modified,\n publishAt: parsed.publishAt,\n unpublishAt: parsed.unpublishAt,\n previousPathnames: parsed.previousPathnames,\n meta: parsed.meta || {},\n content: parsed.content || {},\n };\n return textEncoder.encode(VXJSON.serialize(canonical));\n } catch {\n return null;\n }\n}\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.byteLength !== b.byteLength) return false;\n for (let i = 0; i < a.byteLength; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction deriveType(path: string, parsed: ParsedHeaderMetadata): 'puck' | 'mdx' | 'json' {\n if (parsed.type) return parsed.type;\n if (path.endsWith('.mdx')) return 'mdx';\n if (path.endsWith('.json')) return 'json';\n return 'puck';\n}\n\nfunction parseFullContent(path: string, bytes: Uint8Array): ContentData | null {\n try {\n if (path.endsWith('.mdx')) {\n // Empty options: see parseHeaderMetadataMdx on the memo-cache hazard.\n const { content } = matter(textDecoder.decode(bytes), {});\n return { mdx: content };\n }\n const data = JSON.parse(textDecoder.decode(bytes));\n if (path.endsWith('.json')) return { data: data.data || {} };\n return data.content || {};\n } catch {\n return null;\n }\n}\n\nfunction etagFor(path: string, bytes: Uint8Array, contentStartPos?: number): string | null {\n if (path.endsWith('.mdx')) {\n const etags = calculateEtagsFromMdxBuffer(bytes, contentStartPos ?? findMdxContentStartPosition(bytes));\n return `${etags.metaEtag}.${etags.contentEtag}`;\n }\n if (path.endsWith('.json')) {\n return VXJSON.calculateSimpleEtag(bytes);\n }\n const result = VXJSON.calculateETags(bytes);\n if (!result.success) return null;\n return result.contentEtag ? `${result.metaEtag}.${result.contentEtag}` : result.metaEtag;\n}\n\n/**\n * Parse a content blob's header bytes (default 4 KB) into a manifest entry.\n *\n * Pure: no I/O, no clock, no FS. The `repaired` flag means \"header bytes\n * were not canonical, so we computed the canonical manifest entry from a\n * repaired in-memory copy\" — actual writes (e.g., FS rename) happen in\n * the caller, not here. The Branch DO never writes-on-read; it just records\n * the canonical form for the next commit.\n */\nexport function parseContentHeader(input: {\n path: string;\n header: Uint8Array;\n size: number;\n complete: boolean;\n}): ParseHeaderResult {\n const { path, header, complete } = input;\n\n const layout = parsePathLayout(path);\n if (!layout) {\n return {\n ok: false,\n reason: 'unsupported-locale-path',\n message: `Path does not match any known content layout: ${path}`,\n };\n }\n\n let parsedMeta: ParsedHeaderMetadata | null;\n let bytes = header;\n let repaired = false;\n\n if (path.endsWith('.mdx')) {\n parsedMeta = parseHeaderMetadataMdx(bytes);\n if (!parsedMeta) {\n return { ok: false, reason: 'malformed-mdx', message: `Could not parse MDX header for ${path}` };\n }\n } else if (path.endsWith('.json')) {\n parsedMeta = parseHeaderMetadataJson(bytes);\n if (!parsedMeta) {\n return { ok: false, reason: 'malformed-vxjson', message: `Could not parse JSON header for ${path}` };\n }\n } else if (path.endsWith('.vxjson')) {\n if (complete) {\n // For complete blobs, treat canonical-form serialization as the\n // source of truth for etag stability. Even if VXJSON.calculateETags\n // succeeds on the raw bytes, the meta-etag depends on the alphabetic\n // sort order that VXJSON.serialize enforces — so a file whose\n // metadata fields are in a different order produces a different\n // meta-etag than its canonical form. Re-serialize, compare, mark\n // repaired when bytes diverge.\n const canonical = canonicalizeVxjsonBytes(bytes);\n if (canonical) {\n if (!bytesEqual(canonical, bytes)) {\n bytes = canonical;\n repaired = true;\n }\n parsedMeta = parseHeaderMetadataVxjson(bytes, true);\n } else {\n parsedMeta = null;\n }\n } else {\n // Partial header: parse what we can; no canonicalisation possible\n // without the full blob, and `complete: false` is the caller's\n // signal that the etag will be deferred.\n parsedMeta = parseHeaderMetadataVxjson(bytes, false);\n }\n if (!parsedMeta) {\n return { ok: false, reason: 'malformed-vxjson', message: `Could not parse VXJSON header for ${path}` };\n }\n } else {\n return { ok: false, reason: 'unknown-format', message: `Unknown file extension for ${path}` };\n }\n\n const type = deriveType(path, parsedMeta);\n\n const localeVersion: LocaleVersion = {\n locale: layout.locale,\n etag: '',\n created: parsedMeta.created || '',\n modified: parsedMeta.modified || '',\n ...(parsedMeta.publishAt ? { publishAt: parsedMeta.publishAt } : {}),\n ...(parsedMeta.unpublishAt ? { unpublishAt: parsedMeta.unpublishAt } : {}),\n ...(layout.pathname ? { pathname: layout.pathname } : {}),\n ...(parsedMeta.previousPathnames ? { previousPathnames: parsedMeta.previousPathnames } : {}),\n ...(layout.name ? { name: layout.name } : {}),\n meta: parsedMeta.meta || { title: layout.name || 'Untitled' },\n };\n\n const manifest: ContentManifest = {\n id: parsedMeta.id || '',\n type,\n kind: layout.kind,\n site: layout.site,\n collection: layout.collection,\n locales: { [layout.locale]: localeVersion },\n };\n\n let content: ContentData | undefined;\n if (complete || repaired) {\n const full = parseFullContent(path, bytes);\n if (full) content = full;\n const etag = etagFor(path, bytes, parsedMeta.contentStartPos);\n if (etag) localeVersion.etag = etag;\n }\n\n return { ok: true, manifest, locale: layout.locale, localeVersion, content, repaired };\n}\n"],"mappings":";;;;AAKA,MAAM,cAAc,IAAI,YAAY;AACpC,MAAM,cAAc,IAAI,YAAY;;;;;;;;;;;;;;;;AAiDpC,SAAS,gBAAgB,MAAuC;CAC9D,MAAM,QAAQ,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC5C,IAAI,MAAM,SAAS,GAAG,OAAO;CAE7B,MAAM,WAAW,MAAM,MAAM,SAAS;CAEtC,IAAI,MAAM,OAAO,UAAU;EAEzB,IAAI,MAAM,WAAW,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