@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
@@ -1,916 +0,0 @@
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/types.d.ts
59
- interface ContentAPIOptions {
60
- contentRoot: string;
61
- canvasDir?: string;
62
- }
63
- interface APIError {
64
- error: {
65
- code: string;
66
- message: string;
67
- details?: any;
68
- };
69
- }
70
- declare const ErrorCodes: {
71
- readonly CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND";
72
- readonly LOCALE_NOT_FOUND: "LOCALE_NOT_FOUND";
73
- readonly COLLECTION_NOT_FOUND: "COLLECTION_NOT_FOUND";
74
- readonly SITE_NOT_FOUND: "SITE_NOT_FOUND";
75
- readonly STALE_WRITE: "STALE_WRITE";
76
- readonly ALREADY_EXISTS: "ALREADY_EXISTS";
77
- readonly PATHNAME_TAKEN: "PATHNAME_TAKEN";
78
- readonly NAME_TAKEN: "NAME_TAKEN";
79
- readonly METADATA_TOO_LARGE: "METADATA_TOO_LARGE";
80
- readonly WRITE_ERROR: "WRITE_ERROR";
81
- readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
82
- readonly INVALID_LOCALE: "INVALID_LOCALE";
83
- readonly INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE";
84
- readonly INVALID_REQUEST: "INVALID_REQUEST";
85
- readonly INTERNAL_ERROR: "INTERNAL_ERROR";
86
- readonly FETCH_ERROR: "FETCH_ERROR";
87
- readonly GIT_NOT_REPO: "GIT_NOT_REPO";
88
- readonly GIT_COMMIT_FAILED: "GIT_COMMIT_FAILED";
89
- readonly GIT_PUSH_FAILED: "GIT_PUSH_FAILED";
90
- readonly GIT_PULL_FAILED: "GIT_PULL_FAILED";
91
- readonly GIT_STATUS_FAILED: "GIT_STATUS_FAILED";
92
- readonly ASSET_NOT_FOUND: "ASSET_NOT_FOUND";
93
- readonly ASSET_INVALID_FORMAT: "ASSET_INVALID_FORMAT";
94
- readonly ASSET_TOO_LARGE: "ASSET_TOO_LARGE";
95
- readonly ASSET_UPLOAD_FAILED: "ASSET_UPLOAD_FAILED";
96
- };
97
- type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
98
- type ContentType = 'puck' | 'mdx' | 'json';
99
- interface ContentData {
100
- puckData?: any;
101
- mdx?: string;
102
- data?: Record<string, unknown>;
103
- }
104
- interface ContentProp {
105
- content: ContentData;
106
- }
107
- interface ContentIdentity {
108
- id: string;
109
- type: ContentType;
110
- kind: 'block' | 'page' | 'data';
111
- site?: string;
112
- collection: string;
113
- }
114
- interface LocalePathData {
115
- locale: string;
116
- pathname?: string;
117
- name?: string;
118
- }
119
- interface LocaleVersion extends LocalePathData {
120
- etag: string;
121
- created: string;
122
- modified: string;
123
- publishAt?: string;
124
- unpublishAt?: string;
125
- previousPathnames?: Record<string, string>;
126
- meta: ContentMeta;
127
- }
128
- interface ContentManifest extends ContentIdentity {
129
- locales: Record<string, LocaleVersion | undefined>;
130
- }
131
- interface LocalizedManifest extends ContentIdentity {
132
- localized: LocaleVersion;
133
- }
134
- interface LocalizedEntry extends ContentIdentity {
135
- localized: LocaleVersion & ContentProp;
136
- }
137
- interface ContentEntry extends ContentManifest {
138
- locales: Record<string, LocaleVersion & ContentProp>;
139
- }
140
- interface UpdateResult {
141
- success: boolean;
142
- etag?: string;
143
- modified?: Date;
144
- reason?: 'not_found' | 'stale_write' | 'write_error';
145
- error?: Error;
146
- currentEtag?: string;
147
- conflictDetails?: {
148
- metaChanged: boolean;
149
- contentChanged: boolean;
150
- currentMeta?: ContentMeta;
151
- currentContent?: ContentData;
152
- localContent?: ContentData;
153
- };
154
- }
155
- interface MoveResult {
156
- moved: boolean;
157
- previousPathname?: string;
158
- files?: string[];
159
- reason?: 'not_found' | 'already_exists' | 'stale_write' | 'write_error';
160
- error?: Error;
161
- etag?: string;
162
- }
163
- interface ContentListResult {
164
- items: ContentManifest[];
165
- total: number;
166
- hasMore?: boolean;
167
- }
168
- interface GlobalFilters {
169
- site?: string;
170
- collection?: string;
171
- locales?: string[];
172
- type?: 'puck' | 'mdx' | 'json';
173
- published?: boolean;
174
- kind?: 'block' | 'page' | 'data';
175
- localization?: 'complete' | 'partial' | 'one';
176
- missingLocales?: string[];
177
- }
178
- interface SiteFilters {
179
- collection?: string;
180
- locales?: string[];
181
- type?: 'puck' | 'mdx';
182
- published?: boolean;
183
- }
184
- interface BlockFilters {
185
- collection?: string;
186
- locales?: string[];
187
- }
188
- interface FindOptions {
189
- excludeSites?: string[];
190
- includeUnpublished?: boolean;
191
- }
192
- interface CreateContentInput {
193
- kind: 'block' | 'page' | 'data';
194
- site?: string;
195
- collection: string;
196
- type: ContentType;
197
- created?: string;
198
- name?: string;
199
- meta?: Partial<ContentMeta>;
200
- locales: {
201
- [locale: string]: {
202
- pathname?: string;
203
- publishAt?: string | null | false;
204
- unpublishAt?: string | null | false;
205
- meta?: Partial<ContentMeta>;
206
- } & ContentProp;
207
- };
208
- }
209
- interface CreatePageInput {
210
- collection: string;
211
- locales: {
212
- [locale: string]: {
213
- pathname: string;
214
- publishAt?: string | null | false;
215
- unpublishAt?: string | null | false;
216
- meta: ContentMeta;
217
- content: {
218
- puckData: any;
219
- };
220
- };
221
- };
222
- }
223
- interface CreateBlockInput {
224
- collection: string;
225
- type: 'mdx';
226
- name: string;
227
- meta?: Partial<ContentMeta>;
228
- locales: {
229
- [locale: string]: {
230
- publishAt?: string | null | false;
231
- unpublishAt?: string | null | false;
232
- meta?: Partial<ContentMeta>;
233
- content: {
234
- mdx: string;
235
- };
236
- };
237
- };
238
- }
239
- interface UpdateLocaleInput {
240
- id: string;
241
- locale: string;
242
- data: LocaleUpdateData;
243
- etag: string;
244
- }
245
- interface LocaleUpdateData {
246
- pathname?: string;
247
- name?: string;
248
- publishAt?: string | null | false;
249
- unpublishAt?: string | null | false;
250
- modified?: string;
251
- meta?: Partial<ContentMeta>;
252
- content?: ContentData;
253
- }
254
- interface DeleteLocaleInput {
255
- id: string;
256
- locale: string;
257
- etag: string;
258
- }
259
- interface SitesConfig {
260
- sites: {
261
- [siteName: string]: {
262
- locales: string[];
263
- defaultLocale: string;
264
- domains?: {
265
- [locale: string]: string;
266
- };
267
- };
268
- };
269
- globalLocales: string[];
270
- }
271
- interface BatchResult {
272
- operations: BatchOperationResult[];
273
- success: boolean;
274
- failed: number;
275
- updated: number;
276
- }
277
- interface ContentMeta {
278
- title: string;
279
- description?: string;
280
- author?: string;
281
- tags?: string[];
282
- keywords?: string[];
283
- ogTitle?: string;
284
- ogDescription?: string;
285
- ogImage?: string;
286
- [key: string]: any;
287
- }
288
- /**
289
- * VXJSON (Variant JSON) File Format
290
- *
291
- * VXJSON is a specialized JSON format that guarantees:
292
- * 1. The root is always an object (never an array or primitive)
293
- * 2. The "content" field always comes last in the object
294
- * 3. Field order is deterministic for consistent ETag calculation
295
- *
296
- * This format enables efficient streaming ETag calculation where metadata
297
- * can be hashed separately from content, supporting partial updates and
298
- * conflict resolution in CMS scenarios.
299
- *
300
- * Files using this format have the extension .vxjson
301
- */
302
- interface VXJSONFile {
303
- id: string;
304
- type: ContentType;
305
- created: string;
306
- modified: string;
307
- publishAt?: string;
308
- unpublishAt?: string;
309
- previousPathnames?: Record<string, string>;
310
- meta: ContentMeta;
311
- content: ContentData;
312
- }
313
- interface MDXFrontmatter {
314
- id: string;
315
- type: 'mdx';
316
- created: string;
317
- modified: string;
318
- publishAt?: string;
319
- unpublishAt?: string;
320
- meta: ContentMeta;
321
- }
322
- type WriteResult = {
323
- success: true;
324
- etag: string;
325
- modified?: Date;
326
- reason?: undefined;
327
- error?: undefined;
328
- currentEtag?: undefined;
329
- } | {
330
- success: false;
331
- etag?: undefined;
332
- modified?: undefined;
333
- reason: 'stale_write';
334
- error?: undefined;
335
- currentEtag: string;
336
- } | {
337
- success: false;
338
- etag?: undefined;
339
- modified?: undefined;
340
- reason: 'already_exists';
341
- error?: undefined;
342
- currentEtag: string;
343
- } | {
344
- success: false;
345
- etag?: undefined;
346
- modified?: undefined;
347
- reason: 'write_error';
348
- error: Error;
349
- currentEtag?: string;
350
- };
351
- interface DeleteResult {
352
- success: boolean;
353
- error?: Error;
354
- reason?: 'stale_write' | 'not_found' | 'delete_error';
355
- currentEtag?: string;
356
- }
357
- interface CreateResult {
358
- success: boolean;
359
- id?: string;
360
- etag?: string;
361
- created?: Date;
362
- reason?: 'already_exists' | 'write_error' | 'invalid_name' | 'name_taken' | 'pathname_taken' | 'pathname_in_redirects' | 'metadata_too_large';
363
- error?: Error;
364
- existingId?: string;
365
- }
366
- interface BatchOperationResult {
367
- id: string;
368
- locale: string;
369
- updated: boolean;
370
- error?: Error;
371
- etag?: string;
372
- }
373
- /**
374
- * Minimal page reference for listing/navigation in data context.
375
- *
376
- * Used in dataBindings.pages for blog listing components
377
- * and getStaticPaths() to enumerate available pages.
378
- */
379
- interface PageReference {
380
- /** Page identifier. */
381
- id: string;
382
- /** URL pathname. */
383
- pathname: string;
384
- /** Page title (if available without full load). */
385
- title?: string;
386
- /** Content collection. */
387
- collection: string;
388
- /** Page metadata from content. */
389
- meta?: Record<string, unknown>;
390
- /** Page timestamps for sorting and display. */
391
- timestamps?: {
392
- created?: Date;
393
- modified?: Date;
394
- };
395
- }
396
- /**
397
- * A single entry from a data collection.
398
- *
399
- * Simplified representation of collection data for use in component resolvers.
400
- */
401
- interface DataCollectionEntry {
402
- /** Unique identifier for the entry. */
403
- id: string;
404
- /** Human-readable name of the entry. */
405
- name: string;
406
- /** The entry's data content. */
407
- data: Record<string, unknown>;
408
- /** Optional metadata for the entry. */
409
- meta?: Record<string, unknown>;
410
- }
411
- /**
412
- * Context object passed to Puck component resolvers via metadata.
413
- *
414
- * Contains fetched collection data and contextual information
415
- * for data-driven component rendering.
416
- */
417
- interface DataContext {
418
- /** Collection data keyed by collection name. */
419
- collections: Record<string, DataCollectionEntry[]>;
420
- /** Pages matching the dataBindings.pages filter. */
421
- pages?: PageReference[];
422
- /** Current locale used for data fetching. */
423
- locale: string;
424
- /** Site name from routing configuration. */
425
- siteName: string;
426
- }
427
- interface LocaleFileData {
428
- locale: string;
429
- etag: string;
430
- created: string;
431
- modified: string;
432
- publishAt?: string;
433
- unpublishAt?: string;
434
- previousPathnames?: Record<string, string>;
435
- meta: ContentMeta;
436
- content: {
437
- puckData?: any;
438
- mdx?: string;
439
- data?: Record<string, unknown>;
440
- };
441
- }
442
- //#endregion
443
- //#region src/base-content-index.d.ts
444
- /**
445
- * Base class for content indexes (blocks, data)
446
- * Maintains collection->name->locale lookups with V8-optimized structures
447
- */
448
- declare class BaseContentIndex {
449
- protected index: Map<string, ContentManifest>;
450
- protected contentCache: Map<string, Record<string, ContentData | null>>;
451
- protected nameIndex: Map<string, Map<string, ContentManifest>>;
452
- readonly collections: Set<string>;
453
- /**
454
- * Add or update content in the index
455
- * Merges manifest locales and updates content cache if provided
456
- */
457
- addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
458
- /**
459
- * Remove a specific locale from an entry
460
- */
461
- removeLocale(id: string, locale: string): void;
462
- /**
463
- * Remove an entry from the index
464
- */
465
- removeEntry(id: string): void;
466
- /**
467
- * Get cached content for a specific locale
468
- */
469
- getCachedContent(id: string, locale: string): ContentData | null;
470
- /**
471
- * Get content manifest
472
- */
473
- getManifest(id: string): ContentManifest | null;
474
- /**
475
- * Find entry by name
476
- */
477
- getByName(collection: string, name: string, locale?: string): ContentManifest | null;
478
- /**
479
- * Generator for all manifests
480
- */
481
- getAllManifests(): Generator<ContentManifest>;
482
- /**
483
- * Generator for manifests by locale
484
- */
485
- getManifestsByLocale(locale: string): Generator<ContentManifest>;
486
- /**
487
- * Generator for manifests by collection
488
- */
489
- getManifestsByCollection(collection: string): Generator<ContentManifest>;
490
- /**
491
- * Get the count of indexed content entries (unique IDs)
492
- */
493
- get entryCount(): number;
494
- /**
495
- * Clear all indexes
496
- */
497
- clear(): void;
498
- }
499
- //#endregion
500
- //#region src/block-index.d.ts
501
- /**
502
- * V8-optimized index for blocks
503
- * Maintains collection->name->locale lookups
504
- */
505
- declare class BlockIndex extends BaseContentIndex {
506
- constructor(locales: string[]);
507
- }
508
- //#endregion
509
- //#region src/data-index.d.ts
510
- /**
511
- * V8-optimized index for data collections
512
- * Maintains collection->name->locale lookups
513
- */
514
- declare class DataIndex extends BaseContentIndex {}
515
- //#endregion
516
- //#region src/data.d.ts
517
- interface DataFilters {
518
- collection?: string;
519
- locales?: string[];
520
- }
521
- interface CreateDataInput {
522
- collection: string;
523
- name: string;
524
- meta?: {
525
- title?: string;
526
- description?: string;
527
- [key: string]: unknown;
528
- };
529
- locales: {
530
- [locale: string]: {
531
- publishAt?: string | null | false;
532
- unpublishAt?: string | null | false;
533
- meta?: {
534
- title?: string;
535
- description?: string;
536
- [key: string]: unknown;
537
- };
538
- content: {
539
- data: Record<string, unknown>;
540
- };
541
- };
542
- };
543
- }
544
- declare class Data {
545
- private api;
546
- private dataIndex;
547
- constructor(api: ContentAPI, dataIndex: DataIndex);
548
- listContent(filters?: DataFilters): Generator<ContentManifest>;
549
- get collections(): Set<string>;
550
- getByName(collection: string, name: string, locale?: string): ContentManifest | null;
551
- isNameAvailable(collection: string, name: string, excludeId?: string): boolean;
552
- getNameConflict(collection: string, name: string, excludeId?: string): string | null;
553
- isDataNameValid(dataName: string): boolean;
554
- create(input: CreateDataInput): Promise<CreateResult>;
555
- }
556
- //#endregion
557
- //#region src/site-index.d.ts
558
- /**
559
- * V8-optimized index for a single site
560
- * Maintains pathname lookups and collections for one site only
561
- */
562
- declare class SiteIndex {
563
- private locales;
564
- private index;
565
- private contentCache;
566
- private pathnameIndex;
567
- private previousPathnameIndex;
568
- readonly collections: Set<string>;
569
- constructor(siteName: string, locales: string[]);
570
- /**
571
- * Add or update content in the index
572
- * Merges manifest locales and updates content cache if provided
573
- */
574
- addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
575
- /**
576
- * Remove a specific locale from an entry
577
- */
578
- removeLocale(id: string, locale: string): void;
579
- /**
580
- * Remove an entry from the index
581
- */
582
- removeEntry(id: string): void;
583
- /**
584
- * Get cached content for a specific locale
585
- */
586
- getCachedContent(id: string, locale: string): ContentData | null;
587
- /**
588
- * Get content manifest
589
- */
590
- getManifest(id: string): ContentManifest | null;
591
- /**
592
- * Find content by pathname
593
- */
594
- getByPathname(pathname: string, locale?: string): ContentManifest | null;
595
- /**
596
- * Find content by previous pathname (for redirects)
597
- */
598
- getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
599
- /**
600
- * Generator for all manifests
601
- */
602
- getAllManifests(): Generator<ContentManifest>;
603
- /**
604
- * Generator for manifests by locale
605
- */
606
- getManifestsByLocale(locale: string): Generator<ContentManifest>;
607
- /**
608
- * Get the count of indexed content entries (unique IDs)
609
- */
610
- get entryCount(): number;
611
- /**
612
- * Clear all indexes
613
- */
614
- clear(): void;
615
- }
616
- //#endregion
617
- //#region src/site.d.ts
618
- declare class Site {
619
- private siteName;
620
- private api;
621
- private siteIndex;
622
- constructor(siteName: string, api: ContentAPI, siteIndex: SiteIndex);
623
- listContent(filters?: SiteFilters): Generator<ContentManifest>;
624
- listPages(locale?: string): Generator<ContentManifest>;
625
- get collections(): Set<string>;
626
- getByPathname(pathname: string, locale?: string): ContentManifest | null;
627
- getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
628
- move(id: string, locale: string, newPathname: string): Promise<MoveResult>;
629
- getRedirect(pathname: string): ContentManifest | null;
630
- isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean;
631
- getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null;
632
- isPathnameInRedirects(pathname: string, locale: string): boolean;
633
- create(data: CreatePageInput): Promise<CreateResult>;
634
- }
635
- //#endregion
636
- //#region src/content-api.interface.d.ts
637
- /**
638
- * Content API Interface
639
- *
640
- * Provides a unified interface for content operations across different storage backends.
641
- *
642
- * ## Indexing and Caching
643
- *
644
- * Implementations should index content at startup for performance. However, since content
645
- * files can be modified externally (via git, text editors, etc.), implementations must:
646
- *
647
- * 1. Perform read-repair when files are invalid (e.g., VXJSON with incorrect field order)
648
- * 2. Handle files that were added after the initial indexing
649
- * 3. Update the index when files are repaired or discovered
650
- *
651
- * ## Read-Repair
652
- *
653
- * For file-based implementations, read-repair should:
654
- * - Fix missing required fields (id, created, modified)
655
- * - Ensure VXJSON files have "content" as the last field
656
- * - Update the index with repaired content
657
- * - Write the repaired file back to disk
658
- */
659
- interface ContentAPI {
660
- /**
661
- * Get content with all locales
662
- * @param id - The content ID
663
- * @returns The content entry with all locales, or null if not found
664
- */
665
- getContent(id: string): Promise<ContentEntry | null>;
666
- /**
667
- * Get content for a specific locale
668
- *
669
- * For file-based implementations:
670
- * - Should handle files added after initial indexing
671
- * - Should perform read-repair if the file is invalid
672
- * - Should update the index with discovered/repaired content
673
- *
674
- * @param id - The content ID
675
- * @param locale - The locale code
676
- * @returns The localized content entry, or null if not found
677
- */
678
- getLocalized(id: string, locale: string): Promise<LocalizedEntry | null>;
679
- createContent(data: CreateContentInput): Promise<CreateResult>;
680
- updateLocalized(input: UpdateLocaleInput): Promise<UpdateResult>;
681
- deleteContent(id: string, etag: string): Promise<DeleteResult>;
682
- deleteLocalized(input: DeleteLocaleInput): Promise<DeleteResult>;
683
- getSite(siteName: string): Site | null;
684
- readonly blocks: Blocks;
685
- readonly data: Data;
686
- listAllContent(filters?: GlobalFilters): Generator<ContentManifest>;
687
- findUntranslatedContent(targetLocale: string, options?: FindOptions): Generator<ContentManifest>;
688
- readonly sitesConfig: SitesConfig;
689
- batchUpdate(operations: UpdateLocaleInput[]): Promise<BatchResult>;
690
- getContentAsBuffer(id: string, locale: string): Promise<{
691
- buffer: Uint8Array;
692
- etag: string;
693
- contentType: 'application/json' | 'text/mdx';
694
- } | null>;
695
- }
696
- //#endregion
697
- //#region src/blocks.d.ts
698
- declare class Blocks {
699
- private api;
700
- private blockIndex;
701
- constructor(api: ContentAPI, blockIndex: BlockIndex);
702
- listContent(filters?: BlockFilters): Generator<ContentManifest>;
703
- get collections(): Set<string>;
704
- getByName(collection: string, name: string, locale?: string): ContentManifest | null;
705
- isNameAvailable(collection: string, name: string, excludeId?: string): boolean;
706
- getNameConflict(collection: string, name: string, excludeId?: string): string | null;
707
- isBlockNameValid(blockName: string): boolean;
708
- create(data: CreateBlockInput): Promise<CreateResult>;
709
- }
710
- //#endregion
711
- //#region src/component-registry.types.d.ts
712
- interface ComponentEntry {
713
- displayName: string;
714
- path: string | null;
715
- }
716
- interface ComponentEntryWithId extends ComponentEntry {
717
- id: string;
718
- }
719
- interface ComponentRegistry {
720
- [componentId: string]: ComponentEntry;
721
- }
722
- //#endregion
723
- //#region src/content-utils.d.ts
724
- declare function localesOf<T>(manifest: {
725
- locales: Record<string, T | undefined>;
726
- }): Generator<T>;
727
- /**
728
- * Pure utility functions for content operations
729
- * These functions don't depend on any class state and can be shared
730
- * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
731
- */
732
- /**
733
- * Check if content is published based on publishAt/unpublishAt dates
734
- */
735
- declare function isContentPublished(localeVersion: Pick<LocaleVersion, 'publishAt' | 'unpublishAt'>, now?: Date): boolean;
736
- /**
737
- * Validate that metadata doesn't exceed 4KB when serialized
738
- * This ensures efficient indexing as per the specification
739
- */
740
- declare function isMetadataTooLarge(meta: ContentMeta): boolean;
741
- /**
742
- * Extract block name from various sources
743
- * Used when displaying blocks in the UI
744
- */
745
- declare function extractBlockName(source: string): string;
746
- /**
747
- * Validate block name according to the specification
748
- * - Cannot contain dots (reserved for locale separator)
749
- * - Cannot contain slashes (would create subdirectories)
750
- * - Cannot contain spaces (for clean filenames)
751
- * - Must have at least one character
752
- */
753
- declare function isValidBlockName(name: string): boolean;
754
- /**
755
- * Format file size for display with human-readable units
756
- * @example formatFileSize(1536) // "1.5 KB"
757
- */
758
- declare function formatFileSize(bytes: number): string;
759
- /**
760
- * Calculate metadata size in bytes
761
- */
762
- declare function getMetadataSize(meta: ContentMeta): number;
763
- /**
764
- * Check if a pathname is valid
765
- * - Must start with /
766
- * - Cannot contain spaces (should be URL-encoded)
767
- * - Cannot contain special characters that would break URLs
768
- */
769
- declare function isValidPathname(pathname: string): boolean;
770
- /**
771
- * Normalize a pathname to ensure consistency
772
- * - Ensure it starts with /
773
- * - Remove trailing slashes (except for root)
774
- * - Collapse multiple slashes
775
- */
776
- declare function normalizePathname(pathname: string): string;
777
- /**
778
- * Generate a content ID in the standard format
779
- * IDs are prefixed with "vx-" followed by 8 random characters
780
- */
781
- declare function generateContentId(): string;
782
- /**
783
- * Get the current date/time in ISO format
784
- * Used for timestamps in content files
785
- */
786
- declare function getCurrentISODate(): string;
787
- /**
788
- * Parse a date string safely
789
- * Returns null if invalid
790
- */
791
- declare function parseDate(dateStr: string | undefined): Date | null;
792
- /**
793
- * Creates a V8-optimized object by mapping site names to values.
794
- * Ensures all objects have the same hidden class by adding properties in consistent order.
795
- *
796
- * @param sitesConfig - Sites configuration containing site names
797
- * @param factory - Function that creates the value for each site
798
- * @returns Object with all sites initialized in alphabetical order
799
- */
800
- declare function mapSiteNames<T>(sitesConfig: {
801
- sites: Record<string, any>;
802
- }, factory: (siteName: string) => T): Record<string, T>;
803
- /**
804
- * Creates a V8-optimized object by mapping locale names to values.
805
- * Ensures all objects have the same hidden class by adding properties in consistent order.
806
- *
807
- * @param locales - Array of locale codes
808
- * @param factory - Function that creates the value for each locale
809
- * @returns Object with all locales initialized in array order
810
- */
811
- declare function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T>;
812
- /**
813
- * Resolves a publish date value to a valid string or undefined.
814
- * Handles various input types including null, false, and empty strings.
815
- *
816
- * @param updateValue - The value being updated (string | null | false | undefined)
817
- * @param currentValue - The current value to fall back to if updateValue is undefined
818
- * @returns A valid date string or undefined
819
- */
820
- declare function resolvePublishDate(updateValue: string | null | false | undefined, currentValue: string | undefined): string | undefined;
821
- /**
822
- * Serializes MDX content with frontmatter.
823
- * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
824
- * consistent MDX output that includes frontmatter for variable access.
825
- *
826
- * @param frontmatterData - The frontmatter data to serialize
827
- * @param mdxContent - The MDX content (without frontmatter)
828
- * @returns Complete MDX file content with frontmatter
829
- */
830
- declare function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string;
831
- //#endregion
832
- //#region src/content-operations.d.ts
833
- /**
834
- * Shared business logic for content operations
835
- * Used by both FileSystemContentAPI and InMemoryContentAPI
836
- */
837
- interface ValidationResult {
838
- valid: boolean;
839
- error?: string;
840
- sortedMeta?: ContentMeta;
841
- size?: number;
842
- }
843
- interface CreateValidationResult {
844
- valid: boolean;
845
- error?: string;
846
- reason?: 'metadata_too_large' | 'pathname_taken' | 'pathname_in_redirects' | 'invalid_name' | 'name_taken';
847
- existingId?: string;
848
- }
849
- /**
850
- * Validate and prepare metadata for storage
851
- * Ensures title exists and metadata doesn't exceed 4KB
852
- */
853
- declare function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult;
854
- /**
855
- * Build pathname history update
856
- */
857
- declare function buildPathnameHistory(oldPathname: string | undefined, newPathname: string | undefined, isPublished: boolean, now: string): Record<string, string>;
858
- /**
859
- * Build a locale manifest
860
- */
861
- declare function buildLocaleVersion(params: {
862
- locale: string;
863
- etag: string;
864
- created: string;
865
- modified: string;
866
- meta: ContentMeta;
867
- kind: 'block' | 'page' | 'data';
868
- publishAt?: string;
869
- unpublishAt?: string;
870
- pathname?: string;
871
- name?: string;
872
- previousPathnames?: Record<string, string>;
873
- }): LocaleVersion;
874
- /**
875
- * Update publish dates on a locale manifest
876
- */
877
- declare function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void;
878
- /**
879
- * Validate content creation data
880
- */
881
- declare function validateCreateContent(data: CreateContentInput, sites: Record<string, Site>, blocks: Blocks, dataApi?: {
882
- isDataNameValid: (name: string) => boolean;
883
- getNameConflict: (collection: string, name: string) => string | null;
884
- }): CreateValidationResult;
885
- /**
886
- * Update scope bit flags
887
- * Can be combined with bitwise OR and checked with bitwise AND
888
- */
889
- declare const UPDATE_SCOPE: {
890
- readonly NONE: 0;
891
- readonly META: number;
892
- readonly CONTENT: number;
893
- readonly BOTH: 3;
894
- };
895
- type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];
896
- /**
897
- * Determine what parts of content are being updated
898
- * Returns bit flags that can be checked with bitwise AND
899
- *
900
- * Example usage:
901
- * ```
902
- * const scope = analyzeUpdateScope(data);
903
- * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }
904
- * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }
905
- * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }
906
- * ```
907
- */
908
- declare function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope;
909
- /**
910
- * Determine whether the modified timestamp should be updated
911
- * Updates for ANY change - either metadata or content
912
- */
913
- declare function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean;
914
- //#endregion
915
- export { DataContext as $, ComponentRegistry as A, ContentData as B, mapSiteNames as C, AssetUsage as Ct, serializeMdxWithFrontmatter as D, resolvePublishDate as E, ManifestEntryData as Et, APIError as F, ContentMeta as G, ContentIdentity as H, BatchOperationResult as I, CreateBlockInput as J, ContentProp as K, BatchResult as L, ContentAPI as M, Site as N, ComponentEntry as O, Data as P, DataCollectionEntry as Q, BlockFilters as R, mapLocales as S, AssetManifestData as St, parseDate as T, FolderTreeNode as Tt, ContentListResult as U, ContentEntry as V, ContentManifest as W, CreatePageInput as X, CreateContentInput as Y, CreateResult as Z, isContentPublished as _, UpdateLocaleInput as _t, analyzeUpdateScope as a, GlobalFilters as at, isValidPathname as b, WriteResult as bt, shouldUpdateModifiedTimestamp as c, LocaleUpdateData as ct, validateCreateContent as d, LocalizedManifest as dt, DeleteLocaleInput as et, extractBlockName as f, MDXFrontmatter as ft, getMetadataSize as g, SitesConfig as gt, getCurrentISODate as h, SiteFilters as ht, ValidationResult as i, FindOptions as it, Blocks as j, ComponentEntryWithId as k, updatePublishDates as l, LocaleVersion as lt, generateContentId as m, PageReference as mt, UPDATE_SCOPE as n, ErrorCode as nt, buildLocaleVersion as o, LocaleFileData as ot, formatFileSize as p, MoveResult as pt, ContentType as q, UpdateScope as r, ErrorCodes as rt, buildPathnameHistory as s, LocalePathData as st, CreateValidationResult as t, DeleteResult as tt, validateAndPrepareMetadata as u, LocalizedEntry as ut, isMetadataTooLarge as v, UpdateResult as vt, normalizePathname as w, FolderListing as wt, localesOf as x, AssetEntry as xt, isValidBlockName as y, VXJSONFile as yt, ContentAPIOptions as z };
916
- //# sourceMappingURL=content-operations-BZLfJWqT.d.mts.map