@conloca/content-api 0.1.0 → 0.1.1

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.
Files changed (67) hide show
  1. package/dist/asset-manifest.d.ts +20 -0
  2. package/dist/asset-manifest.d.ts.map +1 -0
  3. package/dist/asset-operations.d.ts +156 -0
  4. package/dist/asset-operations.d.ts.map +1 -0
  5. package/dist/asset-types.d.ts +56 -0
  6. package/dist/asset-types.d.ts.map +1 -0
  7. package/dist/base-content-index.d.ts +57 -0
  8. package/dist/base-content-index.d.ts.map +1 -0
  9. package/dist/block-index.d.ts +9 -0
  10. package/dist/block-index.d.ts.map +1 -0
  11. package/dist/blocks.d.ts +16 -0
  12. package/dist/blocks.d.ts.map +1 -0
  13. package/dist/cf-access.d.ts +31 -0
  14. package/dist/cf-access.d.ts.map +1 -0
  15. package/dist/component-registry.d.ts +50 -0
  16. package/dist/component-registry.d.ts.map +1 -0
  17. package/dist/component-registry.types.d.ts +11 -0
  18. package/dist/component-registry.types.d.ts.map +1 -0
  19. package/dist/content-api.interface.d.ts +64 -0
  20. package/dist/content-api.interface.d.ts.map +1 -0
  21. package/dist/content-filters.d.ts +31 -0
  22. package/dist/content-filters.d.ts.map +1 -0
  23. package/dist/content-index.d.ts +126 -0
  24. package/dist/content-index.d.ts.map +1 -0
  25. package/dist/content-operations.d.ts +94 -0
  26. package/dist/content-operations.d.ts.map +1 -0
  27. package/dist/content-utils.d.ts +109 -0
  28. package/dist/content-utils.d.ts.map +1 -0
  29. package/dist/content-watcher.d.ts +25 -0
  30. package/dist/content-watcher.d.ts.map +1 -0
  31. package/dist/data-index.d.ts +8 -0
  32. package/dist/data-index.d.ts.map +1 -0
  33. package/dist/data.d.ts +43 -0
  34. package/dist/data.d.ts.map +1 -0
  35. package/dist/etag-utils.d.ts +77 -0
  36. package/dist/etag-utils.d.ts.map +1 -0
  37. package/dist/filesystem-content-api.d.ts +120 -0
  38. package/dist/filesystem-content-api.d.ts.map +1 -0
  39. package/dist/git-operations.d.ts +44 -0
  40. package/dist/git-operations.d.ts.map +1 -0
  41. package/dist/in-memory-content-api.d.ts +35 -0
  42. package/dist/in-memory-content-api.d.ts.map +1 -0
  43. package/dist/index.d.ts +17 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/json-whitespace-view.d.ts +32 -0
  46. package/dist/json-whitespace-view.d.ts.map +1 -0
  47. package/dist/middleware.d.ts +20 -0
  48. package/dist/middleware.d.ts.map +1 -0
  49. package/dist/node.d.ts +25 -0
  50. package/dist/node.d.ts.map +1 -0
  51. package/dist/schemas/index.d.ts +179 -0
  52. package/dist/schemas/index.d.ts.map +1 -0
  53. package/dist/site-index.d.ts +60 -0
  54. package/dist/site-index.d.ts.map +1 -0
  55. package/dist/site.d.ts +21 -0
  56. package/dist/site.d.ts.map +1 -0
  57. package/dist/types.d.ts +329 -0
  58. package/dist/types.d.ts.map +1 -0
  59. package/dist/url-safe-base64.d.ts +12 -0
  60. package/dist/url-safe-base64.d.ts.map +1 -0
  61. package/dist/utils.d.ts +46 -0
  62. package/dist/utils.d.ts.map +1 -0
  63. package/dist/vite-plugin.d.ts +12 -0
  64. package/dist/vite-plugin.d.ts.map +1 -0
  65. package/dist/vxjson.d.ts +111 -0
  66. package/dist/vxjson.d.ts.map +1 -0
  67. package/package.json +1 -4
@@ -0,0 +1,126 @@
1
+ import { BlockIndex } from './block-index';
2
+ import { DataIndex } from './data-index';
3
+ import { SiteIndex } from './site-index';
4
+ import type { ContentData, ContentIdentity, ContentManifest, LocaleVersion, SitesConfig } from './types';
5
+ export declare class ContentIndex {
6
+ private sitesConfig;
7
+ private static get cache();
8
+ private siteIndexes;
9
+ private blockIndex;
10
+ private dataIndex;
11
+ private constructor();
12
+ /**
13
+ * Get cached index or create a new one
14
+ */
15
+ static getCachedOrCreate(contentRoot: string, sitesConfig: SitesConfig): Promise<ContentIndex>;
16
+ /**
17
+ * Clear all cached indexes
18
+ */
19
+ static clearCache(): void;
20
+ /**
21
+ * Create a new index without caching - for testing
22
+ */
23
+ static createUncached(sitesConfig: SitesConfig): ContentIndex;
24
+ /**
25
+ * Add or update content in the appropriate index
26
+ * Updates a single locale's manifest and content cache if provided
27
+ */
28
+ addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
29
+ /**
30
+ * Remove a specific locale from content
31
+ */
32
+ removeLocale(id: string, locale: string): void;
33
+ /**
34
+ * Get cached content
35
+ */
36
+ getCachedContent(id: string, locale: string): ContentData | null;
37
+ /**
38
+ * Remove an entry from all indexes
39
+ */
40
+ removeEntry(id: string): void;
41
+ /**
42
+ * Get content manifest for a content ID
43
+ */
44
+ getManifest(id: string): ContentManifest | null;
45
+ /**
46
+ * Get a specific locale manifest
47
+ */
48
+ getLocaleVersion(id: string, locale: string): LocaleVersion | null;
49
+ /**
50
+ * Get site index
51
+ */
52
+ getSiteIndex(site: string): SiteIndex | null;
53
+ /**
54
+ * Get block index
55
+ */
56
+ getBlockIndex(): BlockIndex;
57
+ /**
58
+ * Find content by pathname (delegates to site indexes)
59
+ */
60
+ getByPathname(site: string, pathname: string, locale?: string): ContentManifest | null;
61
+ /**
62
+ * Find content by previous pathname (for redirects)
63
+ */
64
+ getByPreviousPathname(site: string, pathname: string, locale?: string): ContentManifest | null;
65
+ /**
66
+ * Find block by name
67
+ */
68
+ getBlockByName(collection: string, name: string, locale?: string): ContentManifest | null;
69
+ /**
70
+ * Get data index
71
+ */
72
+ getDataIndex(): DataIndex;
73
+ /**
74
+ * Find data entry by name
75
+ */
76
+ getDataByName(collection: string, name: string, locale?: string): ContentManifest | null;
77
+ /**
78
+ * Get all collections for data
79
+ */
80
+ getDataCollections(): Set<string>;
81
+ /**
82
+ * List all content (for iteration)
83
+ */
84
+ listAllContent(): Generator<ContentManifest>;
85
+ /**
86
+ * Generator for all sites
87
+ */
88
+ allSites(): Generator<string>;
89
+ /**
90
+ * Get all collections for a site
91
+ */
92
+ getCollectionsForSite(site: string): Set<string>;
93
+ /**
94
+ * Get all collections for blocks
95
+ */
96
+ getBlockCollections(): Set<string>;
97
+ /**
98
+ * Get default locale for a site
99
+ */
100
+ getDefaultLocale(site: string): string;
101
+ /**
102
+ * Find content missing a specific locale
103
+ */
104
+ findUntranslatedContent(targetLocale: string, options?: {
105
+ excludeSites?: string[];
106
+ includeUnpublished?: boolean;
107
+ }): Generator<ContentManifest>;
108
+ /**
109
+ * Generators for efficient filtering
110
+ */
111
+ getManifestsForKind(kind: 'block' | 'page' | 'data'): Generator<ContentManifest>;
112
+ getManifestsForSite(site: string): Generator<ContentManifest>;
113
+ getManifestsForSiteLocale(site: string, locale: string): Generator<ContentManifest>;
114
+ getManifestsForSiteCollection(site: string, collection: string): Generator<ContentManifest>;
115
+ getManifestsForLocale(locale: string): Generator<ContentManifest>;
116
+ getManifestsForCollection(collection: string): Generator<ContentManifest>;
117
+ /**
118
+ * Get the count of indexed content entries
119
+ */
120
+ get entryCount(): number;
121
+ /**
122
+ * Clear all indexes
123
+ */
124
+ clear(): void;
125
+ }
126
+ //# sourceMappingURL=content-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-index.d.ts","sourceRoot":"","sources":["../src/content-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAYzG,qBAAa,YAAY;IAeH,OAAO,CAAC,WAAW;IAbvC,OAAO,CAAC,MAAM,KAAK,KAAK,GAEvB;IAGD,OAAO,CAAC,WAAW,CAAwC;IAG3D,OAAO,CAAC,UAAU,CAAa;IAG/B,OAAO,CAAC,SAAS,CAAY;IAE7B,OAAO;IAcP;;OAEG;WACU,iBAAiB,CAAC,WAA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C,eAAe,CAAC;IAoB1E;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAUvB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAUd"}
@@ -0,0 +1,94 @@
1
+ import type { Blocks } from './blocks';
2
+ import { generateContentId, isContentPublished } from './content-utils';
3
+ import type { Site } from './site';
4
+ import type { ContentMeta, CreateContentInput, LocaleUpdateData, LocaleVersion } from './types';
5
+ /**
6
+ * Shared business logic for content operations
7
+ * Used by both FileSystemContentAPI and InMemoryContentAPI
8
+ */
9
+ export interface ValidationResult {
10
+ valid: boolean;
11
+ error?: string;
12
+ sortedMeta?: ContentMeta;
13
+ size?: number;
14
+ }
15
+ export interface CreateValidationResult {
16
+ valid: boolean;
17
+ error?: string;
18
+ reason?: 'metadata_too_large' | 'pathname_taken' | 'pathname_in_redirects' | 'invalid_name' | 'name_taken';
19
+ existingId?: string;
20
+ }
21
+ /**
22
+ * Validate and prepare metadata for storage
23
+ * Ensures title exists and metadata doesn't exceed 4KB
24
+ */
25
+ export declare function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult;
26
+ /**
27
+ * Build pathname history update
28
+ */
29
+ export declare function buildPathnameHistory(oldPathname: string | undefined, newPathname: string | undefined, isPublished: boolean, now: string): Record<string, string>;
30
+ /**
31
+ * Build a locale manifest
32
+ */
33
+ export declare function buildLocaleVersion(params: {
34
+ locale: string;
35
+ etag: string;
36
+ created: string;
37
+ modified: string;
38
+ meta: ContentMeta;
39
+ kind: 'block' | 'page' | 'data';
40
+ publishAt?: string;
41
+ unpublishAt?: string;
42
+ pathname?: string;
43
+ name?: string;
44
+ previousPathnames?: Record<string, string>;
45
+ }): LocaleVersion;
46
+ /**
47
+ * Update publish dates on a locale manifest
48
+ */
49
+ export declare function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void;
50
+ /**
51
+ * Validate content creation data
52
+ */
53
+ export declare function validateCreateContent(data: CreateContentInput, sites: Record<string, Site>, blocks: Blocks, dataApi?: {
54
+ isDataNameValid: (name: string) => boolean;
55
+ getNameConflict: (collection: string, name: string) => string | null;
56
+ }): CreateValidationResult;
57
+ /**
58
+ * Generate a new content ID
59
+ */
60
+ export { generateContentId };
61
+ /**
62
+ * Check if content is published
63
+ */
64
+ export { isContentPublished };
65
+ /**
66
+ * Update scope bit flags
67
+ * Can be combined with bitwise OR and checked with bitwise AND
68
+ */
69
+ export declare const UPDATE_SCOPE: {
70
+ readonly NONE: 0;
71
+ readonly META: number;
72
+ readonly CONTENT: number;
73
+ readonly BOTH: 3;
74
+ };
75
+ export type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];
76
+ /**
77
+ * Determine what parts of content are being updated
78
+ * Returns bit flags that can be checked with bitwise AND
79
+ *
80
+ * Example usage:
81
+ * ```
82
+ * const scope = analyzeUpdateScope(data);
83
+ * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
84
+ * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
85
+ * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
86
+ * ```
87
+ */
88
+ export declare function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope;
89
+ /**
90
+ * Determine whether the modified timestamp should be updated
91
+ * Updates for ANY change - either metadata or content
92
+ */
93
+ export declare function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean;
94
+ //# sourceMappingURL=content-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-operations.d.ts","sourceRoot":"","sources":["../src/content-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhG;;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,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAoBxF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACtE,GACA,sBAAsB,CA+HxB;AAED;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,CAetE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAG7E"}
@@ -0,0 +1,109 @@
1
+ import type { ContentMeta, LocaleVersion } from './types';
2
+ export declare function localesOf<T>(manifest: {
3
+ locales: Record<string, T | undefined>;
4
+ }): Generator<T>;
5
+ /**
6
+ * Pure utility functions for content operations
7
+ * These functions don't depend on any class state and can be shared
8
+ * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
9
+ */
10
+ /**
11
+ * Check if content is published based on publishAt/unpublishAt dates
12
+ */
13
+ export declare function isContentPublished(localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>, now?: Date): boolean;
14
+ /**
15
+ * Validate that metadata doesn't exceed 4KB when serialized
16
+ * This ensures efficient indexing as per the specification
17
+ */
18
+ export declare function isMetadataTooLarge(meta: ContentMeta): boolean;
19
+ /**
20
+ * Extract block name from various sources
21
+ * Used when displaying blocks in the UI
22
+ */
23
+ export declare function extractBlockName(source: string): string;
24
+ /**
25
+ * Validate block name according to the specification
26
+ * - Cannot contain dots (reserved for locale separator)
27
+ * - Cannot contain slashes (would create subdirectories)
28
+ * - Cannot contain spaces (for clean filenames)
29
+ * - Must have at least one character
30
+ */
31
+ export declare function isValidBlockName(name: string): boolean;
32
+ /**
33
+ * Format file size for display with human-readable units
34
+ * @example formatFileSize(1536) // "1.5 KB"
35
+ */
36
+ export declare function formatFileSize(bytes: number): string;
37
+ /**
38
+ * Calculate metadata size in bytes
39
+ */
40
+ export declare function getMetadataSize(meta: ContentMeta): number;
41
+ /**
42
+ * Check if a pathname is valid
43
+ * - Must start with /
44
+ * - Cannot contain spaces (should be URL-encoded)
45
+ * - Cannot contain special characters that would break URLs
46
+ */
47
+ export declare function isValidPathname(pathname: string): boolean;
48
+ /**
49
+ * Normalize a pathname to ensure consistency
50
+ * - Ensure it starts with /
51
+ * - Remove trailing slashes (except for root)
52
+ * - Collapse multiple slashes
53
+ */
54
+ export declare function normalizePathname(pathname: string): string;
55
+ /**
56
+ * Generate a content ID in the standard format
57
+ * IDs are prefixed with "vx-" followed by 8 random characters
58
+ */
59
+ export declare function generateContentId(): string;
60
+ /**
61
+ * Get the current date/time in ISO format
62
+ * Used for timestamps in content files
63
+ */
64
+ export declare function getCurrentISODate(): string;
65
+ /**
66
+ * Parse a date string safely
67
+ * Returns null if invalid
68
+ */
69
+ export declare function parseDate(dateStr: string | undefined): Date | null;
70
+ /**
71
+ * Creates a V8-optimized object by mapping site names to values.
72
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
73
+ *
74
+ * @param sitesConfig - Sites configuration containing site names
75
+ * @param factory - Function that creates the value for each site
76
+ * @returns Object with all sites initialized in alphabetical order
77
+ */
78
+ export declare function mapSiteNames<T>(sitesConfig: {
79
+ sites: Record<string, any>;
80
+ }, factory: (siteName: string) => T): Record<string, T>;
81
+ /**
82
+ * Creates a V8-optimized object by mapping locale names to values.
83
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
84
+ *
85
+ * @param locales - Array of locale codes
86
+ * @param factory - Function that creates the value for each locale
87
+ * @returns Object with all locales initialized in array order
88
+ */
89
+ export declare function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T>;
90
+ /**
91
+ * Resolves a publish date value to a valid string or undefined.
92
+ * Handles various input types including null, false, and empty strings.
93
+ *
94
+ * @param updateValue - The value being updated (string | null | false | undefined)
95
+ * @param currentValue - The current value to fall back to if updateValue is undefined
96
+ * @returns A valid date string or undefined
97
+ */
98
+ export declare function resolvePublishDate(updateValue: string | null | false | undefined, currentValue: string | undefined): string | undefined;
99
+ /**
100
+ * Serializes MDX content with frontmatter.
101
+ * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
102
+ * consistent MDX output that includes frontmatter for variable access.
103
+ *
104
+ * @param frontmatterData - The frontmatter data to serialize
105
+ * @param mdxContent - The MDX content (without frontmatter)
106
+ * @returns Complete MDX file content with frontmatter
107
+ */
108
+ export declare function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string;
109
+ //# sourceMappingURL=content-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-utils.d.ts","sourceRoot":"","sources":["../src/content-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,wBAAiB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAIhG;AAED;;;;GAIG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,IAAI,CAAC,aAAa,EAA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C,CAAC,CAMlG;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,EAC9C,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI5G"}
@@ -0,0 +1,25 @@
1
+ import { FileSystemContentAPI } from './filesystem-content-api';
2
+ export interface ContentWatcherOptions {
3
+ contentRoot: string;
4
+ canvasDir?: string;
5
+ }
6
+ export interface WebSocketSender {
7
+ send(payload: {
8
+ type: string;
9
+ event: string;
10
+ data: any;
11
+ }): void;
12
+ }
13
+ /**
14
+ * Creates a content API instance for the given options
15
+ */
16
+ export declare function createContentAPI(options: ContentWatcherOptions): Promise<FileSystemContentAPI>;
17
+ /**
18
+ * Creates file change handlers for content watching
19
+ */
20
+ export declare function createContentWatchHandlers(contentApi: FileSystemContentAPI, options: ContentWatcherOptions, ws: WebSocketSender): {
21
+ onChange: (file: string) => Promise<void>;
22
+ onAdd: (file: string) => Promise<void>;
23
+ onUnlink: (file: string) => Promise<void>;
24
+ };
25
+ //# sourceMappingURL=content-watcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-watcher.d.ts","sourceRoot":"","sources":["../src/content-watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAC;CACjE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAKpG;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,qBAAqB,EAC9B,EAAE,EAAE,eAAe;qBAyDA,MAAM;kBACT,MAAM;qBACH,MAAM;EAE1B"}
@@ -0,0 +1,8 @@
1
+ import { BaseContentIndex } from './base-content-index';
2
+ /**
3
+ * V8-optimized index for data collections
4
+ * Maintains collection->name->locale lookups
5
+ */
6
+ export declare class DataIndex extends BaseContentIndex {
7
+ }
8
+ //# sourceMappingURL=data-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-index.d.ts","sourceRoot":"","sources":["../src/data-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;GAGG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;CAAG"}
package/dist/data.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { ContentAPI } from './content-api.interface';
2
+ import type { DataIndex } from './data-index';
3
+ import type { ContentManifest, CreateResult } from './types';
4
+ export interface DataFilters {
5
+ collection?: string;
6
+ locales?: string[];
7
+ }
8
+ export interface CreateDataInput {
9
+ collection: string;
10
+ name: string;
11
+ meta?: {
12
+ title?: string;
13
+ description?: string;
14
+ [key: string]: unknown;
15
+ };
16
+ locales: {
17
+ [locale: string]: {
18
+ publishAt?: string | null | false;
19
+ unpublishAt?: string | null | false;
20
+ meta?: {
21
+ title?: string;
22
+ description?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ content: {
26
+ data: Record<string, unknown>;
27
+ };
28
+ };
29
+ };
30
+ }
31
+ export declare class Data {
32
+ private api;
33
+ private dataIndex;
34
+ constructor(api: ContentAPI, dataIndex: DataIndex);
35
+ listContent(filters?: DataFilters): Generator<ContentManifest>;
36
+ get collections(): Set<string>;
37
+ getByName(collection: string, name: string, locale?: string): ContentManifest | null;
38
+ isNameAvailable(collection: string, name: string, excludeId?: string): boolean;
39
+ getNameConflict(collection: string, name: string, excludeId?: string): string | null;
40
+ isDataNameValid(dataName: string): boolean;
41
+ create(input: CreateDataInput): Promise<CreateResult>;
42
+ }
43
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACxE,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG;YAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;YAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;YACpC,IAAI,CAAC,EAAE;gBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;gBAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;aAAE,CAAC;YACxE,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;aAC/B,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,qBAAa,IAAI;IAEb,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,SAAS;gBADT,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,SAAS;IAI7B,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC,eAAe,CAAC;IA0B/D,IAAI,WAAW,IAAI,GAAG,CAAC,MAAM,CAAC,CAE7B;IAGD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAKpF,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAM9E,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IASpF,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAqBpC,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC;CA8B5D"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Dual ETag system for content API
3
+ * - Meta ETag: Based on non-derived LocaleManifest fields (using xxHash)
4
+ * - Content ETag: Based on ContentProp.content (using SHA256)
5
+ * Both skip whitespace to allow pretty-printing without affecting hashes
6
+ *
7
+ * Format: "metaEtag.contentEtag" in query strings
8
+ */
9
+ /**
10
+ * Calculate metadata ETag using xxHash from buffer view
11
+ * @param buffer - The file buffer view
12
+ * @param start - Start position (inclusive)
13
+ * @param end - End position (exclusive), or -1 for entire buffer
14
+ */
15
+ export declare function calculateMetaEtagFromBuffer(buffer: Uint8Array, start?: number, end?: number): string;
16
+ /**
17
+ * Calculate content ETag using SHA256 from buffer view
18
+ * @param buffer - The file buffer view
19
+ * @param start - Start position (inclusive)
20
+ * @param end - End position (exclusive), or -1 for entire buffer
21
+ */
22
+ export declare function calculateContentEtagFromBuffer(buffer: Uint8Array, start?: number, end?: number): string;
23
+ /**
24
+ * Find the content start position in MDX buffer (after second ---)
25
+ * @param buffer - The MDX content buffer
26
+ * @returns Position where content starts, or -1 if not found
27
+ */
28
+ export declare function findMdxContentStartPosition(buffer: Uint8Array): number;
29
+ /**
30
+ * Calculate both ETags from an MDX buffer
31
+ *
32
+ * MDX files use YAML frontmatter which has different characteristics than JSON:
33
+ * - YAML does not require quotes around keys or string values
34
+ * - YAML allows multiple formatting styles (flow vs block style)
35
+ * - YAML field order is not significant for parsing
36
+ *
37
+ * Unlike VXJSON which requires "content" to be the last field and needs special
38
+ * parsing to validate structure, YAML frontmatter can be hashed as-is because:
39
+ * 1. The frontmatter boundaries are clearly delimited by ---
40
+ * 2. Different YAML formatting of the same data SHOULD produce different hashes
41
+ * (e.g., flow style [a,b] vs block style with dashes)
42
+ * 3. There's no requirement to validate field ordering
43
+ *
44
+ * This means we can directly hash the YAML bytes without any whitespace
45
+ * normalization or parsing, which is both simpler and more correct.
46
+ *
47
+ * @param buffer - The complete file buffer
48
+ * @param contentStartPos - Position where content starts (after second ---), or -1 if no content
49
+ */
50
+ export declare function calculateEtagsFromMdxBuffer(buffer: Uint8Array, contentStartPos: number): {
51
+ metaEtag: string;
52
+ contentEtag: string;
53
+ };
54
+ /**
55
+ * Combined ETag structure
56
+ */
57
+ export interface DualEtag {
58
+ meta: string;
59
+ content: string;
60
+ }
61
+ /**
62
+ * Format dual ETags for query string: "meta.content"
63
+ */
64
+ export declare function formatDualEtag(etags: DualEtag): string;
65
+ /**
66
+ * Parse dual ETags from query string: "meta.content"
67
+ */
68
+ export declare function parseDualEtag(etag: string): DualEtag | null;
69
+ /**
70
+ * Check if etag matches either meta or content
71
+ */
72
+ export declare function matchesEtag(providedEtag: string, currentMeta: string, currentContent: string): {
73
+ matches: boolean;
74
+ metaChanged: boolean;
75
+ contentChanged: boolean;
76
+ };
77
+ //# sourceMappingURL=etag-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"etag-utils.d.ts","sourceRoot":"","sources":["../src/etag-utils.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,SAAI,EAAE,GAAG,SAAK,GAAG,MAAM,CAS3F;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,SAAI,EAAE,GAAG,SAAK,GAAG,MAAM,CAQ9F;AAKD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAiCtE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,MAAM,GACtB;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CA8BA;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAQ3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACzB,CAkBA"}
@@ -0,0 +1,120 @@
1
+ import { Blocks } from './blocks';
2
+ import type { ContentAPI } from './content-api.interface';
3
+ import { Data } from './data';
4
+ import { Site } from './site';
5
+ import type { BatchResult, ContentAPIOptions, ContentData, ContentEntry, ContentManifest, CreateContentInput, CreateResult, DeleteLocaleInput, DeleteResult, FindOptions, GlobalFilters, LocalizedEntry, LocalizedManifest, SitesConfig, UpdateLocaleInput, UpdateResult } from './types';
6
+ interface ReindexResult {
7
+ filesProcessed: number;
8
+ filesSkipped: number;
9
+ filesDeleted?: number;
10
+ errors?: number;
11
+ updated: LocalizedManifest[];
12
+ deleted?: Array<{
13
+ id: string;
14
+ locale: string;
15
+ kind: 'page' | 'block' | 'data';
16
+ }>;
17
+ }
18
+ /**
19
+ * FileSystem-based Content API Implementation
20
+ *
21
+ * Stores content as files on disk in a git-friendly format:
22
+ * - Pages: /{site}/pages/{filename}.{locale}.vxjson
23
+ * - Blocks: /blocks/{collection}/{filename}.{locale}.{mdx|vxjson}
24
+ *
25
+ * ## Indexing
26
+ *
27
+ * Content is indexed at startup for performance. The index is cached per
28
+ * content root path and cleared when the process restarts.
29
+ *
30
+ * ## Read-Repair
31
+ *
32
+ * Since files can be modified externally (git, editors), this implementation:
33
+ *
34
+ * 1. Repairs invalid VXJSON files (ensures "content" field is last)
35
+ * 2. Adds missing required fields (id, created, modified)
36
+ * 3. Handles files added after initial indexing
37
+ * 4. Updates the index when files are repaired or discovered
38
+ *
39
+ * ## Performance
40
+ *
41
+ * - Initial indexing reads only first 4KB of each file
42
+ * - Full content is loaded on demand
43
+ * - ETags are calculated using streaming for efficiency
44
+ */
45
+ export declare class FileSystemContentAPI implements ContentAPI {
46
+ private contentRoot;
47
+ private absoluteContentRoot;
48
+ private contentIndex;
49
+ readonly sitesConfig: SitesConfig;
50
+ readonly blocks: Blocks;
51
+ readonly data: Data;
52
+ private readonly sites;
53
+ get normalizedContentRoot(): string;
54
+ private constructor();
55
+ static create(options: ContentAPIOptions): Promise<FileSystemContentAPI>;
56
+ /**
57
+ * Clear all caches - useful for testing
58
+ */
59
+ static clearCaches(): void;
60
+ private indexAllContent;
61
+ private parseFileHeaderWithRepair;
62
+ /**
63
+ * Perform read-repair by writing back the file with missing fields
64
+ * This ensures stable IDs and timestamps across restarts
65
+ */
66
+ private performReadRepair;
67
+ private scanContentFiles;
68
+ private getFilePath;
69
+ /**
70
+ * Parse a file path back into its components for checking against the path index
71
+ * Returns null if the path doesn't match expected patterns
72
+ */
73
+ parseFilePath(filePath: string): {
74
+ kind: 'page' | 'block' | 'data';
75
+ site?: string;
76
+ collection: string;
77
+ pathname?: string;
78
+ name?: string;
79
+ locale: string;
80
+ } | null;
81
+ getContent(id: string): Promise<ContentEntry | null>;
82
+ getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
83
+ private readLocaleFile;
84
+ createContent(data: CreateContentInput): Promise<CreateResult>;
85
+ updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
86
+ deleteContent(id: string, etag: string): Promise<DeleteResult>;
87
+ deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
88
+ getSite(siteName: string): Site | null;
89
+ listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
90
+ findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
91
+ /**
92
+ * Reindex files that were added or changed after initial creation
93
+ *
94
+ * This method:
95
+ * 1. Either scans for all content files or processes specific paths
96
+ * 2. Uses the path index to check if files are already indexed
97
+ * 3. Indexes new files or force-reindexes specified files
98
+ * 4. Optionally handles file deletions
99
+ *
100
+ * @param paths - Optional array of specific file paths to reindex. If not provided, scans all content files.
101
+ * @param options - Options for reindexing behavior
102
+ * @returns Statistics about the reindexing operation
103
+ */
104
+ reindex(paths?: string[], options?: {
105
+ handleDeletions?: boolean;
106
+ }): Promise<ReindexResult>;
107
+ /**
108
+ * Read content directly from cache
109
+ * For testing purposes - returns null if not cached
110
+ */
111
+ readFromCache(id: string, locale: string): Promise<ContentData | null>;
112
+ getContentAsBuffer(id: string, locale: string): Promise<{
113
+ buffer: Uint8Array;
114
+ etag: string;
115
+ contentType: 'application/json' | 'text/mdx';
116
+ } | null>;
117
+ batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
118
+ }
119
+ export {};
120
+ //# sourceMappingURL=filesystem-content-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-content-api.d.ts","sourceRoot":"","sources":["../src/filesystem-content-api.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAgB1D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,YAAY,EAEZ,eAAe,EAGf,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,EAIb,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,YAAY,EAEb,MAAM,SAAS,CAAC;AAEjB,UAAU,aAAa;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;CAClF;AAwED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,oBAAqB,YAAW,UAAU;IACrD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,YAAY,CAAe;IACnC,QAAQ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