@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,9 +1,9 @@
1
+ import { p as normalizeAndValidatePathname, u as localesOf } from "./content-utils-fWNHTrPy.mjs";
1
2
  import sortKeys from "sort-keys";
2
- import { nanoid } from "nanoid";
3
- import yaml from "yaml";
4
-
5
3
  //#region src/blocks.ts
6
4
  var Blocks = class {
5
+ api;
6
+ blockIndex;
7
7
  constructor(api, blockIndex) {
8
8
  this.api = api;
9
9
  this.blockIndex = blockIndex;
@@ -58,188 +58,6 @@ var Blocks = class {
58
58
  });
59
59
  }
60
60
  };
61
-
62
- //#endregion
63
- //#region src/content-utils.ts
64
- function* localesOf(manifest) {
65
- for (const value of Object.values(manifest.locales)) if (value) yield value;
66
- }
67
- /**
68
- * Pure utility functions for content operations
69
- * These functions don't depend on any class state and can be shared
70
- * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
71
- */
72
- /**
73
- * Check if content is published based on publishAt/unpublishAt dates
74
- */
75
- function isContentPublished(localeVersion, now = /* @__PURE__ */ new Date()) {
76
- if (localeVersion.publishAt) {
77
- const publishDate = new Date(localeVersion.publishAt);
78
- if (!isNaN(publishDate.getTime()) && publishDate > now) return false;
79
- }
80
- if (localeVersion.unpublishAt) {
81
- const unpublishDate = new Date(localeVersion.unpublishAt);
82
- if (!isNaN(unpublishDate.getTime()) && unpublishDate < now) return false;
83
- }
84
- return true;
85
- }
86
- /**
87
- * Validate that metadata doesn't exceed 4KB when serialized
88
- * This ensures efficient indexing as per the specification
89
- */
90
- function isMetadataTooLarge(meta) {
91
- return new TextEncoder().encode(JSON.stringify(meta)).length > 4096;
92
- }
93
- /**
94
- * Extract block name from various sources
95
- * Used when displaying blocks in the UI
96
- */
97
- function extractBlockName(source) {
98
- if (source.includes("/") && !source.includes(".")) {
99
- const parts = source.split("/");
100
- return parts[parts.length - 1];
101
- }
102
- if (source.includes(".")) {
103
- const match = source.match(/^(.+?)\.([a-z]{2})?\.(mdx|vxjson)$/);
104
- if (match) return match[1];
105
- return source.replace(/\.[^.]+$/, "");
106
- }
107
- if (source.startsWith("vx-")) return `block-${source.substring(3, 8)}`;
108
- return source;
109
- }
110
- /**
111
- * Validate block name according to the specification
112
- * - Cannot contain dots (reserved for locale separator)
113
- * - Cannot contain slashes (would create subdirectories)
114
- * - Cannot contain spaces (for clean filenames)
115
- * - Must have at least one character
116
- */
117
- function isValidBlockName(name) {
118
- if (!name || name.length === 0) return false;
119
- if (name.includes(".")) return false;
120
- if (name.includes("/")) return false;
121
- if (name.includes(" ")) return false;
122
- return true;
123
- }
124
- /**
125
- * Format file size for display with human-readable units
126
- * @example formatFileSize(1536) // "1.5 KB"
127
- */
128
- function formatFileSize(bytes) {
129
- if (bytes < 1024) return `${bytes} B`;
130
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
131
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
132
- }
133
- /**
134
- * Calculate metadata size in bytes
135
- */
136
- function getMetadataSize(meta) {
137
- return new TextEncoder().encode(JSON.stringify(meta)).length;
138
- }
139
- /**
140
- * Check if a pathname is valid
141
- * - Must start with /
142
- * - Cannot contain spaces (should be URL-encoded)
143
- * - Cannot contain special characters that would break URLs
144
- */
145
- function isValidPathname(pathname) {
146
- if (!pathname || !pathname.startsWith("/")) return false;
147
- if (pathname.includes(" ")) return false;
148
- if (pathname.includes("?") || pathname.includes("#")) return false;
149
- return true;
150
- }
151
- /**
152
- * Normalize a pathname to ensure consistency
153
- * - Ensure it starts with /
154
- * - Remove trailing slashes (except for root)
155
- * - Collapse multiple slashes
156
- */
157
- function normalizePathname(pathname) {
158
- if (!pathname) return "/";
159
- if (!pathname.startsWith("/")) pathname = "/" + pathname;
160
- pathname = pathname.replace(/\/+/g, "/");
161
- if (pathname !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1);
162
- return pathname;
163
- }
164
- /**
165
- * Generate a content ID in the standard format
166
- * IDs are prefixed with "vx-" followed by 8 random characters
167
- */
168
- function generateContentId() {
169
- return `vx-${nanoid(8)}`;
170
- }
171
- /**
172
- * Get the current date/time in ISO format
173
- * Used for timestamps in content files
174
- */
175
- function getCurrentISODate() {
176
- return (/* @__PURE__ */ new Date()).toISOString();
177
- }
178
- /**
179
- * Parse a date string safely
180
- * Returns null if invalid
181
- */
182
- function parseDate(dateStr) {
183
- if (!dateStr) return null;
184
- try {
185
- const date = new Date(dateStr);
186
- if (isNaN(date.getTime())) return null;
187
- return date;
188
- } catch {
189
- return null;
190
- }
191
- }
192
- /**
193
- * Creates a V8-optimized object by mapping site names to values.
194
- * Ensures all objects have the same hidden class by adding properties in consistent order.
195
- *
196
- * @param sitesConfig - Sites configuration containing site names
197
- * @param factory - Function that creates the value for each site
198
- * @returns Object with all sites initialized in alphabetical order
199
- */
200
- function mapSiteNames(sitesConfig, factory) {
201
- const obj = {};
202
- for (const siteName of Object.keys(sitesConfig.sites)) obj[siteName] = factory(siteName);
203
- return obj;
204
- }
205
- /**
206
- * Creates a V8-optimized object by mapping locale names to values.
207
- * Ensures all objects have the same hidden class by adding properties in consistent order.
208
- *
209
- * @param locales - Array of locale codes
210
- * @param factory - Function that creates the value for each locale
211
- * @returns Object with all locales initialized in array order
212
- */
213
- function mapLocales(locales, factory) {
214
- const obj = {};
215
- for (const locale of locales) obj[locale] = factory(locale);
216
- return obj;
217
- }
218
- /**
219
- * Resolves a publish date value to a valid string or undefined.
220
- * Handles various input types including null, false, and empty strings.
221
- *
222
- * @param updateValue - The value being updated (string | null | false | undefined)
223
- * @param currentValue - The current value to fall back to if updateValue is undefined
224
- * @returns A valid date string or undefined
225
- */
226
- function resolvePublishDate(updateValue, currentValue) {
227
- if (updateValue !== void 0) return updateValue && typeof updateValue === "string" ? updateValue : void 0;
228
- return currentValue;
229
- }
230
- /**
231
- * Serializes MDX content with frontmatter.
232
- * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
233
- * consistent MDX output that includes frontmatter for variable access.
234
- *
235
- * @param frontmatterData - The frontmatter data to serialize
236
- * @param mdxContent - The MDX content (without frontmatter)
237
- * @returns Complete MDX file content with frontmatter
238
- */
239
- function serializeMdxWithFrontmatter(frontmatterData, mdxContent) {
240
- return `---\n${yaml.stringify(frontmatterData)}---\n\n${mdxContent}`;
241
- }
242
-
243
61
  //#endregion
244
62
  //#region src/content-operations.ts
245
63
  /**
@@ -330,16 +148,24 @@ function validateCreateContent(data, sites, blocks, dataApi) {
330
148
  valid: false,
331
149
  error: `Pathname is required for pages (locale: ${locale})`
332
150
  };
333
- const existingId = site.getPathnameConflict(pathname, locale);
151
+ const validation = normalizeAndValidatePathname(pathname);
152
+ if (!validation.valid) return {
153
+ valid: false,
154
+ error: `Invalid pathname for locale ${locale}: ${validation.message}`,
155
+ reason: "invalid_pathname"
156
+ };
157
+ localeData.pathname = validation.value;
158
+ const normalized = validation.value;
159
+ const existingId = site.getPathnameConflict(normalized, locale);
334
160
  if (existingId) return {
335
161
  valid: false,
336
- error: `Pathname ${pathname} already exists`,
162
+ error: `Pathname ${normalized} already exists`,
337
163
  reason: "pathname_taken",
338
164
  existingId
339
165
  };
340
- if (site.isPathnameInRedirects(pathname, locale)) return {
166
+ if (site.isPathnameInRedirects(normalized, locale)) return {
341
167
  valid: false,
342
- error: `Pathname ${pathname} is already in use as a redirect`,
168
+ error: `Pathname ${normalized} is already in use as a redirect`,
343
169
  reason: "pathname_in_redirects"
344
170
  };
345
171
  }
@@ -419,10 +245,12 @@ function analyzeUpdateScope(data) {
419
245
  function shouldUpdateModifiedTimestamp(data) {
420
246
  return analyzeUpdateScope(data) !== UPDATE_SCOPE.NONE;
421
247
  }
422
-
423
248
  //#endregion
424
249
  //#region src/site.ts
425
250
  var Site = class {
251
+ siteName;
252
+ api;
253
+ siteIndex;
426
254
  constructor(siteName, api, siteIndex) {
427
255
  this.siteName = siteName;
428
256
  this.api = api;
@@ -532,7 +360,7 @@ var Site = class {
532
360
  });
533
361
  }
534
362
  };
535
-
536
363
  //#endregion
537
- export { parseDate as C, Blocks as E, normalizePathname as S, serializeMdxWithFrontmatter as T, isValidBlockName as _, buildPathnameHistory as a, mapLocales as b, validateAndPrepareMetadata as c, formatFileSize as d, generateContentId as f, isMetadataTooLarge as g, isContentPublished as h, buildLocaleVersion as i, validateCreateContent as l, getMetadataSize as m, UPDATE_SCOPE as n, shouldUpdateModifiedTimestamp as o, getCurrentISODate as p, analyzeUpdateScope as r, updatePublishDates as s, Site as t, extractBlockName as u, isValidPathname as v, resolvePublishDate as w, mapSiteNames as x, localesOf as y };
538
- //# sourceMappingURL=site-vNtJ5jCh.mjs.map
364
+ export { buildPathnameHistory as a, validateAndPrepareMetadata as c, buildLocaleVersion as i, validateCreateContent as l, UPDATE_SCOPE as n, shouldUpdateModifiedTimestamp as o, analyzeUpdateScope as r, updatePublishDates as s, Site as t, Blocks as u };
365
+
366
+ //# sourceMappingURL=site-8oaj1Q60.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-8oaj1Q60.mjs","names":[],"sources":["../src/blocks.ts","../src/content-operations.ts","../src/site.ts"],"sourcesContent":["import type { BlockIndex } from './block-index';\nimport type { ContentAPI } from './content-api.interface';\nimport type { BlockFilters, ContentManifest, CreateBlockInput, CreateResult } from './types';\n\nexport class Blocks {\n constructor(\n private api: ContentAPI,\n private blockIndex: BlockIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: BlockFilters): Generator<ContentManifest> {\n // Choose the most efficient method based on filters\n if (filters?.collection) {\n if (filters.locales && filters.locales.length > 0) {\n // Filter by locales after getting collection entries\n for (const manifest of this.blockIndex.getManifestsByCollection(filters.collection)) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getManifestsByCollection(filters.collection);\n }\n } else if (filters?.locales && filters.locales.length > 0) {\n // For multiple locales, we need to check each\n for (const manifest of this.blockIndex.getAllManifests()) {\n if (filters.locales.some((locale) => manifest.locales[locale])) {\n yield manifest;\n }\n }\n } else {\n yield* this.blockIndex.getAllManifests();\n }\n }\n\n // Get all block collections\n get collections(): Set<string> {\n return this.blockIndex.collections;\n }\n\n // Block operations (returns null if not found)\n getByName(collection: string, name: string, locale?: string): ContentManifest | null {\n return this.blockIndex.getByName(collection, name, locale);\n }\n\n // Check if block name is available\n isNameAvailable(collection: string, name: string, excludeId?: string): boolean {\n const existing = this.getByName(collection, name);\n return !existing || existing.id === excludeId;\n }\n\n // Get the ID of content that conflicts with a block name\n getNameConflict(collection: string, name: string, excludeId?: string): string | null {\n const existing = this.getByName(collection, name);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if block name is valid\n isBlockNameValid(blockName: string): boolean {\n // Block names must not be empty\n if (!blockName || blockName.trim() === '') {\n return false;\n }\n\n // Block names must not contain dots (would interfere with locale suffixes)\n if (blockName.includes('.')) {\n return false;\n }\n\n // Block names must not contain path separators\n if (blockName.includes('/') || blockName.includes('\\\\')) {\n return false;\n }\n\n // Block names should only contain alphanumeric, hyphens, underscores\n return /^[a-zA-Z0-9_-]+$/.test(blockName);\n }\n\n // Create block with name validation\n async create(data: CreateBlockInput): Promise<CreateResult> {\n // Validate block name\n if (!this.isBlockNameValid(data.name)) {\n return {\n success: false,\n reason: 'invalid_name',\n error: new Error(`Invalid block name: ${data.name}`),\n };\n }\n\n // Check if name is already taken in any locale\n const existing = this.getByName(data.collection, data.name);\n if (existing) {\n return {\n success: false,\n reason: 'name_taken',\n error: new Error(`Block name ${data.name} already exists in collection ${data.collection}`),\n };\n }\n\n // Create the content\n return this.api.createContent({\n kind: 'block',\n collection: data.collection,\n type: 'mdx',\n name: data.name,\n meta: data.meta,\n locales: data.locales,\n });\n }\n}\n","import sortKeys from 'sort-keys';\nimport type { Blocks } from './blocks';\nimport { generateContentId, isContentPublished, normalizeAndValidatePathname } from './content-utils';\nimport type { Site } from './site';\nimport type { ContentMeta, CreateContentInput, LocaleUpdateData, LocaleVersion } from './types';\n\n/**\n * Shared business logic for content operations\n * Used by both FileSystemContentAPI and InMemoryContentAPI\n */\n\n// Validation result types\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n sortedMeta?: ContentMeta;\n size?: number;\n}\n\nexport interface CreateValidationResult {\n valid: boolean;\n error?: string;\n reason?:\n | 'metadata_too_large'\n | 'pathname_taken'\n | 'pathname_in_redirects'\n | 'invalid_pathname'\n | 'invalid_name'\n | 'name_taken';\n existingId?: string;\n}\n\n/**\n * Validate and prepare metadata for storage\n * Ensures title exists and metadata doesn't exceed 4KB\n */\nexport function validateAndPrepareMetadata(meta: Partial<ContentMeta>): ValidationResult {\n // Ensure title is present\n if (!meta.title) {\n return {\n valid: false,\n error: 'Title is required in metadata',\n };\n }\n\n const sortedMeta = sortKeys(meta, { deep: true }) as ContentMeta; // We've validated title exists\n const metaJson = JSON.stringify(sortedMeta, null, 2);\n const metaSize = new TextEncoder().encode(metaJson).length;\n\n if (metaSize > 4088) {\n // Leave 8 bytes for safety\n return {\n valid: false,\n error: `Metadata exceeds 4KB limit (${metaSize} bytes)`,\n };\n }\n\n return {\n valid: true,\n sortedMeta,\n size: metaSize,\n };\n}\n\n/**\n * Build pathname history update\n */\nexport function buildPathnameHistory(\n oldPathname: string | undefined,\n newPathname: string | undefined,\n isPublished: boolean,\n now: string,\n): Record<string, string> {\n const history: Record<string, string> = {};\n\n if (oldPathname && newPathname && oldPathname !== newPathname && isPublished) {\n history[oldPathname] = now;\n }\n\n return history;\n}\n\n/**\n * Build a locale manifest\n */\nexport function buildLocaleVersion(params: {\n locale: string;\n etag: string;\n created: string;\n modified: string;\n meta: ContentMeta;\n kind: 'block' | 'page' | 'data';\n publishAt?: string;\n unpublishAt?: string;\n pathname?: string;\n name?: string;\n previousPathnames?: Record<string, string>;\n}): LocaleVersion {\n const manifest: LocaleVersion = {\n locale: params.locale,\n etag: params.etag,\n created: params.created,\n modified: params.modified,\n meta: params.meta,\n };\n\n // Add optional fields only if they exist\n if (params.publishAt) {\n manifest.publishAt = params.publishAt;\n }\n if (params.unpublishAt) {\n manifest.unpublishAt = params.unpublishAt;\n }\n if (params.pathname && params.kind === 'page') {\n manifest.pathname = params.pathname;\n }\n if (params.name && (params.kind === 'block' || params.kind === 'data')) {\n manifest.name = params.name;\n }\n if (params.previousPathnames && Object.keys(params.previousPathnames).length > 0) {\n manifest.previousPathnames = params.previousPathnames;\n }\n\n return manifest;\n}\n\n/**\n * Update publish dates on a locale manifest\n */\nexport function updatePublishDates(manifest: LocaleVersion, data: LocaleUpdateData): void {\n // Handle publishAt\n if ('publishAt' in data) {\n if (data.publishAt && typeof data.publishAt === 'string') {\n manifest.publishAt = data.publishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.publishAt;\n }\n }\n\n // Handle unpublishAt\n if ('unpublishAt' in data) {\n if (data.unpublishAt && typeof data.unpublishAt === 'string') {\n manifest.unpublishAt = data.unpublishAt;\n } else {\n // Explicitly delete the field when value is falsy\n delete manifest.unpublishAt;\n }\n }\n}\n\n/**\n * Validate content creation data\n */\nexport function validateCreateContent(\n data: CreateContentInput,\n sites: Record<string, Site>,\n blocks: Blocks,\n dataApi?: {\n isDataNameValid: (name: string) => boolean;\n getNameConflict: (collection: string, name: string) => string | null;\n },\n): CreateValidationResult {\n // Validate metadata for all locales\n for (const localeData of Object.values(data.locales)) {\n const meta = { ...data.meta, ...localeData.meta };\n const validation = validateAndPrepareMetadata(meta);\n if (!validation.valid) {\n return {\n valid: false,\n error: validation.error,\n reason: 'metadata_too_large',\n };\n }\n }\n\n // Validate pathname for pages\n if (data.kind === 'page') {\n if (!data.site) {\n return {\n valid: false,\n error: 'Site is required for pages',\n };\n }\n\n const site = sites[data.site];\n if (!site) {\n return {\n valid: false,\n error: `Site ${data.site} not found`,\n };\n }\n\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const pathname = localeData.pathname;\n\n // Pathname is required for pages\n if (!pathname) {\n return {\n valid: false,\n error: `Pathname is required for pages (locale: ${locale})`,\n };\n }\n\n // Validate and normalize pathname shape. The normalized value is\n // written back to localeData so the rest of the create flow (file\n // writes, indexing) sees the cleaned form.\n const validation = normalizeAndValidatePathname(pathname);\n if (!validation.valid) {\n return {\n valid: false,\n error: `Invalid pathname for locale ${locale}: ${validation.message}`,\n reason: 'invalid_pathname',\n };\n }\n localeData.pathname = validation.value;\n const normalized = validation.value;\n\n // Check if pathname is already taken\n const existingId = site.getPathnameConflict(normalized, locale);\n if (existingId) {\n return {\n valid: false,\n error: `Pathname ${normalized} already exists`,\n reason: 'pathname_taken',\n existingId,\n };\n }\n\n // Check if pathname is in redirects\n if (site.isPathnameInRedirects(normalized, locale)) {\n return {\n valid: false,\n error: `Pathname ${normalized} is already in use as a redirect`,\n reason: 'pathname_in_redirects',\n };\n }\n }\n }\n\n // Validate block name uniqueness\n if (data.kind === 'block') {\n if (!data.name) {\n return {\n valid: false,\n error: 'Block name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate block name format\n if (!blocks.isBlockNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid block name: ${data.name}. Block names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = blocks.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Block name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n // Validate data entry name uniqueness\n if (data.kind === 'data' && dataApi) {\n if (!data.name) {\n return {\n valid: false,\n error: 'Data name is required',\n reason: 'invalid_name',\n };\n }\n\n // Validate data name format\n if (!dataApi.isDataNameValid(data.name)) {\n return {\n valid: false,\n error: `Invalid data name: ${data.name}. Data names must contain only alphanumeric characters, hyphens, and underscores.`,\n reason: 'invalid_name',\n };\n }\n\n // Check if name is already taken in any locale\n const existingId = dataApi.getNameConflict(data.collection, data.name);\n if (existingId) {\n return {\n valid: false,\n error: `Data name ${data.name} already exists in collection ${data.collection}`,\n reason: 'name_taken',\n existingId,\n };\n }\n }\n\n return { valid: true };\n}\n\n/**\n * Generate a new content ID\n */\n/**\n * Check if content is published\n */\nexport { generateContentId, isContentPublished };\n\n/**\n * Update scope bit flags\n * Can be combined with bitwise OR and checked with bitwise AND\n */\nexport const UPDATE_SCOPE = {\n NONE: 0, // 00\n META: 1 << 0, // 01\n CONTENT: 1 << 1, // 10\n BOTH: 3, // 11 (META | CONTENT)\n} as const;\n\nexport type UpdateScope = (typeof UPDATE_SCOPE)[keyof typeof UPDATE_SCOPE];\n\n/**\n * Determine what parts of content are being updated\n * Returns bit flags that can be checked with bitwise AND\n *\n * Example usage:\n * ```\n * const scope = analyzeUpdateScope(data);\n * if (scope & UPDATE_SCOPE.META) { // metadata is being updated }\n * if (scope & UPDATE_SCOPE.CONTENT) { // content is being updated }\n * if (scope === UPDATE_SCOPE.BOTH) { // both are being updated }\n * ```\n */\nexport function analyzeUpdateScope(data: LocaleUpdateData): UpdateScope {\n let scope = UPDATE_SCOPE.NONE;\n\n // Note: pathname is NOT considered a metadata change because:\n // - For pages, pathname is derived from file path, not stored in metadata\n // - Pathname changes don't affect the metadata hash in the ETag\n if (data.meta !== undefined || data.publishAt !== undefined || data.unpublishAt !== undefined) {\n scope |= UPDATE_SCOPE.META;\n }\n\n if (data.content !== undefined) {\n scope |= UPDATE_SCOPE.CONTENT;\n }\n\n return scope;\n}\n\n/**\n * Determine whether the modified timestamp should be updated\n * Updates for ANY change - either metadata or content\n */\nexport function shouldUpdateModifiedTimestamp(data: LocaleUpdateData): boolean {\n const scope = analyzeUpdateScope(data);\n return scope !== UPDATE_SCOPE.NONE;\n}\n","import type { ContentAPI } from './content-api.interface';\nimport { localesOf } from './content-utils';\nimport type { SiteIndex } from './site-index';\nimport type { ContentManifest, CreatePageInput, CreateResult, MoveResult, SiteFilters } from './types';\n\nexport class Site {\n constructor(\n private siteName: string,\n private api: ContentAPI,\n private siteIndex: SiteIndex,\n ) {}\n\n // Content discovery\n *listContent(filters?: SiteFilters): Generator<ContentManifest> {\n // Get the base manifests using the most efficient method\n let manifests: Generator<ContentManifest>;\n\n if (filters?.locales && filters.locales.length === 1) {\n manifests = this.siteIndex.getManifestsByLocale(filters.locales[0]);\n } else {\n manifests = this.siteIndex.getAllManifests();\n }\n\n // Apply additional filters if needed\n if (filters?.collection || filters?.type || filters?.published !== undefined) {\n for (const manifest of manifests) {\n if (filters.collection && manifest.collection !== filters.collection) continue;\n if (filters.type && manifest.type !== filters.type) continue;\n if (filters.published !== undefined) {\n // Check if any locale is published\n let hasPublishedLocale = false;\n for (const locale of localesOf(manifest)) {\n if (!locale.unpublishAt || new Date(locale.unpublishAt) > new Date()) {\n hasPublishedLocale = true;\n break;\n }\n }\n if (filters.published !== hasPublishedLocale) continue;\n }\n yield manifest;\n }\n } else {\n // No additional filters, yield all manifests\n yield* manifests;\n }\n }\n\n // List pages (convenience method for middleware)\n *listPages(locale?: string): Generator<ContentManifest> {\n const filters: SiteFilters = {};\n if (locale) filters.locales = [locale];\n\n yield* this.listContent(filters);\n }\n\n // Get all collections for this site\n get collections(): Set<string> {\n return this.siteIndex.collections;\n }\n\n // Pathname operations (returns null if available, ContentManifest if taken)\n getByPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPathname(pathname, locale);\n }\n\n // Get by previous pathname (for redirects)\n getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname, locale);\n }\n\n // Move content (handles rename + redirect tracking)\n async move(id: string, locale: string, newPathname: string): Promise<MoveResult> {\n // Check if new pathname is available\n const existing = this.getByPathname(newPathname, locale);\n if (existing && existing.id !== id) {\n return {\n moved: false,\n reason: 'already_exists',\n };\n }\n\n // Get current content\n const content = await this.api.getLocalized(id, locale);\n if (!content) {\n return {\n moved: false,\n reason: 'not_found',\n };\n }\n\n // Update with new pathname (this will handle previousPathnames)\n const updateResult = await this.api.updateLocalized({\n id,\n locale,\n data: {\n pathname: newPathname,\n meta: content.localized.meta,\n },\n etag: content.localized.etag,\n });\n\n if (!updateResult.success) {\n return {\n moved: false,\n reason: updateResult.reason,\n error: updateResult.error,\n };\n }\n\n return {\n moved: true,\n previousPathname: content.localized.pathname,\n etag: updateResult.etag,\n };\n }\n\n // Check if pathname is in redirect history\n getRedirect(pathname: string): ContentManifest | null {\n return this.siteIndex.getByPreviousPathname(pathname);\n }\n\n // Validate pathname is available (not taken or in redirects)\n isPathnameAvailable(pathname: string, locale: string, excludeId?: string): boolean {\n // Check if pathname is already taken\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return false;\n }\n\n // Check if pathname is in redirects\n const redirect = this.getByPreviousPathname(pathname, locale);\n if (redirect && redirect.id !== excludeId) {\n return false;\n }\n\n return true;\n }\n\n // Get the ID of content that conflicts with a pathname\n getPathnameConflict(pathname: string, locale: string, excludeId?: string): string | null {\n const existing = this.getByPathname(pathname, locale);\n if (existing && existing.id !== excludeId) {\n return existing.id;\n }\n return null;\n }\n\n // Check if pathname is in redirects\n isPathnameInRedirects(pathname: string, locale: string): boolean {\n return this.getByPreviousPathname(pathname, locale) !== null;\n }\n\n // Create page with validation\n async create(data: CreatePageInput): Promise<CreateResult> {\n // Validate pathname availability for all locales\n for (const [locale, localeData] of Object.entries(data.locales)) {\n const existing = this.getByPathname(localeData.pathname, locale);\n if (existing) {\n return {\n success: false,\n reason: 'pathname_taken',\n error: new Error(`Pathname ${localeData.pathname} is already in use for locale ${locale}`),\n };\n }\n\n // Check redirects too\n const redirect = this.getRedirect(localeData.pathname);\n if (redirect) {\n return {\n success: false,\n reason: 'pathname_in_redirects',\n error: new Error(`Pathname ${localeData.pathname} is in redirect history for locale ${locale}`),\n };\n }\n }\n\n return this.api.createContent({\n kind: 'page',\n site: this.siteName,\n collection: data.collection,\n type: 'puck',\n locales: data.locales,\n });\n }\n}\n"],"mappings":";;;AAIA,IAAa,SAAb,MAAoB;CAER;CACA;CAFV,YACE,KACA,YACA;EAFQ,KAAA,MAAA;EACA,KAAA,aAAA;CACP;CAGH,CAAC,YAAY,SAAoD;EAE/D,IAAI,SAAS,YACX,IAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAEzC;QAAA,MAAM,YAAY,KAAK,WAAW,yBAAyB,QAAQ,UAAU,GAChF,IAAI,QAAQ,QAAQ,MAAM,WAAW,SAAS,QAAQ,OAAO,GAC3D,MAAM;EAAA,OAIV,OAAO,KAAK,WAAW,yBAAyB,QAAQ,UAAU;OAE/D,IAAI,SAAS,WAAW,QAAQ,QAAQ,SAAS,GAEjD;QAAA,MAAM,YAAY,KAAK,WAAW,gBAAgB,GACrD,IAAI,QAA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GACN,SAAS,KAAK;EAChB,CAAC;CACH;AACF"}
@@ -0,0 +1,136 @@
1
+ import { c as ContentIdentity, k as LocaleVersion, o as ContentData, u as ContentManifest } from "./types-DjfhS272.mjs";
2
+ //#region src/base-content-index.d.ts
3
+ /**
4
+ * Base class for content indexes (blocks, data)
5
+ * Maintains collection->name->locale lookups with V8-optimized structures
6
+ */
7
+ declare class BaseContentIndex {
8
+ protected index: Map<string, ContentManifest>;
9
+ protected contentCache: Map<string, Record<string, ContentData | null>>;
10
+ protected nameIndex: Map<string, Map<string, ContentManifest>>;
11
+ readonly collections: Set<string>;
12
+ /**
13
+ * Add or update content in the index
14
+ * Merges manifest locales and updates content cache if provided
15
+ */
16
+ addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
17
+ /**
18
+ * Remove a specific locale from an entry
19
+ */
20
+ removeLocale(id: string, locale: string): void;
21
+ /**
22
+ * Remove an entry from the index
23
+ */
24
+ removeEntry(id: string): void;
25
+ /**
26
+ * Get cached content for a specific locale
27
+ */
28
+ getCachedContent(id: string, locale: string): ContentData | null;
29
+ /**
30
+ * Get content manifest
31
+ */
32
+ getManifest(id: string): ContentManifest | null;
33
+ /**
34
+ * Find entry by name
35
+ */
36
+ getByName(collection: string, name: string, locale?: string): ContentManifest | null;
37
+ /**
38
+ * Generator for all manifests
39
+ */
40
+ getAllManifests(): Generator<ContentManifest>;
41
+ /**
42
+ * Generator for manifests by locale
43
+ */
44
+ getManifestsByLocale(locale: string): Generator<ContentManifest>;
45
+ /**
46
+ * Generator for manifests by collection
47
+ */
48
+ getManifestsByCollection(collection: string): Generator<ContentManifest>;
49
+ /**
50
+ * Get the count of indexed content entries (unique IDs)
51
+ */
52
+ get entryCount(): number;
53
+ /**
54
+ * Clear all indexes
55
+ */
56
+ clear(): void;
57
+ }
58
+ //#endregion
59
+ //#region src/block-index.d.ts
60
+ /**
61
+ * V8-optimized index for blocks
62
+ * Maintains collection->name->locale lookups
63
+ */
64
+ declare class BlockIndex extends BaseContentIndex {
65
+ constructor(locales: string[]);
66
+ }
67
+ //#endregion
68
+ //#region src/data-index.d.ts
69
+ /**
70
+ * V8-optimized index for data collections
71
+ * Maintains collection->name->locale lookups
72
+ */
73
+ declare class DataIndex extends BaseContentIndex {}
74
+ //#endregion
75
+ //#region src/site-index.d.ts
76
+ /**
77
+ * V8-optimized index for a single site
78
+ * Maintains pathname lookups and collections for one site only
79
+ */
80
+ declare class SiteIndex {
81
+ private locales;
82
+ private index;
83
+ private contentCache;
84
+ private pathnameIndex;
85
+ private previousPathnameIndex;
86
+ readonly collections: Set<string>;
87
+ constructor(siteName: string, locales: string[]);
88
+ /**
89
+ * Add or update content in the index
90
+ * Merges manifest locales and updates content cache if provided
91
+ */
92
+ addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
93
+ /**
94
+ * Remove a specific locale from an entry
95
+ */
96
+ removeLocale(id: string, locale: string): void;
97
+ /**
98
+ * Remove an entry from the index
99
+ */
100
+ removeEntry(id: string): void;
101
+ /**
102
+ * Get cached content for a specific locale
103
+ */
104
+ getCachedContent(id: string, locale: string): ContentData | null;
105
+ /**
106
+ * Get content manifest
107
+ */
108
+ getManifest(id: string): ContentManifest | null;
109
+ /**
110
+ * Find content by pathname
111
+ */
112
+ getByPathname(pathname: string, locale?: string): ContentManifest | null;
113
+ /**
114
+ * Find content by previous pathname (for redirects)
115
+ */
116
+ getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
117
+ /**
118
+ * Generator for all manifests
119
+ */
120
+ getAllManifests(): Generator<ContentManifest>;
121
+ /**
122
+ * Generator for manifests by locale
123
+ */
124
+ getManifestsByLocale(locale: string): Generator<ContentManifest>;
125
+ /**
126
+ * Get the count of indexed content entries (unique IDs)
127
+ */
128
+ get entryCount(): number;
129
+ /**
130
+ * Clear all indexes
131
+ */
132
+ clear(): void;
133
+ }
134
+ //#endregion
135
+ export { DataIndex as n, BlockIndex as r, SiteIndex as t };
136
+ //# sourceMappingURL=site-index-B_254bCc.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-index-B_254bCc.d.mts","names":[],"sources":["../src/base-content-index.ts","../src/block-index.ts","../src/data-index.ts","../src/site-index.ts"],"mappings":";;;;;;cAOa;YAED,OAAO,YAAY;YAGnB,cAAc,YAAY,eAAe;YAGzC,WAAW,YAAY,YAAY;WAGpC,aAAa;;;;;EAMtB,WAAW,UAAU,iBAAiB,eAAe,eAAe,UAAU;;;;EAoD9E,aAAa,YAAY;;;;EAuBzB,YAAY;;;;EAyBZ,iBAAiB,YAAY,iBAAiB;;;;EAQ9C,YAAY,aAAa;;;;EAOzB,UAAU,oBAAoB,cAAc,kBAAkB;;;;EAkB7D,mBAAmB,UAAU;;;;EAS7B,qBAAqB,iBAAiB,UAAU;;;;EAWhD,yBAAyB,qBAAqB,UAAU;;;;MAWrD;;;;EAOJ;;;;;;;;cC7LW,mBAAmB;EAClB,YAAA;;;;;;;;cCDD,kBAAkB;;;;;;;cCClB;UAoBD;UAlBF;UAGA;UAIA;UAIA;WAGC,aAAa;EAGpB,YAAA,kBACQ;;;;;EAWV,WAAW,UAAU,iBAAiB,eAAe,eAAe,UAAU;;;;EA4I9E,aAAa,YAAY;;;;EAkCzB,YAAY;;;;EA2BZ,iBAAiB,YAAY,iBAAiB;;;;EAQ9C,YAAY,aAAa;;;;EAOzB,cAAc,kBAAkB,kBAAkB;;;;EAmBlD,sBAAsB,kBAAkB,kBAAkB;;;;EAmBzD,mBAAmB,UAAU;;;;EAS7B,qBAAqB,iBAAiB,UAAU;;;;MAW7C;;;;EAOJ"}
@@ -0,0 +1,60 @@
1
+ import type { ContentData, ContentIdentity, ContentManifest, LocaleVersion } from './types';
2
+ /**
3
+ * V8-optimized index for a single site
4
+ * Maintains pathname lookups and collections for one site only
5
+ */
6
+ export declare class SiteIndex {
7
+ private locales;
8
+ private index;
9
+ private contentCache;
10
+ private pathnameIndex;
11
+ private previousPathnameIndex;
12
+ readonly collections: Set<string>;
13
+ constructor(siteName: string, locales: string[]);
14
+ /**
15
+ * Add or update content in the index
16
+ * Merges manifest locales and updates content cache if provided
17
+ */
18
+ addContent(identity: ContentIdentity, localeVersion: LocaleVersion, content?: ContentData | null): void;
19
+ /**
20
+ * Remove a specific locale from an entry
21
+ */
22
+ removeLocale(id: string, locale: string): void;
23
+ /**
24
+ * Remove an entry from the index
25
+ */
26
+ removeEntry(id: string): void;
27
+ /**
28
+ * Get cached content for a specific locale
29
+ */
30
+ getCachedContent(id: string, locale: string): ContentData | null;
31
+ /**
32
+ * Get content manifest
33
+ */
34
+ getManifest(id: string): ContentManifest | null;
35
+ /**
36
+ * Find content by pathname
37
+ */
38
+ getByPathname(pathname: string, locale?: string): ContentManifest | null;
39
+ /**
40
+ * Find content by previous pathname (for redirects)
41
+ */
42
+ getByPreviousPathname(pathname: string, locale?: string): ContentManifest | null;
43
+ /**
44
+ * Generator for all manifests
45
+ */
46
+ getAllManifests(): Generator<ContentManifest>;
47
+ /**
48
+ * Generator for manifests by locale
49
+ */
50
+ getManifestsByLocale(locale: string): Generator<ContentManifest>;
51
+ /**
52
+ * Get the count of indexed content entries (unique IDs)
53
+ */
54
+ get entryCount(): number;
55
+ /**
56
+ * Clear all indexes
57
+ */
58
+ clear(): void;
59
+ }
60
+ //# sourceMappingURL=site-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-index.d.ts","sourceRoot":"","sources":["../src/site-index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE5F;;;GAGG;AACH,qBAAa,SAAS;IAoBlB,OAAO,CAAC,OAAO;IAlBjB,OAAO,CAAC,KAAK,CAA2C;IAGxD,OAAO,CAAC,YAAY,CAA8D;IAIlF,OAAO,CAAC,aAAa,CAA+C;IAIpE,OAAO,CAAC,qBAAqB,CAA+C;IAG5E,QAAQ,CAAC,WAAW,EAAE,GAAG,CAA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