@riverbankcms/sdk 0.179.0 → 0.181.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 (240) hide show
  1. package/README.md +2 -2
  2. package/dist/_dts/{BlocksIslandsHydrator-DKwgs95u.d.ts → BlocksIslandsHydrator-CVCasDPz.d.ts} +1 -1
  3. package/dist/_dts/{Page-lWenra5i.d.ts → Page-Dtj2Ui3S.d.ts} +7 -7
  4. package/dist/_dts/{SdkPreviewMode-BRxhRw4I.d.ts → SdkPreviewMode-D1f_60WW.d.ts} +3 -2
  5. package/dist/_dts/{client-qWn7xAwJ.d.ts → client-Chr9pNVW.d.ts} +288 -121
  6. package/dist/_dts/{content-types-DL6GIvTm.d.ts → content-types-kjccgopX.d.ts} +2 -2
  7. package/dist/_dts/{contracts-CzWyAiJj.d.ts → contracts-BodaiS00.d.ts} +3 -3
  8. package/dist/_dts/{generatePageMetadata-CBKd0cJ4.d.ts → generatePageMetadata-BS6kaJFp.d.ts} +2 -2
  9. package/dist/_dts/{index-DCiSHd-C.d.ts → index-Brl6_I2j.d.ts} +5 -4
  10. package/dist/_dts/{index-CaCum9mM.d.ts → index-CJkefwYh.d.ts} +2 -2
  11. package/dist/_dts/{index-7CDBZGb-.d.ts → index-D1WpKwQe.d.ts} +1 -1
  12. package/dist/_dts/{index-BU9uAkHB.d.ts → index-DG0OvBs0.d.ts} +8 -8
  13. package/dist/_dts/{index-BYnG_vF5.d.ts → index-Diqt0PvG.d.ts} +1 -1
  14. package/dist/_dts/{index-CZgJrhzT.d.ts → index-Dy50xUMK.d.ts} +2 -2
  15. package/dist/_dts/{loadContent-CPKbFQyq.d.ts → loadContent-BgxshKrA.d.ts} +7 -7
  16. package/dist/_dts/{request-BjKBCS7t.d.ts → request-CA0izds5.d.ts} +4561 -1390
  17. package/dist/_dts/{resolveBlockData-DupbMCup.d.ts → resolveBlockData-ChQmwEd3.d.ts} +5 -5
  18. package/dist/_dts/{resolvePageContent-BqNyCHi8.d.ts → resolvePageContent-BvGyvblj.d.ts} +1 -1
  19. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  20. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client.d.ts +7 -7
  22. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  23. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  24. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  26. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  27. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  28. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -2
  29. package/dist/_dts/sdk/src/index.d.ts +104 -8
  30. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  31. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  32. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  33. package/dist/_dts/sdk/src/next/index.d.ts +84 -53
  34. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  35. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  36. package/dist/_dts/sdk/src/portal/client.d.ts +43 -56
  37. package/dist/_dts/sdk/src/portal/index.d.ts +3 -18
  38. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  39. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  42. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  43. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  44. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  46. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  47. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  48. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  49. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  50. package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
  51. package/dist/_dts/sdk/src/server.d.ts +5 -5
  52. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  53. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  54. package/dist/_dts/{serviceBookingOutline-YcsIjvn1.d.ts → serviceBookingOutline-BgFbJQhU.d.ts} +8 -7
  55. package/dist/_dts/{types-B7e6Lmo5.d.ts → types-CQrsP1x_.d.ts} +3 -3
  56. package/dist/_dts/{types-CT-KOxl_.d.ts → types-CgS3xLk8.d.ts} +7 -2
  57. package/dist/_dts/{types-BOxSq-Bq.d.ts → types-R65DKjPn.d.ts} +9 -8
  58. package/dist/_dts/{validation-Dz6qccue.d.ts → validation-6LTIbuBA.d.ts} +4 -4
  59. package/dist/client/{BlocksIslandsHydrator-1XifJg6V.mjs → BlocksIslandsHydrator-DqZPz6oW.mjs} +19 -19
  60. package/dist/client/{BookingMailingListNote-BsbEgagJ.mjs → BookingMailingListNote-uWfR2kaG.mjs} +177 -70
  61. package/dist/client/{BookingQuestionFields-C8IbeLHj.mjs → BookingQuestionFields-CyNIKw6k.mjs} +23 -82
  62. package/dist/client/CalendarAction-D_Glwvz2.mjs +105 -0
  63. package/dist/client/{CalendarNavigationChevron-Bbqij1XQ.mjs → CalendarNavigationChevron-BGCX3zwG.mjs} +6 -6
  64. package/dist/client/{CheckboxChoice-BZPLCgTU.mjs → CheckboxChoice-C8i4NraK.mjs} +1 -1
  65. package/dist/client/{DemoBookingPortalAccess-uA9H8LIL.mjs → DemoBookingPortalAccess-DFLPyuqe.mjs} +18 -10
  66. package/dist/client/{EventCalendar.client-yoSI77ov.mjs → EventCalendar.client-zDL4-t-B.mjs} +10 -10
  67. package/dist/client/{EventCombined.client-HeCNlliq.mjs → EventCombined.client-uciDKLID.mjs} +60 -10
  68. package/dist/client/{EventEmbeddedCheckoutStep-BDnicDM6.mjs → EventEmbeddedCheckoutStep-BGkbUhuw.mjs} +1 -1
  69. package/dist/client/{EventItem-Duhk1vnF.mjs → EventItem-CwzrjcRw.mjs} +8 -7
  70. package/dist/client/{EventListWeekNavigation-BiutEqPK.mjs → EventListWeekNavigation-ChvcnPma.mjs} +1 -1
  71. package/dist/client/{EventListing.client-B5ln77jG.mjs → EventListing.client-DA57Qoyx.mjs} +3 -3
  72. package/dist/client/{EventListing.view-hUDhNtMv.mjs → EventListing.view-DZ0qMFF4.mjs} +8 -211
  73. package/dist/client/{EventRegistrationPayment-DqtX1vB2.mjs → EventRegistrationPayment-DSqCJL8E.mjs} +1657 -403
  74. package/dist/client/{Page-ChJ2TGVk.mjs → Page-C7mygH_f.mjs} +536 -287
  75. package/dist/client/{ProtectedSubmitButton-De6AzhE6.mjs → ProtectedSubmitButton-BNnKuir8.mjs} +1 -1
  76. package/dist/client/{SiteTermsAgreementField-CDBU31xW.mjs → SiteTermsAgreementField-B4z-e4Wq.mjs} +27 -24
  77. package/dist/client/{StepIndicator-JQA-VuEH.mjs → StepIndicator-Dn_DY4oY.mjs} +1 -1
  78. package/dist/client/{StepIndicator-2Dl9zon2.mjs → StepIndicator-atfDU82W.mjs} +21 -13
  79. package/dist/client/{ThemedButton-CnSa7o-I.mjs → ThemedButton-PFOhXktM.mjs} +1 -33
  80. package/dist/client/{accessibleSurfaces-Wl8-_OVJ.mjs → accessibleSurfaces-n6kS6Hct.mjs} +77 -1
  81. package/dist/client/{accordion-B6SqU49k.mjs → accordion-CsW8U3ff.mjs} +1 -1
  82. package/dist/client/{booking-form.client-DrEOjQ3N.mjs → booking-form.client-cBWM392H.mjs} +442 -86
  83. package/dist/client/bookingCalendar--aWnqFDn.mjs +180 -0
  84. package/dist/client/{bookingForm-drZBwEZW.mjs → bookingForm-DgySpp6C.mjs} +4 -4
  85. package/dist/client/bookings.mjs +51 -15
  86. package/dist/client/{boxStyleClassNames-DEh45w16.mjs → boxStyleClassNames-BpGVdLFD.mjs} +2 -2
  87. package/dist/client/{carousel-C-YJliD-.mjs → carousel-DJoleFV3.mjs} +2 -2
  88. package/dist/client/{carousel.client-DMtGYTTM.mjs → carousel.client-BtLwHefX.mjs} +1 -1
  89. package/dist/client/{cart-acGFWK9R.mjs → cart-EO5o6uPH.mjs} +3 -3
  90. package/dist/client/{cart.client-BzlOGP2j.mjs → cart.client-D_gPw45z.mjs} +1 -1
  91. package/dist/client/{checkout-SEontwhy.mjs → checkout-NVfZW0kR.mjs} +3 -3
  92. package/dist/client/{checkout.client-C0Qvh-d4.mjs → checkout.client-DD3JuqOy.mjs} +1 -1
  93. package/dist/client/{checkoutUrls-yUKeq1N9.mjs → checkoutUrls-z2gXvlGw.mjs} +1 -1
  94. package/dist/client/client.mjs +306 -196
  95. package/dist/client/constants-CoOkvw__.mjs +100 -0
  96. package/dist/client/{context-DTrwaQtg.mjs → context-CRhn9qzS.mjs} +922 -388
  97. package/dist/client/{dateFormatting-Cg8E1r9l.mjs → dateFormatting-BnWB4L1s.mjs} +15 -25
  98. package/dist/client/{demoPortalMagicLink-D0kOJYOX.mjs → demoPortalMagicLink-CWDGSTBu.mjs} +2 -3
  99. package/dist/client/{enhanceHeaderSection-DyrpZ7ks.mjs → enhanceHeaderSection-tdP_-Z9o.mjs} +4 -5
  100. package/dist/client/{event-registration.client-RLZQWi2V.mjs → event-registration.client-D7YYKySQ.mjs} +2084 -1640
  101. package/dist/client/{eventCalendar-CphYnImh.mjs → eventCalendar-CsAfu5d0.mjs} +4 -4
  102. package/dist/client/{eventCombined-BvqjASB_.mjs → eventCombined-VXJB5CoS.mjs} +4 -4
  103. package/dist/client/{eventListing-BaNAoC_M.mjs → eventListing-B3KIZNfY.mjs} +4 -4
  104. package/dist/client/{eventRegistration-COMHoRl6.mjs → eventRegistration-BP-dEk1c.mjs} +4 -4
  105. package/dist/client/{form-DyH2juYT.mjs → form-DM8Zbxbv.mjs} +3 -3
  106. package/dist/client/{form.client-DBwzkB0M.mjs → form.client-e2z_Tlgk.mjs} +5 -5
  107. package/dist/client/{form.parts-CY4kX3mh.mjs → form.parts-Ctljy1a3.mjs} +3 -3
  108. package/dist/client/gifting/client.mjs +32 -29
  109. package/dist/client/{gifting-CIx4V378.mjs → gifting-DWIsqQru.mjs} +4 -4
  110. package/dist/client/{gifting.client-BEVPpzJM.mjs → gifting.client-QsSWF0uA.mjs} +5 -5
  111. package/dist/client/{gifting.parts-VnORjnZK.mjs → gifting.parts-CedLgwa_.mjs} +2 -2
  112. package/dist/client/{headerSection-DGcJfRS8.mjs → headerSection-DAkRkwb-.mjs} +2 -2
  113. package/dist/client/{mediaAssets-B99AP7ai.mjs → mediaAssets-COfQolI3.mjs} +1 -1
  114. package/dist/client/{mediaContext-Fusweriw.mjs → mediaContext-DzvnjYXm.mjs} +1 -1
  115. package/dist/client/{newsletter-form.client-BvEDkjiD.mjs → newsletter-form.client-WYja9-WN.mjs} +7 -7
  116. package/dist/client/{newsletter-form.interactive-DCO1lErD.mjs → newsletter-form.interactive-RuM86VAv.mjs} +37 -44
  117. package/dist/client/{newsletter-form.parts-BIy4IUT3.mjs → newsletter-form.parts-2petDnWv.mjs} +2 -2
  118. package/dist/client/{newsletterForm-CoTXDNFS.mjs → newsletterForm-BUbXdA_e.mjs} +3 -3
  119. package/dist/client/{lookSurfaces-IqT_SVnX.mjs → noop-Dl4mZ-rr.mjs} +257 -49
  120. package/dist/client/portal/client.mjs +11779 -6745
  121. package/dist/client/portalOrders-COGn4BKG.mjs +596 -0
  122. package/dist/client/portalRoutes-D72yvtDh.mjs +862 -0
  123. package/dist/client/{product-detail.client-YHQ2aKX1.mjs → product-detail.client-pOAryevt.mjs} +1 -1
  124. package/dist/client/{product-list.client-DxoZw1vF.mjs → product-list.client-CcUpUiud.mjs} +1 -1
  125. package/dist/client/{productDetail-DjuFvkey.mjs → productDetail-BZJCfqat.mjs} +3 -3
  126. package/dist/client/{productList-DE9GEFoZ.mjs → productList-CiRs3mNb.mjs} +3 -3
  127. package/dist/client/{propsDecoder-Cyag_HOs.mjs → propsDecoder--uHW4tFM.mjs} +2 -2
  128. package/dist/client/{registry.server-BPwV-0Pp.mjs → registry.server-CDNNd8wC.mjs} +318 -235
  129. package/dist/client/{renderableMediaAssetAdmission-BlfqYLJW.mjs → renderableMediaAssetAdmission-BsOWd9lf.mjs} +1 -1
  130. package/dist/client/rendering/client.mjs +26 -26
  131. package/dist/client/rendering/islands.mjs +1 -1
  132. package/dist/client/rendering.mjs +16 -8
  133. package/dist/client/{richText-coerce-NrRqDeOg.mjs → richText-coerce-CQGE_wHV.mjs} +2 -1
  134. package/dist/client/{routeIslandApiConfig-BWq5gKFK.mjs → routeIslandApiConfig-BtCg87-N.mjs} +1 -1
  135. package/dist/client/{runtimeResponse-D2j2-mOk.mjs → runtimeResponse-DL_ARBpa.mjs} +1 -1
  136. package/dist/client/{runtimeResponse-DtWSfWSZ.mjs → runtimeResponse-Ds9cmBUf.mjs} +1 -1
  137. package/dist/client/{shop-C3wM0Hr4.mjs → shop-Rx_gEMK8.mjs} +3 -3
  138. package/dist/client/{shop-commerce-34YvcpbX.mjs → shop-commerce-D8evQnMT.mjs} +53 -16
  139. package/dist/client/{shop-commerce-store-B7xHksOs.mjs → shop-commerce-store-C9PcsSTj.mjs} +22 -5
  140. package/dist/client/{shop-discount-apply.state-BiBnozfO.mjs → shop-discount-apply.state-D5CtGfJI.mjs} +2 -2
  141. package/dist/client/{shop.client-C0v88nLd.mjs → shop.client-D4lzQ9oY.mjs} +17 -39
  142. package/dist/client/{shopShared-Ct-BRNez.mjs → shopShared-BVbq7Nm-.mjs} +2 -2
  143. package/dist/client/spam-protection.mjs +1 -1
  144. package/dist/client/src-Al4ooTl_.mjs +164 -0
  145. package/dist/client/{src-CCtanNlD.mjs → src-ZSqRK3dD.mjs} +345 -92
  146. package/dist/client/{timetableModel-lhE29TNT.mjs → timetableModel-BQJrSK0K.mjs} +205 -80
  147. package/dist/client/{shop-add-feedback-DvC2kP1K.mjs → urlParams-C2QHo1Pa.mjs} +1 -42
  148. package/dist/client/{useAvailableSlots-BelJviOT.mjs → useAvailableSlots-Dm3lKJKR.mjs} +3 -24
  149. package/dist/client/{useDiscountCodeUi-rQRE1-Ho.mjs → useDiscountCodeUi-klgfGn7f.mjs} +1 -1
  150. package/dist/client/{useEventPagination-C4rS2Xxl.mjs → useEventPagination-Jnjt7_ly.mjs} +8 -8
  151. package/dist/client/{view-LJVHVqsy.mjs → view-CC_yQLSA.mjs} +4 -4
  152. package/dist/client/{wizardSteps-CNDsxeJH.mjs → wizardSteps-BliJOzEX.mjs} +2512 -675
  153. package/dist/preview-next/before-render.mjs +1 -0
  154. package/dist/preview-next/client/{LocationPickerEnvironment-BHAT81Wx.mjs → LocationPickerEnvironment-BW3dRFIv.mjs} +1 -1
  155. package/dist/preview-next/client/{MapLibreEditMap-B52hkdIZ.mjs → MapLibreEditMap-Db9BHyXh.mjs} +2 -2
  156. package/dist/preview-next/client/{PageSectionToolbar-C4TtBPN-.mjs → PageSectionToolbar-BhL0uADo.mjs} +4 -4
  157. package/dist/preview-next/client/{PreviewEditorSidebar-D6fkE59-.mjs → PreviewEditorSidebar-Ct8eIm0i.mjs} +8 -7
  158. package/dist/preview-next/client/{PreviewEditorUI-amcDlj0O.mjs → PreviewEditorUI-BS32G4V9.mjs} +5 -5
  159. package/dist/preview-next/client/{PreviewShell-DeQjx4zk.mjs → PreviewShell-RL0WfZXD.mjs} +7 -7
  160. package/dist/preview-next/client/{SdkPreviewModeRuntime-Cx0SXnoX.mjs → SdkPreviewModeRuntime-MK_gHeGy.mjs} +39 -7
  161. package/dist/preview-next/client/{lucide-react-McYZeSMb.mjs → lucide-react-00FF_oar.mjs} +13 -1
  162. package/dist/preview-next/client/{previewAssistantSlot-aqpU34WI.mjs → previewAssistantSlot-CQyS8pcq.mjs} +10318 -3719
  163. package/dist/preview-next/client/{previewChromeRoot-D3Gy_Rs0.mjs → previewChromeRoot-BSxp3Mfu.mjs} +1 -1
  164. package/dist/preview-next/client/runtime.mjs +3 -3
  165. package/dist/preview-next/client/{sdk-runtime-Dzx_RrN7.mjs → sdk-runtime-DKnTzy74.mjs} +2 -2
  166. package/dist/preview-next/client/{siteStyleAccess-LHedw83e.mjs → siteStyleAccess-BlmbvbLN.mjs} +37 -25
  167. package/dist/preview-next/client/{useAutosaveStatus-DpSd9aVk.mjs → useAutosaveStatus-D-7GwZOQ.mjs} +1 -1
  168. package/dist/preview-next/client/{useOpenBlockForSetup-BGZn5AT1.mjs → useOpenBlockForSetup-BNZtGM5g.mjs} +2 -2
  169. package/dist/preview-next/container-responsive.css +292 -170
  170. package/dist/preview-next/keepAlive.mjs +1 -1
  171. package/dist/preview-next/middleware.mjs +1 -1
  172. package/dist/preview-next/{route-contract-DnL-FgSV.mjs → route-contract-R3PcMmax.mjs} +114 -37
  173. package/dist/server/{Block.shared-BEbq6EwO.mjs → Block.shared-CniF9tSu.mjs} +5 -5
  174. package/dist/server/{ThemeScopeCore-DFEM1a85.mjs → ThemeScopeCore-BQWsnGT6.mjs} +133 -120
  175. package/dist/server/{accessibleSurfaces-CM3QANtw.mjs → accessibleSurfaces-WPzUAHp4.mjs} +33 -2
  176. package/dist/server/accordions-By_0Ykks.mjs +111 -0
  177. package/dist/server/{bindings-Bly0dRs7.mjs → bindings-DxojjtK3.mjs} +7 -7
  178. package/dist/server/{client-CGJ2ztYp.mjs → client-CDndhbYO.mjs} +1412 -1307
  179. package/dist/server/config-validation.mjs +1 -1
  180. package/dist/server/config.mjs +2 -2
  181. package/dist/server/constants-VyF5nEhL.mjs +1474 -0
  182. package/dist/server/{customCss-BZ8YSrQg.mjs → customCss-C9kgPHvr.mjs} +41 -5
  183. package/dist/server/data/resolveBlockData.mjs +1 -1
  184. package/dist/server/index.mjs +3 -3
  185. package/dist/server/{loadContent-BkK1w3QQ.mjs → loadContent-BKstMBmX.mjs} +7 -4
  186. package/dist/server/{loadPage-DTLe0FEs.mjs → loadPage-IgNnZaqr.mjs} +3 -3
  187. package/dist/server/{lookMediaFrame-CaH018pK.mjs → lookMediaFrame-TFjgNG61.mjs} +74 -18
  188. package/dist/server/manifest.mjs +36 -25
  189. package/dist/server/{mapLocation-BM5WX7FY.mjs → mapLocation-MDDSubTp.mjs} +1 -1
  190. package/dist/server/media-BRmYrnzb.mjs +31 -0
  191. package/dist/server/{media-luf7RF22.mjs → media-gvfIw3z8.mjs} +2 -31
  192. package/dist/server/{navigation-BcNfYYuu.mjs → navigation-quBYlSKD.mjs} +2 -2
  193. package/dist/server/navigation.mjs +1 -1
  194. package/dist/server/next.mjs +170 -104
  195. package/dist/server/{overrideResolution-Uy9Zp2Ks.mjs → overrideResolution-CCaAPpIa.mjs} +1 -1
  196. package/dist/server/page-converter.mjs +3 -3
  197. package/dist/server/{pageRenderPlan-JzxBnqfV.mjs → pageRenderPlan-B7iULvKe.mjs} +15 -12
  198. package/dist/server/{pageRuntimeSupport-DyNSd2Yj.mjs → pageRuntimeSupport-BytMroxn.mjs} +9 -5
  199. package/dist/server/{pageShared-DU4ETFPS.mjs → pageShared-Dcs_XTIO.mjs} +836 -624
  200. package/dist/server/{parseThemeForPersistence-DOsfofCy.mjs → parseThemeForPersistence-Bihl4W5K.mjs} +3 -2
  201. package/dist/server/{portal-B4JVkdjc.mjs → portal-CMW_b9mG.mjs} +62 -46
  202. package/dist/server/portal.mjs +3 -3
  203. package/dist/server/portalQuestions-oUyohgL9.mjs +225 -0
  204. package/dist/server/{prebuild-8jNtDXmS.mjs → prebuild-agaH-vZV.mjs} +1 -1
  205. package/dist/server/prebuild.mjs +1 -1
  206. package/dist/server/{prefetchBlockData-xeMG42aw.mjs → prefetchBlockData-DwpRjqw4.mjs} +5 -3
  207. package/dist/server/{registry-DH1VrsCl.mjs → registry-DM9dHfDC.mjs} +582 -526
  208. package/dist/server/rendering/components/pageShared.mjs +1 -1
  209. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  210. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  211. package/dist/server/rendering/server.mjs +4 -4
  212. package/dist/server/rendering.mjs +10 -9
  213. package/dist/server/{resolveBlockData-BN8tweTx.mjs → resolveBlockData-CinHGf8l.mjs} +39 -31
  214. package/dist/server/{resolveButtonColourStates--6yJp9Tq.mjs → resolveButtonColourStates-B0O1IM16.mjs} +2 -1028
  215. package/dist/server/{resolvePageContent-DnM16_f9.mjs → resolvePageContent-BWKUZUIn.mjs} +1 -1
  216. package/dist/server/{responseMedia-F-ElH2Rd.mjs → responseMedia-IfH65QAH.mjs} +57 -2
  217. package/dist/server/routing.mjs +1 -1
  218. package/dist/server/{schema-BpsqaSSU.mjs → schema-CwfxQjc4.mjs} +10 -113
  219. package/dist/server/server.mjs +3 -3
  220. package/dist/server/{servicePageContent-B-FezJmH.mjs → servicePageContent-BBBhOtdE.mjs} +31 -26
  221. package/dist/server/theme-bridge.mjs +3 -2
  222. package/dist/server/theme.mjs +2 -2
  223. package/dist/server/{three-pass-converter-39SXCCnh.mjs → three-pass-converter-DPaUPTfl.mjs} +34 -16
  224. package/dist/server/titleSourceSchema-NhK6azFS.mjs +2018 -0
  225. package/dist/server/typeGuards-CTW_9AXq.mjs +413 -0
  226. package/dist/server/types-BKaBZFjD.mjs +1085 -0
  227. package/dist/server/{validation-3jOzYdPL.mjs → validation-DG5jX3jH.mjs} +70 -17
  228. package/dist/server/{version-8t0o6_jd.mjs → version-CipbxPHL.mjs} +1 -1
  229. package/dist/server/video-Cdr3wh-q.mjs +272 -0
  230. package/dist/styles/index.css +3446 -3796
  231. package/package.json +2 -1
  232. package/dist/_dts/index-DVSipdrT.d.ts +0 -101
  233. package/dist/client/TabBarFragment-DlKQRhP4.mjs +0 -56
  234. package/dist/client/checkoutRoute-DKlZRNZD.mjs +0 -22
  235. package/dist/client/constants-4o4_hl34.mjs +0 -6
  236. package/dist/client/creditProducts-BQ1t1erI.mjs +0 -266
  237. package/dist/client/formatDate-CTEN7gxW.mjs +0 -26
  238. package/dist/server/constants-Cj7hfbrA.mjs +0 -41
  239. package/dist/server/richTextSchema-QLaQrbII.mjs +0 -212
  240. package/dist/server/titleSourceSchema-Cu-3PRvv.mjs +0 -122
@@ -1,8 +1,8 @@
1
- import { n as parseSurfaceTree } from "./accessibleSurfaces-CM3QANtw.mjs";
2
- import { o as isSupportedLoaderEndpoint, r as encodePublicProductCategorySelector, t as materializeEntriesMedia } from "./responseMedia-F-ElH2Rd.mjs";
3
- import { f as parseSiteId, t as publicMapLocationParamsSchema } from "./mapLocation-BM5WX7FY.mjs";
1
+ import { n as parseSurfaceTree } from "./accessibleSurfaces-WPzUAHp4.mjs";
2
+ import { i as rethrowClientFrameworkSignal, l as isSupportedLoaderEndpoint, o as encodePublicProductCategorySelector, r as findFrameworkSignal, t as materializeEntriesMedia } from "./responseMedia-IfH65QAH.mjs";
3
+ import { f as parseSiteId, t as publicMapLocationParamsSchema } from "./mapLocation-MDDSubTp.mjs";
4
4
  import { a as ApiEnvelopeError, c as unwrapResponse, i as ApiRequestError, l as CLIENT_ERROR_REPORT_ENDPOINT_DEFINITIONS, n as attachResilienceStatusToError, o as extractApiEnvelopeErrorDetails, s as isApiError, t as RiverbankApiError, u as defineEndpointDefinitions } from "./error-f4g44bKx.mjs";
5
- import { t as SDK_VERSION } from "./version-8t0o6_jd.mjs";
5
+ import { t as SDK_VERSION } from "./version-CipbxPHL.mjs";
6
6
  import { z } from "zod";
7
7
  /**
8
8
  * How long a rendered page may hold availability it read through the batch
@@ -1377,6 +1377,17 @@ const APPOINTMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
1377
1377
  "server:internal_error"
1378
1378
  ]
1379
1379
  },
1380
+ getTeamMemberTemplatePreview: {
1381
+ path: "/sites/{siteId}/bookings/profile-editor/{entryId}/template-preview",
1382
+ method: "GET",
1383
+ auth: "user",
1384
+ responseKind: "json",
1385
+ errors: [
1386
+ "auth:forbidden",
1387
+ "resource:not_found",
1388
+ "server:internal_error"
1389
+ ]
1390
+ },
1380
1391
  updateTeamMemberProfilePolicy: {
1381
1392
  path: "/sites/{siteId}/bookings/resources/profile-policy",
1382
1393
  method: "PUT",
@@ -1561,7 +1572,11 @@ const APPOINTMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
1561
1572
  method: "DELETE",
1562
1573
  auth: "user",
1563
1574
  responseKind: "json",
1564
- errors: ["resource:not_found", "server:internal_error"]
1575
+ errors: [
1576
+ "resource:not_found",
1577
+ "resource:conflict",
1578
+ "server:internal_error"
1579
+ ]
1565
1580
  },
1566
1581
  getAppointmentSetup: {
1567
1582
  path: "/sites/{siteId}/bookings/appointment-setup",
@@ -7081,7 +7096,7 @@ const API_ENDPOINTS$1 = {
7081
7096
  ],
7082
7097
  auth: "public",
7083
7098
  responseKind: "json",
7084
- errors: ["validation:invalid_input", "server:internal_error"]
7099
+ errors: ["server:internal_error"]
7085
7100
  },
7086
7101
  resolveRouteDecision: {
7087
7102
  path: "/sites/{siteId}/route-decision",
@@ -7093,7 +7108,7 @@ const API_ENDPOINTS$1 = {
7093
7108
  ],
7094
7109
  auth: "public",
7095
7110
  responseKind: "json",
7096
- errors: ["validation:invalid_input", "server:internal_error"]
7111
+ errors: ["server:internal_error"]
7097
7112
  },
7098
7113
  getPageByPath: {
7099
7114
  path: "/sites/{siteId}/pages",
@@ -7644,7 +7659,7 @@ const API_ENDPOINTS$1 = {
7644
7659
  tags: ["backup"],
7645
7660
  auth: "user",
7646
7661
  responseKind: "json",
7647
- errors: ["validation:invalid_input", "server:internal_error"]
7662
+ errors: ["server:internal_error"]
7648
7663
  },
7649
7664
  deleteBackupUpload: {
7650
7665
  path: "/backup/upload",
@@ -7772,6 +7787,38 @@ const API_ENDPOINTS$1 = {
7772
7787
  "server:internal_error"
7773
7788
  ]
7774
7789
  },
7790
+ getEventRoomsRoster: {
7791
+ errors: [],
7792
+ path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms",
7793
+ method: "GET",
7794
+ tags: ["site-{siteId}", "event-series-{seriesId}"],
7795
+ auth: "user",
7796
+ responseKind: "json"
7797
+ },
7798
+ getChangeEventRoomOptions: {
7799
+ errors: [],
7800
+ path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms/change/options",
7801
+ method: "GET",
7802
+ tags: [
7803
+ "site-{siteId}",
7804
+ "event-series-{seriesId}",
7805
+ "bookings"
7806
+ ],
7807
+ auth: "user",
7808
+ responseKind: "json"
7809
+ },
7810
+ changeEventRoom: {
7811
+ errors: [],
7812
+ path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms/change",
7813
+ method: "POST",
7814
+ tags: [
7815
+ "site-{siteId}",
7816
+ "event-series-{seriesId}",
7817
+ "bookings"
7818
+ ],
7819
+ auth: "user",
7820
+ responseKind: "json"
7821
+ },
7775
7822
  listEventSeriesAttendees: {
7776
7823
  path: "/sites/{siteId}/bookings/event-series/{seriesId}/attendees",
7777
7824
  method: "GET",
@@ -8248,7 +8295,7 @@ const API_ENDPOINTS$1 = {
8248
8295
  auth: "user",
8249
8296
  responseKind: "json",
8250
8297
  demoMutation: DEMO_MUTATION_BLOCKED_DISABLED,
8251
- errors: ["validation:invalid_input", "server:internal_error"]
8298
+ errors: ["server:internal_error"]
8252
8299
  },
8253
8300
  getBookingPass: {
8254
8301
  path: "/sites/{siteId}/bookings/passes/{passId}",
@@ -8326,7 +8373,7 @@ const API_ENDPOINTS$1 = {
8326
8373
  auth: "user",
8327
8374
  responseKind: "json",
8328
8375
  demoMutation: DEMO_MUTATION_BLOCKED_DISABLED,
8329
- errors: ["validation:invalid_input", "server:internal_error"]
8376
+ errors: ["server:internal_error"]
8330
8377
  },
8331
8378
  getBookingMembership: {
8332
8379
  path: "/sites/{siteId}/bookings/memberships/{membershipId}",
@@ -9576,18 +9623,23 @@ const API_ENDPOINTS$1 = {
9576
9623
  auth: "public",
9577
9624
  responseKind: "json"
9578
9625
  },
9579
- portalGetCredit: {
9580
- path: "/portal/credit",
9626
+ portalGetDetails: {
9627
+ path: "/portal/details",
9581
9628
  method: "GET",
9582
9629
  auth: "public",
9583
- responseKind: "json"
9630
+ responseKind: "json",
9631
+ errors: ["server:internal_error"]
9584
9632
  },
9585
- portalGetOrders: {
9586
- path: "/portal/orders",
9587
- method: "GET",
9588
- errors: [],
9633
+ portalUpdateNewsletter: {
9634
+ path: "/portal/details/newsletter",
9635
+ method: "PATCH",
9589
9636
  auth: "public",
9590
- responseKind: "json"
9637
+ responseKind: "json",
9638
+ errors: [
9639
+ "validation:invalid_input",
9640
+ "resource:conflict",
9641
+ "server:internal_error"
9642
+ ]
9591
9643
  },
9592
9644
  portalCreateOrderCheckout: {
9593
9645
  path: "/portal/orders/{orderId}/checkout",
@@ -9628,42 +9680,74 @@ const API_ENDPOINTS$1 = {
9628
9680
  auth: "public",
9629
9681
  responseKind: "json"
9630
9682
  },
9631
- portalGetPasses: {
9632
- path: "/portal/passes",
9683
+ portalGetEventTicket: {
9684
+ path: "/portal/events/{registrationId}/ticket",
9633
9685
  method: "GET",
9634
9686
  auth: "public",
9635
9687
  responseKind: "json"
9636
9688
  },
9637
- portalGetMemberships: {
9638
- path: "/portal/memberships",
9689
+ portalGetRegularSessions: {
9690
+ path: "/portal/appointments/regular-sessions",
9639
9691
  method: "GET",
9640
9692
  auth: "public",
9641
- responseKind: "json"
9693
+ responseKind: "json",
9694
+ errors: ["server:internal_error"]
9642
9695
  },
9643
- portalGetEvents: {
9644
- path: "/portal/events",
9696
+ portalGetBookings: {
9697
+ path: "/portal/bookings",
9645
9698
  method: "GET",
9646
9699
  auth: "public",
9647
- responseKind: "json"
9700
+ responseKind: "json",
9701
+ errors: ["server:internal_error"]
9648
9702
  },
9649
- portalGetEventTicket: {
9650
- path: "/portal/events/{registrationId}/ticket",
9703
+ portalGetHome: {
9704
+ path: "/portal/home",
9651
9705
  method: "GET",
9652
9706
  auth: "public",
9653
- responseKind: "json"
9707
+ responseKind: "json",
9708
+ errors: ["server:internal_error"]
9654
9709
  },
9655
- portalGetRegularSessions: {
9656
- path: "/portal/appointments/regular-sessions",
9710
+ portalGetOccurrenceBookings: {
9711
+ path: "/portal/occurrences/{occurrenceId}/bookings",
9657
9712
  method: "GET",
9658
9713
  auth: "public",
9659
9714
  responseKind: "json",
9660
9715
  errors: ["server:internal_error"]
9661
9716
  },
9662
- portalGetAppointments: {
9663
- path: "/portal/appointments",
9717
+ portalGetHoldings: {
9718
+ path: "/portal/holdings",
9664
9719
  method: "GET",
9665
9720
  auth: "public",
9666
- responseKind: "json"
9721
+ responseKind: "json",
9722
+ errors: ["server:internal_error"]
9723
+ },
9724
+ portalGetPayments: {
9725
+ path: "/portal/payments",
9726
+ method: "GET",
9727
+ auth: "public",
9728
+ responseKind: "json",
9729
+ errors: ["server:internal_error"]
9730
+ },
9731
+ portalGetReceipt: {
9732
+ path: "/portal/payments/receipts/{receiptId}",
9733
+ method: "GET",
9734
+ auth: "public",
9735
+ responseKind: "json",
9736
+ errors: ["resource:not_found", "server:internal_error"]
9737
+ },
9738
+ portalGetOrder: {
9739
+ path: "/portal/orders/{orderId}",
9740
+ method: "GET",
9741
+ auth: "public",
9742
+ responseKind: "json",
9743
+ errors: ["resource:not_found", "server:internal_error"]
9744
+ },
9745
+ portalGetBooking: {
9746
+ path: "/portal/bookings/{kind}/{bookingId}",
9747
+ method: "GET",
9748
+ auth: "public",
9749
+ responseKind: "json",
9750
+ errors: ["resource:not_found", "server:internal_error"]
9667
9751
  },
9668
9752
  portalGetAppointmentBookingQuestions: {
9669
9753
  path: "/portal/appointments/{appointmentId}/booking-questions",
@@ -9764,13 +9848,6 @@ const API_ENDPOINTS$1 = {
9764
9848
  "server:internal_error"
9765
9849
  ]
9766
9850
  },
9767
- portalGetWholeSeriesRegistrations: {
9768
- path: "/portal/dated-offerings/whole-series",
9769
- method: "GET",
9770
- auth: "public",
9771
- responseKind: "json",
9772
- errors: ["server:internal_error"]
9773
- },
9774
9851
  portalGetWholeSeriesBookingQuestions: {
9775
9852
  path: "/portal/dated-offerings/whole-series/{registrationId}/booking-questions",
9776
9853
  method: "GET",
@@ -10124,14 +10201,6 @@ function resolveApiBaseUrl() {
10124
10201
  }
10125
10202
  //#endregion
10126
10203
  //#region ../api/src/pageReadResponseCache.ts
10127
- var CacheProbeMiss = class extends Error {};
10128
- /** Next has no response-dependent fetch TTL. Only the matching policy may store a page read. */
10129
- var UncachedPageRead = class extends Error {
10130
- constructor(snapshot) {
10131
- super("Page read belongs to another cache policy");
10132
- this.snapshot = snapshot;
10133
- }
10134
- };
10135
10204
  function isRecord(value) {
10136
10205
  return typeof value === "object" && value !== null && !Array.isArray(value);
10137
10206
  }
@@ -10146,130 +10215,156 @@ function envelopePage(body) {
10146
10215
  const data = isRecord(body) && body.success === true && isRecord(body.data) ? body.data : null;
10147
10216
  return data?.type === "content" && isRecord(data.content) ? data.content : data;
10148
10217
  }
10149
- function admit(snapshot) {
10218
+ function parseBody(body) {
10150
10219
  try {
10151
- const page = envelopePage(JSON.parse(snapshot.body));
10152
- if (snapshot.status === 200 && isResolvedPage(page)) return {
10153
- resolved: true,
10220
+ return JSON.parse(body);
10221
+ } catch {
10222
+ return null;
10223
+ }
10224
+ }
10225
+ const header = (snapshot, name) => snapshot.headers.find(([key]) => key.toLowerCase() === name)?.[1];
10226
+ /** Only a complete, resolved page is stored. Anything else passes through and keeps the policy its failure names. */
10227
+ function admit(snapshot) {
10228
+ const page = envelopePage(parseBody(snapshot.body));
10229
+ if (snapshot.status === 200 && isResolvedPage(page)) {
10230
+ if (header(snapshot, "x-riverbank-page-storage") === "no-store") return {
10231
+ kind: "pass-through",
10232
+ dependencies: "availability"
10233
+ };
10234
+ return {
10235
+ kind: "store",
10154
10236
  dependencies: page.dependencies
10155
10237
  };
10156
- } catch {}
10238
+ }
10157
10239
  return {
10158
- resolved: false,
10159
- dependencies: snapshot.status === 200 || snapshot.headers.some(([key, value]) => key === "x-riverbank-page-dependencies" && value === "availability") ? "availability" : "content"
10240
+ kind: "pass-through",
10241
+ dependencies: snapshot.status === 200 || header(snapshot, "x-riverbank-page-dependencies") === "availability" ? "availability" : "content"
10160
10242
  };
10161
10243
  }
10162
- /** A scoped transport read is shared with Next's background refresh, never across requests. */
10163
- function liveResponse(read) {
10164
- const pending = /* @__PURE__ */ new Map();
10165
- return () => {
10166
- const existing = pending.get("response");
10167
- if (existing) return existing;
10168
- const response = read().then(async (value) => ({
10169
- body: await value.text(),
10170
- status: value.status,
10171
- headers: [...value.headers.entries()],
10172
- cachedAt: Date.now()
10173
- }));
10174
- pending.set("response", response);
10175
- return response;
10244
+ /**
10245
+ * One cache entry per request, judged by the policy it is looked up with. Content is looked up first, so a
10246
+ * plain page costs one lookup and never registers the availability policy. A page whose snapshot depends on
10247
+ * availability is looked up again under that policy, which checks its tags and 60-second budget. A snapshot
10248
+ * past its own budget is never served: the live read replaces it.
10249
+ */
10250
+ function planPageRead(state, now, budgetSeconds) {
10251
+ const subject = state.live ?? state.cached;
10252
+ if (!subject) return {
10253
+ kind: "lookup",
10254
+ dependencies: "content"
10255
+ };
10256
+ const { dependencies } = admit(subject);
10257
+ if (!state.lookedUp.includes(dependencies)) return {
10258
+ kind: "lookup",
10259
+ dependencies
10260
+ };
10261
+ if (state.live) return {
10262
+ kind: "serve",
10263
+ snapshot: state.live
10176
10264
  };
10265
+ return now - subject.cachedAt < budgetSeconds(dependencies) * 1e3 ? {
10266
+ kind: "serve",
10267
+ snapshot: subject
10268
+ } : { kind: "read-live" };
10177
10269
  }
10178
- /** Neutral probes do not register a policy; the chosen entry is then checked with its real tags. */
10179
- async function readPolicy(input, probe = false) {
10180
- const policy = buildPageReadCachePolicy(input.siteId, input.dependency);
10181
- const revalidate = Math.min(policy.revalidate, input.maxAge ?? policy.revalidate);
10182
- const snapshot = await input.cache(async () => {
10183
- const snapshot = await input.read();
10184
- const admission = admit(snapshot);
10185
- if (!admission.resolved || admission.dependencies !== input.dependency) throw new UncachedPageRead(snapshot);
10270
+ /**
10271
+ * `unstable_cache` stores whatever its callback returns, so a response that must not be kept leaves the
10272
+ * callback by this one exception, which `lookup` turns back into a value straight away.
10273
+ */
10274
+ var PassThroughResponse = class extends Error {
10275
+ constructor(snapshot) {
10276
+ super("Page read must not be stored");
10277
+ this.snapshot = snapshot;
10278
+ }
10279
+ };
10280
+ async function lookup(input, dependencies) {
10281
+ const { tags } = buildPageReadCachePolicy(input.siteId, dependencies);
10282
+ const load = async () => {
10283
+ const snapshot = await input.live();
10284
+ if (admit(snapshot).kind === "pass-through") throw new PassThroughResponse(snapshot);
10186
10285
  return snapshot;
10187
- }, [
10188
- "page-read-envelope-v2",
10189
- input.key,
10190
- input.dependency
10191
- ], probe ? {
10192
- revalidate: false,
10193
- tags: []
10194
- } : {
10195
- ...policy,
10196
- revalidate
10197
- })();
10198
- if (Date.now() - snapshot.cachedAt < revalidate * 1e3) return snapshot;
10199
- return probe ? null : input.read();
10200
- }
10201
- async function probePolicy(input) {
10202
- return readPolicy({
10203
- ...input,
10204
- read: async () => {
10205
- throw new CacheProbeMiss();
10206
- }
10207
- }, true).catch((error) => {
10208
- if (error instanceof CacheProbeMiss) return null;
10209
- throw error;
10210
- });
10211
- }
10212
- /** Read in a framework cache scope, but never store an unclassified or failed response. */
10213
- async function readInCacheScope(cache, key, read) {
10286
+ };
10214
10287
  try {
10215
- return await cache(async () => {
10216
- throw new UncachedPageRead(await read());
10217
- }, ["page-read-live-v2", key], {
10218
- revalidate: false,
10219
- tags: []
10220
- })();
10288
+ return {
10289
+ cached: await input.cache(load, ["page-read-envelope-v3", input.key], {
10290
+ revalidate: input.budgetSeconds(dependencies),
10291
+ tags
10292
+ })(),
10293
+ live: null
10294
+ };
10221
10295
  } catch (error) {
10222
- if (error instanceof UncachedPageRead) return error.snapshot;
10296
+ if (error instanceof PassThroughResponse) return {
10297
+ cached: null,
10298
+ live: error.snapshot
10299
+ };
10223
10300
  throw error;
10224
10301
  }
10225
10302
  }
10226
- async function selectResponse(input) {
10227
- const candidate = await probePolicy({
10228
- ...input,
10229
- dependency: "content"
10230
- }) ?? await probePolicy({
10231
- ...input,
10232
- dependency: "availability"
10233
- });
10234
- if (candidate) try {
10235
- const checked = await readPolicy({
10236
- ...input,
10237
- dependency: admit(candidate).dependencies
10303
+ async function runPlan(input, state) {
10304
+ const step = planPageRead(state, Date.now(), input.budgetSeconds);
10305
+ switch (step.kind) {
10306
+ case "serve": return step.snapshot;
10307
+ case "read-live": return runPlan(input, {
10308
+ ...state,
10309
+ live: await input.live()
10238
10310
  });
10239
- if (checked) return checked;
10240
- } catch (error) {
10241
- if (error instanceof UncachedPageRead) return storeResponse(input, error.snapshot);
10242
- throw error;
10311
+ case "lookup": {
10312
+ const found = await lookup(input, step.dependencies);
10313
+ return runPlan(input, {
10314
+ lookedUp: [...state.lookedUp, step.dependencies],
10315
+ cached: found.cached ?? state.cached,
10316
+ live: state.live ?? found.live
10317
+ });
10318
+ }
10243
10319
  }
10244
- return storeResponse(input, await readInCacheScope(input.cache, input.key, input.read));
10245
10320
  }
10246
- async function storeResponse(input, snapshot) {
10247
- const admission = admit(snapshot);
10248
- try {
10249
- return await readPolicy({
10250
- ...input,
10251
- key: admission.resolved ? input.key : `${input.key}:refusal:${snapshot.status}`,
10252
- dependency: admission.dependencies,
10253
- read: async () => snapshot
10254
- }) ?? snapshot;
10255
- } catch (error) {
10256
- if (error instanceof UncachedPageRead) return error.snapshot;
10257
- throw error;
10258
- }
10321
+ /**
10322
+ * One transport read per page read, shared by a miss, a stale entry's refresh and the live fallback.
10323
+ * It starts only when one of them asks for it.
10324
+ */
10325
+ function sharedRead(read) {
10326
+ const transport = { started: null };
10327
+ return () => transport.started ?? (transport.started = read().then(async (value) => ({
10328
+ body: await value.text(),
10329
+ status: value.status,
10330
+ headers: [...value.headers.entries()],
10331
+ cachedAt: Date.now()
10332
+ })));
10333
+ }
10334
+ /**
10335
+ * Next prints an `unstable_cache` key in plain text when a refresh fails ("revalidating cache with key: …"),
10336
+ * and the request identity carries the site's secret API key. Only its SHA-256 digest reaches the framework,
10337
+ * which keeps one entry per URL and credential without the credential itself.
10338
+ */
10339
+ async function frameworkCacheKey(request) {
10340
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(request));
10341
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
10259
10342
  }
10260
10343
  async function cachePageReadResponse(input) {
10261
- if (!input.cache) return input.read();
10262
- const result = await selectResponse({
10263
- ...input,
10344
+ if (!input.cache || input.maxAge !== void 0 && input.maxAge <= 0) return input.read();
10345
+ const maxAge = input.maxAge;
10346
+ const budgetSeconds = (dependencies) => {
10347
+ const policy = buildPageReadCachePolicy(input.siteId, dependencies).revalidate;
10348
+ return maxAge === void 0 ? policy : Math.min(policy, maxAge);
10349
+ };
10350
+ const key = await frameworkCacheKey(input.key);
10351
+ const result = await runPlan({
10264
10352
  cache: input.cache,
10265
- read: liveResponse(input.read)
10353
+ key,
10354
+ siteId: input.siteId,
10355
+ live: sharedRead(input.read),
10356
+ budgetSeconds
10357
+ }, {
10358
+ lookedUp: [],
10359
+ cached: null,
10360
+ live: null
10266
10361
  });
10267
10362
  return new Response(result.body, {
10268
10363
  status: result.status,
10269
10364
  headers: result.headers
10270
10365
  });
10271
10366
  }
10272
- /** Result adapters use this for cache fallbacks that did not return through the HTTP transport. */
10367
+ /** Result adapters use this when the SDK served a page without the HTTP transport (memory, durable or prebuild fallback). */
10273
10368
  async function observePageReadPolicy(cache, siteId, payload) {
10274
10369
  if (!cache) return;
10275
10370
  const dependency = pageReadDependencies(payload);
@@ -10523,7 +10618,14 @@ async function parseJsonSuccess(endpoint, response, config, decoder) {
10523
10618
  if (!raw.trim()) return buildSuccessEnvelope(coerceResponse(void 0), requestId);
10524
10619
  const parsed = decodeSuccessJson(raw, endpoint, response, config, decoder);
10525
10620
  requireUsableCommitProjection(response, parsed);
10526
- return successJsonEnvelope(parsed, requestId);
10621
+ const envelope = successJsonEnvelope(parsed, requestId);
10622
+ return envelope.success && response.headers.get("x-riverbank-page-storage") === "no-store" ? {
10623
+ ...envelope,
10624
+ meta: {
10625
+ ...envelope.meta,
10626
+ storage: "no-store"
10627
+ }
10628
+ } : envelope;
10527
10629
  }
10528
10630
  function decodeSuccessJson(raw, endpoint, response, config, decoder) {
10529
10631
  try {
@@ -10724,768 +10826,1051 @@ function requireUsableCommitProjection(response, parsed) {
10724
10826
  throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
10725
10827
  }
10726
10828
  //#endregion
10727
- //#region ../site-renderer/src/runtimeResponse.ts
10728
- /** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
10729
- function restoreRuntimeResponse(serialized) {
10730
- return parseSurfaceTree(serialized);
10731
- }
10732
- //#endregion
10733
- //#region ../site-renderer/src/runtimeClient.ts
10734
- /** Only a client that reconstructs surfaces advertises revision transport. */
10735
- function createRuntimeApiClient(transport) {
10736
- const revisionTransport = (request) => transport({
10737
- ...request,
10738
- ...request.endpoint === "getContentByPath" ? { params: {
10739
- ...request.params,
10740
- surfaceTransport: "revision-v1"
10741
- } } : {}
10742
- });
10743
- return createParsedApiClient(revisionTransport, {
10744
- representation: "restored",
10745
- decode: restoreRuntimeResponse
10746
- });
10747
- }
10748
- function createRuntimeInternalAPIClient(baseUrl, options) {
10749
- return createRuntimeApiClient(createApiResponseTransport(() => ({}), baseUrl, options));
10750
- }
10751
- function createRuntimeBearerAPIClient(token, baseUrl, options) {
10752
- return createRuntimeApiClient(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
10753
- }
10754
- //#endregion
10755
- //#region src/client/entryListReadRequest.ts
10756
- const entryOrder = {
10757
- newest: "published_at.desc",
10758
- oldest: "published_at.asc",
10759
- title: "title.asc",
10760
- manual: "manual.asc"
10829
+ //#region src/client/resilience.ts
10830
+ const DEFAULT_RETRY_CONFIG = {
10831
+ maxAttempts: 3,
10832
+ baseDelayMs: 200,
10833
+ maxDelayMs: 2e3,
10834
+ jitter: "full"
10761
10835
  };
10762
- function entrySelection(input) {
10763
- return input.mode === "manual" && input.entryIds?.length ? {
10764
- keyPart: input.entryIds.join(","),
10765
- params: {
10766
- mode: "manual",
10767
- entryIds: JSON.stringify(input.entryIds)
10768
- }
10769
- } : {
10770
- keyPart: "",
10771
- params: {}
10772
- };
10773
- }
10774
- function entryListMemoryKey(input, selection) {
10775
- const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
10776
- return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
10836
+ const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
10837
+ failureThreshold: 5,
10838
+ resetTimeoutMs: 3e4,
10839
+ halfOpenMaxRequests: 2
10840
+ };
10841
+ /**
10842
+ * Error codes that indicate permanent infrastructure failures.
10843
+ * These should NOT be retried as the server is definitively unreachable.
10844
+ */
10845
+ const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10846
+ "ECONNREFUSED",
10847
+ "ENOTFOUND",
10848
+ "EAI_AGAIN"
10849
+ ]);
10850
+ /**
10851
+ * Error codes that indicate transient network issues.
10852
+ * These MAY succeed on retry as the server was reachable but had a hiccup.
10853
+ */
10854
+ const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10855
+ "ECONNRESET",
10856
+ "EPIPE",
10857
+ "ETIMEDOUT",
10858
+ "ESOCKETTIMEDOUT"
10859
+ ]);
10860
+ /**
10861
+ * Node.js network error codes (POSIX style).
10862
+ * These are the codes we're looking for in the cause chain.
10863
+ */
10864
+ const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10865
+ "ECONNREFUSED",
10866
+ "ENOTFOUND",
10867
+ "EAI_AGAIN",
10868
+ "ECONNRESET",
10869
+ "EPIPE",
10870
+ "ETIMEDOUT",
10871
+ "ESOCKETTIMEDOUT"
10872
+ ]);
10873
+ /**
10874
+ * Check if a string is a Node.js network error code (not an API error code).
10875
+ * API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
10876
+ */
10877
+ function isNodeNetworkErrorCode(code) {
10878
+ return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
10777
10879
  }
10778
- /** One interpretation of pagination, selection and preview for the transport and memory key. */
10779
- function buildEntryListReadRequest(input) {
10780
- const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
10781
- const selection = entrySelection(input);
10782
- const orderParam = order ? entryOrder[order] : void 0;
10783
- return {
10784
- cacheKey: entryListMemoryKey(input, selection),
10785
- params: {
10786
- siteId,
10787
- type: contentType,
10788
- ...typeof limit === "number" && { limit: String(limit) },
10789
- ...typeof offset === "number" && { offset: String(offset) },
10790
- ...includeMeta && { meta: "true" },
10791
- ...orderParam && { order: orderParam },
10792
- ...preview && { stage: "preview" },
10793
- ...selection.params
10880
+ /**
10881
+ * Extract the Node.js error code from an error's cause chain.
10882
+ * Handles nested cause chains like:
10883
+ * RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
10884
+ *
10885
+ * Skips API error codes (like 'network:connection_error') and only returns
10886
+ * actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
10887
+ *
10888
+ * @example
10889
+ * RiverbankApiError: Network request failed
10890
+ * [cause]: TypeError: fetch failed
10891
+ * [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
10892
+ * code: 'ECONNREFUSED'
10893
+ */
10894
+ function getErrorCodeFromCause(error) {
10895
+ let current = error;
10896
+ while (current) {
10897
+ const nodeError = current;
10898
+ if (nodeError.code && typeof nodeError.code === "string") {
10899
+ if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
10794
10900
  }
10795
- };
10901
+ current = current.cause;
10902
+ }
10796
10903
  }
10797
- //#endregion
10798
- //#region src/client/cache.ts
10799
- var SimpleCache = class {
10800
- constructor(options = {}) {
10801
- this.cache = /* @__PURE__ */ new Map();
10802
- this.maxSize = options.maxSize ?? 100;
10803
- this.ttl = options.ttl ?? 3e5;
10804
- this.staleTtl = options.staleTtl ?? 3e5;
10904
+ /**
10905
+ * Determine if an error is transient and should trigger circuit breaker / retry
10906
+ *
10907
+ * Transient (opens circuit, triggers retry):
10908
+ * - Network errors (status 0) that are NOT permanent infrastructure failures
10909
+ * - 5xx server errors
10910
+ * - 429 rate limit
10911
+ * - Connection reset, broken pipe, timeout
10912
+ *
10913
+ * Permanent (does NOT open circuit, no retry):
10914
+ * - 4xx client errors (400, 401, 403, 404)
10915
+ * - Validation errors
10916
+ * - ECONNREFUSED (server not running)
10917
+ * - ENOTFOUND (DNS failure)
10918
+ */
10919
+ function isTransientError(error) {
10920
+ if (error instanceof RiverbankApiError) {
10921
+ const errorCode = getErrorCodeFromCause(error);
10922
+ if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
10923
+ if (error.status === 0) return true;
10924
+ if (error.status === 429) return true;
10925
+ if (error.status >= 500) return true;
10926
+ return false;
10927
+ }
10928
+ if (error instanceof TypeError) {
10929
+ const errorCode = getErrorCodeFromCause(error);
10930
+ if (errorCode) {
10931
+ if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
10932
+ if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
10933
+ }
10934
+ return true;
10935
+ }
10936
+ return true;
10937
+ }
10938
+ /**
10939
+ * Calculate backoff delay for retry attempt
10940
+ *
10941
+ * Uses exponential backoff with optional full jitter.
10942
+ * Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
10943
+ */
10944
+ function calculateBackoff(attempt, config) {
10945
+ const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
10946
+ const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
10947
+ const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
10948
+ const exponential = baseDelayMs * Math.pow(2, attempt - 1);
10949
+ const capped = Math.min(exponential, maxDelayMs);
10950
+ if (jitter === "full") return Math.random() * capped;
10951
+ return capped;
10952
+ }
10953
+ /**
10954
+ * Circuit breaker for fail-fast behavior
10955
+ *
10956
+ * States:
10957
+ * - closed: Normal operation, requests allowed
10958
+ * - open: Too many failures, requests blocked
10959
+ * - half-open: Testing if service recovered, limited requests allowed
10960
+ */
10961
+ var CircuitBreaker = class {
10962
+ constructor(config) {
10963
+ this.state = "closed";
10964
+ this.failureCount = 0;
10965
+ this.successCount = 0;
10966
+ this.openUntil = 0;
10967
+ this.halfOpenRequests = 0;
10968
+ this.config = {
10969
+ failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
10970
+ resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
10971
+ halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
10972
+ };
10805
10973
  }
10806
10974
  /**
10807
- * Get a fresh value (within TTL)
10808
- * @returns The value if fresh, null otherwise
10975
+ * Check if circuit is open (requests should be blocked)
10976
+ * Also handles automatic transition from open to half-open after timeout
10809
10977
  */
10810
- getFresh(key) {
10811
- const entry = this.cache.get(key);
10812
- if (!entry) return null;
10813
- if (Date.now() <= entry.freshUntil) return entry.value;
10814
- return null;
10978
+ isOpen() {
10979
+ if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
10980
+ return this.state === "open";
10815
10981
  }
10816
10982
  /**
10817
- * Get a value that may be stale (past TTL but within staleTtl)
10818
- * @returns Object with value and stale age, or null if expired
10983
+ * Check if a request can be attempted
10984
+ * - closed: always yes
10985
+ * - open: always no
10986
+ * - half-open: limited number of probes
10819
10987
  */
10820
- getStale(key) {
10821
- const entry = this.cache.get(key);
10822
- if (!entry) return null;
10823
- const now = Date.now();
10824
- if (now > entry.staleUntil) {
10825
- this.cache.delete(key);
10826
- return null;
10827
- }
10828
- const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
10829
- return {
10830
- value: entry.value,
10831
- staleAgeSec
10832
- };
10988
+ canAttempt() {
10989
+ if (this.state === "closed") return true;
10990
+ if (this.state === "open") return false;
10991
+ return this.halfOpenRequests < this.config.halfOpenMaxRequests;
10833
10992
  }
10834
10993
  /**
10835
- * Store a value with TTL and stale window
10994
+ * Increment half-open request counter (call before making request in half-open)
10836
10995
  */
10837
- set(key, value, options) {
10838
- const ttl = options?.ttl ?? this.ttl;
10839
- const staleTtl = options?.staleTtl ?? this.staleTtl;
10840
- const now = Date.now();
10841
- while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
10842
- this.cache.set(key, {
10843
- value,
10844
- tags: options?.tags ?? [],
10845
- createdAt: now,
10846
- freshUntil: now + ttl,
10847
- staleUntil: now + ttl + staleTtl
10848
- });
10996
+ incrementHalfOpenRequests() {
10997
+ if (this.state === "half-open") this.halfOpenRequests++;
10849
10998
  }
10850
10999
  /**
10851
- * Evict one entry to make room for a new one
10852
- * Priority: oldest stale entry, then oldest fresh entry
11000
+ * Record a successful request
10853
11001
  */
10854
- evictOne(now) {
10855
- let oldestStaleKey = null;
10856
- let oldestStaleTime = Infinity;
10857
- let oldestFreshKey = null;
10858
- let oldestFreshTime = Infinity;
10859
- for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
10860
- if (entry.createdAt < oldestStaleTime) {
10861
- oldestStaleTime = entry.createdAt;
10862
- oldestStaleKey = key;
10863
- }
10864
- } else if (entry.createdAt < oldestFreshTime) {
10865
- oldestFreshTime = entry.createdAt;
10866
- oldestFreshKey = key;
10867
- }
10868
- const keyToEvict = oldestStaleKey ?? oldestFreshKey;
10869
- if (keyToEvict) this.cache.delete(keyToEvict);
11002
+ recordSuccess() {
11003
+ if (this.state === "half-open") {
11004
+ this.successCount++;
11005
+ if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
11006
+ } else this.failureCount = 0;
10870
11007
  }
10871
11008
  /**
10872
- * Remove all fully expired entries (past staleUntil)
11009
+ * Record a failed request
11010
+ * Only counts transient failures toward circuit breaker threshold
10873
11011
  */
10874
- prune() {
10875
- const now = Date.now();
10876
- for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
11012
+ recordFailure(error) {
11013
+ if (!isTransientError(error)) return;
11014
+ this.failureCount++;
11015
+ if (this.state === "half-open") this.transitionTo("open");
11016
+ else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
10877
11017
  }
10878
11018
  /**
10879
- * Clear all entries
11019
+ * Get current circuit state
10880
11020
  */
10881
- clearForTags(tags) {
10882
- if (tags.includes("riverbank")) {
10883
- this.clear();
10884
- return;
10885
- }
10886
- const selected = new Set(tags);
10887
- [...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
10888
- }
10889
- clear() {
10890
- this.cache.clear();
11021
+ getState() {
11022
+ return {
11023
+ state: this.state,
11024
+ failureCount: this.failureCount,
11025
+ openUntil: this.state === "open" ? this.openUntil : void 0
11026
+ };
10891
11027
  }
10892
11028
  /**
10893
- * Check if a key exists and is not fully expired
11029
+ * Transition to a new state
10894
11030
  */
10895
- has(key) {
10896
- const entry = this.cache.get(key);
10897
- if (!entry) return false;
10898
- const now = Date.now();
10899
- if (now > entry.staleUntil) {
10900
- this.cache.delete(key);
10901
- return false;
11031
+ transitionTo(newState) {
11032
+ this.state = newState;
11033
+ if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
11034
+ else if (newState === "half-open") {
11035
+ this.halfOpenRequests = 0;
11036
+ this.successCount = 0;
11037
+ } else if (newState === "closed") {
11038
+ this.failureCount = 0;
11039
+ this.successCount = 0;
11040
+ this.halfOpenRequests = 0;
10902
11041
  }
10903
- return now <= entry.freshUntil;
10904
11042
  }
10905
11043
  };
10906
- //#endregion
10907
- //#region src/request-options.ts
10908
- /** Every API client the SDK creates sends its version as `x-sdk-version`. */
10909
- const sdkRequestOptions = { sdkVersion: SDK_VERSION };
10910
- //#endregion
10911
- //#region src/public-api/runtime.ts
10912
- const PUBLIC_ENDPOINT_NAMES = [
10913
- "getSite",
10914
- "getContentByPath",
10915
- "resolveRouteOutcome",
10916
- "resolveRouteDecision",
10917
- "listPublishedEntries",
10918
- "getPublishedEntryPreview",
10919
- "getPublicFormById",
10920
- "listPublicForms",
10921
- "getPublicBookingServices",
10922
- "getPublicWeeklySlotAvailability",
10923
- "getPublicChallenge",
10924
- "listPublicEvents",
10925
- "batchBlockLoaders",
10926
- "listPublicTeamMembers",
10927
- "listPublicProducts",
10928
- "listPublicPasses",
10929
- "listPublicMemberships",
10930
- "checkRedirect",
10931
- "getRoutableContent",
10932
- "getPublicRoutableContent",
10933
- "getPublicSitemapRoutes"
10934
- ];
10935
- const API_ENDPOINTS = Object.freeze({
10936
- getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
10937
- getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
10938
- getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
10939
- getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
10940
- getContentByPath: {
10941
- revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
10942
- path: "/sites/{siteId}/pages",
10943
- method: "GET",
10944
- tags: [TAG_TEMPLATES.siteRoutableContent],
10945
- auth: "public",
10946
- responseKind: "json"
10947
- },
10948
- resolveRouteOutcome: {
10949
- revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
10950
- path: "/sites/{siteId}/route-outcome",
10951
- method: "GET",
10952
- tags: [
10953
- TAG_TEMPLATES.siteRoutableContent,
10954
- TAG_TEMPLATES.siteRedirects,
10955
- TAG_TEMPLATES.siteRouteOutcomes
10956
- ],
10957
- auth: "public",
10958
- responseKind: "json"
10959
- },
10960
- resolveRouteDecision: {
10961
- path: "/sites/{siteId}/route-decision",
10962
- method: "GET",
10963
- tags: [
10964
- TAG_TEMPLATES.siteRoutableContent,
10965
- TAG_TEMPLATES.siteRedirects,
10966
- TAG_TEMPLATES.siteRouteOutcomes
10967
- ],
10968
- auth: "public",
10969
- responseKind: "json"
10970
- },
10971
- listPublishedEntries: {
10972
- path: "/public/content/{siteId}/{type}/entries",
10973
- method: "GET",
10974
- revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
10975
- tags: [TAG_TEMPLATES.siteRoutableContent],
10976
- auth: "public",
10977
- responseKind: "json"
10978
- },
10979
- getPublishedEntryPreview: {
10980
- path: "/public/content/{siteId}/{type}/{slug}/preview",
10981
- method: "GET",
10982
- revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
10983
- tags: [TAG_TEMPLATES.siteRoutableContent],
10984
- auth: "public",
10985
- responseKind: "json"
10986
- },
10987
- getPublicFormById: {
10988
- path: "/public/forms/{formId}",
10989
- method: "GET",
10990
- revalidate: publicReadFreshnessSeconds("getPublicFormById"),
10991
- tags: [TAG_TEMPLATES.formById],
10992
- auth: "public",
10993
- responseKind: "json"
10994
- },
10995
- listPublicForms: {
10996
- path: "/public/sites/{siteId}/forms",
10997
- method: "GET",
10998
- revalidate: 60,
10999
- tags: [TAG_TEMPLATES.siteForms],
11000
- auth: "public",
11001
- responseKind: "json"
11002
- },
11003
- getPublicBookingServices: {
11004
- path: "/public/bookings/services",
11005
- method: "GET",
11006
- revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
11007
- tags: [TAG_TEMPLATES.publicBookingServices],
11008
- auth: "public",
11009
- responseKind: "json"
11010
- },
11011
- getPublicWeeklySlotAvailability: {
11012
- path: "/public/bookings/weekly-slot-availability",
11013
- method: "GET",
11014
- revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
11015
- tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
11016
- auth: "public",
11017
- responseKind: "json"
11018
- },
11019
- getPublicChallenge: {
11020
- path: "/public/challenge",
11021
- method: "GET",
11022
- auth: "public",
11023
- responseKind: "text"
11024
- },
11025
- listPublicEvents: {
11026
- path: "/public/sites/{siteId}/events",
11027
- method: "GET",
11028
- revalidate: publicReadFreshnessSeconds("listPublicEvents"),
11029
- tags: [TAG_TEMPLATES.publicEvents],
11030
- auth: "public",
11031
- responseKind: "json"
11032
- },
11033
- batchBlockLoaders: {
11034
- path: "/public/sites/{siteId}/block-loaders/batch",
11035
- method: "POST",
11036
- auth: "public",
11037
- responseKind: "json"
11038
- },
11039
- listPublicTeamMembers: {
11040
- path: "/public/sites/{siteId}/team-members",
11041
- method: "GET",
11042
- revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
11043
- tags: [TAG_TEMPLATES.publicTeamMembers],
11044
- auth: "public",
11045
- responseKind: "json"
11046
- },
11047
- listPublicProducts: {
11048
- path: "/public/sites/{siteId}/products",
11049
- method: "GET",
11050
- revalidate: publicReadFreshnessSeconds("listPublicProducts"),
11051
- tags: [TAG_TEMPLATES.publicProducts],
11052
- auth: "public",
11053
- responseKind: "json"
11054
- },
11055
- listPublicPasses: {
11056
- path: "/public/sites/{siteId}/bookings/products/passes",
11057
- method: "GET",
11058
- revalidate: publicReadFreshnessSeconds("listPublicPasses"),
11059
- tags: [TAG_TEMPLATES.publicPasses],
11060
- auth: "public",
11061
- responseKind: "json"
11062
- },
11063
- listPublicMemberships: {
11064
- path: "/public/sites/{siteId}/bookings/products/memberships",
11065
- method: "GET",
11066
- revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
11067
- tags: [TAG_TEMPLATES.publicMemberships],
11068
- auth: "public",
11069
- responseKind: "json"
11070
- },
11071
- checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
11072
- });
11073
- function buildEndpointURL(baseURL, endpoint) {
11074
- return baseURL + API_ENDPOINTS[endpoint].path;
11075
- }
11076
- function publicSiteReadDefinition(definition) {
11077
- return {
11078
- path: definition.path,
11079
- method: definition.method,
11080
- revalidate: definition.revalidate,
11081
- tags: definition.tags,
11082
- auth: definition.auth,
11083
- responseKind: definition.responseKind
11084
- };
11085
- }
11086
- //#endregion
11087
- //#region src/client/runtimeCacheKeys.ts
11088
11044
  /**
11089
- * Bump when a cached payload's shape changes incompatibly, so readers skip
11090
- * entries written in the old shape until publish or a live success rewrites
11091
- * them.
11045
+ * Fetch with timeout and retry logic
11092
11046
  *
11093
- * - 5: page reads carry the admitted destination envelope and availability dependencies.
11094
- * - 4: owned surface inputs use the shared revision transport envelope (#1627).
11095
- * - 3: hidden business-source maps and private locations are removed before public projection (#1611).
11096
- * - 2: pages carry intent-only `runtimeJoins` in place of compiled
11097
- * `runtimeBoundaries` (issue 1422).
11047
+ * @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
11048
+ * @param config - Retry configuration
11049
+ * @returns Result from successful fetch
11050
+ * @throws Last error after all retries exhausted
11098
11051
  */
11099
- const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 5;
11100
- function toNonEmptyString(value) {
11101
- if (value === null || value === void 0) return null;
11102
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
11103
- const normalized = String(value).trim();
11104
- return normalized.length > 0 ? normalized : null;
11052
+ async function fetchWithTimeoutAndRetry(fetcher, config) {
11053
+ const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
11054
+ const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
11055
+ let lastError;
11056
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
11057
+ const controller = new AbortController();
11058
+ const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
11059
+ try {
11060
+ return await fetcher(controller.signal);
11061
+ } finally {
11062
+ clearTimeout(timeoutId);
11063
+ }
11064
+ } catch (error) {
11065
+ lastError = error;
11066
+ if (!shouldRetryError(error, config.retryOn)) throw error;
11067
+ if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
11068
+ }
11069
+ throw lastError;
11105
11070
  }
11106
- function normalizeRuntimePublicPath(value) {
11107
- const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
11108
- const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
11109
- return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
11071
+ /**
11072
+ * Check if an error is an AbortError (from AbortController.abort() or timeout)
11073
+ */
11074
+ function isAbortError$1(error) {
11075
+ if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
11076
+ if (error instanceof Error && error.name === "AbortError") return true;
11077
+ return false;
11110
11078
  }
11111
- function normalizeRuntimeHostname(value) {
11112
- const trimmed = value.trim().toLowerCase();
11113
- return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
11079
+ /**
11080
+ * Check if an error should be retried
11081
+ */
11082
+ function shouldRetryError(error, customRetryOn) {
11083
+ if (isAbortError$1(error)) return false;
11084
+ if (findFrameworkSignal(error) !== void 0) return false;
11085
+ if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
11086
+ return isTransientError(error);
11114
11087
  }
11115
- function normalizeScalar(value) {
11116
- return value.trim().toLowerCase();
11088
+ /**
11089
+ * Get delay before retrying, respecting Retry-After if present
11090
+ */
11091
+ function getRetryDelay(error, attempt, config) {
11092
+ if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
11093
+ return calculateBackoff(attempt, config);
11117
11094
  }
11118
- function unsafeAsPublishedRuntimeCacheKey(value) {
11119
- return value;
11095
+ /**
11096
+ * Sleep for specified milliseconds
11097
+ */
11098
+ function sleep(ms) {
11099
+ return new Promise((resolve) => setTimeout(resolve, ms));
11120
11100
  }
11121
- function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
11122
- return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
11101
+ /**
11102
+ * Error thrown when circuit breaker is open
11103
+ */
11104
+ var CircuitOpenError = class extends Error {
11105
+ constructor(state) {
11106
+ super("Circuit breaker is open");
11107
+ this.name = "CircuitOpenError";
11108
+ this.circuitState = state;
11109
+ }
11110
+ };
11111
+ //#endregion
11112
+ //#region ../site-renderer/src/runtimeResponse.ts
11113
+ /** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
11114
+ function restoreRuntimeResponse(serialized) {
11115
+ return parseSurfaceTree(serialized);
11123
11116
  }
11124
- function selectSiteRuntimeIdentity(params) {
11125
- const slug = toNonEmptyString(params.slug);
11126
- if (slug !== null) return { slug: normalizeScalar(slug) };
11127
- const domain = toNonEmptyString(params.domain);
11128
- if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
11129
- const id = toNonEmptyString(params.id);
11130
- if (id !== null) return { id: normalizeScalar(id) };
11131
- return null;
11117
+ //#endregion
11118
+ //#region ../site-renderer/src/runtimeClient.ts
11119
+ /** Only a client that reconstructs surfaces advertises revision transport. */
11120
+ function createRuntimeApiClient$1(transport) {
11121
+ const revisionTransport = (request) => transport({
11122
+ ...request,
11123
+ ...request.endpoint === "getContentByPath" ? { params: {
11124
+ ...request.params,
11125
+ surfaceTransport: "revision-v1"
11126
+ } } : {}
11127
+ });
11128
+ return createParsedApiClient(revisionTransport, {
11129
+ representation: "restored",
11130
+ decode: restoreRuntimeResponse
11131
+ });
11132
11132
  }
11133
- function deriveGetSiteKey(params) {
11134
- const identity = selectSiteRuntimeIdentity(params);
11135
- if (identity === null) return {
11136
- ok: false,
11137
- error: {
11138
- kind: "missing_site_identity",
11139
- acceptedParams: [
11140
- "slug",
11141
- "domain",
11142
- "id"
11143
- ]
11144
- }
11145
- };
11146
- const normalizedParams = {
11147
- ...identity,
11148
- ...toNonEmptyString(params.currentPath) === null ? {} : { currentPath: normalizeRuntimePublicPath(params.currentPath) }
11149
- };
11150
- return {
11151
- ok: true,
11152
- endpoint: "getSite",
11153
- key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
11154
- normalizedParams
11155
- };
11133
+ function createRuntimeInternalAPIClient(baseUrl, options) {
11134
+ return createRuntimeApiClient$1(createApiResponseTransport(() => ({}), baseUrl, options));
11156
11135
  }
11157
- function deriveGetContentByPathKey(params) {
11158
- const siteId = toNonEmptyString(params.siteId);
11159
- if (siteId === null) return {
11160
- ok: false,
11161
- error: {
11162
- kind: "missing_required_param",
11163
- endpoint: "getContentByPath",
11164
- param: "siteId"
11136
+ function createRuntimeBearerAPIClient(token, baseUrl, options) {
11137
+ return createRuntimeApiClient$1(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
11138
+ }
11139
+ //#endregion
11140
+ //#region src/client/entryListReadRequest.ts
11141
+ const entryOrder = {
11142
+ newest: "published_at.desc",
11143
+ oldest: "published_at.asc",
11144
+ title: "title.asc",
11145
+ manual: "manual.asc"
11146
+ };
11147
+ function entrySelection(input) {
11148
+ return input.mode === "manual" && input.entryIds?.length ? {
11149
+ keyPart: input.entryIds.join(","),
11150
+ params: {
11151
+ mode: "manual",
11152
+ entryIds: JSON.stringify(input.entryIds)
11165
11153
  }
11154
+ } : {
11155
+ keyPart: "",
11156
+ params: {}
11166
11157
  };
11167
- const normalizedParams = {
11168
- siteId: normalizeScalar(siteId),
11169
- path: normalizeRuntimePublicPath(params.path),
11170
- contentContract: "native"
11171
- };
11172
- return {
11173
- ok: true,
11174
- endpoint: "getContentByPath",
11175
- key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
11176
- normalizedParams
11177
- };
11178
- }
11179
- function deriveDurableRuntimeCacheKey(input) {
11180
- switch (input.endpoint) {
11181
- case "getSite": return deriveGetSiteKey(input.params);
11182
- case "getContentByPath": return deriveGetContentByPathKey(input.params);
11183
- }
11184
11158
  }
11185
- function isPublishedRuntimeCacheKeyEndpoint(value) {
11186
- return value === "getSite" || value === "getContentByPath";
11159
+ function entryListMemoryKey(input, selection) {
11160
+ const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
11161
+ return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
11187
11162
  }
11188
- function parsePublishedRuntimeCacheKey(value) {
11189
- const details = parsePublishedRuntimeCacheKeyDetails(value);
11190
- if (!details.ok) return details;
11163
+ /** One interpretation of pagination, selection and preview for the transport and memory key. */
11164
+ function buildEntryListReadRequest(input) {
11165
+ const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
11166
+ const selection = entrySelection(input);
11167
+ const orderParam = order ? entryOrder[order] : void 0;
11191
11168
  return {
11192
- ok: true,
11193
- key: details.key,
11194
- endpoint: details.endpoint
11169
+ cacheKey: entryListMemoryKey(input, selection),
11170
+ params: {
11171
+ siteId,
11172
+ type: contentType,
11173
+ ...typeof limit === "number" && { limit: String(limit) },
11174
+ ...typeof offset === "number" && { offset: String(offset) },
11175
+ ...includeMeta && { meta: "true" },
11176
+ ...orderParam && { order: orderParam },
11177
+ ...preview && { stage: "preview" },
11178
+ ...selection.params
11179
+ }
11195
11180
  };
11196
11181
  }
11197
- function parsePublishedRuntimeCacheKeyDetails(value) {
11198
- if (typeof value !== "string") return {
11199
- ok: false,
11200
- error: "not_string"
11201
- };
11202
- const parts = value.split(":");
11203
- if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
11204
- ok: false,
11205
- error: "invalid_prefix"
11206
- };
11207
- const endpoint = parts[2];
11208
- if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
11209
- ok: false,
11210
- error: "unknown_endpoint"
11211
- };
11212
- const normalizedParams = {};
11213
- for (const part of parts.slice(3)) {
11214
- const separatorIndex = part.indexOf("=");
11215
- if (separatorIndex <= 0) return {
11216
- ok: false,
11217
- error: "invalid_param_encoding"
11182
+ //#endregion
11183
+ //#region src/client/cache.ts
11184
+ var SimpleCache = class {
11185
+ constructor(options = {}) {
11186
+ this.cache = /* @__PURE__ */ new Map();
11187
+ this.maxSize = options.maxSize ?? 100;
11188
+ this.ttl = options.ttl ?? 3e5;
11189
+ this.staleTtl = options.staleTtl ?? 3e5;
11190
+ }
11191
+ /**
11192
+ * Get a fresh value (within TTL)
11193
+ * @returns The value if fresh, null otherwise
11194
+ */
11195
+ getFresh(key) {
11196
+ const entry = this.cache.get(key);
11197
+ if (!entry) return null;
11198
+ if (Date.now() <= entry.freshUntil) return entry.value;
11199
+ return null;
11200
+ }
11201
+ /**
11202
+ * Get a value that may be stale (past TTL but within staleTtl)
11203
+ * @returns Object with value and stale age, or null if expired
11204
+ */
11205
+ getStale(key) {
11206
+ const entry = this.cache.get(key);
11207
+ if (!entry) return null;
11208
+ const now = Date.now();
11209
+ if (now > entry.staleUntil) {
11210
+ this.cache.delete(key);
11211
+ return null;
11212
+ }
11213
+ const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
11214
+ return {
11215
+ value: entry.value,
11216
+ staleAgeSec
11218
11217
  };
11219
- try {
11220
- const key = decodeURIComponent(part.slice(0, separatorIndex));
11221
- normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
11222
- } catch {
11223
- return {
11224
- ok: false,
11225
- error: "invalid_param_encoding"
11226
- };
11218
+ }
11219
+ /**
11220
+ * Store a value with TTL and stale window
11221
+ */
11222
+ set(key, value, options) {
11223
+ const ttl = options?.ttl ?? this.ttl;
11224
+ const staleTtl = options?.staleTtl ?? this.staleTtl;
11225
+ const now = Date.now();
11226
+ while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
11227
+ this.cache.set(key, {
11228
+ value,
11229
+ tags: options?.tags ?? [],
11230
+ createdAt: now,
11231
+ freshUntil: now + ttl,
11232
+ staleUntil: now + ttl + staleTtl
11233
+ });
11234
+ }
11235
+ /**
11236
+ * Evict one entry to make room for a new one
11237
+ * Priority: oldest stale entry, then oldest fresh entry
11238
+ */
11239
+ evictOne(now) {
11240
+ let oldestStaleKey = null;
11241
+ let oldestStaleTime = Infinity;
11242
+ let oldestFreshKey = null;
11243
+ let oldestFreshTime = Infinity;
11244
+ for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
11245
+ if (entry.createdAt < oldestStaleTime) {
11246
+ oldestStaleTime = entry.createdAt;
11247
+ oldestStaleKey = key;
11248
+ }
11249
+ } else if (entry.createdAt < oldestFreshTime) {
11250
+ oldestFreshTime = entry.createdAt;
11251
+ oldestFreshKey = key;
11227
11252
  }
11253
+ const keyToEvict = oldestStaleKey ?? oldestFreshKey;
11254
+ if (keyToEvict) this.cache.delete(keyToEvict);
11228
11255
  }
11229
- if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
11230
- ok: false,
11231
- error: "invalid_param_encoding"
11232
- };
11233
- return {
11234
- ok: true,
11235
- key: unsafeAsPublishedRuntimeCacheKey(value),
11236
- endpoint,
11237
- normalizedParams
11238
- };
11239
- }
11240
- function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
11241
- const keys = Object.keys(normalizedParams).sort();
11242
- switch (endpoint) {
11243
- case "getSite": return [
11244
- "domain",
11245
- "id",
11246
- "slug"
11247
- ].filter((key) => normalizedParams[key] !== void 0).length === 1 && keys.every((key) => [
11248
- "currentPath",
11249
- "domain",
11250
- "id",
11251
- "slug"
11252
- ].includes(key));
11253
- case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
11254
- "contentContract",
11255
- "path",
11256
- "siteId"
11257
- ].includes(key));
11256
+ /**
11257
+ * Remove all fully expired entries (past staleUntil)
11258
+ */
11259
+ prune() {
11260
+ const now = Date.now();
11261
+ for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
11258
11262
  }
11259
- }
11260
- function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
11261
- if (typeof value !== "number") return {
11262
- ok: false,
11263
- error: "not_number"
11264
- };
11265
- if (!Number.isInteger(value)) return {
11266
- ok: false,
11267
- error: "not_integer"
11268
- };
11269
- if (value <= 0) return {
11270
- ok: false,
11271
- error: "not_positive"
11272
- };
11273
- return {
11274
- ok: true,
11275
- value
11276
- };
11277
- }
11263
+ /**
11264
+ * Clear all entries
11265
+ */
11266
+ clearForTags(tags) {
11267
+ if (tags.includes("riverbank")) {
11268
+ this.clear();
11269
+ return;
11270
+ }
11271
+ const selected = new Set(tags);
11272
+ [...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
11273
+ }
11274
+ clear() {
11275
+ this.cache.clear();
11276
+ }
11277
+ /**
11278
+ * Check if a key exists and is not fully expired
11279
+ */
11280
+ has(key) {
11281
+ const entry = this.cache.get(key);
11282
+ if (!entry) return false;
11283
+ const now = Date.now();
11284
+ if (now > entry.staleUntil) {
11285
+ this.cache.delete(key);
11286
+ return false;
11287
+ }
11288
+ return now <= entry.freshUntil;
11289
+ }
11290
+ };
11278
11291
  //#endregion
11279
- //#region src/client/runtimeCachePolicy.ts
11280
- const DEFAULT_STALE_TTL_SEC = 1440 * 60;
11281
- const DEFAULT_MEMORY_TTL_SEC = 60;
11282
- const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
11283
- getSite: {
11284
- kind: "durable-public-stale",
11285
- staleTtlSec: DEFAULT_STALE_TTL_SEC
11286
- },
11292
+ //#region src/request-options.ts
11293
+ /** Every API client the SDK creates sends its version as `x-sdk-version`. */
11294
+ const sdkRequestOptions = { sdkVersion: SDK_VERSION };
11295
+ //#endregion
11296
+ //#region src/public-api/runtime.ts
11297
+ const PUBLIC_ENDPOINT_NAMES = [
11298
+ "getSite",
11299
+ "getContentByPath",
11300
+ "resolveRouteOutcome",
11301
+ "resolveRouteDecision",
11302
+ "listPublishedEntries",
11303
+ "getPublishedEntryPreview",
11304
+ "getPublicFormById",
11305
+ "listPublicForms",
11306
+ "getPublicBookingServices",
11307
+ "getPublicWeeklySlotAvailability",
11308
+ "getPublicChallenge",
11309
+ "listPublicEvents",
11310
+ "batchBlockLoaders",
11311
+ "listPublicTeamMembers",
11312
+ "listPublicProducts",
11313
+ "listPublicPasses",
11314
+ "listPublicMemberships",
11315
+ "checkRedirect",
11316
+ "getRoutableContent",
11317
+ "getPublicRoutableContent",
11318
+ "getPublicSitemapRoutes"
11319
+ ];
11320
+ const API_ENDPOINTS = Object.freeze({
11321
+ getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
11322
+ getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
11323
+ getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
11324
+ getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
11287
11325
  getContentByPath: {
11288
- kind: "durable-public-stale",
11289
- staleTtlSec: DEFAULT_STALE_TTL_SEC
11326
+ revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
11327
+ path: "/sites/{siteId}/pages",
11328
+ method: "GET",
11329
+ tags: [TAG_TEMPLATES.siteRoutableContent],
11330
+ auth: "public",
11331
+ responseKind: "json"
11290
11332
  },
11291
11333
  resolveRouteOutcome: {
11292
- kind: "memory-only",
11293
- reason: "durable_rollout_pending"
11334
+ revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
11335
+ path: "/sites/{siteId}/route-outcome",
11336
+ method: "GET",
11337
+ tags: [
11338
+ TAG_TEMPLATES.siteRoutableContent,
11339
+ TAG_TEMPLATES.siteRedirects,
11340
+ TAG_TEMPLATES.siteRouteOutcomes
11341
+ ],
11342
+ auth: "public",
11343
+ responseKind: "json"
11294
11344
  },
11295
11345
  resolveRouteDecision: {
11296
- kind: "memory-only",
11297
- reason: "durable_rollout_pending"
11346
+ path: "/sites/{siteId}/route-decision",
11347
+ method: "GET",
11348
+ tags: [
11349
+ TAG_TEMPLATES.siteRoutableContent,
11350
+ TAG_TEMPLATES.siteRedirects,
11351
+ TAG_TEMPLATES.siteRouteOutcomes
11352
+ ],
11353
+ auth: "public",
11354
+ responseKind: "json"
11298
11355
  },
11299
11356
  listPublishedEntries: {
11300
- kind: "memory-only",
11301
- reason: "durable_rollout_pending"
11357
+ path: "/public/content/{siteId}/{type}/entries",
11358
+ method: "GET",
11359
+ revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
11360
+ tags: [TAG_TEMPLATES.siteRoutableContent],
11361
+ auth: "public",
11362
+ responseKind: "json"
11302
11363
  },
11303
11364
  getPublishedEntryPreview: {
11304
- kind: "memory-only",
11305
- reason: "durable_rollout_pending"
11365
+ path: "/public/content/{siteId}/{type}/{slug}/preview",
11366
+ method: "GET",
11367
+ revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
11368
+ tags: [TAG_TEMPLATES.siteRoutableContent],
11369
+ auth: "public",
11370
+ responseKind: "json"
11306
11371
  },
11307
11372
  getPublicFormById: {
11308
- kind: "memory-only",
11309
- reason: "durable_rollout_pending"
11373
+ path: "/public/forms/{formId}",
11374
+ method: "GET",
11375
+ revalidate: publicReadFreshnessSeconds("getPublicFormById"),
11376
+ tags: [TAG_TEMPLATES.formById],
11377
+ auth: "public",
11378
+ responseKind: "json"
11310
11379
  },
11311
11380
  listPublicForms: {
11312
- kind: "memory-only",
11313
- reason: "durable_rollout_pending"
11381
+ path: "/public/sites/{siteId}/forms",
11382
+ method: "GET",
11383
+ revalidate: 60,
11384
+ tags: [TAG_TEMPLATES.siteForms],
11385
+ auth: "public",
11386
+ responseKind: "json"
11314
11387
  },
11315
11388
  getPublicBookingServices: {
11316
- kind: "live-only",
11317
- reason: "safety_sensitive_booking"
11389
+ path: "/public/bookings/services",
11390
+ method: "GET",
11391
+ revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
11392
+ tags: [TAG_TEMPLATES.publicBookingServices],
11393
+ auth: "public",
11394
+ responseKind: "json"
11318
11395
  },
11319
11396
  getPublicWeeklySlotAvailability: {
11320
- kind: "live-only",
11321
- reason: "safety_sensitive_booking"
11397
+ path: "/public/bookings/weekly-slot-availability",
11398
+ method: "GET",
11399
+ revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
11400
+ tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
11401
+ auth: "public",
11402
+ responseKind: "json"
11322
11403
  },
11323
11404
  getPublicChallenge: {
11324
- kind: "live-only",
11325
- reason: "challenge_endpoint"
11405
+ path: "/public/challenge",
11406
+ method: "GET",
11407
+ auth: "public",
11408
+ responseKind: "text"
11326
11409
  },
11327
11410
  listPublicEvents: {
11328
- kind: "memory-only",
11329
- reason: "durable_rollout_pending"
11411
+ path: "/public/sites/{siteId}/events",
11412
+ method: "GET",
11413
+ revalidate: publicReadFreshnessSeconds("listPublicEvents"),
11414
+ tags: [TAG_TEMPLATES.publicEvents],
11415
+ auth: "public",
11416
+ responseKind: "json"
11330
11417
  },
11331
11418
  batchBlockLoaders: {
11332
- kind: "live-only",
11333
- reason: "opaque_batch_loader"
11419
+ path: "/public/sites/{siteId}/block-loaders/batch",
11420
+ method: "POST",
11421
+ auth: "public",
11422
+ responseKind: "json"
11334
11423
  },
11335
11424
  listPublicTeamMembers: {
11336
- kind: "memory-only",
11337
- reason: "durable_rollout_pending"
11425
+ path: "/public/sites/{siteId}/team-members",
11426
+ method: "GET",
11427
+ revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
11428
+ tags: [TAG_TEMPLATES.publicTeamMembers],
11429
+ auth: "public",
11430
+ responseKind: "json"
11338
11431
  },
11339
11432
  listPublicProducts: {
11340
- kind: "memory-only",
11341
- reason: "durable_rollout_pending"
11433
+ path: "/public/sites/{siteId}/products",
11434
+ method: "GET",
11435
+ revalidate: publicReadFreshnessSeconds("listPublicProducts"),
11436
+ tags: [TAG_TEMPLATES.publicProducts],
11437
+ auth: "public",
11438
+ responseKind: "json"
11342
11439
  },
11343
11440
  listPublicPasses: {
11344
- kind: "live-only",
11345
- reason: "safety_sensitive_booking"
11441
+ path: "/public/sites/{siteId}/bookings/products/passes",
11442
+ method: "GET",
11443
+ revalidate: publicReadFreshnessSeconds("listPublicPasses"),
11444
+ tags: [TAG_TEMPLATES.publicPasses],
11445
+ auth: "public",
11446
+ responseKind: "json"
11346
11447
  },
11347
11448
  listPublicMemberships: {
11348
- kind: "live-only",
11349
- reason: "safety_sensitive_booking"
11350
- },
11351
- checkRedirect: {
11352
- kind: "memory-only",
11353
- reason: "durable_rollout_pending"
11354
- },
11355
- getRoutableContent: {
11356
- kind: "live-only",
11357
- reason: "auth_required"
11358
- },
11359
- getPublicRoutableContent: {
11360
- kind: "memory-only",
11361
- reason: "durable_rollout_pending"
11449
+ path: "/public/sites/{siteId}/bookings/products/memberships",
11450
+ method: "GET",
11451
+ revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
11452
+ tags: [TAG_TEMPLATES.publicMemberships],
11453
+ auth: "public",
11454
+ responseKind: "json"
11362
11455
  },
11363
- getPublicSitemapRoutes: {
11364
- kind: "memory-only",
11365
- reason: "durable_rollout_pending"
11366
- }
11367
- };
11368
- const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
11369
- function isPublicEndpointName(endpoint) {
11370
- return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
11371
- }
11372
- function isTruthyParam(value) {
11373
- return value === true || value === "true" || value === 1 || value === "1";
11456
+ checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
11457
+ });
11458
+ function buildEndpointURL(baseURL, endpoint) {
11459
+ return baseURL + API_ENDPOINTS[endpoint].path;
11374
11460
  }
11375
- function isPreviewRequest(endpoint, params) {
11376
- if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
11377
- if (endpoint === "listPublishedEntries") return params.stage === "preview";
11378
- return false;
11461
+ function publicSiteReadDefinition(definition) {
11462
+ return {
11463
+ path: definition.path,
11464
+ method: definition.method,
11465
+ revalidate: definition.revalidate,
11466
+ tags: definition.tags,
11467
+ auth: definition.auth,
11468
+ responseKind: definition.responseKind
11469
+ };
11379
11470
  }
11380
- function getEndpointFreshTtlSec(endpoint) {
11381
- return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
11471
+ //#endregion
11472
+ //#region src/client/runtimeCacheKeys.ts
11473
+ /**
11474
+ * Bump when a cached payload's shape changes incompatibly, so readers skip
11475
+ * entries written in the old shape until publish or a live success rewrites
11476
+ * them.
11477
+ *
11478
+ * - 5: page reads carry the admitted destination envelope and availability dependencies.
11479
+ * - 4: owned surface inputs use the shared revision transport envelope (#1627).
11480
+ * - 3: hidden business-source maps and private locations are removed before public projection (#1611).
11481
+ * - 2: pages carry intent-only `runtimeJoins` in place of compiled
11482
+ * `runtimeBoundaries` (issue 1422).
11483
+ */
11484
+ const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 5;
11485
+ function toNonEmptyString(value) {
11486
+ if (value === null || value === void 0) return null;
11487
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
11488
+ const normalized = String(value).trim();
11489
+ return normalized.length > 0 ? normalized : null;
11382
11490
  }
11383
- function assertNever(value) {
11384
- throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
11491
+ function normalizeRuntimePublicPath(value) {
11492
+ const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
11493
+ const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
11494
+ return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
11385
11495
  }
11386
- function resolveKnownEndpointPolicy(endpoint, params) {
11387
- if (isPreviewRequest(endpoint, params)) return {
11388
- kind: "live-only",
11389
- endpoint,
11390
- reason: "preview_request"
11496
+ function normalizeRuntimeHostname(value) {
11497
+ const trimmed = value.trim().toLowerCase();
11498
+ return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
11499
+ }
11500
+ function normalizeScalar(value) {
11501
+ return value.trim().toLowerCase();
11502
+ }
11503
+ function unsafeAsPublishedRuntimeCacheKey(value) {
11504
+ return value;
11505
+ }
11506
+ function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
11507
+ return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
11508
+ }
11509
+ function selectSiteRuntimeIdentity(params) {
11510
+ const slug = toNonEmptyString(params.slug);
11511
+ if (slug !== null) return { slug: normalizeScalar(slug) };
11512
+ const domain = toNonEmptyString(params.domain);
11513
+ if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
11514
+ const id = toNonEmptyString(params.id);
11515
+ if (id !== null) return { id: normalizeScalar(id) };
11516
+ return null;
11517
+ }
11518
+ function deriveGetSiteKey(params) {
11519
+ const identity = selectSiteRuntimeIdentity(params);
11520
+ if (identity === null) return {
11521
+ ok: false,
11522
+ error: {
11523
+ kind: "missing_site_identity",
11524
+ acceptedParams: [
11525
+ "slug",
11526
+ "domain",
11527
+ "id"
11528
+ ]
11529
+ }
11391
11530
  };
11392
- if (endpoint === "getSite" && isTruthyParam(params.force)) return {
11393
- kind: "live-only",
11394
- endpoint,
11395
- reason: "force_refresh"
11531
+ const normalizedParams = {
11532
+ ...identity,
11533
+ ...toNonEmptyString(params.currentPath) === null ? {} : { currentPath: normalizeRuntimePublicPath(params.currentPath) }
11396
11534
  };
11397
- if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
11398
- kind: "live-only",
11399
- endpoint,
11400
- reason: "safety_sensitive_booking"
11535
+ return {
11536
+ ok: true,
11537
+ endpoint: "getSite",
11538
+ key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
11539
+ normalizedParams
11401
11540
  };
11402
- const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
11403
- if (override.kind === "live-only") return {
11404
- kind: "live-only",
11405
- endpoint,
11406
- reason: override.reason
11541
+ }
11542
+ function deriveGetContentByPathKey(params) {
11543
+ const siteId = toNonEmptyString(params.siteId);
11544
+ if (siteId === null) return {
11545
+ ok: false,
11546
+ error: {
11547
+ kind: "missing_required_param",
11548
+ endpoint: "getContentByPath",
11549
+ param: "siteId"
11550
+ }
11407
11551
  };
11408
- const endpointDefinition = API_ENDPOINTS[endpoint];
11409
- if (endpointDefinition.method !== "GET") return {
11410
- kind: "live-only",
11411
- endpoint,
11412
- reason: "non_get_request"
11552
+ const normalizedParams = {
11553
+ siteId: normalizeScalar(siteId),
11554
+ path: normalizeRuntimePublicPath(params.path),
11555
+ contentContract: "native"
11413
11556
  };
11414
- if (endpointDefinition.auth === "user") return {
11415
- kind: "live-only",
11416
- endpoint,
11417
- reason: "auth_required"
11557
+ return {
11558
+ ok: true,
11559
+ endpoint: "getContentByPath",
11560
+ key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
11561
+ normalizedParams
11418
11562
  };
11419
- switch (override.kind) {
11420
- case "durable-public-stale": return {
11421
- kind: "durable-public-stale",
11422
- endpoint,
11423
- freshTtlSec: getEndpointFreshTtlSec(endpoint),
11424
- staleTtlSec: override.staleTtlSec
11425
- };
11426
- case "memory-only": return {
11427
- kind: "memory-only",
11428
- endpoint,
11429
- freshTtlSec: getEndpointFreshTtlSec(endpoint),
11430
- reason: override.reason
11431
- };
11432
- default: return assertNever(override);
11563
+ }
11564
+ function deriveDurableRuntimeCacheKey(input) {
11565
+ switch (input.endpoint) {
11566
+ case "getSite": return deriveGetSiteKey(input.params);
11567
+ case "getContentByPath": return deriveGetContentByPathKey(input.params);
11433
11568
  }
11434
11569
  }
11435
- function resolveRuntimeCachePolicy(input) {
11436
- if (input.method && input.method.toUpperCase() !== "GET") return {
11437
- kind: "live-only",
11438
- endpoint: input.endpoint,
11439
- reason: "non_get_request"
11440
- };
11441
- if (!isPublicEndpointName(input.endpoint)) return {
11442
- kind: "live-only",
11443
- endpoint: input.endpoint,
11444
- reason: "unknown_endpoint"
11570
+ function isPublishedRuntimeCacheKeyEndpoint(value) {
11571
+ return value === "getSite" || value === "getContentByPath";
11572
+ }
11573
+ function parsePublishedRuntimeCacheKey(value) {
11574
+ const details = parsePublishedRuntimeCacheKeyDetails(value);
11575
+ if (!details.ok) return details;
11576
+ return {
11577
+ ok: true,
11578
+ key: details.key,
11579
+ endpoint: details.endpoint
11445
11580
  };
11446
- return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
11447
11581
  }
11448
- function classifyPublishedRuntimeCacheFreshness(input) {
11449
- const freshUntilMs = Date.parse(input.freshUntil);
11450
- const staleUntilMs = Date.parse(input.staleUntil);
11451
- if (Number.isNaN(freshUntilMs)) return {
11452
- kind: "invalid_timestamp",
11453
- field: "freshUntil"
11582
+ function parsePublishedRuntimeCacheKeyDetails(value) {
11583
+ if (typeof value !== "string") return {
11584
+ ok: false,
11585
+ error: "not_string"
11454
11586
  };
11455
- if (Number.isNaN(staleUntilMs)) return {
11456
- kind: "invalid_timestamp",
11457
- field: "staleUntil"
11587
+ const parts = value.split(":");
11588
+ if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
11589
+ ok: false,
11590
+ error: "invalid_prefix"
11458
11591
  };
11459
- const nowMs = input.now.getTime();
11460
- if (nowMs > staleUntilMs) return { kind: "expired" };
11461
- if (nowMs <= freshUntilMs) return {
11462
- kind: "fresh",
11463
- staleAgeSec: 0
11592
+ const endpoint = parts[2];
11593
+ if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
11594
+ ok: false,
11595
+ error: "unknown_endpoint"
11596
+ };
11597
+ const normalizedParams = {};
11598
+ for (const part of parts.slice(3)) {
11599
+ const separatorIndex = part.indexOf("=");
11600
+ if (separatorIndex <= 0) return {
11601
+ ok: false,
11602
+ error: "invalid_param_encoding"
11603
+ };
11604
+ try {
11605
+ const key = decodeURIComponent(part.slice(0, separatorIndex));
11606
+ normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
11607
+ } catch {
11608
+ return {
11609
+ ok: false,
11610
+ error: "invalid_param_encoding"
11611
+ };
11612
+ }
11613
+ }
11614
+ if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
11615
+ ok: false,
11616
+ error: "invalid_param_encoding"
11464
11617
  };
11465
11618
  return {
11466
- kind: "stale",
11467
- staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
11619
+ ok: true,
11620
+ key: unsafeAsPublishedRuntimeCacheKey(value),
11621
+ endpoint,
11622
+ normalizedParams
11468
11623
  };
11469
11624
  }
11470
- function derivePublishedRuntimeCacheKey(input) {
11471
- const policy = resolveRuntimeCachePolicy({
11472
- endpoint: input.endpoint,
11473
- method: "GET",
11474
- params: input.params
11475
- });
11476
- if (policy.kind !== "durable-public-stale") return {
11625
+ function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
11626
+ const keys = Object.keys(normalizedParams).sort();
11627
+ switch (endpoint) {
11628
+ case "getSite": return [
11629
+ "domain",
11630
+ "id",
11631
+ "slug"
11632
+ ].filter((key) => normalizedParams[key] !== void 0).length === 1 && keys.every((key) => [
11633
+ "currentPath",
11634
+ "domain",
11635
+ "id",
11636
+ "slug"
11637
+ ].includes(key));
11638
+ case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
11639
+ "contentContract",
11640
+ "path",
11641
+ "siteId"
11642
+ ].includes(key));
11643
+ }
11644
+ }
11645
+ function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
11646
+ if (typeof value !== "number") return {
11477
11647
  ok: false,
11478
- error: {
11479
- kind: "not_durable_eligible",
11480
- policy
11481
- }
11648
+ error: "not_number"
11649
+ };
11650
+ if (!Number.isInteger(value)) return {
11651
+ ok: false,
11652
+ error: "not_integer"
11653
+ };
11654
+ if (value <= 0) return {
11655
+ ok: false,
11656
+ error: "not_positive"
11657
+ };
11658
+ return {
11659
+ ok: true,
11660
+ value
11482
11661
  };
11483
- return deriveDurableRuntimeCacheKey(input);
11484
11662
  }
11485
11663
  //#endregion
11486
- //#region src/client/contentReadOperations.ts
11487
- function planPublishedRuntimeCache(input) {
11488
- const policy = resolveRuntimeCachePolicy({
11664
+ //#region src/client/runtimeCachePolicy.ts
11665
+ const DEFAULT_STALE_TTL_SEC = 1440 * 60;
11666
+ const DEFAULT_MEMORY_TTL_SEC = 60;
11667
+ const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
11668
+ getSite: {
11669
+ kind: "durable-public-stale",
11670
+ staleTtlSec: DEFAULT_STALE_TTL_SEC
11671
+ },
11672
+ getContentByPath: {
11673
+ kind: "durable-public-stale",
11674
+ staleTtlSec: DEFAULT_STALE_TTL_SEC
11675
+ },
11676
+ resolveRouteOutcome: {
11677
+ kind: "memory-only",
11678
+ reason: "durable_rollout_pending"
11679
+ },
11680
+ resolveRouteDecision: {
11681
+ kind: "memory-only",
11682
+ reason: "durable_rollout_pending"
11683
+ },
11684
+ listPublishedEntries: {
11685
+ kind: "memory-only",
11686
+ reason: "durable_rollout_pending"
11687
+ },
11688
+ getPublishedEntryPreview: {
11689
+ kind: "memory-only",
11690
+ reason: "durable_rollout_pending"
11691
+ },
11692
+ getPublicFormById: {
11693
+ kind: "memory-only",
11694
+ reason: "durable_rollout_pending"
11695
+ },
11696
+ listPublicForms: {
11697
+ kind: "memory-only",
11698
+ reason: "durable_rollout_pending"
11699
+ },
11700
+ getPublicBookingServices: {
11701
+ kind: "live-only",
11702
+ reason: "safety_sensitive_booking"
11703
+ },
11704
+ getPublicWeeklySlotAvailability: {
11705
+ kind: "live-only",
11706
+ reason: "safety_sensitive_booking"
11707
+ },
11708
+ getPublicChallenge: {
11709
+ kind: "live-only",
11710
+ reason: "challenge_endpoint"
11711
+ },
11712
+ listPublicEvents: {
11713
+ kind: "memory-only",
11714
+ reason: "durable_rollout_pending"
11715
+ },
11716
+ batchBlockLoaders: {
11717
+ kind: "live-only",
11718
+ reason: "opaque_batch_loader"
11719
+ },
11720
+ listPublicTeamMembers: {
11721
+ kind: "memory-only",
11722
+ reason: "durable_rollout_pending"
11723
+ },
11724
+ listPublicProducts: {
11725
+ kind: "memory-only",
11726
+ reason: "durable_rollout_pending"
11727
+ },
11728
+ listPublicPasses: {
11729
+ kind: "live-only",
11730
+ reason: "safety_sensitive_booking"
11731
+ },
11732
+ listPublicMemberships: {
11733
+ kind: "live-only",
11734
+ reason: "safety_sensitive_booking"
11735
+ },
11736
+ checkRedirect: {
11737
+ kind: "memory-only",
11738
+ reason: "durable_rollout_pending"
11739
+ },
11740
+ getRoutableContent: {
11741
+ kind: "live-only",
11742
+ reason: "auth_required"
11743
+ },
11744
+ getPublicRoutableContent: {
11745
+ kind: "memory-only",
11746
+ reason: "durable_rollout_pending"
11747
+ },
11748
+ getPublicSitemapRoutes: {
11749
+ kind: "memory-only",
11750
+ reason: "durable_rollout_pending"
11751
+ }
11752
+ };
11753
+ const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
11754
+ function isPublicEndpointName(endpoint) {
11755
+ return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
11756
+ }
11757
+ function isTruthyParam(value) {
11758
+ return value === true || value === "true" || value === 1 || value === "1";
11759
+ }
11760
+ function isPreviewRequest(endpoint, params) {
11761
+ if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
11762
+ if (endpoint === "listPublishedEntries") return params.stage === "preview";
11763
+ return false;
11764
+ }
11765
+ function getEndpointFreshTtlSec(endpoint) {
11766
+ return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
11767
+ }
11768
+ function assertNever(value) {
11769
+ throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
11770
+ }
11771
+ function resolveKnownEndpointPolicy(endpoint, params) {
11772
+ if (isPreviewRequest(endpoint, params)) return {
11773
+ kind: "live-only",
11774
+ endpoint,
11775
+ reason: "preview_request"
11776
+ };
11777
+ if (endpoint === "getSite" && isTruthyParam(params.force)) return {
11778
+ kind: "live-only",
11779
+ endpoint,
11780
+ reason: "force_refresh"
11781
+ };
11782
+ if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
11783
+ kind: "live-only",
11784
+ endpoint,
11785
+ reason: "safety_sensitive_booking"
11786
+ };
11787
+ const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
11788
+ if (override.kind === "live-only") return {
11789
+ kind: "live-only",
11790
+ endpoint,
11791
+ reason: override.reason
11792
+ };
11793
+ const endpointDefinition = API_ENDPOINTS[endpoint];
11794
+ if (endpointDefinition.method !== "GET") return {
11795
+ kind: "live-only",
11796
+ endpoint,
11797
+ reason: "non_get_request"
11798
+ };
11799
+ if (endpointDefinition.auth === "user") return {
11800
+ kind: "live-only",
11801
+ endpoint,
11802
+ reason: "auth_required"
11803
+ };
11804
+ switch (override.kind) {
11805
+ case "durable-public-stale": return {
11806
+ kind: "durable-public-stale",
11807
+ endpoint,
11808
+ freshTtlSec: getEndpointFreshTtlSec(endpoint),
11809
+ staleTtlSec: override.staleTtlSec
11810
+ };
11811
+ case "memory-only": return {
11812
+ kind: "memory-only",
11813
+ endpoint,
11814
+ freshTtlSec: getEndpointFreshTtlSec(endpoint),
11815
+ reason: override.reason
11816
+ };
11817
+ default: return assertNever(override);
11818
+ }
11819
+ }
11820
+ function resolveRuntimeCachePolicy(input) {
11821
+ if (input.method && input.method.toUpperCase() !== "GET") return {
11822
+ kind: "live-only",
11823
+ endpoint: input.endpoint,
11824
+ reason: "non_get_request"
11825
+ };
11826
+ if (!isPublicEndpointName(input.endpoint)) return {
11827
+ kind: "live-only",
11828
+ endpoint: input.endpoint,
11829
+ reason: "unknown_endpoint"
11830
+ };
11831
+ return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
11832
+ }
11833
+ function classifyPublishedRuntimeCacheFreshness(input) {
11834
+ const freshUntilMs = Date.parse(input.freshUntil);
11835
+ const staleUntilMs = Date.parse(input.staleUntil);
11836
+ if (Number.isNaN(freshUntilMs)) return {
11837
+ kind: "invalid_timestamp",
11838
+ field: "freshUntil"
11839
+ };
11840
+ if (Number.isNaN(staleUntilMs)) return {
11841
+ kind: "invalid_timestamp",
11842
+ field: "staleUntil"
11843
+ };
11844
+ const nowMs = input.now.getTime();
11845
+ if (nowMs > staleUntilMs) return { kind: "expired" };
11846
+ if (nowMs <= freshUntilMs) return {
11847
+ kind: "fresh",
11848
+ staleAgeSec: 0
11849
+ };
11850
+ return {
11851
+ kind: "stale",
11852
+ staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
11853
+ };
11854
+ }
11855
+ function derivePublishedRuntimeCacheKey(input) {
11856
+ const policy = resolveRuntimeCachePolicy({
11857
+ endpoint: input.endpoint,
11858
+ method: "GET",
11859
+ params: input.params
11860
+ });
11861
+ if (policy.kind !== "durable-public-stale") return {
11862
+ ok: false,
11863
+ error: {
11864
+ kind: "not_durable_eligible",
11865
+ policy
11866
+ }
11867
+ };
11868
+ return deriveDurableRuntimeCacheKey(input);
11869
+ }
11870
+ //#endregion
11871
+ //#region src/client/contentReadOperations.ts
11872
+ function planPublishedRuntimeCache(input) {
11873
+ const policy = resolveRuntimeCachePolicy({
11489
11874
  endpoint: input.endpoint,
11490
11875
  method: "GET",
11491
11876
  params: input.params
@@ -11499,470 +11884,188 @@ function planPublishedRuntimeCache(input) {
11499
11884
  normalizedParams: keyResult.normalizedParams,
11500
11885
  freshTtlSec: policy.freshTtlSec,
11501
11886
  staleTtlSec: policy.staleTtlSec,
11502
- siteId: input.siteId ?? null
11503
- };
11504
- }
11505
- function siteApiParams(params) {
11506
- return {
11507
- ...params.slug ? { slug: params.slug } : {},
11508
- ...params.domain ? { domain: params.domain } : {},
11509
- ...params.id ? { id: params.id } : {},
11510
- ...params.currentPath ? { currentPath: params.currentPath } : {},
11511
- ...params.force ? { force: "true" } : {}
11512
- };
11513
- }
11514
- function siteReadIdentity(params) {
11515
- const identifier = params.slug || params.domain || params.id;
11516
- if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
11517
- return identifier;
11518
- }
11519
- function planSiteRead(params) {
11520
- const identifier = siteReadIdentity(params);
11521
- const { slug, domain, id, currentPath, force } = params;
11522
- const publishedRuntimeCache = planPublishedRuntimeCache({
11523
- endpoint: "getSite",
11524
- params: {
11525
- slug,
11526
- domain,
11527
- id,
11528
- currentPath,
11529
- force
11530
- }
11531
- });
11532
- return {
11533
- publishedRuntimeCache,
11534
- prebuildIdentifier: id || slug || domain,
11535
- cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
11536
- };
11537
- }
11538
- async function readSiteWithResilience(input, params) {
11539
- const { slug, domain, id, signal, force } = params;
11540
- const plan = planSiteRead(params);
11541
- const prebuildId = plan.prebuildIdentifier;
11542
- const prebuild = input.prebuildLoader;
11543
- return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
11544
- endpoint: "getSite",
11545
- params: siteApiParams(params),
11546
- options: {
11547
- signal: requestSignal,
11548
- ...force ? { cache: "no-store" } : {}
11549
- }
11550
- }), {
11551
- signal,
11552
- force,
11553
- publishedRuntimeCache: plan.publishedRuntimeCache,
11554
- cacheTags: buildSiteReadTags({
11555
- slug,
11556
- domain,
11557
- id
11558
- }),
11559
- prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
11560
- });
11561
- }
11562
- async function readPageWithResilience(input, params) {
11563
- const { siteId, path, preview = false, signal } = params;
11564
- const publishedRuntimeCache = planPublishedRuntimeCache({
11565
- endpoint: "getContentByPath",
11566
- params: {
11567
- siteId,
11568
- path,
11569
- preview
11570
- },
11571
- siteId
11572
- });
11573
- const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
11574
- const result = await input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
11575
- endpoint: "getContentByPath",
11576
- params: {
11577
- siteId,
11578
- path,
11579
- preview: String(preview)
11580
- },
11581
- options: { signal: requestSignal }
11582
- }), {
11583
- pageRead: { siteId },
11584
- preview,
11585
- signal,
11586
- publishedRuntimeCache,
11587
- cacheTags: buildSiteReadTags({ siteId }),
11588
- prebuildFallback: void 0
11589
- });
11590
- if (!preview) await observePageReadResponse(input.frameworkCache, siteId, result.data);
11591
- return result;
11592
- }
11593
- function createContentReadOperations(input) {
11594
- return {
11595
- getSiteWithResilience: (params) => readSiteWithResilience(input, params),
11596
- getPageWithResilience: (params) => readPageWithResilience(input, params)
11597
- };
11598
- }
11599
- //#endregion
11600
- //#region src/client/publicAppointmentReadOperations.ts
11601
- function createPublicAppointmentReadOperations(deps) {
11602
- return {
11603
- async getPublicBookingServices(params) {
11604
- const { siteId, ids, signal } = params;
11605
- if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
11606
- const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
11607
- return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
11608
- const apiParams = {
11609
- siteId,
11610
- ...ids && { ids }
11611
- };
11612
- return await deps.apiClient({
11613
- endpoint: "getPublicBookingServices",
11614
- params: apiParams,
11615
- options: { signal: requestSignal }
11616
- });
11617
- }, {
11618
- signal,
11619
- cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
11620
- });
11621
- },
11622
- async getPublicWeeklySlotAvailability(params) {
11623
- const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
11624
- if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
11625
- const cacheKey = [
11626
- "public-weekly-slot-availability",
11627
- siteId,
11628
- serviceId,
11629
- resourceId ?? "",
11630
- horizonWeeks ?? "",
11631
- timezone ?? ""
11632
- ].join(":");
11633
- return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
11634
- const apiParams = {
11635
- siteId,
11636
- serviceId,
11637
- ...resourceId && { resourceId },
11638
- ...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
11639
- ...timezone && { timezone }
11640
- };
11641
- return await deps.apiClient({
11642
- endpoint: "getPublicWeeklySlotAvailability",
11643
- params: apiParams,
11644
- options: { signal: requestSignal }
11645
- });
11646
- }, {
11647
- signal,
11648
- cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
11649
- });
11650
- }
11651
- };
11652
- }
11653
- //#endregion
11654
- //#region src/client/publicEventReadOperations.ts
11655
- function createPublicEventReadOperations(deps) {
11656
- return { async listPublicEventCalendarWindow({ signal, ...params }) {
11657
- return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
11658
- endpoint: "listPublicEventCalendarWindow",
11659
- params: {
11660
- ...params,
11661
- limit: params.limit === void 0 ? void 0 : String(params.limit)
11662
- },
11663
- options: { signal: requestSignal }
11664
- }), {
11665
- signal,
11666
- cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
11667
- });
11668
- } };
11669
- }
11670
- //#endregion
11671
- //#region src/client/combineAbortSignals.ts
11672
- /** Combine signals into one that aborts when any input aborts. */
11673
- function combineAbortSignals(...signals) {
11674
- const controller = new AbortController();
11675
- for (const signal of signals) {
11676
- if (signal.aborted) {
11677
- controller.abort(signal.reason);
11678
- break;
11679
- }
11680
- signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
11681
- }
11682
- return controller.signal;
11683
- }
11684
- //#endregion
11685
- //#region src/client/resilience.ts
11686
- const DEFAULT_RETRY_CONFIG = {
11687
- maxAttempts: 3,
11688
- baseDelayMs: 200,
11689
- maxDelayMs: 2e3,
11690
- jitter: "full"
11691
- };
11692
- const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
11693
- failureThreshold: 5,
11694
- resetTimeoutMs: 3e4,
11695
- halfOpenMaxRequests: 2
11696
- };
11697
- /**
11698
- * Error codes that indicate permanent infrastructure failures.
11699
- * These should NOT be retried as the server is definitively unreachable.
11700
- */
11701
- const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
11702
- "ECONNREFUSED",
11703
- "ENOTFOUND",
11704
- "EAI_AGAIN"
11705
- ]);
11706
- /**
11707
- * Error codes that indicate transient network issues.
11708
- * These MAY succeed on retry as the server was reachable but had a hiccup.
11709
- */
11710
- const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
11711
- "ECONNRESET",
11712
- "EPIPE",
11713
- "ETIMEDOUT",
11714
- "ESOCKETTIMEDOUT"
11715
- ]);
11716
- /**
11717
- * Node.js network error codes (POSIX style).
11718
- * These are the codes we're looking for in the cause chain.
11719
- */
11720
- const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
11721
- "ECONNREFUSED",
11722
- "ENOTFOUND",
11723
- "EAI_AGAIN",
11724
- "ECONNRESET",
11725
- "EPIPE",
11726
- "ETIMEDOUT",
11727
- "ESOCKETTIMEDOUT"
11728
- ]);
11729
- /**
11730
- * Check if a string is a Node.js network error code (not an API error code).
11731
- * API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
11732
- */
11733
- function isNodeNetworkErrorCode(code) {
11734
- return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
11735
- }
11736
- /**
11737
- * Extract the Node.js error code from an error's cause chain.
11738
- * Handles nested cause chains like:
11739
- * RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
11740
- *
11741
- * Skips API error codes (like 'network:connection_error') and only returns
11742
- * actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
11743
- *
11744
- * @example
11745
- * RiverbankApiError: Network request failed
11746
- * [cause]: TypeError: fetch failed
11747
- * [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
11748
- * code: 'ECONNREFUSED'
11749
- */
11750
- function getErrorCodeFromCause(error) {
11751
- let current = error;
11752
- while (current) {
11753
- const nodeError = current;
11754
- if (nodeError.code && typeof nodeError.code === "string") {
11755
- if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
11756
- }
11757
- current = current.cause;
11758
- }
11759
- }
11760
- /**
11761
- * Determine if an error is transient and should trigger circuit breaker / retry
11762
- *
11763
- * Transient (opens circuit, triggers retry):
11764
- * - Network errors (status 0) that are NOT permanent infrastructure failures
11765
- * - 5xx server errors
11766
- * - 429 rate limit
11767
- * - Connection reset, broken pipe, timeout
11768
- *
11769
- * Permanent (does NOT open circuit, no retry):
11770
- * - 4xx client errors (400, 401, 403, 404)
11771
- * - Validation errors
11772
- * - ECONNREFUSED (server not running)
11773
- * - ENOTFOUND (DNS failure)
11774
- */
11775
- function isTransientError(error) {
11776
- if (error instanceof RiverbankApiError) {
11777
- const errorCode = getErrorCodeFromCause(error);
11778
- if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
11779
- if (error.status === 0) return true;
11780
- if (error.status === 429) return true;
11781
- if (error.status >= 500) return true;
11782
- return false;
11783
- }
11784
- if (error instanceof TypeError) {
11785
- const errorCode = getErrorCodeFromCause(error);
11786
- if (errorCode) {
11787
- if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
11788
- if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
11789
- }
11790
- return true;
11791
- }
11792
- return true;
11793
- }
11794
- /**
11795
- * Calculate backoff delay for retry attempt
11796
- *
11797
- * Uses exponential backoff with optional full jitter.
11798
- * Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
11799
- */
11800
- function calculateBackoff(attempt, config) {
11801
- const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
11802
- const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
11803
- const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
11804
- const exponential = baseDelayMs * Math.pow(2, attempt - 1);
11805
- const capped = Math.min(exponential, maxDelayMs);
11806
- if (jitter === "full") return Math.random() * capped;
11807
- return capped;
11808
- }
11809
- /**
11810
- * Circuit breaker for fail-fast behavior
11811
- *
11812
- * States:
11813
- * - closed: Normal operation, requests allowed
11814
- * - open: Too many failures, requests blocked
11815
- * - half-open: Testing if service recovered, limited requests allowed
11816
- */
11817
- var CircuitBreaker = class {
11818
- constructor(config) {
11819
- this.state = "closed";
11820
- this.failureCount = 0;
11821
- this.successCount = 0;
11822
- this.openUntil = 0;
11823
- this.halfOpenRequests = 0;
11824
- this.config = {
11825
- failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
11826
- resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
11827
- halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
11828
- };
11829
- }
11830
- /**
11831
- * Check if circuit is open (requests should be blocked)
11832
- * Also handles automatic transition from open to half-open after timeout
11833
- */
11834
- isOpen() {
11835
- if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
11836
- return this.state === "open";
11837
- }
11838
- /**
11839
- * Check if a request can be attempted
11840
- * - closed: always yes
11841
- * - open: always no
11842
- * - half-open: limited number of probes
11843
- */
11844
- canAttempt() {
11845
- if (this.state === "closed") return true;
11846
- if (this.state === "open") return false;
11847
- return this.halfOpenRequests < this.config.halfOpenMaxRequests;
11848
- }
11849
- /**
11850
- * Increment half-open request counter (call before making request in half-open)
11851
- */
11852
- incrementHalfOpenRequests() {
11853
- if (this.state === "half-open") this.halfOpenRequests++;
11854
- }
11855
- /**
11856
- * Record a successful request
11857
- */
11858
- recordSuccess() {
11859
- if (this.state === "half-open") {
11860
- this.successCount++;
11861
- if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
11862
- } else this.failureCount = 0;
11863
- }
11864
- /**
11865
- * Record a failed request
11866
- * Only counts transient failures toward circuit breaker threshold
11867
- */
11868
- recordFailure(error) {
11869
- if (!isTransientError(error)) return;
11870
- this.failureCount++;
11871
- if (this.state === "half-open") this.transitionTo("open");
11872
- else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
11873
- }
11874
- /**
11875
- * Get current circuit state
11876
- */
11877
- getState() {
11878
- return {
11879
- state: this.state,
11880
- failureCount: this.failureCount,
11881
- openUntil: this.state === "open" ? this.openUntil : void 0
11882
- };
11883
- }
11884
- /**
11885
- * Transition to a new state
11886
- */
11887
- transitionTo(newState) {
11888
- this.state = newState;
11889
- if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
11890
- else if (newState === "half-open") {
11891
- this.halfOpenRequests = 0;
11892
- this.successCount = 0;
11893
- } else if (newState === "closed") {
11894
- this.failureCount = 0;
11895
- this.successCount = 0;
11896
- this.halfOpenRequests = 0;
11887
+ siteId: input.siteId ?? null
11888
+ };
11889
+ }
11890
+ function siteApiParams(params) {
11891
+ return {
11892
+ ...params.slug ? { slug: params.slug } : {},
11893
+ ...params.domain ? { domain: params.domain } : {},
11894
+ ...params.id ? { id: params.id } : {},
11895
+ ...params.currentPath ? { currentPath: params.currentPath } : {},
11896
+ ...params.force ? { force: "true" } : {}
11897
+ };
11898
+ }
11899
+ function siteReadIdentity(params) {
11900
+ const identifier = params.slug || params.domain || params.id;
11901
+ if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
11902
+ return identifier;
11903
+ }
11904
+ function planSiteRead(params) {
11905
+ const identifier = siteReadIdentity(params);
11906
+ const { slug, domain, id, currentPath, force } = params;
11907
+ const publishedRuntimeCache = planPublishedRuntimeCache({
11908
+ endpoint: "getSite",
11909
+ params: {
11910
+ slug,
11911
+ domain,
11912
+ id,
11913
+ currentPath,
11914
+ force
11897
11915
  }
11898
- }
11899
- };
11900
- /**
11901
- * Fetch with timeout and retry logic
11902
- *
11903
- * @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
11904
- * @param config - Retry configuration
11905
- * @returns Result from successful fetch
11906
- * @throws Last error after all retries exhausted
11907
- */
11908
- async function fetchWithTimeoutAndRetry(fetcher, config) {
11909
- const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
11910
- const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
11911
- let lastError;
11912
- for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
11913
- const controller = new AbortController();
11914
- const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
11915
- try {
11916
- return await fetcher(controller.signal);
11917
- } finally {
11918
- clearTimeout(timeoutId);
11916
+ });
11917
+ return {
11918
+ publishedRuntimeCache,
11919
+ prebuildIdentifier: id || slug || domain,
11920
+ cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
11921
+ };
11922
+ }
11923
+ async function readSiteWithResilience(input, params) {
11924
+ const { slug, domain, id, signal, force } = params;
11925
+ const plan = planSiteRead(params);
11926
+ const prebuildId = plan.prebuildIdentifier;
11927
+ const prebuild = input.prebuildLoader;
11928
+ return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
11929
+ endpoint: "getSite",
11930
+ params: siteApiParams(params),
11931
+ options: {
11932
+ signal: requestSignal,
11933
+ ...force ? { cache: "no-store" } : {}
11919
11934
  }
11920
- } catch (error) {
11921
- lastError = error;
11922
- if (!shouldRetryError(error, config.retryOn)) throw error;
11923
- if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
11924
- }
11925
- throw lastError;
11935
+ }), {
11936
+ signal,
11937
+ force,
11938
+ publishedRuntimeCache: plan.publishedRuntimeCache,
11939
+ cacheTags: buildSiteReadTags({
11940
+ slug,
11941
+ domain,
11942
+ id
11943
+ }),
11944
+ prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
11945
+ });
11926
11946
  }
11927
- /**
11928
- * Check if an error is an AbortError (from AbortController.abort() or timeout)
11929
- */
11930
- function isAbortError$1(error) {
11931
- if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
11932
- if (error instanceof Error && error.name === "AbortError") return true;
11933
- return false;
11947
+ async function readPageWithResilience(input, params) {
11948
+ const { siteId, path, preview = false, signal } = params;
11949
+ const publishedRuntimeCache = planPublishedRuntimeCache({
11950
+ endpoint: "getContentByPath",
11951
+ params: {
11952
+ siteId,
11953
+ path,
11954
+ preview
11955
+ },
11956
+ siteId
11957
+ });
11958
+ const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
11959
+ const result = await input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
11960
+ endpoint: "getContentByPath",
11961
+ params: {
11962
+ siteId,
11963
+ path,
11964
+ preview: String(preview)
11965
+ },
11966
+ options: { signal: requestSignal }
11967
+ }), {
11968
+ pageRead: { siteId },
11969
+ preview,
11970
+ signal,
11971
+ publishedRuntimeCache,
11972
+ cacheTags: buildSiteReadTags({ siteId }),
11973
+ prebuildFallback: void 0
11974
+ });
11975
+ if (!preview && result.resilience.source !== "live") await observePageReadResponse(input.frameworkCache, siteId, result.data);
11976
+ return result;
11934
11977
  }
11935
- /**
11936
- * Check if an error should be retried
11937
- */
11938
- function shouldRetryError(error, customRetryOn) {
11939
- if (isAbortError$1(error)) return false;
11940
- if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
11941
- return isTransientError(error);
11978
+ function createContentReadOperations(input) {
11979
+ return {
11980
+ getSiteWithResilience: (params) => readSiteWithResilience(input, params),
11981
+ getPageWithResilience: (params) => readPageWithResilience(input, params)
11982
+ };
11942
11983
  }
11943
- /**
11944
- * Get delay before retrying, respecting Retry-After if present
11945
- */
11946
- function getRetryDelay(error, attempt, config) {
11947
- if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
11948
- return calculateBackoff(attempt, config);
11984
+ //#endregion
11985
+ //#region src/client/publicAppointmentReadOperations.ts
11986
+ function createPublicAppointmentReadOperations(deps) {
11987
+ return {
11988
+ async getPublicBookingServices(params) {
11989
+ const { siteId, ids, signal } = params;
11990
+ if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
11991
+ const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
11992
+ return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
11993
+ const apiParams = {
11994
+ siteId,
11995
+ ...ids && { ids }
11996
+ };
11997
+ return await deps.apiClient({
11998
+ endpoint: "getPublicBookingServices",
11999
+ params: apiParams,
12000
+ options: { signal: requestSignal }
12001
+ });
12002
+ }, {
12003
+ signal,
12004
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
12005
+ });
12006
+ },
12007
+ async getPublicWeeklySlotAvailability(params) {
12008
+ const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
12009
+ if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
12010
+ const cacheKey = [
12011
+ "public-weekly-slot-availability",
12012
+ siteId,
12013
+ serviceId,
12014
+ resourceId ?? "",
12015
+ horizonWeeks ?? "",
12016
+ timezone ?? ""
12017
+ ].join(":");
12018
+ return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
12019
+ const apiParams = {
12020
+ siteId,
12021
+ serviceId,
12022
+ ...resourceId && { resourceId },
12023
+ ...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
12024
+ ...timezone && { timezone }
12025
+ };
12026
+ return await deps.apiClient({
12027
+ endpoint: "getPublicWeeklySlotAvailability",
12028
+ params: apiParams,
12029
+ options: { signal: requestSignal }
12030
+ });
12031
+ }, {
12032
+ signal,
12033
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
12034
+ });
12035
+ }
12036
+ };
11949
12037
  }
11950
- /**
11951
- * Sleep for specified milliseconds
11952
- */
11953
- function sleep(ms) {
11954
- return new Promise((resolve) => setTimeout(resolve, ms));
12038
+ //#endregion
12039
+ //#region src/client/publicEventReadOperations.ts
12040
+ function createPublicEventReadOperations(deps) {
12041
+ return { async listPublicEventCalendarWindow({ signal, ...params }) {
12042
+ return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
12043
+ endpoint: "listPublicEventCalendarWindow",
12044
+ params: {
12045
+ ...params,
12046
+ limit: params.limit === void 0 ? void 0 : String(params.limit)
12047
+ },
12048
+ options: { signal: requestSignal }
12049
+ }), {
12050
+ signal,
12051
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
12052
+ });
12053
+ } };
11955
12054
  }
11956
- /**
11957
- * Error thrown when circuit breaker is open
11958
- */
11959
- var CircuitOpenError = class extends Error {
11960
- constructor(state) {
11961
- super("Circuit breaker is open");
11962
- this.name = "CircuitOpenError";
11963
- this.circuitState = state;
12055
+ //#endregion
12056
+ //#region src/client/combineAbortSignals.ts
12057
+ /** Combine signals into one that aborts when any input aborts. */
12058
+ function combineAbortSignals(...signals) {
12059
+ const controller = new AbortController();
12060
+ for (const signal of signals) {
12061
+ if (signal.aborted) {
12062
+ controller.abort(signal.reason);
12063
+ break;
12064
+ }
12065
+ signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
11964
12066
  }
11965
- };
12067
+ return controller.signal;
12068
+ }
11966
12069
  //#endregion
11967
12070
  //#region src/client/publicLoaderCacheAccess.ts
11968
12071
  function shouldWrite(cacheEnabled, force) {
@@ -12190,6 +12293,7 @@ function getNetworkErrorCode(error) {
12190
12293
  * - AbortError (let propagate raw for consumer detection)
12191
12294
  */
12192
12295
  function convertToTypedError(error) {
12296
+ rethrowClientFrameworkSignal(error);
12193
12297
  if (isAbortError(error)) throw error;
12194
12298
  if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
12195
12299
  code: error.code,
@@ -12247,6 +12351,15 @@ function resolveAuth(config) {
12247
12351
  };
12248
12352
  throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
12249
12353
  }
12354
+ /** The framework adapter is fixed at construction: `@riverbankcms/sdk/next` supplies Next's. */
12355
+ function createRuntimeApiClient(deps, config, authConfig) {
12356
+ const frameworkCache = config.frameworkCache;
12357
+ const requestOptions = frameworkCache ? {
12358
+ ...sdkRequestOptions,
12359
+ frameworkCache
12360
+ } : sdkRequestOptions;
12361
+ return withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, requestOptions) : deps.createBearerAPIClient(authConfig.type === "api-key" ? authConfig.key : authConfig.token, config.baseUrl, requestOptions), config.defaultHeaders);
12362
+ }
12250
12363
  const defaultRiverbankClientDeps = {
12251
12364
  createBearerAPIClient: createRuntimeBearerAPIClient,
12252
12365
  createInternalAPIClient: createRuntimeInternalAPIClient
@@ -12278,11 +12391,12 @@ function resolveMemoryCachePolicy(config) {
12278
12391
  servesFreshMemoryHits: enabled ?? !isRunningInNextServer()
12279
12392
  };
12280
12393
  }
12281
- const frameworkCacheInstallers = /* @__PURE__ */ new WeakMap();
12282
- /** Install host effects on an existing SDK client without replacing its cache or resilience state. */
12283
- function installFrameworkCache(client, adapter) {
12284
- frameworkCacheInstallers.get(client)?.(adapter);
12285
- return client;
12394
+ /** The server marks a page built with parts missing (`x-riverbank-page-storage: no-store`); no SDK cache may keep it. */
12395
+ function readLive(response) {
12396
+ return {
12397
+ data: unwrapResponse(response),
12398
+ storable: !(response.success && response.meta?.storage === "no-store")
12399
+ };
12286
12400
  }
12287
12401
  function createRiverbankClient(config) {
12288
12402
  return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
@@ -12322,18 +12436,8 @@ function createRiverbankClientWithDeps(deps, config) {
12322
12436
  keyType = "preview";
12323
12437
  break;
12324
12438
  }
12325
- function createApiClient(frameworkCache) {
12326
- const requestOptions = frameworkCache ? {
12327
- ...sdkRequestOptions,
12328
- frameworkCache
12329
- } : sdkRequestOptions;
12330
- return withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, requestOptions) : deps.createBearerAPIClient(authConfig.type === "api-key" ? authConfig.key : authConfig.token, config.baseUrl, requestOptions), config.defaultHeaders);
12331
- }
12332
- const framework = {
12333
- adapter: config.frameworkCache,
12334
- apiClient: createApiClient(config.frameworkCache)
12335
- };
12336
- const apiClient = (params) => framework.apiClient(params);
12439
+ const frameworkCache = config.frameworkCache;
12440
+ const apiClient = createRuntimeApiClient(deps, config, authConfig);
12337
12441
  const cache = new SimpleCache({
12338
12442
  maxSize: cacheMaxSize,
12339
12443
  ttl: cacheTTL,
@@ -12503,31 +12607,37 @@ function createRiverbankClientWithDeps(deps, config) {
12503
12607
  }));
12504
12608
  throw new CircuitOpenError(circuitState);
12505
12609
  }
12506
- try {
12507
- let data;
12508
- if (resilienceEnabled) {
12509
- if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
12510
- data = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
12511
- const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
12512
- try {
12513
- return unwrapResponse(await fetcher(combinedSignal));
12514
- } catch (error) {
12515
- convertToTypedError(error);
12516
- }
12517
- }, {
12518
- ...retryConfig,
12519
- requestTimeoutMs
12520
- });
12521
- circuitBreaker.recordSuccess();
12522
- } else try {
12523
- data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
12610
+ const storeLive = async (data) => {
12611
+ if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, memoryWritePolicy(options.pageRead, data, options.cacheTags, cacheTTL));
12612
+ if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
12613
+ };
12614
+ const fetchLive = async () => {
12615
+ if (!resilienceEnabled) try {
12616
+ return readLive(await fetcher(options.signal ?? new AbortController().signal));
12524
12617
  } catch (error) {
12525
12618
  convertToTypedError(error);
12526
12619
  }
12527
- if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, memoryWritePolicy(options.pageRead, data, options.cacheTags, cacheTTL));
12528
- if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
12620
+ if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
12621
+ const live = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
12622
+ const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
12623
+ try {
12624
+ return readLive(await fetcher(combinedSignal));
12625
+ } catch (error) {
12626
+ convertToTypedError(error);
12627
+ }
12628
+ }, {
12629
+ ...retryConfig,
12630
+ requestTimeoutMs
12631
+ });
12632
+ circuitBreaker.recordSuccess();
12633
+ return live;
12634
+ };
12635
+ try {
12636
+ const { data, storable } = await fetchLive();
12637
+ if (storable) await storeLive(data);
12529
12638
  return emitStatus("live", data, statusDetails());
12530
12639
  } catch (error) {
12640
+ rethrowClientFrameworkSignal(error);
12531
12641
  if (isPageReadRefusal(options.pageRead, error)) throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({ error: getRiverbankErrorInfo(error) })).resilience);
12532
12642
  if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
12533
12643
  if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
@@ -12567,9 +12677,7 @@ function createRiverbankClientWithDeps(deps, config) {
12567
12677
  apiClient,
12568
12678
  resilientFetch,
12569
12679
  prebuildLoader,
12570
- get frameworkCache() {
12571
- return framework.adapter;
12572
- }
12680
+ frameworkCache
12573
12681
  });
12574
12682
  const eventReads = createPublicEventReadOperations({
12575
12683
  apiClient,
@@ -12593,7 +12701,7 @@ function createRiverbankClientWithDeps(deps, config) {
12593
12701
  prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
12594
12702
  }));
12595
12703
  }
12596
- const client = {
12704
+ return {
12597
12705
  async getSite(params) {
12598
12706
  return (await contentReads.getSiteWithResilience(params)).data;
12599
12707
  },
@@ -12958,14 +13066,11 @@ function createRiverbankClientWithDeps(deps, config) {
12958
13066
  },
12959
13067
  getBaseUrl() {
12960
13068
  return config.baseUrl;
13069
+ },
13070
+ hasFrameworkCache() {
13071
+ return frameworkCache !== void 0;
12961
13072
  }
12962
13073
  };
12963
- frameworkCacheInstallers.set(client, (adapter) => {
12964
- if (framework.adapter) return;
12965
- framework.apiClient = createApiClient(adapter);
12966
- framework.adapter = adapter;
12967
- });
12968
- return client;
12969
13074
  }
12970
13075
  //#endregion
12971
- export { derivePublishedRuntimeCacheKey as a, isPublishedRuntimeCacheKeyEndpoint as c, parsePublishedRuntimeCacheKeyDetails as d, parsePublishedRuntimeCachePayloadSchemaVersion as f, createBearerAPIClient as g, sdkRequestOptions as h, classifyPublishedRuntimeCacheFreshness as i, normalizeRuntimePublicPath as l, buildEndpointURL as m, installFrameworkCache as n, resolveRuntimeCachePolicy as o, API_ENDPOINTS as p, CircuitOpenError as r, DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as s, createRiverbankClient as t, parsePublishedRuntimeCacheKey as u };
13076
+ export { DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, createBearerAPIClient as h, resolveRuntimeCachePolicy as i, parsePublishedRuntimeCacheKeyDetails as l, CircuitOpenError as m, classifyPublishedRuntimeCacheFreshness as n, isPublishedRuntimeCacheKeyEndpoint as o, sdkRequestOptions as p, derivePublishedRuntimeCacheKey as r, normalizeRuntimePublicPath as s, createRiverbankClient as t, parsePublishedRuntimeCachePayloadSchemaVersion as u };