@conloca/content-api 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/asset-manifest.d.ts +23 -0
  2. package/dist/asset-manifest.d.ts.map +1 -0
  3. package/dist/asset-manifest.js +73 -0
  4. package/dist/asset-operations.d.ts +159 -0
  5. package/dist/asset-operations.d.ts.map +1 -0
  6. package/dist/asset-operations.js +736 -0
  7. package/dist/asset-types.d.ts +56 -0
  8. package/dist/asset-types.d.ts.map +1 -0
  9. package/dist/asset-types.js +7 -0
  10. package/dist/base-content-index.d.ts +57 -0
  11. package/dist/base-content-index.d.ts.map +1 -0
  12. package/dist/base-content-index.js +179 -0
  13. package/dist/block-index.d.ts +9 -0
  14. package/dist/block-index.d.ts.map +1 -0
  15. package/dist/block-index.js +11 -0
  16. package/dist/blocks.d.ts +16 -0
  17. package/dist/blocks.d.ts.map +1 -0
  18. package/dist/blocks.js +103 -0
  19. package/dist/cf-access.d.ts +31 -0
  20. package/dist/cf-access.d.ts.map +1 -0
  21. package/dist/cf-access.js +66 -0
  22. package/dist/component-registry.d.ts +50 -0
  23. package/dist/component-registry.d.ts.map +1 -0
  24. package/dist/component-registry.js +120 -0
  25. package/dist/component-registry.types-C0ctF9nh.d.mts +71 -0
  26. package/dist/component-registry.types-C0ctF9nh.d.mts.map +1 -0
  27. package/dist/component-registry.types.d.ts +11 -0
  28. package/dist/component-registry.types.d.ts.map +1 -0
  29. package/dist/component-registry.types.js +1 -0
  30. package/dist/content-api.interface.d.ts +64 -0
  31. package/dist/content-api.interface.d.ts.map +1 -0
  32. package/dist/content-api.interface.js +1 -0
  33. package/dist/content-filters.d.ts +31 -0
  34. package/dist/content-filters.d.ts.map +1 -0
  35. package/dist/content-filters.js +246 -0
  36. package/dist/content-index-D092_vk1.mjs +629 -0
  37. package/dist/content-index-D092_vk1.mjs.map +1 -0
  38. package/dist/content-index-D6IVMmAB.d.mts +127 -0
  39. package/dist/content-index-D6IVMmAB.d.mts.map +1 -0
  40. package/dist/content-index.d.ts +126 -0
  41. package/dist/content-index.d.ts.map +1 -0
  42. package/dist/content-index.js +418 -0
  43. package/dist/content-operations-DIbsxG5A.d.mts +354 -0
  44. package/dist/content-operations-DIbsxG5A.d.mts.map +1 -0
  45. package/dist/content-operations.d.ts +93 -0
  46. package/dist/content-operations.d.ts.map +1 -0
  47. package/dist/content-operations.js +275 -0
  48. package/dist/content-reader.d.ts +10 -0
  49. package/dist/content-reader.d.ts.map +1 -0
  50. package/dist/content-reader.js +13 -0
  51. package/dist/content-utils-fWNHTrPy.mjs +280 -0
  52. package/dist/content-utils-fWNHTrPy.mjs.map +1 -0
  53. package/dist/content-utils.d.ts +132 -0
  54. package/dist/content-utils.d.ts.map +1 -0
  55. package/dist/content-utils.js +352 -0
  56. package/dist/content-watcher.d.ts +43 -0
  57. package/dist/content-watcher.d.ts.map +1 -0
  58. package/dist/content-watcher.js +83 -0
  59. package/dist/data-DquNIEnQ.mjs +62 -0
  60. package/dist/data-DquNIEnQ.mjs.map +1 -0
  61. package/dist/data-index.d.ts +8 -0
  62. package/dist/data-index.d.ts.map +1 -0
  63. package/dist/data-index.js +7 -0
  64. package/dist/data.d.ts +43 -0
  65. package/dist/data.d.ts.map +1 -0
  66. package/dist/data.js +103 -0
  67. package/dist/etag-utils.d.ts +77 -0
  68. package/dist/etag-utils.d.ts.map +1 -0
  69. package/dist/etag-utils.js +160 -0
  70. package/dist/filesystem-content-api-B1KIQJfk.mjs +2 -0
  71. package/dist/filesystem-content-api-C0HIhqZi.mjs +1620 -0
  72. package/dist/filesystem-content-api-C0HIhqZi.mjs.map +1 -0
  73. package/dist/filesystem-content-api-DCdNi-co.d.mts +134 -0
  74. package/dist/filesystem-content-api-DCdNi-co.d.mts.map +1 -0
  75. package/dist/filesystem-content-api.d.ts +135 -0
  76. package/dist/filesystem-content-api.d.ts.map +1 -0
  77. package/dist/filesystem-content-api.js +2181 -0
  78. package/dist/git-operations.d.ts +49 -0
  79. package/dist/git-operations.d.ts.map +1 -0
  80. package/dist/git-operations.js +252 -0
  81. package/dist/header-parser.d.ts +37 -0
  82. package/dist/header-parser.d.ts.map +1 -0
  83. package/dist/header-parser.js +286 -0
  84. package/dist/in-memory-content-api.d.ts +35 -0
  85. package/dist/in-memory-content-api.d.ts.map +1 -0
  86. package/dist/in-memory-content-api.js +591 -0
  87. package/dist/index-DxVTFK66.d.mts +105 -0
  88. package/dist/index-DxVTFK66.d.mts.map +1 -0
  89. package/dist/index.d.mts +6 -4
  90. package/dist/index.d.mts.map +1 -1
  91. package/dist/index.d.ts +19 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +16 -0
  94. package/dist/index.mjs +37 -5
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/indexing.d.mts +152 -0
  97. package/dist/indexing.d.mts.map +1 -0
  98. package/dist/indexing.d.ts +5 -0
  99. package/dist/indexing.d.ts.map +1 -0
  100. package/dist/indexing.js +7 -0
  101. package/dist/indexing.mjs +255 -0
  102. package/dist/indexing.mjs.map +1 -0
  103. package/dist/json-whitespace-view.d.ts +32 -0
  104. package/dist/json-whitespace-view.d.ts.map +1 -0
  105. package/dist/json-whitespace-view.js +152 -0
  106. package/dist/middleware.d.ts +20 -0
  107. package/dist/middleware.d.ts.map +1 -0
  108. package/dist/middleware.js +1031 -0
  109. package/dist/node.d.mts +28 -126
  110. package/dist/node.d.mts.map +1 -1
  111. package/dist/node.d.ts +25 -0
  112. package/dist/node.d.ts.map +1 -0
  113. package/dist/node.js +24 -0
  114. package/dist/node.mjs +199 -2890
  115. package/dist/node.mjs.map +1 -1
  116. package/dist/reader.d.mts +15 -0
  117. package/dist/reader.d.mts.map +1 -0
  118. package/dist/reader.d.ts +15 -0
  119. package/dist/reader.d.ts.map +1 -0
  120. package/dist/reader.js +13 -0
  121. package/dist/reader.mjs +22 -0
  122. package/dist/reader.mjs.map +1 -0
  123. package/dist/schemas/index.d.mts +2 -90
  124. package/dist/schemas/index.d.ts +102 -0
  125. package/dist/schemas/index.d.ts.map +1 -0
  126. package/dist/schemas/index.js +87 -0
  127. package/dist/schemas/index.mjs +2 -70
  128. package/dist/schemas-CFRD0FIQ.mjs +84 -0
  129. package/dist/schemas-CFRD0FIQ.mjs.map +1 -0
  130. package/dist/{types-BUG0Cfkg.mjs → site-8oaj1Q60.mjs} +20 -222
  131. package/dist/site-8oaj1Q60.mjs.map +1 -0
  132. package/dist/site-index-B_254bCc.d.mts +136 -0
  133. package/dist/site-index-B_254bCc.d.mts.map +1 -0
  134. package/dist/site-index.d.ts +60 -0
  135. package/dist/site-index.d.ts.map +1 -0
  136. package/dist/site-index.js +287 -0
  137. package/dist/site.d.ts +21 -0
  138. package/dist/site.d.ts.map +1 -0
  139. package/dist/site.js +168 -0
  140. package/dist/types-DOdldbfD.mjs +34 -0
  141. package/dist/types-DOdldbfD.mjs.map +1 -0
  142. package/dist/types-DjfhS272.d.mts +456 -0
  143. package/dist/types-DjfhS272.d.mts.map +1 -0
  144. package/dist/types.d.ts +453 -0
  145. package/dist/types.d.ts.map +1 -0
  146. package/dist/types.js +36 -0
  147. package/dist/url-safe-base64.d.ts +12 -0
  148. package/dist/url-safe-base64.d.ts.map +1 -0
  149. package/dist/url-safe-base64.js +40 -0
  150. package/dist/url-validation.d.ts +14 -0
  151. package/dist/url-validation.d.ts.map +1 -0
  152. package/dist/url-validation.js +81 -0
  153. package/dist/utils/atomic-write.d.ts +6 -0
  154. package/dist/utils/atomic-write.d.ts.map +1 -0
  155. package/dist/utils/atomic-write.js +20 -0
  156. package/dist/utils.d.ts +46 -0
  157. package/dist/utils.d.ts.map +1 -0
  158. package/dist/utils.js +70 -0
  159. package/dist/vite-plugin.d.ts +12 -0
  160. package/dist/vite-plugin.d.ts.map +1 -0
  161. package/dist/vite-plugin.js +29 -0
  162. package/dist/vxjson-qHrgLGip.mjs +555 -0
  163. package/dist/vxjson-qHrgLGip.mjs.map +1 -0
  164. package/dist/vxjson-serialize-geF6qvpn.mjs +34 -0
  165. package/dist/vxjson-serialize-geF6qvpn.mjs.map +1 -0
  166. package/dist/vxjson-serialize.d.mts +17 -0
  167. package/dist/vxjson-serialize.d.mts.map +1 -0
  168. package/dist/vxjson-serialize.d.ts +14 -0
  169. package/dist/vxjson-serialize.d.ts.map +1 -0
  170. package/dist/vxjson-serialize.js +50 -0
  171. package/dist/vxjson-serialize.mjs +2 -0
  172. package/dist/vxjson.d.ts +112 -0
  173. package/dist/vxjson.d.ts.map +1 -0
  174. package/dist/vxjson.js +391 -0
  175. package/dist/xxhash.d.ts +10 -0
  176. package/dist/xxhash.d.ts.map +1 -0
  177. package/dist/xxhash.js +31 -0
  178. package/package.json +88 -17
  179. package/dist/content-operations-BZLfJWqT.d.mts +0 -916
  180. package/dist/content-operations-BZLfJWqT.d.mts.map +0 -1
  181. package/dist/schemas/index.d.mts.map +0 -1
  182. package/dist/schemas/index.mjs.map +0 -1
  183. package/dist/types-BUG0Cfkg.mjs.map +0 -1
@@ -0,0 +1,354 @@
1
+ import { A as LocalizedEntry, I as SiteFilters, L as SitesConfig, O as LocaleUpdateData, P as MoveResult, R as UpdateLocaleInput, T as GlobalFilters, _ as CreateResult, b as DeleteLocaleInput, d as ContentMeta, g as CreatePageInput, h as CreateContentInput, i as BlockFilters, k as LocaleVersion, m as CreateBlockInput, r as BatchResult, s as ContentEntry, u as ContentManifest, w as FindOptions, x as DeleteResult, z as UpdateResult } from "./types-DjfhS272.mjs";
2
+ import { n as DataIndex, r as BlockIndex, t as SiteIndex } from "./site-index-B_254bCc.mjs";
3
+ //#region src/data.d.ts
4
+ interface DataFilters {
5
+ collection?: string;
6
+ locales?: string[];
7
+ }
8
+ 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
+ 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
+ //#endregion
44
+ //#region src/site.d.ts
45
+ declare class Site {
46
+ private siteName;
47
+ private api;
48
+ private siteIndex;
49
+ constructor(siteName: string, api: ContentAPI, siteIndex: SiteIndex);
50
+ listContent(filters?: SiteFilters): Generator<ContentManifest>;
51
+ listPages(locale?: string): Generator<ContentManifest>;
52
+ get collections(): Set<string>;
53
+ getByPathname(pathname: string, locale?: string): ContentManifest | null;
54
+ getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
55
+ move(id: string, locale: string, newPathname: string): Promise<MoveResult>;
56
+ getRedirect(pathname: string): ContentManifest | null;
57
+ isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean;
58
+ getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null;
59
+ isPathnameInRedirects(pathname: string, locale: string): boolean;
60
+ create(data: CreatePageInput): Promise<CreateResult>;
61
+ }
62
+ //#endregion
63
+ //#region src/content-api.interface.d.ts
64
+ /**
65
+ * Content API Interface
66
+ *
67
+ * Provides a unified interface for content operations across different storage backends.
68
+ *
69
+ * ## Indexing and Caching
70
+ *
71
+ * Implementations should index content at startup for performance. However, since content
72
+ * files can be modified externally (via git, text editors, etc.), implementations must:
73
+ *
74
+ * 1. Perform read-repair when files are invalid (e.g., VXJSON with incorrect field order)
75
+ * 2. Handle files that were added after the initial indexing
76
+ * 3. Update the index when files are repaired or discovered
77
+ *
78
+ * ## Read-Repair
79
+ *
80
+ * For file-based implementations, read-repair should:
81
+ * - Fix missing required fields (id, created, modified)
82
+ * - Ensure VXJSON files have "content" as the last field
83
+ * - Update the index with repaired content
84
+ * - Write the repaired file back to disk
85
+ */
86
+ interface ContentAPI {
87
+ /**
88
+ * Get content with all locales
89
+ * @param id - The content ID
90
+ * @returns The content entry with all locales, or null if not found
91
+ */
92
+ getContent(id: string): Promise<ContentEntry | null>;
93
+ /**
94
+ * Get content for a specific locale
95
+ *
96
+ * For file-based implementations:
97
+ * - Should handle files added after initial indexing
98
+ * - Should perform read-repair if the file is invalid
99
+ * - Should update the index with discovered/repaired content
100
+ *
101
+ * @param id - The content ID
102
+ * @param locale - The locale code
103
+ * @returns The localized content entry, or null if not found
104
+ */
105
+ getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
106
+ createContent(data: CreateContentInput): Promise<CreateResult>;
107
+ updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
108
+ deleteContent(id: string, etag: string): Promise<DeleteResult>;
109
+ deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
110
+ getSite(siteName: string): Site | null;
111
+ readonly blocks: Blocks;
112
+ readonly data: Data;
113
+ listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
114
+ findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
115
+ readonly sitesConfig: SitesConfig;
116
+ batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
117
+ getContentAsBuffer(id: string, locale: string): Promise<{
118
+ buffer: Uint8Array;
119
+ etag: string;
120
+ contentType: 'application/json' | 'text/mdx';
121
+ } | null>;
122
+ }
123
+ //#endregion
124
+ //#region src/blocks.d.ts
125
+ declare class Blocks {
126
+ private api;
127
+ private blockIndex;
128
+ constructor(api: ContentAPI, blockIndex: BlockIndex);
129
+ listContent(filters?: BlockFilters): Generator<ContentManifest>;
130
+ get collections(): Set<string>;
131
+ getByName(collection: string, name: string, locale?: string): ContentManifest | null;
132
+ isNameAvailable(collection: string, name: string, excludeId?: string): boolean;
133
+ getNameConflict(collection: string, name: string, excludeId?: string): string | null;
134
+ isBlockNameValid(blockName: string): boolean;
135
+ create(data: CreateBlockInput): Promise<CreateResult>;
136
+ }
137
+ //#endregion
138
+ //#region src/content-utils.d.ts
139
+ declare function localesOf<T>(manifest: {
140
+ locales: Record<string, T | undefined>;
141
+ }): Generator<T>;
142
+ /**
143
+ * Pure utility functions for content operations
144
+ * These functions don't depend on any class state and can be shared
145
+ * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
146
+ */
147
+ /**
148
+ * Check if content is published based on publishAt/unpublishAt dates
149
+ */
150
+ declare function isContentPublished(localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>, now?: Date): boolean;
151
+ /**
152
+ * Validate that metadata doesn't exceed 4KB when serialized
153
+ * This ensures efficient indexing as per the specification
154
+ */
155
+ declare function isMetadataTooLarge(meta: ContentMeta): boolean;
156
+ /**
157
+ * Extract block name from various sources
158
+ * Used when displaying blocks in the UI
159
+ */
160
+ declare function extractBlockName(source: string): string;
161
+ /**
162
+ * Validate block name according to the specification
163
+ * - Cannot contain dots (reserved for locale separator)
164
+ * - Cannot contain slashes (would create subdirectories)
165
+ * - Cannot contain spaces (for clean filenames)
166
+ * - Must have at least one character
167
+ */
168
+ declare function isValidBlockName(name: string): boolean;
169
+ /**
170
+ * Format file size for display with human-readable units
171
+ * @example formatFileSize(1536) // "1.5 KB"
172
+ */
173
+ declare function formatFileSize(bytes: number): string;
174
+ /**
175
+ * Calculate metadata size in bytes
176
+ */
177
+ declare function getMetadataSize(meta: ContentMeta): number;
178
+ /**
179
+ * Check if a pathname is valid
180
+ * - Must start with /
181
+ * - Cannot contain spaces (should be URL-encoded)
182
+ * - Cannot contain special characters that would break URLs
183
+ */
184
+ declare function isValidPathname(pathname: string): boolean;
185
+ /**
186
+ * Normalize a pathname to ensure consistency
187
+ * - Ensure it starts with /
188
+ * - Remove trailing slashes (except for root)
189
+ * - Collapse multiple slashes
190
+ */
191
+ declare function normalizePathname(pathname: string): string;
192
+ /**
193
+ * Reasons a pathname can be rejected. Each maps to a specific user-facing
194
+ * error message so the UI can highlight the exact problem.
195
+ */
196
+ type PathnameValidationReason = 'empty' | 'whitespace' | 'forbidden_char' | 'control_char' | 'uppercase' | 'non_ascii' | 'traversal_segment' | 'disallowed_char';
197
+ interface PathnameValidationResult {
198
+ /** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */
199
+ value: string;
200
+ valid: boolean;
201
+ reason?: PathnameValidationReason;
202
+ message?: string;
203
+ }
204
+ /**
205
+ * Validate the shape of a CMS pathname and normalize it for storage.
206
+ *
207
+ * Silently fixes harmless slips (missing leading slash, doubled slashes,
208
+ * trailing slash) and rejects malformed inputs with a specific reason so
209
+ * the UI can show a helpful error message.
210
+ *
211
+ * Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
212
+ * `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected.
213
+ */
214
+ declare function normalizeAndValidatePathname(input: string | undefined | null): PathnameValidationResult;
215
+ /**
216
+ * Generate a content ID in the standard format
217
+ * IDs are prefixed with "vx-" followed by 8 random characters
218
+ */
219
+ declare function generateContentId(): string;
220
+ /**
221
+ * Get the current date/time in ISO format
222
+ * Used for timestamps in content files
223
+ */
224
+ declare function getCurrentISODate(): string;
225
+ /**
226
+ * Parse a date string safely
227
+ * Returns null if invalid
228
+ */
229
+ declare function parseDate(dateStr: string | undefined): Date | null;
230
+ /**
231
+ * Creates a V8-optimized object by mapping site names to values.
232
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
233
+ *
234
+ * @param sitesConfig - Sites configuration containing site names
235
+ * @param factory - Function that creates the value for each site
236
+ * @returns Object with all sites initialized in alphabetical order
237
+ */
238
+ declare function mapSiteNames<T>(sitesConfig: {
239
+ sites: Record<string, any>;
240
+ }, factory: (siteName: string) => T): Record<string, T>;
241
+ /**
242
+ * Creates a V8-optimized object by mapping locale names to values.
243
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
244
+ *
245
+ * @param locales - Array of locale codes
246
+ * @param factory - Function that creates the value for each locale
247
+ * @returns Object with all locales initialized in array order
248
+ */
249
+ declare function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T>;
250
+ /**
251
+ * Resolves a publish date value to a valid string or undefined.
252
+ * Handles various input types including null, false, and empty strings.
253
+ *
254
+ * @param updateValue - The value being updated (string | null | false | undefined)
255
+ * @param currentValue - The current value to fall back to if updateValue is undefined
256
+ * @returns A valid date string or undefined
257
+ */
258
+ declare function resolvePublishDate(updateValue: string | null | false | undefined, currentValue: string | undefined): string | undefined;
259
+ /**
260
+ * Serializes MDX content with frontmatter.
261
+ * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
262
+ * consistent MDX output that includes frontmatter for variable access.
263
+ *
264
+ * @param frontmatterData - The frontmatter data to serialize
265
+ * @param mdxContent - The MDX content (without frontmatter)
266
+ * @returns Complete MDX file content with frontmatter
267
+ */
268
+ declare function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string;
269
+ //#endregion
270
+ //#region src/content-operations.d.ts
271
+ /**
272
+ * Shared business logic for content operations
273
+ * Used by both FileSystemContentAPI and InMemoryContentAPI
274
+ */
275
+ interface ValidationResult {
276
+ valid: boolean;
277
+ error?: string;
278
+ sortedMeta?: ContentMeta;
279
+ size?: number;
280
+ }
281
+ interface CreateValidationResult {
282
+ valid: boolean;
283
+ error?: string;
284
+ reason?: 'metadata_too_large' | 'pathname_taken' | 'pathname_in_redirects' | 'invalid_pathname' | 'invalid_name' | 'name_taken';
285
+ existingId?: string;
286
+ }
287
+ /**
288
+ * Validate and prepare metadata for storage
289
+ * Ensures title exists and metadata doesn't exceed 4KB
290
+ */
291
+ declare function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult;
292
+ /**
293
+ * Build pathname history update
294
+ */
295
+ declare function buildPathnameHistory(oldPathname: string | undefined, newPathname: string | undefined, isPublished: boolean, now: string): Record<string, string>;
296
+ /**
297
+ * Build a locale manifest
298
+ */
299
+ declare function buildLocaleVersion(params: {
300
+ locale: string;
301
+ etag: string;
302
+ created: string;
303
+ modified: string;
304
+ meta: ContentMeta;
305
+ kind: 'block' | 'page' | 'data';
306
+ publishAt?: string;
307
+ unpublishAt?: string;
308
+ pathname?: string;
309
+ name?: string;
310
+ previousPathnames?: Record<string, string>;
311
+ }): LocaleVersion;
312
+ /**
313
+ * Update publish dates on a locale manifest
314
+ */
315
+ declare function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void;
316
+ /**
317
+ * Validate content creation data
318
+ */
319
+ declare function validateCreateContent(data: CreateContentInput, sites: Record<string, Site>, blocks: Blocks, dataApi?: {
320
+ isDataNameValid: (name: string) => boolean;
321
+ getNameConflict: (collection: string, name: string) => string | null;
322
+ }): CreateValidationResult;
323
+ /**
324
+ * Update scope bit flags
325
+ * Can be combined with bitwise OR and checked with bitwise AND
326
+ */
327
+ declare const UPDATE_SCOPE: {
328
+ readonly NONE: 0;
329
+ readonly META: number;
330
+ readonly CONTENT: number;
331
+ readonly BOTH: 3;
332
+ };
333
+ type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];
334
+ /**
335
+ * Determine what parts of content are being updated
336
+ * Returns bit flags that can be checked with bitwise AND
337
+ *
338
+ * Example usage:
339
+ * ```
340
+ * const scope = analyzeUpdateScope(data);
341
+ * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
342
+ * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
343
+ * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
344
+ * ```
345
+ */
346
+ declare function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope;
347
+ /**
348
+ * Determine whether the modified timestamp should be updated
349
+ * Updates for ANY change - either metadata or content
350
+ */
351
+ declare function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean;
352
+ //#endregion
353
+ export { serializeMdxWithFrontmatter as A, localesOf as C, normalizePathname as D, normalizeAndValidatePathname as E, ContentAPI as M, Site as N, parseDate as O, Data as P, isValidPathname as S, mapSiteNames as T, getCurrentISODate as _, analyzeUpdateScope as a, isMetadataTooLarge as b, shouldUpdateModifiedTimestamp as c, validateCreateContent as d, PathnameValidationReason as f, generateContentId as g, formatFileSize as h, ValidationResult as i, Blocks as j, resolvePublishDate as k, updatePublishDates as l, extractBlockName as m, UPDATE_SCOPE as n, buildLocaleVersion as o, PathnameValidationResult as p, UpdateScope as r, buildPathnameHistory as s, CreateValidationResult as t, validateAndPrepareMetadata as u, getMetadataSize as v, mapLocales as w, isValidBlockName as x, isContentPublished as y };
354
+ //# sourceMappingURL=content-operations-DIbsxG5A.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-operations-DIbsxG5A.d.mts","names":[],"sources":["../src/data.ts","../src/site.ts","../src/content-api.interface.ts","../src/blocks.ts","../src/content-utils.ts","../src/content-operations.ts"],"mappings":";;;UAIiB;EACf;EACA;;UAGe;EACf;EACA;EACA;IAAS;IAAgB;KAAuB;;EAChD;KACG;MACC;MACA;MACA;QAAS;QAAgB;SAAuB;;MAChD;QACE,MAAM;;;;;cAMD;UAED;UACA;EADA,YAAA,KAAK,YACL,WAAW;EAIpB,YAAY,UAAU,cAAc,UAAU;MA0B3C,eAAe;EAKnB,UAAU,oBAAoB,cAAc,kBAAkB;EAK9D,gBAAgB,oBAAoB,cAAc;EAMlD,gBAAgB,oBAAoB,cAAc;EASlD,gBAAgB;EAqBV,OAAO,OAAO,kBAAkB,QAAQ;;;;cCnGnC;UAED;UACA;UACA;EAFA,YAAA,kBACA,KAAK,YACL,WAAW;EAIpB,YAAY,UAAU,cAAc,UAAU;EAmC9C,UAAU,kBAAkB,UAAU;MAQnC,eAAe;EAKnB,cAAc,kBAAkB,kBAAkB;EAKlD,sBAAsB,kBAAkB,kBAAkB;EAK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6BAA6B,mCAAmC;;;;;iBAuEhE;;;;;iBAQA;;;;;iBAQA,UAAU,8BAA8B;;;;;;;;;iBAoBxC,aAAa,GAC3B;EAAe,OAAO;GACtB,UAAU,qBAAqB,IAC9B,eAAe;;;;;;;;;iBAiBF,WAAW,GAAG,mBAAmB,UAAU,mBAAmB,IAAI,eAAe;;;;;;;;;iBAgBjF,mBACd,gDACA;;;;;;;;;;iBAoBc,4BAA4B,iBAAiB,qBAAqB;;;;;;;UCrWjE;EACf;EACA;EACA,aAAa;EACb;;UAGe;EACf;EACA;EACA;EAOA;;;;;;iBAOc,2BAA2B,MAAM,QAAQ,eAAe;;;;iBA+BxD,qBACd,iCACA,iCACA,sBACA,cACC;;;;iBAaa,mBAAmB;EACjC;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,oBAAoB;IAClB;;;;iBAgCY,mBAAmB,UAAU,eAAe,MAAM;;;;iBAyBlD,sBACd,MAAM,oBACN,OAAO,eAAe,OACtB,QAAQ,QACR;EACE,kBAAkB;EAClB,kBAAkB,oBAAoB;IAEvC;;;;;cA2JU;;;;;;KAOD,sBAAsB,2BAA2B;;;;;;;;;;;;;iBAc7C,mBAAmB,MAAM,mBAAmB;;;;;iBAqB5C,8BAA8B,MAAM"}
@@ -0,0 +1,93 @@
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_pathname' | '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
+ /**
61
+ * Check if content is published
62
+ */
63
+ export { generateContentId, isContentPublished };
64
+ /**
65
+ * Update scope bit flags
66
+ * Can be combined with bitwise OR and checked with bitwise AND
67
+ */
68
+ export declare const UPDATE_SCOPE: {
69
+ readonly NONE: 0;
70
+ readonly META: number;
71
+ readonly CONTENT: number;
72
+ readonly BOTH: 3;
73
+ };
74
+ export type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];
75
+ /**
76
+ * Determine what parts of content are being updated
77
+ * Returns bit flags that can be checked with bitwise AND
78
+ *
79
+ * Example usage:
80
+ * ```
81
+ * const scope = analyzeUpdateScope(data);
82
+ * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
83
+ * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
84
+ * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
85
+ * ```
86
+ */
87
+ export declare function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope;
88
+ /**
89
+ * Determine whether the modified timestamp should be updated
90
+ * Updates for ANY change - either metadata or content
91
+ */
92
+ export declare function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean;
93
+ //# 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,EAAgC,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhG;;;GAGG;AAGH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EACH,oBAAoB,GACpB,gBAAgB,GAChB,uBAAuB,GACvB,kBAAkB,GAClB,cAAc,GACd,YAAY,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,gBAAgB,CA0BvF;AAED;;GAEG;AACH,wBAAgB,oBAA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