@conloca/content-api 0.1.15 → 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-CBGONnYn.d.mts → component-registry.types-C0ctF9nh.d.mts} +1 -1
- 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-Db1Iv9T0.mjs → data-DquNIEnQ.mjs} +4 -2
- package/dist/{data-Db1Iv9T0.mjs.map → data-DquNIEnQ.mjs.map} +1 -1
- 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-kxKY5IUw.mjs → filesystem-content-api-C0HIhqZi.mjs} +172 -1230
- package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
- package/dist/{filesystem-content-api-C1TM0GLo.d.mts → filesystem-content-api-DCdNi-co.d.mts} +19 -4
- 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 -5
- 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 -6
- 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 +10 -15
- 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 +89 -135
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +5 -8
- package/dist/reader.d.mts.map +1 -1
- 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 +8 -8
- package/dist/reader.mjs.map +1 -1
- 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/{site-vNtJ5jCh.mjs → site-8oaj1Q60.mjs} +21 -193
- 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-DWt912tu.mjs → types-DOdldbfD.mjs} +3 -2
- 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 +79 -17
- package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
- package/dist/content-operations-Dv67amz3.d.mts +0 -852
- package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
- package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
- package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
- package/dist/schemas/index.d.mts.map +0 -1
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/site-vNtJ5jCh.mjs.map +0 -1
- package/dist/types-DWt912tu.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,7 +1,8 @@
|
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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";
|
|
5
6
|
//#region src/git-operations.d.ts
|
|
6
7
|
interface GitStatus {
|
|
7
8
|
isRepo: boolean;
|
|
@@ -75,5 +76,5 @@ declare const ContentUtils: {
|
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
78
|
//#endregion
|
|
78
|
-
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, MDXCompileResponse, 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 };
|
|
79
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,22 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
|
|
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";
|
|
5
6
|
//#region src/utils.ts
|
|
6
7
|
/**
|
|
7
8
|
* Utilities for working with suffix pattern as specified in 04-cms-api.md
|
|
8
9
|
*/
|
|
9
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
|
+
*/
|
|
10
19
|
extractLocale(filename) {
|
|
11
20
|
return filename.match(/\.([a-z]{2})\.(vxjson|mdx)$/)?.[1] || "en";
|
|
12
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
|
+
*/
|
|
13
29
|
extractBasePath(filename) {
|
|
14
30
|
return filename.replace(/\.([a-z]{2})?\.(vxjson|mdx)$/, "").replace(/\.(vxjson|mdx)$/, "");
|
|
15
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
|
+
*/
|
|
16
38
|
buildFilename(basePath, locale, extension = "vxjson") {
|
|
17
39
|
if (locale === "en" && extension === "vxjson") return `${basePath}.${extension}`;
|
|
18
40
|
return `${basePath}.${locale}.${extension}`;
|
|
19
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* Group files by base path for i18n
|
|
44
|
+
*/
|
|
20
45
|
groupByContent(filenames) {
|
|
21
46
|
const groups = /* @__PURE__ */ new Map();
|
|
22
47
|
for (const filename of filenames) {
|
|
@@ -28,9 +53,15 @@ const ContentUtils = {
|
|
|
28
53
|
}
|
|
29
54
|
return groups;
|
|
30
55
|
},
|
|
56
|
+
/**
|
|
57
|
+
* Check if a file is a content file (vxjson or mdx)
|
|
58
|
+
*/
|
|
31
59
|
isContentFile(filename) {
|
|
32
60
|
return /\.(vxjson|mdx)$/.test(filename);
|
|
33
61
|
},
|
|
62
|
+
/**
|
|
63
|
+
* Parse filename to get all components
|
|
64
|
+
*/
|
|
34
65
|
parseFilename(filename) {
|
|
35
66
|
const extension = filename.match(/\.(vxjson|mdx)$/)?.[1] || "";
|
|
36
67
|
const locale = this.extractLocale(filename);
|
|
@@ -41,7 +72,7 @@ const ContentUtils = {
|
|
|
41
72
|
};
|
|
42
73
|
}
|
|
43
74
|
};
|
|
44
|
-
|
|
45
75
|
//#endregion
|
|
46
|
-
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
|
+
|
|
47
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
|