@conloca/content-api 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component-registry.types-CBGONnYn.d.mts +71 -0
- package/dist/component-registry.types-CBGONnYn.d.mts.map +1 -0
- package/dist/{content-operations-CGGNiuJk.d.mts → content-operations-Dv67amz3.d.mts} +61 -71
- package/dist/content-operations-Dv67amz3.d.mts.map +1 -0
- package/dist/data-Db1Iv9T0.mjs +60 -0
- package/dist/data-Db1Iv9T0.mjs.map +1 -0
- package/dist/filesystem-content-api-C1TM0GLo.d.mts +119 -0
- package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +1 -0
- package/dist/filesystem-content-api-kxKY5IUw.mjs +2678 -0
- package/dist/filesystem-content-api-kxKY5IUw.mjs.map +1 -0
- package/dist/index.d.mts +29 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +31 -120
- package/dist/node.d.mts.map +1 -1
- package/dist/node.mjs +333 -2878
- package/dist/node.mjs.map +1 -1
- package/dist/reader.d.mts +18 -0
- package/dist/reader.d.mts.map +1 -0
- package/dist/reader.mjs +22 -0
- package/dist/reader.mjs.map +1 -0
- package/dist/{types-BUG0Cfkg.mjs → site-vNtJ5jCh.mjs} +2 -32
- package/dist/site-vNtJ5jCh.mjs.map +1 -0
- package/dist/types-DWt912tu.mjs +33 -0
- package/dist/types-DWt912tu.mjs.map +1 -0
- package/package.json +14 -5
- package/dist/content-operations-CGGNiuJk.d.mts.map +0 -1
- package/dist/types-BUG0Cfkg.mjs.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//#region src/asset-types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Browser-safe asset type definitions for @conloca/content-api
|
|
4
|
+
*
|
|
5
|
+
* These types are safe to import in browser environments.
|
|
6
|
+
* The Node.js implementation (AssetManifest class) is in asset-manifest.ts
|
|
7
|
+
*/
|
|
8
|
+
interface AssetEntry {
|
|
9
|
+
filename: string;
|
|
10
|
+
originalName: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
size: number;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
alt?: string;
|
|
16
|
+
uploadedAt: string;
|
|
17
|
+
uploadedBy?: string;
|
|
18
|
+
/** Folder path relative to assets root, default '/' */
|
|
19
|
+
folder?: string;
|
|
20
|
+
/** Tags for categorization/filtering */
|
|
21
|
+
tags?: string[];
|
|
22
|
+
}
|
|
23
|
+
/** Asset usage reference - tracks where an asset is used */
|
|
24
|
+
interface AssetUsage {
|
|
25
|
+
page: string;
|
|
26
|
+
field: string;
|
|
27
|
+
}
|
|
28
|
+
/** Folder listing result */
|
|
29
|
+
interface FolderListing {
|
|
30
|
+
assets: AssetEntry[];
|
|
31
|
+
folders: {
|
|
32
|
+
name: string;
|
|
33
|
+
path: string;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
/** Folder tree node for hierarchical folder view */
|
|
37
|
+
interface FolderTreeNode {
|
|
38
|
+
name: string;
|
|
39
|
+
path: string;
|
|
40
|
+
assetCount: number;
|
|
41
|
+
children: FolderTreeNode[];
|
|
42
|
+
}
|
|
43
|
+
/** Metadata stored per-file in the manifest (keyed by relative path) */
|
|
44
|
+
interface ManifestEntryData {
|
|
45
|
+
alt?: string;
|
|
46
|
+
tags?: string[];
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
uploadedAt?: string;
|
|
50
|
+
uploadedBy?: string;
|
|
51
|
+
originalName?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Object-keyed manifest structure for O(1) lookup by relative path */
|
|
54
|
+
interface AssetManifestData {
|
|
55
|
+
[relativePath: string]: ManifestEntryData;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/component-registry.types.d.ts
|
|
59
|
+
interface ComponentEntry {
|
|
60
|
+
displayName: string;
|
|
61
|
+
path: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface ComponentEntryWithId extends ComponentEntry {
|
|
64
|
+
id: string;
|
|
65
|
+
}
|
|
66
|
+
interface ComponentRegistry {
|
|
67
|
+
[componentId: string]: ComponentEntry;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { AssetManifestData as a, FolderTreeNode as c, AssetEntry as i, ManifestEntryData as l, ComponentEntryWithId as n, AssetUsage as o, ComponentRegistry as r, FolderListing as s, ComponentEntry as t };
|
|
71
|
+
//# sourceMappingURL=component-registry.types-CBGONnYn.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-registry.types-CBGONnYn.d.mts","names":[],"sources":["../src/asset-types.ts","../src/component-registry.types.ts"],"mappings":";;AAOA;;;;;UAAiB,UAAA;EACf,QAAA;EACA,YAAA;EACA,QAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,GAAA;EACA,UAAA;EACA,UAAA;EAII;EAFJ,MAAA;EAMe;EAJf,IAAA;AAAA;;UAIe,UAAA;EACf,IAAA;EACA,KAAA;AAAA;;UAIe,aAAA;EACf,MAAA,EAAQ,UAAA;EACR,OAAA;IAAW,IAAA;IAAc,IAAA;EAAA;AAAA;AAI3B;AAAA,UAAiB,cAAA;EACf,IAAA;EACA,IAAA;EACA,UAAA;EACA,QAAA,EAAU,cAAA;AAAA;;UAIK,iBAAA;EACf,GAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;EACA,UAAA;EACA,UAAA;EACA,YAAA;AAAA;;UAIe,iBAAA;EAAA,CACd,YAAA,WAAuB,iBAAA;AAAA;;;UCxDT,cAAA;EACf,WAAA;EACA,IAAA;AAAA;AAAA,UAGe,oBAAA,SAA6B,cAAA;EAC5C,EAAA;AAAA;AAAA,UAGe,iBAAA;EAAA,CACd,WAAA,WAAsB,cAAA;AAAA"}
|
|
@@ -1,60 +1,3 @@
|
|
|
1
|
-
//#region src/asset-types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Browser-safe asset type definitions for @conloca/content-api
|
|
4
|
-
*
|
|
5
|
-
* These types are safe to import in browser environments.
|
|
6
|
-
* The Node.js implementation (AssetManifest class) is in asset-manifest.ts
|
|
7
|
-
*/
|
|
8
|
-
interface AssetEntry {
|
|
9
|
-
filename: string;
|
|
10
|
-
originalName: string;
|
|
11
|
-
mimeType: string;
|
|
12
|
-
size: number;
|
|
13
|
-
width?: number;
|
|
14
|
-
height?: number;
|
|
15
|
-
alt?: string;
|
|
16
|
-
uploadedAt: string;
|
|
17
|
-
uploadedBy?: string;
|
|
18
|
-
/** Folder path relative to assets root, default '/' */
|
|
19
|
-
folder?: string;
|
|
20
|
-
/** Tags for categorization/filtering */
|
|
21
|
-
tags?: string[];
|
|
22
|
-
}
|
|
23
|
-
/** Asset usage reference - tracks where an asset is used */
|
|
24
|
-
interface AssetUsage {
|
|
25
|
-
page: string;
|
|
26
|
-
field: string;
|
|
27
|
-
}
|
|
28
|
-
/** Folder listing result */
|
|
29
|
-
interface FolderListing {
|
|
30
|
-
assets: AssetEntry[];
|
|
31
|
-
folders: {
|
|
32
|
-
name: string;
|
|
33
|
-
path: string;
|
|
34
|
-
}[];
|
|
35
|
-
}
|
|
36
|
-
/** Folder tree node for hierarchical folder view */
|
|
37
|
-
interface FolderTreeNode {
|
|
38
|
-
name: string;
|
|
39
|
-
path: string;
|
|
40
|
-
assetCount: number;
|
|
41
|
-
children: FolderTreeNode[];
|
|
42
|
-
}
|
|
43
|
-
/** Metadata stored per-file in the manifest (keyed by relative path) */
|
|
44
|
-
interface ManifestEntryData {
|
|
45
|
-
alt?: string;
|
|
46
|
-
tags?: string[];
|
|
47
|
-
width?: number;
|
|
48
|
-
height?: number;
|
|
49
|
-
uploadedAt?: string;
|
|
50
|
-
uploadedBy?: string;
|
|
51
|
-
originalName?: string;
|
|
52
|
-
}
|
|
53
|
-
/** Object-keyed manifest structure for O(1) lookup by relative path */
|
|
54
|
-
interface AssetManifestData {
|
|
55
|
-
[relativePath: string]: ManifestEntryData;
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
1
|
//#region src/types.d.ts
|
|
59
2
|
interface ContentAPIOptions {
|
|
60
3
|
contentRoot: string;
|
|
@@ -67,6 +10,10 @@ interface APIError {
|
|
|
67
10
|
details?: any;
|
|
68
11
|
};
|
|
69
12
|
}
|
|
13
|
+
interface MDXCompileResponse {
|
|
14
|
+
code: string;
|
|
15
|
+
metadata: Record<string, unknown>;
|
|
16
|
+
}
|
|
70
17
|
declare const ErrorCodes: {
|
|
71
18
|
readonly CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND";
|
|
72
19
|
readonly LOCALE_NOT_FOUND: "LOCALE_NOT_FOUND";
|
|
@@ -82,6 +29,7 @@ declare const ErrorCodes: {
|
|
|
82
29
|
readonly INVALID_LOCALE: "INVALID_LOCALE";
|
|
83
30
|
readonly INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE";
|
|
84
31
|
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
32
|
+
readonly MDX_COMPILE_FAILED: "MDX_COMPILE_FAILED";
|
|
85
33
|
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
86
34
|
readonly FETCH_ERROR: "FETCH_ERROR";
|
|
87
35
|
readonly GIT_NOT_REPO: "GIT_NOT_REPO";
|
|
@@ -370,6 +318,60 @@ interface BatchOperationResult {
|
|
|
370
318
|
error?: Error;
|
|
371
319
|
etag?: string;
|
|
372
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Minimal page reference for listing/navigation in data context.
|
|
323
|
+
*
|
|
324
|
+
* Used in dataBindings.pages for blog listing components
|
|
325
|
+
* and getStaticPaths() to enumerate available pages.
|
|
326
|
+
*/
|
|
327
|
+
interface PageReference {
|
|
328
|
+
/** Page identifier. */
|
|
329
|
+
id: string;
|
|
330
|
+
/** URL pathname. */
|
|
331
|
+
pathname: string;
|
|
332
|
+
/** Page title (if available without full load). */
|
|
333
|
+
title?: string;
|
|
334
|
+
/** Content collection. */
|
|
335
|
+
collection: string;
|
|
336
|
+
/** Page metadata from content. */
|
|
337
|
+
meta?: Record<string, unknown>;
|
|
338
|
+
/** Page timestamps for sorting and display. */
|
|
339
|
+
timestamps?: {
|
|
340
|
+
created?: Date;
|
|
341
|
+
modified?: Date;
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A single entry from a data collection.
|
|
346
|
+
*
|
|
347
|
+
* Simplified representation of collection data for use in component resolvers.
|
|
348
|
+
*/
|
|
349
|
+
interface DataCollectionEntry {
|
|
350
|
+
/** Unique identifier for the entry. */
|
|
351
|
+
id: string;
|
|
352
|
+
/** Human-readable name of the entry. */
|
|
353
|
+
name: string;
|
|
354
|
+
/** The entry's data content. */
|
|
355
|
+
data: Record<string, unknown>;
|
|
356
|
+
/** Optional metadata for the entry. */
|
|
357
|
+
meta?: Record<string, unknown>;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Context object passed to Puck component resolvers via metadata.
|
|
361
|
+
*
|
|
362
|
+
* Contains fetched collection data and contextual information
|
|
363
|
+
* for data-driven component rendering.
|
|
364
|
+
*/
|
|
365
|
+
interface DataContext {
|
|
366
|
+
/** Collection data keyed by collection name. */
|
|
367
|
+
collections: Record<string, DataCollectionEntry[]>;
|
|
368
|
+
/** Pages matching the dataBindings.pages filter. */
|
|
369
|
+
pages?: PageReference[];
|
|
370
|
+
/** Current locale used for data fetching. */
|
|
371
|
+
locale: string;
|
|
372
|
+
/** Site name from routing configuration. */
|
|
373
|
+
siteName: string;
|
|
374
|
+
}
|
|
373
375
|
interface LocaleFileData {
|
|
374
376
|
locale: string;
|
|
375
377
|
etag: string;
|
|
@@ -654,18 +656,6 @@ declare class Blocks {
|
|
|
654
656
|
create(data: CreateBlockInput): Promise<CreateResult>;
|
|
655
657
|
}
|
|
656
658
|
//#endregion
|
|
657
|
-
//#region src/component-registry.types.d.ts
|
|
658
|
-
interface ComponentEntry {
|
|
659
|
-
displayName: string;
|
|
660
|
-
path: string | null;
|
|
661
|
-
}
|
|
662
|
-
interface ComponentEntryWithId extends ComponentEntry {
|
|
663
|
-
id: string;
|
|
664
|
-
}
|
|
665
|
-
interface ComponentRegistry {
|
|
666
|
-
[componentId: string]: ComponentEntry;
|
|
667
|
-
}
|
|
668
|
-
//#endregion
|
|
669
659
|
//#region src/content-utils.d.ts
|
|
670
660
|
declare function localesOf<T>(manifest: {
|
|
671
661
|
locales: Record<string, T | undefined>;
|
|
@@ -858,5 +848,5 @@ declare function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope;
|
|
|
858
848
|
*/
|
|
859
849
|
declare function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean;
|
|
860
850
|
//#endregion
|
|
861
|
-
export {
|
|
862
|
-
//# sourceMappingURL=content-operations-
|
|
851
|
+
export { ErrorCode as $, Site as A, ContentListResult as B, mapSiteNames as C, serializeMdxWithFrontmatter as D, resolvePublishDate as E, BlockFilters as F, CreateBlockInput as G, ContentMeta as H, ContentAPIOptions as I, CreateResult as J, CreateContentInput as K, ContentData as L, APIError as M, BatchOperationResult as N, Blocks as O, BatchResult as P, DeleteResult as Q, ContentEntry as R, mapLocales as S, parseDate as T, ContentProp as U, ContentManifest as V, ContentType as W, DataContext as X, DataCollectionEntry as Y, DeleteLocaleInput as Z, isContentPublished as _, VXJSONFile as _t, analyzeUpdateScope as a, LocaleUpdateData as at, isValidPathname as b, shouldUpdateModifiedTimestamp as c, LocalizedManifest as ct, validateCreateContent as d, MoveResult as dt, ErrorCodes as et, extractBlockName as f, PageReference as ft, getMetadataSize as g, UpdateResult as gt, getCurrentISODate as h, UpdateLocaleInput as ht, ValidationResult as i, LocalePathData as it, Data as j, ContentAPI as k, updatePublishDates as l, MDXCompileResponse as lt, generateContentId as m, SitesConfig as mt, UPDATE_SCOPE as n, GlobalFilters as nt, buildLocaleVersion as o, LocaleVersion as ot, formatFileSize as p, SiteFilters as pt, CreatePageInput as q, UpdateScope as r, LocaleFileData as rt, buildPathnameHistory as s, LocalizedEntry as st, CreateValidationResult as t, FindOptions as tt, validateAndPrepareMetadata as u, MDXFrontmatter as ut, isMetadataTooLarge as v, WriteResult as vt, normalizePathname as w, localesOf as x, isValidBlockName as y, ContentIdentity as z };
|
|
852
|
+
//# sourceMappingURL=content-operations-Dv67amz3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-operations-Dv67amz3.d.mts","names":[],"sources":["../src/types.ts","../src/base-content-index.ts","../src/block-index.ts","../src/data-index.ts","../src/data.ts","../src/site-index.ts","../src/site.ts","../src/content-api.interface.ts","../src/blocks.ts","../src/content-utils.ts","../src/content-operations.ts"],"mappings":";UAAiB,iBAAA;EACf,WAAA;EACA,SAAA;AAAA;AAAA,UAIe,QAAA;EACf,KAAA;IACE,IAAA;IACA,OAAA;IACA,OAAA;EAAA;AAAA;AAAA,UAIa,kBAAA;EACf,IAAA;EACA,QAAA,EAAU,MAAA;AAAA;AAAA,cAIC,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCD,SAAA,WAAoB,UAAA,eAAyB,UAAA;AAAA,KAG7C,WAAA;AAAA,UAGK,WAAA;EACf,QAAA;EACA,GAAA;EACA,IAAA,GAAO,MAAA;AAAA;AAAA,UAIQ,WAAA;EACf,OAAA,EAAS,WAAA;AAAA;AAAA,UAIM,eAAA;EACf,EAAA;EACA,IAAA,EAAM,WAAA;EACN,IAAA;EACA,IAAA;EACA,UAAA;AAAA;AAAA,UAIe,cAAA;EACf,MAAA;EACA,QAAA;EACA,IAAA;AAAA;AAAA,UAIe,aAAA,SAAsB,cAAA;EACrC,IAAA;EACA,OAAA;EACA,QAAA;EACA,SAAA;EACA,WAAA;EACA,iBAAA,GAAoB,MAAA;EACpB,IAAA,EAAM,WAAA;AAAA;AAAA,UAIS,eAAA,SAAwB,eAAA;EACvC,OAAA,EAAS,MAAA,SAAe,aAAA;AAAA;AAA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EACN,KAAA,EAAO,MAAA,SAAe,IAAA,GACtB,MAAA,EAAQ,MAAA,EACR,OAAA;EACE,eAAA,GAAkB,IAAA;EAClB,eAAA,GAAkB,UAAA,UAAoB,IAAA;AAAA,IAEvC,sBAAA;;;;AV1FH;cUyOa,YAAA;EAAA;;;;;KAOD,WAAA,WAAsB,YAAA,eAA2B,YAAA;;;AVzO7D;;;;;AAKA;;;;;iBUkPgB,kBAAA,CAAmB,IAAA,EAAM,gBAAA,GAAmB,WAAA;;;;;iBAqB5C,6BAAA,CAA8B,IAAA,EAAM,gBAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/data.ts
|
|
2
|
+
var Data = class {
|
|
3
|
+
constructor(api, dataIndex) {
|
|
4
|
+
this.api = api;
|
|
5
|
+
this.dataIndex = dataIndex;
|
|
6
|
+
}
|
|
7
|
+
*listContent(filters) {
|
|
8
|
+
if (filters?.collection) if (filters.locales && filters.locales.length > 0) {
|
|
9
|
+
for (const manifest of this.dataIndex.getManifestsByCollection(filters.collection)) if (filters.locales.some((locale) => manifest.locales[locale])) yield manifest;
|
|
10
|
+
} else yield* this.dataIndex.getManifestsByCollection(filters.collection);
|
|
11
|
+
else if (filters?.locales && filters.locales.length > 0) {
|
|
12
|
+
for (const manifest of this.dataIndex.getAllManifests()) if (filters.locales.some((locale) => manifest.locales[locale])) yield manifest;
|
|
13
|
+
} else yield* this.dataIndex.getAllManifests();
|
|
14
|
+
}
|
|
15
|
+
get collections() {
|
|
16
|
+
return this.dataIndex.collections;
|
|
17
|
+
}
|
|
18
|
+
getByName(collection, name, locale) {
|
|
19
|
+
return this.dataIndex.getByName(collection, name, locale);
|
|
20
|
+
}
|
|
21
|
+
isNameAvailable(collection, name, excludeId) {
|
|
22
|
+
const existing = this.getByName(collection, name);
|
|
23
|
+
return !existing || existing.id === excludeId;
|
|
24
|
+
}
|
|
25
|
+
getNameConflict(collection, name, excludeId) {
|
|
26
|
+
const existing = this.getByName(collection, name);
|
|
27
|
+
if (existing && existing.id !== excludeId) return existing.id;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
isDataNameValid(dataName) {
|
|
31
|
+
if (!dataName || dataName.trim() === "") return false;
|
|
32
|
+
if (dataName.includes(".")) return false;
|
|
33
|
+
if (dataName.includes("/") || dataName.includes("\\")) return false;
|
|
34
|
+
return /^[a-zA-Z0-9_-]+$/.test(dataName);
|
|
35
|
+
}
|
|
36
|
+
async create(input) {
|
|
37
|
+
if (!this.isDataNameValid(input.name)) return {
|
|
38
|
+
success: false,
|
|
39
|
+
reason: "invalid_name",
|
|
40
|
+
error: /* @__PURE__ */ new Error(`Invalid data name: ${input.name}`)
|
|
41
|
+
};
|
|
42
|
+
if (this.getByName(input.collection, input.name)) return {
|
|
43
|
+
success: false,
|
|
44
|
+
reason: "name_taken",
|
|
45
|
+
error: /* @__PURE__ */ new Error(`Data name ${input.name} already exists in collection ${input.collection}`)
|
|
46
|
+
};
|
|
47
|
+
return this.api.createContent({
|
|
48
|
+
kind: "data",
|
|
49
|
+
collection: input.collection,
|
|
50
|
+
type: "json",
|
|
51
|
+
name: input.name,
|
|
52
|
+
meta: input.meta,
|
|
53
|
+
locales: input.locales
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Data as t };
|
|
60
|
+
//# sourceMappingURL=data-Db1Iv9T0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-Db1Iv9T0.mjs","names":[],"sources":["../src/data.ts"],"sourcesContent":["import type { ContentAPI } from './content-api.interface';\nimport type { DataIndex } from './data-index';\nimport type { ContentManifest, CreateResult } from './types';\n\nexport interface DataFilters {\n collection?: string;\n locales?: string[];\n}\n\nexport interface CreateDataInput {\n collection: string;\n name: string;\n meta?: { title?: string; description?: string; [key: string]: unknown };\n locales: {\n [locale: string]: {\n publishAt?: string | null | false;\n unpublishAt?: string | null | false;\n meta?: { title?: string; description?: string; [key: string]: unknown };\n content: {\n data: Record<string, unknown>;\n };\n };\n };\n}\n\nexport class Data {\n constructor(\n private api: ContentAPI,\n private dataIndex: DataIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: DataFilters): Generator<ContentManifest> {\n // Choose the most efficient method based on filters\n if (filters?.collection) {\n if (filters.locales && filters.locales.length > 0) {\n // Filter by locales after getting collection entries\n for (const manifest of this.dataIndex.getManifestsByCollection(filters.collection)) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.dataIndex.getManifestsByCollection(filters.collection);\n }\n } else if (filters?.locales && filters.locales.length > 0) {\n // For multiple locales, we need to check each\n for (const manifest of this.dataIndex.getAllManifests()) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.dataIndex.getAllManifests();\n }\n }\n\n // Get all data collections\n get collections(): Set<string> {\n return this.dataIndex.collections;\n }\n\n // Data operations (returns null if not found)\n getByName(collection: string, name: string, locale?: string): ContentManifest | null {\n return this.dataIndex.getByName(collection, name, locale);\n }\n\n // Check if data name is available\n isNameAvailable(collection: string, name: string, excludeId?: string): boolean {\n const existing = this.getByName(collection, name);\n return !existing || existing.id === excludeId;\n }\n\n // Get the ID of content that conflicts with a data name\n getNameConflict(collection: string, name: string, excludeId?: string): string | null {\n const existing = this.getByName(collection, name);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if data name is valid\n isDataNameValid(dataName: string): boolean {\n // Data names must not be empty\n if (!dataName || dataName.trim() === '') {\n return false;\n }\n\n // Data names must not contain dots (would interfere with locale suffixes)\n if (dataName.includes('.')) {\n return false;\n }\n\n // Data names must not contain path separators\n if (dataName.includes('/') || dataName.includes('\\\\')) {\n return false;\n }\n\n // Data names should only contain alphanumeric, hyphens, underscores\n return /^[a-zA-Z0-9_-]+$/.test(dataName);\n }\n\n // Create data entry with name validation\n async create(input: CreateDataInput): Promise<CreateResult> {\n // Validate data name\n if (!this.isDataNameValid(input.name)) {\n return {\n success: false,\n reason: 'invalid_name',\n error: new Error(`Invalid data name: ${input.name}`),\n };\n }\n\n // Check if name is already taken in any locale\n const existing = this.getByName(input.collection, input.name);\n if (existing) {\n return {\n success: false,\n reason: 'name_taken',\n error: new Error(`Data name ${input.name} already exists in collection ${input.collection}`),\n };\n }\n\n // Create the content\n return this.api.createContent({\n kind: 'data',\n collection: input.collection,\n type: 'json',\n name: input.name,\n meta: input.meta,\n locales: input.locales,\n });\n }\n}\n"],"mappings":";AAyBA,IAAa,OAAb,MAAkB;CAChB,YACE,AAAQ,KACR,AAAQ,WACR;EAFQ;EACA;;CAIV,CAAC,YAAY,SAAmD;AAE9D,MAAI,SAAS,WACX,KAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAE9C;QAAK,MAAM,YAAY,KAAK,UAAU,yBAAyB,QAAQ,WAAW,CAChF,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,UAAU,yBAAyB,QAAQ,WAAW;WAE3D,SAAS,WAAW,QAAQ,QAAQ,SAAS,GAEtD;QAAK,MAAM,YAAY,KAAK,UAAU,iBAAiB,CACrD,KAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,QAAQ,CAC5D,OAAM;QAIV,QAAO,KAAK,UAAU,iBAAiB;;CAK3C,IAAI,cAA2B;AAC7B,SAAO,KAAK,UAAU;;CAIxB,UAAU,YAAoB,MAAc,QAAyC;AACnF,SAAO,KAAK,UAAU,UAAU,YAAY,MAAM,OAAO;;CAI3D,gBAAgB,YAAoB,MAAc,WAA6B;EAC7E,MAAM,WAAW,KAAK,UAAU,YAAY,KAAK;AACjD,SAAO,CAAC,YAAY,SAAS,OAAO;;CAItC,gBAAgB,YAAoB,MAAc,WAAmC;EACnF,MAAM,WAAW,KAAK,UAAU,YAAY,KAAK;AACjD,MAAI,YAAY,SAAS,OAAO,UAC9B,QAAO,SAAS;AAElB,SAAO;;CAIT,gBAAgB,UAA2B;AAEzC,MAAI,CAAC,YAAY,SAAS,MAAM,KAAK,GACnC,QAAO;AAIT,MAAI,SAAS,SAAS,IAAI,CACxB,QAAO;AAIT,MAAI,SAAS,SAAS,IAAI,IAAI,SAAS,SAAS,KAAK,CACnD,QAAO;AAIT,SAAO,mBAAmB,KAAK,SAAS;;CAI1C,MAAM,OAAO,OAA+C;AAE1D,MAAI,CAAC,KAAK,gBAAgB,MAAM,KAAK,CACnC,QAAO;GACL,SAAS;GACT,QAAQ;GACR,uBAAO,IAAI,MAAM,sBAAsB,MAAM,OAAO;GACrD;AAKH,MADiB,KAAK,UAAU,MAAM,YAAY,MAAM,KAAK,CAE3D,QAAO;GACL,SAAS;GACT,QAAQ;GACR,uBAAO,IAAI,MAAM,aAAa,MAAM,KAAK,gCAAgC,MAAM,aAAa;GAC7F;AAIH,SAAO,KAAK,IAAI,cAAc;GAC5B,MAAM;GACN,YAAY,MAAM;GAClB,MAAM;GACN,MAAM,MAAM;GACZ,MAAM,MAAM;GACZ,SAAS,MAAM;GAChB,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { A as Site, I as ContentAPIOptions, J as CreateResult, K as CreateContentInput, L as ContentData, O as Blocks, P as BatchResult, Q as DeleteResult, R as ContentEntry, V as ContentManifest, Z as DeleteLocaleInput, ct as LocalizedManifest, gt as UpdateResult, ht as UpdateLocaleInput, j as Data, k as ContentAPI, mt as SitesConfig, nt as GlobalFilters, st as LocalizedEntry, tt as FindOptions } from "./content-operations-Dv67amz3.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/filesystem-content-api.d.ts
|
|
4
|
+
interface ReindexResult {
|
|
5
|
+
filesProcessed: number;
|
|
6
|
+
filesSkipped: number;
|
|
7
|
+
filesDeleted?: number;
|
|
8
|
+
errors?: number;
|
|
9
|
+
updated: LocalizedManifest[];
|
|
10
|
+
deleted?: Array<{
|
|
11
|
+
id: string;
|
|
12
|
+
locale: string;
|
|
13
|
+
kind: 'page' | 'block' | 'data';
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* FileSystem-based Content API Implementation
|
|
18
|
+
*
|
|
19
|
+
* Stores content as files on disk in a git-friendly format:
|
|
20
|
+
* - Pages: /{site}/pages/{filename}.{locale}.vxjson
|
|
21
|
+
* - Blocks: /blocks/{collection}/{filename}.{locale}.{mdx|vxjson}
|
|
22
|
+
*
|
|
23
|
+
* ## Indexing
|
|
24
|
+
*
|
|
25
|
+
* Content is indexed at startup for performance. The index is cached per
|
|
26
|
+
* content root path and cleared when the process restarts.
|
|
27
|
+
*
|
|
28
|
+
* ## Read-Repair
|
|
29
|
+
*
|
|
30
|
+
* Since files can be modified externally (git, editors), this implementation:
|
|
31
|
+
*
|
|
32
|
+
* 1. Repairs invalid VXJSON files (ensures "content" field is last)
|
|
33
|
+
* 2. Adds missing required fields (id, created, modified)
|
|
34
|
+
* 3. Handles files added after initial indexing
|
|
35
|
+
* 4. Updates the index when files are repaired or discovered
|
|
36
|
+
*
|
|
37
|
+
* ## Performance
|
|
38
|
+
*
|
|
39
|
+
* - Initial indexing reads only first 4KB of each file
|
|
40
|
+
* - Full content is loaded on demand
|
|
41
|
+
* - ETags are calculated using streaming for efficiency
|
|
42
|
+
*/
|
|
43
|
+
declare class FileSystemContentAPI implements ContentAPI {
|
|
44
|
+
private contentRoot;
|
|
45
|
+
private absoluteContentRoot;
|
|
46
|
+
private contentIndex;
|
|
47
|
+
readonly sitesConfig: SitesConfig;
|
|
48
|
+
readonly blocks: Blocks;
|
|
49
|
+
readonly data: Data;
|
|
50
|
+
private readonly sites;
|
|
51
|
+
get normalizedContentRoot(): string;
|
|
52
|
+
private constructor();
|
|
53
|
+
static create(options: ContentAPIOptions): Promise<FileSystemContentAPI>;
|
|
54
|
+
/**
|
|
55
|
+
* Clear all caches - useful for testing
|
|
56
|
+
*/
|
|
57
|
+
static clearCaches(): void;
|
|
58
|
+
private indexAllContent;
|
|
59
|
+
private parseFileHeaderWithRepair;
|
|
60
|
+
/**
|
|
61
|
+
* Perform read-repair by writing back the file with missing fields
|
|
62
|
+
* This ensures stable IDs and timestamps across restarts
|
|
63
|
+
*/
|
|
64
|
+
private performReadRepair;
|
|
65
|
+
private scanContentFiles;
|
|
66
|
+
private getFilePath;
|
|
67
|
+
/**
|
|
68
|
+
* Parse a file path back into its components for checking against the path index
|
|
69
|
+
* Returns null if the path doesn't match expected patterns
|
|
70
|
+
*/
|
|
71
|
+
parseFilePath(filePath: string): {
|
|
72
|
+
kind: 'page' | 'block' | 'data';
|
|
73
|
+
site?: string;
|
|
74
|
+
collection: string;
|
|
75
|
+
pathname?: string;
|
|
76
|
+
name?: string;
|
|
77
|
+
locale: string;
|
|
78
|
+
} | null;
|
|
79
|
+
getContent(id: string): Promise<ContentEntry | null>;
|
|
80
|
+
getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
|
|
81
|
+
private readLocaleFile;
|
|
82
|
+
createContent(data: CreateContentInput): Promise<CreateResult>;
|
|
83
|
+
updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
|
|
84
|
+
deleteContent(id: string, etag: string): Promise<DeleteResult>;
|
|
85
|
+
deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
|
|
86
|
+
getSite(siteName: string): Site | null;
|
|
87
|
+
listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
|
|
88
|
+
findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
|
|
89
|
+
/**
|
|
90
|
+
* Reindex files that were added or changed after initial creation
|
|
91
|
+
*
|
|
92
|
+
* This method:
|
|
93
|
+
* 1. Either scans for all content files or processes specific paths
|
|
94
|
+
* 2. Uses the path index to check if files are already indexed
|
|
95
|
+
* 3. Indexes new files or force-reindexes specified files
|
|
96
|
+
* 4. Optionally handles file deletions
|
|
97
|
+
*
|
|
98
|
+
* @param paths - Optional array of specific file paths to reindex. If not provided, scans all content files.
|
|
99
|
+
* @param options - Options for reindexing behavior
|
|
100
|
+
* @returns Statistics about the reindexing operation
|
|
101
|
+
*/
|
|
102
|
+
reindex(paths?: string[], options?: {
|
|
103
|
+
handleDeletions?: boolean;
|
|
104
|
+
}): Promise<ReindexResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Read content directly from cache
|
|
107
|
+
* For testing purposes - returns null if not cached
|
|
108
|
+
*/
|
|
109
|
+
readFromCache(id: string, locale: string): Promise<ContentData | null>;
|
|
110
|
+
getContentAsBuffer(id: string, locale: string): Promise<{
|
|
111
|
+
buffer: Uint8Array;
|
|
112
|
+
etag: string;
|
|
113
|
+
contentType: 'application/json' | 'text/mdx';
|
|
114
|
+
} | null>;
|
|
115
|
+
batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { FileSystemContentAPI as t };
|
|
119
|
+
//# sourceMappingURL=filesystem-content-api-C1TM0GLo.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem-content-api-C1TM0GLo.d.mts","names":[],"sources":["../src/filesystem-content-api.ts"],"mappings":";;;UAqDU,aAAA;EACR,cAAA;EACA,YAAA;EACA,YAAA;EACA,MAAA;EAEA,OAAA,EAAS,iBAAA;EACT,OAAA,GAAU,KAAA;IAAQ,EAAA;IAAY,MAAA;IAAgB,IAAA;EAAA;AAAA;;;;AAoGhD;;;;;;;;;;;;;;;;;;;;;;;;cAAa,oBAAA,YAAgC,UAAA;EAAA,QACnC,WAAA;EAAA,QACA,mBAAA;EAAA,QACA,YAAA;EAAA,SACC,WAAA,EAAa,WAAA;EAAA,SACb,MAAA,EAAQ,MAAA;EAAA,SACR,IAAA,EAAM,IAAA;EAAA,iBACE,KAAA;EAAA,IAGb,qBAAA,CAAA;EAAA,QAIG,WAAA,CAAA;EAAA,OAwCM,MAAA,CAAO,OAAA,EAAS,iBAAA,GAAoB,OAAA,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