@conloca/content-api 0.1.15 → 0.2.0

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 (281) hide show
  1. package/dist/asset-constraints.d.ts +16 -0
  2. package/dist/asset-constraints.d.ts.map +1 -0
  3. package/dist/asset-constraints.js +29 -0
  4. package/dist/asset-constraints.js.map +1 -0
  5. package/dist/asset-metadata-store.d.ts +60 -0
  6. package/dist/asset-metadata-store.d.ts.map +1 -0
  7. package/dist/asset-metadata-store.js +335 -0
  8. package/dist/asset-metadata-store.js.map +1 -0
  9. package/dist/asset-operations.d.ts +164 -0
  10. package/dist/asset-operations.d.ts.map +1 -0
  11. package/dist/asset-operations.js +784 -0
  12. package/dist/asset-operations.js.map +1 -0
  13. package/dist/asset-types.d.ts +72 -0
  14. package/dist/asset-types.d.ts.map +1 -0
  15. package/dist/asset-types.js +13 -0
  16. package/dist/asset-types.js.map +1 -0
  17. package/dist/asset-usage.d.ts +10 -0
  18. package/dist/asset-usage.d.ts.map +1 -0
  19. package/dist/asset-usage.js +49 -0
  20. package/dist/asset-usage.js.map +1 -0
  21. package/dist/base-content-index.d.ts +63 -0
  22. package/dist/base-content-index.d.ts.map +1 -0
  23. package/dist/base-content-index.js +200 -0
  24. package/dist/base-content-index.js.map +1 -0
  25. package/dist/cf-access.d.ts +31 -0
  26. package/dist/cf-access.d.ts.map +1 -0
  27. package/dist/cf-access.js +67 -0
  28. package/dist/cf-access.js.map +1 -0
  29. package/dist/component-registry.d.ts +50 -0
  30. package/dist/component-registry.d.ts.map +1 -0
  31. package/dist/component-registry.js +121 -0
  32. package/dist/component-registry.js.map +1 -0
  33. package/dist/component-registry.types.d.ts +11 -0
  34. package/dist/component-registry.types.d.ts.map +1 -0
  35. package/dist/component-registry.types.js +2 -0
  36. package/dist/component-registry.types.js.map +1 -0
  37. package/dist/component-vocabulary.d.ts +33 -0
  38. package/dist/component-vocabulary.d.ts.map +1 -0
  39. package/dist/component-vocabulary.js +105 -0
  40. package/dist/component-vocabulary.js.map +1 -0
  41. package/dist/content-api.interface.d.ts +64 -0
  42. package/dist/content-api.interface.d.ts.map +1 -0
  43. package/dist/content-api.interface.js +2 -0
  44. package/dist/content-api.interface.js.map +1 -0
  45. package/dist/content-filters.d.ts +31 -0
  46. package/dist/content-filters.d.ts.map +1 -0
  47. package/dist/content-filters.js +247 -0
  48. package/dist/content-filters.js.map +1 -0
  49. package/dist/content-index.d.ts +184 -0
  50. package/dist/content-index.d.ts.map +1 -0
  51. package/dist/content-index.js +546 -0
  52. package/dist/content-index.js.map +1 -0
  53. package/dist/content-operations.d.ts +157 -0
  54. package/dist/content-operations.d.ts.map +1 -0
  55. package/dist/content-operations.js +359 -0
  56. package/dist/content-operations.js.map +1 -0
  57. package/dist/content-path.d.ts +59 -0
  58. package/dist/content-path.d.ts.map +1 -0
  59. package/dist/content-path.js +88 -0
  60. package/dist/content-path.js.map +1 -0
  61. package/dist/content-reader.d.ts +10 -0
  62. package/dist/content-reader.d.ts.map +1 -0
  63. package/dist/content-reader.js +14 -0
  64. package/dist/content-reader.js.map +1 -0
  65. package/dist/content-utils.d.ts +175 -0
  66. package/dist/content-utils.d.ts.map +1 -0
  67. package/dist/content-utils.js +421 -0
  68. package/dist/content-utils.js.map +1 -0
  69. package/dist/content-watcher.d.ts +43 -0
  70. package/dist/content-watcher.d.ts.map +1 -0
  71. package/dist/content-watcher.js +86 -0
  72. package/dist/content-watcher.js.map +1 -0
  73. package/dist/data-index.d.ts +8 -0
  74. package/dist/data-index.d.ts.map +1 -0
  75. package/dist/data-index.js +8 -0
  76. package/dist/data-index.js.map +1 -0
  77. package/dist/data.d.ts +35 -0
  78. package/dist/data.d.ts.map +1 -0
  79. package/dist/data.js +104 -0
  80. package/dist/data.js.map +1 -0
  81. package/dist/editor-data-bindings.d.ts +10 -0
  82. package/dist/editor-data-bindings.d.ts.map +1 -0
  83. package/dist/editor-data-bindings.js +67 -0
  84. package/dist/editor-data-bindings.js.map +1 -0
  85. package/dist/etag-utils.d.ts +77 -0
  86. package/dist/etag-utils.d.ts.map +1 -0
  87. package/dist/etag-utils.js +161 -0
  88. package/dist/etag-utils.js.map +1 -0
  89. package/dist/filesystem-content-api.d.ts +162 -0
  90. package/dist/filesystem-content-api.d.ts.map +1 -0
  91. package/dist/filesystem-content-api.js +2307 -0
  92. package/dist/filesystem-content-api.js.map +1 -0
  93. package/dist/filesystem-reader-backend.d.ts +46 -0
  94. package/dist/filesystem-reader-backend.d.ts.map +1 -0
  95. package/dist/filesystem-reader-backend.js +119 -0
  96. package/dist/filesystem-reader-backend.js.map +1 -0
  97. package/dist/fragment-index.d.ts +8 -0
  98. package/dist/fragment-index.d.ts.map +1 -0
  99. package/dist/fragment-index.js +8 -0
  100. package/dist/fragment-index.js.map +1 -0
  101. package/dist/fragments.d.ts +16 -0
  102. package/dist/fragments.d.ts.map +1 -0
  103. package/dist/fragments.js +104 -0
  104. package/dist/fragments.js.map +1 -0
  105. package/dist/git-operations.d.ts +49 -0
  106. package/dist/git-operations.d.ts.map +1 -0
  107. package/dist/git-operations.js +256 -0
  108. package/dist/git-operations.js.map +1 -0
  109. package/dist/header-parser.d.ts +37 -0
  110. package/dist/header-parser.d.ts.map +1 -0
  111. package/dist/header-parser.js +233 -0
  112. package/dist/header-parser.js.map +1 -0
  113. package/dist/in-memory-content-api.d.ts +35 -0
  114. package/dist/in-memory-content-api.d.ts.map +1 -0
  115. package/dist/in-memory-content-api.js +609 -0
  116. package/dist/in-memory-content-api.js.map +1 -0
  117. package/dist/index.d.ts +26 -0
  118. package/dist/index.d.ts.map +1 -0
  119. package/dist/index.js +28 -0
  120. package/dist/index.js.map +1 -0
  121. package/dist/indexing.d.ts +5 -0
  122. package/dist/indexing.d.ts.map +1 -0
  123. package/dist/indexing.js +8 -0
  124. package/dist/indexing.js.map +1 -0
  125. package/dist/json-whitespace-view.d.ts +32 -0
  126. package/dist/json-whitespace-view.d.ts.map +1 -0
  127. package/dist/json-whitespace-view.js +153 -0
  128. package/dist/json-whitespace-view.js.map +1 -0
  129. package/dist/middleware.d.ts +20 -0
  130. package/dist/middleware.d.ts.map +1 -0
  131. package/dist/middleware.js +1082 -0
  132. package/dist/middleware.js.map +1 -0
  133. package/dist/node.d.ts +32 -0
  134. package/dist/node.d.ts.map +1 -0
  135. package/dist/node.js +27 -0
  136. package/dist/node.js.map +1 -0
  137. package/dist/page-references.d.ts +21 -0
  138. package/dist/page-references.d.ts.map +1 -0
  139. package/dist/page-references.js +50 -0
  140. package/dist/page-references.js.map +1 -0
  141. package/dist/read-date.d.ts +3 -0
  142. package/dist/read-date.d.ts.map +1 -0
  143. package/dist/read-date.js +9 -0
  144. package/dist/read-date.js.map +1 -0
  145. package/dist/reader-backend.d.ts +54 -0
  146. package/dist/reader-backend.d.ts.map +1 -0
  147. package/dist/reader-backend.js +2 -0
  148. package/dist/reader-backend.js.map +1 -0
  149. package/dist/reader.d.ts +15 -0
  150. package/dist/reader.d.ts.map +1 -0
  151. package/dist/reader.js +14 -0
  152. package/dist/reader.js.map +1 -0
  153. package/dist/schemas/index.d.ts +102 -0
  154. package/dist/schemas/index.d.ts.map +1 -0
  155. package/dist/schemas/index.js +88 -0
  156. package/dist/schemas/index.js.map +1 -0
  157. package/dist/site-index.d.ts +60 -0
  158. package/dist/site-index.d.ts.map +1 -0
  159. package/dist/site-index.js +291 -0
  160. package/dist/site-index.js.map +1 -0
  161. package/dist/site.d.ts +23 -0
  162. package/dist/site.d.ts.map +1 -0
  163. package/dist/site.js +180 -0
  164. package/dist/site.js.map +1 -0
  165. package/dist/types.d.ts +641 -0
  166. package/dist/types.d.ts.map +1 -0
  167. package/dist/types.js +45 -0
  168. package/dist/types.js.map +1 -0
  169. package/dist/url-safe-base64.d.ts +12 -0
  170. package/dist/url-safe-base64.d.ts.map +1 -0
  171. package/dist/url-safe-base64.js +41 -0
  172. package/dist/url-safe-base64.js.map +1 -0
  173. package/dist/url-validation.d.ts +28 -0
  174. package/dist/url-validation.d.ts.map +1 -0
  175. package/dist/url-validation.js +123 -0
  176. package/dist/url-validation.js.map +1 -0
  177. package/dist/utils/atomic-write.d.ts +6 -0
  178. package/dist/utils/atomic-write.d.ts.map +1 -0
  179. package/dist/utils/atomic-write.js +21 -0
  180. package/dist/utils/atomic-write.js.map +1 -0
  181. package/dist/utils.d.ts +46 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +71 -0
  184. package/dist/utils.js.map +1 -0
  185. package/dist/vite-plugin.d.ts +12 -0
  186. package/dist/vite-plugin.d.ts.map +1 -0
  187. package/dist/vite-plugin.js +30 -0
  188. package/dist/vite-plugin.js.map +1 -0
  189. package/dist/vxjson-serialize.d.ts +13 -0
  190. package/dist/vxjson-serialize.d.ts.map +1 -0
  191. package/dist/vxjson-serialize.js +53 -0
  192. package/dist/vxjson-serialize.js.map +1 -0
  193. package/dist/vxjson.d.ts +113 -0
  194. package/dist/vxjson.d.ts.map +1 -0
  195. package/dist/vxjson.js +381 -0
  196. package/dist/vxjson.js.map +1 -0
  197. package/dist/xxhash.d.ts +10 -0
  198. package/dist/xxhash.d.ts.map +1 -0
  199. package/dist/xxhash.js +35 -0
  200. package/dist/xxhash.js.map +1 -0
  201. package/package.json +132 -34
  202. package/src/asset-constraints.ts +33 -0
  203. package/src/asset-metadata-store.ts +401 -0
  204. package/src/asset-operations.ts +914 -0
  205. package/src/asset-types.ts +74 -0
  206. package/src/asset-usage.ts +47 -0
  207. package/src/base-content-index.ts +227 -0
  208. package/src/cf-access.ts +85 -0
  209. package/src/component-registry.ts +145 -0
  210. package/src/component-registry.types.ts +12 -0
  211. package/src/component-vocabulary.ts +87 -0
  212. package/src/content-api.interface.ts +94 -0
  213. package/src/content-filters.ts +278 -0
  214. package/src/content-index.ts +642 -0
  215. package/src/content-operations.ts +497 -0
  216. package/src/content-path.ts +113 -0
  217. package/src/content-reader.ts +18 -0
  218. package/src/content-utils.ts +474 -0
  219. package/src/content-watcher.ts +122 -0
  220. package/src/data-index.ts +7 -0
  221. package/src/data.ts +134 -0
  222. package/src/editor-data-bindings.ts +66 -0
  223. package/src/etag-utils.ts +204 -0
  224. package/src/filesystem-content-api.ts +2685 -0
  225. package/src/filesystem-reader-backend.ts +135 -0
  226. package/src/fragment-index.ts +7 -0
  227. package/src/fragments.ts +113 -0
  228. package/src/git-operations.ts +340 -0
  229. package/src/header-parser.ts +272 -0
  230. package/src/in-memory-content-api.ts +760 -0
  231. package/src/index.ts +45 -0
  232. package/src/indexing.ts +8 -0
  233. package/src/json-whitespace-view.ts +155 -0
  234. package/src/middleware.ts +1341 -0
  235. package/src/node.ts +40 -0
  236. package/src/page-references.ts +76 -0
  237. package/src/read-date.ts +7 -0
  238. package/src/reader-backend.ts +54 -0
  239. package/src/reader.ts +15 -0
  240. package/src/schemas/index.ts +113 -0
  241. package/src/site-index.ts +330 -0
  242. package/src/site.ts +198 -0
  243. package/src/types.ts +759 -0
  244. package/src/url-safe-base64.ts +38 -0
  245. package/src/url-validation.ts +121 -0
  246. package/src/utils/atomic-write.ts +20 -0
  247. package/src/utils.ts +84 -0
  248. package/src/vite-plugin.ts +45 -0
  249. package/src/vxjson-serialize.ts +66 -0
  250. package/src/vxjson.ts +442 -0
  251. package/src/xxhash.ts +43 -0
  252. package/dist/component-registry.types-CBGONnYn.d.mts +0 -71
  253. package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
  254. package/dist/content-operations-Dv67amz3.d.mts +0 -852
  255. package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
  256. package/dist/data-Db1Iv9T0.mjs +0 -60
  257. package/dist/data-Db1Iv9T0.mjs.map +0 -1
  258. package/dist/filesystem-content-api-C1TM0GLo.d.mts +0 -119
  259. package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
  260. package/dist/filesystem-content-api-kxKY5IUw.mjs +0 -2678
  261. package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
  262. package/dist/index.d.mts +0 -79
  263. package/dist/index.d.mts.map +0 -1
  264. package/dist/index.mjs +0 -47
  265. package/dist/index.mjs.map +0 -1
  266. package/dist/node.d.mts +0 -378
  267. package/dist/node.d.mts.map +0 -1
  268. package/dist/node.mjs +0 -2618
  269. package/dist/node.mjs.map +0 -1
  270. package/dist/reader.d.mts +0 -18
  271. package/dist/reader.d.mts.map +0 -1
  272. package/dist/reader.mjs +0 -22
  273. package/dist/reader.mjs.map +0 -1
  274. package/dist/schemas/index.d.mts +0 -90
  275. package/dist/schemas/index.d.mts.map +0 -1
  276. package/dist/schemas/index.mjs +0 -70
  277. package/dist/schemas/index.mjs.map +0 -1
  278. package/dist/site-vNtJ5jCh.mjs +0 -538
  279. package/dist/site-vNtJ5jCh.mjs.map +0 -1
  280. package/dist/types-DWt912tu.mjs +0 -33
  281. package/dist/types-DWt912tu.mjs.map +0 -1
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The ONE locale/path grammar for content files.
3
+ *
4
+ * Every reader that turns a storage path back into content identity parses it
5
+ * here: the pure header parser, the filesystem indexer, and any other reader
6
+ * of content files. Each of those used to carry its own copy of the
7
+ * regex and the copies disagreed — a copy that refused `about.EN.mdx`
8
+ * made content the index had accepted unreadable, and an indexer copy
9
+ * matching `\w+` filed `about.en-US.mdx` under a fallback locale with no
10
+ * pathname at all.
11
+ *
12
+ * Zero imports on purpose: some consumers embed this module where nothing
13
+ * effectful may run at import time.
14
+ */
15
+ /**
16
+ * A two-letter language subtag, optionally followed by a two-letter upper-case
17
+ * region (`en`, `nl`, `en-US`). Case is PRESERVED, never normalized: writers
18
+ * splice this exact string back into the filename (`getFilePath`, and any other
19
+ * writer of content files), so lower-casing it here would make a repo holding
20
+ * `about.EN.mdx` save its next edit to `about.en.mdx` and orphan the original.
21
+ *
22
+ * Wider BCP-47 forms (three-letter languages, script subtags like `zh-Hans`,
23
+ * lower-case regions) are deliberately NOT accepted: no spec text defines the
24
+ * grammar, and every writer in the system emits this shape today.
25
+ */
26
+ const LOCALE_SUBTAG = '[a-zA-Z]{2}(?:-[A-Z]{2})?';
27
+ const LOCALE = new RegExp(`^${LOCALE_SUBTAG}$`);
28
+ /**
29
+ * Whether `locale` is one this grammar reads back. A writer checks a new entry's locale with it:
30
+ * the locale is spliced into the file path, so anything else is either unreadable or, like
31
+ * '../x', a path out of the entry's folder.
32
+ */
33
+ export function isContentLocale(locale) {
34
+ return LOCALE.test(locale);
35
+ }
36
+ /** `<base>.<locale>.<ext>` — the filename half of every content layout. */
37
+ const LOCALE_FILENAME = new RegExp(`^(.+)\\.(${LOCALE_SUBTAG})\\.(mdx|vxjson|json)$`);
38
+ /** Split `<base>.<locale>.<ext>`. Null when the filename carries no locale suffix. */
39
+ export function parseLocaleFilename(filename) {
40
+ const match = LOCALE_FILENAME.exec(filename);
41
+ if (!match)
42
+ return null;
43
+ return { base: match[1], locale: match[2], extension: match[3] };
44
+ }
45
+ /**
46
+ * Pure path → identity mapper. Returns null when the path doesn't match any
47
+ * supported layout or lacks an explicit locale suffix.
48
+ *
49
+ * Layouts honoured here mirror filesystem-content-api.ts:137-144:
50
+ *
51
+ * - `fragments/<collection>/<name>.<locale>.{mdx,vxjson}` (collection required;
52
+ * `fragments/<name>.<locale>.ext` is a legacy form that FileSystemContentAPI
53
+ * repairs by renaming. The pure parser refuses it.)
54
+ * - `data/<collection>/<name>.<locale>.json`
55
+ * - `<site>/<collection>/<path...>/<file>.<locale>.{vxjson,mdx}` (pages; `index`
56
+ * basename maps to the parent path).
57
+ *
58
+ * Reads accept .mdx pages even though the filesystem writer emits main-layout
59
+ * pages as .vxjson only (its mdx pages live under the separate mdxPagesRoot):
60
+ * another writer may derive the extension from the content type, so an
61
+ * mdx-typed page can land here as <site>/pages/<f>.<l>.mdx and must re-parse —
62
+ * dropping it made written pages unreadable.
63
+ */
64
+ export function parseContentPathLayout(path) {
65
+ const parts = path.split('/').filter(Boolean);
66
+ if (parts.length < 3)
67
+ return null;
68
+ const suffix = parseLocaleFilename(parts[parts.length - 1]);
69
+ if (!suffix)
70
+ return null;
71
+ if (parts[0] === 'fragments') {
72
+ if (parts.length !== 3 || suffix.extension === 'json')
73
+ return null;
74
+ return { kind: 'fragment', collection: parts[1], name: suffix.base, locale: suffix.locale };
75
+ }
76
+ if (parts[0] === 'data') {
77
+ if (parts.length !== 3 || suffix.extension !== 'json')
78
+ return null;
79
+ return { kind: 'data', collection: parts[1], name: suffix.base, locale: suffix.locale };
80
+ }
81
+ if (suffix.extension === 'json')
82
+ return null;
83
+ const pathParts = parts.slice(2);
84
+ pathParts[pathParts.length - 1] = suffix.base;
85
+ const pathname = pathParts[pathParts.length - 1] === 'index' ? `/${pathParts.slice(0, -1).join('/')}` : `/${pathParts.join('/')}`;
86
+ return { kind: 'page', site: parts[0], collection: parts[1], locale: suffix.locale, pathname };
87
+ }
88
+ //# sourceMappingURL=content-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-path.js","sourceRoot":"","sources":["../src/content-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,2EAA2E;AAC3E,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,YAAY,aAAa,wBAAwB,CAAC,CAAC;AAYtF,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE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CAAC,CAAC;IACjC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;IAC9C,MAAM,QAAQ,GACZ,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAEnH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;AACjG,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ContentAPIOptions } from './types.js';
2
+ export type ContentReaderOptions = ContentAPIOptions;
3
+ /**
4
+ * Creates a read-oriented content API instance for build-time consumers.
5
+ *
6
+ * The filesystem implementation is loaded lazily so build tooling does not
7
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
8
+ */
9
+ export declare function createContentAPI(options: ContentReaderOptions): Promise<import("./filesystem-content-api.js").FileSystemContentAPI>;
10
+ //# sourceMappingURL=content-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-reader.d.ts","sourceRoot":"","sources":["../src/content-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,uEAOnE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Creates a read-oriented content API instance for build-time consumers.
3
+ *
4
+ * The filesystem implementation is loaded lazily so build tooling does not
5
+ * eagerly traverse native hashing dependencies through the reader entrypoint.
6
+ */
7
+ export async function createContentAPI(options) {
8
+ const { FileSystemContentAPI: ReaderAPI } = await import('./filesystem-content-api.js');
9
+ return ReaderAPI.create({
10
+ ...options,
11
+ canvasDir: options.canvasDir || './canvas',
12
+ });
13
+ }
14
+ //# sourceMappingURL=content-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-reader.js","sourceRoot":"","sources":["../src/content-reader.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA6B;IAClE,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IAExF,OAAO,SAAS,CAAC,MAAM,CAAC;QACtB,GAAG,OAAO;QACV,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,UAAU;KAC3C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,175 @@
1
+ import type { ContentMeta, ContentMetaPatch } from './types.js';
2
+ export declare function localesOf<T>(manifest: {
3
+ locales: Record<string, T | undefined>;
4
+ }): Generator<T>;
5
+ /**
6
+ * Pure utility functions for content operations
7
+ * These functions don't depend on any class state and can be shared
8
+ * between FileSystemContentAPI, InMemoryContentAPI, and other implementations
9
+ */
10
+ /**
11
+ * Whether content is published at `now`: from its publish time on, until the
12
+ * instant its unpublish time arrives. Empty or invalid dates count as not set.
13
+ * Serving a page, the page feed, the site index and the status the editor
14
+ * shows for a page all ask this, so the site and the editor agree at the
15
+ * unpublish instant.
16
+ * The `published` listing filter asks a different question: whether any
17
+ * locale is still before its unpublish time.
18
+ *
19
+ * The schedule takes a locale version or a page entry. A page entry from the
20
+ * Astro schema holds Date values and nulls, and `undefined` is spelled out
21
+ * rather than left to `?:` so a host compiling with exactOptionalPropertyTypes
22
+ * can pass the entry straight in: its schedule keys can be present with no
23
+ * value.
24
+ */
25
+ export declare function isContentPublished(schedule: {
26
+ publishAt?: string | Date | null | undefined;
27
+ unpublishAt?: string | Date | null | undefined;
28
+ }, now?: Date): boolean;
29
+ /**
30
+ * Apply a dialog's metadata patch: absent keys keep the stored value, null
31
+ * deletes the field. Every update path merges through here so "clear" cannot
32
+ * silently regress back into "keep" at one of the spread sites.
33
+ */
34
+ export declare function applyMetaPatch(current: ContentMeta, patch: ContentMetaPatch): Partial<ContentMeta>;
35
+ /**
36
+ * The underlying merge: null deletes, absent or undefined keeps. Shared by
37
+ * content metadata and asset-manifest updates so "clear" means one thing
38
+ * everywhere a dialog saves a fixed set of fields.
39
+ */
40
+ export declare function applyNullClearPatch<T extends object>(current: T, patch: {
41
+ [K in keyof T]?: T[K] | null;
42
+ }): Partial<T>;
43
+ /**
44
+ * A meta field read as a string, or undefined when it holds anything else.
45
+ *
46
+ * Fields outside ContentMeta's declared set are typed as JsonValue, because
47
+ * that is all the format guarantees. Content meta is also hand-editable in
48
+ * git, so a reader that wants a string genuinely cannot assume it has one —
49
+ * narrowing here stops a malformed value from posing as a real one, which a
50
+ * cast would wave through. Takes `unknown` so it also serves callers holding
51
+ * meta in a looser shape than ContentMeta.
52
+ */
53
+ export declare function metaString(value: unknown): string | undefined;
54
+ /**
55
+ * Validate that metadata doesn't exceed 4KB when serialized
56
+ * This ensures efficient indexing as per the specification
57
+ */
58
+ export declare function isMetadataTooLarge(meta: ContentMeta): boolean;
59
+ /**
60
+ * Extract fragment name from various sources
61
+ * Used when displaying fragments in the UI
62
+ */
63
+ export declare function extractFragmentName(source: string): string;
64
+ /**
65
+ * Validate fragment name according to the specification
66
+ * - Cannot contain dots (reserved for locale separator)
67
+ * - Cannot contain slashes (would create subdirectories)
68
+ * - Cannot contain spaces (for clean filenames)
69
+ * - Must have at least one character
70
+ */
71
+ export declare function isValidFragmentName(name: string): boolean;
72
+ /**
73
+ * Format file size for display with human-readable units
74
+ * @example formatFileSize(1536) // "1.5 KB"
75
+ */
76
+ export declare function formatFileSize(bytes: number): string;
77
+ /**
78
+ * Calculate metadata size in bytes
79
+ */
80
+ export declare function getMetadataSize(meta: ContentMeta): number;
81
+ /**
82
+ * Check if a pathname is valid
83
+ * - Must start with /
84
+ * - Cannot contain spaces (should be URL-encoded)
85
+ * - Cannot contain special characters that would break URLs
86
+ */
87
+ export declare function isValidPathname(pathname: string): boolean;
88
+ /**
89
+ * Normalize a pathname to ensure consistency
90
+ * - Ensure it starts with /
91
+ * - Remove trailing slashes (except for root)
92
+ * - Collapse multiple slashes
93
+ */
94
+ export declare function normalizePathname(pathname: string): string;
95
+ /**
96
+ * Reasons a pathname can be rejected. Each maps to a specific user-facing
97
+ * error message so the UI can highlight the exact problem.
98
+ */
99
+ export type PathnameValidationReason = 'empty' | 'whitespace' | 'forbidden_char' | 'control_char' | 'uppercase' | 'non_ascii' | 'traversal_segment' | 'index_segment' | 'disallowed_char';
100
+ export interface PathnameValidationResult {
101
+ /** When valid: the normalized pathname. When invalid: the raw (trimmed) input. */
102
+ value: string;
103
+ valid: boolean;
104
+ reason?: PathnameValidationReason;
105
+ message?: string;
106
+ }
107
+ /**
108
+ * Validate the shape of a CMS pathname and normalize it for storage.
109
+ *
110
+ * Silently fixes harmless slips (missing leading slash, doubled slashes,
111
+ * trailing slash) and rejects malformed inputs with a specific reason so
112
+ * the UI can show a helpful error message.
113
+ *
114
+ * Accepted chars: a–z, 0–9, `-`, `_`, `/`. Mixed case, accents, spaces,
115
+ * `?`, `#`, `\`, and traversal segments (`.`, `..`) are rejected, as is a
116
+ * last segment `index`: a page's file is named after its path, `/` is stored
117
+ * as `index`, and `blog/index` reads back as `/blog`, so `/index` would be the
118
+ * home page's file and `/blog/index` a second page at `/blog`.
119
+ */
120
+ export declare function normalizeAndValidatePathname(input: string | undefined | null): PathnameValidationResult;
121
+ /**
122
+ * Generate a content ID in the standard format
123
+ * IDs are prefixed with "vx-" followed by 8 random characters
124
+ */
125
+ export declare function generateContentId(): string;
126
+ /**
127
+ * Get the current date/time in ISO format
128
+ * Used for timestamps in content files
129
+ */
130
+ export declare function getCurrentISODate(): string;
131
+ /**
132
+ * Parse a date string safely
133
+ * Returns null if invalid
134
+ */
135
+ export declare function parseDate(dateStr: string | undefined): Date | null;
136
+ /**
137
+ * Creates a V8-optimized object by mapping site names to values.
138
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
139
+ *
140
+ * @param sitesConfig - Sites configuration containing site names
141
+ * @param factory - Function that creates the value for each site
142
+ * @returns Object with all sites initialized in alphabetical order
143
+ */
144
+ export declare function mapSiteNames<T>(sitesConfig: {
145
+ sites: Record<string, any>;
146
+ }, factory: (siteName: string) => T): Record<string, T>;
147
+ /**
148
+ * Creates a V8-optimized object by mapping locale names to values.
149
+ * Ensures all objects have the same hidden class by adding properties in consistent order.
150
+ *
151
+ * @param locales - Array of locale codes
152
+ * @param factory - Function that creates the value for each locale
153
+ * @returns Object with all locales initialized in array order
154
+ */
155
+ export declare function mapLocales<T>(locales: string[], factory: (locale: string) => T): Record<string, T>;
156
+ /**
157
+ * Resolves a publish date value to a valid string or undefined.
158
+ * Handles various input types including null, false, and empty strings.
159
+ *
160
+ * @param updateValue - The value being updated (string | null | false | undefined)
161
+ * @param currentValue - The current value to fall back to if updateValue is undefined
162
+ * @returns A valid date string or undefined
163
+ */
164
+ export declare function resolvePublishDate(updateValue: string | null | false | undefined, currentValue: string | undefined): string | undefined;
165
+ /**
166
+ * Serializes MDX content with frontmatter.
167
+ * This is used by both FileSystemContentAPI and InMemoryContentAPI to ensure
168
+ * consistent MDX output that includes frontmatter for variable access.
169
+ *
170
+ * @param frontmatterData - The frontmatter data to serialize
171
+ * @param mdxContent - The MDX content (without frontmatter)
172
+ * @returns Complete MDX file content with frontmatter
173
+ */
174
+ export declare function serializeMdxWithFrontmatter(frontmatterData: Record<string, any>, mdxContent: string): string;
175
+ //# sourceMappingURL=content-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-utils.d.ts","sourceRoot":"","sources":["../src/content-utils.ts"],"names":[],"mappings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