@riverbankcms/sdk 0.178.0 → 0.179.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 (210) hide show
  1. package/README.md +15 -8
  2. package/dist/_dts/{BlocksIslandsHydrator-CrKsXtpD.d.ts → BlocksIslandsHydrator-DKwgs95u.d.ts} +1 -1
  3. package/dist/_dts/{Page-C9i27wZA.d.ts → Page-lWenra5i.d.ts} +7 -7
  4. package/dist/_dts/{SdkPreviewMode-DzGSR3jh.d.ts → SdkPreviewMode-BRxhRw4I.d.ts} +2 -2
  5. package/dist/_dts/{client-BnYN6XsH.d.ts → client-qWn7xAwJ.d.ts} +47 -17
  6. package/dist/_dts/{content-types-CXj6lp3d.d.ts → content-types-DL6GIvTm.d.ts} +2 -2
  7. package/dist/_dts/{contracts-BZLwkTwL.d.ts → contracts-CzWyAiJj.d.ts} +6 -116
  8. package/dist/_dts/{generatePageMetadata-ByEWwe9j.d.ts → generatePageMetadata-CBKd0cJ4.d.ts} +2 -2
  9. package/dist/_dts/{index-DCa-8TEY.d.ts → index-7CDBZGb-.d.ts} +1 -1
  10. package/dist/_dts/{index-CKDRr54L.d.ts → index-BU9uAkHB.d.ts} +4 -4
  11. package/dist/_dts/{index-D9-N1d9v.d.ts → index-BYnG_vF5.d.ts} +1 -1
  12. package/dist/_dts/{index-nnEdgc3Z.d.ts → index-CZgJrhzT.d.ts} +4 -2
  13. package/dist/_dts/{index-cTpvQg_Q.d.ts → index-CaCum9mM.d.ts} +2 -2
  14. package/dist/_dts/{index-0HFgCnGz.d.ts → index-DCiSHd-C.d.ts} +1 -1
  15. package/dist/_dts/{index-BE9dWIsr.d.ts → index-DVSipdrT.d.ts} +3 -3
  16. package/dist/_dts/{loadContent-DYkVV6w4.d.ts → loadContent-CPKbFQyq.d.ts} +15 -13
  17. package/dist/_dts/{request-B20VRWHH.d.ts → request-BjKBCS7t.d.ts} +1201 -335
  18. package/dist/_dts/{resolveBlockData-C_aK5GIS.d.ts → resolveBlockData-DupbMCup.d.ts} +8 -5
  19. package/dist/_dts/resolvePageContent-BqNyCHi8.d.ts +61 -0
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +3 -3
  22. package/dist/_dts/sdk/src/client.d.ts +7 -7
  23. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  24. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/types.d.ts +7 -2
  29. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
  30. package/dist/_dts/sdk/src/index.d.ts +8 -8
  31. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  33. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/next/index.d.ts +16 -8
  35. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  36. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  37. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  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 +7 -7
  47. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  48. package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
  49. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  50. package/dist/_dts/sdk/src/routing/index.d.ts +19 -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 +582 -0
  55. package/dist/_dts/{types-rm2M4LGx.d.ts → types-B7e6Lmo5.d.ts} +3 -3
  56. package/dist/_dts/{types-CYcd15BQ.d.ts → types-BOxSq-Bq.d.ts} +8 -7
  57. package/dist/_dts/{types-CMZ5mkpv.d.ts → types-CT-KOxl_.d.ts} +5 -39
  58. package/dist/_dts/{validation-BSxnRhyy.d.ts → validation-Dz6qccue.d.ts} +4 -4
  59. package/dist/client/{BlocksIslandsHydrator-D1n09bu-.mjs → BlocksIslandsHydrator-1XifJg6V.mjs} +17 -18
  60. package/dist/client/{BookingMailingListNote-DSD4gS96.mjs → BookingMailingListNote-BsbEgagJ.mjs} +7 -7
  61. package/dist/client/{BookingQuestionFields-B57oGPcj.mjs → BookingQuestionFields-C8IbeLHj.mjs} +4 -4
  62. package/dist/client/{CalendarNavigationChevron-qXvsFYOg.mjs → CalendarNavigationChevron-Bbqij1XQ.mjs} +42 -9
  63. package/dist/client/{CheckboxChoice-b-PJLEXe.mjs → CheckboxChoice-BZPLCgTU.mjs} +1 -1
  64. package/dist/client/{DemoBookingPortalAccess-Olvrwi3Z.mjs → DemoBookingPortalAccess-uA9H8LIL.mjs} +4 -4
  65. package/dist/client/{EventCalendar.client-DwFNFb-0.mjs → EventCalendar.client-yoSI77ov.mjs} +10 -10
  66. package/dist/client/{EventCombined.client-Ffu-aVOb.mjs → EventCombined.client-HeCNlliq.mjs} +10 -10
  67. package/dist/client/{EventEmbeddedCheckoutStep-B18VbNS_.mjs → EventEmbeddedCheckoutStep-BDnicDM6.mjs} +1 -1
  68. package/dist/client/{EventItem-b8tVkNHA.mjs → EventItem-Duhk1vnF.mjs} +247 -7
  69. package/dist/client/{EventListWeekNavigation-BxnJW_Gf.mjs → EventListWeekNavigation-BiutEqPK.mjs} +1 -1
  70. package/dist/client/{EventListing.client-ViCnrNg4.mjs → EventListing.client-B5ln77jG.mjs} +3 -3
  71. package/dist/client/{EventListing.view-CdjiepMf.mjs → EventListing.view-hUDhNtMv.mjs} +203 -9
  72. package/dist/client/{EventRegistrationPayment-BVd70XkH.mjs → EventRegistrationPayment-DqtX1vB2.mjs} +189 -111
  73. package/dist/client/{Page-DqETUt-U.mjs → Page-ChJ2TGVk.mjs} +24314 -20226
  74. package/dist/client/{ProtectedSubmitButton-C-ql101B.mjs → ProtectedSubmitButton-De6AzhE6.mjs} +1 -1
  75. package/dist/client/{SiteTermsAgreementField-DkFnbzf_.mjs → SiteTermsAgreementField-CDBU31xW.mjs} +3 -3
  76. package/dist/client/{StepIndicator-JO2PS03n.mjs → StepIndicator-2Dl9zon2.mjs} +6 -6
  77. package/dist/client/{BookingPanelArrangement--EkA1ZQd.mjs → StepIndicator-JQA-VuEH.mjs} +12 -12
  78. package/dist/client/{TabBarFragment-BqfRLojo.mjs → TabBarFragment-DlKQRhP4.mjs} +1 -1
  79. package/dist/client/{ThemedButton-DuaYtnvG.mjs → ThemedButton-CnSa7o-I.mjs} +66 -66
  80. package/dist/client/{accessibleSurfaces-DN8it_Cx.mjs → accessibleSurfaces-Wl8-_OVJ.mjs} +1 -1
  81. package/dist/client/{accordion-XgNxl0Wg.mjs → accordion-B6SqU49k.mjs} +1 -1
  82. package/dist/client/{booking-form.client-ljJoDwuI.mjs → booking-form.client-DrEOjQ3N.mjs} +15 -15
  83. package/dist/client/{bookingForm-DtEHwY4W.mjs → bookingForm-drZBwEZW.mjs} +4 -4
  84. package/dist/client/bookings.mjs +5 -5
  85. package/dist/client/{boxStyleClassNames-BHoMAcun.mjs → boxStyleClassNames-DEh45w16.mjs} +19 -19
  86. package/dist/client/{carousel-B3UhbFu7.mjs → carousel-C-YJliD-.mjs} +2 -2
  87. package/dist/client/{carousel.client-h65clfUO.mjs → carousel.client-DMtGYTTM.mjs} +1 -1
  88. package/dist/client/{cart-DzOJfYOR.mjs → cart-acGFWK9R.mjs} +3 -3
  89. package/dist/client/{cart.client-DBG77v-5.mjs → cart.client-BzlOGP2j.mjs} +1 -1
  90. package/dist/client/{checkout-LmePoEgM.mjs → checkout-SEontwhy.mjs} +3 -3
  91. package/dist/client/{checkout.client-DmgZuLBT.mjs → checkout.client-C0Qvh-d4.mjs} +1 -1
  92. package/dist/client/{checkoutUrls-CMZI8o_V.mjs → checkoutUrls-yUKeq1N9.mjs} +1 -1
  93. package/dist/client/client.mjs +414 -319
  94. package/dist/client/{context-CJIz4FdL.mjs → context-DTrwaQtg.mjs} +2 -1
  95. package/dist/client/{dateFormatting-UoXqBh10.mjs → dateFormatting-Cg8E1r9l.mjs} +1 -1
  96. package/dist/client/{demoPortalMagicLink-6CgFZNvu.mjs → demoPortalMagicLink-D0kOJYOX.mjs} +1 -1
  97. package/dist/client/{enhanceHeaderSection-DaMo6len.mjs → enhanceHeaderSection-DyrpZ7ks.mjs} +4 -4
  98. package/dist/client/{event-registration.client-b6APrFQe.mjs → event-registration.client-RLZQWi2V.mjs} +13 -13
  99. package/dist/client/{eventCalendar-DJYz7yZf.mjs → eventCalendar-CphYnImh.mjs} +4 -4
  100. package/dist/client/{eventCombined-j9VCVgMW.mjs → eventCombined-BvqjASB_.mjs} +4 -4
  101. package/dist/client/{eventListing-DWgpGuFM.mjs → eventListing-BaNAoC_M.mjs} +4 -4
  102. package/dist/client/{eventRegistration-DCinRot3.mjs → eventRegistration-COMHoRl6.mjs} +4 -4
  103. package/dist/client/events-9LPvwbWp.mjs +28 -0
  104. package/dist/client/{form-BBBtRwvy.mjs → form-DyH2juYT.mjs} +3 -3
  105. package/dist/client/{form.client-CZeRQLGF.mjs → form.client-DBwzkB0M.mjs} +5 -5
  106. package/dist/client/{form.parts-DhGGv4_L.mjs → form.parts-CY4kX3mh.mjs} +3 -3
  107. package/dist/client/{formatDate-DVFVDcDW.mjs → formatDate-CTEN7gxW.mjs} +1 -1
  108. package/dist/client/gifting/client.mjs +6 -6
  109. package/dist/client/{gifting-Di9-SpwW.mjs → gifting-CIx4V378.mjs} +4 -4
  110. package/dist/client/{gifting.client-CjT5PrAZ.mjs → gifting.client-BEVPpzJM.mjs} +5 -5
  111. package/dist/client/{gifting.parts-ffP6mjMd.mjs → gifting.parts-VnORjnZK.mjs} +2 -2
  112. package/dist/client/{headerSection-jjAvtSZk.mjs → headerSection-DGcJfRS8.mjs} +2 -2
  113. package/dist/client/{lookSurfaces-C2VzJfyG.mjs → lookSurfaces-IqT_SVnX.mjs} +167 -85
  114. package/dist/client/{newsletter-form.client-D45frHoa.mjs → newsletter-form.client-BvEDkjiD.mjs} +6 -6
  115. package/dist/client/{shop.interactive-D7wky1GL.mjs → newsletter-form.interactive-DCO1lErD.mjs} +3975 -3975
  116. package/dist/client/{newsletter-form.parts-CHdg82ct.mjs → newsletter-form.parts-BIy4IUT3.mjs} +2 -2
  117. package/dist/client/{newsletterForm-tS465_vl.mjs → newsletterForm-CoTXDNFS.mjs} +3 -3
  118. package/dist/client/portal/client.mjs +9 -9
  119. package/dist/client/{product-detail.client-DIWSeW7P.mjs → product-detail.client-YHQ2aKX1.mjs} +1 -1
  120. package/dist/client/{product-list.client-BRf14h_e.mjs → product-list.client-DxoZw1vF.mjs} +1 -1
  121. package/dist/client/{productDetail-gxF5whea.mjs → productDetail-DjuFvkey.mjs} +3 -3
  122. package/dist/client/{productList-B9t0XJrN.mjs → productList-DE9GEFoZ.mjs} +3 -3
  123. package/dist/client/{propsDecoder-Db8wAmgr.mjs → propsDecoder-Cyag_HOs.mjs} +2 -48
  124. package/dist/client/{registry.server-Bn0gE0uP.mjs → registry.server-BPwV-0Pp.mjs} +10420 -9108
  125. package/dist/client/rendering/client.mjs +41 -27
  126. package/dist/client/rendering/islands.mjs +1 -1
  127. package/dist/client/rendering.mjs +23 -2836
  128. package/dist/client/{richText-coerce-COnKrLO7.mjs → richText-coerce-NrRqDeOg.mjs} +1 -1
  129. package/dist/client/{routeIslandApiConfig-Bok1Oy50.mjs → routeIslandApiConfig-BWq5gKFK.mjs} +1 -1
  130. package/dist/client/runtimeResponse-D2j2-mOk.mjs +3 -0
  131. package/dist/client/{runtimeResponse-9v8q2NBc.mjs → runtimeResponse-DtWSfWSZ.mjs} +1 -1
  132. package/dist/client/{shop-D1oTPDxm.mjs → shop-C3wM0Hr4.mjs} +3 -3
  133. package/dist/client/{shop-commerce-DyMZLC0a.mjs → shop-commerce-34YvcpbX.mjs} +14 -14
  134. package/dist/client/{shop-commerce-store-FODNS63D.mjs → shop-commerce-store-B7xHksOs.mjs} +1 -1
  135. package/dist/client/{shop-discount-apply.state-C4xcmFzZ.mjs → shop-discount-apply.state-BiBnozfO.mjs} +2 -2
  136. package/dist/client/{shop.client-CRgRulfI.mjs → shop.client-C0v88nLd.mjs} +14 -14
  137. package/dist/client/{shopShared-Bd_hy9ZO.mjs → shopShared-Ct-BRNez.mjs} +2 -2
  138. package/dist/client/spam-protection.mjs +1 -1
  139. package/dist/client/{noop-D11X-B6n.mjs → src-CCtanNlD.mjs} +317 -342
  140. package/dist/client/{timetableModel-UlWfP1gh.mjs → timetableModel-lhE29TNT.mjs} +65 -11
  141. package/dist/client/{types-DjWUR_O6.mjs → types-BEaKfam_.mjs} +65 -65
  142. package/dist/client/{useAvailableSlots-D-qoooLy.mjs → useAvailableSlots-BelJviOT.mjs} +2 -2
  143. package/dist/client/useDiscountCodeUi-rQRE1-Ho.mjs +196 -0
  144. package/dist/client/{useEventPagination-CQH2e9sQ.mjs → useEventPagination-C4rS2Xxl.mjs} +8 -8
  145. package/dist/client/{view-bGU1ws-m.mjs → view-LJVHVqsy.mjs} +4 -4
  146. package/dist/client/{display-D1oVR5Eh.mjs → wizardSteps-CNDsxeJH.mjs} +8935 -8913
  147. package/dist/preview-next/before-render.mjs +4 -3
  148. package/dist/preview-next/client/{PageSectionToolbar-D-Le7O3o.mjs → PageSectionToolbar-C4TtBPN-.mjs} +3 -3
  149. package/dist/preview-next/client/{PreviewEditorSidebar-DNy5j_ce.mjs → PreviewEditorSidebar-D6fkE59-.mjs} +5 -5
  150. package/dist/preview-next/client/{PreviewEditorUI-CzJvgbqt.mjs → PreviewEditorUI-amcDlj0O.mjs} +4 -4
  151. package/dist/preview-next/client/{PreviewShell-xhJ6ca1i.mjs → PreviewShell-DeQjx4zk.mjs} +5 -5
  152. package/dist/preview-next/client/{SdkPreviewModeRuntime-BmYO1TdT.mjs → SdkPreviewModeRuntime-Cx0SXnoX.mjs} +5 -5
  153. package/dist/preview-next/client/{previewAssistantSlot-BN93X9o1.mjs → previewAssistantSlot-aqpU34WI.mjs} +627 -498
  154. package/dist/preview-next/client/{previewChromeRoot-C51RQseo.mjs → previewChromeRoot-D3Gy_Rs0.mjs} +1 -1
  155. package/dist/preview-next/client/runtime.mjs +3 -3
  156. package/dist/preview-next/client/{sdk-runtime-oeGquJM-.mjs → sdk-runtime-Dzx_RrN7.mjs} +2 -2
  157. package/dist/preview-next/client/{siteStyleAccess-BGTAcPud.mjs → siteStyleAccess-LHedw83e.mjs} +1 -1
  158. package/dist/preview-next/client/{useAutosaveStatus-BMGXjGZq.mjs → useAutosaveStatus-DpSd9aVk.mjs} +1 -1
  159. package/dist/preview-next/client/{useOpenBlockForSetup-CTDoR_gQ.mjs → useOpenBlockForSetup-BGZn5AT1.mjs} +1 -1
  160. package/dist/preview-next/keepAlive.mjs +1 -1
  161. package/dist/preview-next/middleware.mjs +1 -1
  162. package/dist/preview-next/{route-contract-BtdzkSUg.mjs → route-contract-DnL-FgSV.mjs} +28 -10
  163. package/dist/server/{Block.shared-Bp3OlOjj.mjs → Block.shared-BEbq6EwO.mjs} +4 -4
  164. package/dist/server/{bindings-DrbJuftt.mjs → bindings-Bly0dRs7.mjs} +36 -5
  165. package/dist/server/{client-Bf06n9oj.mjs → client-CGJ2ztYp.mjs} +1449 -1600
  166. package/dist/server/config-validation.mjs +1 -1
  167. package/dist/server/config.mjs +2 -2
  168. package/dist/server/contentTypeResolver-B9vy8BrF.mjs +19 -0
  169. package/dist/server/data/dataLoaderContext.mjs +1 -1
  170. package/dist/server/data/resolveBlockData.mjs +1 -1
  171. package/dist/server/{dataLoaderContext-B3fXA54R.mjs → dataLoaderContext-lMRTfG5Z.mjs} +1 -0
  172. package/dist/server/error-f4g44bKx.mjs +387 -0
  173. package/dist/server/index.mjs +3 -2
  174. package/dist/server/loadContent-BkK1w3QQ.mjs +692 -0
  175. package/dist/server/{loadPage-5iZefzDd.mjs → loadPage-DTLe0FEs.mjs} +22 -4
  176. package/dist/server/next.mjs +54 -94
  177. package/dist/server/{overrideResolution-CUHtm7tW.mjs → overrideResolution-Uy9Zp2Ks.mjs} +1 -1
  178. package/dist/server/page-converter.mjs +1 -1
  179. package/dist/server/{pageRenderPlan-GmPXForc.mjs → pageRenderPlan-JzxBnqfV.mjs} +7 -2
  180. package/dist/server/{pageRuntimeSupport-Dd8LFzfa.mjs → pageRuntimeSupport-DyNSd2Yj.mjs} +50 -2
  181. package/dist/server/{pageShared-tz-GVWft.mjs → pageShared-DU4ETFPS.mjs} +8 -50
  182. package/dist/server/{prebuild-JmsuYCIH.mjs → prebuild-8jNtDXmS.mjs} +5 -4
  183. package/dist/server/prebuild.mjs +1 -1
  184. package/dist/server/{prefetchBlockData-Ce9DDwON.mjs → prefetchBlockData-xeMG42aw.mjs} +3 -2
  185. package/dist/server/{registry-D12XF_h1.mjs → registry-DH1VrsCl.mjs} +122 -19
  186. package/dist/server/rendering/components/pageShared.mjs +1 -1
  187. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  188. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  189. package/dist/server/rendering/server.mjs +5 -4
  190. package/dist/server/rendering.mjs +9 -8
  191. package/dist/server/{resolveBlockData-D9yZIN3V.mjs → resolveBlockData-BN8tweTx.mjs} +24 -5
  192. package/dist/server/resolvePageContent-DnM16_f9.mjs +89 -0
  193. package/dist/server/routing.mjs +271 -57
  194. package/dist/server/server.mjs +3 -3
  195. package/dist/server/{loadContent-eaTY7RPg.mjs → servicePageContent-B-FezJmH.mjs} +709 -453
  196. package/dist/server/{validation-CLq5cw6M.mjs → validation-3jOzYdPL.mjs} +3 -3
  197. package/dist/server/{version-oPbhAx8E.mjs → version-8t0o6_jd.mjs} +1 -1
  198. package/package.json +1 -1
  199. package/dist/_dts/footerPageOutline-D_XbQW_o.d.ts +0 -256
  200. package/dist/_dts/resolvePageContent-YT6ndha1.d.ts +0 -162
  201. package/dist/client/LocationMapActions-CiMtl1Ha.mjs +0 -62
  202. package/dist/client/MapDrawingSvg-BCZa3dpf.mjs +0 -200
  203. package/dist/client/course-DBEU9IA9.mjs +0 -244
  204. package/dist/client/duration-Q6_QNgiv.mjs +0 -37
  205. package/dist/client/event-details.client-BwASwKIq.mjs +0 -53
  206. package/dist/client/eventDetails-BzGOVDI-.mjs +0 -13
  207. package/dist/client/runtimeResponse-CVkM0dHy.mjs +0 -3
  208. package/dist/client/useDiscountCodeUi-B9DODAkj.mjs +0 -237
  209. package/dist/client/view-DNX59QwM.mjs +0 -1372
  210. package/dist/server/resolvePageContent-CAELMBEJ.mjs +0 -438
@@ -1,7 +1,8 @@
1
1
  import { n as parseSurfaceTree } from "./accessibleSurfaces-CM3QANtw.mjs";
2
2
  import { o as isSupportedLoaderEndpoint, r as encodePublicProductCategorySelector, t as materializeEntriesMedia } from "./responseMedia-F-ElH2Rd.mjs";
3
3
  import { f as parseSiteId, t as publicMapLocationParamsSchema } from "./mapLocation-BM5WX7FY.mjs";
4
- import { t as SDK_VERSION } from "./version-oPbhAx8E.mjs";
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
6
  import { z } from "zod";
6
7
  /**
7
8
  * How long a rendered page may hold availability it read through the batch
@@ -43,7 +44,6 @@ const PUBLIC_READ_CACHE_POLICIES = {
43
44
  "public_memberships"
44
45
  ], "batch_only"),
45
46
  getPublicMapLocation: availability(["public_events", "public_event_filters"], "batch_only"),
46
- resolveEventSubroute: availability(["public_events", "public_event_filters"], "direct"),
47
47
  listPublicRouteCandidates: content(["published_content"], "batch_only"),
48
48
  listPublicTeamMembers: content(["public_team_members"]),
49
49
  listPublicProducts: availability(["public_products"], "direct"),
@@ -95,15 +95,6 @@ const BEFORE_BOOKING_QUESTIONS_ROUTE = {
95
95
  method: "POST"
96
96
  };
97
97
  //#endregion
98
- //#region ../api/src/defineEndpointDefinitions.ts
99
- /**
100
- * Validates extracted endpoint descriptors while preserving each literal path,
101
- * method, and parameter contract for the typed URL builders.
102
- */
103
- function defineEndpointDefinitions(definitions) {
104
- return definitions;
105
- }
106
- //#endregion
107
98
  //#region ../api/src/apiEndpointTypes.ts
108
99
  function allowedDemoMutationPolicy() {
109
100
  return {
@@ -682,6 +673,23 @@ function buildFetchPolicy(siteId, reads, freshnessSeconds) {
682
673
  function buildPublicReadBatchFetchPolicy(siteId, reads) {
683
674
  return buildFetchPolicy(siteId, reads, publicReadBatchFreshnessSeconds);
684
675
  }
676
+ /** A page may depend on admission even when an ordinary CMS page won precedence. */
677
+ function buildPageReadCachePolicy(siteId, dependencies) {
678
+ return dependencies === "availability" ? {
679
+ tags: normalizeRevalidateTags([
680
+ ...buildCacheReadTags([TAG_TEMPLATES.siteRoutableContent], { siteId }),
681
+ ...buildPublicReadFetchTags("listPublicEvents", { siteId }),
682
+ ...buildPublicReadFetchTags("getPublicBookingService", { siteId })
683
+ ]),
684
+ revalidate: 60
685
+ } : {
686
+ tags: buildCacheReadTags([TAG_TEMPLATES.siteRoutableContent], { siteId }),
687
+ revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS
688
+ };
689
+ }
690
+ function pageReadDependencies(payload) {
691
+ return typeof payload === "object" && payload !== null && "dependencies" in payload && payload.dependencies === "content" ? "content" : "availability";
692
+ }
685
693
  //#endregion
686
694
  //#region ../api/src/sdkEntryReadEndpoints.ts
687
695
  const SDK_ENTRY_READ_ENDPOINTS = {
@@ -2895,15 +2903,6 @@ const PUBLIC_EVENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
2895
2903
  "resource:conflict",
2896
2904
  "server:internal_error"
2897
2905
  ]
2898
- },
2899
- resolveEventSubroute: {
2900
- path: "/public/sites/{siteId}/events/subroutes/resolve",
2901
- method: "GET",
2902
- revalidate: publicReadFreshnessSeconds("resolveEventSubroute"),
2903
- tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
2904
- auth: "public",
2905
- responseKind: "json",
2906
- errors: []
2907
2906
  }
2908
2907
  });
2909
2908
  //#endregion
@@ -4357,52 +4356,6 @@ const BOOKING_PEOPLE_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
4357
4356
  ]
4358
4357
  }
4359
4358
  });
4360
- //#endregion
4361
- //#region ../api/src/clientErrorReporting.ts
4362
- const CLIENT_ERROR_REPORT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({ reportClientError: {
4363
- path: "/client/error-report",
4364
- method: "POST",
4365
- auth: "user",
4366
- errors: [],
4367
- responseKind: "json"
4368
- } });
4369
- const CLIENT_ERROR_REPORT_LIMITS = {
4370
- pathname: 1024,
4371
- name: 120,
4372
- message: 2e3,
4373
- stack: 8e3,
4374
- digest: 128,
4375
- componentStack: 8e3,
4376
- sourceLocation: 1024,
4377
- navigationAgeMs: 6e4
4378
- };
4379
- const clientErrorEventSchema = z.enum([
4380
- "dashboard:route-error",
4381
- "dashboard:app-error",
4382
- "client:error-boundary",
4383
- "client:window-error",
4384
- "client:unhandled-rejection"
4385
- ]);
4386
- z.object({
4387
- event: clientErrorEventSchema,
4388
- pathname: z.string().startsWith("/").max(CLIENT_ERROR_REPORT_LIMITS.pathname),
4389
- name: z.string().max(CLIENT_ERROR_REPORT_LIMITS.name),
4390
- message: z.string().max(CLIENT_ERROR_REPORT_LIMITS.message),
4391
- stack: z.string().max(CLIENT_ERROR_REPORT_LIMITS.stack).nullable(),
4392
- digest: z.string().max(CLIENT_ERROR_REPORT_LIMITS.digest).nullable(),
4393
- componentStack: z.string().max(CLIENT_ERROR_REPORT_LIMITS.componentStack).nullable(),
4394
- sourceLocation: z.string().max(CLIENT_ERROR_REPORT_LIMITS.sourceLocation).nullable(),
4395
- navigation: z.object({
4396
- fromPathname: z.string().regex(/^\/[^?#]*$/).max(CLIENT_ERROR_REPORT_LIMITS.pathname),
4397
- toPathname: z.string().regex(/^\/[^?#]*$/).max(CLIENT_ERROR_REPORT_LIMITS.pathname),
4398
- type: z.enum([
4399
- "push",
4400
- "replace",
4401
- "traverse"
4402
- ]),
4403
- ageMs: z.number().int().min(0).max(CLIENT_ERROR_REPORT_LIMITS.navigationAgeMs)
4404
- }).strict().nullable().optional()
4405
- }).strict();
4406
4359
  const API_ENDPOINTS$1 = {
4407
4360
  ...PAGE_SECTION_LOOK_ENDPOINT_DEFINITIONS,
4408
4361
  ...PAGE_JOURNAL_ENDPOINT_DEFINITIONS,
@@ -6109,6 +6062,14 @@ const API_ENDPOINTS$1 = {
6109
6062
  responseKind: "json",
6110
6063
  errors: []
6111
6064
  },
6065
+ adminDeleteSupportTicketScreenshot: {
6066
+ path: "/admin/support/tickets/screenshot/delete",
6067
+ method: "POST",
6068
+ tags: ["admin", "support"],
6069
+ auth: "admin",
6070
+ responseKind: "json",
6071
+ errors: []
6072
+ },
6112
6073
  mfaTotpEnroll: {
6113
6074
  path: "/auth/mfa/totp/enroll",
6114
6075
  method: "POST",
@@ -7110,6 +7071,7 @@ const API_ENDPOINTS$1 = {
7110
7071
  responseKind: "json"
7111
7072
  },
7112
7073
  resolveRouteOutcome: {
7074
+ revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
7113
7075
  path: "/sites/{siteId}/route-outcome",
7114
7076
  method: "GET",
7115
7077
  tags: [
@@ -8037,6 +7999,25 @@ const API_ENDPOINTS$1 = {
8037
7999
  "bookings"
8038
8000
  ]
8039
8001
  },
8002
+ listEventBookingTicketChoices: {
8003
+ errors: [],
8004
+ path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/ticket-choices",
8005
+ method: "GET",
8006
+ auth: "user",
8007
+ responseKind: "json"
8008
+ },
8009
+ changeEventBookingTickets: {
8010
+ errors: [],
8011
+ path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/change-tickets",
8012
+ method: "POST",
8013
+ auth: "user",
8014
+ responseKind: "json",
8015
+ tags: [
8016
+ "site-{siteId}",
8017
+ "event-attendee-{attendeeId}",
8018
+ "bookings"
8019
+ ]
8020
+ },
8040
8021
  restoreEventBooking: {
8041
8022
  errors: [],
8042
8023
  path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/restore",
@@ -10091,147 +10072,6 @@ const API_ENDPOINTS$1 = {
10091
10072
  }
10092
10073
  };
10093
10074
  //#endregion
10094
- //#region ../api/src/common/capacityOverride.ts
10095
- const capacityOverrideRefusalSchema = z.object({
10096
- booked: z.number().int().nonnegative(),
10097
- held: z.number().int().nonnegative(),
10098
- capacity: z.number().int().nonnegative(),
10099
- name: z.string(),
10100
- retryPersonId: z.string().optional()
10101
- });
10102
- function isCapacityOverrideRefusal(value) {
10103
- return capacityOverrideRefusalSchema.safeParse(value).success;
10104
- }
10105
- const API_ERROR_CODE_SET = /* @__PURE__ */ new Set([
10106
- "auth:unauthenticated",
10107
- "auth:token_expired",
10108
- "auth:token_invalid",
10109
- "auth:forbidden",
10110
- "auth:mfa_required",
10111
- "auth:mfa_setup_required",
10112
- "auth:sudo_required",
10113
- "auth:insufficient_permissions",
10114
- "auth:impersonation_restricted",
10115
- "auth:lease_required",
10116
- "auth:lease_lost",
10117
- "client:editing_held",
10118
- "site_terms_changed",
10119
- "site_terms_agreement_missing",
10120
- "validation:invalid_input",
10121
- "validation:missing_field",
10122
- "validation:invalid_format",
10123
- "validation:payload_too_large",
10124
- "resource:not_found",
10125
- "resource:already_exists",
10126
- "resource:conflict",
10127
- "resource:gone",
10128
- "rate_limit:exceeded",
10129
- "billing:payment_required",
10130
- "billing:plan_limit_exceeded",
10131
- "billing:pass_redemption_failed",
10132
- "server:internal_error",
10133
- "server:unavailable",
10134
- "external:service_error",
10135
- "external:registrar_orphaned_contact_profile",
10136
- "network:connection_error",
10137
- "network:timeout",
10138
- "network:dns_error"
10139
- ]);
10140
- function isApiErrorCode(value) {
10141
- return typeof value === "string" && API_ERROR_CODE_SET.has(value);
10142
- }
10143
- function isApiError(result) {
10144
- return result.success === false;
10145
- }
10146
- function isApiSuccess(result) {
10147
- return result.success === true;
10148
- }
10149
- function isRecord(value) {
10150
- return typeof value === "object" && value !== null && !Array.isArray(value);
10151
- }
10152
- function isFieldError(value) {
10153
- return isRecord(value) && typeof value.field === "string" && typeof value.code === "string" && typeof value.message === "string" && (value.capacityOverride === void 0 || isCapacityOverrideRefusal(value.capacityOverride));
10154
- }
10155
- function fieldErrorsFromUnknown(value) {
10156
- if (!Array.isArray(value)) return null;
10157
- return value.every(isFieldError) ? value : null;
10158
- }
10159
- function extractEnvelopeErrorObject(body) {
10160
- if (!isRecord(body)) return null;
10161
- const error = body.error;
10162
- if (!isRecord(error)) return null;
10163
- if ("success" in body && body.success !== false) return null;
10164
- return error;
10165
- }
10166
- function extractApiEnvelopeErrorDetails(body) {
10167
- const error = extractEnvelopeErrorObject(body);
10168
- if (!error) return {
10169
- rawCode: null,
10170
- code: null,
10171
- tag: null,
10172
- message: null,
10173
- status: null,
10174
- fieldErrors: null
10175
- };
10176
- const rawCode = typeof error.code === "string" ? error.code : null;
10177
- const message = typeof error.message === "string" && error.message.trim().length > 0 ? error.message : null;
10178
- return {
10179
- rawCode,
10180
- code: isApiErrorCode(rawCode) ? rawCode : null,
10181
- tag: typeof error.tag === "string" ? error.tag : null,
10182
- message,
10183
- status: typeof error.status === "number" && Number.isFinite(error.status) ? error.status : null,
10184
- fieldErrors: fieldErrorsFromUnknown(error.fieldErrors)
10185
- };
10186
- }
10187
- /**
10188
- * Error class for API failures that can be thrown from unwrapResponse.
10189
- * Preserves all error metadata from the envelope.
10190
- */
10191
- var ApiEnvelopeError = class extends Error {
10192
- constructor(error) {
10193
- super(error.message);
10194
- this.name = "ApiEnvelopeError";
10195
- this.code = error.code;
10196
- this.requestId = error.requestId;
10197
- this.timestamp = error.timestamp;
10198
- this.status = error.status;
10199
- this.tag = error.tag;
10200
- this.fieldErrors = error.fieldErrors;
10201
- }
10202
- };
10203
- /**
10204
- * Unwrap a successful API response or throw on error.
10205
- *
10206
- * @example
10207
- * ```typescript
10208
- * const response = await apiClient({ endpoint: 'getUser', params: { id } });
10209
- * const user = unwrapResponse(response); // Throws if not success
10210
- * ```
10211
- */
10212
- function unwrapResponse(result) {
10213
- if (isApiSuccess(result)) return result.data;
10214
- throw new ApiEnvelopeError(result.error);
10215
- }
10216
- //#endregion
10217
- //#region ../api/src/request-error.ts
10218
- var ApiRequestError = class extends Error {
10219
- constructor(message, options) {
10220
- super(message);
10221
- this.name = "ApiRequestError";
10222
- this.endpoint = options.endpoint;
10223
- this.status = options.status;
10224
- this.method = options.method;
10225
- this.auth = options.auth;
10226
- this.requestId = options.requestId;
10227
- this.body = options.body;
10228
- this.cause = options.cause;
10229
- this.errorCode = options.errorCode;
10230
- this.tag = options.tag;
10231
- this.retryAfterMs = options.retryAfterMs;
10232
- }
10233
- };
10234
- //#endregion
10235
10075
  //#region ../api/src/url.ts
10236
10076
  function looksLikeLocalAuthority(authority) {
10237
10077
  const normalized = authority.toLowerCase();
@@ -10283,6 +10123,163 @@ function resolveApiBaseUrl() {
10283
10123
  return getCmsApiUrl();
10284
10124
  }
10285
10125
  //#endregion
10126
+ //#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
+ function isRecord(value) {
10136
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10137
+ }
10138
+ function isResolvedPage(page) {
10139
+ return page?.kind === "resolved" && typeof page.requestedPath === "string" && (page.dependencies === "content" || page.dependencies === "availability") && isRecord(page.result) && [
10140
+ "cms",
10141
+ "system_event",
10142
+ "system_service"
10143
+ ].includes(String(page.result.kind));
10144
+ }
10145
+ function envelopePage(body) {
10146
+ const data = isRecord(body) && body.success === true && isRecord(body.data) ? body.data : null;
10147
+ return data?.type === "content" && isRecord(data.content) ? data.content : data;
10148
+ }
10149
+ function admit(snapshot) {
10150
+ try {
10151
+ const page = envelopePage(JSON.parse(snapshot.body));
10152
+ if (snapshot.status === 200 && isResolvedPage(page)) return {
10153
+ resolved: true,
10154
+ dependencies: page.dependencies
10155
+ };
10156
+ } catch {}
10157
+ return {
10158
+ resolved: false,
10159
+ dependencies: snapshot.status === 200 || snapshot.headers.some(([key, value]) => key === "x-riverbank-page-dependencies" && value === "availability") ? "availability" : "content"
10160
+ };
10161
+ }
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;
10176
+ };
10177
+ }
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);
10186
+ 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) {
10214
+ try {
10215
+ return await cache(async () => {
10216
+ throw new UncachedPageRead(await read());
10217
+ }, ["page-read-live-v2", key], {
10218
+ revalidate: false,
10219
+ tags: []
10220
+ })();
10221
+ } catch (error) {
10222
+ if (error instanceof UncachedPageRead) return error.snapshot;
10223
+ throw error;
10224
+ }
10225
+ }
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
10238
+ });
10239
+ if (checked) return checked;
10240
+ } catch (error) {
10241
+ if (error instanceof UncachedPageRead) return storeResponse(input, error.snapshot);
10242
+ throw error;
10243
+ }
10244
+ return storeResponse(input, await readInCacheScope(input.cache, input.key, input.read));
10245
+ }
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
+ }
10259
+ }
10260
+ async function cachePageReadResponse(input) {
10261
+ if (!input.cache) return input.read();
10262
+ const result = await selectResponse({
10263
+ ...input,
10264
+ cache: input.cache,
10265
+ read: liveResponse(input.read)
10266
+ });
10267
+ return new Response(result.body, {
10268
+ status: result.status,
10269
+ headers: result.headers
10270
+ });
10271
+ }
10272
+ /** Result adapters use this for cache fallbacks that did not return through the HTTP transport. */
10273
+ async function observePageReadPolicy(cache, siteId, payload) {
10274
+ if (!cache) return;
10275
+ const dependency = pageReadDependencies(payload);
10276
+ await cache(async () => true, [
10277
+ "page-read-policy-v2",
10278
+ siteId,
10279
+ dependency
10280
+ ], buildPageReadCachePolicy(siteId, dependency))();
10281
+ }
10282
+ //#endregion
10286
10283
  //#region ../api/src/common/operationId.ts
10287
10284
  const OPERATION_ID_HEADER = "X-Riverbank-Operation-Id";
10288
10285
  z.uuid();
@@ -10353,18 +10350,9 @@ z.enum([
10353
10350
  ]);
10354
10351
  //#endregion
10355
10352
  //#region ../api/src/request.ts
10356
- let revalidateTag = null;
10357
- let revalidateTagResolved = false;
10358
- function getRevalidateTag() {
10359
- if (revalidateTagResolved) return revalidateTag;
10360
- revalidateTagResolved = true;
10361
- if (typeof window !== "undefined") return null;
10362
- try {
10363
- revalidateTag = new Function("modulePath", "return require(modulePath)")("next/cache").revalidateTag ?? null;
10364
- } catch {
10365
- revalidateTag = null;
10366
- }
10367
- return revalidateTag;
10353
+ /** Preserve the returned dependency even when the SDK served a durable fallback. */
10354
+ function observePageReadResponse(adapter, siteId, payload) {
10355
+ return observePageReadPolicy(adapter?.cache ?? null, siteId, payload);
10368
10356
  }
10369
10357
  /**
10370
10358
  * Generate a UUID, with fallback for environments where crypto.randomUUID isn't available.
@@ -10454,8 +10442,8 @@ function serializePathParam(endpoint, key, value) {
10454
10442
  if (typeof value === "string") return value;
10455
10443
  throw new Error(`Invalid path param for endpoint ${String(endpoint)}: ${key} must be a string`);
10456
10444
  }
10457
- function invalidateCacheTags(tags, params) {
10458
- const resolved = getRevalidateTag();
10445
+ function invalidateCacheTags(adapter, tags, params) {
10446
+ const resolved = adapter?.invalidateTag;
10459
10447
  if (typeof window !== "undefined" || !resolved || !tags) return;
10460
10448
  tags.forEach((tag) => {
10461
10449
  let processedTag = tag;
@@ -10463,7 +10451,7 @@ function invalidateCacheTags(tags, params) {
10463
10451
  processedTag = processedTag.replace(`{${key}}`, String(value));
10464
10452
  });
10465
10453
  try {
10466
- resolved(processedTag, "max");
10454
+ resolved(processedTag);
10467
10455
  } catch {}
10468
10456
  });
10469
10457
  }
@@ -10556,7 +10544,7 @@ function successJsonEnvelope(parsed, requestId) {
10556
10544
  if (parsed && typeof parsed === "object" && "success" in parsed && typeof parsed.success === "boolean") return parsed;
10557
10545
  return buildSuccessEnvelope(coerceResponse(parsed), requestId);
10558
10546
  }
10559
- function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersion } = {}) {
10547
+ function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersion, frameworkCache } = {}) {
10560
10548
  return ({ endpoint, body, params, options = {} }) => {
10561
10549
  const plan = buildApiRequestPlan({
10562
10550
  endpoint,
@@ -10570,14 +10558,31 @@ function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersi
10570
10558
  baseUrl: normalizeCmsApiBaseUrl(baseUrl ?? resolveApiBaseUrl()),
10571
10559
  sdkVersion
10572
10560
  });
10573
- const fetchPromise = fetch(plan.url, plan.init);
10561
+ const fetchPromise = executeApiRequest(plan, endpoint, params, options, frameworkCache);
10574
10562
  if (plan.cacheInvalidationTags) return fetchPromise.then((response) => {
10575
- if (response.ok) invalidateCacheTags(plan.cacheInvalidationTags, params);
10563
+ if (response.ok) invalidateCacheTags(frameworkCache, plan.cacheInvalidationTags, params);
10576
10564
  return response;
10577
10565
  });
10578
10566
  return fetchPromise;
10579
10567
  };
10580
10568
  }
10569
+ function isPublishedPageRead(endpoint, params, options) {
10570
+ return (endpoint === "getContentByPath" || endpoint === "resolveRouteOutcome") && params?.preview !== true && params?.preview !== "true" && options.cache !== "no-store";
10571
+ }
10572
+ function executeApiRequest(plan, endpoint, params, options, frameworkCache) {
10573
+ const inputParams = params;
10574
+ const { next: fetchPolicy, ...uncachedInit } = plan.init;
10575
+ return isPublishedPageRead(endpoint, inputParams, options) ? cachePageReadResponse({
10576
+ cache: frameworkCache?.cache ?? null,
10577
+ key: JSON.stringify([plan.url, [...new Headers(plan.init.headers).entries()]]),
10578
+ siteId: typeof inputParams?.siteId === "string" ? inputParams.siteId : "",
10579
+ maxAge: typeof fetchPolicy?.revalidate === "number" ? fetchPolicy.revalidate : void 0,
10580
+ read: () => fetch(plan.url, {
10581
+ ...uncachedInit,
10582
+ cache: "no-store"
10583
+ })
10584
+ }) : fetch(plan.url, plan.init);
10585
+ }
10581
10586
  const batchReadPolicyBodySchema = z.object({ requests: z.array(z.object({
10582
10587
  endpoint: z.string(),
10583
10588
  params: z.record(z.string(), z.unknown()).optional()
@@ -10611,10 +10616,12 @@ function batchReadRequestOptions(params, body, options) {
10611
10616
  function publicReadRequestOptions(endpoint, params, body, options) {
10612
10617
  if (endpoint === "batchBlockLoaders") return batchReadRequestOptions(params, body, options);
10613
10618
  const preview = params?.preview === true || params?.preview === "true";
10614
- return endpoint === "getContentByPath" && preview ? {
10619
+ if (endpoint !== "getContentByPath" && endpoint !== "resolveRouteOutcome") return options;
10620
+ if (preview) return {
10615
10621
  ...options,
10616
10622
  cache: "no-store"
10617
- } : options;
10623
+ };
10624
+ return options;
10618
10625
  }
10619
10626
  function assertResolvedEndpointPath(endpoint, url) {
10620
10627
  const tokens = [...url.match(/\{[^}]+\}/g) ?? [], ...url.match(/(^|\/):([A-Za-z][A-Za-z0-9_]*)\b/g) ?? []];
@@ -10717,1472 +10724,1245 @@ function requireUsableCommitProjection(response, parsed) {
10717
10724
  throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
10718
10725
  }
10719
10726
  //#endregion
10720
- //#region src/client/error.ts
10721
- let _Symbol$for;
10722
- _Symbol$for = Symbol.for("nodejs.util.inspect.custom");
10723
- /**
10724
- * Error thrown by SDK when API returns an error response
10725
- *
10726
- * @example
10727
- * ```ts
10728
- * try {
10729
- * await client.getSite({ slug: 'my-site' });
10730
- * } catch (error) {
10731
- * if (error instanceof RiverbankApiError) {
10732
- * console.log('Error code:', error.code);
10733
- * console.log('Request ID:', error.requestId);
10734
- *
10735
- * if (error.isAuthError()) {
10736
- * // Handle authentication error
10737
- * }
10738
- *
10739
- * if (error.isValidationError() && error.fieldErrors) {
10740
- * // Handle field-level validation errors
10741
- * error.fieldErrors.forEach(fe => {
10742
- * console.log(`${fe.field}: ${fe.message}`);
10743
- * });
10744
- * }
10745
- *
10746
- * // Check if error can be retried
10747
- * if (error.isRetryable) {
10748
- * const delay = error.retryAfterMs ?? 1000;
10749
- * console.log(`Retrying after ${delay}ms...`);
10750
- * }
10751
- * }
10752
- * }
10753
- * ```
10754
- */
10755
- var RiverbankApiError = class RiverbankApiError extends Error {
10756
- constructor(apiError) {
10757
- super(apiError.message);
10758
- this.name = "RiverbankApiError";
10759
- if ("cause" in apiError && apiError.cause) this.cause = apiError.cause;
10760
- this.code = apiError.code;
10761
- this.requestId = apiError.requestId;
10762
- this.status = apiError.status;
10763
- this.fieldErrors = apiError.fieldErrors;
10764
- this.timestamp = apiError.timestamp;
10765
- this.retryAfterMs = "retryAfterMs" in apiError ? apiError.retryAfterMs : void 0;
10766
- this.isRetryable = this.computeRetryable();
10767
- Object.setPrototypeOf(this, RiverbankApiError.prototype);
10768
- }
10769
- /**
10770
- * Compute whether this error is retryable based on HTTP status code.
10771
- * - 0 (network errors - no HTTP response): retryable
10772
- * - 429 (rate limit): retryable
10773
- * - 5xx (server errors): retryable
10774
- * - 4xx (client errors, except 429): NOT retryable
10775
- */
10776
- computeRetryable() {
10777
- if (this.status === 0) return true;
10778
- if (this.status === 429) return true;
10779
- if (this.status >= 500) return true;
10780
- return false;
10781
- }
10782
- /**
10783
- * Check if this is a network error (no HTTP response received)
10784
- *
10785
- * Matches: network:connection_error, network:timeout, network:dns_error
10786
- */
10787
- isNetworkError() {
10788
- return this.code.startsWith("network:");
10789
- }
10790
- /**
10791
- * Check if this error matches a specific error code
10792
- *
10793
- * @example
10794
- * ```ts
10795
- * if (error.is('auth:unauthenticated')) {
10796
- * // Redirect to login
10797
- * }
10798
- * ```
10799
- */
10800
- is(code) {
10801
- return this.code === code;
10802
- }
10803
- /**
10804
- * Check if this is an authentication or authorization error
10805
- *
10806
- * Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
10807
- * auth:forbidden, auth:mfa_required, auth:insufficient_permissions
10808
- */
10809
- isAuthError() {
10810
- return this.code.startsWith("auth:");
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"
10761
+ };
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 ?? ""}`;
10777
+ }
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
10794
+ }
10795
+ };
10796
+ }
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;
10811
10805
  }
10812
10806
  /**
10813
- * Check if this is a validation error
10814
- *
10815
- * Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
10807
+ * Get a fresh value (within TTL)
10808
+ * @returns The value if fresh, null otherwise
10816
10809
  */
10817
- isValidationError() {
10818
- return this.code.startsWith("validation:");
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;
10819
10815
  }
10820
10816
  /**
10821
- * Check if this is a resource error (not found, conflict, etc.)
10822
- *
10823
- * Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
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
10824
10819
  */
10825
- isResourceError() {
10826
- return this.code.startsWith("resource:");
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
+ };
10827
10833
  }
10828
10834
  /**
10829
- * Check if this is a rate limiting error
10835
+ * Store a value with TTL and stale window
10830
10836
  */
10831
- isRateLimitError() {
10832
- return this.code.startsWith("rate_limit:");
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
+ });
10833
10849
  }
10834
10850
  /**
10835
- * Check if this is a billing/payment error
10851
+ * Evict one entry to make room for a new one
10852
+ * Priority: oldest stale entry, then oldest fresh entry
10836
10853
  */
10837
- isBillingError() {
10838
- return this.code.startsWith("billing:");
10839
- }
10840
- /**
10841
- * Check if this is a server error
10842
- */
10843
- isServerError() {
10844
- return this.code.startsWith("server:");
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);
10845
10870
  }
10846
10871
  /**
10847
- * Returns a human-readable string representation of the error.
10848
- * Includes all key details for debugging.
10849
- *
10850
- * @example
10851
- * "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
10872
+ * Remove all fully expired entries (past staleUntil)
10852
10873
  */
10853
- toString() {
10854
- const parts = [`RiverbankApiError: ${this.message}`];
10855
- if (this.code) parts.push(`Code: ${this.code}`);
10856
- if (this.status) parts.push(`Status: ${this.status}`);
10857
- if (this.requestId) parts.push(`RequestId: ${this.requestId}`);
10858
- return parts.join(" | ");
10874
+ prune() {
10875
+ const now = Date.now();
10876
+ for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
10859
10877
  }
10860
10878
  /**
10861
- * Custom Node.js inspect output for better console.log display.
10862
- * This ensures that console.log(error) shows all relevant details
10863
- * instead of just "[Object]" for nested properties.
10879
+ * Clear all entries
10864
10880
  */
10865
- [_Symbol$for]() {
10866
- return this.toDetailedString();
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();
10867
10891
  }
10868
10892
  /**
10869
- * Returns a detailed multi-line string for debugging.
10870
- * Used by the Node.js inspect symbol for console output.
10893
+ * Check if a key exists and is not fully expired
10871
10894
  */
10872
- toDetailedString() {
10873
- const lines = [
10874
- `RiverbankApiError: ${this.message}`,
10875
- ` Code: ${this.code}`,
10876
- ` Status: ${this.status}`,
10877
- ` RequestId: ${this.requestId}`,
10878
- ` Timestamp: ${this.timestamp}`
10879
- ];
10880
- if (this.isRetryable) {
10881
- lines.push(` Retryable: true`);
10882
- if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
10883
- }
10884
- if (this.fieldErrors && this.fieldErrors.length > 0) {
10885
- lines.push(" FieldErrors:");
10886
- this.fieldErrors.forEach((fe) => {
10887
- lines.push(` - ${fe.field}: ${fe.message}`);
10888
- });
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;
10889
10902
  }
10890
- return lines.join("\n");
10903
+ return now <= entry.freshUntil;
10891
10904
  }
10892
10905
  };
10893
- const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
10894
- function attachResilienceStatusToError(error, resilienceStatus) {
10895
- const target = error !== null && (typeof error === "object" || typeof error === "function") ? error : new Error(typeof error === "string" || typeof error === "number" || typeof error === "boolean" || typeof error === "bigint" ? String(error) : "Unknown error");
10896
- Object.defineProperty(target, resilienceStatusSymbol, {
10897
- configurable: true,
10898
- enumerable: false,
10899
- value: resilienceStatus
10900
- });
10901
- return target;
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;
10902
11075
  }
10903
- function getResilienceStatusFromError(error) {
10904
- if (error === null || typeof error !== "object" && typeof error !== "function") return;
10905
- return error[resilienceStatusSymbol];
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
+ };
10906
11085
  }
10907
11086
  //#endregion
10908
- //#region src/client/resilience.ts
10909
- const DEFAULT_RETRY_CONFIG = {
10910
- maxAttempts: 3,
10911
- baseDelayMs: 200,
10912
- maxDelayMs: 2e3,
10913
- jitter: "full"
10914
- };
10915
- const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
10916
- failureThreshold: 5,
10917
- resetTimeoutMs: 3e4,
10918
- halfOpenMaxRequests: 2
10919
- };
10920
- /**
10921
- * Error codes that indicate permanent infrastructure failures.
10922
- * These should NOT be retried as the server is definitively unreachable.
10923
- */
10924
- const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10925
- "ECONNREFUSED",
10926
- "ENOTFOUND",
10927
- "EAI_AGAIN"
10928
- ]);
11087
+ //#region src/client/runtimeCacheKeys.ts
10929
11088
  /**
10930
- * Error codes that indicate transient network issues.
10931
- * These MAY succeed on retry as the server was reachable but had a hiccup.
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.
11092
+ *
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).
10932
11098
  */
10933
- const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10934
- "ECONNRESET",
10935
- "EPIPE",
10936
- "ETIMEDOUT",
10937
- "ESOCKETTIMEDOUT"
10938
- ]);
10939
- /**
10940
- * Node.js network error codes (POSIX style).
10941
- * These are the codes we're looking for in the cause chain.
10942
- */
10943
- const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
10944
- "ECONNREFUSED",
10945
- "ENOTFOUND",
10946
- "EAI_AGAIN",
10947
- "ECONNRESET",
10948
- "EPIPE",
10949
- "ETIMEDOUT",
10950
- "ESOCKETTIMEDOUT"
10951
- ]);
10952
- /**
10953
- * Check if a string is a Node.js network error code (not an API error code).
10954
- * API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
10955
- */
10956
- function isNodeNetworkErrorCode(code) {
10957
- return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
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;
10958
11105
  }
10959
- /**
10960
- * Extract the Node.js error code from an error's cause chain.
10961
- * Handles nested cause chains like:
10962
- * RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
10963
- *
10964
- * Skips API error codes (like 'network:connection_error') and only returns
10965
- * actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
10966
- *
10967
- * @example
10968
- * RiverbankApiError: Network request failed
10969
- * [cause]: TypeError: fetch failed
10970
- * [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
10971
- * code: 'ECONNREFUSED'
10972
- */
10973
- function getErrorCodeFromCause(error) {
10974
- let current = error;
10975
- while (current) {
10976
- const nodeError = current;
10977
- if (nodeError.code && typeof nodeError.code === "string") {
10978
- if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
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) || "/";
11110
+ }
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(/\.$/, "");
11114
+ }
11115
+ function normalizeScalar(value) {
11116
+ return value.trim().toLowerCase();
11117
+ }
11118
+ function unsafeAsPublishedRuntimeCacheKey(value) {
11119
+ return value;
11120
+ }
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(":")}`);
11123
+ }
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;
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
+ ]
10979
11144
  }
10980
- current = current.cause;
10981
- }
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
+ };
10982
11156
  }
10983
- /**
10984
- * Determine if an error is transient and should trigger circuit breaker / retry
10985
- *
10986
- * Transient (opens circuit, triggers retry):
10987
- * - Network errors (status 0) that are NOT permanent infrastructure failures
10988
- * - 5xx server errors
10989
- * - 429 rate limit
10990
- * - Connection reset, broken pipe, timeout
10991
- *
10992
- * Permanent (does NOT open circuit, no retry):
10993
- * - 4xx client errors (400, 401, 403, 404)
10994
- * - Validation errors
10995
- * - ECONNREFUSED (server not running)
10996
- * - ENOTFOUND (DNS failure)
10997
- */
10998
- function isTransientError(error) {
10999
- if (error instanceof RiverbankApiError) {
11000
- const errorCode = getErrorCodeFromCause(error);
11001
- if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
11002
- if (error.status === 0) return true;
11003
- if (error.status === 429) return true;
11004
- if (error.status >= 500) return true;
11005
- return false;
11006
- }
11007
- if (error instanceof TypeError) {
11008
- const errorCode = getErrorCodeFromCause(error);
11009
- if (errorCode) {
11010
- if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
11011
- if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
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"
11012
11165
  }
11013
- return true;
11166
+ };
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);
11014
11183
  }
11015
- return true;
11016
11184
  }
11017
- /**
11018
- * Calculate backoff delay for retry attempt
11019
- *
11020
- * Uses exponential backoff with optional full jitter.
11021
- * Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
11022
- */
11023
- function calculateBackoff(attempt, config) {
11024
- const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
11025
- const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
11026
- const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
11027
- const exponential = baseDelayMs * Math.pow(2, attempt - 1);
11028
- const capped = Math.min(exponential, maxDelayMs);
11029
- if (jitter === "full") return Math.random() * capped;
11030
- return capped;
11185
+ function isPublishedRuntimeCacheKeyEndpoint(value) {
11186
+ return value === "getSite" || value === "getContentByPath";
11031
11187
  }
11032
- /**
11033
- * Circuit breaker for fail-fast behavior
11034
- *
11035
- * States:
11036
- * - closed: Normal operation, requests allowed
11037
- * - open: Too many failures, requests blocked
11038
- * - half-open: Testing if service recovered, limited requests allowed
11039
- */
11040
- var CircuitBreaker = class {
11041
- constructor(config) {
11042
- this.state = "closed";
11043
- this.failureCount = 0;
11044
- this.successCount = 0;
11045
- this.openUntil = 0;
11046
- this.halfOpenRequests = 0;
11047
- this.config = {
11048
- failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
11049
- resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
11050
- halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
11188
+ function parsePublishedRuntimeCacheKey(value) {
11189
+ const details = parsePublishedRuntimeCacheKeyDetails(value);
11190
+ if (!details.ok) return details;
11191
+ return {
11192
+ ok: true,
11193
+ key: details.key,
11194
+ endpoint: details.endpoint
11195
+ };
11196
+ }
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"
11051
11218
  };
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
+ };
11227
+ }
11052
11228
  }
11053
- /**
11054
- * Check if circuit is open (requests should be blocked)
11055
- * Also handles automatic transition from open to half-open after timeout
11056
- */
11057
- isOpen() {
11058
- if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
11059
- return this.state === "open";
11060
- }
11061
- /**
11062
- * Check if a request can be attempted
11063
- * - closed: always yes
11064
- * - open: always no
11065
- * - half-open: limited number of probes
11066
- */
11067
- canAttempt() {
11068
- if (this.state === "closed") return true;
11069
- if (this.state === "open") return false;
11070
- return this.halfOpenRequests < this.config.halfOpenMaxRequests;
11071
- }
11072
- /**
11073
- * Increment half-open request counter (call before making request in half-open)
11074
- */
11075
- incrementHalfOpenRequests() {
11076
- if (this.state === "half-open") this.halfOpenRequests++;
11077
- }
11078
- /**
11079
- * Record a successful request
11080
- */
11081
- recordSuccess() {
11082
- if (this.state === "half-open") {
11083
- this.successCount++;
11084
- if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
11085
- } else this.failureCount = 0;
11086
- }
11087
- /**
11088
- * Record a failed request
11089
- * Only counts transient failures toward circuit breaker threshold
11090
- */
11091
- recordFailure(error) {
11092
- if (!isTransientError(error)) return;
11093
- this.failureCount++;
11094
- if (this.state === "half-open") this.transitionTo("open");
11095
- else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
11096
- }
11097
- /**
11098
- * Get current circuit state
11099
- */
11100
- getState() {
11101
- return {
11102
- state: this.state,
11103
- failureCount: this.failureCount,
11104
- openUntil: this.state === "open" ? this.openUntil : void 0
11105
- };
11106
- }
11107
- /**
11108
- * Transition to a new state
11109
- */
11110
- transitionTo(newState) {
11111
- this.state = newState;
11112
- if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
11113
- else if (newState === "half-open") {
11114
- this.halfOpenRequests = 0;
11115
- this.successCount = 0;
11116
- } else if (newState === "closed") {
11117
- this.failureCount = 0;
11118
- this.successCount = 0;
11119
- this.halfOpenRequests = 0;
11120
- }
11121
- }
11122
- };
11123
- /**
11124
- * Fetch with timeout and retry logic
11125
- *
11126
- * @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
11127
- * @param config - Retry configuration
11128
- * @returns Result from successful fetch
11129
- * @throws Last error after all retries exhausted
11130
- */
11131
- async function fetchWithTimeoutAndRetry(fetcher, config) {
11132
- const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
11133
- const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
11134
- let lastError;
11135
- for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
11136
- const controller = new AbortController();
11137
- const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
11138
- try {
11139
- return await fetcher(controller.signal);
11140
- } finally {
11141
- clearTimeout(timeoutId);
11142
- }
11143
- } catch (error) {
11144
- lastError = error;
11145
- if (!shouldRetryError(error, config.retryOn)) throw error;
11146
- if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
11147
- }
11148
- throw lastError;
11149
- }
11150
- /**
11151
- * Check if an error is an AbortError (from AbortController.abort() or timeout)
11152
- */
11153
- function isAbortError$1(error) {
11154
- if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
11155
- if (error instanceof Error && error.name === "AbortError") return true;
11156
- return false;
11157
- }
11158
- /**
11159
- * Check if an error should be retried
11160
- */
11161
- function shouldRetryError(error, customRetryOn) {
11162
- if (isAbortError$1(error)) return false;
11163
- if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
11164
- return isTransientError(error);
11165
- }
11166
- /**
11167
- * Get delay before retrying, respecting Retry-After if present
11168
- */
11169
- function getRetryDelay(error, attempt, config) {
11170
- if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
11171
- return calculateBackoff(attempt, config);
11172
- }
11173
- /**
11174
- * Sleep for specified milliseconds
11175
- */
11176
- function sleep(ms) {
11177
- return new Promise((resolve) => setTimeout(resolve, ms));
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
+ };
11178
11239
  }
11179
- /**
11180
- * Error thrown when circuit breaker is open
11181
- */
11182
- var CircuitOpenError = class extends Error {
11183
- constructor(state) {
11184
- super("Circuit breaker is open");
11185
- this.name = "CircuitOpenError";
11186
- this.circuitState = state;
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));
11187
11258
  }
11188
- };
11189
- //#endregion
11190
- //#region ../site-renderer/src/runtimeResponse.ts
11191
- /** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
11192
- function restoreRuntimeResponse(serialized) {
11193
- return parseSurfaceTree(serialized);
11194
- }
11195
- //#endregion
11196
- //#region ../site-renderer/src/runtimeClient.ts
11197
- /** Only a client that reconstructs surfaces advertises revision transport. */
11198
- function createRuntimeApiClient(transport) {
11199
- const revisionTransport = (request) => transport({
11200
- ...request,
11201
- ...request.endpoint === "getContentByPath" ? { params: {
11202
- ...request.params,
11203
- surfaceTransport: "revision-v1"
11204
- } } : {}
11205
- });
11206
- return createParsedApiClient(revisionTransport, {
11207
- representation: "restored",
11208
- decode: restoreRuntimeResponse
11209
- });
11210
- }
11211
- function createRuntimeInternalAPIClient(baseUrl, options) {
11212
- return createRuntimeApiClient(createApiResponseTransport(() => ({}), baseUrl, options));
11213
11259
  }
11214
- function createRuntimeBearerAPIClient(token, baseUrl, options) {
11215
- return createRuntimeApiClient(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
11216
- }
11217
- //#endregion
11218
- //#region src/client/entryListReadRequest.ts
11219
- const entryOrder = {
11220
- newest: "published_at.desc",
11221
- oldest: "published_at.asc",
11222
- title: "title.asc",
11223
- manual: "manual.asc"
11224
- };
11225
- function entrySelection(input) {
11226
- return input.mode === "manual" && input.entryIds?.length ? {
11227
- keyPart: input.entryIds.join(","),
11228
- params: {
11229
- mode: "manual",
11230
- entryIds: JSON.stringify(input.entryIds)
11231
- }
11232
- } : {
11233
- keyPart: "",
11234
- params: {}
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"
11235
11272
  };
11236
- }
11237
- function entryListMemoryKey(input, selection) {
11238
- const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
11239
- return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
11240
- }
11241
- /** One interpretation of pagination, selection and preview for the transport and memory key. */
11242
- function buildEntryListReadRequest(input) {
11243
- const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
11244
- const selection = entrySelection(input);
11245
- const orderParam = order ? entryOrder[order] : void 0;
11246
11273
  return {
11247
- cacheKey: entryListMemoryKey(input, selection),
11248
- params: {
11249
- siteId,
11250
- type: contentType,
11251
- ...typeof limit === "number" && { limit: String(limit) },
11252
- ...typeof offset === "number" && { offset: String(offset) },
11253
- ...includeMeta && { meta: "true" },
11254
- ...orderParam && { order: orderParam },
11255
- ...preview && { stage: "preview" },
11256
- ...selection.params
11257
- }
11274
+ ok: true,
11275
+ value
11258
11276
  };
11259
11277
  }
11260
11278
  //#endregion
11261
- //#region src/client/cache.ts
11262
- var SimpleCache = class {
11263
- constructor(options = {}) {
11264
- this.cache = /* @__PURE__ */ new Map();
11265
- this.maxSize = options.maxSize ?? 100;
11266
- this.ttl = options.ttl ?? 3e5;
11267
- this.staleTtl = options.staleTtl ?? 3e5;
11268
- }
11269
- /**
11270
- * Get a fresh value (within TTL)
11271
- * @returns The value if fresh, null otherwise
11272
- */
11273
- getFresh(key) {
11274
- const entry = this.cache.get(key);
11275
- if (!entry) return null;
11276
- if (Date.now() <= entry.freshUntil) return entry.value;
11277
- return null;
11278
- }
11279
- /**
11280
- * Get a value that may be stale (past TTL but within staleTtl)
11281
- * @returns Object with value and stale age, or null if expired
11282
- */
11283
- getStale(key) {
11284
- const entry = this.cache.get(key);
11285
- if (!entry) return null;
11286
- const now = Date.now();
11287
- if (now > entry.staleUntil) {
11288
- this.cache.delete(key);
11289
- return null;
11290
- }
11291
- const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
11292
- return {
11293
- value: entry.value,
11294
- staleAgeSec
11295
- };
11296
- }
11297
- /**
11298
- * Store a value with TTL and stale window
11299
- */
11300
- set(key, value, options) {
11301
- const ttl = options?.ttl ?? this.ttl;
11302
- const staleTtl = options?.staleTtl ?? this.staleTtl;
11303
- const now = Date.now();
11304
- while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
11305
- this.cache.set(key, {
11306
- value,
11307
- tags: options?.tags ?? [],
11308
- createdAt: now,
11309
- freshUntil: now + ttl,
11310
- staleUntil: now + ttl + staleTtl
11311
- });
11312
- }
11313
- /**
11314
- * Evict one entry to make room for a new one
11315
- * Priority: oldest stale entry, then oldest fresh entry
11316
- */
11317
- evictOne(now) {
11318
- let oldestStaleKey = null;
11319
- let oldestStaleTime = Infinity;
11320
- let oldestFreshKey = null;
11321
- let oldestFreshTime = Infinity;
11322
- for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
11323
- if (entry.createdAt < oldestStaleTime) {
11324
- oldestStaleTime = entry.createdAt;
11325
- oldestStaleKey = key;
11326
- }
11327
- } else if (entry.createdAt < oldestFreshTime) {
11328
- oldestFreshTime = entry.createdAt;
11329
- oldestFreshKey = key;
11330
- }
11331
- const keyToEvict = oldestStaleKey ?? oldestFreshKey;
11332
- if (keyToEvict) this.cache.delete(keyToEvict);
11333
- }
11334
- /**
11335
- * Remove all fully expired entries (past staleUntil)
11336
- */
11337
- prune() {
11338
- const now = Date.now();
11339
- for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
11340
- }
11341
- /**
11342
- * Clear all entries
11343
- */
11344
- clearForTags(tags) {
11345
- if (tags.includes("riverbank")) {
11346
- this.clear();
11347
- return;
11348
- }
11349
- const selected = new Set(tags);
11350
- [...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
11351
- }
11352
- clear() {
11353
- this.cache.clear();
11354
- }
11355
- /**
11356
- * Check if a key exists and is not fully expired
11357
- */
11358
- has(key) {
11359
- const entry = this.cache.get(key);
11360
- if (!entry) return false;
11361
- const now = Date.now();
11362
- if (now > entry.staleUntil) {
11363
- this.cache.delete(key);
11364
- return false;
11365
- }
11366
- return now <= entry.freshUntil;
11367
- }
11368
- };
11369
- //#endregion
11370
- //#region src/request-options.ts
11371
- /** Every API client the SDK creates sends its version as `x-sdk-version`. */
11372
- const sdkRequestOptions = { sdkVersion: SDK_VERSION };
11373
- //#endregion
11374
- //#region src/public-api/runtime.ts
11375
- const PUBLIC_ENDPOINT_NAMES = [
11376
- "getSite",
11377
- "getContentByPath",
11378
- "resolveRouteOutcome",
11379
- "resolveRouteDecision",
11380
- "listPublishedEntries",
11381
- "getPublishedEntryPreview",
11382
- "getPublicFormById",
11383
- "listPublicForms",
11384
- "getPublicBookingServices",
11385
- "getPublicWeeklySlotAvailability",
11386
- "getPublicChallenge",
11387
- "listPublicEvents",
11388
- "batchBlockLoaders",
11389
- "listPublicTeamMembers",
11390
- "listPublicProducts",
11391
- "listPublicPasses",
11392
- "listPublicMemberships",
11393
- "resolveEventSubroute",
11394
- "checkRedirect",
11395
- "getRoutableContent",
11396
- "getPublicRoutableContent",
11397
- "getPublicSitemapRoutes"
11398
- ];
11399
- const API_ENDPOINTS = Object.freeze({
11400
- getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
11401
- getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
11402
- getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
11403
- getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
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
+ },
11404
11287
  getContentByPath: {
11405
- revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
11406
- path: "/sites/{siteId}/pages",
11407
- method: "GET",
11408
- tags: [TAG_TEMPLATES.siteRoutableContent],
11409
- auth: "public",
11410
- responseKind: "json"
11288
+ kind: "durable-public-stale",
11289
+ staleTtlSec: DEFAULT_STALE_TTL_SEC
11411
11290
  },
11412
11291
  resolveRouteOutcome: {
11413
- path: "/sites/{siteId}/route-outcome",
11414
- method: "GET",
11415
- tags: [
11416
- TAG_TEMPLATES.siteRoutableContent,
11417
- TAG_TEMPLATES.siteRedirects,
11418
- TAG_TEMPLATES.siteRouteOutcomes
11419
- ],
11420
- auth: "public",
11421
- responseKind: "json"
11292
+ kind: "memory-only",
11293
+ reason: "durable_rollout_pending"
11422
11294
  },
11423
11295
  resolveRouteDecision: {
11424
- path: "/sites/{siteId}/route-decision",
11425
- method: "GET",
11426
- tags: [
11427
- TAG_TEMPLATES.siteRoutableContent,
11428
- TAG_TEMPLATES.siteRedirects,
11429
- TAG_TEMPLATES.siteRouteOutcomes
11430
- ],
11431
- auth: "public",
11432
- responseKind: "json"
11296
+ kind: "memory-only",
11297
+ reason: "durable_rollout_pending"
11433
11298
  },
11434
11299
  listPublishedEntries: {
11435
- path: "/public/content/{siteId}/{type}/entries",
11436
- method: "GET",
11437
- revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
11438
- tags: [TAG_TEMPLATES.siteRoutableContent],
11439
- auth: "public",
11440
- responseKind: "json"
11300
+ kind: "memory-only",
11301
+ reason: "durable_rollout_pending"
11441
11302
  },
11442
11303
  getPublishedEntryPreview: {
11443
- path: "/public/content/{siteId}/{type}/{slug}/preview",
11444
- method: "GET",
11445
- revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
11446
- tags: [TAG_TEMPLATES.siteRoutableContent],
11447
- auth: "public",
11448
- responseKind: "json"
11304
+ kind: "memory-only",
11305
+ reason: "durable_rollout_pending"
11449
11306
  },
11450
11307
  getPublicFormById: {
11451
- path: "/public/forms/{formId}",
11452
- method: "GET",
11453
- revalidate: publicReadFreshnessSeconds("getPublicFormById"),
11454
- tags: [TAG_TEMPLATES.formById],
11455
- auth: "public",
11456
- responseKind: "json"
11308
+ kind: "memory-only",
11309
+ reason: "durable_rollout_pending"
11457
11310
  },
11458
11311
  listPublicForms: {
11459
- path: "/public/sites/{siteId}/forms",
11460
- method: "GET",
11461
- revalidate: 60,
11462
- tags: [TAG_TEMPLATES.siteForms],
11463
- auth: "public",
11464
- responseKind: "json"
11312
+ kind: "memory-only",
11313
+ reason: "durable_rollout_pending"
11465
11314
  },
11466
11315
  getPublicBookingServices: {
11467
- path: "/public/bookings/services",
11468
- method: "GET",
11469
- revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
11470
- tags: [TAG_TEMPLATES.publicBookingServices],
11471
- auth: "public",
11472
- responseKind: "json"
11316
+ kind: "live-only",
11317
+ reason: "safety_sensitive_booking"
11473
11318
  },
11474
11319
  getPublicWeeklySlotAvailability: {
11475
- path: "/public/bookings/weekly-slot-availability",
11476
- method: "GET",
11477
- revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
11478
- tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
11479
- auth: "public",
11480
- responseKind: "json"
11320
+ kind: "live-only",
11321
+ reason: "safety_sensitive_booking"
11481
11322
  },
11482
11323
  getPublicChallenge: {
11483
- path: "/public/challenge",
11484
- method: "GET",
11485
- auth: "public",
11486
- responseKind: "text"
11324
+ kind: "live-only",
11325
+ reason: "challenge_endpoint"
11487
11326
  },
11488
11327
  listPublicEvents: {
11489
- path: "/public/sites/{siteId}/events",
11490
- method: "GET",
11491
- revalidate: publicReadFreshnessSeconds("listPublicEvents"),
11492
- tags: [TAG_TEMPLATES.publicEvents],
11493
- auth: "public",
11494
- responseKind: "json"
11328
+ kind: "memory-only",
11329
+ reason: "durable_rollout_pending"
11495
11330
  },
11496
11331
  batchBlockLoaders: {
11497
- path: "/public/sites/{siteId}/block-loaders/batch",
11498
- method: "POST",
11499
- auth: "public",
11500
- responseKind: "json"
11332
+ kind: "live-only",
11333
+ reason: "opaque_batch_loader"
11501
11334
  },
11502
11335
  listPublicTeamMembers: {
11503
- path: "/public/sites/{siteId}/team-members",
11504
- method: "GET",
11505
- revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
11506
- tags: [TAG_TEMPLATES.publicTeamMembers],
11507
- auth: "public",
11508
- responseKind: "json"
11336
+ kind: "memory-only",
11337
+ reason: "durable_rollout_pending"
11509
11338
  },
11510
11339
  listPublicProducts: {
11511
- path: "/public/sites/{siteId}/products",
11512
- method: "GET",
11513
- revalidate: publicReadFreshnessSeconds("listPublicProducts"),
11514
- tags: [TAG_TEMPLATES.publicProducts],
11515
- auth: "public",
11516
- responseKind: "json"
11340
+ kind: "memory-only",
11341
+ reason: "durable_rollout_pending"
11517
11342
  },
11518
11343
  listPublicPasses: {
11519
- path: "/public/sites/{siteId}/bookings/products/passes",
11520
- method: "GET",
11521
- revalidate: publicReadFreshnessSeconds("listPublicPasses"),
11522
- tags: [TAG_TEMPLATES.publicPasses],
11523
- auth: "public",
11524
- responseKind: "json"
11344
+ kind: "live-only",
11345
+ reason: "safety_sensitive_booking"
11525
11346
  },
11526
11347
  listPublicMemberships: {
11527
- path: "/public/sites/{siteId}/bookings/products/memberships",
11528
- method: "GET",
11529
- revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
11530
- tags: [TAG_TEMPLATES.publicMemberships],
11531
- auth: "public",
11532
- responseKind: "json"
11348
+ kind: "live-only",
11349
+ reason: "safety_sensitive_booking"
11533
11350
  },
11534
- resolveEventSubroute: {
11535
- path: "/public/sites/{siteId}/events/subroutes/resolve",
11536
- method: "GET",
11537
- revalidate: 60,
11538
- tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
11539
- auth: "public",
11540
- responseKind: "json"
11351
+ checkRedirect: {
11352
+ kind: "memory-only",
11353
+ reason: "durable_rollout_pending"
11541
11354
  },
11542
- checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
11543
- });
11544
- function buildEndpointURL(baseURL, endpoint) {
11545
- return baseURL + API_ENDPOINTS[endpoint].path;
11546
- }
11547
- function publicSiteReadDefinition(definition) {
11548
- return {
11549
- path: definition.path,
11550
- method: definition.method,
11551
- revalidate: definition.revalidate,
11552
- tags: definition.tags,
11553
- auth: definition.auth,
11554
- responseKind: definition.responseKind
11555
- };
11556
- }
11557
- //#endregion
11558
- //#region src/client/runtimeCacheKeys.ts
11559
- /**
11560
- * Bump when a cached payload's shape changes incompatibly, so readers skip
11561
- * entries written in the old shape until publish or a live success rewrites
11562
- * them.
11563
- *
11564
- * - 4: owned surface inputs use the shared revision transport envelope (#1627).
11565
- * - 3: hidden business-source maps and private locations are removed before public projection (#1611).
11566
- * - 2: pages carry intent-only `runtimeJoins` in place of compiled
11567
- * `runtimeBoundaries` (issue 1422).
11568
- */
11569
- const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 4;
11570
- function toNonEmptyString(value) {
11571
- if (value === null || value === void 0) return null;
11572
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
11573
- const normalized = String(value).trim();
11574
- return normalized.length > 0 ? normalized : null;
11355
+ getRoutableContent: {
11356
+ kind: "live-only",
11357
+ reason: "auth_required"
11358
+ },
11359
+ getPublicRoutableContent: {
11360
+ kind: "memory-only",
11361
+ reason: "durable_rollout_pending"
11362
+ },
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);
11575
11371
  }
11576
- function normalizeRuntimePublicPath(value) {
11577
- const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
11578
- const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
11579
- return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
11372
+ function isTruthyParam(value) {
11373
+ return value === true || value === "true" || value === 1 || value === "1";
11580
11374
  }
11581
- function normalizeRuntimeHostname(value) {
11582
- const trimmed = value.trim().toLowerCase();
11583
- return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
11375
+ function isPreviewRequest(endpoint, params) {
11376
+ if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
11377
+ if (endpoint === "listPublishedEntries") return params.stage === "preview";
11378
+ return false;
11584
11379
  }
11585
- function normalizeScalar(value) {
11586
- return value.trim().toLowerCase();
11380
+ function getEndpointFreshTtlSec(endpoint) {
11381
+ return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
11587
11382
  }
11588
- function unsafeAsPublishedRuntimeCacheKey(value) {
11589
- return value;
11383
+ function assertNever(value) {
11384
+ throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
11590
11385
  }
11591
- function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
11592
- return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
11386
+ function resolveKnownEndpointPolicy(endpoint, params) {
11387
+ if (isPreviewRequest(endpoint, params)) return {
11388
+ kind: "live-only",
11389
+ endpoint,
11390
+ reason: "preview_request"
11391
+ };
11392
+ if (endpoint === "getSite" && isTruthyParam(params.force)) return {
11393
+ kind: "live-only",
11394
+ endpoint,
11395
+ reason: "force_refresh"
11396
+ };
11397
+ if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
11398
+ kind: "live-only",
11399
+ endpoint,
11400
+ reason: "safety_sensitive_booking"
11401
+ };
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
11407
+ };
11408
+ const endpointDefinition = API_ENDPOINTS[endpoint];
11409
+ if (endpointDefinition.method !== "GET") return {
11410
+ kind: "live-only",
11411
+ endpoint,
11412
+ reason: "non_get_request"
11413
+ };
11414
+ if (endpointDefinition.auth === "user") return {
11415
+ kind: "live-only",
11416
+ endpoint,
11417
+ reason: "auth_required"
11418
+ };
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);
11433
+ }
11593
11434
  }
11594
- function selectSiteRuntimeIdentity(params) {
11595
- const slug = toNonEmptyString(params.slug);
11596
- if (slug !== null) return { slug: normalizeScalar(slug) };
11597
- const domain = toNonEmptyString(params.domain);
11598
- if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
11599
- const id = toNonEmptyString(params.id);
11600
- if (id !== null) return { id: normalizeScalar(id) };
11601
- return null;
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"
11445
+ };
11446
+ return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
11602
11447
  }
11603
- function deriveGetSiteKey(params) {
11604
- const identity = selectSiteRuntimeIdentity(params);
11605
- if (identity === null) return {
11606
- ok: false,
11607
- error: {
11608
- kind: "missing_site_identity",
11609
- acceptedParams: [
11610
- "slug",
11611
- "domain",
11612
- "id"
11613
- ]
11614
- }
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"
11615
11454
  };
11616
- const normalizedParams = {
11617
- ...identity,
11618
- ...toNonEmptyString(params.currentPath) === null ? {} : { currentPath: normalizeRuntimePublicPath(params.currentPath) }
11455
+ if (Number.isNaN(staleUntilMs)) return {
11456
+ kind: "invalid_timestamp",
11457
+ field: "staleUntil"
11458
+ };
11459
+ const nowMs = input.now.getTime();
11460
+ if (nowMs > staleUntilMs) return { kind: "expired" };
11461
+ if (nowMs <= freshUntilMs) return {
11462
+ kind: "fresh",
11463
+ staleAgeSec: 0
11619
11464
  };
11620
11465
  return {
11621
- ok: true,
11622
- endpoint: "getSite",
11623
- key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
11624
- normalizedParams
11466
+ kind: "stale",
11467
+ staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
11625
11468
  };
11626
11469
  }
11627
- function deriveGetContentByPathKey(params) {
11628
- const siteId = toNonEmptyString(params.siteId);
11629
- if (siteId === null) return {
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 {
11630
11477
  ok: false,
11631
11478
  error: {
11632
- kind: "missing_required_param",
11633
- endpoint: "getContentByPath",
11634
- param: "siteId"
11479
+ kind: "not_durable_eligible",
11480
+ policy
11635
11481
  }
11636
11482
  };
11637
- const normalizedParams = {
11638
- siteId: normalizeScalar(siteId),
11639
- path: normalizeRuntimePublicPath(params.path),
11640
- contentContract: "native"
11641
- };
11483
+ return deriveDurableRuntimeCacheKey(input);
11484
+ }
11485
+ //#endregion
11486
+ //#region src/client/contentReadOperations.ts
11487
+ function planPublishedRuntimeCache(input) {
11488
+ const policy = resolveRuntimeCachePolicy({
11489
+ endpoint: input.endpoint,
11490
+ method: "GET",
11491
+ params: input.params
11492
+ });
11493
+ if (policy.kind !== "durable-public-stale") return null;
11494
+ const keyResult = derivePublishedRuntimeCacheKey(input);
11495
+ if (!keyResult.ok) return null;
11642
11496
  return {
11643
- ok: true,
11644
- endpoint: "getContentByPath",
11645
- key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
11646
- normalizedParams
11497
+ cacheKey: keyResult.key,
11498
+ endpoint: keyResult.endpoint,
11499
+ normalizedParams: keyResult.normalizedParams,
11500
+ freshTtlSec: policy.freshTtlSec,
11501
+ staleTtlSec: policy.staleTtlSec,
11502
+ siteId: input.siteId ?? null
11647
11503
  };
11648
11504
  }
11649
- function deriveDurableRuntimeCacheKey(input) {
11650
- switch (input.endpoint) {
11651
- case "getSite": return deriveGetSiteKey(input.params);
11652
- case "getContentByPath": return deriveGetContentByPathKey(input.params);
11653
- }
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
+ };
11654
11513
  }
11655
- function isPublishedRuntimeCacheKeyEndpoint(value) {
11656
- return value === "getSite" || value === "getContentByPath";
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;
11657
11518
  }
11658
- function parsePublishedRuntimeCacheKey(value) {
11659
- const details = parsePublishedRuntimeCacheKeyDetails(value);
11660
- if (!details.ok) return details;
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
+ });
11661
11532
  return {
11662
- ok: true,
11663
- key: details.key,
11664
- endpoint: details.endpoint
11533
+ publishedRuntimeCache,
11534
+ prebuildIdentifier: id || slug || domain,
11535
+ cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
11665
11536
  };
11666
11537
  }
11667
- function parsePublishedRuntimeCacheKeyDetails(value) {
11668
- if (typeof value !== "string") return {
11669
- ok: false,
11670
- error: "not_string"
11671
- };
11672
- const parts = value.split(":");
11673
- if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
11674
- ok: false,
11675
- error: "invalid_prefix"
11676
- };
11677
- const endpoint = parts[2];
11678
- if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
11679
- ok: false,
11680
- error: "unknown_endpoint"
11681
- };
11682
- const normalizedParams = {};
11683
- for (const part of parts.slice(3)) {
11684
- const separatorIndex = part.indexOf("=");
11685
- if (separatorIndex <= 0) return {
11686
- ok: false,
11687
- error: "invalid_param_encoding"
11688
- };
11689
- try {
11690
- const key = decodeURIComponent(part.slice(0, separatorIndex));
11691
- normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
11692
- } catch {
11693
- return {
11694
- ok: false,
11695
- error: "invalid_param_encoding"
11696
- };
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" } : {}
11697
11549
  }
11698
- }
11699
- if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
11700
- ok: false,
11701
- error: "invalid_param_encoding"
11702
- };
11703
- return {
11704
- ok: true,
11705
- key: unsafeAsPublishedRuntimeCacheKey(value),
11706
- endpoint,
11707
- normalizedParams
11708
- };
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
+ });
11709
11561
  }
11710
- function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
11711
- const keys = Object.keys(normalizedParams).sort();
11712
- switch (endpoint) {
11713
- case "getSite": return [
11714
- "domain",
11715
- "id",
11716
- "slug"
11717
- ].filter((key) => normalizedParams[key] !== void 0).length === 1 && keys.every((key) => [
11718
- "currentPath",
11719
- "domain",
11720
- "id",
11721
- "slug"
11722
- ].includes(key));
11723
- case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
11724
- "contentContract",
11725
- "path",
11726
- "siteId"
11727
- ].includes(key));
11728
- }
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;
11729
11592
  }
11730
- function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
11731
- if (typeof value !== "number") return {
11732
- ok: false,
11733
- error: "not_number"
11734
- };
11735
- if (!Number.isInteger(value)) return {
11736
- ok: false,
11737
- error: "not_integer"
11738
- };
11739
- if (value <= 0) return {
11740
- ok: false,
11741
- error: "not_positive"
11593
+ function createContentReadOperations(input) {
11594
+ return {
11595
+ getSiteWithResilience: (params) => readSiteWithResilience(input, params),
11596
+ getPageWithResilience: (params) => readPageWithResilience(input, params)
11742
11597
  };
11598
+ }
11599
+ //#endregion
11600
+ //#region src/client/publicAppointmentReadOperations.ts
11601
+ function createPublicAppointmentReadOperations(deps) {
11743
11602
  return {
11744
- ok: true,
11745
- value
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
+ }
11746
11651
  };
11747
11652
  }
11748
11653
  //#endregion
11749
- //#region src/client/runtimeCachePolicy.ts
11750
- const DEFAULT_STALE_TTL_SEC = 1440 * 60;
11751
- const DEFAULT_MEMORY_TTL_SEC = 60;
11752
- const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
11753
- getSite: {
11754
- kind: "durable-public-stale",
11755
- staleTtlSec: DEFAULT_STALE_TTL_SEC
11756
- },
11757
- getContentByPath: {
11758
- kind: "durable-public-stale",
11759
- staleTtlSec: DEFAULT_STALE_TTL_SEC
11760
- },
11761
- resolveRouteOutcome: {
11762
- kind: "memory-only",
11763
- reason: "durable_rollout_pending"
11764
- },
11765
- resolveRouteDecision: {
11766
- kind: "memory-only",
11767
- reason: "durable_rollout_pending"
11768
- },
11769
- listPublishedEntries: {
11770
- kind: "memory-only",
11771
- reason: "durable_rollout_pending"
11772
- },
11773
- getPublishedEntryPreview: {
11774
- kind: "memory-only",
11775
- reason: "durable_rollout_pending"
11776
- },
11777
- getPublicFormById: {
11778
- kind: "memory-only",
11779
- reason: "durable_rollout_pending"
11780
- },
11781
- listPublicForms: {
11782
- kind: "memory-only",
11783
- reason: "durable_rollout_pending"
11784
- },
11785
- getPublicBookingServices: {
11786
- kind: "live-only",
11787
- reason: "safety_sensitive_booking"
11788
- },
11789
- getPublicWeeklySlotAvailability: {
11790
- kind: "live-only",
11791
- reason: "safety_sensitive_booking"
11792
- },
11793
- getPublicChallenge: {
11794
- kind: "live-only",
11795
- reason: "challenge_endpoint"
11796
- },
11797
- listPublicEvents: {
11798
- kind: "memory-only",
11799
- reason: "durable_rollout_pending"
11800
- },
11801
- batchBlockLoaders: {
11802
- kind: "live-only",
11803
- reason: "opaque_batch_loader"
11804
- },
11805
- listPublicTeamMembers: {
11806
- kind: "memory-only",
11807
- reason: "durable_rollout_pending"
11808
- },
11809
- listPublicProducts: {
11810
- kind: "memory-only",
11811
- reason: "durable_rollout_pending"
11812
- },
11813
- listPublicPasses: {
11814
- kind: "live-only",
11815
- reason: "safety_sensitive_booking"
11816
- },
11817
- listPublicMemberships: {
11818
- kind: "live-only",
11819
- reason: "safety_sensitive_booking"
11820
- },
11821
- resolveEventSubroute: {
11822
- kind: "memory-only",
11823
- reason: "durable_rollout_pending"
11824
- },
11825
- checkRedirect: {
11826
- kind: "memory-only",
11827
- reason: "durable_rollout_pending"
11828
- },
11829
- getRoutableContent: {
11830
- kind: "live-only",
11831
- reason: "auth_required"
11832
- },
11833
- getPublicRoutableContent: {
11834
- kind: "memory-only",
11835
- reason: "durable_rollout_pending"
11836
- },
11837
- getPublicSitemapRoutes: {
11838
- kind: "memory-only",
11839
- reason: "durable_rollout_pending"
11840
- }
11841
- };
11842
- const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
11843
- function isPublicEndpointName(endpoint) {
11844
- return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
11845
- }
11846
- function isTruthyParam(value) {
11847
- return value === true || value === "true" || value === 1 || value === "1";
11848
- }
11849
- function isPreviewRequest(endpoint, params) {
11850
- if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
11851
- if (endpoint === "listPublishedEntries" || endpoint === "resolveEventSubroute") return params.stage === "preview";
11852
- return false;
11853
- }
11854
- function getEndpointFreshTtlSec(endpoint) {
11855
- return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
11856
- }
11857
- function assertNever(value) {
11858
- throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
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
+ } };
11859
11669
  }
11860
- function resolveKnownEndpointPolicy(endpoint, params) {
11861
- if (isPreviewRequest(endpoint, params)) return {
11862
- kind: "live-only",
11863
- endpoint,
11864
- reason: "preview_request"
11865
- };
11866
- if (endpoint === "getSite" && isTruthyParam(params.force)) return {
11867
- kind: "live-only",
11868
- endpoint,
11869
- reason: "force_refresh"
11870
- };
11871
- if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
11872
- kind: "live-only",
11873
- endpoint,
11874
- reason: "safety_sensitive_booking"
11875
- };
11876
- const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
11877
- if (override.kind === "live-only") return {
11878
- kind: "live-only",
11879
- endpoint,
11880
- reason: override.reason
11881
- };
11882
- const endpointDefinition = API_ENDPOINTS[endpoint];
11883
- if (endpointDefinition.method !== "GET") return {
11884
- kind: "live-only",
11885
- endpoint,
11886
- reason: "non_get_request"
11887
- };
11888
- if (endpointDefinition.auth === "user") return {
11889
- kind: "live-only",
11890
- endpoint,
11891
- reason: "auth_required"
11892
- };
11893
- switch (override.kind) {
11894
- case "durable-public-stale": return {
11895
- kind: "durable-public-stale",
11896
- endpoint,
11897
- freshTtlSec: getEndpointFreshTtlSec(endpoint),
11898
- staleTtlSec: override.staleTtlSec
11899
- };
11900
- case "memory-only": return {
11901
- kind: "memory-only",
11902
- endpoint,
11903
- freshTtlSec: getEndpointFreshTtlSec(endpoint),
11904
- reason: override.reason
11905
- };
11906
- default: return assertNever(override);
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 });
11907
11681
  }
11682
+ return controller.signal;
11908
11683
  }
11909
- function resolveRuntimeCachePolicy(input) {
11910
- if (input.method && input.method.toUpperCase() !== "GET") return {
11911
- kind: "live-only",
11912
- endpoint: input.endpoint,
11913
- reason: "non_get_request"
11914
- };
11915
- if (!isPublicEndpointName(input.endpoint)) return {
11916
- kind: "live-only",
11917
- endpoint: input.endpoint,
11918
- reason: "unknown_endpoint"
11919
- };
11920
- return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
11921
- }
11922
- function classifyPublishedRuntimeCacheFreshness(input) {
11923
- const freshUntilMs = Date.parse(input.freshUntil);
11924
- const staleUntilMs = Date.parse(input.staleUntil);
11925
- if (Number.isNaN(freshUntilMs)) return {
11926
- kind: "invalid_timestamp",
11927
- field: "freshUntil"
11928
- };
11929
- if (Number.isNaN(staleUntilMs)) return {
11930
- kind: "invalid_timestamp",
11931
- field: "staleUntil"
11932
- };
11933
- const nowMs = input.now.getTime();
11934
- if (nowMs > staleUntilMs) return { kind: "expired" };
11935
- if (nowMs <= freshUntilMs) return {
11936
- kind: "fresh",
11937
- staleAgeSec: 0
11938
- };
11939
- return {
11940
- kind: "stale",
11941
- staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
11942
- };
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);
11943
11735
  }
11944
- function derivePublishedRuntimeCacheKey(input) {
11945
- const policy = resolveRuntimeCachePolicy({
11946
- endpoint: input.endpoint,
11947
- method: "GET",
11948
- params: input.params
11949
- });
11950
- if (policy.kind !== "durable-public-stale") return {
11951
- ok: false,
11952
- error: {
11953
- kind: "not_durable_eligible",
11954
- policy
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;
11955
11756
  }
11956
- };
11957
- return deriveDurableRuntimeCacheKey(input);
11958
- }
11959
- //#endregion
11960
- //#region src/client/contentReadOperations.ts
11961
- function planPublishedRuntimeCache(input) {
11962
- const policy = resolveRuntimeCachePolicy({
11963
- endpoint: input.endpoint,
11964
- method: "GET",
11965
- params: input.params
11966
- });
11967
- if (policy.kind !== "durable-public-stale") return null;
11968
- const keyResult = derivePublishedRuntimeCacheKey(input);
11969
- if (!keyResult.ok) return null;
11970
- return {
11971
- cacheKey: keyResult.key,
11972
- endpoint: keyResult.endpoint,
11973
- normalizedParams: keyResult.normalizedParams,
11974
- freshTtlSec: policy.freshTtlSec,
11975
- staleTtlSec: policy.staleTtlSec,
11976
- siteId: input.siteId ?? null
11977
- };
11757
+ current = current.cause;
11758
+ }
11978
11759
  }
11979
- function siteApiParams(params) {
11980
- return {
11981
- ...params.slug ? { slug: params.slug } : {},
11982
- ...params.domain ? { domain: params.domain } : {},
11983
- ...params.id ? { id: params.id } : {},
11984
- ...params.currentPath ? { currentPath: params.currentPath } : {},
11985
- ...params.force ? { force: "true" } : {}
11986
- };
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;
11987
11793
  }
11988
- function siteReadIdentity(params) {
11989
- const identifier = params.slug || params.domain || params.id;
11990
- if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
11991
- return identifier;
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;
11992
11808
  }
11993
- function planSiteRead(params) {
11994
- const identifier = siteReadIdentity(params);
11995
- const { slug, domain, id, currentPath, force } = params;
11996
- const publishedRuntimeCache = planPublishedRuntimeCache({
11997
- endpoint: "getSite",
11998
- params: {
11999
- slug,
12000
- domain,
12001
- id,
12002
- currentPath,
12003
- force
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;
12004
11897
  }
12005
- });
12006
- return {
12007
- publishedRuntimeCache,
12008
- prebuildIdentifier: id || slug || domain,
12009
- cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
12010
- };
12011
- }
12012
- async function readSiteWithResilience(input, params) {
12013
- const { slug, domain, id, signal, force } = params;
12014
- const plan = planSiteRead(params);
12015
- const prebuildId = plan.prebuildIdentifier;
12016
- const prebuild = input.prebuildLoader;
12017
- return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
12018
- endpoint: "getSite",
12019
- params: siteApiParams(params),
12020
- options: {
12021
- signal: requestSignal,
12022
- ...force ? { cache: "no-store" } : {}
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);
12023
11919
  }
12024
- }), {
12025
- signal,
12026
- force,
12027
- publishedRuntimeCache: plan.publishedRuntimeCache,
12028
- cacheTags: buildSiteReadTags({
12029
- slug,
12030
- domain,
12031
- id
12032
- }),
12033
- prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
12034
- });
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;
12035
11926
  }
12036
- async function readPageWithResilience(input, params) {
12037
- const { siteId, path, preview = false, signal } = params;
12038
- const publishedRuntimeCache = planPublishedRuntimeCache({
12039
- endpoint: "getContentByPath",
12040
- params: {
12041
- siteId,
12042
- path,
12043
- preview
12044
- },
12045
- siteId
12046
- });
12047
- const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
12048
- return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
12049
- endpoint: "getContentByPath",
12050
- params: {
12051
- siteId,
12052
- path,
12053
- preview: String(preview)
12054
- },
12055
- options: { signal: requestSignal }
12056
- }), {
12057
- preview,
12058
- signal,
12059
- publishedRuntimeCache,
12060
- cacheTags: buildSiteReadTags({ siteId }),
12061
- prebuildFallback: void 0
12062
- });
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;
12063
11934
  }
12064
- function createContentReadOperations(input) {
12065
- return {
12066
- getSiteWithResilience: (params) => readSiteWithResilience(input, params),
12067
- getPageWithResilience: (params) => readPageWithResilience(input, params)
12068
- };
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);
12069
11942
  }
12070
- //#endregion
12071
- //#region src/client/publicAppointmentReadOperations.ts
12072
- function createPublicAppointmentReadOperations(deps) {
12073
- return {
12074
- async getPublicBookingServices(params) {
12075
- const { siteId, ids, signal } = params;
12076
- if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
12077
- const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
12078
- return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
12079
- const apiParams = {
12080
- siteId,
12081
- ...ids && { ids }
12082
- };
12083
- return await deps.apiClient({
12084
- endpoint: "getPublicBookingServices",
12085
- params: apiParams,
12086
- options: { signal: requestSignal }
12087
- });
12088
- }, {
12089
- signal,
12090
- cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
12091
- });
12092
- },
12093
- async getPublicWeeklySlotAvailability(params) {
12094
- const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
12095
- if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
12096
- const cacheKey = [
12097
- "public-weekly-slot-availability",
12098
- siteId,
12099
- serviceId,
12100
- resourceId ?? "",
12101
- horizonWeeks ?? "",
12102
- timezone ?? ""
12103
- ].join(":");
12104
- return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
12105
- const apiParams = {
12106
- siteId,
12107
- serviceId,
12108
- ...resourceId && { resourceId },
12109
- ...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
12110
- ...timezone && { timezone }
12111
- };
12112
- return await deps.apiClient({
12113
- endpoint: "getPublicWeeklySlotAvailability",
12114
- params: apiParams,
12115
- options: { signal: requestSignal }
12116
- });
12117
- }, {
12118
- signal,
12119
- cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
12120
- });
12121
- }
12122
- };
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);
12123
11949
  }
12124
- //#endregion
12125
- //#region src/client/publicEventReadOperations.ts
12126
- function createPublicEventReadOperations(deps) {
12127
- async function resolveEventSubroute(params, kind) {
12128
- const { siteId, subject, segment, signal, preview = false } = params;
12129
- if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
12130
- const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
12131
- return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
12132
- endpoint: "resolveEventSubroute",
12133
- params: {
12134
- siteId,
12135
- kind,
12136
- subjectKind: subject.kind,
12137
- subjectId,
12138
- segment,
12139
- stage: preview ? "preview" : "published"
12140
- },
12141
- options: { signal: requestSignal }
12142
- }), {
12143
- signal,
12144
- preview,
12145
- cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
12146
- });
12147
- }
12148
- return {
12149
- async listPublicEventCalendarWindow({ signal, ...params }) {
12150
- return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
12151
- endpoint: "listPublicEventCalendarWindow",
12152
- params: {
12153
- ...params,
12154
- limit: params.limit === void 0 ? void 0 : String(params.limit)
12155
- },
12156
- options: { signal: requestSignal }
12157
- }), {
12158
- signal,
12159
- cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
12160
- });
12161
- },
12162
- async resolveEventOccurrence(params) {
12163
- const response = await resolveEventSubroute(params, "event-occurrence");
12164
- return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
12165
- },
12166
- async resolveEventRun(params) {
12167
- const response = await resolveEventSubroute(params, "event-run");
12168
- return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
12169
- }
12170
- };
11950
+ /**
11951
+ * Sleep for specified milliseconds
11952
+ */
11953
+ function sleep(ms) {
11954
+ return new Promise((resolve) => setTimeout(resolve, ms));
12171
11955
  }
12172
- //#endregion
12173
- //#region src/client/combineAbortSignals.ts
12174
- /** Combine signals into one that aborts when any input aborts. */
12175
- function combineAbortSignals(...signals) {
12176
- const controller = new AbortController();
12177
- for (const signal of signals) {
12178
- if (signal.aborted) {
12179
- controller.abort(signal.reason);
12180
- break;
12181
- }
12182
- signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
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;
12183
11964
  }
12184
- return controller.signal;
12185
- }
11965
+ };
12186
11966
  //#endregion
12187
11967
  //#region src/client/publicLoaderCacheAccess.ts
12188
11968
  function shouldWrite(cacheEnabled, force) {
@@ -12261,6 +12041,38 @@ function generateRequestId() {
12261
12041
  function toRecord(value) {
12262
12042
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
12263
12043
  }
12044
+ function adapterExceptionMessage(error) {
12045
+ return error instanceof Error ? error.message : String(error);
12046
+ }
12047
+ function publishedCacheLifetime(plan, payload) {
12048
+ if (plan.endpoint !== "getContentByPath" || pageReadDependencies(payload) !== "availability") return {
12049
+ freshTtlSec: plan.freshTtlSec,
12050
+ staleTtlSec: plan.staleTtlSec
12051
+ };
12052
+ const ttl = buildPageReadCachePolicy(plan.siteId ?? "", "availability").revalidate;
12053
+ return {
12054
+ freshTtlSec: ttl,
12055
+ staleTtlSec: ttl
12056
+ };
12057
+ }
12058
+ function reusableDurablePayload(plan, payload, freshness) {
12059
+ return plan.endpoint !== "getContentByPath" || pageReadDependencies(payload) !== "availability" || freshness === "fresh";
12060
+ }
12061
+ function memoryWritePolicy(pageRead, data, tags, cacheTTL) {
12062
+ if (!pageRead) return { tags };
12063
+ const dependency = pageReadDependencies(data);
12064
+ const policy = buildPageReadCachePolicy(pageRead.siteId, dependency);
12065
+ return {
12066
+ tags: policy.tags,
12067
+ ...dependency === "availability" ? {
12068
+ ttl: Math.min(cacheTTL, policy.revalidate * 1e3),
12069
+ staleTtl: 0
12070
+ } : {}
12071
+ };
12072
+ }
12073
+ function isPageReadRefusal(pageRead, error) {
12074
+ return Boolean(pageRead) && error instanceof RiverbankApiError && error.status === 404;
12075
+ }
12264
12076
  function getRuntimePayloadSiteId(value) {
12265
12077
  const site = toRecord(value).site;
12266
12078
  if (!site || typeof site !== "object" || Array.isArray(site)) return null;
@@ -12385,7 +12197,8 @@ function convertToTypedError(error) {
12385
12197
  requestId: error.requestId,
12386
12198
  timestamp: error.timestamp,
12387
12199
  status: error.status,
12388
- fieldErrors: error.fieldErrors
12200
+ fieldErrors: error.fieldErrors,
12201
+ tag: error.tag
12389
12202
  });
12390
12203
  if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
12391
12204
  const body = error.body;
@@ -12452,8 +12265,8 @@ const defaultRiverbankClientDeps = {
12452
12265
  * ```
12453
12266
  */
12454
12267
  /**
12455
- * A memory hit skips fetch, so Next never sees the read's tags: an ISR render would store old
12456
- * content under a page no webhook can reach. Next's tagged fetch cache already covers these reads.
12268
+ * Next's tagged cache owns normal reads; SDK memory remains an outage fallback by default.
12269
+ * Explicitly enabled admitted-page memory hits also register their returned framework policy.
12457
12270
  */
12458
12271
  function isRunningInNextServer() {
12459
12272
  return typeof window === "undefined" && typeof process !== "undefined" && Boolean(process.env.NEXT_RUNTIME);
@@ -12465,6 +12278,12 @@ function resolveMemoryCachePolicy(config) {
12465
12278
  servesFreshMemoryHits: enabled ?? !isRunningInNextServer()
12466
12279
  };
12467
12280
  }
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;
12286
+ }
12468
12287
  function createRiverbankClient(config) {
12469
12288
  return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
12470
12289
  }
@@ -12503,7 +12322,18 @@ function createRiverbankClientWithDeps(deps, config) {
12503
12322
  keyType = "preview";
12504
12323
  break;
12505
12324
  }
12506
- const apiClient = withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, sdkRequestOptions) : authConfig.type === "api-key" ? deps.createBearerAPIClient(authConfig.key, config.baseUrl, sdkRequestOptions) : deps.createBearerAPIClient(authConfig.token, config.baseUrl, sdkRequestOptions), config.defaultHeaders);
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);
12507
12337
  const cache = new SimpleCache({
12508
12338
  maxSize: cacheMaxSize,
12509
12339
  ttl: cacheTTL,
@@ -12554,7 +12384,7 @@ function createRiverbankClientWithDeps(deps, config) {
12554
12384
  const result = await reader({
12555
12385
  cacheKey: plan.cacheKey,
12556
12386
  endpoint: plan.endpoint,
12557
- payloadSchemaVersion: 4
12387
+ payloadSchemaVersion: 5
12558
12388
  });
12559
12389
  if (result.kind === "miss") return {
12560
12390
  kind: "miss",
@@ -12570,6 +12400,7 @@ function createRiverbankClientWithDeps(deps, config) {
12570
12400
  error: result.error
12571
12401
  }
12572
12402
  };
12403
+ if (!reusableDurablePayload(plan, result.payload, result.freshness)) return null;
12573
12404
  return {
12574
12405
  kind: "hit",
12575
12406
  result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
@@ -12585,7 +12416,7 @@ function createRiverbankClientWithDeps(deps, config) {
12585
12416
  outcome: "error",
12586
12417
  error: {
12587
12418
  kind: "adapter_exception",
12588
- message: error instanceof Error ? error.message : String(error)
12419
+ message: adapterExceptionMessage(error)
12589
12420
  }
12590
12421
  }
12591
12422
  };
@@ -12601,13 +12432,21 @@ function createRiverbankClientWithDeps(deps, config) {
12601
12432
  normalizedParams: plan.normalizedParams,
12602
12433
  payload,
12603
12434
  siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
12604
- freshTtlSec: plan.freshTtlSec,
12605
- staleTtlSec: plan.staleTtlSec,
12606
- payloadSchemaVersion: 4,
12435
+ ...publishedCacheLifetime(plan, payload),
12436
+ payloadSchemaVersion: 5,
12607
12437
  writeReason: "live_success"
12608
12438
  });
12609
12439
  } catch {}
12610
12440
  }
12441
+ function tryPrebuildFallback(input) {
12442
+ const prebuild = input.allowed && !input.preview && input.fallback ? input.fallback() : null;
12443
+ return prebuild ? emitStatus("prebuild", prebuild.data, input.statusDetails({
12444
+ prebuildAgeSec: prebuild.prebuildAgeSec,
12445
+ cacheTier: "prebuild",
12446
+ durableCache: input.durableCache,
12447
+ error: input.error
12448
+ })) : null;
12449
+ }
12611
12450
  async function resilientFetch(cacheKey, fetcher, options) {
12612
12451
  const requestId = generateRequestId();
12613
12452
  const startTime = Date.now();
@@ -12642,18 +12481,18 @@ function createRiverbankClientWithDeps(deps, config) {
12642
12481
  }) : null;
12643
12482
  const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
12644
12483
  if (durableFallback?.kind === "hit") return durableFallback.result;
12645
- if (allowFallbacks && !isPreview && options.prebuildFallback) {
12646
- const prebuildResult = options.prebuildFallback();
12647
- if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
12648
- prebuildAgeSec: prebuildResult.prebuildAgeSec,
12649
- cacheTier: "prebuild",
12650
- durableCache,
12651
- error: {
12652
- code: "circuit_open",
12653
- message: "Circuit breaker is open"
12654
- }
12655
- }));
12656
- }
12484
+ const prebuild = tryPrebuildFallback({
12485
+ allowed: allowFallbacks,
12486
+ preview: isPreview,
12487
+ fallback: options.prebuildFallback,
12488
+ statusDetails,
12489
+ durableCache,
12490
+ error: {
12491
+ code: "circuit_open",
12492
+ message: "Circuit breaker is open"
12493
+ }
12494
+ });
12495
+ if (prebuild) return prebuild;
12657
12496
  const circuitState = circuitBreaker.getState();
12658
12497
  emitStatus("error", null, statusDetails({
12659
12498
  durableCache,
@@ -12685,10 +12524,11 @@ function createRiverbankClientWithDeps(deps, config) {
12685
12524
  } catch (error) {
12686
12525
  convertToTypedError(error);
12687
12526
  }
12688
- if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, { tags: options.cacheTags });
12527
+ if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, memoryWritePolicy(options.pageRead, data, options.cacheTags, cacheTTL));
12689
12528
  if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
12690
12529
  return emitStatus("live", data, statusDetails());
12691
12530
  } catch (error) {
12531
+ if (isPageReadRefusal(options.pageRead, error)) throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({ error: getRiverbankErrorInfo(error) })).resilience);
12692
12532
  if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
12693
12533
  if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
12694
12534
  const stale = cache.getStale(cacheKey);
@@ -12705,15 +12545,15 @@ function createRiverbankClientWithDeps(deps, config) {
12705
12545
  const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
12706
12546
  const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
12707
12547
  if (durableFallback?.kind === "hit") return durableFallback.result;
12708
- if (allowFallbacks && !isPreview && options.prebuildFallback) {
12709
- const prebuildResult = options.prebuildFallback();
12710
- if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
12711
- prebuildAgeSec: prebuildResult.prebuildAgeSec,
12712
- cacheTier: "prebuild",
12713
- durableCache,
12714
- error: errorInfo
12715
- }));
12716
- }
12548
+ const prebuild = tryPrebuildFallback({
12549
+ allowed: allowFallbacks,
12550
+ preview: isPreview,
12551
+ fallback: options.prebuildFallback,
12552
+ statusDetails,
12553
+ durableCache,
12554
+ error: errorInfo
12555
+ });
12556
+ if (prebuild) return prebuild;
12717
12557
  throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
12718
12558
  error: errorInfo,
12719
12559
  durableCache
@@ -12726,7 +12566,10 @@ function createRiverbankClientWithDeps(deps, config) {
12726
12566
  const contentReads = createContentReadOperations({
12727
12567
  apiClient,
12728
12568
  resilientFetch,
12729
- prebuildLoader
12569
+ prebuildLoader,
12570
+ get frameworkCache() {
12571
+ return framework.adapter;
12572
+ }
12730
12573
  });
12731
12574
  const eventReads = createPublicEventReadOperations({
12732
12575
  apiClient,
@@ -12750,7 +12593,7 @@ function createRiverbankClientWithDeps(deps, config) {
12750
12593
  prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
12751
12594
  }));
12752
12595
  }
12753
- return {
12596
+ const client = {
12754
12597
  async getSite(params) {
12755
12598
  return (await contentReads.getSiteWithResilience(params)).data;
12756
12599
  },
@@ -13117,6 +12960,12 @@ function createRiverbankClientWithDeps(deps, config) {
13117
12960
  return config.baseUrl;
13118
12961
  }
13119
12962
  };
12963
+ frameworkCacheInstallers.set(client, (adapter) => {
12964
+ if (framework.adapter) return;
12965
+ framework.apiClient = createApiClient(adapter);
12966
+ framework.adapter = adapter;
12967
+ });
12968
+ return client;
13120
12969
  }
13121
12970
  //#endregion
13122
- export { createBearerAPIClient as _, DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, getResilienceStatusFromError as g, RiverbankApiError 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, ApiRequestError as v, unwrapResponse as y };
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 };