@conloca/content-api 0.1.15 → 0.1.16

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