@websolutespa/bom-next 4.0.0-next.1 → 4.0.0-next.11

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 (527) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +93 -18
  3. package/dist/cache-handler/redis.d.ts +80 -0
  4. package/dist/cache-handler/redis.d.ts.map +1 -0
  5. package/dist/cache-handler/redis.js +164 -0
  6. package/dist/cache-handler/redis.js.map +1 -0
  7. package/dist/cache-handlers/default.d.ts +26 -0
  8. package/dist/cache-handlers/default.d.ts.map +1 -0
  9. package/dist/cache-handlers/default.js +172 -0
  10. package/dist/cache-handlers/default.js.map +1 -0
  11. package/dist/client/client.d.ts +2 -4
  12. package/dist/client/client.d.ts.map +1 -1
  13. package/dist/client/client.js +8 -17
  14. package/dist/client/client.js.map +1 -1
  15. package/dist/client/extra.d.ts +3 -5
  16. package/dist/client/extra.d.ts.map +1 -1
  17. package/dist/client/extra.js +3 -10
  18. package/dist/client/extra.js.map +1 -1
  19. package/dist/client/label.d.ts +3 -5
  20. package/dist/client/label.d.ts.map +1 -1
  21. package/dist/client/label.js +8 -15
  22. package/dist/client/label.js.map +1 -1
  23. package/dist/client/layout.d.ts +3 -5
  24. package/dist/client/layout.d.ts.map +1 -1
  25. package/dist/client/layout.js +3 -10
  26. package/dist/client/layout.js.map +1 -1
  27. package/dist/client/local.collection.d.ts +0 -2
  28. package/dist/client/local.collection.d.ts.map +1 -1
  29. package/dist/client/local.collection.js +2 -4
  30. package/dist/client/local.collection.js.map +1 -1
  31. package/dist/client/metadata.d.ts +13 -4
  32. package/dist/client/metadata.d.ts.map +1 -1
  33. package/dist/client/metadata.js +43 -80
  34. package/dist/client/metadata.js.map +1 -1
  35. package/dist/client/page.d.ts +4 -4
  36. package/dist/client/page.d.ts.map +1 -1
  37. package/dist/client/page.js +3 -10
  38. package/dist/client/page.js.map +1 -1
  39. package/dist/client/useApi.d.ts +7 -7
  40. package/dist/client/useApi.d.ts.map +1 -1
  41. package/dist/client/useApi.js +2 -4
  42. package/dist/client/useApi.js.map +1 -1
  43. package/dist/client/useCollectionApi.d.ts +6 -6
  44. package/dist/client/useCollectionApi.d.ts.map +1 -1
  45. package/dist/client/useCollectionApi.js +2 -4
  46. package/dist/client/useCollectionApi.js.map +1 -1
  47. package/dist/client/useExtra.d.ts +0 -2
  48. package/dist/client/useExtra.d.ts.map +1 -1
  49. package/dist/client/useExtra.js +2 -5
  50. package/dist/client/useExtra.js.map +1 -1
  51. package/dist/client/useHttp.d.ts +0 -2
  52. package/dist/client/useHttp.d.ts.map +1 -1
  53. package/dist/client/useHttp.js +5 -9
  54. package/dist/client/useHttp.js.map +1 -1
  55. package/dist/client/useLabel.d.ts +0 -2
  56. package/dist/client/useLabel.d.ts.map +1 -1
  57. package/dist/client/useLabel.js +2 -5
  58. package/dist/client/useLabel.js.map +1 -1
  59. package/dist/client/useLayout.d.ts +0 -2
  60. package/dist/client/useLayout.d.ts.map +1 -1
  61. package/dist/client/useLayout.js +2 -5
  62. package/dist/client/useLayout.js.map +1 -1
  63. package/dist/client/useLink.d.ts +0 -2
  64. package/dist/client/useLink.d.ts.map +1 -1
  65. package/dist/client/useLink.js +3 -7
  66. package/dist/client/useLink.js.map +1 -1
  67. package/dist/client/useMetaData.d.ts +0 -3
  68. package/dist/client/useMetaData.d.ts.map +1 -1
  69. package/dist/client/useMetaData.js +2 -5
  70. package/dist/client/useMetaData.js.map +1 -1
  71. package/dist/client/usePage.d.ts +33 -33
  72. package/dist/client/usePage.d.ts.map +1 -1
  73. package/dist/client/usePage.js +2 -5
  74. package/dist/client/usePage.js.map +1 -1
  75. package/dist/client/useUser.d.ts +0 -2
  76. package/dist/client/useUser.d.ts.map +1 -1
  77. package/dist/client/useUser.js +2 -5
  78. package/dist/client/useUser.js.map +1 -1
  79. package/dist/client/user.d.ts +15 -8
  80. package/dist/client/user.d.ts.map +1 -1
  81. package/dist/client/user.js +41 -28
  82. package/dist/client/user.js.map +1 -1
  83. package/dist/config/with-bom.d.ts +28 -0
  84. package/dist/config/with-bom.d.ts.map +1 -0
  85. package/dist/config/with-bom.js +64 -0
  86. package/dist/config/with-bom.js.map +1 -0
  87. package/dist/exports/cache-handlers-default.d.ts +2 -0
  88. package/dist/exports/cache-handlers-default.js +2 -0
  89. package/dist/exports/cache-handlers-isr.d.ts +2 -0
  90. package/dist/exports/cache-handlers-isr.js +2 -0
  91. package/dist/exports/client.d.ts +2 -2
  92. package/dist/exports/client.js +2 -3
  93. package/dist/exports/config.d.ts +3 -0
  94. package/dist/exports/config.js +3 -0
  95. package/dist/exports/instrumentation.js +1 -2
  96. package/dist/exports/proxy.d.ts +4 -4
  97. package/dist/exports/proxy.js +3 -4
  98. package/dist/exports/server.d.ts +17 -4
  99. package/dist/exports/server.js +16 -5
  100. package/dist/index.d.ts +2 -2
  101. package/dist/index.js +2 -3
  102. package/dist/instrumentation/client.d.ts +0 -2
  103. package/dist/instrumentation/client.d.ts.map +1 -1
  104. package/dist/instrumentation/client.js +1 -2
  105. package/dist/instrumentation/client.js.map +1 -1
  106. package/dist/instrumentation/sentry/capture.requestError.js +4 -6
  107. package/dist/instrumentation/sentry/capture.requestError.js.map +1 -1
  108. package/dist/instrumentation/sentry/capture.routerTransitionStart.js +4 -4
  109. package/dist/instrumentation/sentry/capture.routerTransitionStart.js.map +1 -1
  110. package/dist/instrumentation/sentry/config.client.js +2 -2
  111. package/dist/instrumentation/sentry/config.client.js.map +1 -1
  112. package/dist/instrumentation/sentry/config.edge.js +2 -2
  113. package/dist/instrumentation/sentry/config.edge.js.map +1 -1
  114. package/dist/instrumentation/sentry/config.server.js +2 -2
  115. package/dist/instrumentation/sentry/config.server.js.map +1 -1
  116. package/dist/instrumentation/server.d.ts +0 -2
  117. package/dist/instrumentation/server.d.ts.map +1 -1
  118. package/dist/instrumentation/server.js +9 -8
  119. package/dist/instrumentation/server.js.map +1 -1
  120. package/dist/instrumentation/types.d.ts +0 -1
  121. package/dist/instrumentation/types.d.ts.map +1 -1
  122. package/dist/lib/breadcrumb.d.ts +0 -3
  123. package/dist/lib/breadcrumb.d.ts.map +1 -1
  124. package/dist/lib/breadcrumb.js +1 -6
  125. package/dist/lib/breadcrumb.js.map +1 -1
  126. package/dist/lib/const.d.ts +1 -2
  127. package/dist/lib/const.d.ts.map +1 -1
  128. package/dist/lib/const.js +1 -10
  129. package/dist/lib/const.js.map +1 -1
  130. package/dist/lib/debug.js +13 -0
  131. package/dist/lib/debug.js.map +1 -0
  132. package/dist/lib/http.d.ts +0 -2
  133. package/dist/lib/http.d.ts.map +1 -1
  134. package/dist/lib/http.js +5 -15
  135. package/dist/lib/http.js.map +1 -1
  136. package/dist/lib/label.d.ts +0 -2
  137. package/dist/lib/label.d.ts.map +1 -1
  138. package/dist/lib/label.js +3 -4
  139. package/dist/lib/label.js.map +1 -1
  140. package/dist/lib/layout.defaults.d.ts +0 -2
  141. package/dist/lib/layout.defaults.d.ts.map +1 -1
  142. package/dist/lib/layout.defaults.js +1 -1
  143. package/dist/lib/layout.defaults.js.map +1 -1
  144. package/dist/lib/link.d.ts +0 -2
  145. package/dist/lib/link.d.ts.map +1 -1
  146. package/dist/lib/link.js +1 -2
  147. package/dist/lib/link.js.map +1 -1
  148. package/dist/lib/meta-data.d.ts +0 -1
  149. package/dist/lib/meta-data.d.ts.map +1 -1
  150. package/dist/lib/open-graph.d.ts +0 -1
  151. package/dist/lib/open-graph.d.ts.map +1 -1
  152. package/dist/lib/page-metadata.d.ts +49 -0
  153. package/dist/lib/page-metadata.d.ts.map +1 -0
  154. package/dist/lib/page-metadata.js +192 -0
  155. package/dist/lib/page-metadata.js.map +1 -0
  156. package/dist/lib/pagination.d.ts +0 -2
  157. package/dist/lib/pagination.d.ts.map +1 -1
  158. package/dist/lib/pagination.js +2 -4
  159. package/dist/lib/pagination.js.map +1 -1
  160. package/dist/lib/route.d.ts +11 -3
  161. package/dist/lib/route.d.ts.map +1 -1
  162. package/dist/lib/route.js +21 -13
  163. package/dist/lib/route.js.map +1 -1
  164. package/dist/lib/store.d.ts +3 -4
  165. package/dist/lib/store.d.ts.map +1 -1
  166. package/dist/lib/store.js +31 -31
  167. package/dist/lib/store.js.map +1 -1
  168. package/dist/lib/structured-data.d.ts +0 -2
  169. package/dist/lib/structured-data.d.ts.map +1 -1
  170. package/dist/lib/ttl-cache.js +59 -0
  171. package/dist/lib/ttl-cache.js.map +1 -0
  172. package/dist/lib/twitter-card.d.ts +0 -1
  173. package/dist/lib/twitter-card.d.ts.map +1 -1
  174. package/dist/lib/utils.d.ts +0 -2
  175. package/dist/lib/utils.d.ts.map +1 -1
  176. package/dist/lib/utils.js +2 -3
  177. package/dist/lib/utils.js.map +1 -1
  178. package/dist/mock.d.ts +1 -1
  179. package/dist/mock.d.ts.map +1 -1
  180. package/dist/proxy/protected-route.d.ts +0 -2
  181. package/dist/proxy/protected-route.d.ts.map +1 -1
  182. package/dist/proxy/protected-route.js +12 -13
  183. package/dist/proxy/protected-route.js.map +1 -1
  184. package/dist/proxy/proxy.d.ts +3 -4
  185. package/dist/proxy/proxy.d.ts.map +1 -1
  186. package/dist/proxy/proxy.js +2 -18
  187. package/dist/proxy/proxy.js.map +1 -1
  188. package/dist/proxy/route-auto-detection.d.ts +6 -3
  189. package/dist/proxy/route-auto-detection.d.ts.map +1 -1
  190. package/dist/proxy/route-auto-detection.js +77 -47
  191. package/dist/proxy/route-auto-detection.js.map +1 -1
  192. package/dist/proxy/route-proxy.d.ts +5 -5
  193. package/dist/proxy/route-proxy.d.ts.map +1 -1
  194. package/dist/proxy/route-proxy.js +95 -36
  195. package/dist/proxy/route-proxy.js.map +1 -1
  196. package/dist/server/cache/cached-types.d.ts +22 -0
  197. package/dist/server/cache/cached-types.d.ts.map +1 -0
  198. package/dist/server/cache/cached-types.js +34 -0
  199. package/dist/server/cache/cached-types.js.map +1 -0
  200. package/dist/server/cache/cached.d.ts +17 -0
  201. package/dist/server/cache/cached.d.ts.map +1 -0
  202. package/dist/server/cache/cached.js +21 -0
  203. package/dist/server/cache/cached.js.map +1 -0
  204. package/dist/server/cache/defaults.js +46 -0
  205. package/dist/server/cache/defaults.js.map +1 -0
  206. package/dist/server/cache/executor.d.ts +54 -0
  207. package/dist/server/cache/executor.d.ts.map +1 -0
  208. package/dist/server/cache/executor.js +84 -0
  209. package/dist/server/cache/executor.js.map +1 -0
  210. package/dist/server/cache/handler.d.ts +16 -0
  211. package/dist/server/cache/handler.d.ts.map +1 -0
  212. package/dist/server/cache/handler.js +103 -0
  213. package/dist/server/cache/handler.js.map +1 -0
  214. package/dist/server/cache/index.d.ts +10 -0
  215. package/dist/server/cache/inspector/filesystem.js +147 -0
  216. package/dist/server/cache/inspector/filesystem.js.map +1 -0
  217. package/dist/server/cache/inspector/index.d.ts +11 -0
  218. package/dist/server/cache/inspector/index.d.ts.map +1 -0
  219. package/dist/server/cache/inspector/index.js +20 -0
  220. package/dist/server/cache/inspector/index.js.map +1 -0
  221. package/dist/server/cache/inspector/redis.js +145 -0
  222. package/dist/server/cache/inspector/redis.js.map +1 -0
  223. package/dist/server/cache/inspector/route-cache-key.js +23 -0
  224. package/dist/server/cache/inspector/route-cache-key.js.map +1 -0
  225. package/dist/server/cache/inspector/types.d.ts +36 -0
  226. package/dist/server/cache/inspector/types.d.ts.map +1 -0
  227. package/dist/server/cache/inspector/types.js +10 -0
  228. package/dist/server/cache/inspector/types.js.map +1 -0
  229. package/dist/server/cache/local-executor.d.ts +28 -0
  230. package/dist/server/cache/local-executor.d.ts.map +1 -0
  231. package/dist/server/cache/local-executor.js +42 -0
  232. package/dist/server/cache/local-executor.js.map +1 -0
  233. package/dist/server/cache/mode/classic.d.ts +16 -0
  234. package/dist/server/cache/mode/classic.d.ts.map +1 -0
  235. package/dist/server/cache/mode/classic.js +49 -0
  236. package/dist/server/cache/mode/classic.js.map +1 -0
  237. package/dist/server/cache/mode/components.d.ts +13 -0
  238. package/dist/server/cache/mode/components.d.ts.map +1 -0
  239. package/dist/server/cache/mode/components.js +51 -0
  240. package/dist/server/cache/mode/components.js.map +1 -0
  241. package/dist/server/cache/profiles.d.ts +44 -0
  242. package/dist/server/cache/profiles.d.ts.map +1 -0
  243. package/dist/server/cache/profiles.js +36 -0
  244. package/dist/server/cache/profiles.js.map +1 -0
  245. package/dist/server/cache/registry.d.ts +33 -0
  246. package/dist/server/cache/registry.d.ts.map +1 -0
  247. package/dist/server/cache/registry.js +42 -0
  248. package/dist/server/cache/registry.js.map +1 -0
  249. package/dist/server/cache/tag-page.d.ts +11 -0
  250. package/dist/server/cache/tag-page.d.ts.map +1 -0
  251. package/dist/server/cache/tag-page.js +24 -0
  252. package/dist/server/cache/tag-page.js.map +1 -0
  253. package/dist/server/context.d.ts +0 -3
  254. package/dist/server/context.d.ts.map +1 -1
  255. package/dist/server/context.js +80 -24
  256. package/dist/server/context.js.map +1 -1
  257. package/dist/server/handlers/auth.handler.d.ts +0 -2
  258. package/dist/server/handlers/auth.handler.d.ts.map +1 -1
  259. package/dist/server/handlers/auth.handler.js +11 -11
  260. package/dist/server/handlers/auth.handler.js.map +1 -1
  261. package/dist/server/handlers/captions.handler.d.ts +0 -2
  262. package/dist/server/handlers/captions.handler.d.ts.map +1 -1
  263. package/dist/server/handlers/captions.handler.js +2 -4
  264. package/dist/server/handlers/captions.handler.js.map +1 -1
  265. package/dist/server/handlers/collection.handler.d.ts +0 -2
  266. package/dist/server/handlers/collection.handler.d.ts.map +1 -1
  267. package/dist/server/handlers/collection.handler.js +2 -4
  268. package/dist/server/handlers/collection.handler.js.map +1 -1
  269. package/dist/server/handlers/error-response.js +2 -6
  270. package/dist/server/handlers/error-response.js.map +1 -1
  271. package/dist/server/handlers/index.handler.d.ts +0 -2
  272. package/dist/server/handlers/index.handler.d.ts.map +1 -1
  273. package/dist/server/handlers/index.handler.js +1 -2
  274. package/dist/server/handlers/index.handler.js.map +1 -1
  275. package/dist/server/handlers/preview.handler.d.ts +0 -2
  276. package/dist/server/handlers/preview.handler.d.ts.map +1 -1
  277. package/dist/server/handlers/preview.handler.js +3 -6
  278. package/dist/server/handlers/preview.handler.js.map +1 -1
  279. package/dist/server/handlers/registry.handler.d.ts +0 -2
  280. package/dist/server/handlers/registry.handler.d.ts.map +1 -1
  281. package/dist/server/handlers/registry.handler.js +76 -22
  282. package/dist/server/handlers/registry.handler.js.map +1 -1
  283. package/dist/server/handlers/revalidate.handler.d.ts +47 -0
  284. package/dist/server/handlers/revalidate.handler.d.ts.map +1 -0
  285. package/dist/server/handlers/revalidate.handler.js +101 -0
  286. package/dist/server/handlers/revalidate.handler.js.map +1 -0
  287. package/dist/server/handlers/route.handler.d.ts +11 -4
  288. package/dist/server/handlers/route.handler.d.ts.map +1 -1
  289. package/dist/server/handlers/route.handler.js +52 -51
  290. package/dist/server/handlers/route.handler.js.map +1 -1
  291. package/dist/server/handlers/sitemap.handler.d.ts +0 -2
  292. package/dist/server/handlers/sitemap.handler.d.ts.map +1 -1
  293. package/dist/server/handlers/sitemap.handler.js +10 -14
  294. package/dist/server/handlers/sitemap.handler.js.map +1 -1
  295. package/dist/server/handlers/static-params.handler.d.ts +0 -3
  296. package/dist/server/handlers/static-params.handler.d.ts.map +1 -1
  297. package/dist/server/handlers/static-params.handler.js +14 -15
  298. package/dist/server/handlers/static-params.handler.js.map +1 -1
  299. package/dist/server/handlers/vars.handler.d.ts +0 -2
  300. package/dist/server/handlers/vars.handler.d.ts.map +1 -1
  301. package/dist/server/handlers/vars.handler.js +4 -5
  302. package/dist/server/handlers/vars.handler.js.map +1 -1
  303. package/dist/server/helpers.d.ts +2 -6
  304. package/dist/server/helpers.d.ts.map +1 -1
  305. package/dist/server/helpers.js +1 -10
  306. package/dist/server/helpers.js.map +1 -1
  307. package/dist/server/json-ld.d.ts +31 -0
  308. package/dist/server/json-ld.d.ts.map +1 -0
  309. package/dist/server/json-ld.js +45 -0
  310. package/dist/server/json-ld.js.map +1 -0
  311. package/dist/server/layout.js +9 -28
  312. package/dist/server/layout.js.map +1 -1
  313. package/dist/server/lazy.d.ts +0 -4
  314. package/dist/server/lazy.d.ts.map +1 -1
  315. package/dist/server/lazy.js +10 -16
  316. package/dist/server/lazy.js.map +1 -1
  317. package/dist/server/local-api.d.ts +0 -2
  318. package/dist/server/local-api.d.ts.map +1 -1
  319. package/dist/server/local-api.js +15 -16
  320. package/dist/server/local-api.js.map +1 -1
  321. package/dist/server/metadata.d.ts +29 -12
  322. package/dist/server/metadata.d.ts.map +1 -1
  323. package/dist/server/metadata.js +26 -20
  324. package/dist/server/metadata.js.map +1 -1
  325. package/dist/server/mixer-payload.d.ts +0 -2
  326. package/dist/server/mixer-payload.d.ts.map +1 -1
  327. package/dist/server/mixer.d.ts +22 -114
  328. package/dist/server/mixer.d.ts.map +1 -1
  329. package/dist/server/mixer.js +121 -271
  330. package/dist/server/mixer.js.map +1 -1
  331. package/dist/server/page.d.ts +0 -3
  332. package/dist/server/page.d.ts.map +1 -1
  333. package/dist/server/page.js +2 -23
  334. package/dist/server/page.js.map +1 -1
  335. package/dist/server/utils.d.ts +0 -2
  336. package/dist/server/utils.d.ts.map +1 -1
  337. package/dist/server/utils.js +2 -4
  338. package/dist/server/utils.js.map +1 -1
  339. package/dist/server/utmz.d.ts +0 -2
  340. package/dist/server/utmz.d.ts.map +1 -1
  341. package/dist/server/utmz.js +1 -1
  342. package/dist/server/utmz.js.map +1 -1
  343. package/dist/types.d.ts +17 -25
  344. package/dist/types.d.ts.map +1 -1
  345. package/package.json +131 -38
  346. package/src/cache-handler/redis.test.ts +153 -0
  347. package/src/cache-handler/redis.ts +282 -0
  348. package/src/cache-handlers/default.test.ts +125 -0
  349. package/src/cache-handlers/default.ts +246 -0
  350. package/src/client/client.tsx +20 -18
  351. package/src/client/extra.tsx +17 -21
  352. package/src/client/label.tsx +20 -24
  353. package/src/client/layout.tsx +18 -22
  354. package/src/client/local.collection.ts +72 -33
  355. package/src/client/metadata.tsx +187 -217
  356. package/src/client/page.tsx +18 -22
  357. package/src/client/useApi.test.tsx +212 -203
  358. package/src/client/useApi.ts +115 -59
  359. package/src/client/useCollectionApi.test.tsx +213 -201
  360. package/src/client/useCollectionApi.ts +135 -66
  361. package/src/client/useExtra.tsx +12 -12
  362. package/src/client/useHttp.ts +78 -54
  363. package/src/client/useLabel.test.tsx +82 -76
  364. package/src/client/useLabel.tsx +12 -12
  365. package/src/client/useLayout.tsx +13 -13
  366. package/src/client/useLink.tsx +16 -13
  367. package/src/client/useMetaData.tsx +12 -12
  368. package/src/client/usePage.tsx +12 -12
  369. package/src/client/useUser.tsx +12 -12
  370. package/src/client/user.test.tsx +63 -0
  371. package/src/client/user.tsx +72 -43
  372. package/src/config/with-bom.test.ts +61 -0
  373. package/src/config/with-bom.ts +68 -0
  374. package/src/exports/cache-handlers-default.ts +3 -0
  375. package/src/exports/cache-handlers-isr.ts +3 -0
  376. package/src/exports/client.ts +19 -20
  377. package/src/exports/config.ts +3 -0
  378. package/src/exports/instrumentation.ts +1 -1
  379. package/src/exports/proxy.ts +4 -5
  380. package/src/exports/server.ts +22 -20
  381. package/src/global.d.ts +6 -6
  382. package/src/index.ts +16 -16
  383. package/src/instrumentation/client.ts +18 -19
  384. package/src/instrumentation/sentry/capture.requestError.ts +9 -6
  385. package/src/instrumentation/sentry/capture.routerTransitionStart.ts +7 -4
  386. package/src/instrumentation/sentry/config.client.ts +9 -9
  387. package/src/instrumentation/sentry/config.edge.ts +9 -9
  388. package/src/instrumentation/sentry/config.server.ts +9 -9
  389. package/src/instrumentation/server.ts +33 -24
  390. package/src/instrumentation/types.ts +11 -12
  391. package/src/lib/breadcrumb.ts +25 -21
  392. package/src/lib/const.ts +18 -18
  393. package/src/lib/debug.ts +11 -0
  394. package/src/lib/http.test.ts +25 -25
  395. package/src/lib/http.ts +127 -85
  396. package/src/lib/label.ts +47 -43
  397. package/src/lib/layout.defaults.ts +167 -167
  398. package/src/lib/link.ts +19 -19
  399. package/src/lib/meta-data.ts +60 -60
  400. package/src/lib/open-graph.ts +165 -165
  401. package/src/lib/page-metadata.test.ts +160 -0
  402. package/src/lib/page-metadata.ts +277 -0
  403. package/src/lib/pagination.ts +80 -78
  404. package/src/lib/route.test.ts +62 -0
  405. package/src/lib/route.ts +117 -83
  406. package/src/lib/store.ts +63 -63
  407. package/src/lib/structured-data.ts +24 -24
  408. package/src/lib/ttl-cache.ts +72 -0
  409. package/src/lib/twitter-card.ts +49 -49
  410. package/src/lib/utils.ts +44 -45
  411. package/src/mock.ts +292 -264
  412. package/src/proxy/protected-route.test.ts +75 -75
  413. package/src/proxy/protected-route.ts +68 -57
  414. package/src/proxy/proxy.test.ts +51 -48
  415. package/src/proxy/proxy.ts +81 -71
  416. package/src/proxy/route-auto-detection.test.ts +55 -0
  417. package/src/proxy/route-auto-detection.ts +222 -126
  418. package/src/proxy/route-proxy.test.ts +104 -0
  419. package/src/proxy/route-proxy.ts +291 -187
  420. package/src/server/cache/cached-types.ts +73 -0
  421. package/src/server/cache/cached.test.ts +115 -0
  422. package/src/server/cache/cached.ts +22 -0
  423. package/src/server/cache/defaults.ts +46 -0
  424. package/src/server/cache/executor.test.ts +134 -0
  425. package/src/server/cache/executor.ts +141 -0
  426. package/src/server/cache/handler.test.ts +122 -0
  427. package/src/server/cache/handler.ts +126 -0
  428. package/src/server/cache/index.ts +39 -0
  429. package/src/server/cache/inspector/filesystem.test.ts +142 -0
  430. package/src/server/cache/inspector/filesystem.ts +214 -0
  431. package/src/server/cache/inspector/index.ts +19 -0
  432. package/src/server/cache/inspector/redis.test.ts +97 -0
  433. package/src/server/cache/inspector/redis.ts +177 -0
  434. package/src/server/cache/inspector/route-cache-key.test.ts +31 -0
  435. package/src/server/cache/inspector/route-cache-key.ts +40 -0
  436. package/src/server/cache/inspector/types.ts +49 -0
  437. package/src/server/cache/local-executor.ts +39 -0
  438. package/src/server/cache/mode/classic.ts +59 -0
  439. package/src/server/cache/mode/components.test.ts +53 -0
  440. package/src/server/cache/mode/components.ts +64 -0
  441. package/src/server/cache/profiles.ts +41 -0
  442. package/src/server/cache/registry.test.ts +66 -0
  443. package/src/server/cache/registry.ts +82 -0
  444. package/src/server/cache/route-parity.test.ts +33 -0
  445. package/src/server/cache/tag-page.ts +23 -0
  446. package/src/server/context.cache.test.ts +79 -0
  447. package/src/server/context.test.ts +645 -467
  448. package/src/server/context.ts +488 -306
  449. package/src/server/context.type-test.ts +12 -6
  450. package/src/server/handlers/auth.handler.ts +32 -27
  451. package/src/server/handlers/captions.handler.ts +36 -32
  452. package/src/server/handlers/collection.handler.test.ts +63 -57
  453. package/src/server/handlers/collection.handler.ts +221 -212
  454. package/src/server/handlers/error-response.ts +50 -45
  455. package/src/server/handlers/index.handler.ts +153 -146
  456. package/src/server/handlers/preview.handler.ts +63 -63
  457. package/src/server/handlers/registry.handler.test.ts +171 -65
  458. package/src/server/handlers/registry.handler.ts +514 -259
  459. package/src/server/handlers/revalidate.handler.ts +148 -0
  460. package/src/server/handlers/route.handler.test.ts +50 -0
  461. package/src/server/handlers/route.handler.ts +188 -161
  462. package/src/server/handlers/sitemap.handler.ts +432 -374
  463. package/src/server/handlers/static-params.cache.test.ts +81 -0
  464. package/src/server/handlers/static-params.handler.ts +123 -111
  465. package/src/server/handlers/vars.handler.ts +174 -167
  466. package/src/server/helpers.ts +97 -58
  467. package/src/server/json-ld.tsx +65 -0
  468. package/src/server/layout.ts +148 -126
  469. package/src/server/lazy.ts +41 -41
  470. package/src/server/local-api.ts +67 -63
  471. package/src/server/metadata.ts +79 -95
  472. package/src/server/mixer-payload.ts +115 -124
  473. package/src/server/mixer-payload.type-test.ts +27 -27
  474. package/src/server/mixer.ts +496 -487
  475. package/src/server/page.ts +148 -131
  476. package/src/server/request-data.test.ts +34 -0
  477. package/src/server/utils.ts +23 -23
  478. package/src/server/utmz.ts +11 -11
  479. package/src/types.ts +363 -313
  480. package/dist/_virtual/rolldown_runtime.js +0 -27
  481. package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +0 -76
  482. package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js.map +0 -1
  483. package/dist/node_modules/deepmerge/dist/cjs.js +0 -94
  484. package/dist/node_modules/deepmerge/dist/cjs.js.map +0 -1
  485. package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js +0 -105
  486. package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js.map +0 -1
  487. package/dist/node_modules/dom-serializer/lib/esm/index.js +0 -141
  488. package/dist/node_modules/dom-serializer/lib/esm/index.js.map +0 -1
  489. package/dist/node_modules/domelementtype/lib/esm/index.js +0 -53
  490. package/dist/node_modules/domelementtype/lib/esm/index.js.map +0 -1
  491. package/dist/node_modules/domhandler/lib/esm/index.js +0 -131
  492. package/dist/node_modules/domhandler/lib/esm/index.js.map +0 -1
  493. package/dist/node_modules/domhandler/lib/esm/node.js +0 -308
  494. package/dist/node_modules/domhandler/lib/esm/node.js.map +0 -1
  495. package/dist/node_modules/entities/lib/esm/decode.js +0 -364
  496. package/dist/node_modules/entities/lib/esm/decode.js.map +0 -1
  497. package/dist/node_modules/entities/lib/esm/decode_codepoint.js +0 -59
  498. package/dist/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  499. package/dist/node_modules/entities/lib/esm/escape.js +0 -93
  500. package/dist/node_modules/entities/lib/esm/escape.js.map +0 -1
  501. package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -6
  502. package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  503. package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -6
  504. package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  505. package/dist/node_modules/html-to-text/lib/html-to-text.js +0 -1828
  506. package/dist/node_modules/html-to-text/lib/html-to-text.js.map +0 -1
  507. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js +0 -435
  508. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js.map +0 -1
  509. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js +0 -739
  510. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js.map +0 -1
  511. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js +0 -20
  512. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js.map +0 -1
  513. package/dist/node_modules/leac/lib/leac.js +0 -101
  514. package/dist/node_modules/leac/lib/leac.js.map +0 -1
  515. package/dist/node_modules/parseley/lib/parseley.js +0 -314
  516. package/dist/node_modules/parseley/lib/parseley.js.map +0 -1
  517. package/dist/node_modules/peberminta/lib/core.js +0 -149
  518. package/dist/node_modules/peberminta/lib/core.js.map +0 -1
  519. package/dist/node_modules/selderee/lib/selderee.js +0 -325
  520. package/dist/node_modules/selderee/lib/selderee.js.map +0 -1
  521. package/src/lib/payload.config.ts +0 -12
  522. package/src/server/mock/category.ts +0 -34
  523. package/src/server/mock/collection.ts +0 -21
  524. package/src/server/mock/page.ts +0 -62
  525. package/src/server/mock/route.ts +0 -36
  526. package/src/server/mock/store.ts +0 -159
  527. package/src/server/session/session.ts +0 -101
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # @websolutespa/bom-next
2
2
 
3
+ ## 4.0.0-next.11
4
+
5
+ ### Minor Changes
6
+
7
+ - 67f9535: Site side of the Next.js cache panel, named cached functions, and support for both caching models (classic ISR and Cache Components).
8
+
9
+ - **Page tags.** `createPageContext` and `createLayoutContext` tag every rendered page from its route: market, locale, collection, document, route, category ancestors and the layout collections. Decorators that list other documents call `tagPage([collectionTag('…')])`.
10
+ - **Cache endpoint.** `getCacheHandler()` (`/api/-cache`, Bearer `MIXER_SECRET`) reports the cached pages, functions and process caches of the instance (file system, Redis, or none on Vercel) and applies cache actions. `revalidate` maps to `revalidateTag(tag, 'max')`, `invalidate` to `revalidateTag(tag, { expire: 0 })`; actions can also revalidate paths, clear process caches and warm pages after the response. `registerIntrumentation()` registers it in process for the Bowl admin, so sites need no change.
11
+ - **Next.js 16.4 route cache.** The inspector reads both `.next/server/app` and the runtime route cache (`.next/server/route-cache/<kind>/<sha256(source route)>/$/<path>`).
12
+ - **Cached functions.** `bomCached(name, fn, { life, tags, resultTags })` caches a data function by name, with a BOM lifetime and tags, and `documentTags(collection, result)` builds document tags from Payload results. Lifetimes are named profiles (`bomProfiles`: `bom-layout`, `bom-page`, `bom-listing`, `bom-static`).
13
+ - **`withBom(nextConfig)`** (`@websolutespa/bom-next/config`) picks the implementation:
14
+ - Classic ISR: `unstable_cache`.
15
+ - `cacheComponents: true`: `'use cache'`, `cacheLife` and `cacheTag`, the BOM `cacheLife` profiles, the BOM `cacheHandlers.default`, and cached page and layout reads in `createPageContext`.
16
+ - Under Cache Components, `getStaticParams` returns at least one real route per template and fails clearly when a template has no published page.
17
+ - With `REDIS_URL` at build time, it sets the shared Redis cache handler.
18
+ - **Redis handlers.**
19
+ - `@websolutespa/bom-next/cache-handlers/isr` honours the second argument of `revalidateTag` (stale-while-revalidate versus expire now) and writes meta keys the panel lists.
20
+ - `@websolutespa/bom-next/cache-handlers/default` (`'use cache'`) shares the same tag keys, in memory or in Redis.
21
+ - **Fix.** `resolveRoute` handles a populated page document (it produced `[object Object]`).
22
+ - **Optional peer:** `redis`.
23
+
24
+ ## 4.0.0-next.10
25
+
26
+ ## 4.0.0-next.9
27
+
28
+ ## 4.0.0-next.8
29
+
30
+ ### Patch Changes
31
+
32
+ - Cleanup: unused dependencies, peers and unreachable code removed.
33
+ - `payload-utils`: the `jsdom` peer accepts `^26.1.0 || ^30.1.3`, and `htmlToLexical` imports it on use, so routes that never convert html don't load it. jsdom 30 fails with `ERR_REQUIRE_ESM` on Vercel's Node runtime; projects can stay on jsdom 26 and drop a `jsdom` override.
34
+ - Peers that nothing imports are gone: `uuid` (search, seo, thron), `@payloadcms/ui` (seed), `react-error-boundary` (mixer-ui, mixer-emails), `@websolutespa/payload-utils` (live-preview).
35
+ - `bom-mixer-hooks` declares `@types/html-to-text`, which it got from the web apps before.
36
+ - `bom-mixer-llm` publishes only the default mocks.
37
+ - Source files that no export reached are removed: mixer-ui carousel, navbar/menubar, media-image-next, useThemeForm, lazy-loader-client; mixer-llm card and product cta, Background, scroller-lenis, cors, useBlock, useComponent.
38
+ - `bom-cli`: nodemon is a dev dependency (it was installed in every project); no theme or storybook apps.
39
+ - `bom-next`: `jose` and `transliteration` dropped with the unused mock and session code.
40
+ - `eslint-config` is the legacy ESLint 10 config; projects on oxlint and oxfmt use `@websolutespa/oxc`.
41
+
42
+ ## 4.0.0-next.7
43
+
44
+ ## 4.0.0-next.6
45
+
46
+ ### Minor Changes
47
+
48
+ - 4.x on the 3.1 stack: Payload 3.91, Next.js 16.4.2, React 19.2.9, TypeScript 6, Vitest 5, ESLint 10 (see the 3.1.0 and 3.1.1 notes below for the breaking changes of the stack).
49
+ - `@websolutespa/bom-next`: peers are ranges (`next ^16.3.3`, `payload ^3.91.0`, `react ^19.2.1`); `@sentry/nextjs` is an optional peer, loaded only when `NEXT_PUBLIC_SENTRY_DSN` is set; `jose` and `transliteration` are declared and pinned; no `next/dist` internals.
50
+ - `@websolutespa/bom-next`: local api reads use the logged in user or, without one, the guest user (roles `guest`), like the http api with `STORE_API_KEY`.
51
+ - `@websolutespa/payload-plugin-bowl`: the mixer context is resolved for reads with a user only: the api key user (guest), the logged in user, or for the local api of bom-next the same users. Without a user the request is still being authenticated (since Payload 3.90 the jwt user lookup receives the request query).
52
+
53
+ ### Patch Changes
54
+
55
+ - a82309c: The package ships `dist/**/*.js` and `.d.ts` again, as its `exports` map expects: tsdown 0.21 emitted `.mjs`/`.d.mts`, so `@websolutespa/bom-next` could not be resolved (ERR_MODULE_NOT_FOUND on `dist/index.js`).
56
+ - 4.x consumers type check and create projects from the 4.x samples.
57
+ - `IUser` and `IEndUser` accept the bom-core user contract (`UserWithRoles`, `IEndUser`) as well as the generated bowl documents: a user typed with `@websolutespa/bom-core`'s `IEndUser` (e.g. a login response) can be passed to `useUser().setUser` again, and `user.roles` is typed on both. Payload 3.91's generated types require `collection: 'users' | 'end_users'`, which the bom-core contract does not have.
58
+ - `useLabel()` returns the same function while the labels do not change: effects that list `label` in their dependencies ran again on every `LabelProvider` render (e.g. a toast shown twice).
59
+ - `schema-dts` is a peer dependency (`^2.1.0`) of `@websolutespa/bom-next`, like the mixer packages: its public types use it, and a project on `schema-dts` 1.x got `TS2321: Excessive stack depth` instead of a peer warning. Projects on 1.x move to 2.1.0.
60
+ - `bom create` (4.x) falls back to the `bom-next` branch samples when its release tag does not exist.
61
+
62
+ ## 4.0.0-next.5
63
+
64
+ ### Patch Changes
65
+
66
+ - feat: renamed API handlers for image, mock, preview, revalidate, vars, and session endpoints
67
+ - Updated dependencies
68
+ - @websolutespa/payload-plugin-bowl@4.0.0-next.4
69
+
70
+ ## 4.0.0-next.4
71
+
72
+ ### Patch Changes
73
+
74
+ - Helpers no longer read request data; only the template does and passes it down.
75
+ - `getPageMetadata` / `getMetadata` read only `params` (no more `DYNAMIC_SERVER_USAGE` on static/ISR pages). A dynamic template awaits its own `searchParams` and calls `buildPageMetadata(page, layout, { searchParams })`.
76
+ - `getPayload` no longer calls `headers()`: in draft mode pass `headers` from the template.
77
+ - `draft` defaults to `false` in `createPageContext` and `createLayoutContext`; `'auto'` (reads `draftMode()`) is an explicit opt-in.
78
+ - Session helpers (`createSession`, `getSession`, `hasValidSession`, `updateSession`, `deleteSession`) take the cookie store as an argument.
79
+ - `detectedRoute` cookie values with dot segments (`..`, also percent-encoded) or backslashes are rejected.
80
+
81
+ - Updated dependencies
82
+ - @websolutespa/payload-plugin-bowl@4.0.0-next.3
83
+ - @websolutespa/payload-db-memory@3.0.3
84
+ - @websolutespa/payload-utils@4.0.0-next.0
85
+ - @websolutespa/bom-core@4.0.0-next.1
86
+
87
+ ## 4.0.0-next.3
88
+
89
+ ### Patch Changes
90
+
91
+ - Proxy: route resolutions are cached per instance (`BOM_ROUTE_CACHE_TTL` seconds, default 30; misses and redirects at most 10) with concurrent lookups shared. Draft requests and server errors are never cached.
92
+ - Proxy: the resolver query values (`pathname`, `href`, `hrefBeforeRedirect`) are now encoded, and CMS redirects go to the target and status returned by the resolver instead of always to `/`.
93
+ - `routeAutoDetection`: a valid `detectedRoute` cookie (relative paths only) redirects straight away without route, market or GeoIP lookups; GeoIP calls have a 2 s timeout and are cached per IP for one hour.
94
+ - Per-request diagnostics (proxy, local API calls, context cache) are logged in development only.
95
+ - Server context: `getRoutes` and `getMixerContext` read routes from the Bowl route store instead of re-reading every page collection and media document. Routes no longer depend on `market`, `locale` or `user`, and unpublished pages and category routes are not part of the public routes anymore.
96
+ - Server context: locale, market, category and route reads run in parallel; the result is cached per market, locale and user for `MEMORY_CACHE_DURATION` seconds and cleared as soon as the route store changes (also from other instances through Redis). Draft contexts are never cached, only shared within a request. The `_mixer` and `_route` globals are replaced by `_bomMixerContext`.
97
+ - `decorateLazyComponents` runs the lazy decorators in parallel, keeping the component order.
98
+ - Metadata: new `getPageMetadata`, `buildPageMetadata` and `inheritParentMetadata` build plain-text title and description, canonical (keeping `pagination[page]`), `alternates.languages` with `x-default`, robots, keywords, Open Graph and Twitter on the server. `getMetadata` is now a wrapper of `getPageMetadata`, so its result contains all of them instead of title and description only; Open Graph and Twitter fields left empty by the page are inherited from the parent metadata.
99
+ - Metadata: `JsonLd` and `buildPageStructuredData` render JSON-LD in Server Components.
100
+ - `MetaDataProvider` no longer uses `next/compat/router` (pass the query string through the new `search` prop), takes `brand.url` from `layout.homeHref`, reads `meta.robots` or `meta.robot`, converts HTML to text without bullets, link URLs or uppercased headings, and uses uppercase hreflang countries (`it-IT`).
101
+ - `layout.homeHref` exposes the root page href for the current market and locale.
102
+ - `html-to-text` and `schema-dts` are declared as dependencies.
103
+ - Registry: aliases are read from `components.json` (or `UI_REGISTRY_COMPONENTS_JSON` and `UI_REGISTRY_SOURCE_ALIAS`) and rewritten to registry imports; only import and export specifiers are rewritten. Items that import app code the registry cannot ship are reported in `meta.unresolvedImports`, or hidden with `UI_REGISTRY_SKIP_UNRESOLVED`.
104
+ - `UserProvider` reads `/auth/me` once per browser session and accepts `initialUser`; `invalidateUser()` forces a new read.
105
+ - Updated dependencies
106
+ - @websolutespa/payload-plugin-bowl@4.0.0-next.2
107
+ - @websolutespa/bom-core@4.0.0-next.1
108
+
109
+ ## 4.0.0-next.2
110
+
111
+ ### Patch Changes
112
+
113
+ - feat: add route template handling and tests for static parameters
114
+
3
115
  ## 4.0.0-next.1
4
116
 
5
117
  ### Minor Changes
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # @websolutespa/bom-next
2
-
3
- [![npm version](https://badge.fury.io/js/%40websolutespa%2Fbom-next.svg)](https://badge.fury.io/js/%40websolutespa%2Fbom-next)
4
-
5
- [![status alpha](https://img.shields.io/badge/status-alpha-red.svg)](https://shields.io/)
6
-
7
- Next module of the [BOM Repository](https://github.com/websolutespa/bom) by [websolute](https://www.websolute.com/).
8
-
9
- ---
10
-
11
- ##### *this library is for internal usage and not production ready*
1
+ # @websolutespa/bom-next
2
+
3
+ [![npm version](https://badge.fury.io/js/%40websolutespa%2Fbom-next.svg)](https://badge.fury.io/js/%40websolutespa%2Fbom-next)
4
+
5
+ [![status alpha](https://img.shields.io/badge/status-alpha-red.svg)](https://shields.io/)
6
+
7
+ Next module of the [BOM Repository](https://github.com/websolutespa/bom) by [websolute](https://www.websolute.com/).
8
+
9
+ ---
10
+
11
+ ##### _this library is for internal usage and not production ready_
12
12
 
13
13
  ## Page context
14
14
 
@@ -27,13 +27,88 @@ const { page, layout, label, link } = await createPageContext(market, locale, 'p
27
27
  const { layout } = await createLayoutContext(market, locale, { config }); // depth: DEFAULT_LAYOUT_DEPTH (1)
28
28
  ```
29
29
 
30
- | option | default | |
31
- |---|---|---|
32
- | `depth` | `2` | `0` ids only, `1` direct relations/uploads (including those inside blocks), `2` relations of relations |
33
- | `select` | – | Payload select; envelope fields (`id`, `slug`, `title`, `category`, `markets`, `meta`, `template`) are always read |
34
- | `populate` | – | per-collection select for populated documents |
35
- | `draft` | `'auto'` | `true` / `false`, or `'auto'` to read Next `draftMode()` |
36
- | `layout` | `{ depth: 1 }` | layout options, or `false` to skip the layout |
30
+ | option | default | |
31
+ | ---------- | -------------- | ------------------------------------------------------------------------------------------------------------------ |
32
+ | `depth` | `2` | `0` ids only, `1` direct relations/uploads (including those inside blocks), `2` relations of relations |
33
+ | `select` | – | Payload select; envelope fields (`id`, `slug`, `title`, `category`, `markets`, `meta`, `template`) are always read |
34
+ | `populate` | – | per-collection select for populated documents |
35
+ | `draft` | `'auto'` | `true` / `false`, or `'auto'` to read Next `draftMode()` |
36
+ | `layout` | `{ depth: 1 }` | layout options, or `false` to skip the layout |
37
37
 
38
38
  Page and layout reads are memoized per request, so `getMetadata` and the page component share them when called with the same options.
39
39
  To bind `config` once: `export const { createPageContext, createLayoutContext, getMetadata } = createContextHelpers({ config, defaults: { depth: 2 } });`
40
+
41
+ ## Metadata
42
+
43
+ `getPageMetadata` (and `getMetadata`, its `config`-first form) returns a `generateMetadata` function that renders on the server: plain-text title and description, canonical (keeping `?pagination[page]=N` after the first page), `alternates.languages` with one `locale-COUNTRY` entry per market country plus `x-default`, robots, keywords, Open Graph and Twitter.
44
+
45
+ ```ts
46
+ import { getPageMetadata, JsonLd, buildPageStructuredData } from '@websolutespa/bom-next/server';
47
+
48
+ export const generateMetadata = getPageMetadata('post_detail', {
49
+ config,
50
+ metadata: {
51
+ brand: { name: 'Example', logo: '/logo.png', twitterName: '@example' },
52
+ extend: (metadata, { page }) => ({ ...metadata, title: `${metadata.title} | Example` }),
53
+ },
54
+ });
55
+
56
+ // JSON-LD in the page component
57
+ <JsonLd data={buildPageStructuredData(page, layout, { brand: { name: 'Example' } })} />
58
+ ```
59
+
60
+ `buildPageMetadata(page, layout, options)` is the same builder for custom routes. URLs are resolved against `NEXT_PUBLIC_URL` unless `baseUrl` is passed. Robots come from `meta.robots`, or `meta.robot` (the `@payloadcms/plugin-seo` field).
61
+
62
+ The client `MetaDataProvider` only computes values for `useMetaData`; the `next/head` based `Meta`, `OpenGraph` and `StructuredData` components of the mixer packages render nothing in the App Router.
63
+
64
+ `layout.homeHref` is the root page href for the current market and locale; prefer it to `layout.topLevelHrefs.<slug>`, which is keyed by collection slug or template.
65
+
66
+ ## Routing proxy
67
+
68
+ `createRouteProxy` resolves each request through `/api/-route` and caches the result per instance: found routes for `BOM_ROUTE_CACHE_TTL` seconds (default `30`, `0` disables), misses and redirects for at most 10 seconds. Draft requests and server errors are never cached. CMS redirects send the browser to the target returned by the resolver.
69
+
70
+ `routeAutoDetection` redirects `/` straight from the `detectedRoute` cookie when present; otherwise it detects the market (GeoIP, 2 s timeout, cached per IP for one hour) and the locale.
71
+
72
+ The server context (`getContext`) reads routes from the Bowl route store and caches the rest per market, locale and user for `MEMORY_CACHE_DURATION` seconds (default 300). Any route store change, local or from another instance through Redis, clears it. Draft contexts are never cached.
73
+
74
+ ## Cache
75
+
76
+ Pages are tagged from their route by `createPageContext` and `createLayoutContext`, and invalidated by the Bowl change hooks and the Bowl cache panel (`/admin/cache`). The site exposes its side of the panel with one route:
77
+
78
+ ```ts
79
+ // src/app/api/-cache/route.ts
80
+ import { getCacheHandler } from '@websolutespa/bom-next/server';
81
+
82
+ export const { GET, POST } = getCacheHandler();
83
+ export const dynamic = 'force-dynamic';
84
+ ```
85
+
86
+ - `tagPage(tags)` adds tags to the page being rendered, for example a decorator that lists another collection: `tagPage([collectionTag('post_detail')])`.
87
+ - `bomCached(name, fn, { life, tags, resultTags })` caches a data function by name. `life` is a BOM profile (`bom-layout`, `bom-page`, `bom-listing`, `bom-static`, see `bomProfiles`) or an inline profile. `documentTags(collection, result)` tags a result by its documents. Every entry carries `bom:fn:<name>`, so the panel lists and revalidates it.
88
+ - `withBom(nextConfig)` (`@websolutespa/bom-next/config`) wires the caching model:
89
+ - **Classic ISR** (default): `bomCached` uses `unstable_cache`, templates keep `generateStaticParams` and `export const revalidate`.
90
+ - **`cacheComponents: true`**: `bomCached` and `tagPage` use `'use cache'`, `cacheLife` and `cacheTag`; the BOM profiles are registered as `cacheLife` profiles, `cacheHandlers.default` is the BOM `'use cache'` handler, and `createPageContext` reads public pages and layouts through cached functions. Templates must drop `export const revalidate`. `getStaticParams` returns at least one route per template (Cache Components refuses an empty list), so every template needs one published page at build time.
91
+ - **`REDIS_URL` at build time**: `cacheHandler` is the shared Redis handler (`@websolutespa/bom-next/cache-handlers/isr`), which applies `revalidateTag(tag, 'max')` as stale-while-revalidate across instances; `'use cache'` entries share its tag keys.
92
+ - `registerIntrumentation()` registers the in-process cache executor; Bowl uses `/api/-cache` (Bearer `MIXER_SECRET`) when it runs in another process.
93
+
94
+ The cache panel reads the file-system cache (`.next/server/app` and the Next.js 16.4 runtime route cache under `.next/server/route-cache`), the Redis handlers' meta keys, or nothing on Vercel. `next dev` has no ISR cache: check the panel after `next build && next start`.
95
+
96
+ ## Environment
97
+
98
+ Per-request diagnostics (proxy, local API calls, context cache) are logged in development only (`NODE_ENV` unset or `development`).
99
+
100
+ | Variable | Default | |
101
+ | ----------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------ |
102
+ | `BOM_ROUTE_CACHE_TTL` | `30` | proxy route cache lifetime in seconds, `0` disables it |
103
+ | `MEMORY_CACHE_DURATION` | `300` | server context cache lifetime in seconds |
104
+ | `BOM_USE_CACHE_MAX_BYTES` | `67108864` | memory limit of the in-process `'use cache'` handler (Cache Components without Redis) |
105
+ | `MIXER_SECRET` | – | Bearer token of `/api/-revalidate` and `/api/-cache` |
106
+ | `REDIS_URL`, `REDIS_PREFIX` | – | shared Redis cache handlers (set at build time for `withBom`) and key prefix |
107
+ | `UI_REGISTRY_SOURCE_DIR` | `packages/ui/src` | registry source directory |
108
+ | `UI_REGISTRY_COMPONENTS_JSON` | nearest `components.json` | shadcn config whose aliases (e.g. `@/ui/lib/utils`) are mapped to registry imports |
109
+ | `UI_REGISTRY_SOURCE_ALIAS` | – | extra import prefix pointing at the registry source, e.g. `@/ui/` |
110
+ | `UI_REGISTRY_SKIP_UNRESOLVED` | – | `1` hides registry items that import app code; otherwise they are listed with `meta.unresolvedImports` |
111
+
112
+ ## User
113
+
114
+ `UserProvider` reads `/api/auth/me` once per page load, shared by every mount and client navigation. Pass `initialUser` (a user or `null`) when the server already knows it to skip the request; `setUser` and `invalidateUser()` keep the cached value current after login or logout.
@@ -0,0 +1,80 @@
1
+ //#region src/cache-handler/redis.d.ts
2
+ /**
3
+ * Next.js incremental cache handler (ISR pages, route handlers, `fetch` and `unstable_cache` entries) backed by
4
+ * Redis, shared by every instance of a site. Set it in `next.config` with `withBom()`, or directly:
5
+ * `cacheHandler: require.resolve('@websolutespa/bom-next/cache-handlers/isr')`, `cacheMaxMemorySize: 0`.
6
+ *
7
+ * - Entries: `${REDIS_PREFIX}:next:<key>`, written as `{ lastModified, tags, revalidate, value }` (in this
8
+ * order: the cache panel reads the head of the value without parsing the page).
9
+ * - Meta: `${REDIS_PREFIX}:next-meta:<key>`, a small JSON per entry that the cache panel lists with SCAN.
10
+ * - Tags: `${REDIS_PREFIX}:next-tag:<tag>` is when the tag expired (the next request waits for a fresh render),
11
+ * `${REDIS_PREFIX}:next-tag-stale:<tag>` when it went stale (served once more, regenerated in the background).
12
+ * `revalidateTag(tag, 'max')` sets the stale time; `revalidateTag(tag, { expire: 0 })`, `updateTag` and
13
+ * `revalidatePath` set the expiry. Next.js only applies stale tags of its own file-system cache, so this handler
14
+ * reports a stale entry by moving its `lastModified` back past its revalidate time.
15
+ * - Redis down: reads miss and writes are dropped, so pages still render (uncached) instead of failing.
16
+ */
17
+ /** The subset of a `redis` client this handler uses (injectable for tests). */
18
+ type RedisLike = {
19
+ isReady: boolean;
20
+ get(key: string): Promise<string | null>;
21
+ mGet(keys: string[]): Promise<(string | null)[]>;
22
+ set(key: string, value: string, options?: {
23
+ EX?: number;
24
+ }): Promise<unknown>;
25
+ mSet(entries: [string, string][]): Promise<unknown>;
26
+ del(key: string | string[]): Promise<unknown>;
27
+ };
28
+ type CacheHandlerContext = {
29
+ tags?: string[];
30
+ softTags?: string[];
31
+ revalidate?: number | false;
32
+ cacheControl?: {
33
+ revalidate?: number | false;
34
+ expire?: number;
35
+ };
36
+ };
37
+ /** Serializes a cache entry, keeping Buffers and Maps (RSC payloads, segment data). */
38
+ declare function encode(entry: unknown): string;
39
+ /** Restores a cache entry written by {@link encode}. */
40
+ declare function decode<T = unknown>(raw: string): T;
41
+ /** The fields of a Next.js cache value this handler reads; the rest is stored as it is. */
42
+ type CacheValue = {
43
+ kind?: string;
44
+ status?: number;
45
+ revalidate?: number | false;
46
+ headers?: Record<string, string | string[] | undefined>;
47
+ };
48
+ /** Explicit tags of a value: the context tags plus the `x-next-cache-tags` header of pages and route handlers. */
49
+ /** A connecting client used only while ready: awaiting `connect()` would hang every request while Redis is down. */
50
+ declare function getRedisClient(): Promise<RedisLike | undefined>;
51
+ /** Builds the handler class around a client getter, so tests can inject one. */
52
+ declare function createRedisCacheHandler(getClient?: () => Promise<RedisLike | undefined>, prefix?: string): {
53
+ new (_ctx?: unknown): {
54
+ get(key: string, ctx?: CacheHandlerContext): Promise<{
55
+ lastModified: number;
56
+ value: CacheValue;
57
+ } | null>;
58
+ set(key: string, data: CacheValue | null, ctx?: CacheHandlerContext): Promise<void>;
59
+ revalidateTag(tags: string | string[], durations?: {
60
+ expire?: number;
61
+ }): Promise<void>;
62
+ resetRequestCache(): void;
63
+ };
64
+ };
65
+ declare const _default: {
66
+ new (_ctx?: unknown): {
67
+ get(key: string, ctx?: CacheHandlerContext): Promise<{
68
+ lastModified: number;
69
+ value: CacheValue;
70
+ } | null>;
71
+ set(key: string, data: CacheValue | null, ctx?: CacheHandlerContext): Promise<void>;
72
+ revalidateTag(tags: string | string[], durations?: {
73
+ expire?: number;
74
+ }): Promise<void>;
75
+ resetRequestCache(): void;
76
+ };
77
+ };
78
+ //#endregion
79
+ export { RedisLike, _default, createRedisCacheHandler, decode, encode, getRedisClient };
80
+ //# sourceMappingURL=redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.d.ts","names":[],"sources":["../../src/cache-handler/redis.ts"],"mappings":";;AAiBA;;;;;;;;;;;;;;;KAAY,SAAA;EACV,OAAA;EACA,GAAA,CAAI,GAAA,WAAc,OAAA;EAClB,IAAA,CAAK,IAAA,aAAiB,OAAA;EACtB,GAAA,CAAI,GAAA,UAAa,KAAA,UAAe,OAAA;IAAY,EAAA;EAAA,IAAgB,OAAA;EAC5D,IAAA,CAAK,OAAA,uBAA8B,OAAA;EACnC,GAAA,CAAI,GAAA,sBAAyB,OAAA;AAAA;AAAA,KAGnB,mBAAA;EACV,IAAA;EACA,QAAA;EACA,UAAA;EACA,YAAA;IAAiB,UAAA;IAA6B,MAAA;EAAA;AAAA;;iBA0ChC,MAAA,CAAO,KAAA;;iBAKP,MAAA,aAAA,CAAoB,GAAA,WAAc,CAAA;;KAK7C,UAAA;EACH,IAAA;EACA,MAAA;EACA,UAAA;EACA,OAAA,GAAU,MAAA;AAAA;;;iBA0CU,cAAA,CAAA,GAAkB,OAAA,CAAQ,SAAA;AAjD/C;AAAA,iBAmFe,uBAAA,CACd,SAAA,SAAiB,OAAA,CAAQ,SAAA,eACzB,MAAA;EAAA;qBAMuB,GAAA,GAAQ,mBAAA,GAAmB,OAAA;;;;qBA2C3B,IAAA,EAAQ,UAAA,SAAiB,GAAA,GAAQ,mBAAA,GAAmB,OAAA;2CAuC9B,SAAA;MAAgB,MAAA;IAAA,IAAiB,OAAA;;;;cA2B/E,QAAA;EAAA;qBA7GwB,GAAA,GAAQ,mBAAA,GAAmB,OAAA;;;;qBA2C3B,IAAA,EAAQ,UAAA,SAAiB,GAAA,GAAQ,mBAAA,GAAmB,OAAA;2CAuC9B,SAAA;MAAgB,MAAA;IAAA,IAAiB,OAAA"}
@@ -0,0 +1,164 @@
1
+ //#region src/cache-handler/redis.ts
2
+ const tagsHeader = "x-next-cache-tags";
3
+ function redisPrefix(env = process.env) {
4
+ return env.REDIS_PREFIX ? `${env.REDIS_PREFIX}:` : "";
5
+ }
6
+ const keys = (prefix) => ({
7
+ entry: `${prefix}next:`,
8
+ meta: `${prefix}next-meta:`,
9
+ expired: `${prefix}next-tag:`,
10
+ stale: `${prefix}next-tag-stale:`
11
+ });
12
+ function replacer(_key, value) {
13
+ if (value instanceof Map) return {
14
+ __t: "map",
15
+ d: Array.from(value.entries())
16
+ };
17
+ if (value && typeof value === "object" && value.type === "Buffer" && Array.isArray(value.data)) return {
18
+ __t: "buf",
19
+ d: Buffer.from(value.data).toString("base64")
20
+ };
21
+ return value;
22
+ }
23
+ function reviver(_key, value) {
24
+ if (value && typeof value === "object" && value.__t === "map") return new Map(value.d);
25
+ if (value && typeof value === "object" && value.__t === "buf") return Buffer.from(value.d, "base64");
26
+ return value;
27
+ }
28
+ /** Serializes a cache entry, keeping Buffers and Maps (RSC payloads, segment data). */
29
+ function encode(entry) {
30
+ return JSON.stringify(entry, replacer);
31
+ }
32
+ /** Restores a cache entry written by {@link encode}. */
33
+ function decode(raw) {
34
+ return JSON.parse(raw, reviver);
35
+ }
36
+ /** Explicit tags of a value: the context tags plus the `x-next-cache-tags` header of pages and route handlers. */
37
+ function entryTags(value, ctx) {
38
+ const tags = new Set(ctx?.tags ?? []);
39
+ const header = value?.headers?.[tagsHeader];
40
+ if (typeof header === "string") header.split(",").filter(Boolean).forEach((tag) => tags.add(tag));
41
+ return Array.from(tags);
42
+ }
43
+ function revalidateOf(value, ctx) {
44
+ const revalidate = ctx?.cacheControl?.revalidate ?? ctx?.revalidate ?? value?.revalidate;
45
+ return typeof revalidate === "number" || revalidate === false ? revalidate : null;
46
+ }
47
+ let sharedClient;
48
+ /** A connecting client used only while ready: awaiting `connect()` would hang every request while Redis is down. */
49
+ async function getRedisClient() {
50
+ if (!process.env.REDIS_URL) return;
51
+ if (!sharedClient) {
52
+ const { createClient } = await import("redis");
53
+ const client = createClient({
54
+ url: process.env.REDIS_URL,
55
+ disableOfflineQueue: true,
56
+ socket: {
57
+ connectTimeout: 2e3,
58
+ reconnectStrategy: (retries) => Math.min(retries * 200, 5e3)
59
+ }
60
+ });
61
+ sharedClient = client;
62
+ let logged = false;
63
+ client.on("error", (error) => {
64
+ if (!logged) {
65
+ console.warn("[cache-handler] redis unavailable, serving uncached:", error.message);
66
+ logged = true;
67
+ }
68
+ });
69
+ client.on("ready", () => {
70
+ logged = false;
71
+ });
72
+ client.connect().catch(() => {});
73
+ }
74
+ return sharedClient.isReady ? sharedClient : void 0;
75
+ }
76
+ /** Builds the handler class around a client getter, so tests can inject one. */
77
+ function createRedisCacheHandler(getClient = getRedisClient, prefix = redisPrefix()) {
78
+ const k = keys(prefix);
79
+ return class RedisCacheHandler {
80
+ constructor(_ctx) {}
81
+ async get(key, ctx) {
82
+ const client = await getClient();
83
+ if (!client?.isReady) return null;
84
+ try {
85
+ const raw = await client.get(k.entry + key);
86
+ if (!raw) return null;
87
+ const entry = decode(raw);
88
+ const tags = [...new Set([
89
+ ...entry.tags ?? [],
90
+ ...ctx?.tags ?? [],
91
+ ...ctx?.softTags ?? []
92
+ ])];
93
+ if (!tags.length) return {
94
+ lastModified: entry.lastModified,
95
+ value: entry.value
96
+ };
97
+ const [expired, stale] = await Promise.all([client.mGet(tags.map((tag) => k.expired + tag)), client.mGet(tags.map((tag) => k.stale + tag))]);
98
+ const now = Date.now();
99
+ if (expired.some((at) => at && Number(at) > entry.lastModified && Number(at) <= now)) return null;
100
+ if (stale.some((at) => at && Number(at) > entry.lastModified)) {
101
+ if (typeof entry.revalidate !== "number") return null;
102
+ return {
103
+ lastModified: Math.min(entry.lastModified, now - entry.revalidate * 1e3 - 1),
104
+ value: entry.value
105
+ };
106
+ }
107
+ return {
108
+ lastModified: entry.lastModified,
109
+ value: entry.value
110
+ };
111
+ } catch {
112
+ return null;
113
+ }
114
+ }
115
+ async set(key, data, ctx) {
116
+ const client = await getClient();
117
+ if (!client?.isReady) return;
118
+ try {
119
+ if (data == null) {
120
+ await client.del([k.entry + key, k.meta + key]);
121
+ return;
122
+ }
123
+ const entry = {
124
+ lastModified: Date.now(),
125
+ tags: entryTags(data, ctx),
126
+ revalidate: revalidateOf(data, ctx),
127
+ value: data
128
+ };
129
+ const raw = encode(entry);
130
+ const expire = ctx?.cacheControl?.expire;
131
+ const ttl = typeof expire === "number" && Number.isFinite(expire) && expire > 0 ? { EX: Math.ceil(expire) } : void 0;
132
+ const meta = {
133
+ lastModified: entry.lastModified,
134
+ tags: entry.tags,
135
+ revalidate: entry.revalidate,
136
+ kind: data.kind ?? null,
137
+ status: typeof data.status === "number" ? data.status : null,
138
+ size: Buffer.byteLength(raw)
139
+ };
140
+ await Promise.all([client.set(k.entry + key, raw, ttl), client.set(k.meta + key, JSON.stringify(meta), ttl)]);
141
+ } catch {}
142
+ }
143
+ async revalidateTag(tags, durations) {
144
+ const list = (Array.isArray(tags) ? tags : [tags]).filter(Boolean);
145
+ const client = await getClient();
146
+ if (!client?.isReady || !list.length) return;
147
+ const now = Date.now();
148
+ const writes = [];
149
+ for (const tag of list) if (durations) {
150
+ writes.push([k.stale + tag, String(now)]);
151
+ if (durations.expire !== void 0) writes.push([k.expired + tag, String(now + durations.expire * 1e3)]);
152
+ } else writes.push([k.expired + tag, String(now)]);
153
+ try {
154
+ await client.mSet(writes);
155
+ } catch {}
156
+ }
157
+ resetRequestCache() {}
158
+ };
159
+ }
160
+ var redis_default = createRedisCacheHandler();
161
+ //#endregion
162
+ export { createRedisCacheHandler, decode, redis_default as default, encode, getRedisClient, keys, redisPrefix };
163
+
164
+ //# sourceMappingURL=redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.js","names":[],"sources":["../../src/cache-handler/redis.ts"],"sourcesContent":["/**\n * Next.js incremental cache handler (ISR pages, route handlers, `fetch` and `unstable_cache` entries) backed by\n * Redis, shared by every instance of a site. Set it in `next.config` with `withBom()`, or directly:\n * `cacheHandler: require.resolve('@websolutespa/bom-next/cache-handlers/isr')`, `cacheMaxMemorySize: 0`.\n *\n * - Entries: `${REDIS_PREFIX}:next:<key>`, written as `{ lastModified, tags, revalidate, value }` (in this\n * order: the cache panel reads the head of the value without parsing the page).\n * - Meta: `${REDIS_PREFIX}:next-meta:<key>`, a small JSON per entry that the cache panel lists with SCAN.\n * - Tags: `${REDIS_PREFIX}:next-tag:<tag>` is when the tag expired (the next request waits for a fresh render),\n * `${REDIS_PREFIX}:next-tag-stale:<tag>` when it went stale (served once more, regenerated in the background).\n * `revalidateTag(tag, 'max')` sets the stale time; `revalidateTag(tag, { expire: 0 })`, `updateTag` and\n * `revalidatePath` set the expiry. Next.js only applies stale tags of its own file-system cache, so this handler\n * reports a stale entry by moving its `lastModified` back past its revalidate time.\n * - Redis down: reads miss and writes are dropped, so pages still render (uncached) instead of failing.\n */\n\n/** The subset of a `redis` client this handler uses (injectable for tests). */\nexport type RedisLike = {\n isReady: boolean;\n get(key: string): Promise<string | null>;\n mGet(keys: string[]): Promise<(string | null)[]>;\n set(key: string, value: string, options?: { EX?: number }): Promise<unknown>;\n mSet(entries: [string, string][]): Promise<unknown>;\n del(key: string | string[]): Promise<unknown>;\n};\n\nexport type CacheHandlerContext = {\n tags?: string[];\n softTags?: string[];\n revalidate?: number | false;\n cacheControl?: { revalidate?: number | false; expire?: number };\n};\n\nexport const tagsHeader = 'x-next-cache-tags';\n\nexport function redisPrefix(env: NodeJS.ProcessEnv = process.env): string {\n return env.REDIS_PREFIX ? `${env.REDIS_PREFIX}:` : '';\n}\n\nexport const keys = (prefix: string) => ({\n entry: `${prefix}next:`,\n meta: `${prefix}next-meta:`,\n expired: `${prefix}next-tag:`,\n stale: `${prefix}next-tag-stale:`,\n});\n\nfunction replacer(_key: string, value: unknown) {\n if (value instanceof Map) {\n return { __t: 'map', d: Array.from(value.entries()) };\n }\n if (\n value &&\n typeof value === 'object' &&\n (value as { type?: string }).type === 'Buffer' &&\n Array.isArray((value as { data?: unknown }).data)\n ) {\n return { __t: 'buf', d: Buffer.from((value as { data: number[] }).data).toString('base64') };\n }\n return value;\n}\n\nfunction reviver(_key: string, value: unknown) {\n if (value && typeof value === 'object' && (value as { __t?: string }).__t === 'map') {\n return new Map((value as { d: [unknown, unknown][] }).d);\n }\n if (value && typeof value === 'object' && (value as { __t?: string }).__t === 'buf') {\n return Buffer.from((value as { d: string }).d, 'base64');\n }\n return value;\n}\n\n/** Serializes a cache entry, keeping Buffers and Maps (RSC payloads, segment data). */\nexport function encode(entry: unknown): string {\n return JSON.stringify(entry, replacer);\n}\n\n/** Restores a cache entry written by {@link encode}. */\nexport function decode<T = unknown>(raw: string): T {\n return JSON.parse(raw, reviver) as T;\n}\n\n/** The fields of a Next.js cache value this handler reads; the rest is stored as it is. */\ntype CacheValue = {\n kind?: string;\n status?: number;\n revalidate?: number | false;\n headers?: Record<string, string | string[] | undefined>;\n};\n\ntype StoredEntry = {\n lastModified: number;\n tags: string[];\n revalidate: number | false | null;\n value: CacheValue;\n};\n\n/** Explicit tags of a value: the context tags plus the `x-next-cache-tags` header of pages and route handlers. */\nexport function entryTags(\n value: CacheValue | null | undefined,\n ctx: CacheHandlerContext | undefined\n): string[] {\n const tags = new Set(ctx?.tags ?? []);\n const header = value?.headers?.[tagsHeader];\n if (typeof header === 'string') {\n header\n .split(',')\n .filter(Boolean)\n .forEach((tag) => tags.add(tag));\n }\n return Array.from(tags);\n}\n\nfunction revalidateOf(\n value: CacheValue,\n ctx: CacheHandlerContext | undefined\n): number | false | null {\n const revalidate = ctx?.cacheControl?.revalidate ?? ctx?.revalidate ?? value?.revalidate;\n return typeof revalidate === 'number' || revalidate === false ? revalidate : null;\n}\n\ntype ConnectingClient = RedisLike & {\n on(event: 'error' | 'ready', listener: (error: Error) => void): unknown;\n connect(): Promise<unknown>;\n};\n\nlet sharedClient: ConnectingClient | undefined;\n\n/** A connecting client used only while ready: awaiting `connect()` would hang every request while Redis is down. */\nexport async function getRedisClient(): Promise<RedisLike | undefined> {\n if (!process.env.REDIS_URL) {\n return undefined;\n }\n if (!sharedClient) {\n const { createClient } = await import('redis');\n const client = createClient({\n url: process.env.REDIS_URL,\n // fail fast while disconnected instead of queueing commands behind a dead socket\n disableOfflineQueue: true,\n socket: {\n connectTimeout: 2000,\n reconnectStrategy: (retries: number) => Math.min(retries * 200, 5000),\n },\n }) as unknown as ConnectingClient;\n sharedClient = client;\n let logged = false;\n client.on('error', (error: Error) => {\n if (!logged) {\n console.warn('[cache-handler] redis unavailable, serving uncached:', error.message);\n logged = true;\n }\n });\n client.on('ready', () => {\n logged = false;\n });\n client.connect().catch(() => {\n /* reported by the error listener, retried by reconnectStrategy */\n });\n }\n return sharedClient.isReady ? sharedClient : undefined;\n}\n\n/** Builds the handler class around a client getter, so tests can inject one. */\nexport function createRedisCacheHandler(\n getClient: () => Promise<RedisLike | undefined> = getRedisClient,\n prefix = redisPrefix()\n) {\n const k = keys(prefix);\n return class RedisCacheHandler {\n constructor(_ctx?: unknown) {}\n\n async get(key: string, ctx?: CacheHandlerContext) {\n const client = await getClient();\n if (!client?.isReady) {\n return null;\n }\n try {\n const raw = await client.get(k.entry + key);\n if (!raw) {\n return null;\n }\n const entry = decode<StoredEntry>(raw);\n const tags = [\n ...new Set([...(entry.tags ?? []), ...(ctx?.tags ?? []), ...(ctx?.softTags ?? [])]),\n ];\n if (!tags.length) {\n return { lastModified: entry.lastModified, value: entry.value };\n }\n const [expired, stale] = await Promise.all([\n client.mGet(tags.map((tag) => k.expired + tag)),\n client.mGet(tags.map((tag) => k.stale + tag)),\n ]);\n const now = Date.now();\n // an expiry set after this entry was written, and already reached, is a miss: blocking regeneration\n if (expired.some((at) => at && Number(at) > entry.lastModified && Number(at) <= now)) {\n return null;\n }\n if (stale.some((at) => at && Number(at) > entry.lastModified)) {\n if (typeof entry.revalidate !== 'number') {\n // never revalidated by time: a stale entry can only be regenerated by a miss\n return null;\n }\n // serve once more and regenerate in the background: Next.js sees an entry past its revalidate time\n return {\n lastModified: Math.min(entry.lastModified, now - entry.revalidate * 1000 - 1),\n value: entry.value,\n };\n }\n return { lastModified: entry.lastModified, value: entry.value };\n } catch {\n return null;\n }\n }\n\n async set(key: string, data: CacheValue | null, ctx?: CacheHandlerContext) {\n const client = await getClient();\n if (!client?.isReady) {\n return;\n }\n try {\n if (data == null) {\n await client.del([k.entry + key, k.meta + key]);\n return;\n }\n const entry: StoredEntry = {\n lastModified: Date.now(),\n tags: entryTags(data, ctx),\n revalidate: revalidateOf(data, ctx),\n value: data,\n };\n const raw = encode(entry);\n const expire = ctx?.cacheControl?.expire;\n const ttl =\n typeof expire === 'number' && Number.isFinite(expire) && expire > 0\n ? { EX: Math.ceil(expire) }\n : undefined;\n const meta = {\n lastModified: entry.lastModified,\n tags: entry.tags,\n revalidate: entry.revalidate,\n kind: data.kind ?? null,\n status: typeof data.status === 'number' ? data.status : null,\n size: Buffer.byteLength(raw),\n };\n await Promise.all([\n client.set(k.entry + key, raw, ttl),\n client.set(k.meta + key, JSON.stringify(meta), ttl),\n ]);\n } catch {\n // a failed write only costs a regeneration on the next request\n }\n }\n\n async revalidateTag(tags: string | string[], durations?: { expire?: number }) {\n const list = (Array.isArray(tags) ? tags : [tags]).filter(Boolean);\n const client = await getClient();\n if (!client?.isReady || !list.length) {\n return;\n }\n const now = Date.now();\n const writes: [string, string][] = [];\n for (const tag of list) {\n if (durations) {\n writes.push([k.stale + tag, String(now)]);\n if (durations.expire !== undefined) {\n writes.push([k.expired + tag, String(now + durations.expire * 1000)]);\n }\n } else {\n writes.push([k.expired + tag, String(now)]);\n }\n }\n try {\n await client.mSet(writes);\n } catch {\n // the entries expire on their own\n }\n }\n\n resetRequestCache() {}\n };\n}\n\nexport default createRedisCacheHandler();\n"],"mappings":"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"}
@@ -0,0 +1,26 @@
1
+ import { RedisLike } from "../cache-handler/redis.js";
2
+ import { CacheHandler } from "next/cache";
3
+
4
+ //#region src/cache-handlers/default.d.ts
5
+ /**
6
+ * `cacheHandlers.default` for `'use cache'` (Cache Components), set by `withBom()`. In memory per process by
7
+ * default (bounded, least recently used out first); shared in Redis when `REDIS_URL` is set. Tag state uses the
8
+ * same keys as the ISR handler (`next-tag:` expired, `next-tag-stale:` stale), so one `revalidateTag` reaches
9
+ * pages and cached functions on every instance. It also keeps a small index of what it stores, which the cache
10
+ * panel lists (`listUseCacheEntries`).
11
+ */
12
+ type UseCacheMeta = {
13
+ key: string;
14
+ tags: string[];
15
+ timestamp: number;
16
+ revalidate: number;
17
+ expire: number;
18
+ size: number;
19
+ };
20
+ /** Entries of this process (memory mode) for the cache panel. */
21
+ declare function listUseCacheEntries(): UseCacheMeta[];
22
+ declare function createUseCacheHandler(getClient?: () => Promise<RedisLike | undefined>, prefix?: string, useRedis?: boolean): CacheHandler;
23
+ declare const _default: CacheHandler;
24
+ //#endregion
25
+ export { _default, createUseCacheHandler, listUseCacheEntries };
26
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","names":[],"sources":["../../src/cache-handlers/default.ts"],"mappings":";;;;;;AAUA;;;;;KAAY,YAAA;EACV,GAAA;EACA,IAAA;EACA,SAAA;EACA,UAAA;EACA,MAAA;EACA,IAAA;AAAA;AAmEF;AAAA,iBAvBgB,mBAAA,CAAA,GAAuB,YAAA;AAAA,iBAuBvB,qBAAA,CACd,SAAA,SAAiB,OAAA,CAAQ,SAAA,eACzB,MAAA,WACA,QAAA,aACC,YAAA;AAAA,cA4JF,QAAA"}