nextjs-studio 0.4.0 → 1.0.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 (238) hide show
  1. package/README.md +3 -1
  2. package/dist/bin/nextjs-studio.js +286 -34
  3. package/dist/bin/nextjs-studio.js.map +1 -1
  4. package/dist/cli/ui/.next/BUILD_ID +1 -0
  5. package/dist/cli/ui/.next/app-path-routes-manifest.json +12 -0
  6. package/dist/cli/ui/.next/build-manifest.json +20 -0
  7. package/dist/cli/ui/.next/export-marker.json +6 -0
  8. package/dist/cli/ui/.next/images-manifest.json +67 -0
  9. package/dist/cli/ui/.next/next-minimal-server.js.nft.json +1 -0
  10. package/dist/cli/ui/.next/next-server.js.nft.json +1 -0
  11. package/dist/cli/ui/.next/package.json +1 -0
  12. package/dist/cli/ui/.next/prerender-manifest.json +61 -0
  13. package/dist/cli/ui/.next/react-loadable-manifest.json +286 -0
  14. package/dist/cli/ui/.next/required-server-files.js +338 -0
  15. package/dist/cli/ui/.next/required-server-files.json +338 -0
  16. package/dist/cli/ui/.next/routes-manifest.json +125 -0
  17. package/dist/cli/ui/.next/server/app/_global-error/page.js +3 -0
  18. package/dist/cli/ui/.next/server/app/_global-error/page.js.nft.json +1 -0
  19. package/dist/cli/ui/.next/server/app/_global-error/page_client-reference-manifest.js +1 -0
  20. package/dist/cli/ui/.next/server/app/_global-error.html +2 -0
  21. package/dist/cli/ui/.next/server/app/_global-error.meta +16 -0
  22. package/dist/cli/ui/.next/server/app/_global-error.rsc +12 -0
  23. package/dist/cli/ui/.next/server/app/_global-error.segments/_full.segment.rsc +12 -0
  24. package/dist/cli/ui/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +5 -0
  25. package/dist/cli/ui/.next/server/app/_global-error.segments/_global-error.segment.rsc +4 -0
  26. package/dist/cli/ui/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
  27. package/dist/cli/ui/.next/server/app/_global-error.segments/_index.segment.rsc +4 -0
  28. package/dist/cli/ui/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  29. package/dist/cli/ui/.next/server/app/_not-found/page.js +2 -0
  30. package/dist/cli/ui/.next/server/app/_not-found/page.js.nft.json +1 -0
  31. package/dist/cli/ui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  32. package/dist/cli/ui/.next/server/app/_not-found.html +1 -0
  33. package/dist/cli/ui/.next/server/app/_not-found.meta +16 -0
  34. package/dist/cli/ui/.next/server/app/_not-found.rsc +15 -0
  35. package/dist/cli/ui/.next/server/app/_not-found.segments/_full.segment.rsc +15 -0
  36. package/dist/cli/ui/.next/server/app/_not-found.segments/_head.segment.rsc +5 -0
  37. package/dist/cli/ui/.next/server/app/_not-found.segments/_index.segment.rsc +7 -0
  38. package/dist/cli/ui/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
  39. package/dist/cli/ui/.next/server/app/_not-found.segments/_not-found.segment.rsc +4 -0
  40. package/dist/cli/ui/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -0
  41. package/dist/cli/ui/.next/server/app/api/media/[collection]/[filename]/route.js +1 -0
  42. package/dist/cli/ui/.next/server/app/api/media/[collection]/[filename]/route.js.nft.json +1 -0
  43. package/dist/cli/ui/.next/server/app/api/media/[collection]/[filename]/route_client-reference-manifest.js +1 -0
  44. package/dist/cli/ui/.next/server/app/api/media/[collection]/route.js +1 -0
  45. package/dist/cli/ui/.next/server/app/api/media/[collection]/route.js.nft.json +1 -0
  46. package/dist/cli/ui/.next/server/app/api/media/[collection]/route_client-reference-manifest.js +1 -0
  47. package/dist/cli/ui/.next/server/app/api/public/[...path]/route.js +1 -0
  48. package/dist/cli/ui/.next/server/app/api/public/[...path]/route.js.nft.json +1 -0
  49. package/dist/cli/ui/.next/server/app/api/public/[...path]/route_client-reference-manifest.js +1 -0
  50. package/dist/cli/ui/.next/server/app/api/sync/[collection]/route.js +1 -0
  51. package/dist/cli/ui/.next/server/app/api/sync/[collection]/route.js.nft.json +1 -0
  52. package/dist/cli/ui/.next/server/app/api/sync/[collection]/route_client-reference-manifest.js +1 -0
  53. package/dist/cli/ui/.next/server/app/api/watch/route.js +3 -0
  54. package/dist/cli/ui/.next/server/app/api/watch/route.js.nft.json +1 -0
  55. package/dist/cli/ui/.next/server/app/api/watch/route_client-reference-manifest.js +1 -0
  56. package/dist/cli/ui/.next/server/app/collection/[name]/[slug]/page.js +99 -0
  57. package/dist/cli/ui/.next/server/app/collection/[name]/[slug]/page.js.nft.json +1 -0
  58. package/dist/cli/ui/.next/server/app/collection/[name]/[slug]/page_client-reference-manifest.js +1 -0
  59. package/dist/cli/ui/.next/server/app/collection/[name]/page.js +5 -0
  60. package/dist/cli/ui/.next/server/app/collection/[name]/page.js.nft.json +1 -0
  61. package/dist/cli/ui/.next/server/app/collection/[name]/page_client-reference-manifest.js +1 -0
  62. package/dist/cli/ui/.next/server/app/page.js +2 -0
  63. package/dist/cli/ui/.next/server/app/page.js.nft.json +1 -0
  64. package/dist/cli/ui/.next/server/app/page_client-reference-manifest.js +1 -0
  65. package/dist/cli/ui/.next/server/app-paths-manifest.json +12 -0
  66. package/dist/cli/ui/.next/server/chunks/1875.js +1 -0
  67. package/dist/cli/ui/.next/server/chunks/2198.js +1 -0
  68. package/dist/cli/ui/.next/server/chunks/2446.js +36 -0
  69. package/dist/cli/ui/.next/server/chunks/2474.js +148 -0
  70. package/dist/cli/ui/.next/server/chunks/2490.js +55 -0
  71. package/dist/cli/ui/.next/server/chunks/2717.js +56 -0
  72. package/dist/cli/ui/.next/server/chunks/2729.js +166 -0
  73. package/dist/cli/ui/.next/server/chunks/2774.js +1 -0
  74. package/dist/cli/ui/.next/server/chunks/2796.js +1 -0
  75. package/dist/cli/ui/.next/server/chunks/3145.js +1 -0
  76. package/dist/cli/ui/.next/server/chunks/3186.js +1 -0
  77. package/dist/cli/ui/.next/server/chunks/3494.js +24 -0
  78. package/dist/cli/ui/.next/server/chunks/3610.js +1 -0
  79. package/dist/cli/ui/.next/server/chunks/3659.js +93 -0
  80. package/dist/cli/ui/.next/server/chunks/3744.js +1 -0
  81. package/dist/cli/ui/.next/server/chunks/3806.js +136 -0
  82. package/dist/cli/ui/.next/server/chunks/408.js +1 -0
  83. package/dist/cli/ui/.next/server/chunks/4189.js +62 -0
  84. package/dist/cli/ui/.next/server/chunks/4293.js +1 -0
  85. package/dist/cli/ui/.next/server/chunks/4469.js +4 -0
  86. package/dist/cli/ui/.next/server/chunks/4484.js +1 -0
  87. package/dist/cli/ui/.next/server/chunks/449.js +82 -0
  88. package/dist/cli/ui/.next/server/chunks/4607.js +22 -0
  89. package/dist/cli/ui/.next/server/chunks/479.js +5 -0
  90. package/dist/cli/ui/.next/server/chunks/4931.js +63 -0
  91. package/dist/cli/ui/.next/server/chunks/528.js +1 -0
  92. package/dist/cli/ui/.next/server/chunks/5341.js +1 -0
  93. package/dist/cli/ui/.next/server/chunks/5585.js +29 -0
  94. package/dist/cli/ui/.next/server/chunks/5677.js +1 -0
  95. package/dist/cli/ui/.next/server/chunks/5724.js +1 -0
  96. package/dist/cli/ui/.next/server/chunks/5760.js +174 -0
  97. package/dist/cli/ui/.next/server/chunks/5784.js +24 -0
  98. package/dist/cli/ui/.next/server/chunks/6.js +262 -0
  99. package/dist/cli/ui/.next/server/chunks/6040.js +1 -0
  100. package/dist/cli/ui/.next/server/chunks/6067.js +13 -0
  101. package/dist/cli/ui/.next/server/chunks/6553.js +1 -0
  102. package/dist/cli/ui/.next/server/chunks/6656.js +201 -0
  103. package/dist/cli/ui/.next/server/chunks/6672.js +1 -0
  104. package/dist/cli/ui/.next/server/chunks/6872.js +1 -0
  105. package/dist/cli/ui/.next/server/chunks/7146.js +59 -0
  106. package/dist/cli/ui/.next/server/chunks/7354.js +1 -0
  107. package/dist/cli/ui/.next/server/chunks/7677.js +1 -0
  108. package/dist/cli/ui/.next/server/chunks/7781.js +1 -0
  109. package/dist/cli/ui/.next/server/chunks/8194.js +215 -0
  110. package/dist/cli/ui/.next/server/chunks/8231.js +1 -0
  111. package/dist/cli/ui/.next/server/chunks/8319.js +2 -0
  112. package/dist/cli/ui/.next/server/chunks/8339.js +1 -0
  113. package/dist/cli/ui/.next/server/chunks/8775.js +1 -0
  114. package/dist/cli/ui/.next/server/chunks/9503.js +43 -0
  115. package/dist/cli/ui/.next/server/chunks/958.js +131 -0
  116. package/dist/cli/ui/.next/server/chunks/9739.js +1 -0
  117. package/dist/cli/ui/.next/server/functions-config-manifest.json +4 -0
  118. package/dist/cli/ui/.next/server/interception-route-rewrite-manifest.js +1 -0
  119. package/dist/cli/ui/.next/server/middleware-build-manifest.js +1 -0
  120. package/dist/cli/ui/.next/server/middleware-manifest.json +6 -0
  121. package/dist/cli/ui/.next/server/middleware-react-loadable-manifest.js +1 -0
  122. package/dist/cli/ui/.next/server/next-font-manifest.js +1 -0
  123. package/dist/cli/ui/.next/server/next-font-manifest.json +1 -0
  124. package/dist/cli/ui/.next/server/pages/404.html +1 -0
  125. package/dist/cli/ui/.next/server/pages/500.html +2 -0
  126. package/dist/cli/ui/.next/server/pages-manifest.json +4 -0
  127. package/dist/cli/ui/.next/server/server-reference-manifest.js +1 -0
  128. package/dist/cli/ui/.next/server/server-reference-manifest.json +1 -0
  129. package/dist/cli/ui/.next/server/webpack-runtime.js +1 -0
  130. package/dist/cli/ui/.next/static/chunks/0937d497-2b220e2d0368e918.js +1 -0
  131. package/dist/cli/ui/.next/static/chunks/1013.5541c1c75688ef6e.js +1 -0
  132. package/dist/cli/ui/.next/static/chunks/1039.d26ef6a818f26d70.js +4 -0
  133. package/dist/cli/ui/.next/static/chunks/1325.cb67348b484ce7a0.js +24 -0
  134. package/dist/cli/ui/.next/static/chunks/1858-d10f8bead2218ad2.js +2 -0
  135. package/dist/cli/ui/.next/static/chunks/1882.05c68ab6bdcd8c31.js +1 -0
  136. package/dist/cli/ui/.next/static/chunks/2011.7e73842f1e8e2cde.js +1 -0
  137. package/dist/cli/ui/.next/static/chunks/2046.73486ea936c9afd2.js +1 -0
  138. package/dist/cli/ui/.next/static/chunks/2389.b73d3a1286a228d0.js +1 -0
  139. package/dist/cli/ui/.next/static/chunks/2430.08df5899978ebf26.js +43 -0
  140. package/dist/cli/ui/.next/static/chunks/2462-4255d8f51dc56f12.js +1 -0
  141. package/dist/cli/ui/.next/static/chunks/3098-4269da0468edc350.js +1 -0
  142. package/dist/cli/ui/.next/static/chunks/317.b4fcc40f219152b1.js +1 -0
  143. package/dist/cli/ui/.next/static/chunks/3197.d2f3398e552228e4.js +1 -0
  144. package/dist/cli/ui/.next/static/chunks/3212-1a9c9d110d15abab.js +4 -0
  145. package/dist/cli/ui/.next/static/chunks/3809.8df186de2ff997f8.js +1 -0
  146. package/dist/cli/ui/.next/static/chunks/3918.caaf4eb4f6450524.js +1 -0
  147. package/dist/cli/ui/.next/static/chunks/3987-6d3217e36ae5b4dc.js +1 -0
  148. package/dist/cli/ui/.next/static/chunks/3c774391-ec08594272867fd5.js +79 -0
  149. package/dist/cli/ui/.next/static/chunks/4075052f.9006147a6182ed95.js +1 -0
  150. package/dist/cli/ui/.next/static/chunks/4389.e7a3c58aa62118e3.js +82 -0
  151. package/dist/cli/ui/.next/static/chunks/46bdbe0e-f5103600b23143b8.js +1 -0
  152. package/dist/cli/ui/.next/static/chunks/4860.2ba51d1d81857c81.js +1 -0
  153. package/dist/cli/ui/.next/static/chunks/4882.794e2a9231f129e5.js +55 -0
  154. package/dist/cli/ui/.next/static/chunks/5149.8de9918b9ace58f5.js +166 -0
  155. package/dist/cli/ui/.next/static/chunks/5230.b7c87400f0d8516f.js +215 -0
  156. package/dist/cli/ui/.next/static/chunks/5263.7adc3ade53cd4ed3.js +24 -0
  157. package/dist/cli/ui/.next/static/chunks/5313.1dfcc2126f85a8f8.js +1 -0
  158. package/dist/cli/ui/.next/static/chunks/5350-17c792e27bf38c77.js +1 -0
  159. package/dist/cli/ui/.next/static/chunks/5638.e3a2119354708654.js +1 -0
  160. package/dist/cli/ui/.next/static/chunks/5758.33b45c6c407ecd94.js +1 -0
  161. package/dist/cli/ui/.next/static/chunks/589.019158de5d02c262.js +1 -0
  162. package/dist/cli/ui/.next/static/chunks/6013.e33e73569339afee.js +62 -0
  163. package/dist/cli/ui/.next/static/chunks/6084.7511ad4ebb4f9df5.js +1 -0
  164. package/dist/cli/ui/.next/static/chunks/612.d3aeebcaaaf06fb2.js +1 -0
  165. package/dist/cli/ui/.next/static/chunks/6239.6c0cd99ea36222b6.js +5 -0
  166. package/dist/cli/ui/.next/static/chunks/6299-79a74877b87acf9f.js +1 -0
  167. package/dist/cli/ui/.next/static/chunks/6484.d38aa531768c3452.js +148 -0
  168. package/dist/cli/ui/.next/static/chunks/6505.731f74c28b8980b3.js +1 -0
  169. package/dist/cli/ui/.next/static/chunks/6584.be94a55391bcdcce.js +262 -0
  170. package/dist/cli/ui/.next/static/chunks/6800.1066ad1f5add7c75.js +1 -0
  171. package/dist/cli/ui/.next/static/chunks/7052.89e2de773d10ac20.js +131 -0
  172. package/dist/cli/ui/.next/static/chunks/7127.360abfa43dc4427e.js +36 -0
  173. package/dist/cli/ui/.next/static/chunks/7430.2b247d9ac6ef694c.js +149 -0
  174. package/dist/cli/ui/.next/static/chunks/7444.66c4d6bbc19309b3.js +59 -0
  175. package/dist/cli/ui/.next/static/chunks/7546.4cb4db4685212384.js +63 -0
  176. package/dist/cli/ui/.next/static/chunks/7564.7b9271fcf06df80c.js +29 -0
  177. package/dist/cli/ui/.next/static/chunks/7664.8268c156d8988844.js +174 -0
  178. package/dist/cli/ui/.next/static/chunks/7722-04e64cc1b26cfa65.js +1 -0
  179. package/dist/cli/ui/.next/static/chunks/8701.3995b58a75e43147.js +56 -0
  180. package/dist/cli/ui/.next/static/chunks/8800.548c3da26cfebf06.js +1 -0
  181. package/dist/cli/ui/.next/static/chunks/8814-7b64110c79ce7209.js +15 -0
  182. package/dist/cli/ui/.next/static/chunks/9058.a195d15265251194.js +1 -0
  183. package/dist/cli/ui/.next/static/chunks/9211.91144a0d23e4cf6d.js +1 -0
  184. package/dist/cli/ui/.next/static/chunks/9690.c1f08c02a675b9ce.js +1 -0
  185. package/dist/cli/ui/.next/static/chunks/9919.1ccc9ca4a749d9b7.js +93 -0
  186. package/dist/cli/ui/.next/static/chunks/app/_global-error/page-ad53913b77389472.js +1 -0
  187. package/dist/cli/ui/.next/static/chunks/app/_not-found/page-202c1e16a4b86ac8.js +1 -0
  188. package/dist/cli/ui/.next/static/chunks/app/api/media/[collection]/[filename]/route-ad53913b77389472.js +1 -0
  189. package/dist/cli/ui/.next/static/chunks/app/api/media/[collection]/route-ad53913b77389472.js +1 -0
  190. package/dist/cli/ui/.next/static/chunks/app/api/public/[...path]/route-ad53913b77389472.js +1 -0
  191. package/dist/cli/ui/.next/static/chunks/app/api/sync/[collection]/route-ad53913b77389472.js +1 -0
  192. package/dist/cli/ui/.next/static/chunks/app/api/watch/route-ad53913b77389472.js +1 -0
  193. package/dist/cli/ui/.next/static/chunks/app/collection/[name]/[slug]/page-7ea9eff252374845.js +6 -0
  194. package/dist/cli/ui/.next/static/chunks/app/collection/[name]/loading-03fc0b653e7060ae.js +1 -0
  195. package/dist/cli/ui/.next/static/chunks/app/collection/[name]/page-ad5976bebc9820cf.js +1 -0
  196. package/dist/cli/ui/.next/static/chunks/app/layout-74cd2ebe3fac00e7.js +1 -0
  197. package/dist/cli/ui/.next/static/chunks/app/page-ed5acadf20146966.js +1 -0
  198. package/dist/cli/ui/.next/static/chunks/b1767599.6a816b06e55b02a1.js +1 -0
  199. package/dist/cli/ui/.next/static/chunks/c6164070.3b9741bce302db0f.js +136 -0
  200. package/dist/cli/ui/.next/static/chunks/fb2ceba8.7fc23e46ca00cfd1.js +53 -0
  201. package/dist/cli/ui/.next/static/chunks/framework-ada624c9bf38edc6.js +1 -0
  202. package/dist/cli/ui/.next/static/chunks/main-0513ff42a7f2e1a0.js +5 -0
  203. package/dist/cli/ui/.next/static/chunks/main-app-b8d23dfb755744e8.js +1 -0
  204. package/dist/cli/ui/.next/static/chunks/next/dist/client/components/builtin/app-error-ad53913b77389472.js +1 -0
  205. package/dist/cli/ui/.next/static/chunks/next/dist/client/components/builtin/forbidden-ad53913b77389472.js +1 -0
  206. package/dist/cli/ui/.next/static/chunks/next/dist/client/components/builtin/global-error-558ee1074f45044b.js +1 -0
  207. package/dist/cli/ui/.next/static/chunks/next/dist/client/components/builtin/not-found-ad53913b77389472.js +1 -0
  208. package/dist/cli/ui/.next/static/chunks/next/dist/client/components/builtin/unauthorized-ad53913b77389472.js +1 -0
  209. package/dist/cli/ui/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  210. package/dist/cli/ui/.next/static/chunks/webpack-acb903cd88aafa6f.js +1 -0
  211. package/dist/cli/ui/.next/static/css/e143949aa3f17880.css +3 -0
  212. package/dist/cli/ui/.next/static/media/034d78ad42e9620c-s.woff2 +0 -0
  213. package/dist/cli/ui/.next/static/media/0484562807a97172-s.p.woff2 +0 -0
  214. package/dist/cli/ui/.next/static/media/29a4aea02fdee119-s.woff2 +0 -0
  215. package/dist/cli/ui/.next/static/media/29e7bbdce9332268-s.woff2 +0 -0
  216. package/dist/cli/ui/.next/static/media/4c285fdca692ea22-s.p.woff2 +0 -0
  217. package/dist/cli/ui/.next/static/media/6c177e25b87fd9cd-s.woff2 +0 -0
  218. package/dist/cli/ui/.next/static/media/6c9a125e97d835e1-s.woff2 +0 -0
  219. package/dist/cli/ui/.next/static/media/8888a3826f4a3af4-s.p.woff2 +0 -0
  220. package/dist/cli/ui/.next/static/media/a1386beebedccca4-s.woff2 +0 -0
  221. package/dist/cli/ui/.next/static/media/b957ea75a84b6ea7-s.p.woff2 +0 -0
  222. package/dist/cli/ui/.next/static/media/c3bc380753a8436c-s.woff2 +0 -0
  223. package/dist/cli/ui/.next/static/media/db911767852bc875-s.woff2 +0 -0
  224. package/dist/cli/ui/.next/static/media/eafabf029ad39a43-s.p.woff2 +0 -0
  225. package/dist/cli/ui/.next/static/media/f10b8e9d91f3edcb-s.woff2 +0 -0
  226. package/dist/cli/ui/.next/static/media/fe0777f1195381cb-s.woff2 +0 -0
  227. package/dist/cli/ui/.next/static/zkOuvkSWApTVHCrj7neNk/_buildManifest.js +1 -0
  228. package/dist/cli/ui/.next/static/zkOuvkSWApTVHCrj7neNk/_ssgManifest.js +1 -0
  229. package/dist/cli/ui/next.config.js +1 -0
  230. package/dist/cli/ui/package.json +4 -0
  231. package/dist/core/index.d.ts +34 -391
  232. package/dist/core/index.js +112 -338
  233. package/dist/core/index.js.map +1 -1
  234. package/dist/core/server.d.ts +135 -0
  235. package/dist/core/server.js +707 -0
  236. package/dist/core/server.js.map +1 -0
  237. package/dist/query-builder-KXz9cPzF.d.ts +330 -0
  238. package/package.json +31 -10
@@ -0,0 +1,707 @@
1
+ // src/core/server.ts
2
+ import path3 from "path";
3
+
4
+ // src/shared/constants.ts
5
+ var CONTENTS_DIR = "contents";
6
+ var CONFIG_FILENAMES = ["studio.config.ts", "studio.config.js", "studio.config.mjs"];
7
+ var SUPPORTED_EXTENSIONS = [".mdx", ".json"];
8
+ var COLLECTION_ORDER_FILE = "collection.json";
9
+ var IMAGE_MIME_TYPES = [
10
+ "image/png",
11
+ "image/jpeg",
12
+ "image/gif",
13
+ "image/webp",
14
+ "image/svg+xml",
15
+ "image/avif"
16
+ ];
17
+ var VIDEO_MIME_TYPES = ["video/mp4", "video/webm", "video/ogg"];
18
+ var AUDIO_MIME_TYPES = [
19
+ "audio/mpeg",
20
+ "audio/ogg",
21
+ "audio/wav",
22
+ "audio/webm",
23
+ "audio/aac",
24
+ "audio/flac"
25
+ ];
26
+ var MEDIA_MIME_TYPES = [...IMAGE_MIME_TYPES, ...VIDEO_MIME_TYPES, ...AUDIO_MIME_TYPES];
27
+
28
+ // src/core/fs-adapter.ts
29
+ import fs from "fs/promises";
30
+ import fsSync from "fs";
31
+ import path from "path";
32
+ var FsAdapter = class {
33
+ basePath;
34
+ constructor(basePath) {
35
+ this.basePath = path.resolve(basePath);
36
+ }
37
+ resolve(...segments) {
38
+ return path.resolve(this.basePath, ...segments);
39
+ }
40
+ async readFile(filePath) {
41
+ return fs.readFile(this.resolve(filePath), "utf-8");
42
+ }
43
+ async writeFile(filePath, content) {
44
+ const fullPath = this.resolve(filePath);
45
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
46
+ await fs.writeFile(fullPath, content, "utf-8");
47
+ }
48
+ async deleteFile(filePath) {
49
+ await fs.unlink(this.resolve(filePath));
50
+ }
51
+ async exists(filePath) {
52
+ try {
53
+ await fs.access(this.resolve(filePath));
54
+ return true;
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+ async getStats(filePath) {
60
+ const fullPath = this.resolve(filePath);
61
+ const stats = await fs.stat(fullPath);
62
+ return { path: filePath, size: stats.size, modifiedAt: stats.mtime };
63
+ }
64
+ async listFiles(dirPath, extensions) {
65
+ const fullPath = this.resolve(dirPath);
66
+ const filterExts = extensions ?? SUPPORTED_EXTENSIONS;
67
+ let entries;
68
+ try {
69
+ entries = await fs.readdir(fullPath, { withFileTypes: true });
70
+ } catch {
71
+ return [];
72
+ }
73
+ return entries.filter((entry) => entry.isFile() && filterExts.some((ext) => entry.name.endsWith(ext))).map((entry) => this.join(dirPath, entry.name));
74
+ }
75
+ async listDirectories(dirPath) {
76
+ const fullPath = this.resolve(dirPath);
77
+ let entries;
78
+ try {
79
+ entries = await fs.readdir(fullPath, { withFileTypes: true });
80
+ } catch {
81
+ return [];
82
+ }
83
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => this.join(dirPath, entry.name));
84
+ }
85
+ async readBuffer(filePath) {
86
+ return fs.readFile(this.resolve(filePath));
87
+ }
88
+ async writeBuffer(filePath, data) {
89
+ const fullPath = this.resolve(filePath);
90
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
91
+ await fs.writeFile(fullPath, data);
92
+ }
93
+ async listAllFiles(dirPath) {
94
+ const fullPath = this.resolve(dirPath);
95
+ let entries;
96
+ try {
97
+ entries = await fs.readdir(fullPath, { withFileTypes: true });
98
+ } catch {
99
+ return [];
100
+ }
101
+ const results = [];
102
+ for (const entry of entries) {
103
+ if (!entry.isFile()) continue;
104
+ const relativePath = this.join(dirPath, entry.name);
105
+ const stats = await fs.stat(this.resolve(relativePath));
106
+ results.push({ name: entry.name, relativePath, size: stats.size, modifiedAt: stats.mtime });
107
+ }
108
+ return results;
109
+ }
110
+ join(...segments) {
111
+ return path.join(...segments);
112
+ }
113
+ basename(filePath) {
114
+ return path.basename(filePath);
115
+ }
116
+ extname(filePath) {
117
+ return path.extname(filePath);
118
+ }
119
+ relative(from, to) {
120
+ return path.relative(from, to);
121
+ }
122
+ normalizeSlug(relativePath, ext) {
123
+ return relativePath.replace(ext, "").split(path.sep).join("/");
124
+ }
125
+ readFileSync(filePath) {
126
+ return fsSync.readFileSync(this.resolve(filePath), "utf-8");
127
+ }
128
+ existsSync(filePath) {
129
+ return fsSync.existsSync(this.resolve(filePath));
130
+ }
131
+ listFilesSync(dirPath, extensions) {
132
+ const fullPath = this.resolve(dirPath);
133
+ const filterExts = extensions ?? SUPPORTED_EXTENSIONS;
134
+ let entries;
135
+ try {
136
+ entries = fsSync.readdirSync(fullPath, { withFileTypes: true });
137
+ } catch {
138
+ return [];
139
+ }
140
+ return entries.filter((entry) => entry.isFile() && filterExts.some((ext) => entry.name.endsWith(ext))).map((entry) => this.join(dirPath, entry.name));
141
+ }
142
+ listDirectoriesSync(dirPath) {
143
+ const fullPath = this.resolve(dirPath);
144
+ let entries;
145
+ try {
146
+ entries = fsSync.readdirSync(fullPath, { withFileTypes: true });
147
+ } catch {
148
+ return [];
149
+ }
150
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => this.join(dirPath, entry.name));
151
+ }
152
+ };
153
+
154
+ // src/core/indexer.ts
155
+ import slugify from "@sindresorhus/slugify";
156
+
157
+ // src/core/parsers/parser-mdx.ts
158
+ import matter from "gray-matter";
159
+
160
+ // src/core/frontmatter-binder.ts
161
+ var TOKEN_REGEX = /\{frontmatter\.([a-zA-Z0-9_.]+)\}/g;
162
+ function bindFrontmatter(body, data) {
163
+ return body.replace(TOKEN_REGEX, (_match, path4) => {
164
+ const value = resolvePath(data, path4);
165
+ if (value === void 0 || value === null) return _match;
166
+ if (typeof value === "object") return JSON.stringify(value);
167
+ return String(value);
168
+ });
169
+ }
170
+ function resolvePath(obj, path4) {
171
+ const keys = path4.split(".");
172
+ let current = obj;
173
+ for (const key of keys) {
174
+ if (typeof current !== "object" || current === null) return void 0;
175
+ current = current[key];
176
+ }
177
+ return current;
178
+ }
179
+
180
+ // src/core/parsers/parser-mdx.ts
181
+ function normalizeDates(data) {
182
+ const result = {};
183
+ for (const [key, value] of Object.entries(data)) {
184
+ if (value instanceof Date) {
185
+ result[key] = value.toISOString().split("T")[0];
186
+ } else if (typeof value === "object" && value !== null && !Array.isArray(value)) {
187
+ result[key] = normalizeDates(value);
188
+ } else {
189
+ result[key] = value;
190
+ }
191
+ }
192
+ return result;
193
+ }
194
+ function parseMdx(content, options) {
195
+ const { data: rawData, content: body } = matter(content);
196
+ const data = normalizeDates(rawData);
197
+ const trimmed = body.trim();
198
+ return {
199
+ data,
200
+ body: options?.bindTokens ? bindFrontmatter(trimmed, data) : trimmed
201
+ };
202
+ }
203
+
204
+ // src/core/parsers/parser-json.ts
205
+ function parseJson(content) {
206
+ const parsed = JSON.parse(content);
207
+ if (Array.isArray(parsed)) {
208
+ return {
209
+ type: "json-array",
210
+ entries: parsed
211
+ };
212
+ }
213
+ if (typeof parsed === "object" && parsed !== null) {
214
+ return {
215
+ type: "json-object",
216
+ data: parsed
217
+ };
218
+ }
219
+ throw new Error("JSON content must be an array or object");
220
+ }
221
+
222
+ // src/core/schema-inferrer.ts
223
+ var RE_ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
224
+ var RE_ISO_DATETIME = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?$/;
225
+ var RE_EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
226
+ var RE_URL = /^https?:\/\/.+/;
227
+ var LONG_TEXT_THRESHOLD = 200;
228
+ var RICH_TEXT_FIELD_NAMES = ["description", "descriptions", "text", "content"];
229
+ function isISODate(value) {
230
+ return RE_ISO_DATE.test(value);
231
+ }
232
+ function isISODateTime(value) {
233
+ return RE_ISO_DATETIME.test(value);
234
+ }
235
+ function isEmail(value) {
236
+ return RE_EMAIL.test(value);
237
+ }
238
+ function isUrl(value) {
239
+ return RE_URL.test(value);
240
+ }
241
+ function inferStringField(name, strings) {
242
+ if (strings.every(isEmail)) return { name, type: "email" };
243
+ if (strings.every(isUrl)) return { name, type: "url" };
244
+ if (strings.every(isISODateTime)) return { name, type: "date", includeTime: true };
245
+ if (strings.every(isISODate)) return { name, type: "date" };
246
+ if (RICH_TEXT_FIELD_NAMES.includes(name.toLowerCase())) return { name, type: "long-text" };
247
+ const isLong = strings.some((s) => s.length > LONG_TEXT_THRESHOLD || s.includes("\n"));
248
+ return { name, type: isLong ? "long-text" : "text" };
249
+ }
250
+ function inferArrayField(name, items) {
251
+ if (items.length === 0) return { name, type: "array", itemFields: [] };
252
+ if (items.every((item) => typeof item === "string")) {
253
+ const unique = [...new Set(items)].slice(0, 50);
254
+ const options = unique.map((v) => ({ label: v, value: v }));
255
+ return { name, type: "multi-select", options };
256
+ }
257
+ if (items.every((item) => typeof item === "object" && item !== null && !Array.isArray(item))) {
258
+ return { name, type: "array", itemFields: inferFields(items) };
259
+ }
260
+ return { name, type: "array", itemFields: [] };
261
+ }
262
+ function inferFieldDefinition(name, values) {
263
+ const present = values.filter((v) => v !== null && v !== void 0);
264
+ if (present.length === 0) return { name, type: "text" };
265
+ if (present.every((v) => typeof v === "boolean")) return { name, type: "boolean" };
266
+ if (present.every((v) => typeof v === "number")) {
267
+ const format = present.every((v) => Number.isInteger(v)) ? "integer" : "decimal";
268
+ return { name, type: "number", format };
269
+ }
270
+ if (present.every((v) => typeof v === "string")) {
271
+ return inferStringField(name, present);
272
+ }
273
+ if (present.every((v) => Array.isArray(v))) {
274
+ return inferArrayField(name, present.flat());
275
+ }
276
+ if (present.every((v) => typeof v === "object" && v !== null && !Array.isArray(v))) {
277
+ return { name, type: "object", fields: inferFields(present) };
278
+ }
279
+ return { name, type: "text" };
280
+ }
281
+ function inferFields(rows) {
282
+ const keySet = new Set(rows.flatMap((row) => Object.keys(row)));
283
+ return Array.from(keySet).map((key) => inferFieldDefinition(key, rows.map((row) => row[key])));
284
+ }
285
+ function inferSchema(entries, collectionName) {
286
+ const rows = entries.map((entry) => entry.data);
287
+ return { collection: collectionName, fields: inferFields(rows) };
288
+ }
289
+
290
+ // src/core/locale-parser.ts
291
+ var LOCALE_REGEX = /\.([a-z]{2}(?:-[A-Z]{2})?)\.mdx$/;
292
+ function parseLocaleFromFilename(filename) {
293
+ const match = LOCALE_REGEX.exec(filename);
294
+ return match?.[1];
295
+ }
296
+ function stripLocaleFromSlug(slug, locale) {
297
+ if (!locale) return slug;
298
+ const dotSuffix = `.${locale}`;
299
+ if (slug.endsWith(dotSuffix)) return slug.slice(0, -dotSuffix.length);
300
+ const dashSuffix = `-${locale}`;
301
+ if (slug.endsWith(dashSuffix)) return slug.slice(0, -dashSuffix.length);
302
+ return slug;
303
+ }
304
+
305
+ // src/core/indexer.ts
306
+ var ContentIndex = class {
307
+ entries = /* @__PURE__ */ new Map();
308
+ collections = /* @__PURE__ */ new Map();
309
+ fs;
310
+ constructor(fsAdapter) {
311
+ this.fs = fsAdapter;
312
+ }
313
+ async build(config) {
314
+ this.clear();
315
+ const dirs = await this.fs.listDirectories(".");
316
+ for (const dir of dirs) {
317
+ const dirName = this.fs.basename(dir);
318
+ const collectionName = slugify(dirName);
319
+ const collectionConfig = config?.collections?.[collectionName];
320
+ await this.indexCollection(dirName, collectionName, collectionConfig?.schema);
321
+ }
322
+ }
323
+ buildSync(config) {
324
+ this.clear();
325
+ const dirs = this.fs.listDirectoriesSync(".");
326
+ for (const dir of dirs) {
327
+ const dirName = this.fs.basename(dir);
328
+ const collectionName = slugify(dirName);
329
+ const collectionConfig = config?.collections?.[collectionName];
330
+ this.indexCollectionSync(dirName, collectionName, collectionConfig?.schema);
331
+ }
332
+ }
333
+ getCollection(name) {
334
+ return this.entries.get(name) ?? [];
335
+ }
336
+ getCollections() {
337
+ return Array.from(this.collections.values());
338
+ }
339
+ clear() {
340
+ this.entries.clear();
341
+ this.collections.clear();
342
+ }
343
+ updateEntry(collectionName, entry) {
344
+ const entries = this.entries.get(collectionName) ?? [];
345
+ const idx = entries.findIndex((e) => e.slug === entry.slug);
346
+ if (idx >= 0) {
347
+ entries[idx] = entry;
348
+ } else {
349
+ entries.push(entry);
350
+ }
351
+ this.entries.set(collectionName, entries);
352
+ this.updateCollectionMeta(collectionName);
353
+ }
354
+ removeEntry(collectionName, slug) {
355
+ const entries = this.entries.get(collectionName);
356
+ if (!entries) return;
357
+ const filtered = entries.filter((e) => e.slug !== slug);
358
+ this.entries.set(collectionName, filtered);
359
+ this.updateCollectionMeta(collectionName);
360
+ }
361
+ updateCollectionMeta(collectionName) {
362
+ const col = this.collections.get(collectionName);
363
+ const entries = this.entries.get(collectionName) ?? [];
364
+ if (col) {
365
+ this.collections.set(collectionName, {
366
+ ...col,
367
+ count: entries.length,
368
+ type: this.detectCollectionType(entries)
369
+ });
370
+ }
371
+ }
372
+ async indexCollection(dirName, collectionName, manualSchema) {
373
+ const entries = [];
374
+ await this.scanDir(dirName, collectionName, dirName, entries);
375
+ const orderPath = this.fs.join(dirName, COLLECTION_ORDER_FILE);
376
+ const ordering = await this.readOrdering(orderPath);
377
+ if (ordering) {
378
+ this.applyOrdering(entries, ordering);
379
+ }
380
+ const schema = manualSchema ?? inferSchema(entries, collectionName);
381
+ this.entries.set(collectionName, entries);
382
+ this.collections.set(collectionName, {
383
+ name: collectionName,
384
+ type: this.detectCollectionType(entries),
385
+ count: entries.length,
386
+ basePath: dirName,
387
+ schema
388
+ });
389
+ }
390
+ indexCollectionSync(dirName, collectionName, manualSchema) {
391
+ const entries = [];
392
+ this.scanDirSync(dirName, collectionName, dirName, entries);
393
+ const orderPath = this.fs.join(dirName, COLLECTION_ORDER_FILE);
394
+ const ordering = this.readOrderingSync(orderPath);
395
+ if (ordering) {
396
+ this.applyOrdering(entries, ordering);
397
+ }
398
+ const schema = manualSchema ?? inferSchema(entries, collectionName);
399
+ this.entries.set(collectionName, entries);
400
+ this.collections.set(collectionName, {
401
+ name: collectionName,
402
+ type: this.detectCollectionType(entries),
403
+ count: entries.length,
404
+ basePath: dirName,
405
+ schema
406
+ });
407
+ }
408
+ async scanDir(dirName, collectionName, dirPath, entries) {
409
+ const subDirs = await this.fs.listDirectories(dirPath);
410
+ for (const subDir of subDirs) {
411
+ await this.scanDir(dirName, collectionName, subDir, entries);
412
+ }
413
+ const files = await this.fs.listFiles(dirPath);
414
+ for (const filePath of files) {
415
+ const fileName = this.fs.basename(filePath);
416
+ if (fileName === COLLECTION_ORDER_FILE) continue;
417
+ const ext = this.fs.extname(fileName);
418
+ const content = await this.fs.readFile(filePath);
419
+ const relativePath = this.fs.relative(dirName, filePath);
420
+ const slug = this.fs.normalizeSlug(relativePath, ext).split("/").map((segment) => slugify(segment)).join("/");
421
+ if (ext === ".mdx") {
422
+ entries.push(this.buildMdxEntry(collectionName, slug, fileName, content));
423
+ } else if (ext === ".json") {
424
+ entries.push(...this.buildJsonEntries(collectionName, slug, content));
425
+ }
426
+ }
427
+ }
428
+ scanDirSync(dirName, collectionName, dirPath, entries) {
429
+ const subDirs = this.fs.listDirectoriesSync(dirPath);
430
+ for (const subDir of subDirs) {
431
+ this.scanDirSync(dirName, collectionName, subDir, entries);
432
+ }
433
+ const files = this.fs.listFilesSync(dirPath);
434
+ for (const filePath of files) {
435
+ const fileName = this.fs.basename(filePath);
436
+ if (fileName === COLLECTION_ORDER_FILE) continue;
437
+ const ext = this.fs.extname(fileName);
438
+ const content = this.fs.readFileSync(filePath);
439
+ const relativePath = this.fs.relative(dirName, filePath);
440
+ const slug = this.fs.normalizeSlug(relativePath, ext).split("/").map((segment) => slugify(segment)).join("/");
441
+ if (ext === ".mdx") {
442
+ entries.push(this.buildMdxEntry(collectionName, slug, fileName, content));
443
+ } else if (ext === ".json") {
444
+ entries.push(...this.buildJsonEntries(collectionName, slug, content));
445
+ }
446
+ }
447
+ }
448
+ buildMdxEntry(collectionName, slug, fileName, content) {
449
+ const parsed = parseMdx(content);
450
+ const locale = parseLocaleFromFilename(fileName);
451
+ const normalizedSlug = stripLocaleFromSlug(slug, locale);
452
+ return {
453
+ collection: collectionName,
454
+ slug: normalizedSlug,
455
+ path: `/${collectionName}/${normalizedSlug}`,
456
+ body: parsed.body,
457
+ data: parsed.data,
458
+ ...locale ? { locale } : {}
459
+ };
460
+ }
461
+ buildJsonEntries(collectionName, slug, content) {
462
+ const parsed = parseJson(content);
463
+ if (parsed.type === "json-array") {
464
+ return parsed.entries.map((data, index) => {
465
+ const entrySlug = typeof data["slug"] === "string" ? slugify(data["slug"]) : `${slug}/${index}`;
466
+ return {
467
+ collection: collectionName,
468
+ slug: entrySlug,
469
+ path: `/${collectionName}/${entrySlug}`,
470
+ data
471
+ };
472
+ });
473
+ }
474
+ return [{ collection: collectionName, slug, path: `/${collectionName}/${slug}`, data: parsed.data }];
475
+ }
476
+ async readOrdering(orderPath) {
477
+ if (!await this.fs.exists(orderPath)) return null;
478
+ try {
479
+ const content = await this.fs.readFile(orderPath);
480
+ const parsed = JSON.parse(content);
481
+ if (Array.isArray(parsed)) return parsed;
482
+ } catch (error) {
483
+ console.warn(`[Nextjs Studio] Failed to parse ordering file: ${orderPath}`, error);
484
+ }
485
+ return null;
486
+ }
487
+ readOrderingSync(orderPath) {
488
+ if (!this.fs.existsSync(orderPath)) return null;
489
+ try {
490
+ const content = this.fs.readFileSync(orderPath);
491
+ const parsed = JSON.parse(content);
492
+ if (Array.isArray(parsed)) return parsed;
493
+ } catch (error) {
494
+ console.warn(`[Nextjs Studio] Failed to parse ordering file: ${orderPath}`, error);
495
+ }
496
+ return null;
497
+ }
498
+ applyOrdering(entries, ordering) {
499
+ const orderMap = new Map(ordering.map((slug, index) => [slug, index]));
500
+ entries.sort((a, b) => {
501
+ const aIndex = orderMap.get(a.slug) ?? Infinity;
502
+ const bIndex = orderMap.get(b.slug) ?? Infinity;
503
+ return aIndex - bIndex;
504
+ });
505
+ }
506
+ detectCollectionType(entries) {
507
+ if (entries.length === 0) return "mdx";
508
+ const first = entries[0];
509
+ if (first.body !== void 0) return "mdx";
510
+ if (entries.length === 1 && !first.slug.includes("/")) return "json-object";
511
+ return "json-array";
512
+ }
513
+ };
514
+
515
+ // src/core/content-store.ts
516
+ var store = null;
517
+ function getStore() {
518
+ if (!store) {
519
+ throw new Error(
520
+ "Content not loaded. Auto-init requires 'nextjs-studio/server' \u2014 use loadContentSync() in a server context, or queryCollection() will auto-init when imported from 'nextjs-studio/server'."
521
+ );
522
+ }
523
+ return store;
524
+ }
525
+ function setStore(index) {
526
+ store = index;
527
+ }
528
+ function hasStore() {
529
+ return store !== null;
530
+ }
531
+ async function loadContent(fsAdapter, config) {
532
+ const index = new ContentIndex(fsAdapter);
533
+ await index.build(config);
534
+ store = index;
535
+ return index;
536
+ }
537
+ function loadContentSync(fsAdapter, config) {
538
+ const index = new ContentIndex(fsAdapter);
539
+ index.buildSync(config);
540
+ store = index;
541
+ return index;
542
+ }
543
+
544
+ // src/core/config-loader.ts
545
+ import { existsSync } from "fs";
546
+ import path2 from "path";
547
+ import { pathToFileURL } from "url";
548
+ function resolveConfigPath(projectRoot) {
549
+ for (const filename of CONFIG_FILENAMES) {
550
+ const fullPath = path2.resolve(projectRoot, filename);
551
+ if (existsSync(fullPath)) return fullPath;
552
+ }
553
+ return void 0;
554
+ }
555
+ async function loadStudioConfig(projectRoot) {
556
+ const configPath = resolveConfigPath(projectRoot);
557
+ if (!configPath) return {};
558
+ return loadConfigFromPath(configPath);
559
+ }
560
+ async function loadConfigFromPath(configPath) {
561
+ try {
562
+ const fileUrl = pathToFileURL(configPath).href;
563
+ const mod = await import(
564
+ /* webpackIgnore: true */
565
+ fileUrl
566
+ );
567
+ const config = mod.default ?? mod.config ?? mod;
568
+ if (typeof config !== "object" || config === null || Array.isArray(config)) {
569
+ return {};
570
+ }
571
+ return config;
572
+ } catch {
573
+ return {};
574
+ }
575
+ }
576
+
577
+ // src/core/query-builder.ts
578
+ import { filter, orderBy, get, slice } from "lodash-es";
579
+
580
+ // src/core/draft-filter.ts
581
+ function isDraft(entry) {
582
+ return entry.data.draft === true;
583
+ }
584
+
585
+ // src/core/query-builder.ts
586
+ var QueryBuilder = class {
587
+ collectionName;
588
+ options = {};
589
+ _excludeDrafts = false;
590
+ _locale;
591
+ constructor(collection) {
592
+ this.collectionName = collection;
593
+ }
594
+ where(conditions) {
595
+ this.options.where = { ...this.options.where, ...conditions };
596
+ return this;
597
+ }
598
+ sort(field, order = "asc") {
599
+ this.options.sort = { field, order };
600
+ return this;
601
+ }
602
+ limit(count) {
603
+ this.options.limit = count;
604
+ return this;
605
+ }
606
+ offset(count) {
607
+ this.options.offset = count;
608
+ return this;
609
+ }
610
+ excludeDrafts() {
611
+ this._excludeDrafts = true;
612
+ return this;
613
+ }
614
+ locale(code) {
615
+ this._locale = code;
616
+ return this;
617
+ }
618
+ all() {
619
+ let entries = [...getStore().getCollection(this.collectionName)];
620
+ if (this._excludeDrafts) {
621
+ entries = entries.filter((entry) => !isDraft(entry));
622
+ }
623
+ if (this._locale) {
624
+ const loc = this._locale;
625
+ entries = entries.filter((entry) => entry.locale === loc);
626
+ }
627
+ if (this.options.where) {
628
+ const conditions = this.options.where;
629
+ entries = filter(
630
+ entries,
631
+ (entry) => Object.entries(conditions).every(([key, value]) => get(entry.data, key) === value)
632
+ );
633
+ }
634
+ if (this.options.sort) {
635
+ const { field, order } = this.options.sort;
636
+ entries = orderBy(entries, [(entry) => get(entry.data, field)], [order]);
637
+ }
638
+ const start = this.options.offset ?? 0;
639
+ const end = this.options.limit ? start + this.options.limit : void 0;
640
+ return slice(entries, start, end).map((e) => ({
641
+ collection: e.collection,
642
+ slug: e.slug,
643
+ path: e.path,
644
+ body: e.body,
645
+ locale: e.locale,
646
+ ...e.data
647
+ }));
648
+ }
649
+ first() {
650
+ return this.limit(1).all()[0];
651
+ }
652
+ one() {
653
+ const result = this.limit(1).all()[0];
654
+ if (result === void 0) {
655
+ throw new Error(`Collection "${this.collectionName}" is empty \u2014 expected exactly one entry.`);
656
+ }
657
+ return result;
658
+ }
659
+ count() {
660
+ return this.all().length;
661
+ }
662
+ };
663
+ var FLUENT_METHODS = /* @__PURE__ */ new Set(["where", "sort", "limit", "offset", "excludeDrafts", "locale"]);
664
+ function wrapWithArrayProxy(builder) {
665
+ let cache = null;
666
+ return new Proxy(builder, {
667
+ get(target, prop, receiver) {
668
+ if (FLUENT_METHODS.has(String(prop))) {
669
+ const method = Reflect.get(target, prop);
670
+ return (...args) => {
671
+ cache = null;
672
+ method.apply(target, args);
673
+ return receiver;
674
+ };
675
+ }
676
+ if (prop in target) {
677
+ const value2 = Reflect.get(target, prop, receiver);
678
+ return typeof value2 === "function" ? value2.bind(target) : value2;
679
+ }
680
+ if (!cache) cache = target.all();
681
+ const value = Reflect.get(cache, prop);
682
+ return typeof value === "function" ? value.bind(cache) : value;
683
+ }
684
+ });
685
+ }
686
+ function queryCollection(name) {
687
+ return wrapWithArrayProxy(new QueryBuilder(name));
688
+ }
689
+
690
+ // src/core/server.ts
691
+ if (!hasStore()) {
692
+ const dir = path3.join(process.cwd(), CONTENTS_DIR);
693
+ const index = new ContentIndex(new FsAdapter(dir));
694
+ index.buildSync();
695
+ setStore(index);
696
+ }
697
+ export {
698
+ ContentIndex,
699
+ FsAdapter,
700
+ loadConfigFromPath,
701
+ loadContent,
702
+ loadContentSync,
703
+ loadStudioConfig,
704
+ queryCollection,
705
+ resolveConfigPath
706
+ };
707
+ //# sourceMappingURL=server.js.map