@lupinum/ginko-content 0.1.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 (512) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/compatibility.json +27 -0
  4. package/dist/cli.d.mts +1 -0
  5. package/dist/cli.mjs +690 -0
  6. package/dist/cms-contract/build +1 -0
  7. package/dist/cms-contract/build.d.ts +44 -0
  8. package/dist/cms-contract/build.js +513 -0
  9. package/dist/cms-contract/index +1 -0
  10. package/dist/cms-contract/index.d.ts +25 -0
  11. package/dist/cms-contract/index.js +37 -0
  12. package/dist/cms-contract/mdc +1 -0
  13. package/dist/cms-contract/mdc.d.ts +32 -0
  14. package/dist/cms-contract/mdc.js +52 -0
  15. package/dist/cms-contract/path +1 -0
  16. package/dist/cms-contract/path.d.ts +12 -0
  17. package/dist/cms-contract/path.js +18 -0
  18. package/dist/cms-contract/schema +1 -0
  19. package/dist/cms-contract/schema.d.ts +18 -0
  20. package/dist/cms-contract/schema.js +13 -0
  21. package/dist/cms-contract/types +1 -0
  22. package/dist/cms-contract/types.d.ts +177 -0
  23. package/dist/cms-contract/types.js +0 -0
  24. package/dist/cms-import/index +1 -0
  25. package/dist/cms-import/index.d.ts +21 -0
  26. package/dist/cms-import/index.js +57 -0
  27. package/dist/config.d.mts +3 -0
  28. package/dist/config.mjs +3 -0
  29. package/dist/core/cache +1 -0
  30. package/dist/core/cache-hints +1 -0
  31. package/dist/core/cache-hints.d.ts +3 -0
  32. package/dist/core/cache-hints.js +55 -0
  33. package/dist/core/cache.d.ts +29 -0
  34. package/dist/core/cache.js +0 -0
  35. package/dist/core/content/collection +1 -0
  36. package/dist/core/content/collection.d.ts +3 -0
  37. package/dist/core/content/collection.js +52 -0
  38. package/dist/core/content/graph +1 -0
  39. package/dist/core/content/graph.d.ts +147 -0
  40. package/dist/core/content/graph.js +189 -0
  41. package/dist/core/content/ignore +1 -0
  42. package/dist/core/content/ignore.d.ts +5 -0
  43. package/dist/core/content/ignore.js +10 -0
  44. package/dist/core/content/locale +1 -0
  45. package/dist/core/content/locale.d.ts +61 -0
  46. package/dist/core/content/locale.js +77 -0
  47. package/dist/core/content/path +1 -0
  48. package/dist/core/content/path.d.ts +36 -0
  49. package/dist/core/content/path.js +143 -0
  50. package/dist/core/content/slug +1 -0
  51. package/dist/core/content/slug.d.ts +4 -0
  52. package/dist/core/content/slug.js +41 -0
  53. package/dist/core/content/sources +1 -0
  54. package/dist/core/content/sources.d.ts +2 -0
  55. package/dist/core/content/sources.js +6 -0
  56. package/dist/core/errors +1 -0
  57. package/dist/core/errors.d.ts +15 -0
  58. package/dist/core/errors.js +10 -0
  59. package/dist/core/markdown/tree +1 -0
  60. package/dist/core/markdown/tree.d.ts +9 -0
  61. package/dist/core/markdown/tree.js +47 -0
  62. package/dist/core/query/builder +1 -0
  63. package/dist/core/query/builder.d.ts +18 -0
  64. package/dist/core/query/builder.js +186 -0
  65. package/dist/core/query/execute +1 -0
  66. package/dist/core/query/execute.d.ts +52 -0
  67. package/dist/core/query/execute.js +304 -0
  68. package/dist/core/query/filter +1 -0
  69. package/dist/core/query/filter.d.ts +42 -0
  70. package/dist/core/query/filter.js +118 -0
  71. package/dist/core/query/json +1 -0
  72. package/dist/core/query/json.d.ts +2 -0
  73. package/dist/core/query/json.js +20 -0
  74. package/dist/core/query/lower +1 -0
  75. package/dist/core/query/lower.d.ts +14 -0
  76. package/dist/core/query/lower.js +121 -0
  77. package/dist/core/query/operators +1 -0
  78. package/dist/core/query/operators.d.ts +23 -0
  79. package/dist/core/query/operators.js +126 -0
  80. package/dist/core/query/params +1 -0
  81. package/dist/core/query/params.d.ts +15 -0
  82. package/dist/core/query/params.js +83 -0
  83. package/dist/core/query/plan +1 -0
  84. package/dist/core/query/plan.d.ts +110 -0
  85. package/dist/core/query/plan.js +0 -0
  86. package/dist/core/references/resolve +1 -0
  87. package/dist/core/references/resolve.d.ts +31 -0
  88. package/dist/core/references/resolve.js +121 -0
  89. package/dist/core/references/schema +1 -0
  90. package/dist/core/references/schema.d.ts +8 -0
  91. package/dist/core/references/schema.js +70 -0
  92. package/dist/core/result +1 -0
  93. package/dist/core/result.d.ts +27 -0
  94. package/dist/core/result.js +2 -0
  95. package/dist/features/collections/resolve +1 -0
  96. package/dist/features/collections/resolve.d.ts +63 -0
  97. package/dist/features/collections/resolve.js +76 -0
  98. package/dist/features/localization/config +1 -0
  99. package/dist/features/localization/config.d.ts +18 -0
  100. package/dist/features/localization/config.js +25 -0
  101. package/dist/features/localization/links +1 -0
  102. package/dist/features/localization/links.d.ts +1 -0
  103. package/dist/features/localization/links.js +69 -0
  104. package/dist/features/localization/path +1 -0
  105. package/dist/features/localization/path.d.ts +32 -0
  106. package/dist/features/localization/path.js +80 -0
  107. package/dist/features/localization/results +1 -0
  108. package/dist/features/localization/results.d.ts +42 -0
  109. package/dist/features/localization/results.js +149 -0
  110. package/dist/features/localization/translated-slugs +1 -0
  111. package/dist/features/localization/translated-slugs.d.ts +11 -0
  112. package/dist/features/localization/translated-slugs.js +80 -0
  113. package/dist/features/navigation/build +1 -0
  114. package/dist/features/navigation/build.d.ts +28 -0
  115. package/dist/features/navigation/build.js +104 -0
  116. package/dist/features/navigation/canonical +1 -0
  117. package/dist/features/navigation/canonical.d.ts +33 -0
  118. package/dist/features/navigation/canonical.js +149 -0
  119. package/dist/features/navigation/query +1 -0
  120. package/dist/features/navigation/query.d.ts +19 -0
  121. package/dist/features/navigation/query.js +51 -0
  122. package/dist/features/navigation/resolve +1 -0
  123. package/dist/features/navigation/resolve.d.ts +20 -0
  124. package/dist/features/navigation/resolve.js +79 -0
  125. package/dist/features/navigation/tree +1 -0
  126. package/dist/features/navigation/tree.d.ts +6 -0
  127. package/dist/features/navigation/tree.js +32 -0
  128. package/dist/features/search/navigation +1 -0
  129. package/dist/features/search/navigation.d.ts +6 -0
  130. package/dist/features/search/navigation.js +21 -0
  131. package/dist/features/search/sections +1 -0
  132. package/dist/features/search/sections.d.ts +21 -0
  133. package/dist/features/search/sections.js +98 -0
  134. package/dist/features/sitemap/query +1 -0
  135. package/dist/features/sitemap/query.d.ts +68 -0
  136. package/dist/features/sitemap/query.js +171 -0
  137. package/dist/integrations/nitro/context +1 -0
  138. package/dist/integrations/nitro/context.d.ts +63 -0
  139. package/dist/integrations/nitro/context.js +28 -0
  140. package/dist/integrations/nitro/ingest +1 -0
  141. package/dist/integrations/nitro/ingest.d.ts +18 -0
  142. package/dist/integrations/nitro/ingest.js +120 -0
  143. package/dist/integrations/nitro/preview +1 -0
  144. package/dist/integrations/nitro/preview.d.ts +5 -0
  145. package/dist/integrations/nitro/preview.js +21 -0
  146. package/dist/integrations/nitro/runtime-config +1 -0
  147. package/dist/integrations/nitro/runtime-config.d.ts +1 -0
  148. package/dist/integrations/nitro/runtime-config.js +4 -0
  149. package/dist/integrations/nitro/storage +1 -0
  150. package/dist/integrations/nitro/storage.d.ts +9 -0
  151. package/dist/integrations/nitro/storage.js +113 -0
  152. package/dist/integrations/vue/content-components +1 -0
  153. package/dist/integrations/vue/content-components.d.ts +24 -0
  154. package/dist/integrations/vue/content-components.js +67 -0
  155. package/dist/integrations/vue/html-tags +1 -0
  156. package/dist/integrations/vue/html-tags.d.ts +2 -0
  157. package/dist/integrations/vue/html-tags.js +119 -0
  158. package/dist/integrations/vue/markdown-refs +1 -0
  159. package/dist/integrations/vue/markdown-refs.d.ts +1 -0
  160. package/dist/integrations/vue/markdown-refs.js +1 -0
  161. package/dist/module.d.mts +2044 -0
  162. package/dist/module.json +12 -0
  163. package/dist/module.mjs +1381 -0
  164. package/dist/parsers/csv +1 -0
  165. package/dist/parsers/csv.d.ts +2 -0
  166. package/dist/parsers/csv.js +38 -0
  167. package/dist/parsers/from-csv +1 -0
  168. package/dist/parsers/from-csv.d.ts +20 -0
  169. package/dist/parsers/from-csv.js +85 -0
  170. package/dist/parsers/index +1 -0
  171. package/dist/parsers/index.d.ts +10 -0
  172. package/dist/parsers/index.js +50 -0
  173. package/dist/parsers/json +1 -0
  174. package/dist/parsers/json.d.ts +2 -0
  175. package/dist/parsers/json.js +29 -0
  176. package/dist/parsers/markdown +1 -0
  177. package/dist/parsers/markdown-plugins +1 -0
  178. package/dist/parsers/markdown-plugins.d.ts +3 -0
  179. package/dist/parsers/markdown-plugins.js +58 -0
  180. package/dist/parsers/markdown.d.ts +2 -0
  181. package/dist/parsers/markdown.js +64 -0
  182. package/dist/parsers/path-meta +1 -0
  183. package/dist/parsers/path-meta.d.ts +4 -0
  184. package/dist/parsers/path-meta.js +37 -0
  185. package/dist/parsers/utils +1 -0
  186. package/dist/parsers/utils.d.ts +2 -0
  187. package/dist/parsers/utils.js +3 -0
  188. package/dist/parsers/yaml +1 -0
  189. package/dist/parsers/yaml.d.ts +2 -0
  190. package/dist/parsers/yaml.js +19 -0
  191. package/dist/public/client +1 -0
  192. package/dist/public/client.d.ts +19 -0
  193. package/dist/public/client.js +26 -0
  194. package/dist/public/provider +1 -0
  195. package/dist/public/provider-errors +1 -0
  196. package/dist/public/provider-errors.d.ts +4 -0
  197. package/dist/public/provider-errors.js +28 -0
  198. package/dist/public/provider.d.ts +74 -0
  199. package/dist/public/provider.js +6 -0
  200. package/dist/public/server +1 -0
  201. package/dist/public/server.d.ts +19 -0
  202. package/dist/public/server.js +28 -0
  203. package/dist/runtime/app/components/ContentRenderer.d.vue.ts +62 -0
  204. package/dist/runtime/app/components/ContentRenderer.vue +84 -0
  205. package/dist/runtime/app/components/ContentRenderer.vue.d.ts +62 -0
  206. package/dist/runtime/app/components/ContentRendererInline.d.vue.ts +50 -0
  207. package/dist/runtime/app/components/ContentRendererInline.vue +97 -0
  208. package/dist/runtime/app/components/ContentRendererInline.vue.d.ts +50 -0
  209. package/dist/runtime/app/components/Prose/ProseCode.d.vue.ts +61 -0
  210. package/dist/runtime/app/components/Prose/ProseCode.vue +32 -0
  211. package/dist/runtime/app/components/Prose/ProseCode.vue.d.ts +61 -0
  212. package/dist/runtime/app/components/Prose/ProseCodeInline.d.vue.ts +13 -0
  213. package/dist/runtime/app/components/Prose/ProseCodeInline.vue +3 -0
  214. package/dist/runtime/app/components/Prose/ProseCodeInline.vue.d.ts +13 -0
  215. package/dist/runtime/app/components/Prose/ProseImg.d.vue.ts +59 -0
  216. package/dist/runtime/app/components/Prose/ProseImg.vue +59 -0
  217. package/dist/runtime/app/components/Prose/ProseImg.vue.d.ts +59 -0
  218. package/dist/runtime/app/components/Prose/ProsePre.d.vue.ts +79 -0
  219. package/dist/runtime/app/components/Prose/ProsePre.vue +42 -0
  220. package/dist/runtime/app/components/Prose/ProsePre.vue.d.ts +79 -0
  221. package/dist/runtime/app/components/internal/ContentRendererMarkdown.d.vue.ts +68 -0
  222. package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue +99 -0
  223. package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue.d.ts +68 -0
  224. package/dist/runtime/app/components/internal/MarkdownRenderer +1 -0
  225. package/dist/runtime/app/components/internal/MarkdownRenderer.d.ts +90 -0
  226. package/dist/runtime/app/components/internal/MarkdownRenderer.js +191 -0
  227. package/dist/runtime/app/composables/async-data +1 -0
  228. package/dist/runtime/app/composables/async-data.d.ts +2 -0
  229. package/dist/runtime/app/composables/async-data.js +4 -0
  230. package/dist/runtime/app/composables/content-i18n +1 -0
  231. package/dist/runtime/app/composables/content-i18n.d.ts +5 -0
  232. package/dist/runtime/app/composables/content-i18n.js +1 -0
  233. package/dist/runtime/app/composables/head +1 -0
  234. package/dist/runtime/app/composables/head.d.ts +11 -0
  235. package/dist/runtime/app/composables/head.js +98 -0
  236. package/dist/runtime/app/composables/locale +1 -0
  237. package/dist/runtime/app/composables/locale-context +1 -0
  238. package/dist/runtime/app/composables/locale-context.d.ts +5 -0
  239. package/dist/runtime/app/composables/locale-context.js +8 -0
  240. package/dist/runtime/app/composables/locale.d.ts +8 -0
  241. package/dist/runtime/app/composables/locale.js +15 -0
  242. package/dist/runtime/app/composables/navigation +1 -0
  243. package/dist/runtime/app/composables/navigation.d.ts +3 -0
  244. package/dist/runtime/app/composables/navigation.js +7 -0
  245. package/dist/runtime/app/composables/preview +1 -0
  246. package/dist/runtime/app/composables/preview.d.ts +5 -0
  247. package/dist/runtime/app/composables/preview.js +52 -0
  248. package/dist/runtime/app/composables/query-api +1 -0
  249. package/dist/runtime/app/composables/query-api.d.ts +27 -0
  250. package/dist/runtime/app/composables/query-api.js +46 -0
  251. package/dist/runtime/app/composables/route +1 -0
  252. package/dist/runtime/app/composables/route.d.ts +11 -0
  253. package/dist/runtime/app/composables/route.js +150 -0
  254. package/dist/runtime/app/composables/runtime +1 -0
  255. package/dist/runtime/app/composables/runtime.d.ts +2 -0
  256. package/dist/runtime/app/composables/runtime.js +7 -0
  257. package/dist/runtime/app/composables/search +1 -0
  258. package/dist/runtime/app/composables/search.d.ts +58 -0
  259. package/dist/runtime/app/composables/search.js +321 -0
  260. package/dist/runtime/app/composables/site-data +1 -0
  261. package/dist/runtime/app/composables/site-data.d.ts +12 -0
  262. package/dist/runtime/app/composables/site-data.js +12 -0
  263. package/dist/runtime/app/composables/toc +1 -0
  264. package/dist/runtime/app/composables/toc.d.ts +10 -0
  265. package/dist/runtime/app/composables/toc.js +31 -0
  266. package/dist/runtime/app/composables/use-content +1 -0
  267. package/dist/runtime/app/composables/use-content.d.ts +188 -0
  268. package/dist/runtime/app/composables/use-content.js +307 -0
  269. package/dist/runtime/app/composables/useUnwrap +1 -0
  270. package/dist/runtime/app/composables/useUnwrap.d.ts +8 -0
  271. package/dist/runtime/app/composables/useUnwrap.js +35 -0
  272. package/dist/runtime/app/composables/utils +1 -0
  273. package/dist/runtime/app/composables/utils.d.ts +22 -0
  274. package/dist/runtime/app/composables/utils.js +76 -0
  275. package/dist/runtime/app/composables/web-socket +1 -0
  276. package/dist/runtime/app/composables/web-socket.d.ts +3 -0
  277. package/dist/runtime/app/composables/web-socket.js +65 -0
  278. package/dist/runtime/app/pages/content.d.vue.ts +3 -0
  279. package/dist/runtime/app/pages/content.vue +14 -0
  280. package/dist/runtime/app/pages/content.vue.d.ts +3 -0
  281. package/dist/runtime/app/plugins/markdown-components +1 -0
  282. package/dist/runtime/app/plugins/markdown-components.d.ts +2 -0
  283. package/dist/runtime/app/plugins/markdown-components.js +19 -0
  284. package/dist/runtime/app/plugins/ws +1 -0
  285. package/dist/runtime/app/plugins/ws.d.ts +2 -0
  286. package/dist/runtime/app/plugins/ws.js +7 -0
  287. package/dist/runtime/app.d.vue.ts +3 -0
  288. package/dist/runtime/app.vue +3 -0
  289. package/dist/runtime/app.vue.d.ts +3 -0
  290. package/dist/runtime/markdown/plugins +1 -0
  291. package/dist/runtime/markdown/plugins.d.ts +3 -0
  292. package/dist/runtime/markdown/plugins.js +39 -0
  293. package/dist/runtime/query/public-limits +1 -0
  294. package/dist/runtime/query/public-limits.d.ts +2 -0
  295. package/dist/runtime/query/public-limits.js +2 -0
  296. package/dist/runtime/query/resolve +1 -0
  297. package/dist/runtime/query/resolve.d.ts +5 -0
  298. package/dist/runtime/query/resolve.js +9 -0
  299. package/dist/runtime/query/routes +1 -0
  300. package/dist/runtime/query/routes.d.ts +33 -0
  301. package/dist/runtime/query/routes.js +21 -0
  302. package/dist/runtime/query/unified +1 -0
  303. package/dist/runtime/query/unified.d.ts +94 -0
  304. package/dist/runtime/query/unified.js +473 -0
  305. package/dist/runtime/server/api/cache +1 -0
  306. package/dist/runtime/server/api/cache.d.ts +8 -0
  307. package/dist/runtime/server/api/cache.js +26 -0
  308. package/dist/runtime/server/api/locales +1 -0
  309. package/dist/runtime/server/api/locales.d.ts +6 -0
  310. package/dist/runtime/server/api/locales.js +28 -0
  311. package/dist/runtime/server/api/navigation +1 -0
  312. package/dist/runtime/server/api/navigation.d.ts +2 -0
  313. package/dist/runtime/server/api/navigation.js +21 -0
  314. package/dist/runtime/server/api/query +1 -0
  315. package/dist/runtime/server/api/query.d.ts +2 -0
  316. package/dist/runtime/server/api/query.js +6 -0
  317. package/dist/runtime/server/api/revalidate +1 -0
  318. package/dist/runtime/server/api/revalidate.d.ts +6 -0
  319. package/dist/runtime/server/api/revalidate.js +156 -0
  320. package/dist/runtime/server/api/search +1 -0
  321. package/dist/runtime/server/api/search-index +1 -0
  322. package/dist/runtime/server/api/search-index.d.ts +2 -0
  323. package/dist/runtime/server/api/search-index.js +20 -0
  324. package/dist/runtime/server/api/search.d.ts +2 -0
  325. package/dist/runtime/server/api/search.js +40 -0
  326. package/dist/runtime/server/api/site-data +1 -0
  327. package/dist/runtime/server/api/site-data.d.ts +2 -0
  328. package/dist/runtime/server/api/site-data.js +22 -0
  329. package/dist/runtime/server/api/sitemap +1 -0
  330. package/dist/runtime/server/api/sitemap.d.ts +2 -0
  331. package/dist/runtime/server/api/sitemap.js +11 -0
  332. package/dist/runtime/server/cache-adapter +1 -0
  333. package/dist/runtime/server/cache-adapter.d.ts +2 -0
  334. package/dist/runtime/server/cache-adapter.js +11 -0
  335. package/dist/runtime/server/cache-adapters +1 -0
  336. package/dist/runtime/server/cache-adapters.d.ts +9 -0
  337. package/dist/runtime/server/cache-adapters.js +50 -0
  338. package/dist/runtime/server/cache-hints +1 -0
  339. package/dist/runtime/server/cache-hints.d.ts +5 -0
  340. package/dist/runtime/server/cache-hints.js +17 -0
  341. package/dist/runtime/server/collection-helpers +1 -0
  342. package/dist/runtime/server/collection-helpers.d.ts +13 -0
  343. package/dist/runtime/server/collection-helpers.js +99 -0
  344. package/dist/runtime/server/index +1 -0
  345. package/dist/runtime/server/index.d.ts +9 -0
  346. package/dist/runtime/server/index.js +15 -0
  347. package/dist/runtime/server/manifest +1 -0
  348. package/dist/runtime/server/manifest.d.ts +1 -0
  349. package/dist/runtime/server/manifest.js +1 -0
  350. package/dist/runtime/server/navigation +1 -0
  351. package/dist/runtime/server/navigation-query +1 -0
  352. package/dist/runtime/server/navigation-query.d.ts +4 -0
  353. package/dist/runtime/server/navigation-query.js +80 -0
  354. package/dist/runtime/server/navigation.d.ts +2 -0
  355. package/dist/runtime/server/navigation.js +9 -0
  356. package/dist/runtime/server/pagefind +1 -0
  357. package/dist/runtime/server/pagefind.d.ts +2 -0
  358. package/dist/runtime/server/pagefind.js +30 -0
  359. package/dist/runtime/server/plugins/cache +1 -0
  360. package/dist/runtime/server/plugins/cache.d.ts +2 -0
  361. package/dist/runtime/server/plugins/cache.js +17 -0
  362. package/dist/runtime/server/plugins/sitemap +1 -0
  363. package/dist/runtime/server/plugins/sitemap.d.ts +2 -0
  364. package/dist/runtime/server/plugins/sitemap.js +25 -0
  365. package/dist/runtime/server/preview +1 -0
  366. package/dist/runtime/server/preview.d.ts +1 -0
  367. package/dist/runtime/server/preview.js +1 -0
  368. package/dist/runtime/server/provider-query +1 -0
  369. package/dist/runtime/server/provider-query.d.ts +27 -0
  370. package/dist/runtime/server/provider-query.js +131 -0
  371. package/dist/runtime/server/provider-result +1 -0
  372. package/dist/runtime/server/provider-result.d.ts +10 -0
  373. package/dist/runtime/server/provider-result.js +30 -0
  374. package/dist/runtime/server/providers/filesystem +1 -0
  375. package/dist/runtime/server/providers/filesystem.d.ts +2 -0
  376. package/dist/runtime/server/providers/filesystem.js +47 -0
  377. package/dist/runtime/server/providers/index +1 -0
  378. package/dist/runtime/server/providers/index.d.ts +3 -0
  379. package/dist/runtime/server/providers/index.js +190 -0
  380. package/dist/runtime/server/query-api +1 -0
  381. package/dist/runtime/server/query-api.d.ts +28 -0
  382. package/dist/runtime/server/query-api.js +54 -0
  383. package/dist/runtime/server/query-executor +1 -0
  384. package/dist/runtime/server/query-executor.d.ts +4 -0
  385. package/dist/runtime/server/query-executor.js +121 -0
  386. package/dist/runtime/server/runtime-config +1 -0
  387. package/dist/runtime/server/runtime-config.d.ts +1 -0
  388. package/dist/runtime/server/runtime-config.js +1 -0
  389. package/dist/runtime/server/search +1 -0
  390. package/dist/runtime/server/search.d.ts +18 -0
  391. package/dist/runtime/server/search.js +134 -0
  392. package/dist/runtime/server/sitemap +1 -0
  393. package/dist/runtime/server/sitemap-provider +1 -0
  394. package/dist/runtime/server/sitemap-provider.d.ts +10 -0
  395. package/dist/runtime/server/sitemap-provider.js +11 -0
  396. package/dist/runtime/server/sitemap.d.ts +6 -0
  397. package/dist/runtime/server/sitemap.js +45 -0
  398. package/dist/runtime/server/storage +1 -0
  399. package/dist/runtime/server/storage-access +1 -0
  400. package/dist/runtime/server/storage-access.d.ts +1 -0
  401. package/dist/runtime/server/storage-access.js +9 -0
  402. package/dist/runtime/server/storage.d.ts +2 -0
  403. package/dist/runtime/server/storage.js +2 -0
  404. package/dist/runtime/server/validation +1 -0
  405. package/dist/runtime/server/validation.d.ts +1 -0
  406. package/dist/runtime/server/validation.js +6 -0
  407. package/dist/runtime/shared/search +1 -0
  408. package/dist/runtime/shared/search.d.ts +2 -0
  409. package/dist/runtime/shared/search.js +89 -0
  410. package/dist/runtime/transformers/component-resolver +1 -0
  411. package/dist/runtime/transformers/component-resolver.d.ts +10 -0
  412. package/dist/runtime/transformers/component-resolver.js +30 -0
  413. package/dist/runtime/transformers/csv/from-csv +1 -0
  414. package/dist/runtime/transformers/csv/from-csv.d.ts +1 -0
  415. package/dist/runtime/transformers/csv/from-csv.js +1 -0
  416. package/dist/runtime/transformers/csv/index +1 -0
  417. package/dist/runtime/transformers/csv/index.d.ts +1 -0
  418. package/dist/runtime/transformers/csv/index.js +1 -0
  419. package/dist/runtime/transformers/define +1 -0
  420. package/dist/runtime/transformers/define.d.ts +1 -0
  421. package/dist/runtime/transformers/define.js +1 -0
  422. package/dist/runtime/transformers/index +1 -0
  423. package/dist/runtime/transformers/index.d.ts +1 -0
  424. package/dist/runtime/transformers/index.js +1 -0
  425. package/dist/runtime/transformers/json +1 -0
  426. package/dist/runtime/transformers/json.d.ts +1 -0
  427. package/dist/runtime/transformers/json.js +1 -0
  428. package/dist/runtime/transformers/markdown +1 -0
  429. package/dist/runtime/transformers/markdown.d.ts +1 -0
  430. package/dist/runtime/transformers/markdown.js +1 -0
  431. package/dist/runtime/transformers/path-meta +1 -0
  432. package/dist/runtime/transformers/path-meta.d.ts +2 -0
  433. package/dist/runtime/transformers/path-meta.js +2 -0
  434. package/dist/runtime/transformers/utils +1 -0
  435. package/dist/runtime/transformers/utils.d.ts +1 -0
  436. package/dist/runtime/transformers/utils.js +1 -0
  437. package/dist/runtime/transformers/yaml +1 -0
  438. package/dist/runtime/transformers/yaml.d.ts +1 -0
  439. package/dist/runtime/transformers/yaml.js +1 -0
  440. package/dist/runtime/utils/content-components +1 -0
  441. package/dist/runtime/utils/content-components.d.ts +9 -0
  442. package/dist/runtime/utils/content-components.js +16 -0
  443. package/dist/runtime/utils/query +1 -0
  444. package/dist/runtime/utils/query.d.ts +5 -0
  445. package/dist/runtime/utils/query.js +18 -0
  446. package/dist/runtime/virtual/transformers.d.ts +4 -0
  447. package/dist/runtime/virtual.d.ts +7 -0
  448. package/dist/storage/cache +1 -0
  449. package/dist/storage/cache.d.ts +32 -0
  450. package/dist/storage/cache.js +42 -0
  451. package/dist/storage/content +1 -0
  452. package/dist/storage/content.d.ts +41 -0
  453. package/dist/storage/content.js +86 -0
  454. package/dist/storage/contents +1 -0
  455. package/dist/storage/contents.d.ts +5 -0
  456. package/dist/storage/contents.js +116 -0
  457. package/dist/storage/driver +1 -0
  458. package/dist/storage/driver.d.ts +28 -0
  459. package/dist/storage/driver.js +22 -0
  460. package/dist/storage/graph +1 -0
  461. package/dist/storage/graph.d.ts +3 -0
  462. package/dist/storage/graph.js +14 -0
  463. package/dist/storage/manifest +1 -0
  464. package/dist/storage/manifest.d.ts +18 -0
  465. package/dist/storage/manifest.js +68 -0
  466. package/dist/storage/references +1 -0
  467. package/dist/storage/references.d.ts +13 -0
  468. package/dist/storage/references.js +78 -0
  469. package/dist/storage/validation +1 -0
  470. package/dist/storage/validation.d.ts +46 -0
  471. package/dist/storage/validation.js +341 -0
  472. package/dist/testing/provider-contract +1 -0
  473. package/dist/testing/provider-contract.d.ts +31 -0
  474. package/dist/testing/provider-contract.js +237 -0
  475. package/dist/testing/provider-fixture +1 -0
  476. package/dist/testing/provider-fixture.d.ts +65 -0
  477. package/dist/testing/provider-fixture.js +606 -0
  478. package/dist/types/api +1 -0
  479. package/dist/types/api.d.ts +47 -0
  480. package/dist/types/api.js +1 -0
  481. package/dist/types/config +1 -0
  482. package/dist/types/config.d.ts +281 -0
  483. package/dist/types/config.js +28 -0
  484. package/dist/types/content +1 -0
  485. package/dist/types/content.d.ts +311 -0
  486. package/dist/types/content.js +1 -0
  487. package/dist/types/fields +1 -0
  488. package/dist/types/fields.d.ts +81 -0
  489. package/dist/types/fields.js +146 -0
  490. package/dist/types/index +1 -0
  491. package/dist/types/index.d.ts +6 -0
  492. package/dist/types/index.js +6 -0
  493. package/dist/types/module +1 -0
  494. package/dist/types/module.d.ts +428 -0
  495. package/dist/types/module.js +0 -0
  496. package/dist/types/picomatch.d.ts +8 -0
  497. package/dist/types/query +1 -0
  498. package/dist/types/query.d.ts +862 -0
  499. package/dist/types/query.js +1 -0
  500. package/dist/types/reference +1 -0
  501. package/dist/types/reference.d.ts +1 -0
  502. package/dist/types/reference.js +1 -0
  503. package/dist/types/runtime +1 -0
  504. package/dist/types/runtime.d.ts +45 -0
  505. package/dist/types/runtime.js +1 -0
  506. package/dist/types/search +1 -0
  507. package/dist/types/search.d.ts +64 -0
  508. package/dist/types/search.js +0 -0
  509. package/dist/types/virtual.d.ts +19 -0
  510. package/dist/types.d.mts +11 -0
  511. package/dist/web-types.json +466 -0
  512. package/package.json +135 -0
@@ -0,0 +1,304 @@
1
+ import { resolveGraphCanonicalKey, resolveGraphRouteVariant, resolveGraphVariant, resolveLocaleChain, selectGraphDocuments } from "../content/graph.js";
2
+ import { apply, ensureArray, get, omit, sortList, withKeys, withoutKeys } from "./operators.js";
3
+ import { normalizeRouteMounts, routeToContentPathCandidates } from "../content/path.js";
4
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ const includesEntry = (haystack, entry) => typeof haystack === "string" ? haystack.includes(String(entry)) : haystack.includes(entry);
6
+ const compareOperators = {
7
+ eq: (item, value) => value instanceof RegExp ? value.test(String(item)) : item === value,
8
+ ne: (item, value) => value instanceof RegExp ? !value.test(String(item)) : item !== value,
9
+ gt: (item, value) => item > value,
10
+ gte: (item, value) => item >= value,
11
+ lt: (item, value) => item < value,
12
+ lte: (item, value) => item <= value,
13
+ in: (item, value) => ensureArray(value).some((entry) => Array.isArray(item) ? item.includes(entry) : compareOperators.eq(item, entry)),
14
+ contains: (item, value) => {
15
+ const haystack = Array.isArray(item) ? item : String(item);
16
+ return ensureArray(value).every((entry) => includesEntry(haystack, entry));
17
+ },
18
+ containsAny: (item, value) => {
19
+ const haystack = Array.isArray(item) ? item : String(item);
20
+ return ensureArray(value).some((entry) => includesEntry(haystack, entry));
21
+ },
22
+ icontains: (item, value) => {
23
+ if (typeof value !== "string") {
24
+ throw new TypeError("$icontains requires a string condition");
25
+ }
26
+ return String(item).toLocaleLowerCase().includes(value.toLocaleLowerCase());
27
+ },
28
+ exists: (item, value) => value ? typeof item !== "undefined" : typeof item === "undefined",
29
+ type: (item, value) => typeof item === String(value),
30
+ prefix: (item, value) => String(item || "").startsWith(String(value)),
31
+ regex: (item, value) => {
32
+ if (value instanceof RegExp) {
33
+ return value.test(String(item || ""));
34
+ }
35
+ const matched = String(value).match(/\/(.*)\/([dgimsuy]*)$/);
36
+ const regex = matched?.[1] ? new RegExp(matched[1], matched[2] || "") : new RegExp(String(value));
37
+ return regex.test(String(item || ""));
38
+ }
39
+ };
40
+ export const evaluateQueryPlanFilter = (item, filter) => {
41
+ switch (filter.type) {
42
+ case "true":
43
+ return true;
44
+ case "compare":
45
+ return compareOperators[filter.operator](get(item, filter.field), filter.value);
46
+ case "and":
47
+ return filter.clauses.every((clause) => evaluateQueryPlanFilter(item, clause));
48
+ case "or":
49
+ return filter.clauses.some((clause) => evaluateQueryPlanFilter(item, clause));
50
+ case "not":
51
+ return !evaluateQueryPlanFilter(item, filter.clause);
52
+ }
53
+ };
54
+ const collectFieldComparisons = (filter, field) => {
55
+ switch (filter.type) {
56
+ case "true":
57
+ return [];
58
+ case "compare":
59
+ if (filter.field !== field) {
60
+ return [];
61
+ }
62
+ if (filter.operator === "eq" && typeof filter.value === "string") {
63
+ return [filter.value];
64
+ }
65
+ if (filter.operator === "regex" && filter.value instanceof RegExp) {
66
+ return [filter.value];
67
+ }
68
+ if (filter.operator === "regex" && typeof filter.value === "string") {
69
+ return [new RegExp(filter.value)];
70
+ }
71
+ if (filter.operator === "prefix" && typeof filter.value === "string") {
72
+ return [new RegExp(`^${escapeRegExp(filter.value)}`)];
73
+ }
74
+ return [];
75
+ case "and":
76
+ return filter.clauses.flatMap((clause) => collectFieldComparisons(clause, field));
77
+ case "or":
78
+ case "not":
79
+ return [];
80
+ }
81
+ };
82
+ const applyQueryPlanSort = (matched, plan) => {
83
+ for (const clause of [...plan.sort].reverse()) {
84
+ sortList(matched, {
85
+ [clause.field]: clause.direction,
86
+ ...clause.locale ? { $locale: clause.locale } : {},
87
+ ...typeof clause.numeric === "boolean" ? { $numeric: clause.numeric } : {},
88
+ ...clause.caseFirst ? { $caseFirst: clause.caseFirst } : {},
89
+ ...clause.sensitivity ? { $sensitivity: clause.sensitivity } : {}
90
+ });
91
+ }
92
+ };
93
+ export const applyQueryPlanProjection = (items, plan) => {
94
+ return apply(withKeys(plan.projection.only))(apply(withoutKeys(plan.projection.without))(items));
95
+ };
96
+ export const finalizeQueryPlanResponse = (matched, plan) => {
97
+ if (plan.mode === "count") {
98
+ return {
99
+ result: matched.length
100
+ };
101
+ }
102
+ const skipped = plan.skip ? matched.slice(plan.skip) : matched;
103
+ const limited = typeof plan.limit === "number" ? skipped.slice(0, plan.limit) : skipped;
104
+ const projected = applyQueryPlanProjection(limited, plan);
105
+ if (plan.mode === "first") {
106
+ return {
107
+ ...omit(["skip", "limit", "total"])({
108
+ result: projected,
109
+ skip: plan.skip,
110
+ limit: plan.limit || 0,
111
+ total: matched.length
112
+ }),
113
+ result: projected[0]
114
+ };
115
+ }
116
+ return {
117
+ result: projected,
118
+ skip: plan.skip,
119
+ limit: plan.limit || 0,
120
+ total: matched.length
121
+ };
122
+ };
123
+ const findDirConfig = (graph, path, locale) => {
124
+ if (!path) {
125
+ return null;
126
+ }
127
+ const byLocale = graph.byNavigationPath[path];
128
+ if (!byLocale) {
129
+ return null;
130
+ }
131
+ if (locale && byLocale[locale]) {
132
+ return byLocale[locale];
133
+ }
134
+ return Object.values(byLocale)[0] || null;
135
+ };
136
+ const withDirConfig = (content, dirConfig) => {
137
+ if (!content || !dirConfig) {
138
+ return content;
139
+ }
140
+ return {
141
+ ...content,
142
+ _dir: {
143
+ ...dirConfig,
144
+ ...dirConfig.body
145
+ }
146
+ };
147
+ };
148
+ export const executeQueryPlanOnDocuments = (documents, plan) => {
149
+ const matched = documents.filter((item) => !plan.collection || item?._collection === plan.collection).filter((item) => evaluateQueryPlanFilter(item, plan.filter)).map((item) => ({ ...item }));
150
+ applyQueryPlanSort(matched, plan);
151
+ return finalizeQueryPlanResponse(matched, plan);
152
+ };
153
+ const executeStandardPlan = (graph, plan) => {
154
+ const candidates = selectGraphDocuments(graph, {
155
+ collection: plan.collection,
156
+ paths: collectFieldComparisons(plan.filter, "_path")
157
+ });
158
+ const matched = candidates.filter((item) => evaluateQueryPlanFilter(item, plan.filter)).map((item) => ({ ...item }));
159
+ applyQueryPlanSort(matched, plan);
160
+ return finalizeQueryPlanResponse(matched, plan);
161
+ };
162
+ const executeLocalePlan = (graph, plan, options) => {
163
+ const requestedLocale = plan.resolveLocale?.locale;
164
+ const candidates = selectGraphDocuments(graph, {
165
+ collection: plan.collection,
166
+ paths: collectFieldComparisons(plan.filter, "_path")
167
+ });
168
+ const localeChain = resolveLocaleChain(
169
+ requestedLocale,
170
+ options.defaultLocale,
171
+ requestedLocale ? { [requestedLocale]: plan.resolveLocale?.fallback || options.localeFallback?.[requestedLocale] || [] } : {}
172
+ );
173
+ const localeRank = new Map(localeChain.map((locale, index) => [locale, index]));
174
+ const merged = [];
175
+ const indexByCanonical = /* @__PURE__ */ new Map();
176
+ for (const item of candidates.filter((item2) => evaluateQueryPlanFilter(item2, plan.filter))) {
177
+ if (plan.resolveLocale?.exact && item._locale !== requestedLocale) {
178
+ continue;
179
+ }
180
+ const key = item._canonicalKey || item.id || item._id || item._path;
181
+ const rank = localeRank.get(item._locale || "") ?? Number.MAX_SAFE_INTEGER;
182
+ const availableLocales = item._canonicalKey ? Object.keys(graph.byCanonical[item._canonicalKey] || {}) : [item._locale].filter(Boolean);
183
+ const enriched = {
184
+ ...item,
185
+ _requestedLocale: requestedLocale,
186
+ _resolvedLocale: item._locale,
187
+ _fallback: item._locale !== requestedLocale,
188
+ _availableLocales: availableLocales
189
+ };
190
+ if (!indexByCanonical.has(key)) {
191
+ indexByCanonical.set(key, merged.length);
192
+ merged.push({ rank, item: enriched });
193
+ continue;
194
+ }
195
+ const index = indexByCanonical.get(key);
196
+ if (rank < merged[index].rank) {
197
+ merged[index] = { rank, item: enriched };
198
+ }
199
+ }
200
+ const matched = merged.map((entry) => entry.item);
201
+ applyQueryPlanSort(matched, plan);
202
+ return finalizeQueryPlanResponse(matched, plan);
203
+ };
204
+ const executeVariantPlan = (graph, plan, options) => {
205
+ if (!plan.resolveVariant) {
206
+ return { result: void 0 };
207
+ }
208
+ const collectionConfig = plan.collection ? options.collections?.[plan.collection] : void 0;
209
+ const collectionI18n = collectionConfig?.i18n && typeof collectionConfig.i18n === "object" ? collectionConfig.i18n : void 0;
210
+ const defaultLocale = collectionI18n?.defaultLocale || options.defaultLocale;
211
+ const localeFallback = options.localeFallback;
212
+ const routeMounts = normalizeRouteMounts(collectionConfig?.route, collectionI18n?.locales || [], defaultLocale);
213
+ const variant = plan.resolveVariant.ref ? (() => {
214
+ const canonicalKey = resolveGraphCanonicalKey(graph, plan.resolveVariant.ref, plan.collection);
215
+ if (!canonicalKey) return null;
216
+ return resolveGraphVariant(graph, canonicalKey, plan.resolveVariant.locale, {
217
+ defaultLocale,
218
+ fallback: plan.resolveVariant.fallback,
219
+ exact: plan.resolveVariant.exact,
220
+ localeFallback,
221
+ collection: plan.collection
222
+ });
223
+ })() : plan.resolveVariant.route ? (() => {
224
+ const localeChain = plan.resolveVariant.exact ? plan.resolveVariant.locale ? [plan.resolveVariant.locale] : [] : plan.resolveVariant.fallback?.length ? Array.from(new Set([plan.resolveVariant.locale, ...plan.resolveVariant.fallback].filter(Boolean))) : resolveLocaleChain(plan.resolveVariant.locale, defaultLocale, localeFallback || {});
225
+ const candidateLocales = localeChain.length ? localeChain : [""];
226
+ const candidates = routeToContentPathCandidates(
227
+ plan.resolveVariant.route,
228
+ plan.resolveVariant.locale,
229
+ candidateLocales,
230
+ defaultLocale,
231
+ routeMounts
232
+ );
233
+ for (const candidate of candidates) {
234
+ const canonicalKey = graph.byRoute[`${candidate.locale}:${candidate.path}`];
235
+ if (!canonicalKey) {
236
+ continue;
237
+ }
238
+ const resolved = resolveGraphVariant(graph, canonicalKey, plan.resolveVariant.locale, {
239
+ defaultLocale,
240
+ fallback: plan.resolveVariant.fallback,
241
+ exact: plan.resolveVariant.exact,
242
+ localeFallback,
243
+ collection: plan.collection
244
+ });
245
+ if (resolved) return resolved;
246
+ }
247
+ return null;
248
+ })() : resolveGraphRouteVariant(
249
+ graph,
250
+ plan.resolveVariant.path,
251
+ plan.resolveVariant.locale,
252
+ {
253
+ defaultLocale,
254
+ fallback: plan.resolveVariant.fallback,
255
+ exact: plan.resolveVariant.exact,
256
+ localeFallback,
257
+ collection: plan.collection
258
+ }
259
+ );
260
+ if (!variant) {
261
+ return { result: void 0 };
262
+ }
263
+ const content = graph.byId[variant.contentId];
264
+ if (plan.collection && content?._collection !== plan.collection) {
265
+ return { result: void 0 };
266
+ }
267
+ const dirConfig = findDirConfig(graph, content?._path, variant.resolvedLocale);
268
+ const variantPaths = Object.fromEntries(
269
+ Object.entries(graph.byCanonical[variant.canonicalKey] || {}).map(([locale, entry]) => [locale, entry.path])
270
+ );
271
+ const enriched = {
272
+ ...withDirConfig(content, dirConfig),
273
+ ...plan.resolveVariant.path ? { _requestedPath: plan.resolveVariant.path } : {},
274
+ ...plan.resolveVariant.route ? { _requestedRoute: plan.resolveVariant.route } : {},
275
+ ...plan.resolveVariant.ref ? { _requestedRef: plan.resolveVariant.ref } : {},
276
+ _requestedLocale: variant.requestedLocale,
277
+ _resolvedLocale: variant.resolvedLocale,
278
+ _fallback: variant.fallback,
279
+ _availableLocales: variant.availableLocales,
280
+ _variantPaths: variantPaths
281
+ };
282
+ const matched = evaluateQueryPlanFilter(enriched, plan.filter) ? [enriched] : [];
283
+ return finalizeQueryPlanResponse(matched, plan);
284
+ };
285
+ export const executeQueryPlan = (graph, plan, options = {}) => {
286
+ if (plan.resolveVariant) {
287
+ return executeVariantPlan(graph, plan, options);
288
+ }
289
+ if (plan.resolveLocale?.locale) {
290
+ return executeLocalePlan(graph, plan, options);
291
+ }
292
+ return executeStandardPlan(graph, plan);
293
+ };
294
+ export const resolveQueryPlanVariant = (graph, plan, options = {}) => {
295
+ if (plan.resolveVariant) {
296
+ return resolveGraphRouteVariant(graph, plan.resolveVariant.path || plan.resolveVariant.route || "", plan.resolveVariant.locale, {
297
+ defaultLocale: options.defaultLocale,
298
+ fallback: plan.resolveVariant.fallback,
299
+ exact: plan.resolveVariant.exact,
300
+ localeFallback: options.localeFallback
301
+ });
302
+ }
303
+ return null;
304
+ };
@@ -0,0 +1 @@
1
+ export * from './filter.js'
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Query compiler for the unified query API (ADR-0016).
3
+ *
4
+ * `by` selects one document through the graph resolver. `where` filters a
5
+ * result set. Keeping those paths separate is the public contract.
6
+ *
7
+ * Operator names are deliberately close to the internal
8
+ * `ContentQueryBuilderWhere` shape. Public `$prefix` is kept as `$prefix`
9
+ * through the transport instead of being exposed as caller-provided regex.
10
+ */
11
+ import type { ContentSelector, ContentQueryBuilderParams, ContentQueryBuilderWhere, ContentQuerySortFields, LocaleFallback, QueryWhere, SortSpec } from '../../types/query';
12
+ /**
13
+ * Compile a public `where` object to the internal `where` clause shape.
14
+ */
15
+ export declare const compileWhere: (where: QueryWhere | undefined) => ContentQueryBuilderWhere | undefined;
16
+ /**
17
+ * Convert `SortSpec` (e.g. `{ date: -1, title: 1 }`) into the array form the
18
+ * transport expects.
19
+ */
20
+ export declare const compileSort: (sort: SortSpec | undefined) => ContentQuerySortFields[] | undefined;
21
+ /**
22
+ * Normalize `fallback` (string / array / boolean) into the transport shape.
23
+ * Boolean `true` means "use configured fallbacks"; an explicit string or array
24
+ * overrides the chain for this query.
25
+ */
26
+ export declare const compileFallback: (fallback: LocaleFallback | undefined) => boolean | string[] | undefined;
27
+ /**
28
+ * Top-level compile: build the params payload sent to the transport. This is
29
+ * the shared pipeline used by every Layer-1 verb.
30
+ */
31
+ export declare const compileQueryParams: (input: {
32
+ collection: string;
33
+ by?: ContentSelector;
34
+ where?: QueryWhere;
35
+ sort?: SortSpec;
36
+ limit?: number;
37
+ skip?: number;
38
+ select?: ReadonlyArray<string | number | symbol>;
39
+ locale?: string;
40
+ fallback?: LocaleFallback;
41
+ exact?: boolean;
42
+ }) => ContentQueryBuilderParams;
@@ -0,0 +1,118 @@
1
+ import { assertSupportedQueryOperators, SUPPORTED_QUERY_OPERATORS } from "./operators.js";
2
+ import { normalizeContentPath } from "../content/path.js";
3
+ const FIELD_OPERATOR_KEYS = /* @__PURE__ */ new Set([...SUPPORTED_QUERY_OPERATORS, "$nin"]);
4
+ const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date);
5
+ const isOperatorObject = (value) => {
6
+ if (!isPlainObject(value)) return false;
7
+ for (const key of Object.keys(value)) {
8
+ if (key.startsWith("$") && FIELD_OPERATOR_KEYS.has(key)) return true;
9
+ }
10
+ return false;
11
+ };
12
+ const compileFieldOperand = (operand) => {
13
+ if (operand === void 0) {
14
+ return void 0;
15
+ }
16
+ if (!isPlainObject(operand)) {
17
+ return operand;
18
+ }
19
+ if (isOperatorObject(operand)) {
20
+ const out = {};
21
+ for (const [op, value] of Object.entries(operand)) {
22
+ if (op === "$nin") {
23
+ out.$not = { $in: value };
24
+ } else {
25
+ out[op] = value;
26
+ }
27
+ }
28
+ return out;
29
+ }
30
+ return compileWhere(operand);
31
+ };
32
+ export const compileWhere = (where) => {
33
+ if (!where) return void 0;
34
+ assertSupportedQueryOperators(where, ["$nin", "$prefix"]);
35
+ const out = {};
36
+ for (const [key, value] of Object.entries(where)) {
37
+ if (value === void 0) continue;
38
+ if (key === "$and" || key === "$or") {
39
+ const arr = Array.isArray(value) ? value : [];
40
+ const compiled = arr.map((part) => compileWhere(part)).filter((part) => Boolean(part && Object.keys(part).length > 0));
41
+ if (compiled.length) {
42
+ out[key] = compiled;
43
+ }
44
+ continue;
45
+ }
46
+ if (key === "$not") {
47
+ const compiled = compileWhere(value);
48
+ if (compiled && Object.keys(compiled).length > 0) {
49
+ out.$not = compiled;
50
+ }
51
+ continue;
52
+ }
53
+ const targetKey = key === "path" ? "_path" : key;
54
+ const operand = compileFieldOperand(value);
55
+ if (operand !== void 0) {
56
+ ;
57
+ out[targetKey] = operand;
58
+ }
59
+ }
60
+ return Object.keys(out).length ? out : void 0;
61
+ };
62
+ export const compileSort = (sort) => {
63
+ if (!sort) return void 0;
64
+ const fields = Object.entries(sort).map(([field, value]) => {
65
+ const direction = value === "asc" ? 1 : value === "desc" ? -1 : value;
66
+ return [field, direction];
67
+ }).filter(([, v]) => v === 1 || v === -1);
68
+ if (!fields.length) return void 0;
69
+ return fields.map(([field, direction]) => ({ [field]: direction }));
70
+ };
71
+ export const compileFallback = (fallback) => {
72
+ if (fallback === void 0) return void 0;
73
+ if (typeof fallback === "boolean") return fallback;
74
+ if (fallback === "default") return ["default"];
75
+ return Array.isArray(fallback) ? fallback : [fallback];
76
+ };
77
+ export const compileQueryParams = (input) => {
78
+ const path = input.by && "path" in input.by ? normalizeContentPath(input.by.path) : void 0;
79
+ const route = input.by && "route" in input.by ? normalizeContentPath(input.by.route) : void 0;
80
+ const ref = input.by && "ref" in input.by ? input.by.ref : void 0;
81
+ const where = compileWhere(input.where);
82
+ const sort = compileSort(input.sort);
83
+ const fallback = compileFallback(input.fallback);
84
+ const select = input.select ? input.select.map(String) : void 0;
85
+ const params = {
86
+ collection: input.collection,
87
+ ...where ? { where: [where] } : {},
88
+ ...sort ? { sort } : {},
89
+ ...typeof input.limit === "number" ? { limit: input.limit } : {},
90
+ ...typeof input.skip === "number" ? { skip: input.skip } : {},
91
+ ...select ? { only: select } : {}
92
+ };
93
+ if (input.locale || path || route || ref || fallback !== void 0) {
94
+ const exact = input.exact ?? (input.locale ? fallback === void 0 || fallback === false : false);
95
+ params.resolveLocale = {
96
+ ...input.locale ? { locale: input.locale } : {},
97
+ ...fallback !== void 0 ? { fallback } : {},
98
+ ...exact ? { exact: true } : {}
99
+ };
100
+ }
101
+ const useVariantResolver = route || ref || path && (input.locale !== void 0 || fallback !== void 0);
102
+ if (useVariantResolver) {
103
+ ;
104
+ params.resolveVariant = {
105
+ ...path ? { path } : {},
106
+ ...route ? { route } : {},
107
+ ...ref ? { ref } : {},
108
+ ...input.locale ? { locale: input.locale } : {},
109
+ ...fallback !== void 0 ? { fallback } : {},
110
+ ...params.resolveLocale?.exact ? { exact: true } : {}
111
+ };
112
+ } else if (path) {
113
+ const pathClause = { _path: path };
114
+ const existing = Array.isArray(params.where) ? params.where : params.where ? [params.where] : [];
115
+ params.where = [...existing, pathClause];
116
+ }
117
+ return params;
118
+ };
@@ -0,0 +1 @@
1
+ export * from './json.js'
@@ -0,0 +1,2 @@
1
+ export declare function jsonStringify(value: unknown): string;
2
+ export declare function jsonParse(value: string): any;
@@ -0,0 +1,20 @@
1
+ export function jsonStringify(value) {
2
+ return JSON.stringify(value, regExpReplacer);
3
+ }
4
+ export function jsonParse(value) {
5
+ return JSON.parse(value, regExpReviver);
6
+ }
7
+ function regExpReplacer(_key, value) {
8
+ if (value instanceof RegExp) {
9
+ return `--REGEX ${value.toString()}`;
10
+ }
11
+ return value;
12
+ }
13
+ function regExpReviver(_key, value) {
14
+ const withOperator = typeof value === "string" && value.match(/^--([A-Z]+) (.+)$/) || [];
15
+ if (withOperator[1] === "REGEX") {
16
+ const regex = withOperator[2]?.match(/\/(.*)\/([dgimsuy]*)$/);
17
+ return regex?.[1] ? new RegExp(regex[1], regex[2] || "") : value;
18
+ }
19
+ return value;
20
+ }
@@ -0,0 +1 @@
1
+ export * from './lower.js'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Lower `ContentQueryBuilderParams` (the public builder's serialized form)
3
+ * into a `ContentQueryPlan` (the executor's AST — see `./plan.ts`).
4
+ *
5
+ * Lowering is the single place we translate user-level shapes (`$eq`,
6
+ * `$and`, sibling-key-as-`$and`) into the normalized tree the executor
7
+ * expects. Downstream code only touches the plan.
8
+ *
9
+ * The translation is purely syntactic — no graph access, no I/O. It runs
10
+ * once per `.all()`/`.first()`/`.count()` call.
11
+ */
12
+ import type { ContentQueryBuilderParams } from '../../types/query';
13
+ import type { ContentQueryPlan } from './plan';
14
+ export declare const lowerQueryPlan: (params: ContentQueryBuilderParams) => ContentQueryPlan;
@@ -0,0 +1,121 @@
1
+ import { assertSupportedQueryOperators, SUPPORTED_QUERY_OPERATORS } from "./operators.js";
2
+ const ensureQueryWhereArray = (where) => {
3
+ return Array.isArray(where) ? [...where] : where ? [where] : [];
4
+ };
5
+ const COMPARISON_OPERATORS = new Set(SUPPORTED_QUERY_OPERATORS);
6
+ const collapse = (type, clauses) => {
7
+ const filtered = clauses.filter((clause) => clause.type !== "true");
8
+ if (!filtered.length) {
9
+ return { type: "true" };
10
+ }
11
+ if (filtered.length === 1) {
12
+ return filtered[0];
13
+ }
14
+ return { type, clauses: filtered };
15
+ };
16
+ const lowerFieldCondition = (field, value) => {
17
+ if (value && typeof value === "object" && !Array.isArray(value) && !(value instanceof RegExp)) {
18
+ const objectValue = value;
19
+ if ("$options" in objectValue && !("$regex" in objectValue)) {
20
+ throw new TypeError("Query operator $options requires $regex.");
21
+ }
22
+ const clauses = [];
23
+ for (const [key, nestedValue] of Object.entries(objectValue)) {
24
+ if (key === "$options") {
25
+ continue;
26
+ }
27
+ if (COMPARISON_OPERATORS.has(key)) {
28
+ if (key === "$not") {
29
+ clauses.push({
30
+ type: "not",
31
+ clause: lowerFieldCondition(field, nestedValue)
32
+ });
33
+ continue;
34
+ }
35
+ clauses.push({
36
+ type: "compare",
37
+ field,
38
+ // `key` is gated by the `COMPARISON_OPERATORS` set above; after
39
+ // stripping the leading `$` it maps 1:1 to a `CompareOperator`.
40
+ operator: key.slice(1),
41
+ value: key === "$regex" && typeof objectValue.$options === "string" && !(nestedValue instanceof RegExp) ? new RegExp(String(nestedValue), objectValue.$options) : nestedValue
42
+ });
43
+ continue;
44
+ }
45
+ clauses.push(lowerFieldCondition(`${field}.${key}`, nestedValue));
46
+ }
47
+ return collapse("and", clauses);
48
+ }
49
+ return {
50
+ type: "compare",
51
+ field,
52
+ operator: "eq",
53
+ value
54
+ };
55
+ };
56
+ const lowerWhereCondition = (condition) => {
57
+ const clauses = [];
58
+ for (const [key, value] of Object.entries(condition)) {
59
+ if (key === "$and") {
60
+ clauses.push(collapse("and", ensureQueryWhereArray(value).map(lowerWhereCondition)));
61
+ continue;
62
+ }
63
+ if (key === "$or") {
64
+ clauses.push(collapse("or", ensureQueryWhereArray(value).map(lowerWhereCondition)));
65
+ continue;
66
+ }
67
+ if (key === "$not" && value && typeof value === "object" && !Array.isArray(value) && !(value instanceof RegExp)) {
68
+ clauses.push({
69
+ type: "not",
70
+ clause: lowerWhereCondition(value)
71
+ });
72
+ continue;
73
+ }
74
+ clauses.push(lowerFieldCondition(key, value));
75
+ }
76
+ return collapse("and", clauses);
77
+ };
78
+ const lowerSort = (sort = []) => {
79
+ return sort.flatMap((option) => {
80
+ const meta = {
81
+ locale: option.$locale,
82
+ numeric: option.$numeric,
83
+ caseFirst: option.$caseFirst,
84
+ sensitivity: option.$sensitivity
85
+ };
86
+ return Object.entries(option).filter(([key]) => !key.startsWith("$")).map(([field, direction]) => ({
87
+ field,
88
+ direction,
89
+ ...meta
90
+ }));
91
+ });
92
+ };
93
+ export const lowerQueryPlan = (params) => {
94
+ assertSupportedQueryOperators(params.where);
95
+ const resolveVariant = params.resolveVariant;
96
+ return {
97
+ collection: params.collection,
98
+ filter: collapse("and", ensureQueryWhereArray(params.where).map(lowerWhereCondition)),
99
+ sort: lowerSort(params.sort),
100
+ projection: {
101
+ only: params.only ? [...params.only] : [],
102
+ without: params.without ? [...params.without] : []
103
+ },
104
+ skip: params.skip || 0,
105
+ limit: params.limit,
106
+ mode: params.count ? "count" : params.first ? "first" : "all",
107
+ resolveLocale: params.resolveLocale ? {
108
+ locale: params.resolveLocale.locale,
109
+ fallback: Array.isArray(params.resolveLocale.fallback) ? [...params.resolveLocale.fallback] : [],
110
+ exact: params.resolveLocale.exact
111
+ } : void 0,
112
+ resolveVariant: resolveVariant ? {
113
+ ...resolveVariant.path ? { path: resolveVariant.path } : {},
114
+ ...resolveVariant.route ? { route: resolveVariant.route } : {},
115
+ ...resolveVariant.ref ? { ref: resolveVariant.ref } : {},
116
+ locale: resolveVariant.locale,
117
+ fallback: Array.isArray(resolveVariant.fallback) ? [...resolveVariant.fallback] : [],
118
+ exact: resolveVariant.exact
119
+ } : void 0
120
+ };
121
+ };
@@ -0,0 +1 @@
1
+ export * from './operators.js'
@@ -0,0 +1,23 @@
1
+ import type { ContentQuerySortOptions } from '../../types/query';
2
+ export declare const get: (obj: Record<string, unknown> | undefined, path: string) => unknown;
3
+ export declare const omit: (keys?: string[]) => <T extends Record<string, unknown>>(obj: T) => Record<string, unknown>;
4
+ export declare const apply: <TInput, TOutput>(fn: (d: TInput) => TOutput) => (data: TInput | TInput[]) => TOutput | TOutput[];
5
+ export declare const detectProperties: (keys: string[]) => {
6
+ prefixes: string[];
7
+ properties: string[];
8
+ };
9
+ export declare const withoutKeys: (keys?: string[]) => <T extends Record<string, unknown>>(obj: T | undefined) => Record<string, unknown> | undefined;
10
+ export declare const withKeys: (keys?: string[]) => <T extends Record<string, unknown>>(obj: T | undefined) => Record<string, unknown> | undefined;
11
+ export declare const sortList: <T extends Record<string, unknown>>(data: T[], params: ContentQuerySortOptions) => T[];
12
+ /**
13
+ * Raise TypeError if value is not an array.
14
+ */
15
+ export declare function assertArray(value: unknown, message?: string): asserts value is unknown[];
16
+ /**
17
+ * Ensure result is an array
18
+ */
19
+ export declare const ensureArray: <T>(value: T) => T extends Array<unknown> ? T : T[];
20
+ export declare const SUPPORTED_QUERY_OPERATORS: readonly ["$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$in", "$contains", "$containsAny", "$icontains", "$exists", "$type", "$regex", "$prefix", "$options", "$not"];
21
+ export declare const containsStandaloneRegexOptions: (value: unknown) => boolean;
22
+ export declare const findUnsupportedQueryOperator: (value: unknown, extraOperators?: readonly string[]) => string | undefined;
23
+ export declare const assertSupportedQueryOperators: (value: unknown, extraOperators?: readonly string[]) => void;