@riverbankcms/sdk 0.164.0 → 0.166.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 (252) hide show
  1. package/dist/_dts/{BlocksIslandsHydrator-CubPwupc.d.ts → BlocksIslandsHydrator-CPvN6RBW.d.ts} +1 -1
  2. package/dist/_dts/{Page-CDzsagB2.d.ts → Page-rW0xgQCA.d.ts} +18 -256
  3. package/dist/_dts/{SdkPreviewMode-CPRQbRCI.d.ts → SdkPreviewMode-BWZh2WCk.d.ts} +107 -72
  4. package/dist/_dts/{client-CbeYTSry.d.ts → client-D4BXQEZc.d.ts} +5 -1
  5. package/dist/_dts/{content-types--uYRIcIF.d.ts → content-types-MUzta0l9.d.ts} +3 -3
  6. package/dist/_dts/{contracts-DJQYAOsv.d.ts → contracts-Cl9Xh1DO.d.ts} +4 -4
  7. package/dist/_dts/{footerPageOutline-CKkhBwgJ.d.ts → footerPageOutline-4BgLKehl.d.ts} +6 -6
  8. package/dist/_dts/{generatePageMetadata--qd7NCIA.d.ts → generatePageMetadata-BsmJ0qKh.d.ts} +2 -2
  9. package/dist/_dts/{index-wegfy7lf.d.ts → index--qflsCiy.d.ts} +4 -3
  10. package/dist/_dts/{index-CjdIn9-_.d.ts → index-BgJ2aU5c.d.ts} +2 -2
  11. package/dist/_dts/{index-BZE-1azr.d.ts → index-Bmboeb49.d.ts} +2 -2
  12. package/dist/_dts/{index-BpEbwDM7.d.ts → index-DdcwPqQN.d.ts} +4 -4
  13. package/dist/_dts/{index-DriYVLfT.d.ts → index-ahxQCUc7.d.ts} +2 -2
  14. package/dist/_dts/{index-DYQFmf--.d.ts → index-kQ5xkM6X.d.ts} +1 -1
  15. package/dist/_dts/{index-JS8WYgD3.d.ts → index-mMMvLLAJ.d.ts} +2996 -3079
  16. package/dist/_dts/{index-D_pQO-AS.d.ts → index-wbBZ0awa.d.ts} +49398 -48202
  17. package/dist/_dts/{loadContent-DUi94Qfk.d.ts → loadContent-BG5IAV-V.d.ts} +9 -6
  18. package/dist/_dts/resolveBlockData-Cmcle_zV.d.ts +136 -0
  19. package/dist/_dts/{resolvePageContent-JDE0ry6T.d.ts → resolvePageContent-BRJUTFoH.d.ts} +3 -2
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client.d.ts +9 -6
  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 +20 -0
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +2 -0
  28. package/dist/_dts/sdk/src/data/types.d.ts +54 -0
  29. package/dist/_dts/sdk/src/index.d.ts +8 -8
  30. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  31. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  32. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  33. package/dist/_dts/sdk/src/next/index.d.ts +9 -8
  34. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  35. package/dist/_dts/sdk/src/page-converter/index.d.ts +36 -48
  36. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  37. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  38. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  39. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  41. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  42. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +2 -0
  43. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +3 -0
  44. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +257 -0
  45. package/dist/_dts/sdk/src/rendering/index.d.ts +8 -7
  46. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  47. package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
  48. package/dist/_dts/{themeAdmission-D_qtGYAT.d.ts → sdk/src/rendering/themeAdmission.d.ts} +3 -1
  49. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  50. package/dist/_dts/sdk/src/server.d.ts +7 -5
  51. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  52. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  53. package/dist/_dts/{types-DiciZDrk.d.ts → types-BX3Y-EW3.d.ts} +3 -3
  54. package/dist/_dts/{types-DubJnBnI.d.ts → types-DF54stxv.d.ts} +8 -7
  55. package/dist/_dts/{types-W40f2olO.d.ts → types-DuiHLiPo.d.ts} +2 -2
  56. package/dist/_dts/{validation-BF4_zNkR.d.ts → validation-Bxi0f81D.d.ts} +4 -4
  57. package/dist/client/{BlocksIslandsHydrator-64hFxF02.mjs → BlocksIslandsHydrator-DwiRGtgh.mjs} +31 -24
  58. package/dist/client/{BookingMailingListNote-CSQyFm9J.mjs → BookingMailingListNote-DOWOZYlK.mjs} +2 -2
  59. package/dist/client/{CalendarNavigationChevron-Bvkx8Z7Y.mjs → CalendarNavigationChevron-5a0x0vcC.mjs} +7 -7
  60. package/dist/client/{CheckboxChoice-3PhxDxgR.mjs → CheckboxChoice-CZ-anOqV.mjs} +1 -1
  61. package/dist/client/{DemoBookingPortalAccess-pt2xXBQp.mjs → DemoBookingPortalAccess-B2qLkPRB.mjs} +6 -6
  62. package/dist/client/{DemoPortalSignInLink-Qw780EfW.mjs → DemoPortalSignInLink-B9YrzZt2.mjs} +1 -1
  63. package/dist/client/{EventCalendar.client-DWoboRW5.mjs → EventCalendar.client-BhADnDCg.mjs} +17 -10
  64. package/dist/client/{EventCombined.client-C98ucpcP.mjs → EventCombined.client-jik34zTb.mjs} +8 -8
  65. package/dist/client/{EventEmbeddedCheckoutStep-DHRlFfkp.mjs → EventEmbeddedCheckoutStep-D_14yqAU.mjs} +27 -2
  66. package/dist/client/{EventItem-hrSyTApW.mjs → EventItem-CMKrtkT7.mjs} +33 -12
  67. package/dist/client/{EventListWeekNavigation-C3t7H13W.mjs → EventListWeekNavigation-AGHjxy6C.mjs} +1 -1
  68. package/dist/client/{EventListing.client-Cp11sBX_.mjs → EventListing.client-DZeDM0Qt.mjs} +3 -3
  69. package/dist/client/{EventListing.view-Dd5QHIAf.mjs → EventListing.view-3BBRdNVa.mjs} +70 -15
  70. package/dist/client/{EventRegistrationPayment-ByT88VHR.mjs → EventRegistrationPayment-CpNcpga4.mjs} +108 -11
  71. package/dist/client/{LocationMapActions-BsepG5Vv.mjs → LocationMapActions-D5-H9ooQ.mjs} +2 -2
  72. package/dist/client/{MapDrawingSvg-R4JMT4yd.mjs → MapDrawingSvg-C30geMl-.mjs} +1 -1
  73. package/dist/client/{Page-Dub71o3c.mjs → Page-DNDZLRlB.mjs} +3388 -11530
  74. package/dist/client/{ProtectedSubmitButton-DGbgGvdh.mjs → ProtectedSubmitButton-8DuDw2ag.mjs} +1 -1
  75. package/dist/client/{SpamProtectionWidget-CRsKTQV-.mjs → SpamProtectionWidget-CCF6YLUX.mjs} +5 -3
  76. package/dist/client/{StepIndicator-Bp7MyutT.mjs → StepIndicator-Bin7YR0A.mjs} +3 -3
  77. package/dist/client/{TabBarFragment-C4WJyybx.mjs → TabBarFragment-_IAthZVM.mjs} +1 -1
  78. package/dist/client/{ThemedButton-BGVwNwE-.mjs → ThemedButton-8jUc02mZ.mjs} +64 -2
  79. package/dist/client/{accordion-vCG_JC5t.mjs → accordion-uVqNowRX.mjs} +1 -1
  80. package/dist/client/{altchaProtection-BWchRM3v.mjs → altchaProtection-DjIV9A5n.mjs} +1 -1
  81. package/dist/client/{booking-form.client-CHTbcZJM.mjs → booking-form.client-w-PvyWBv.mjs} +19 -14
  82. package/dist/client/{bookingForm-BxbUbzUr.mjs → bookingForm-DNMojb6A.mjs} +4 -4
  83. package/dist/client/bookings.mjs +6 -6
  84. package/dist/client/{carousel-FM1mkkL0.mjs → carousel-C8kxI3Dm.mjs} +2 -2
  85. package/dist/client/{carousel.client-ChoLiWwD.mjs → carousel.client-BO7sCEpH.mjs} +1 -1
  86. package/dist/client/{cart-BDFhbh9j.mjs → cart-DCxjE3Is.mjs} +3 -3
  87. package/dist/client/{cart.client-x3HOke6T.mjs → cart.client-Ceeng8fB.mjs} +1 -1
  88. package/dist/client/{checkout-BibhwnTd.mjs → checkout-B0EKbeVv.mjs} +3 -3
  89. package/dist/client/{checkout.client-CE4jUi0G.mjs → checkout.client-DtPj3fYk.mjs} +1 -1
  90. package/dist/client/client.mjs +9465 -15
  91. package/dist/client/{context-BNAM7NsW.mjs → context-n6IZigd3.mjs} +8 -6
  92. package/dist/client/cta-CDeAwYoN.mjs +121 -0
  93. package/dist/client/{dateFormatting-QwBSo0hK.mjs → dateFormatting-BWPzdeZE.mjs} +1 -1
  94. package/dist/client/{demoPortalMagicLink-NwKJk6gn.mjs → demoPortalMagicLink-BdXu0fj-.mjs} +1 -1
  95. package/dist/client/{enhanceHeaderSection-D4zqEBDl.mjs → enhanceHeaderSection-VHfv8M6-.mjs} +3 -3
  96. package/dist/client/{event-details.client-jFyFjOIC.mjs → event-details.client-Cfr1_Cj4.mjs} +2 -2
  97. package/dist/client/{event-registration.client-BK_jVv3R.mjs → event-registration.client-BhygihpQ.mjs} +43 -17
  98. package/dist/client/{eventCalendar-DSkzejQh.mjs → eventCalendar-B4XCL9u6.mjs} +4 -4
  99. package/dist/client/{eventCombined-BG-BEaYh.mjs → eventCombined-DVjz4wdf.mjs} +4 -4
  100. package/dist/client/{eventDetails-BhIwXAKe.mjs → eventDetails-B0DA1Nw1.mjs} +2 -2
  101. package/dist/client/{eventListing-DQtyO1Xj.mjs → eventListing-2-xjn2nz.mjs} +4 -4
  102. package/dist/client/{eventRegistration-DRTz8X0M.mjs → eventRegistration-ng4iGo9O.mjs} +4 -4
  103. package/dist/client/{form-GXqjObPC.mjs → form-BeNQiZ2V.mjs} +3 -3
  104. package/dist/client/{form.client-CoKNba2e.mjs → form.client-BFdCKlp7.mjs} +7 -7
  105. package/dist/client/{form.parts-magB_epJ.mjs → form.parts-C7gLK3jh.mjs} +3 -3
  106. package/dist/client/{formatDate-BiloOyjS.mjs → formatDate-CWfelfMt.mjs} +1 -1
  107. package/dist/client/gifting/client.mjs +4 -5
  108. package/dist/client/{headerSection-BMQCPHT3.mjs → headerSection-CalNAShx.mjs} +2 -2
  109. package/dist/client/{mediaAssets-BX-vWwQc.mjs → mediaAssets-DpPauppt.mjs} +1 -1
  110. package/dist/client/{mediaContext-CdqGYlWl.mjs → mediaContext-BLo4NtjP.mjs} +25 -19
  111. package/dist/client/{newsletter-form.client-8orCez1z.mjs → newsletter-form.client-Dq7GHGXU.mjs} +9 -9
  112. package/dist/client/{newsletter-form.parts-D8NgHY_F.mjs → newsletter-form.parts-BSMDYQiS.mjs} +2 -2
  113. package/dist/client/{newsletterForm-BhBNsS3n.mjs → newsletterForm-snzZ4L6i.mjs} +3 -3
  114. package/dist/client/{noop-C2vZse15.mjs → noop-D-RG9eR3.mjs} +399 -169
  115. package/dist/client/portal/client.mjs +13 -14
  116. package/dist/client/{product-detail.client-CQ0k0fbH.mjs → product-detail.client-Gu0INDb7.mjs} +1 -1
  117. package/dist/client/{product-list.client-Xlr1P0x9.mjs → product-list.client-BmH40fNf.mjs} +1 -1
  118. package/dist/client/{productDetail-BsCao6X4.mjs → productDetail-DsPUmJ0z.mjs} +3 -3
  119. package/dist/client/{productList-Cc-PmbEe.mjs → productList-DjGrjOwD.mjs} +3 -3
  120. package/dist/client/{propsDecoder-DikkDJ9x.mjs → propsDecoder-kTVPMnfD.mjs} +4 -4
  121. package/dist/client/{registry.server-BpLZo3bC.mjs → registry.server-CKK_RXZo.mjs} +350 -424
  122. package/dist/client/rendering/client.mjs +29 -28
  123. package/dist/client/rendering/islands.mjs +1 -1
  124. package/dist/client/rendering.mjs +70 -8
  125. package/dist/client/{richText-coerce-WuMYrBm3.mjs → richText-coerce-BcjTX-7h.mjs} +1 -1
  126. package/dist/client/{routeIslandApiConfig-DNx6b07x.mjs → routeIslandApiConfig-CaXesATK.mjs} +1 -1
  127. package/dist/client/{shop-DyXtB5TD.mjs → shop-DLufMauE.mjs} +3 -3
  128. package/dist/client/{shop-commerce-xjWH7-Ym.mjs → shop-commerce-BxYYXLNK.mjs} +12 -12
  129. package/dist/client/{shop-commerce-store-CbBsS1kD.mjs → shop-commerce-store-Dp3Nl5YK.mjs} +1 -1
  130. package/dist/client/{shop.client-QOKqQPgK.mjs → shop.client-CBy9_alG.mjs} +13 -13
  131. package/dist/client/{shop.interactive-BQdm441g.mjs → shop.interactive-BM0NRsFQ.mjs} +265 -24
  132. package/dist/client/{shopShared-CyW6MU48.mjs → shopShared-lS23OQE-.mjs} +2 -2
  133. package/dist/client/site-styles-D8jEPGxA.mjs +3 -0
  134. package/dist/{preview-next/client/ThemedButton-g7NPrsGp.mjs → client/site-styles-DELkUk9s.mjs} +25654 -17259
  135. package/dist/client/spam-protection.mjs +2 -2
  136. package/dist/client/src-DjnxOjXG.mjs +217 -0
  137. package/dist/client/surfaceTransportMarker-BXepAVF6.mjs +152 -0
  138. package/dist/client/{timetableModel-BgdkhRuA.mjs → timetableModel-DzRWikCU.mjs} +157 -139
  139. package/dist/client/types-sF-IrGQr.mjs +633 -0
  140. package/dist/client/{useAvailableSlots-wmdo6uZ8.mjs → useAvailableSlots-C3LphWDX.mjs} +8 -5
  141. package/dist/client/{useBookingNowIso-CUExAee1.mjs → useBookingNowIso-Da-f9iHw.mjs} +1 -1
  142. package/dist/client/{useDiscountApply-BRM-OoTN.mjs → useDiscountApply-SLoWhcen.mjs} +3 -3
  143. package/dist/client/{useDiscountCodeUi-BEIvL31G.mjs → useDiscountCodeUi-D6a2BJij.mjs} +1 -1
  144. package/dist/client/{useEventPagination-Dk3g64we.mjs → useEventPagination-Ccr4TZlm.mjs} +12 -159
  145. package/dist/client/{view-BnaOmrap.mjs → view-8w4GA8rf.mjs} +4 -4
  146. package/dist/client/{view-vhKGFfC3.mjs → view-DAVEoe8A.mjs} +310 -247
  147. package/dist/client/{wizardSteps-xqU4q63H.mjs → wizardSteps-DNpajrAH.mjs} +495 -173
  148. package/dist/preview-next/before-render.mjs +4 -141
  149. package/dist/preview-next/client/ArrangementLookControls-DY5TzhEa.mjs +31197 -0
  150. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-43wIAWr4.mjs → EventEmbeddedCheckoutStep-C_h1cMYm.mjs} +33 -4
  151. package/dist/preview-next/client/{LocationPickerEnvironment-QtSG2Bl-.mjs → LocationPickerEnvironment-D56RD3e_.mjs} +1 -1
  152. package/dist/preview-next/client/{MapLibreEditMap-B-rohNcG.mjs → MapLibreEditMap-DFnyCckr.mjs} +2 -2
  153. package/dist/preview-next/client/PreviewEditorSidebar-DdnhmdFO.mjs +37049 -0
  154. package/dist/preview-next/client/PreviewEditorUI-C7ZmYE33.mjs +1189 -0
  155. package/dist/preview-next/client/PreviewShell-DnO38NaL.mjs +4707 -0
  156. package/dist/preview-next/client/SdkPreviewModeRuntime-D2OtoRMB.mjs +4258 -0
  157. package/dist/preview-next/client/SiteChromeCustomizeButton-eIu2RejJ.mjs +71144 -0
  158. package/dist/preview-next/client/ThemedButton-C0dgGJ5k.mjs +2006 -0
  159. package/dist/preview-next/client/{lucide-react-CA9cpo0P.mjs → lucide-react-CPBCf6QT.mjs} +15 -2
  160. package/dist/preview-next/client/previewAssistantSlot-Bp1AlAxx.mjs +110560 -0
  161. package/dist/preview-next/client/previewChromeSurface-D2cREDJ5.mjs +190 -0
  162. package/dist/preview-next/client/runtime.mjs +3 -3
  163. package/dist/preview-next/client/sdk-runtime-DK0PUhLL.mjs +5 -0
  164. package/dist/preview-next/client/useAutosaveStatus--Pw8vnef.mjs +138 -0
  165. package/dist/preview-next/client/useBlockCustomizeControls-C1Rl73N4.mjs +2724 -0
  166. package/dist/preview-next/client/useOpenBlockForSetup-CL3842FM.mjs +28 -0
  167. package/dist/preview-next/keepAlive.mjs +27 -4
  168. package/dist/preview-next/middleware.mjs +2 -2
  169. package/dist/preview-next/{route-contract-D5tHZEz5.mjs → route-contract-Bq7SUX3K.mjs} +143 -126
  170. package/dist/preview-next/{session-P1R_ajT7.mjs → session-DU6zpYUQ.mjs} +1 -1
  171. package/dist/preview-next/session.mjs +1 -1
  172. package/dist/server/{Block.shared-Iy7g11iP.mjs → Block.shared-wXr7Iwhs.mjs} +7 -4
  173. package/dist/server/{src-cbbK3Bho.mjs → ThemeScopeCore-BI2mld9R.mjs} +1153 -2523
  174. package/dist/server/accessibleSurfaces-CuN8U_iU.mjs +2102 -0
  175. package/dist/server/{bindings-BVJGgUT0.mjs → bindings-DjdUq9FR.mjs} +2 -3
  176. package/dist/server/{publicProducts-D3Fc5TKk.mjs → client-07UeMDzA.mjs} +2492 -357
  177. package/dist/server/config-validation.mjs +1 -1
  178. package/dist/server/config.mjs +33 -2
  179. package/dist/server/data/dataLoaderContext.mjs +2 -0
  180. package/dist/server/data/resolveBlockData.mjs +2 -0
  181. package/dist/server/data/types.mjs +1 -0
  182. package/dist/server/dataLoaderContext-B3fXA54R.mjs +47 -0
  183. package/dist/server/identity-Bn9OQiT1.mjs +6 -0
  184. package/dist/server/index.mjs +3 -3
  185. package/dist/server/{loadContent-BuintpdO.mjs → loadContent-ClpaSlBb.mjs} +6 -5
  186. package/dist/server/{loadPage-Dk4wea8M.mjs → loadPage-BwtVqpaA.mjs} +4 -2
  187. package/dist/server/manifest.mjs +1 -1
  188. package/dist/server/media-DnlczCMA.mjs +231 -0
  189. package/dist/server/mode-Cv_TG9gP.mjs +63 -0
  190. package/dist/server/next/middleware.mjs +1 -1
  191. package/dist/server/next/revalidate.mjs +1 -1
  192. package/dist/server/next.mjs +13 -13
  193. package/dist/server/opaqueSurface-3YSDPtDe.mjs +54 -0
  194. package/dist/server/{overrideResolution-BDiQWM7D.mjs → overrideResolution-Du_w3LY4.mjs} +2 -1
  195. package/dist/server/overrides-CD4d-1w7.mjs +177 -0
  196. package/dist/server/page-converter.mjs +243 -91
  197. package/dist/server/pageRenderPlan-BShULdc2.mjs +4055 -0
  198. package/dist/server/{themeAdmission-BdY8lP-K.mjs → pageRuntimeSupport-C4Dh5-mB.mjs} +13 -28
  199. package/dist/server/{overrides-DVemf-GV.mjs → pageShared-HdKFBpaX.mjs} +3594 -1726
  200. package/dist/server/parseThemeForPersistence-CJMrEkze.mjs +52 -0
  201. package/dist/server/{prebuild-DubLNgRH.mjs → prebuild-Cl-bkaMA.mjs} +1 -1
  202. package/dist/server/prebuild.mjs +1 -1
  203. package/dist/server/prefetchBlockData-C4yUmz-r.mjs +786 -0
  204. package/dist/server/publicProducts-W9hDRwjz.mjs +64 -0
  205. package/dist/server/{registry-zjd1P2Dl.mjs → registry-TFPJdGQi.mjs} +20901 -792
  206. package/dist/server/rendering/components/pageShared.mjs +2 -0
  207. package/dist/server/rendering/helpers/loadPage.mjs +2 -0
  208. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +2 -0
  209. package/dist/server/rendering/server.mjs +5 -4
  210. package/dist/server/rendering/themeAdmission.mjs +2 -0
  211. package/dist/server/rendering.mjs +11 -10
  212. package/dist/server/repeaterFields-MIz7r1ez.mjs +9 -0
  213. package/dist/server/{resolveBlockData-CZJ--nH6.mjs → resolveBlockData-OHlOXlOE.mjs} +6 -48
  214. package/dist/server/resolveButtonColourStates-lry2ORwX.mjs +2672 -0
  215. package/dist/server/{richTextSchema-YYc85FX4.mjs → richTextSchema-Euhuj-7V.mjs} +26 -1
  216. package/dist/server/routing.mjs +1 -1
  217. package/dist/server/schema-C2PqHrMo.mjs +2523 -0
  218. package/dist/server/server.mjs +3 -3
  219. package/dist/server/theme-bridge.mjs +1031 -1
  220. package/dist/server/theme.mjs +2 -1
  221. package/dist/server/themeAdmission-DGSAlFUK.mjs +18 -0
  222. package/dist/server/{three-pass-converter-Chnb1XD-.mjs → three-pass-converter-_j2UE2tR.mjs} +1 -1
  223. package/dist/server/validation-CDd6m8Ry.mjs +140 -0
  224. package/dist/server/{validation-CGH-Xs4E.mjs → validation-DIBFZeMB.mjs} +419 -3
  225. package/dist/server/{version-DoOG6F13.mjs → version-DZWZM1H6.mjs} +1 -1
  226. package/dist/styles/index.css +924 -10
  227. package/package.json +39 -1
  228. package/dist/_dts/previewCompiler-BVVgDSdq.d.ts +0 -1
  229. package/dist/client/cta-ChiN1Vgg.mjs +0 -80
  230. package/dist/client/purchase-BMsWpx8y.mjs +0 -894
  231. package/dist/client/schema-DMUkBtIO.mjs +0 -15915
  232. package/dist/client/site-styles-BLHYJ8S7.mjs +0 -12339
  233. package/dist/client/src-VIsPY-kw.mjs +0 -62
  234. package/dist/preview-next/client/PreviewEditorSidebar-C3AQVxQt.mjs +0 -5441
  235. package/dist/preview-next/client/PreviewEditorUI-C-1zDCR_.mjs +0 -756
  236. package/dist/preview-next/client/SdkPreviewModeRuntime-B47yHFL0.mjs +0 -9130
  237. package/dist/preview-next/client/SdkPreviewModeRuntime-C6Rhm2NQ.mjs +0 -3
  238. package/dist/preview-next/client/previewAuthStore-By_zfrS5.mjs +0 -212195
  239. package/dist/preview-next/client/previewChromeSurface-Cjwxv90x.mjs +0 -85
  240. package/dist/preview-next/client/result-BjJUoxUF.mjs +0 -16
  241. package/dist/preview-next/client/sdk-runtime-BG2HYvQj.mjs +0 -4
  242. package/dist/preview-next/client/siteStyleAccess-BiSyYyyr.mjs +0 -14178
  243. package/dist/preview-next/client/spinner-DnWpeDp2.mjs +0 -67
  244. package/dist/preview-next/refresh-contract-uQ6BXgLJ.mjs +0 -25
  245. package/dist/server/bindings-Dgt_0goJ.mjs +0 -17
  246. package/dist/server/client-CiKaE8ms.mjs +0 -2330
  247. package/dist/server/effectiveNavLinkStyle-EDSdd_oK.mjs +0 -11574
  248. package/dist/server/loadPage-BwjncpJf.mjs +0 -2
  249. package/dist/server/prefetchBlockData-Bnbwoe5n.mjs +0 -4156
  250. package/dist/server/schema-BlTWmTSl.mjs +0 -16142
  251. package/dist/server/site-styles-yHytcXIB.mjs +0 -768
  252. package/dist/server/siteChromeOverlayClearance-D0uCNZ7E.mjs +0 -802
@@ -1,5 +1,7 @@
1
- import { On as parseSurfaceTree, gn as parseSiteId } from "./schema-BlTWmTSl.mjs";
2
- import "./site-styles-yHytcXIB.mjs";
1
+ import { n as parseSurfaceTree } from "./accessibleSurfaces-CuN8U_iU.mjs";
2
+ import { t as parseSiteId } from "./identity-Bn9OQiT1.mjs";
3
+ import { i as isSupportedLoaderEndpoint, t as encodePublicProductCategorySelector } from "./publicProducts-W9hDRwjz.mjs";
4
+ import { t as SDK_VERSION } from "./version-DZWZM1H6.mjs";
3
5
  import { z } from "zod";
4
6
  const PUBLIC_CONTENT_FRESHNESS_SECONDS = 3600;
5
7
  function availability(transport) {
@@ -63,29 +65,53 @@ const committedWriteProofSchema = z.object({
63
65
  resultingRevision: z.number().int().nonnegative()
64
66
  });
65
67
  //#endregion
66
- //#region ../blocks/src/system/data/loaderEndpoints.ts
67
- const SUPPORTED_LOADER_ENDPOINTS = [
68
- "listPublishedEntries",
69
- "getPublishedEntryPreview",
70
- "listPublicEvents",
71
- "listPublicEventCalendarWindow",
72
- "listPublicRecurringSchedule",
73
- "getPublicEventDetails",
74
- "listPublicRouteCandidates",
75
- "listPublicTeamMembers",
76
- "listPublicProducts",
77
- "listPublicPasses",
78
- "listPublicMemberships",
79
- "getPublicFormById",
80
- "getPublicBookingServices",
81
- "getPublicWeeklySlotAvailability"
82
- ];
83
- function isSupportedLoaderEndpoint(endpoint) {
84
- return SUPPORTED_LOADER_ENDPOINTS.includes(endpoint);
85
- }
86
- //#endregion
87
68
  //#region ../api/src/pageJournalEndpoints.ts
88
69
  const PAGE_JOURNAL_ENDPOINT_DEFINITIONS = {
70
+ discardAssistantPage: {
71
+ path: "/sites/{siteId}/pages/{pageId}/assistant-discard",
72
+ method: "POST",
73
+ auth: "user",
74
+ responseKind: "json",
75
+ editLease: "unleased-editor",
76
+ errors: [
77
+ "validation:invalid_input",
78
+ "auth:forbidden",
79
+ "server:internal_error"
80
+ ]
81
+ },
82
+ constructAssistantPage: {
83
+ path: "/sites/{siteId}/pages/assistant",
84
+ method: "POST",
85
+ auth: "user",
86
+ responseKind: "json",
87
+ editLease: "unleased-editor",
88
+ errors: [
89
+ "validation:invalid_input",
90
+ "auth:forbidden",
91
+ "resource:conflict",
92
+ "server:internal_error"
93
+ ]
94
+ },
95
+ commitPageChangeBatch: {
96
+ path: "/sites/{siteId}/pages/{pageId}/journal",
97
+ method: "PUT",
98
+ auth: "user",
99
+ responseKind: "json",
100
+ editLease: "managed",
101
+ errors: [
102
+ "validation:invalid_input",
103
+ "resource:not_found",
104
+ "resource:conflict",
105
+ "server:internal_error"
106
+ ]
107
+ },
108
+ getPagePublishReadinessFacts: {
109
+ path: "/sites/{siteId}/pages/readiness-facts",
110
+ method: "POST",
111
+ auth: "user",
112
+ responseKind: "json",
113
+ errors: ["validation:invalid_input", "server:internal_error"]
114
+ },
89
115
  replayThemeJournalChange: {
90
116
  path: "/sites/{siteId}/theme/journal",
91
117
  method: "POST",
@@ -1902,48 +1928,6 @@ const NEWSLETTER_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
1902
1928
  auth: "user",
1903
1929
  responseKind: "json"
1904
1930
  },
1905
- listNewsletterTemplates: {
1906
- path: "/sites/{siteId}/newsletter/templates",
1907
- method: "GET",
1908
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1909
- auth: "user",
1910
- responseKind: "json"
1911
- },
1912
- createNewsletterTemplate: {
1913
- path: "/sites/{siteId}/newsletter/templates",
1914
- method: "POST",
1915
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1916
- auth: "user",
1917
- responseKind: "json"
1918
- },
1919
- getNewsletterTemplate: {
1920
- path: "/sites/{siteId}/newsletter/templates/{templateId}",
1921
- method: "GET",
1922
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1923
- auth: "user",
1924
- responseKind: "json"
1925
- },
1926
- updateNewsletterTemplate: {
1927
- path: "/sites/{siteId}/newsletter/templates/{templateId}",
1928
- method: "PATCH",
1929
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1930
- auth: "user",
1931
- responseKind: "json"
1932
- },
1933
- deleteNewsletterTemplate: {
1934
- path: "/sites/{siteId}/newsletter/templates/{templateId}",
1935
- method: "DELETE",
1936
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1937
- auth: "user",
1938
- responseKind: "json"
1939
- },
1940
- previewNewsletterTemplate: {
1941
- path: "/sites/{siteId}/newsletter/templates/{templateId}/preview",
1942
- method: "POST",
1943
- tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1944
- auth: "user",
1945
- responseKind: "json"
1946
- },
1947
1931
  listNewsletterCampaigns: {
1948
1932
  path: "/sites/{siteId}/newsletter/campaigns",
1949
1933
  method: "GET",
@@ -2001,6 +1985,38 @@ const NEWSLETTER_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
2001
1985
  responseKind: "json",
2002
1986
  demoMutation: DEMO_MUTATION_BLOCKED_HIDDEN
2003
1987
  },
1988
+ listNewsletterWebsitePicker: {
1989
+ path: "/sites/{siteId}/newsletter/website-picker",
1990
+ method: "GET",
1991
+ auth: "user",
1992
+ responseKind: "json",
1993
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
1994
+ errors: []
1995
+ },
1996
+ renderNewsletterCampaignDraft: {
1997
+ path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/render-draft",
1998
+ method: "POST",
1999
+ auth: "user",
2000
+ responseKind: "json",
2001
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
2002
+ errors: []
2003
+ },
2004
+ reviewNewsletterCampaign: {
2005
+ path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/review",
2006
+ method: "POST",
2007
+ auth: "user",
2008
+ responseKind: "json",
2009
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
2010
+ errors: []
2011
+ },
2012
+ duplicateNewsletterCampaign: {
2013
+ path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/duplicate",
2014
+ method: "POST",
2015
+ auth: "user",
2016
+ responseKind: "json",
2017
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
2018
+ errors: []
2019
+ },
2004
2020
  scheduleNewsletterCampaign: {
2005
2021
  path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/schedule",
2006
2022
  method: "POST",
@@ -2168,6 +2184,7 @@ const SDK_APPOINTMENT_SERVICE_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
2168
2184
  errors: [
2169
2185
  "validation:invalid_input",
2170
2186
  "resource:not_found",
2187
+ "resource:conflict",
2171
2188
  "server:internal_error"
2172
2189
  ]
2173
2190
  },
@@ -2186,6 +2203,7 @@ const SDK_APPOINTMENT_SERVICE_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
2186
2203
  errors: [
2187
2204
  "validation:invalid_input",
2188
2205
  "resource:not_found",
2206
+ "resource:conflict",
2189
2207
  "server:internal_error"
2190
2208
  ]
2191
2209
  }
@@ -2554,29 +2572,6 @@ const EVENT_MANAGEMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
2554
2572
  "server:internal_error"
2555
2573
  ]
2556
2574
  },
2557
- /**
2558
- * The web address of an event's own page. A course page belongs to the
2559
- * event itself, so its address is written here rather than through a run.
2560
- */
2561
- updateEventAddress: {
2562
- editLease: "managed",
2563
- path: "/sites/{siteId}/bookings/events/{eventId}/address",
2564
- method: "PATCH",
2565
- tags: [
2566
- "site-{siteId}",
2567
- "event-series-{siteId}",
2568
- TAG_TEMPLATES.siteRoutableContent,
2569
- TAG_TEMPLATES.siteRedirects
2570
- ],
2571
- auth: "user",
2572
- responseKind: "json",
2573
- errors: [
2574
- "validation:invalid_input",
2575
- "resource:not_found",
2576
- "resource:conflict",
2577
- "server:internal_error"
2578
- ]
2579
- },
2580
2575
  createWholeSeriesRun: {
2581
2576
  path: "/sites/{siteId}/bookings/events/{eventId}/runs",
2582
2577
  method: "POST",
@@ -3631,7 +3626,7 @@ z.object({
3631
3626
  ageMs: z.number().int().min(0).max(CLIENT_ERROR_REPORT_LIMITS.navigationAgeMs)
3632
3627
  }).strict().nullable().optional()
3633
3628
  }).strict();
3634
- const API_ENDPOINTS = {
3629
+ const API_ENDPOINTS$1 = {
3635
3630
  ...PAGE_JOURNAL_ENDPOINT_DEFINITIONS,
3636
3631
  ...PREVIEW_AUTH_ENDPOINT_DEFINITIONS,
3637
3632
  ...SITE_LIFECYCLE_ENDPOINT_DEFINITIONS,
@@ -3653,20 +3648,22 @@ const API_ENDPOINTS = {
3653
3648
  auth: "user",
3654
3649
  responseKind: "json"
3655
3650
  },
3656
- aiPlaygroundProposeMulti: {
3657
- path: "/sites/{siteId}/ai/playground/propose-multi",
3651
+ assistantConversation: {
3652
+ path: "/assistant/conversation",
3658
3653
  method: "POST",
3659
3654
  auth: "user",
3660
- responseKind: "stream"
3655
+ responseKind: "json",
3656
+ errors: []
3661
3657
  },
3662
- aiPlaygroundProposeMultiGet: {
3663
- path: "/sites/{siteId}/ai/playground/propose-multi",
3664
- method: "GET",
3658
+ assistantNewConversation: {
3659
+ path: "/assistant/conversation/new",
3660
+ method: "POST",
3665
3661
  auth: "user",
3666
- responseKind: "stream"
3662
+ responseKind: "json",
3663
+ errors: []
3667
3664
  },
3668
- assistantSuggestions: {
3669
- path: "/assistant/suggestions",
3665
+ assistantOutcome: {
3666
+ path: "/assistant/outcome",
3670
3667
  method: "POST",
3671
3668
  auth: "user",
3672
3669
  responseKind: "json",
@@ -3693,42 +3690,6 @@ const API_ENDPOINTS = {
3693
3690
  responseKind: "stream",
3694
3691
  errors: []
3695
3692
  },
3696
- aiPlaygroundPageConvert: {
3697
- path: "/sites/{siteId}/ai/playground/page-convert",
3698
- method: "POST",
3699
- auth: "user",
3700
- responseKind: "json"
3701
- },
3702
- aiPlaygroundPageConvertJobsCreate: {
3703
- path: "/sites/{siteId}/ai/playground/page-convert/jobs",
3704
- method: "POST",
3705
- auth: "user",
3706
- responseKind: "json"
3707
- },
3708
- aiPlaygroundPageConvertJobsList: {
3709
- path: "/sites/{siteId}/ai/playground/page-convert/jobs",
3710
- method: "GET",
3711
- auth: "user",
3712
- responseKind: "json"
3713
- },
3714
- aiPlaygroundPageConvertJobGet: {
3715
- path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}",
3716
- method: "GET",
3717
- auth: "user",
3718
- responseKind: "json"
3719
- },
3720
- aiPlaygroundPageConvertJobRun: {
3721
- path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}/run",
3722
- method: "POST",
3723
- auth: "user",
3724
- responseKind: "json"
3725
- },
3726
- aiPlaygroundPageConvertJobEvents: {
3727
- path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}/events",
3728
- method: "GET",
3729
- auth: "user",
3730
- responseKind: "json"
3731
- },
3732
3693
  aiGenerateSite: {
3733
3694
  path: "/sites/{siteId}/ai/generate",
3734
3695
  method: "POST",
@@ -4378,6 +4339,7 @@ const API_ENDPOINTS = {
4378
4339
  responseKind: "json"
4379
4340
  },
4380
4341
  createContentEntry: {
4342
+ editLease: "unleased-editor",
4381
4343
  path: "/sites/{siteId}/content/{type}",
4382
4344
  method: "POST",
4383
4345
  tags: ["site-{siteId}", "content-{siteId}-{type}"],
@@ -4510,6 +4472,32 @@ const API_ENDPOINTS = {
4510
4472
  auth: "user",
4511
4473
  responseKind: "json"
4512
4474
  },
4475
+ getRouteAddress: {
4476
+ path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
4477
+ method: "GET",
4478
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteRoutableContent],
4479
+ auth: "user",
4480
+ responseKind: "json",
4481
+ errors: ["resource:not_found", "resource:conflict"]
4482
+ },
4483
+ changeRouteAddress: {
4484
+ editLease: "managed",
4485
+ path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
4486
+ method: "PATCH",
4487
+ tags: [
4488
+ TAG_TEMPLATES.site,
4489
+ TAG_TEMPLATES.siteRoutableContent,
4490
+ TAG_TEMPLATES.siteRedirects
4491
+ ],
4492
+ auth: "user",
4493
+ responseKind: "json",
4494
+ errors: [
4495
+ "validation:invalid_input",
4496
+ "resource:not_found",
4497
+ "resource:conflict",
4498
+ "server:internal_error"
4499
+ ]
4500
+ },
4513
4501
  updateRouteMetadata: {
4514
4502
  editLease: "managed",
4515
4503
  path: "/sites/{siteId}/routes/{routeId}/metadata",
@@ -4700,6 +4688,30 @@ const API_ENDPOINTS = {
4700
4688
  auth: "user",
4701
4689
  responseKind: "json"
4702
4690
  },
4691
+ previewWebsiteOperation: {
4692
+ path: "/sites/{siteId}/website/preview",
4693
+ method: "POST",
4694
+ auth: "user",
4695
+ responseKind: "json",
4696
+ errors: [
4697
+ "validation:invalid_input",
4698
+ "auth:insufficient_permissions",
4699
+ "server:internal_error"
4700
+ ]
4701
+ },
4702
+ confirmWebsiteOperation: {
4703
+ editLease: "unleased-editor",
4704
+ path: "/sites/{siteId}/website/confirm",
4705
+ method: "POST",
4706
+ auth: "user",
4707
+ responseKind: "json",
4708
+ tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteSettings],
4709
+ errors: [
4710
+ "validation:invalid_input",
4711
+ "auth:insufficient_permissions",
4712
+ "server:internal_error"
4713
+ ]
4714
+ },
4703
4715
  previewSiteBrandingOperation: {
4704
4716
  path: "/sites/{siteId}/settings/general/preview",
4705
4717
  method: "POST",
@@ -4745,6 +4757,7 @@ const API_ENDPOINTS = {
4745
4757
  errors: [
4746
4758
  "validation:invalid_input",
4747
4759
  "resource:not_found",
4760
+ "resource:conflict",
4748
4761
  "auth:forbidden",
4749
4762
  "server:internal_error"
4750
4763
  ]
@@ -6068,14 +6081,6 @@ const API_ENDPOINTS = {
6068
6081
  auth: "user",
6069
6082
  responseKind: "json"
6070
6083
  },
6071
- getPageDesignEditorState: {
6072
- path: "/sites/{siteId}/pages/{pageId}/design",
6073
- method: "GET",
6074
- tags: [TAG_TEMPLATES.siteRoutableContent, TAG_TEMPLATES.pageById],
6075
- auth: "user",
6076
- responseKind: "json",
6077
- errors: ["resource:not_found", "server:internal_error"]
6078
- },
6079
6084
  savePageDesignState: {
6080
6085
  editLease: "managed",
6081
6086
  path: "/sites/{siteId}/pages/{pageId}/design-state",
@@ -7853,14 +7858,6 @@ const API_ENDPOINTS = {
7853
7858
  auth: "user",
7854
7859
  responseKind: "json"
7855
7860
  },
7856
- aiPlaygroundApply: {
7857
- editLease: "unleased-editor",
7858
- path: "/sites/{siteId}/ai/playground/apply",
7859
- method: "POST",
7860
- tags: ["site-{siteId}"],
7861
- auth: "user",
7862
- responseKind: "json"
7863
- },
7864
7861
  billingStatus: {
7865
7862
  path: "/billing/status",
7866
7863
  method: "GET",
@@ -8813,6 +8810,7 @@ const API_ENDPOINTS = {
8813
8810
  responseKind: "json",
8814
8811
  errors: [
8815
8812
  "resource:not_found",
8813
+ "resource:conflict",
8816
8814
  "validation:invalid_input",
8817
8815
  "server:internal_error"
8818
8816
  ]
@@ -9017,142 +9015,6 @@ var ApiRequestError = class extends Error {
9017
9015
  }
9018
9016
  };
9019
9017
  //#endregion
9020
- //#region ../surfaces/src/index.ts
9021
- const SURFACE_IDS = ["core", "macadamia"];
9022
- /**
9023
- * Deployment tier of a surface root host: `local` = the dev-host entry
9024
- * (e.g. `localhost`, `macadamia.localhost`); `prod` = the public production
9025
- * entry; `demo` = the shared Demo deployment. Used to pair
9026
- * surfaces by tier when rewriting hosts so a dev request stays on the
9027
- * dev tier of the target surface and prod stays on prod.
9028
- */
9029
- const SURFACE_TIERS = [
9030
- "local",
9031
- "demo",
9032
- "prod"
9033
- ];
9034
- /**
9035
- * Root hosts for each surface, keyed by deployment tier. The tier-keyed shape
9036
- * makes it impossible to mis-order entries: callers like
9037
- * `buildSurfaceAwareDashboardOriginForSurfaceId` look up by tier directly
9038
- * rather than relying on positional alignment between arrays.
9039
- */
9040
- const SURFACE_ROOT_HOSTS = {
9041
- core: {
9042
- local: "localhost",
9043
- demo: "demo.macadamia.studio",
9044
- prod: "riverbankcms.com"
9045
- },
9046
- macadamia: {
9047
- local: "macadamia.localhost",
9048
- demo: "demo.macadamia.studio",
9049
- prod: "macadamia.studio"
9050
- }
9051
- };
9052
- const SURFACE_SITE_ROOT_HOSTS = {
9053
- core: {
9054
- local: "localhost",
9055
- demo: "demo.macadamia.studio",
9056
- prod: "riverbanksites.com"
9057
- },
9058
- macadamia: {
9059
- local: "macadamia.localhost",
9060
- demo: "demo.macadamia.studio",
9061
- prod: "macadamia.studio"
9062
- }
9063
- };
9064
- const SURFACE_SITE_ROOT_HOST_ALIASES = { core: { prod: ["preview.riverbanksites.com"] } };
9065
- function surfaceHostTableValues(table) {
9066
- return Object.values(table).flatMap((byTier) => Object.values(byTier).flat());
9067
- }
9068
- function siteSlugLabelUnderRoot(host, siteRootHost) {
9069
- if (!host.endsWith(`.${siteRootHost}`)) return [];
9070
- return host.slice(0, host.length - siteRootHost.length - 1).split(".").slice(-1);
9071
- }
9072
- function deriveSurfaceOwnedSiteSlugs() {
9073
- const siteRootHosts = [...surfaceHostTableValues(SURFACE_SITE_ROOT_HOSTS), ...surfaceHostTableValues(SURFACE_SITE_ROOT_HOST_ALIASES)];
9074
- const labels = [
9075
- ...surfaceHostTableValues(SURFACE_ROOT_HOSTS),
9076
- ...siteRootHosts,
9077
- ...SURFACE_IDS.map((surfaceId) => new URL(resolveSurfaceMarketingCanonicalOrigin(surfaceId)).hostname)
9078
- ].flatMap((host) => siteRootHosts.flatMap((root) => siteSlugLabelUnderRoot(host, root)));
9079
- return [.../* @__PURE__ */ new Set([...labels, "draft-preview"])].sort();
9080
- }
9081
- deriveSurfaceOwnedSiteSlugs();
9082
- const HOST_CANDIDATES = [...SURFACE_IDS.flatMap((surfaceId) => SURFACE_TIERS.flatMap((tier) => [
9083
- {
9084
- surfaceId,
9085
- tier,
9086
- role: "dashboard",
9087
- surfaceRootHost: SURFACE_ROOT_HOSTS[surfaceId][tier]
9088
- },
9089
- {
9090
- surfaceId,
9091
- tier,
9092
- role: "site",
9093
- surfaceRootHost: SURFACE_SITE_ROOT_HOSTS[surfaceId][tier]
9094
- },
9095
- ...(SURFACE_SITE_ROOT_HOST_ALIASES[surfaceId]?.[tier] ?? []).map((surfaceRootHost) => ({
9096
- surfaceId,
9097
- tier,
9098
- role: "site",
9099
- surfaceRootHost
9100
- }))
9101
- ])), ...SURFACE_IDS.map((surfaceId) => ({
9102
- surfaceId,
9103
- tier: "prod",
9104
- role: "dashboard",
9105
- surfaceRootHost: new URL(resolveSurfaceMarketingCanonicalOrigin(surfaceId)).hostname
9106
- }))];
9107
- function siteContextForCandidates(candidates) {
9108
- const sites = candidates.filter((candidate) => candidate.role === "site");
9109
- const first = sites[0];
9110
- if (first === void 0) return null;
9111
- const surfaceIds = [...new Set(sites.map((candidate) => candidate.surfaceId))];
9112
- const base = {
9113
- surfaceRootHost: first.surfaceRootHost,
9114
- tier: first.tier
9115
- };
9116
- return surfaceIds.length > 1 ? {
9117
- ...base,
9118
- kind: "shared",
9119
- surfaceIds
9120
- } : {
9121
- ...base,
9122
- kind: "surface",
9123
- surfaceId: first.surfaceId
9124
- };
9125
- }
9126
- function dashboardContextForCandidates(candidates) {
9127
- const dashboard = candidates.find((candidate) => candidate.role === "dashboard" && (candidate.tier !== "demo" || candidate.surfaceId === "macadamia"));
9128
- return dashboard !== void 0 ? {
9129
- surfaceId: dashboard.surfaceId,
9130
- surfaceRootHost: dashboard.surfaceRootHost,
9131
- tier: dashboard.tier
9132
- } : null;
9133
- }
9134
- [...new Set(HOST_CANDIDATES.map((candidate) => candidate.surfaceRootHost))].map((surfaceRootHost) => {
9135
- const candidates = HOST_CANDIDATES.filter((candidate) => candidate.surfaceRootHost === surfaceRootHost);
9136
- return {
9137
- surfaceRootHost,
9138
- site: siteContextForCandidates(candidates),
9139
- dashboard: dashboardContextForCandidates(candidates)
9140
- };
9141
- }).sort((a, b) => b.surfaceRootHost.length - a.surfaceRootHost.length);
9142
- function buildSurfaceDashboardHostname(input) {
9143
- return SURFACE_ROOT_HOSTS[input.surfaceId][input.tier];
9144
- }
9145
- function buildSurfaceDashboardOrigin(input) {
9146
- const host = buildSurfaceDashboardHostname(input);
9147
- return `${input.protocol ?? (input.tier === "local" ? "http" : "https")}://${host}${input.port != null && input.port.length > 0 ? `:${input.port}` : ""}`;
9148
- }
9149
- function resolveSurfaceMarketingCanonicalOrigin(surfaceId) {
9150
- return surfaceId === "macadamia" ? "https://www.macadamia.studio" : buildSurfaceDashboardOrigin({
9151
- surfaceId,
9152
- tier: "prod"
9153
- });
9154
- }
9155
- //#endregion
9156
9018
  //#region ../api/src/url.ts
9157
9019
  function looksLikeLocalAuthority(authority) {
9158
9020
  const normalized = authority.toLowerCase();
@@ -9210,7 +9072,7 @@ z.uuid();
9210
9072
  /** One client command owns this id; network retries retain the same header. */
9211
9073
  function commandHeaders(endpoint, headers, operationId) {
9212
9074
  const result = new Headers(headers);
9213
- if (API_ENDPOINTS[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
9075
+ if (API_ENDPOINTS$1[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
9214
9076
  return result;
9215
9077
  }
9216
9078
  //#endregion
@@ -9259,6 +9121,7 @@ z.enum([
9259
9121
  "invalid-document",
9260
9122
  "invalid-history",
9261
9123
  "path-unavailable",
9124
+ "homepage-publication-required",
9262
9125
  "invalid-page-version",
9263
9126
  "invalid-block-reference",
9264
9127
  "invalid-content-reference",
@@ -9286,11 +9149,10 @@ function getRevalidateTag() {
9286
9149
  }
9287
9150
  return revalidateTag;
9288
9151
  }
9289
- let sdkVersion;
9290
9152
  /**
9291
9153
  * Generate a UUID, with fallback for environments where crypto.randomUUID isn't available.
9292
9154
  */
9293
- function generateRequestId() {
9155
+ function generateRequestId$1() {
9294
9156
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
9295
9157
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
9296
9158
  const r = Math.random() * 16 | 0;
@@ -9298,13 +9160,6 @@ function generateRequestId() {
9298
9160
  });
9299
9161
  }
9300
9162
  /**
9301
- * Set the SDK version to be included in API request headers
9302
- * Called by the SDK during initialization
9303
- */
9304
- function setSdkVersion(version) {
9305
- sdkVersion = version;
9306
- }
9307
- /**
9308
9163
  * Parse the Retry-After header value to milliseconds.
9309
9164
  * The header can be either:
9310
9165
  * - A number of seconds (e.g., "120")
@@ -9322,8 +9177,8 @@ function parseRetryAfterHeader(headerValue) {
9322
9177
  return delayMs > 0 ? delayMs : void 0;
9323
9178
  }
9324
9179
  }
9325
- function buildEndpointURL(baseURL, endpoint) {
9326
- return baseURL + API_ENDPOINTS[endpoint].path;
9180
+ function buildEndpointURL$1(baseURL, endpoint) {
9181
+ return baseURL + API_ENDPOINTS$1[endpoint].path;
9327
9182
  }
9328
9183
  function isFormDataBody(value) {
9329
9184
  return typeof FormData !== "undefined" && value instanceof FormData;
@@ -9411,7 +9266,7 @@ function buildSuccessEnvelope(data, requestId) {
9411
9266
  success: true,
9412
9267
  data,
9413
9268
  meta: {
9414
- requestId: requestId ?? generateRequestId(),
9269
+ requestId: requestId ?? generateRequestId$1(),
9415
9270
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9416
9271
  apiVersion: "2025-01-01"
9417
9272
  }
@@ -9426,7 +9281,7 @@ function buildErrorEnvelope(code, message, status, requestId) {
9426
9281
  error: {
9427
9282
  code,
9428
9283
  message,
9429
- requestId: requestId ?? generateRequestId(),
9284
+ requestId: requestId ?? generateRequestId$1(),
9430
9285
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9431
9286
  status
9432
9287
  }
@@ -9479,7 +9334,7 @@ async function parseSuccessResponse(endpoint, response, config) {
9479
9334
  default: return buildSuccessEnvelope(void 0, requestId);
9480
9335
  }
9481
9336
  }
9482
- function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
9337
+ function createRawCMSClient(getHeaders = () => ({}), baseUrl, { sdkVersion } = {}) {
9483
9338
  return ({ endpoint, body, params, options = {} }) => {
9484
9339
  const plan = buildApiRequestPlan({
9485
9340
  endpoint,
@@ -9487,7 +9342,7 @@ function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
9487
9342
  params,
9488
9343
  options: {
9489
9344
  ...options,
9490
- headers: commandHeaders(endpoint, options.headers, generateRequestId())
9345
+ headers: commandHeaders(endpoint, options.headers, generateRequestId$1())
9491
9346
  },
9492
9347
  headers: getHeaders(),
9493
9348
  baseUrl: normalizeCmsApiBaseUrl(baseUrl ?? resolveApiBaseUrl()),
@@ -9507,8 +9362,8 @@ function surfaceTransportCapability(endpoint) {
9507
9362
  function buildApiRequestPlan(input) {
9508
9363
  const { endpoint, body, params, headers = {}, baseUrl } = input;
9509
9364
  const options = input.options ?? {};
9510
- let url = buildEndpointURL(baseUrl, endpoint);
9511
- const originalPath = API_ENDPOINTS[endpoint].path;
9365
+ let url = buildEndpointURL$1(baseUrl, endpoint);
9366
+ const originalPath = API_ENDPOINTS$1[endpoint].path;
9512
9367
  const unusedParams = {};
9513
9368
  if (params) Object.entries(params).forEach(([key, value]) => {
9514
9369
  const bracePlaceholder = `{${key}}`;
@@ -9527,7 +9382,7 @@ function buildApiRequestPlan(input) {
9527
9382
  })));
9528
9383
  throw new Error(`Missing required path params for endpoint ${String(endpoint)}: ${missingParams.join(", ")}`);
9529
9384
  }
9530
- const endpointConfig = API_ENDPOINTS[endpoint];
9385
+ const endpointConfig = API_ENDPOINTS$1[endpoint];
9531
9386
  const method = endpointConfig.method;
9532
9387
  const isGetOrHead = method === "GET" || method === "HEAD";
9533
9388
  const queryParams = new URLSearchParams();
@@ -9568,7 +9423,7 @@ function buildApiRequestPlan(input) {
9568
9423
  async function createApiRequestError(response, endpoint, fallbackMessage) {
9569
9424
  const body = await parseErrorBody(response);
9570
9425
  const details = extractApiEnvelopeErrorDetails(body);
9571
- const config = API_ENDPOINTS[endpoint];
9426
+ const config = API_ENDPOINTS$1[endpoint];
9572
9427
  return new ApiRequestError(details.message ?? fallbackMessage ?? `Request to ${String(endpoint)} failed with status ${response.status}`, {
9573
9428
  endpoint,
9574
9429
  status: response.status,
@@ -9585,19 +9440,19 @@ function createParsedClient(rawClient) {
9585
9440
  return async (params) => {
9586
9441
  const response = await rawClient(params);
9587
9442
  const endpoint = params.endpoint;
9588
- const config = API_ENDPOINTS[endpoint];
9443
+ const config = API_ENDPOINTS$1[endpoint];
9589
9444
  if (!response.ok) throw await createApiRequestError(response, endpoint);
9590
9445
  return parseSuccessResponse(endpoint, response, config);
9591
9446
  };
9592
9447
  }
9593
- function createCMSClient(headers = {}, baseUrl) {
9594
- return createParsedClient(createRawCMSClient(() => headers, baseUrl));
9448
+ function createCMSClient(headers = {}, baseUrl, options) {
9449
+ return createParsedClient(createRawCMSClient(() => headers, baseUrl, options));
9595
9450
  }
9596
- function createInternalAPIClient(baseUrl) {
9597
- return createCMSClient({}, baseUrl);
9451
+ function createInternalAPIClient(baseUrl, options) {
9452
+ return createCMSClient({}, baseUrl, options);
9598
9453
  }
9599
- function createBearerAPIClient(token, baseUrl) {
9600
- return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl));
9454
+ function createBearerAPIClient(token, baseUrl, options) {
9455
+ return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
9601
9456
  }
9602
9457
  /** Positive receipt evidence is kept distinct from an HTTP or request failure. */
9603
9458
  function requireUsableCommitProjection(response, parsed) {
@@ -9605,54 +9460,2334 @@ function requireUsableCommitProjection(response, parsed) {
9605
9460
  throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
9606
9461
  }
9607
9462
  //#endregion
9608
- //#region ../api/src/bookingRecords.ts
9609
- const BOOKING_QUESTION_ANSWER_EXPORT_SCOPES = {
9610
- site: "site",
9611
- appointments: "appointments",
9612
- eventSeries: "event_series"
9613
- };
9614
- BOOKING_QUESTION_ANSWER_EXPORT_SCOPES.site, BOOKING_QUESTION_ANSWER_EXPORT_SCOPES.appointments, BOOKING_QUESTION_ANSWER_EXPORT_SCOPES.eventSeries;
9615
- //#endregion
9616
- //#region ../api/src/publicProducts.ts
9617
- function parseJsonValue(value) {
9618
- try {
9619
- return JSON.parse(value);
9620
- } catch {
9621
- return null;
9463
+ //#region src/client/error.ts
9464
+ let _Symbol$for;
9465
+ _Symbol$for = Symbol.for("nodejs.util.inspect.custom");
9466
+ /**
9467
+ * Error thrown by SDK when API returns an error response
9468
+ *
9469
+ * @example
9470
+ * ```ts
9471
+ * try {
9472
+ * await client.getSite({ slug: 'my-site' });
9473
+ * } catch (error) {
9474
+ * if (error instanceof RiverbankApiError) {
9475
+ * console.log('Error code:', error.code);
9476
+ * console.log('Request ID:', error.requestId);
9477
+ *
9478
+ * if (error.isAuthError()) {
9479
+ * // Handle authentication error
9480
+ * }
9481
+ *
9482
+ * if (error.isValidationError() && error.fieldErrors) {
9483
+ * // Handle field-level validation errors
9484
+ * error.fieldErrors.forEach(fe => {
9485
+ * console.log(`${fe.field}: ${fe.message}`);
9486
+ * });
9487
+ * }
9488
+ *
9489
+ * // Check if error can be retried
9490
+ * if (error.isRetryable) {
9491
+ * const delay = error.retryAfterMs ?? 1000;
9492
+ * console.log(`Retrying after ${delay}ms...`);
9493
+ * }
9494
+ * }
9495
+ * }
9496
+ * ```
9497
+ */
9498
+ var RiverbankApiError = class RiverbankApiError extends Error {
9499
+ constructor(apiError) {
9500
+ super(apiError.message);
9501
+ this.name = "RiverbankApiError";
9502
+ if ("cause" in apiError && apiError.cause) this.cause = apiError.cause;
9503
+ this.code = apiError.code;
9504
+ this.requestId = apiError.requestId;
9505
+ this.status = apiError.status;
9506
+ this.fieldErrors = apiError.fieldErrors;
9507
+ this.timestamp = apiError.timestamp;
9508
+ this.retryAfterMs = "retryAfterMs" in apiError ? apiError.retryAfterMs : void 0;
9509
+ this.isRetryable = this.computeRetryable();
9510
+ Object.setPrototypeOf(this, RiverbankApiError.prototype);
9622
9511
  }
9623
- }
9624
- function asRecord(value) {
9625
- return value && typeof value === "object" ? value : null;
9626
- }
9627
- function isNonEmptyString(value) {
9628
- return typeof value === "string" && value.length > 0;
9629
- }
9630
- function encodePublicProductCategorySelector(selector) {
9631
- if (!selector) return {};
9632
- switch (selector.kind) {
9633
- case "category": return {
9634
- productCategoryScope: "category",
9635
- productCategoryId: selector.productCategoryId
9636
- };
9637
- case "current-category-page":
9638
- if (selector.productCategoryEntryId.trim().length === 0) return {};
9639
- return {
9640
- productCategoryScope: "current-category-page",
9641
- productCategoryEntryId: selector.productCategoryEntryId
9642
- };
9512
+ /**
9513
+ * Compute whether this error is retryable based on HTTP status code.
9514
+ * - 0 (network errors - no HTTP response): retryable
9515
+ * - 429 (rate limit): retryable
9516
+ * - 5xx (server errors): retryable
9517
+ * - 4xx (client errors, except 429): NOT retryable
9518
+ */
9519
+ computeRetryable() {
9520
+ if (this.status === 0) return true;
9521
+ if (this.status === 429) return true;
9522
+ if (this.status >= 500) return true;
9523
+ return false;
9643
9524
  }
9525
+ /**
9526
+ * Check if this is a network error (no HTTP response received)
9527
+ *
9528
+ * Matches: network:connection_error, network:timeout, network:dns_error
9529
+ */
9530
+ isNetworkError() {
9531
+ return this.code.startsWith("network:");
9532
+ }
9533
+ /**
9534
+ * Check if this error matches a specific error code
9535
+ *
9536
+ * @example
9537
+ * ```ts
9538
+ * if (error.is('auth:unauthenticated')) {
9539
+ * // Redirect to login
9540
+ * }
9541
+ * ```
9542
+ */
9543
+ is(code) {
9544
+ return this.code === code;
9545
+ }
9546
+ /**
9547
+ * Check if this is an authentication or authorization error
9548
+ *
9549
+ * Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
9550
+ * auth:forbidden, auth:mfa_required, auth:insufficient_permissions
9551
+ */
9552
+ isAuthError() {
9553
+ return this.code.startsWith("auth:");
9554
+ }
9555
+ /**
9556
+ * Check if this is a validation error
9557
+ *
9558
+ * Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
9559
+ */
9560
+ isValidationError() {
9561
+ return this.code.startsWith("validation:");
9562
+ }
9563
+ /**
9564
+ * Check if this is a resource error (not found, conflict, etc.)
9565
+ *
9566
+ * Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
9567
+ */
9568
+ isResourceError() {
9569
+ return this.code.startsWith("resource:");
9570
+ }
9571
+ /**
9572
+ * Check if this is a rate limiting error
9573
+ */
9574
+ isRateLimitError() {
9575
+ return this.code.startsWith("rate_limit:");
9576
+ }
9577
+ /**
9578
+ * Check if this is a billing/payment error
9579
+ */
9580
+ isBillingError() {
9581
+ return this.code.startsWith("billing:");
9582
+ }
9583
+ /**
9584
+ * Check if this is a server error
9585
+ */
9586
+ isServerError() {
9587
+ return this.code.startsWith("server:");
9588
+ }
9589
+ /**
9590
+ * Returns a human-readable string representation of the error.
9591
+ * Includes all key details for debugging.
9592
+ *
9593
+ * @example
9594
+ * "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
9595
+ */
9596
+ toString() {
9597
+ const parts = [`RiverbankApiError: ${this.message}`];
9598
+ if (this.code) parts.push(`Code: ${this.code}`);
9599
+ if (this.status) parts.push(`Status: ${this.status}`);
9600
+ if (this.requestId) parts.push(`RequestId: ${this.requestId}`);
9601
+ return parts.join(" | ");
9602
+ }
9603
+ /**
9604
+ * Custom Node.js inspect output for better console.log display.
9605
+ * This ensures that console.log(error) shows all relevant details
9606
+ * instead of just "[Object]" for nested properties.
9607
+ */
9608
+ [_Symbol$for]() {
9609
+ return this.toDetailedString();
9610
+ }
9611
+ /**
9612
+ * Returns a detailed multi-line string for debugging.
9613
+ * Used by the Node.js inspect symbol for console output.
9614
+ */
9615
+ toDetailedString() {
9616
+ const lines = [
9617
+ `RiverbankApiError: ${this.message}`,
9618
+ ` Code: ${this.code}`,
9619
+ ` Status: ${this.status}`,
9620
+ ` RequestId: ${this.requestId}`,
9621
+ ` Timestamp: ${this.timestamp}`
9622
+ ];
9623
+ if (this.isRetryable) {
9624
+ lines.push(` Retryable: true`);
9625
+ if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
9626
+ }
9627
+ if (this.fieldErrors && this.fieldErrors.length > 0) {
9628
+ lines.push(" FieldErrors:");
9629
+ this.fieldErrors.forEach((fe) => {
9630
+ lines.push(` - ${fe.field}: ${fe.message}`);
9631
+ });
9632
+ }
9633
+ return lines.join("\n");
9634
+ }
9635
+ };
9636
+ const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
9637
+ function attachResilienceStatusToError(error, resilienceStatus) {
9638
+ 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");
9639
+ Object.defineProperty(target, resilienceStatusSymbol, {
9640
+ configurable: true,
9641
+ enumerable: false,
9642
+ value: resilienceStatus
9643
+ });
9644
+ return target;
9645
+ }
9646
+ function getResilienceStatusFromError(error) {
9647
+ if (error === null || typeof error !== "object" && typeof error !== "function") return;
9648
+ return error[resilienceStatusSymbol];
9649
+ }
9650
+ //#endregion
9651
+ //#region src/client/resilience.ts
9652
+ const DEFAULT_RETRY_CONFIG = {
9653
+ maxAttempts: 3,
9654
+ baseDelayMs: 200,
9655
+ maxDelayMs: 2e3,
9656
+ jitter: "full"
9657
+ };
9658
+ const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
9659
+ failureThreshold: 5,
9660
+ resetTimeoutMs: 3e4,
9661
+ halfOpenMaxRequests: 2
9662
+ };
9663
+ /**
9664
+ * Error codes that indicate permanent infrastructure failures.
9665
+ * These should NOT be retried as the server is definitively unreachable.
9666
+ */
9667
+ const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
9668
+ "ECONNREFUSED",
9669
+ "ENOTFOUND",
9670
+ "EAI_AGAIN"
9671
+ ]);
9672
+ /**
9673
+ * Error codes that indicate transient network issues.
9674
+ * These MAY succeed on retry as the server was reachable but had a hiccup.
9675
+ */
9676
+ const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
9677
+ "ECONNRESET",
9678
+ "EPIPE",
9679
+ "ETIMEDOUT",
9680
+ "ESOCKETTIMEDOUT"
9681
+ ]);
9682
+ /**
9683
+ * Node.js network error codes (POSIX style).
9684
+ * These are the codes we're looking for in the cause chain.
9685
+ */
9686
+ const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
9687
+ "ECONNREFUSED",
9688
+ "ENOTFOUND",
9689
+ "EAI_AGAIN",
9690
+ "ECONNRESET",
9691
+ "EPIPE",
9692
+ "ETIMEDOUT",
9693
+ "ESOCKETTIMEDOUT"
9694
+ ]);
9695
+ /**
9696
+ * Check if a string is a Node.js network error code (not an API error code).
9697
+ * API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
9698
+ */
9699
+ function isNodeNetworkErrorCode(code) {
9700
+ return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
9701
+ }
9702
+ /**
9703
+ * Extract the Node.js error code from an error's cause chain.
9704
+ * Handles nested cause chains like:
9705
+ * RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
9706
+ *
9707
+ * Skips API error codes (like 'network:connection_error') and only returns
9708
+ * actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
9709
+ *
9710
+ * @example
9711
+ * RiverbankApiError: Network request failed
9712
+ * [cause]: TypeError: fetch failed
9713
+ * [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
9714
+ * code: 'ECONNREFUSED'
9715
+ */
9716
+ function getErrorCodeFromCause(error) {
9717
+ let current = error;
9718
+ while (current) {
9719
+ const nodeError = current;
9720
+ if (nodeError.code && typeof nodeError.code === "string") {
9721
+ if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
9722
+ }
9723
+ current = current.cause;
9724
+ }
9725
+ }
9726
+ /**
9727
+ * Determine if an error is transient and should trigger circuit breaker / retry
9728
+ *
9729
+ * Transient (opens circuit, triggers retry):
9730
+ * - Network errors (status 0) that are NOT permanent infrastructure failures
9731
+ * - 5xx server errors
9732
+ * - 429 rate limit
9733
+ * - Connection reset, broken pipe, timeout
9734
+ *
9735
+ * Permanent (does NOT open circuit, no retry):
9736
+ * - 4xx client errors (400, 401, 403, 404)
9737
+ * - Validation errors
9738
+ * - ECONNREFUSED (server not running)
9739
+ * - ENOTFOUND (DNS failure)
9740
+ */
9741
+ function isTransientError(error) {
9742
+ if (error instanceof RiverbankApiError) {
9743
+ const errorCode = getErrorCodeFromCause(error);
9744
+ if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
9745
+ if (error.status === 0) return true;
9746
+ if (error.status === 429) return true;
9747
+ if (error.status >= 500) return true;
9748
+ return false;
9749
+ }
9750
+ if (error instanceof TypeError) {
9751
+ const errorCode = getErrorCodeFromCause(error);
9752
+ if (errorCode) {
9753
+ if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
9754
+ if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
9755
+ }
9756
+ return true;
9757
+ }
9758
+ return true;
9759
+ }
9760
+ /**
9761
+ * Calculate backoff delay for retry attempt
9762
+ *
9763
+ * Uses exponential backoff with optional full jitter.
9764
+ * Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
9765
+ */
9766
+ function calculateBackoff(attempt, config) {
9767
+ const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
9768
+ const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
9769
+ const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
9770
+ const exponential = baseDelayMs * Math.pow(2, attempt - 1);
9771
+ const capped = Math.min(exponential, maxDelayMs);
9772
+ if (jitter === "full") return Math.random() * capped;
9773
+ return capped;
9774
+ }
9775
+ /**
9776
+ * Circuit breaker for fail-fast behavior
9777
+ *
9778
+ * States:
9779
+ * - closed: Normal operation, requests allowed
9780
+ * - open: Too many failures, requests blocked
9781
+ * - half-open: Testing if service recovered, limited requests allowed
9782
+ */
9783
+ var CircuitBreaker = class {
9784
+ constructor(config) {
9785
+ this.state = "closed";
9786
+ this.failureCount = 0;
9787
+ this.successCount = 0;
9788
+ this.openUntil = 0;
9789
+ this.halfOpenRequests = 0;
9790
+ this.config = {
9791
+ failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
9792
+ resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
9793
+ halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
9794
+ };
9795
+ }
9796
+ /**
9797
+ * Check if circuit is open (requests should be blocked)
9798
+ * Also handles automatic transition from open to half-open after timeout
9799
+ */
9800
+ isOpen() {
9801
+ if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
9802
+ return this.state === "open";
9803
+ }
9804
+ /**
9805
+ * Check if a request can be attempted
9806
+ * - closed: always yes
9807
+ * - open: always no
9808
+ * - half-open: limited number of probes
9809
+ */
9810
+ canAttempt() {
9811
+ if (this.state === "closed") return true;
9812
+ if (this.state === "open") return false;
9813
+ return this.halfOpenRequests < this.config.halfOpenMaxRequests;
9814
+ }
9815
+ /**
9816
+ * Increment half-open request counter (call before making request in half-open)
9817
+ */
9818
+ incrementHalfOpenRequests() {
9819
+ if (this.state === "half-open") this.halfOpenRequests++;
9820
+ }
9821
+ /**
9822
+ * Record a successful request
9823
+ */
9824
+ recordSuccess() {
9825
+ if (this.state === "half-open") {
9826
+ this.successCount++;
9827
+ if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
9828
+ } else this.failureCount = 0;
9829
+ }
9830
+ /**
9831
+ * Record a failed request
9832
+ * Only counts transient failures toward circuit breaker threshold
9833
+ */
9834
+ recordFailure(error) {
9835
+ if (!isTransientError(error)) return;
9836
+ this.failureCount++;
9837
+ if (this.state === "half-open") this.transitionTo("open");
9838
+ else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
9839
+ }
9840
+ /**
9841
+ * Get current circuit state
9842
+ */
9843
+ getState() {
9844
+ return {
9845
+ state: this.state,
9846
+ failureCount: this.failureCount,
9847
+ openUntil: this.state === "open" ? this.openUntil : void 0
9848
+ };
9849
+ }
9850
+ /**
9851
+ * Transition to a new state
9852
+ */
9853
+ transitionTo(newState) {
9854
+ this.state = newState;
9855
+ if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
9856
+ else if (newState === "half-open") {
9857
+ this.halfOpenRequests = 0;
9858
+ this.successCount = 0;
9859
+ } else if (newState === "closed") {
9860
+ this.failureCount = 0;
9861
+ this.successCount = 0;
9862
+ this.halfOpenRequests = 0;
9863
+ }
9864
+ }
9865
+ };
9866
+ /**
9867
+ * Fetch with timeout and retry logic
9868
+ *
9869
+ * @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
9870
+ * @param config - Retry configuration
9871
+ * @returns Result from successful fetch
9872
+ * @throws Last error after all retries exhausted
9873
+ */
9874
+ async function fetchWithTimeoutAndRetry(fetcher, config) {
9875
+ const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
9876
+ const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
9877
+ let lastError;
9878
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
9879
+ const controller = new AbortController();
9880
+ const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
9881
+ try {
9882
+ return await fetcher(controller.signal);
9883
+ } finally {
9884
+ clearTimeout(timeoutId);
9885
+ }
9886
+ } catch (error) {
9887
+ lastError = error;
9888
+ if (!shouldRetryError(error, config.retryOn)) throw error;
9889
+ if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
9890
+ }
9891
+ throw lastError;
9892
+ }
9893
+ /**
9894
+ * Check if an error is an AbortError (from AbortController.abort() or timeout)
9895
+ */
9896
+ function isAbortError$1(error) {
9897
+ if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
9898
+ if (error instanceof Error && error.name === "AbortError") return true;
9899
+ return false;
9900
+ }
9901
+ /**
9902
+ * Check if an error should be retried
9903
+ */
9904
+ function shouldRetryError(error, customRetryOn) {
9905
+ if (isAbortError$1(error)) return false;
9906
+ if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
9907
+ return isTransientError(error);
9908
+ }
9909
+ /**
9910
+ * Get delay before retrying, respecting Retry-After if present
9911
+ */
9912
+ function getRetryDelay(error, attempt, config) {
9913
+ if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
9914
+ return calculateBackoff(attempt, config);
9915
+ }
9916
+ /**
9917
+ * Sleep for specified milliseconds
9918
+ */
9919
+ function sleep(ms) {
9920
+ return new Promise((resolve) => setTimeout(resolve, ms));
9921
+ }
9922
+ /**
9923
+ * Error thrown when circuit breaker is open
9924
+ */
9925
+ var CircuitOpenError = class extends Error {
9926
+ constructor(state) {
9927
+ super("Circuit breaker is open");
9928
+ this.name = "CircuitOpenError";
9929
+ this.circuitState = state;
9930
+ }
9931
+ };
9932
+ //#endregion
9933
+ //#region src/client/entryListReadRequest.ts
9934
+ const entryOrder = {
9935
+ newest: "published_at.desc",
9936
+ oldest: "published_at.asc",
9937
+ title: "title.asc",
9938
+ manual: "manual.asc"
9939
+ };
9940
+ function entrySelection(input) {
9941
+ return input.mode === "manual" && input.entryIds?.length ? {
9942
+ keyPart: input.entryIds.join(","),
9943
+ params: {
9944
+ mode: "manual",
9945
+ entryIds: JSON.stringify(input.entryIds)
9946
+ }
9947
+ } : {
9948
+ keyPart: "",
9949
+ params: {}
9950
+ };
9951
+ }
9952
+ function entryListMemoryKey(input, selection) {
9953
+ const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
9954
+ return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
9955
+ }
9956
+ /** One interpretation of pagination, selection and preview for the transport and memory key. */
9957
+ function buildEntryListReadRequest(input) {
9958
+ const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
9959
+ const selection = entrySelection(input);
9960
+ const orderParam = order ? entryOrder[order] : void 0;
9961
+ return {
9962
+ cacheKey: entryListMemoryKey(input, selection),
9963
+ params: {
9964
+ siteId,
9965
+ type: contentType,
9966
+ ...typeof limit === "number" && { limit: String(limit) },
9967
+ ...typeof offset === "number" && { offset: String(offset) },
9968
+ ...includeMeta && { meta: "true" },
9969
+ ...orderParam && { order: orderParam },
9970
+ ...preview && { stage: "preview" },
9971
+ ...selection.params
9972
+ }
9973
+ };
9974
+ }
9975
+ //#endregion
9976
+ //#region src/client/cache.ts
9977
+ var SimpleCache = class {
9978
+ constructor(options = {}) {
9979
+ this.cache = /* @__PURE__ */ new Map();
9980
+ this.maxSize = options.maxSize ?? 100;
9981
+ this.ttl = options.ttl ?? 3e5;
9982
+ this.staleTtl = options.staleTtl ?? 3e5;
9983
+ }
9984
+ /**
9985
+ * Get a fresh value (within TTL)
9986
+ * @returns The value if fresh, null otherwise
9987
+ */
9988
+ getFresh(key) {
9989
+ const entry = this.cache.get(key);
9990
+ if (!entry) return null;
9991
+ if (Date.now() <= entry.freshUntil) return entry.value;
9992
+ return null;
9993
+ }
9994
+ /**
9995
+ * Get a value that may be stale (past TTL but within staleTtl)
9996
+ * @returns Object with value and stale age, or null if expired
9997
+ */
9998
+ getStale(key) {
9999
+ const entry = this.cache.get(key);
10000
+ if (!entry) return null;
10001
+ const now = Date.now();
10002
+ if (now > entry.staleUntil) {
10003
+ this.cache.delete(key);
10004
+ return null;
10005
+ }
10006
+ const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
10007
+ return {
10008
+ value: entry.value,
10009
+ staleAgeSec
10010
+ };
10011
+ }
10012
+ /**
10013
+ * Store a value with TTL and stale window
10014
+ */
10015
+ set(key, value, options) {
10016
+ const ttl = options?.ttl ?? this.ttl;
10017
+ const staleTtl = options?.staleTtl ?? this.staleTtl;
10018
+ const now = Date.now();
10019
+ while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
10020
+ this.cache.set(key, {
10021
+ value,
10022
+ tags: options?.tags ?? [],
10023
+ createdAt: now,
10024
+ freshUntil: now + ttl,
10025
+ staleUntil: now + ttl + staleTtl
10026
+ });
10027
+ }
10028
+ /**
10029
+ * Evict one entry to make room for a new one
10030
+ * Priority: oldest stale entry, then oldest fresh entry
10031
+ */
10032
+ evictOne(now) {
10033
+ let oldestStaleKey = null;
10034
+ let oldestStaleTime = Infinity;
10035
+ let oldestFreshKey = null;
10036
+ let oldestFreshTime = Infinity;
10037
+ for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
10038
+ if (entry.createdAt < oldestStaleTime) {
10039
+ oldestStaleTime = entry.createdAt;
10040
+ oldestStaleKey = key;
10041
+ }
10042
+ } else if (entry.createdAt < oldestFreshTime) {
10043
+ oldestFreshTime = entry.createdAt;
10044
+ oldestFreshKey = key;
10045
+ }
10046
+ const keyToEvict = oldestStaleKey ?? oldestFreshKey;
10047
+ if (keyToEvict) this.cache.delete(keyToEvict);
10048
+ }
10049
+ /**
10050
+ * Remove all fully expired entries (past staleUntil)
10051
+ */
10052
+ prune() {
10053
+ const now = Date.now();
10054
+ for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
10055
+ }
10056
+ /**
10057
+ * Clear all entries
10058
+ */
10059
+ clearForTags(tags) {
10060
+ if (tags.includes("riverbank")) {
10061
+ this.clear();
10062
+ return;
10063
+ }
10064
+ const selected = new Set(tags);
10065
+ [...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
10066
+ }
10067
+ clear() {
10068
+ this.cache.clear();
10069
+ }
10070
+ /**
10071
+ * Check if a key exists and is not fully expired
10072
+ */
10073
+ has(key) {
10074
+ const entry = this.cache.get(key);
10075
+ if (!entry) return false;
10076
+ const now = Date.now();
10077
+ if (now > entry.staleUntil) {
10078
+ this.cache.delete(key);
10079
+ return false;
10080
+ }
10081
+ return now <= entry.freshUntil;
10082
+ }
10083
+ };
10084
+ //#endregion
10085
+ //#region src/request-options.ts
10086
+ /** Every API client the SDK creates sends its version as `x-sdk-version`. */
10087
+ const sdkRequestOptions = { sdkVersion: SDK_VERSION };
10088
+ //#endregion
10089
+ //#region src/public-api/runtime.ts
10090
+ const PUBLIC_ENDPOINT_NAMES = [
10091
+ "getSite",
10092
+ "getContentByPath",
10093
+ "resolveRouteOutcome",
10094
+ "resolveRouteDecision",
10095
+ "listPublishedEntries",
10096
+ "getPublishedEntryPreview",
10097
+ "getPublicFormById",
10098
+ "listPublicForms",
10099
+ "getPublicBookingServices",
10100
+ "getPublicWeeklySlotAvailability",
10101
+ "getPublicChallenge",
10102
+ "listPublicEvents",
10103
+ "batchBlockLoaders",
10104
+ "listPublicTeamMembers",
10105
+ "listPublicProducts",
10106
+ "listPublicPasses",
10107
+ "listPublicMemberships",
10108
+ "resolveEventSubroute",
10109
+ "checkRedirect",
10110
+ "getRoutableContent",
10111
+ "getPublicRoutableContent",
10112
+ "getPublicSitemapRoutes"
10113
+ ];
10114
+ const API_ENDPOINTS = Object.freeze({
10115
+ getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
10116
+ getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
10117
+ getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
10118
+ getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
10119
+ getContentByPath: {
10120
+ path: "/sites/{siteId}/pages",
10121
+ method: "GET",
10122
+ tags: [TAG_TEMPLATES.siteRoutableContent],
10123
+ auth: "public",
10124
+ responseKind: "json"
10125
+ },
10126
+ resolveRouteOutcome: {
10127
+ path: "/sites/{siteId}/route-outcome",
10128
+ method: "GET",
10129
+ tags: [
10130
+ TAG_TEMPLATES.siteRoutableContent,
10131
+ TAG_TEMPLATES.siteRedirects,
10132
+ TAG_TEMPLATES.siteRouteOutcomes
10133
+ ],
10134
+ auth: "public",
10135
+ responseKind: "json"
10136
+ },
10137
+ resolveRouteDecision: {
10138
+ path: "/sites/{siteId}/route-decision",
10139
+ method: "GET",
10140
+ tags: [
10141
+ TAG_TEMPLATES.siteRoutableContent,
10142
+ TAG_TEMPLATES.siteRedirects,
10143
+ TAG_TEMPLATES.siteRouteOutcomes
10144
+ ],
10145
+ auth: "public",
10146
+ responseKind: "json"
10147
+ },
10148
+ listPublishedEntries: {
10149
+ path: "/public/content/{siteId}/{type}/entries",
10150
+ method: "GET",
10151
+ revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
10152
+ tags: ["content-{siteId}-{type}"],
10153
+ auth: "public",
10154
+ responseKind: "json"
10155
+ },
10156
+ getPublishedEntryPreview: {
10157
+ path: "/public/content/{siteId}/{type}/{slug}/preview",
10158
+ method: "GET",
10159
+ revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
10160
+ tags: ["content-{siteId}-{type}-{slug}"],
10161
+ auth: "public",
10162
+ responseKind: "json"
10163
+ },
10164
+ getPublicFormById: {
10165
+ path: "/public/forms/{formId}",
10166
+ method: "GET",
10167
+ revalidate: publicReadFreshnessSeconds("getPublicFormById"),
10168
+ tags: [TAG_TEMPLATES.formById],
10169
+ auth: "public",
10170
+ responseKind: "json"
10171
+ },
10172
+ listPublicForms: {
10173
+ path: "/public/sites/{siteId}/forms",
10174
+ method: "GET",
10175
+ revalidate: 60,
10176
+ tags: [TAG_TEMPLATES.siteForms],
10177
+ auth: "public",
10178
+ responseKind: "json"
10179
+ },
10180
+ getPublicBookingServices: {
10181
+ path: "/public/bookings/services",
10182
+ method: "GET",
10183
+ revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
10184
+ tags: [TAG_TEMPLATES.publicBookingServices],
10185
+ auth: "public",
10186
+ responseKind: "json"
10187
+ },
10188
+ getPublicWeeklySlotAvailability: {
10189
+ path: "/public/bookings/weekly-slot-availability",
10190
+ method: "GET",
10191
+ revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
10192
+ tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
10193
+ auth: "public",
10194
+ responseKind: "json"
10195
+ },
10196
+ getPublicChallenge: {
10197
+ path: "/public/challenge",
10198
+ method: "GET",
10199
+ auth: "public",
10200
+ responseKind: "text"
10201
+ },
10202
+ listPublicEvents: {
10203
+ path: "/public/sites/{siteId}/events",
10204
+ method: "GET",
10205
+ revalidate: publicReadFreshnessSeconds("listPublicEvents"),
10206
+ tags: [TAG_TEMPLATES.publicEvents],
10207
+ auth: "public",
10208
+ responseKind: "json"
10209
+ },
10210
+ batchBlockLoaders: {
10211
+ path: "/public/sites/{siteId}/block-loaders/batch",
10212
+ method: "POST",
10213
+ auth: "public",
10214
+ responseKind: "json"
10215
+ },
10216
+ listPublicTeamMembers: {
10217
+ path: "/public/sites/{siteId}/team-members",
10218
+ method: "GET",
10219
+ revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
10220
+ tags: [TAG_TEMPLATES.publicTeamMembers],
10221
+ auth: "public",
10222
+ responseKind: "json"
10223
+ },
10224
+ listPublicProducts: {
10225
+ path: "/public/sites/{siteId}/products",
10226
+ method: "GET",
10227
+ revalidate: publicReadFreshnessSeconds("listPublicProducts"),
10228
+ tags: [TAG_TEMPLATES.publicProducts],
10229
+ auth: "public",
10230
+ responseKind: "json"
10231
+ },
10232
+ listPublicPasses: {
10233
+ path: "/public/sites/{siteId}/bookings/products/passes",
10234
+ method: "GET",
10235
+ revalidate: publicReadFreshnessSeconds("listPublicPasses"),
10236
+ tags: [TAG_TEMPLATES.publicPasses],
10237
+ auth: "public",
10238
+ responseKind: "json"
10239
+ },
10240
+ listPublicMemberships: {
10241
+ path: "/public/sites/{siteId}/bookings/products/memberships",
10242
+ method: "GET",
10243
+ revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
10244
+ tags: [TAG_TEMPLATES.publicMemberships],
10245
+ auth: "public",
10246
+ responseKind: "json"
10247
+ },
10248
+ resolveEventSubroute: {
10249
+ path: "/public/sites/{siteId}/events/subroutes/resolve",
10250
+ method: "GET",
10251
+ revalidate: 60,
10252
+ tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
10253
+ auth: "public",
10254
+ responseKind: "json"
10255
+ },
10256
+ checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
10257
+ });
10258
+ function buildEndpointURL(baseURL, endpoint) {
10259
+ return baseURL + API_ENDPOINTS[endpoint].path;
10260
+ }
10261
+ function publicSiteReadDefinition(definition) {
10262
+ return {
10263
+ path: definition.path,
10264
+ method: definition.method,
10265
+ revalidate: definition.revalidate,
10266
+ tags: definition.tags,
10267
+ auth: definition.auth,
10268
+ responseKind: definition.responseKind
10269
+ };
10270
+ }
10271
+ //#endregion
10272
+ //#region src/client/runtimeCacheKeys.ts
10273
+ /**
10274
+ * Bump when a cached payload's shape changes incompatibly, so readers skip
10275
+ * entries written in the old shape until publish or a live success rewrites
10276
+ * them.
10277
+ *
10278
+ * - 4: owned surface inputs use the shared revision transport envelope (#1627).
10279
+ * - 3: hidden business-source maps and private locations are removed before public projection (#1611).
10280
+ * - 2: pages carry intent-only `runtimeJoins` in place of compiled
10281
+ * `runtimeBoundaries` (issue 1422).
10282
+ */
10283
+ const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 4;
10284
+ function toNonEmptyString(value) {
10285
+ if (value === null || value === void 0) return null;
10286
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
10287
+ const normalized = String(value).trim();
10288
+ return normalized.length > 0 ? normalized : null;
10289
+ }
10290
+ function normalizeRuntimePublicPath(value) {
10291
+ const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
10292
+ const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
10293
+ return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
10294
+ }
10295
+ function normalizeRuntimeHostname(value) {
10296
+ const trimmed = value.trim().toLowerCase();
10297
+ return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
10298
+ }
10299
+ function normalizeScalar(value) {
10300
+ return value.trim().toLowerCase();
10301
+ }
10302
+ function unsafeAsPublishedRuntimeCacheKey(value) {
10303
+ return value;
10304
+ }
10305
+ function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
10306
+ return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
10307
+ }
10308
+ function selectSiteRuntimeIdentity(params) {
10309
+ const slug = toNonEmptyString(params.slug);
10310
+ if (slug !== null) return { slug: normalizeScalar(slug) };
10311
+ const domain = toNonEmptyString(params.domain);
10312
+ if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
10313
+ const id = toNonEmptyString(params.id);
10314
+ if (id !== null) return { id: normalizeScalar(id) };
10315
+ return null;
10316
+ }
10317
+ function deriveGetSiteKey(params) {
10318
+ const identity = selectSiteRuntimeIdentity(params);
10319
+ if (identity === null) return {
10320
+ ok: false,
10321
+ error: {
10322
+ kind: "missing_site_identity",
10323
+ acceptedParams: [
10324
+ "slug",
10325
+ "domain",
10326
+ "id"
10327
+ ]
10328
+ }
10329
+ };
10330
+ const normalizedParams = {
10331
+ ...identity,
10332
+ currentPath: normalizeRuntimePublicPath(params.currentPath)
10333
+ };
10334
+ return {
10335
+ ok: true,
10336
+ endpoint: "getSite",
10337
+ key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
10338
+ normalizedParams
10339
+ };
10340
+ }
10341
+ function deriveGetContentByPathKey(params) {
10342
+ const siteId = toNonEmptyString(params.siteId);
10343
+ if (siteId === null) return {
10344
+ ok: false,
10345
+ error: {
10346
+ kind: "missing_required_param",
10347
+ endpoint: "getContentByPath",
10348
+ param: "siteId"
10349
+ }
10350
+ };
10351
+ const normalizedParams = {
10352
+ siteId: normalizeScalar(siteId),
10353
+ path: normalizeRuntimePublicPath(params.path),
10354
+ contentContract: "native"
10355
+ };
10356
+ return {
10357
+ ok: true,
10358
+ endpoint: "getContentByPath",
10359
+ key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
10360
+ normalizedParams
10361
+ };
10362
+ }
10363
+ function deriveDurableRuntimeCacheKey(input) {
10364
+ switch (input.endpoint) {
10365
+ case "getSite": return deriveGetSiteKey(input.params);
10366
+ case "getContentByPath": return deriveGetContentByPathKey(input.params);
10367
+ }
10368
+ }
10369
+ function isPublishedRuntimeCacheKeyEndpoint(value) {
10370
+ return value === "getSite" || value === "getContentByPath";
10371
+ }
10372
+ function parsePublishedRuntimeCacheKey(value) {
10373
+ const details = parsePublishedRuntimeCacheKeyDetails(value);
10374
+ if (!details.ok) return details;
10375
+ return {
10376
+ ok: true,
10377
+ key: details.key,
10378
+ endpoint: details.endpoint
10379
+ };
10380
+ }
10381
+ function parsePublishedRuntimeCacheKeyDetails(value) {
10382
+ if (typeof value !== "string") return {
10383
+ ok: false,
10384
+ error: "not_string"
10385
+ };
10386
+ const parts = value.split(":");
10387
+ if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
10388
+ ok: false,
10389
+ error: "invalid_prefix"
10390
+ };
10391
+ const endpoint = parts[2];
10392
+ if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
10393
+ ok: false,
10394
+ error: "unknown_endpoint"
10395
+ };
10396
+ const normalizedParams = {};
10397
+ for (const part of parts.slice(3)) {
10398
+ const separatorIndex = part.indexOf("=");
10399
+ if (separatorIndex <= 0) return {
10400
+ ok: false,
10401
+ error: "invalid_param_encoding"
10402
+ };
10403
+ try {
10404
+ const key = decodeURIComponent(part.slice(0, separatorIndex));
10405
+ normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
10406
+ } catch {
10407
+ return {
10408
+ ok: false,
10409
+ error: "invalid_param_encoding"
10410
+ };
10411
+ }
10412
+ }
10413
+ if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
10414
+ ok: false,
10415
+ error: "invalid_param_encoding"
10416
+ };
10417
+ return {
10418
+ ok: true,
10419
+ key: unsafeAsPublishedRuntimeCacheKey(value),
10420
+ endpoint,
10421
+ normalizedParams
10422
+ };
10423
+ }
10424
+ function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
10425
+ const keys = Object.keys(normalizedParams).sort();
10426
+ switch (endpoint) {
10427
+ case "getSite": return [
10428
+ "domain",
10429
+ "id",
10430
+ "slug"
10431
+ ].filter((key) => normalizedParams[key] !== void 0).length === 1 && normalizedParams.currentPath !== void 0 && keys.every((key) => [
10432
+ "currentPath",
10433
+ "domain",
10434
+ "id",
10435
+ "slug"
10436
+ ].includes(key));
10437
+ case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
10438
+ "contentContract",
10439
+ "path",
10440
+ "siteId"
10441
+ ].includes(key));
10442
+ }
10443
+ }
10444
+ function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
10445
+ if (typeof value !== "number") return {
10446
+ ok: false,
10447
+ error: "not_number"
10448
+ };
10449
+ if (!Number.isInteger(value)) return {
10450
+ ok: false,
10451
+ error: "not_integer"
10452
+ };
10453
+ if (value <= 0) return {
10454
+ ok: false,
10455
+ error: "not_positive"
10456
+ };
10457
+ return {
10458
+ ok: true,
10459
+ value
10460
+ };
10461
+ }
10462
+ //#endregion
10463
+ //#region src/client/runtimeCachePolicy.ts
10464
+ const DEFAULT_STALE_TTL_SEC = 1440 * 60;
10465
+ const DEFAULT_MEMORY_TTL_SEC = 60;
10466
+ const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
10467
+ getSite: {
10468
+ kind: "durable-public-stale",
10469
+ staleTtlSec: DEFAULT_STALE_TTL_SEC
10470
+ },
10471
+ getContentByPath: {
10472
+ kind: "durable-public-stale",
10473
+ staleTtlSec: DEFAULT_STALE_TTL_SEC
10474
+ },
10475
+ resolveRouteOutcome: {
10476
+ kind: "memory-only",
10477
+ reason: "durable_rollout_pending"
10478
+ },
10479
+ resolveRouteDecision: {
10480
+ kind: "memory-only",
10481
+ reason: "durable_rollout_pending"
10482
+ },
10483
+ listPublishedEntries: {
10484
+ kind: "memory-only",
10485
+ reason: "durable_rollout_pending"
10486
+ },
10487
+ getPublishedEntryPreview: {
10488
+ kind: "memory-only",
10489
+ reason: "durable_rollout_pending"
10490
+ },
10491
+ getPublicFormById: {
10492
+ kind: "memory-only",
10493
+ reason: "durable_rollout_pending"
10494
+ },
10495
+ listPublicForms: {
10496
+ kind: "memory-only",
10497
+ reason: "durable_rollout_pending"
10498
+ },
10499
+ getPublicBookingServices: {
10500
+ kind: "live-only",
10501
+ reason: "safety_sensitive_booking"
10502
+ },
10503
+ getPublicWeeklySlotAvailability: {
10504
+ kind: "live-only",
10505
+ reason: "safety_sensitive_booking"
10506
+ },
10507
+ getPublicChallenge: {
10508
+ kind: "live-only",
10509
+ reason: "challenge_endpoint"
10510
+ },
10511
+ listPublicEvents: {
10512
+ kind: "memory-only",
10513
+ reason: "durable_rollout_pending"
10514
+ },
10515
+ batchBlockLoaders: {
10516
+ kind: "live-only",
10517
+ reason: "opaque_batch_loader"
10518
+ },
10519
+ listPublicTeamMembers: {
10520
+ kind: "memory-only",
10521
+ reason: "durable_rollout_pending"
10522
+ },
10523
+ listPublicProducts: {
10524
+ kind: "memory-only",
10525
+ reason: "durable_rollout_pending"
10526
+ },
10527
+ listPublicPasses: {
10528
+ kind: "live-only",
10529
+ reason: "safety_sensitive_booking"
10530
+ },
10531
+ listPublicMemberships: {
10532
+ kind: "live-only",
10533
+ reason: "safety_sensitive_booking"
10534
+ },
10535
+ resolveEventSubroute: {
10536
+ kind: "memory-only",
10537
+ reason: "durable_rollout_pending"
10538
+ },
10539
+ checkRedirect: {
10540
+ kind: "memory-only",
10541
+ reason: "durable_rollout_pending"
10542
+ },
10543
+ getRoutableContent: {
10544
+ kind: "live-only",
10545
+ reason: "auth_required"
10546
+ },
10547
+ getPublicRoutableContent: {
10548
+ kind: "memory-only",
10549
+ reason: "durable_rollout_pending"
10550
+ },
10551
+ getPublicSitemapRoutes: {
10552
+ kind: "memory-only",
10553
+ reason: "durable_rollout_pending"
10554
+ }
10555
+ };
10556
+ const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
10557
+ function isPublicEndpointName(endpoint) {
10558
+ return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
10559
+ }
10560
+ function isTruthyParam(value) {
10561
+ return value === true || value === "true" || value === 1 || value === "1";
10562
+ }
10563
+ function isPreviewRequest(endpoint, params) {
10564
+ if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
10565
+ if (endpoint === "listPublishedEntries" || endpoint === "resolveEventSubroute") return params.stage === "preview";
10566
+ return false;
10567
+ }
10568
+ function getEndpointFreshTtlSec(endpoint) {
10569
+ return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
10570
+ }
10571
+ function assertNever(value) {
10572
+ throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
10573
+ }
10574
+ function resolveKnownEndpointPolicy(endpoint, params) {
10575
+ if (isPreviewRequest(endpoint, params)) return {
10576
+ kind: "live-only",
10577
+ endpoint,
10578
+ reason: "preview_request"
10579
+ };
10580
+ if (endpoint === "getSite" && isTruthyParam(params.force)) return {
10581
+ kind: "live-only",
10582
+ endpoint,
10583
+ reason: "force_refresh"
10584
+ };
10585
+ if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
10586
+ kind: "live-only",
10587
+ endpoint,
10588
+ reason: "safety_sensitive_booking"
10589
+ };
10590
+ const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
10591
+ if (override.kind === "live-only") return {
10592
+ kind: "live-only",
10593
+ endpoint,
10594
+ reason: override.reason
10595
+ };
10596
+ const endpointDefinition = API_ENDPOINTS[endpoint];
10597
+ if (endpointDefinition.method !== "GET") return {
10598
+ kind: "live-only",
10599
+ endpoint,
10600
+ reason: "non_get_request"
10601
+ };
10602
+ if (endpointDefinition.auth === "user") return {
10603
+ kind: "live-only",
10604
+ endpoint,
10605
+ reason: "auth_required"
10606
+ };
10607
+ switch (override.kind) {
10608
+ case "durable-public-stale": return {
10609
+ kind: "durable-public-stale",
10610
+ endpoint,
10611
+ freshTtlSec: getEndpointFreshTtlSec(endpoint),
10612
+ staleTtlSec: override.staleTtlSec
10613
+ };
10614
+ case "memory-only": return {
10615
+ kind: "memory-only",
10616
+ endpoint,
10617
+ freshTtlSec: getEndpointFreshTtlSec(endpoint),
10618
+ reason: override.reason
10619
+ };
10620
+ default: return assertNever(override);
10621
+ }
10622
+ }
10623
+ function resolveRuntimeCachePolicy(input) {
10624
+ if (input.method && input.method.toUpperCase() !== "GET") return {
10625
+ kind: "live-only",
10626
+ endpoint: input.endpoint,
10627
+ reason: "non_get_request"
10628
+ };
10629
+ if (!isPublicEndpointName(input.endpoint)) return {
10630
+ kind: "live-only",
10631
+ endpoint: input.endpoint,
10632
+ reason: "unknown_endpoint"
10633
+ };
10634
+ return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
10635
+ }
10636
+ function classifyPublishedRuntimeCacheFreshness(input) {
10637
+ const freshUntilMs = Date.parse(input.freshUntil);
10638
+ const staleUntilMs = Date.parse(input.staleUntil);
10639
+ if (Number.isNaN(freshUntilMs)) return {
10640
+ kind: "invalid_timestamp",
10641
+ field: "freshUntil"
10642
+ };
10643
+ if (Number.isNaN(staleUntilMs)) return {
10644
+ kind: "invalid_timestamp",
10645
+ field: "staleUntil"
10646
+ };
10647
+ const nowMs = input.now.getTime();
10648
+ if (nowMs > staleUntilMs) return { kind: "expired" };
10649
+ if (nowMs <= freshUntilMs) return {
10650
+ kind: "fresh",
10651
+ staleAgeSec: 0
10652
+ };
10653
+ return {
10654
+ kind: "stale",
10655
+ staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
10656
+ };
10657
+ }
10658
+ function derivePublishedRuntimeCacheKey(input) {
10659
+ const policy = resolveRuntimeCachePolicy({
10660
+ endpoint: input.endpoint,
10661
+ method: "GET",
10662
+ params: input.params
10663
+ });
10664
+ if (policy.kind !== "durable-public-stale") return {
10665
+ ok: false,
10666
+ error: {
10667
+ kind: "not_durable_eligible",
10668
+ policy
10669
+ }
10670
+ };
10671
+ return deriveDurableRuntimeCacheKey(input);
10672
+ }
10673
+ //#endregion
10674
+ //#region src/client/contentReadOperations.ts
10675
+ function planPublishedRuntimeCache(input) {
10676
+ const policy = resolveRuntimeCachePolicy({
10677
+ endpoint: input.endpoint,
10678
+ method: "GET",
10679
+ params: input.params
10680
+ });
10681
+ if (policy.kind !== "durable-public-stale") return null;
10682
+ const keyResult = derivePublishedRuntimeCacheKey(input);
10683
+ if (!keyResult.ok) return null;
10684
+ return {
10685
+ cacheKey: keyResult.key,
10686
+ endpoint: keyResult.endpoint,
10687
+ normalizedParams: keyResult.normalizedParams,
10688
+ freshTtlSec: policy.freshTtlSec,
10689
+ staleTtlSec: policy.staleTtlSec,
10690
+ siteId: input.siteId ?? null
10691
+ };
10692
+ }
10693
+ function siteApiParams(params) {
10694
+ return {
10695
+ ...params.slug ? { slug: params.slug } : {},
10696
+ ...params.domain ? { domain: params.domain } : {},
10697
+ ...params.id ? { id: params.id } : {},
10698
+ ...params.currentPath ? { currentPath: params.currentPath } : {},
10699
+ ...params.force ? { force: "true" } : {}
10700
+ };
10701
+ }
10702
+ function siteReadIdentity(params) {
10703
+ const identifier = params.slug || params.domain || params.id;
10704
+ if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
10705
+ return identifier;
10706
+ }
10707
+ function planSiteRead(params) {
10708
+ const identifier = siteReadIdentity(params);
10709
+ const { slug, domain, id, currentPath, force } = params;
10710
+ const publishedRuntimeCache = planPublishedRuntimeCache({
10711
+ endpoint: "getSite",
10712
+ params: {
10713
+ slug,
10714
+ domain,
10715
+ id,
10716
+ currentPath,
10717
+ force
10718
+ }
10719
+ });
10720
+ return {
10721
+ publishedRuntimeCache,
10722
+ prebuildIdentifier: id || slug || domain,
10723
+ cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
10724
+ };
10725
+ }
10726
+ async function readSiteWithResilience(input, params) {
10727
+ const { slug, domain, id, signal, force } = params;
10728
+ const plan = planSiteRead(params);
10729
+ const prebuildId = plan.prebuildIdentifier;
10730
+ const prebuild = input.prebuildLoader;
10731
+ return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
10732
+ endpoint: "getSite",
10733
+ params: siteApiParams(params),
10734
+ options: {
10735
+ signal: requestSignal,
10736
+ ...force ? { cache: "no-store" } : {}
10737
+ }
10738
+ }), {
10739
+ signal,
10740
+ force,
10741
+ publishedRuntimeCache: plan.publishedRuntimeCache,
10742
+ cacheTags: buildSiteReadTags({
10743
+ slug,
10744
+ domain,
10745
+ id
10746
+ }),
10747
+ prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
10748
+ });
10749
+ }
10750
+ async function readPageWithResilience(input, params) {
10751
+ const { siteId, path, preview = false, signal } = params;
10752
+ const publishedRuntimeCache = planPublishedRuntimeCache({
10753
+ endpoint: "getContentByPath",
10754
+ params: {
10755
+ siteId,
10756
+ path,
10757
+ preview
10758
+ },
10759
+ siteId
10760
+ });
10761
+ const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
10762
+ return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
10763
+ endpoint: "getContentByPath",
10764
+ params: {
10765
+ siteId,
10766
+ path,
10767
+ preview: String(preview)
10768
+ },
10769
+ options: { signal: requestSignal }
10770
+ }), {
10771
+ preview,
10772
+ signal,
10773
+ publishedRuntimeCache,
10774
+ cacheTags: buildSiteReadTags({ siteId }),
10775
+ prebuildFallback: void 0
10776
+ });
10777
+ }
10778
+ function createContentReadOperations(input) {
10779
+ return {
10780
+ getSiteWithResilience: (params) => readSiteWithResilience(input, params),
10781
+ getPageWithResilience: (params) => readPageWithResilience(input, params)
10782
+ };
10783
+ }
10784
+ //#endregion
10785
+ //#region src/client/publicAppointmentReadOperations.ts
10786
+ function createPublicAppointmentReadOperations(deps) {
10787
+ return {
10788
+ async getPublicBookingServices(params) {
10789
+ const { siteId, ids, signal } = params;
10790
+ if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
10791
+ const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
10792
+ return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
10793
+ const apiParams = {
10794
+ siteId,
10795
+ ...ids && { ids }
10796
+ };
10797
+ return await deps.apiClient({
10798
+ endpoint: "getPublicBookingServices",
10799
+ params: apiParams,
10800
+ options: { signal: requestSignal }
10801
+ });
10802
+ }, {
10803
+ signal,
10804
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
10805
+ });
10806
+ },
10807
+ async getPublicWeeklySlotAvailability(params) {
10808
+ const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
10809
+ if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
10810
+ const cacheKey = [
10811
+ "public-weekly-slot-availability",
10812
+ siteId,
10813
+ serviceId,
10814
+ resourceId ?? "",
10815
+ horizonWeeks ?? "",
10816
+ timezone ?? ""
10817
+ ].join(":");
10818
+ return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
10819
+ const apiParams = {
10820
+ siteId,
10821
+ serviceId,
10822
+ ...resourceId && { resourceId },
10823
+ ...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
10824
+ ...timezone && { timezone }
10825
+ };
10826
+ return await deps.apiClient({
10827
+ endpoint: "getPublicWeeklySlotAvailability",
10828
+ params: apiParams,
10829
+ options: { signal: requestSignal }
10830
+ });
10831
+ }, {
10832
+ signal,
10833
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
10834
+ });
10835
+ }
10836
+ };
10837
+ }
10838
+ //#endregion
10839
+ //#region src/client/publicEventReadOperations.ts
10840
+ function createPublicEventReadOperations(deps) {
10841
+ async function resolveEventSubroute(params, kind) {
10842
+ const { siteId, subject, segment, signal, preview = false } = params;
10843
+ if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
10844
+ const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
10845
+ return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
10846
+ endpoint: "resolveEventSubroute",
10847
+ params: {
10848
+ siteId,
10849
+ kind,
10850
+ subjectKind: subject.kind,
10851
+ subjectId,
10852
+ segment,
10853
+ stage: preview ? "preview" : "published"
10854
+ },
10855
+ options: { signal: requestSignal }
10856
+ }), {
10857
+ signal,
10858
+ preview,
10859
+ cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
10860
+ });
10861
+ }
10862
+ return {
10863
+ async listPublicEventCalendarWindow({ signal, ...params }) {
10864
+ return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
10865
+ endpoint: "listPublicEventCalendarWindow",
10866
+ params: {
10867
+ ...params,
10868
+ limit: params.limit === void 0 ? void 0 : String(params.limit)
10869
+ },
10870
+ options: { signal: requestSignal }
10871
+ }), {
10872
+ signal,
10873
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
10874
+ });
10875
+ },
10876
+ async resolveEventOccurrence(params) {
10877
+ const response = await resolveEventSubroute(params, "event-occurrence");
10878
+ return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
10879
+ },
10880
+ async resolveEventRun(params) {
10881
+ const response = await resolveEventSubroute(params, "event-run");
10882
+ return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
10883
+ }
10884
+ };
10885
+ }
10886
+ //#endregion
10887
+ //#region src/client/combineAbortSignals.ts
10888
+ /** Combine signals into one that aborts when any input aborts. */
10889
+ function combineAbortSignals(...signals) {
10890
+ const controller = new AbortController();
10891
+ for (const signal of signals) {
10892
+ if (signal.aborted) {
10893
+ controller.abort(signal.reason);
10894
+ break;
10895
+ }
10896
+ signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
10897
+ }
10898
+ return controller.signal;
10899
+ }
10900
+ //#endregion
10901
+ //#region src/client/publicLoaderCacheAccess.ts
10902
+ function shouldWrite(cacheEnabled, force) {
10903
+ return cacheEnabled && !force;
10904
+ }
10905
+ /**
10906
+ * Applies the canonical block-loader freshness policy at the SDK fetch seam.
10907
+ *
10908
+ * Callers provide the endpoint identity, but do not opt into live behavior.
10909
+ * This makes a newly-live endpoint bypass memory and fallback caches without a
10910
+ * second method-level wiring change.
10911
+ */
10912
+ function applyPublicLoaderCachePolicy(endpoint, options) {
10913
+ if (!isPublicReadEndpoint(endpoint) || getPublicReadCachePolicy(endpoint).kind !== "live") return options;
10914
+ return {
10915
+ ...options,
10916
+ force: true
10917
+ };
10918
+ }
10919
+ //#endregion
10920
+ //#region src/client/index.ts
10921
+ let prebuildModule = null;
10922
+ function tryRequire(modulePath) {
10923
+ try {
10924
+ const req = new Function("return typeof require === \"function\" ? require : null")();
10925
+ return req ? req(modulePath) : null;
10926
+ } catch {
10927
+ return null;
10928
+ }
10929
+ }
10930
+ function isNodeRuntime() {
10931
+ if (typeof globalThis !== "object" || globalThis === null) return false;
10932
+ return typeof globalThis.process?.versions?.node === "string";
10933
+ }
10934
+ function getPrebuildModule() {
10935
+ if (prebuildModule !== null) return prebuildModule;
10936
+ if (!isNodeRuntime()) return null;
10937
+ try {
10938
+ prebuildModule = tryRequire("../prebuild/loader");
10939
+ return prebuildModule;
10940
+ } catch {
10941
+ return null;
10942
+ }
10943
+ }
10944
+ function mergeDefaultHeaders(defaultHeaders, options) {
10945
+ if (!defaultHeaders || Object.keys(defaultHeaders).length === 0) return options;
10946
+ return {
10947
+ ...options,
10948
+ headers: {
10949
+ ...defaultHeaders,
10950
+ ...Object.fromEntries(new Headers(options?.headers).entries())
10951
+ }
10952
+ };
10953
+ }
10954
+ function withDefaultHeaders(apiClient, defaultHeaders) {
10955
+ return async (params) => apiClient({
10956
+ ...params,
10957
+ options: mergeDefaultHeaders(defaultHeaders, params.options)
10958
+ });
10959
+ }
10960
+ const DEFAULT_BROWSER_TIMEOUT_MS = 5e3;
10961
+ const DEFAULT_SERVER_TIMEOUT_MS = 8e3;
10962
+ const MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS = 50;
10963
+ function isDurableRuntimeCacheTier(cacheTier) {
10964
+ return cacheTier === "durable-fresh" || cacheTier === "durable-stale";
10965
+ }
10966
+ function isDegradedResilienceStatus(source, details) {
10967
+ return source === "stale" || source === "error" || isDurableRuntimeCacheTier(details.cacheTier) && details.error !== void 0;
10968
+ }
10969
+ /**
10970
+ * Generate a unique request ID for tracing
10971
+ */
10972
+ function generateRequestId() {
10973
+ return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
10974
+ }
10975
+ function toRecord(value) {
10976
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
9644
10977
  }
9645
- function parsePublicProductCategorySelector(value) {
9646
- const record = asRecord(typeof value === "string" ? parseJsonValue(value) : value);
9647
- if (!record) return;
9648
- if (record.kind === "category" && isNonEmptyString(record.productCategoryId)) return {
9649
- kind: "category",
9650
- productCategoryId: record.productCategoryId
10978
+ function getRuntimePayloadSiteId(value) {
10979
+ const site = toRecord(value).site;
10980
+ if (!site || typeof site !== "object" || Array.isArray(site)) return null;
10981
+ const id = site.id;
10982
+ return typeof id === "string" && id.trim().length > 0 ? id : null;
10983
+ }
10984
+ function getRiverbankErrorInfo(error) {
10985
+ if (error instanceof RiverbankApiError) return {
10986
+ code: error.code,
10987
+ message: error.message,
10988
+ status: error.status
10989
+ };
10990
+ if (error instanceof Error) return { message: error.message };
10991
+ return { message: String(error) };
10992
+ }
10993
+ function normalizeEntryIdentifierRefs(identifiers) {
10994
+ const trimmed = identifiers.map((identifier) => identifier.trim()).filter((identifier) => identifier.length > 0);
10995
+ if (trimmed.length === 0) return { kind: "empty" };
10996
+ if (trimmed.length > MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS) throw new Error(`getEntriesByIdentifiers() accepts at most ${MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS} identifiers`);
10997
+ const refs = [];
10998
+ const seen = /* @__PURE__ */ new Set();
10999
+ for (const ref of trimmed) {
11000
+ if (seen.has(ref)) continue;
11001
+ seen.add(ref);
11002
+ refs.push(ref);
11003
+ }
11004
+ return {
11005
+ kind: "refs",
11006
+ refs
11007
+ };
11008
+ }
11009
+ function normalizePublicForm(form) {
11010
+ return {
11011
+ id: form.id,
11012
+ slug: form.slug,
11013
+ name: form.name,
11014
+ schema: toRecord(form.schemaJson),
11015
+ settings: toRecord(form.settingsJson),
11016
+ schemaJson: toRecord(form.schemaJson),
11017
+ settingsJson: toRecord(form.settingsJson),
11018
+ createdAt: form.createdAt ?? null,
11019
+ updatedAt: form.updatedAt ?? null,
11020
+ ...form.siteId ? { siteId: form.siteId } : {},
11021
+ ...form.userId ? { userId: form.userId } : {}
11022
+ };
11023
+ }
11024
+ function normalizePublicFormResponse(response) {
11025
+ return { form: response.form ? normalizePublicForm(response.form) : null };
11026
+ }
11027
+ function normalizePublicFormResult(result) {
11028
+ if (isApiError(result)) return result;
11029
+ return {
11030
+ ...result,
11031
+ data: normalizePublicFormResponse(result.data)
11032
+ };
11033
+ }
11034
+ function normalizePublicFormsResponse(response) {
11035
+ return { forms: response.forms.map((form) => normalizePublicForm(form)) };
11036
+ }
11037
+ function normalizePublicFormsResult(result) {
11038
+ if (isApiError(result)) return result;
11039
+ return {
11040
+ ...result,
11041
+ data: normalizePublicFormsResponse(result.data)
11042
+ };
11043
+ }
11044
+ function normalizeBatchBlockLoaderResult(response, requestId) {
11045
+ if (isApiError(response)) return response;
11046
+ const result = response.data.results[requestId];
11047
+ if (!result) throw new Error(`Missing batch block loader result for "${requestId}"`);
11048
+ if (!result.ok) throw new Error(result.error.message);
11049
+ return {
11050
+ ...response,
11051
+ data: result.data
11052
+ };
11053
+ }
11054
+ /**
11055
+ * Check if an error is an AbortError (from AbortController.abort())
11056
+ */
11057
+ function isAbortError(error) {
11058
+ if (error instanceof DOMException && error.name === "AbortError") return true;
11059
+ if (error instanceof Error && error.name === "AbortError") return true;
11060
+ return false;
11061
+ }
11062
+ /**
11063
+ * Determine the network error code based on error type, code, and message.
11064
+ * Uses multiple detection strategies for cross-runtime compatibility:
11065
+ * 1. Error name (TimeoutError, AbortError) - reliable in browsers
11066
+ * 2. Node.js error code (ETIMEDOUT, ENOTFOUND, etc.) - most reliable in Node
11067
+ * 3. Message matching - fallback for edge cases
11068
+ */
11069
+ function getNetworkErrorCode(error) {
11070
+ if (error.name === "TimeoutError" || error.name === "AbortError") return "network:timeout";
11071
+ const nodeError = error;
11072
+ if (nodeError.code) switch (nodeError.code) {
11073
+ case "ETIMEDOUT":
11074
+ case "ESOCKETTIMEDOUT": return "network:timeout";
11075
+ case "ENOTFOUND":
11076
+ case "EAI_AGAIN": return "network:dns_error";
11077
+ case "ECONNREFUSED":
11078
+ case "ECONNRESET":
11079
+ case "EPIPE": return "network:connection_error";
11080
+ }
11081
+ const message = error.message.toLowerCase();
11082
+ if (message.includes("timeout") || message.includes("timed out")) return "network:timeout";
11083
+ if (message.includes("dns") || message.includes("getaddrinfo") || message.includes("enotfound")) return "network:dns_error";
11084
+ return "network:connection_error";
11085
+ }
11086
+ /**
11087
+ * Convert API errors to RiverbankApiError for consistent SDK error handling.
11088
+ * Handles:
11089
+ * - ApiEnvelopeError (from unwrapResponse)
11090
+ * - ApiRequestError (from fetch with HTTP error)
11091
+ * - Network errors (TypeError, etc. - wrapped with status 0)
11092
+ * - AbortError (let propagate raw for consumer detection)
11093
+ */
11094
+ function convertToTypedError(error) {
11095
+ if (isAbortError(error)) throw error;
11096
+ if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
11097
+ code: error.code,
11098
+ message: error.message,
11099
+ requestId: error.requestId,
11100
+ timestamp: error.timestamp,
11101
+ status: error.status,
11102
+ fieldErrors: error.fieldErrors
11103
+ });
11104
+ if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
11105
+ const body = error.body;
11106
+ if (isApiError(body)) {
11107
+ const envelopeError = body.error;
11108
+ throw new RiverbankApiError({
11109
+ ...envelopeError,
11110
+ retryAfterMs: error.retryAfterMs
11111
+ });
11112
+ }
11113
+ }
11114
+ if (error instanceof TypeError || error instanceof Error && !("status" in error)) {
11115
+ const networkError = error;
11116
+ throw new RiverbankApiError({
11117
+ code: getNetworkErrorCode(networkError),
11118
+ message: networkError.message || "Network request failed",
11119
+ requestId: `local-${Date.now()}`,
11120
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
11121
+ status: 0,
11122
+ cause: networkError
11123
+ });
11124
+ }
11125
+ throw error;
11126
+ }
11127
+ /**
11128
+ * Detect API key type from prefix.
11129
+ *
11130
+ * Key prefixes:
11131
+ * - bld_live_sk_* / bld_test_sk_* → 'content' (published content)
11132
+ * - bld_preview_sk_* → 'preview' (draft content)
11133
+ */
11134
+ function detectKeyType(apiKey) {
11135
+ if (apiKey.startsWith("bld_live_sk_") || apiKey.startsWith("bld_test_sk_")) return "content";
11136
+ if (apiKey.startsWith("bld_preview_sk_")) return "preview";
11137
+ return "unknown";
11138
+ }
11139
+ /**
11140
+ * Resolve auth configuration from config, handling backward compatibility.
11141
+ * Throws if neither `auth` nor `apiKey` is provided.
11142
+ */
11143
+ function resolveAuth(config) {
11144
+ if (config.auth) return config.auth;
11145
+ if (config.apiKey) return {
11146
+ type: "api-key",
11147
+ key: config.apiKey
11148
+ };
11149
+ throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
11150
+ }
11151
+ const defaultRiverbankClientDeps = {
11152
+ createBearerAPIClient,
11153
+ createInternalAPIClient
11154
+ };
11155
+ /**
11156
+ * Create a Riverbank CMS client for fetching content
11157
+ *
11158
+ * @example
11159
+ * ```ts
11160
+ * const client = createRiverbankClient({
11161
+ * apiKey: 'bld_live_sk_...',
11162
+ * baseUrl: 'https://dashboard.example.com/api',
11163
+ * });
11164
+ *
11165
+ * const site = await client.getSite({ slug: 'my-site' });
11166
+ * ```
11167
+ */
11168
+ function createRiverbankClient(config) {
11169
+ return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
11170
+ }
11171
+ function createRiverbankClientWithDeps(deps, config) {
11172
+ if (!config.baseUrl) throw new Error("baseUrl is required when creating a Riverbank client. Expected format: https://dashboard.example.com/api (must include /api path)");
11173
+ if (!config.baseUrl.endsWith("/api")) throw new Error(`baseUrl must end with '/api'. Received: ${config.baseUrl}. Expected format: https://dashboard.example.com/api`);
11174
+ const cacheEnabled = config.cache?.enabled ?? true;
11175
+ const cacheTTL = (config.cache?.ttl ?? 300) * 1e3;
11176
+ const cacheMaxSize = config.cache?.maxSize ?? 100;
11177
+ const resilienceEnabled = config.resilience?.enabled ?? true;
11178
+ const staleIfError = config.resilience?.staleIfError ?? true;
11179
+ const staleTtlMs = (config.resilience?.staleTtlSec ?? 300) * 1e3;
11180
+ const requestTimeoutMs = config.resilience?.requestTimeoutMs ?? (typeof window !== "undefined" ? DEFAULT_BROWSER_TIMEOUT_MS : DEFAULT_SERVER_TIMEOUT_MS);
11181
+ const retryConfig = {
11182
+ maxAttempts: config.resilience?.retry?.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts,
11183
+ baseDelayMs: config.resilience?.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
11184
+ maxDelayMs: config.resilience?.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,
11185
+ jitter: config.resilience?.retry?.jitter ?? DEFAULT_RETRY_CONFIG.jitter,
11186
+ retryOn: config.resilience?.retry?.retryOn
11187
+ };
11188
+ const circuitBreakerConfig = {
11189
+ failureThreshold: config.resilience?.circuitBreaker?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
11190
+ resetTimeoutMs: config.resilience?.circuitBreaker?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
11191
+ halfOpenMaxRequests: config.resilience?.circuitBreaker?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
9651
11192
  };
9652
- if (record.kind === "current-category-page" && isNonEmptyString(record.productCategoryEntryId)) return {
9653
- kind: "current-category-page",
9654
- productCategoryEntryId: record.productCategoryEntryId
11193
+ const authConfig = resolveAuth(config);
11194
+ let keyType;
11195
+ switch (authConfig.type) {
11196
+ case "none":
11197
+ keyType = "unknown";
11198
+ break;
11199
+ case "api-key":
11200
+ keyType = detectKeyType(authConfig.key);
11201
+ break;
11202
+ case "bearer":
11203
+ keyType = "preview";
11204
+ break;
11205
+ }
11206
+ 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);
11207
+ const cache = new SimpleCache({
11208
+ maxSize: cacheMaxSize,
11209
+ ttl: cacheTTL,
11210
+ staleTtl: staleTtlMs
11211
+ });
11212
+ const circuitBreaker = new CircuitBreaker(circuitBreakerConfig);
11213
+ const prebuildDir = config.resilience?.prebuildDir;
11214
+ const prebuildMod = prebuildDir ? getPrebuildModule() : null;
11215
+ const prebuildLoader = (prebuildMod?.canUsePrebuild() ?? false) && prebuildMod && prebuildDir ? new prebuildMod.PrebuildLoader({
11216
+ prebuildDir,
11217
+ maxPrebuildAgeSec: config.resilience?.maxPrebuildAgeSec
11218
+ }) : null;
11219
+ let lastStatus = null;
11220
+ let isDegraded = false;
11221
+ /**
11222
+ * Emit a status update and trigger callbacks
11223
+ */
11224
+ function emitStatus(source, data, details) {
11225
+ const status = {
11226
+ source,
11227
+ isPreview: details.isPreview,
11228
+ cacheKey: details.cacheKey,
11229
+ cacheTier: details.cacheTier,
11230
+ durableCache: details.durableCache,
11231
+ error: details.error,
11232
+ staleAgeSec: details.staleAgeSec,
11233
+ prebuildAgeSec: details.prebuildAgeSec,
11234
+ circuit: circuitBreaker.getState(),
11235
+ requestId: details.requestId,
11236
+ durationMs: details.durationMs
11237
+ };
11238
+ lastStatus = status;
11239
+ config.resilience?.onStatusChange?.(status);
11240
+ const nowDegraded = isDegradedResilienceStatus(source, details);
11241
+ if (nowDegraded !== isDegraded) {
11242
+ isDegraded = nowDegraded;
11243
+ config.resilience?.onDegradedMode?.(nowDegraded, status);
11244
+ }
11245
+ return {
11246
+ data,
11247
+ resilience: status
11248
+ };
11249
+ }
11250
+ async function tryPublishedRuntimeCacheFallback(plan, statusDetails, errorInfo) {
11251
+ const reader = config.publishedRuntimeCache?.read;
11252
+ if (!plan || !reader) return null;
11253
+ try {
11254
+ const result = await reader({
11255
+ cacheKey: plan.cacheKey,
11256
+ endpoint: plan.endpoint,
11257
+ payloadSchemaVersion: 4
11258
+ });
11259
+ if (result.kind === "miss") return {
11260
+ kind: "miss",
11261
+ diagnostic: {
11262
+ outcome: "miss",
11263
+ reason: result.reason
11264
+ }
11265
+ };
11266
+ if (result.kind === "error") return {
11267
+ kind: "error",
11268
+ diagnostic: {
11269
+ outcome: "error",
11270
+ error: result.error
11271
+ }
11272
+ };
11273
+ return {
11274
+ kind: "hit",
11275
+ result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
11276
+ error: errorInfo,
11277
+ staleAgeSec: result.staleAgeSec,
11278
+ cacheTier: result.freshness === "fresh" ? "durable-fresh" : "durable-stale"
11279
+ }))
11280
+ };
11281
+ } catch (error) {
11282
+ return {
11283
+ kind: "error",
11284
+ diagnostic: {
11285
+ outcome: "error",
11286
+ error: {
11287
+ kind: "adapter_exception",
11288
+ message: error instanceof Error ? error.message : String(error)
11289
+ }
11290
+ }
11291
+ };
11292
+ }
11293
+ }
11294
+ async function writePublishedRuntimeCache(plan, payload) {
11295
+ const writer = config.publishedRuntimeCache?.write;
11296
+ if (!plan || !writer) return;
11297
+ try {
11298
+ await writer({
11299
+ cacheKey: plan.cacheKey,
11300
+ endpoint: plan.endpoint,
11301
+ normalizedParams: plan.normalizedParams,
11302
+ payload,
11303
+ siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
11304
+ freshTtlSec: plan.freshTtlSec,
11305
+ staleTtlSec: plan.staleTtlSec,
11306
+ payloadSchemaVersion: 4,
11307
+ writeReason: "live_success"
11308
+ });
11309
+ } catch {}
11310
+ }
11311
+ async function resilientFetch(cacheKey, fetcher, options) {
11312
+ const requestId = generateRequestId();
11313
+ const startTime = Date.now();
11314
+ const isPreview = options.preview ?? false;
11315
+ const allowFallbacks = !options.force;
11316
+ const statusDetails = (extra = {}) => ({
11317
+ requestId,
11318
+ cacheKey,
11319
+ isPreview,
11320
+ durationMs: Date.now() - startTime,
11321
+ ...extra
11322
+ });
11323
+ if (cacheEnabled && !options.force) {
11324
+ const fresh = cache.getFresh(cacheKey);
11325
+ if (fresh !== null) return emitStatus("cache", fresh, statusDetails({ cacheTier: "memory-fresh" }));
11326
+ }
11327
+ if (resilienceEnabled && circuitBreaker.isOpen()) {
11328
+ if (allowFallbacks && !isPreview && staleIfError) {
11329
+ const stale = cache.getStale(cacheKey);
11330
+ if (stale) return emitStatus("stale", stale.value, statusDetails({
11331
+ staleAgeSec: stale.staleAgeSec,
11332
+ cacheTier: "memory-stale",
11333
+ error: {
11334
+ code: "circuit_open",
11335
+ message: "Circuit breaker is open"
11336
+ }
11337
+ }));
11338
+ }
11339
+ const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, {
11340
+ code: "circuit_open",
11341
+ message: "Circuit breaker is open"
11342
+ }) : null;
11343
+ const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
11344
+ if (durableFallback?.kind === "hit") return durableFallback.result;
11345
+ if (allowFallbacks && !isPreview && options.prebuildFallback) {
11346
+ const prebuildResult = options.prebuildFallback();
11347
+ if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
11348
+ prebuildAgeSec: prebuildResult.prebuildAgeSec,
11349
+ cacheTier: "prebuild",
11350
+ durableCache,
11351
+ error: {
11352
+ code: "circuit_open",
11353
+ message: "Circuit breaker is open"
11354
+ }
11355
+ }));
11356
+ }
11357
+ const circuitState = circuitBreaker.getState();
11358
+ emitStatus("error", null, statusDetails({
11359
+ durableCache,
11360
+ error: {
11361
+ code: "circuit_open",
11362
+ message: "Circuit breaker is open"
11363
+ }
11364
+ }));
11365
+ throw new CircuitOpenError(circuitState);
11366
+ }
11367
+ try {
11368
+ let data;
11369
+ if (resilienceEnabled) {
11370
+ if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
11371
+ data = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
11372
+ const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
11373
+ try {
11374
+ return unwrapResponse(await fetcher(combinedSignal));
11375
+ } catch (error) {
11376
+ convertToTypedError(error);
11377
+ }
11378
+ }, {
11379
+ ...retryConfig,
11380
+ requestTimeoutMs
11381
+ });
11382
+ circuitBreaker.recordSuccess();
11383
+ } else try {
11384
+ data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
11385
+ } catch (error) {
11386
+ convertToTypedError(error);
11387
+ }
11388
+ if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, { tags: options.cacheTags });
11389
+ if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
11390
+ return emitStatus("live", data, statusDetails());
11391
+ } catch (error) {
11392
+ if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
11393
+ if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
11394
+ const stale = cache.getStale(cacheKey);
11395
+ if (stale) {
11396
+ const errorInfo = getRiverbankErrorInfo(error);
11397
+ return emitStatus("stale", stale.value, statusDetails({
11398
+ staleAgeSec: stale.staleAgeSec,
11399
+ cacheTier: "memory-stale",
11400
+ error: errorInfo
11401
+ }));
11402
+ }
11403
+ }
11404
+ const errorInfo = getRiverbankErrorInfo(error);
11405
+ const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
11406
+ const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
11407
+ if (durableFallback?.kind === "hit") return durableFallback.result;
11408
+ if (allowFallbacks && !isPreview && options.prebuildFallback) {
11409
+ const prebuildResult = options.prebuildFallback();
11410
+ if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
11411
+ prebuildAgeSec: prebuildResult.prebuildAgeSec,
11412
+ cacheTier: "prebuild",
11413
+ durableCache,
11414
+ error: errorInfo
11415
+ }));
11416
+ }
11417
+ throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
11418
+ error: errorInfo,
11419
+ durableCache
11420
+ })).resilience);
11421
+ }
11422
+ }
11423
+ async function resilientFetchData(policyEndpoint, cacheKey, fetcher, options) {
11424
+ return (await resilientFetch(cacheKey, fetcher, applyPublicLoaderCachePolicy(policyEndpoint, options))).data;
11425
+ }
11426
+ const contentReads = createContentReadOperations({
11427
+ apiClient,
11428
+ resilientFetch,
11429
+ prebuildLoader
11430
+ });
11431
+ const eventReads = createPublicEventReadOperations({
11432
+ apiClient,
11433
+ resilientFetchData
11434
+ });
11435
+ const publicAppointmentReads = createPublicAppointmentReadOperations({
11436
+ apiClient,
11437
+ resilientFetchData
11438
+ });
11439
+ async function getEntriesInternal(params) {
11440
+ const { siteId, preview = false, signal } = params;
11441
+ const request = buildEntryListReadRequest(params);
11442
+ return resilientFetchData("listPublishedEntries", request.cacheKey, (sig) => apiClient({
11443
+ endpoint: "listPublishedEntries",
11444
+ params: request.params,
11445
+ options: { signal: sig }
11446
+ }), {
11447
+ preview,
11448
+ signal,
11449
+ cacheTags: buildPublicReadMemoryCacheTags("listPublishedEntries", { siteId }),
11450
+ prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
11451
+ });
11452
+ }
11453
+ return {
11454
+ async getSite(params) {
11455
+ return (await contentReads.getSiteWithResilience(params)).data;
11456
+ },
11457
+ async getSiteWithResilience(params) {
11458
+ return contentReads.getSiteWithResilience(params);
11459
+ },
11460
+ async getPage(params) {
11461
+ return (await contentReads.getPageWithResilience(params)).data;
11462
+ },
11463
+ async getPageWithResilience(params) {
11464
+ return contentReads.getPageWithResilience(params);
11465
+ },
11466
+ async getEntries(params) {
11467
+ return getEntriesInternal(params);
11468
+ },
11469
+ async getEntriesByIdentifiers(params) {
11470
+ const { siteId, contentType, identifiers, preview, signal } = params;
11471
+ const normalized = normalizeEntryIdentifierRefs(identifiers);
11472
+ if (normalized.kind === "empty") return { entries: [] };
11473
+ return getEntriesInternal({
11474
+ siteId,
11475
+ contentType,
11476
+ preview,
11477
+ signal,
11478
+ mode: "manual",
11479
+ entryIds: normalized.refs
11480
+ });
11481
+ },
11482
+ async getEntry(params) {
11483
+ const { siteId, contentType, slug, signal } = params;
11484
+ return resilientFetchData("getPublishedEntryPreview", `entry:${siteId}:${contentType}:${slug}`, async (sig) => {
11485
+ return await apiClient({
11486
+ endpoint: "getPublishedEntryPreview",
11487
+ params: {
11488
+ siteId,
11489
+ type: contentType,
11490
+ slug
11491
+ },
11492
+ options: { signal: sig }
11493
+ });
11494
+ }, {
11495
+ signal,
11496
+ cacheTags: buildPublicReadMemoryCacheTags("getPublishedEntryPreview", { siteId })
11497
+ });
11498
+ },
11499
+ async getPublicFormById(params) {
11500
+ const { formId, siteId, signal } = params;
11501
+ if (!formId || !siteId) throw new Error("getPublicFormById() requires formId and siteId");
11502
+ return resilientFetchData("getPublicFormById", `public-form:${siteId}:${formId}`, async (sig) => {
11503
+ return normalizePublicFormResult(await apiClient({
11504
+ endpoint: "getPublicFormById",
11505
+ params: {
11506
+ formId,
11507
+ siteId
11508
+ },
11509
+ options: { signal: sig }
11510
+ }));
11511
+ }, {
11512
+ signal,
11513
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicFormById", {
11514
+ siteId,
11515
+ formId
11516
+ })
11517
+ });
11518
+ },
11519
+ async getForms(params) {
11520
+ const { siteId, signal } = params;
11521
+ if (!siteId) throw new Error("getForms() requires siteId");
11522
+ return resilientFetchData("listPublicForms", `forms:${siteId}`, async (sig) => {
11523
+ return normalizePublicFormsResult(await apiClient({
11524
+ endpoint: "listPublicForms",
11525
+ params: { siteId },
11526
+ options: { signal: sig }
11527
+ }));
11528
+ }, {
11529
+ signal,
11530
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicForms", { siteId }),
11531
+ prebuildFallback: prebuildLoader ? () => {
11532
+ const result = prebuildLoader.loadForms();
11533
+ if (result) return {
11534
+ data: { forms: result.data.map((form) => ({
11535
+ id: form.id,
11536
+ slug: form.slug,
11537
+ name: form.name,
11538
+ schema: form.schema,
11539
+ settings: form.settings,
11540
+ schemaJson: form.schema,
11541
+ settingsJson: form.settings,
11542
+ createdAt: null,
11543
+ updatedAt: null
11544
+ })) },
11545
+ prebuildAgeSec: result.prebuildAgeSec
11546
+ };
11547
+ return null;
11548
+ } : void 0
11549
+ });
11550
+ },
11551
+ ...publicAppointmentReads,
11552
+ async listPublicEvents(params) {
11553
+ const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, detailLevel, readProfile, seriesId, includeOccurrenceId, signal } = params;
11554
+ if (!siteId) throw new Error("listPublicEvents() requires siteId");
11555
+ return resilientFetchData("listPublicEvents", `public-events:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${detailLevel ?? ""}:${readProfile ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
11556
+ return await apiClient({
11557
+ endpoint: "listPublicEvents",
11558
+ params: {
11559
+ siteId,
11560
+ ...typeof limit === "number" && { limit: String(limit) },
11561
+ ...from && { from },
11562
+ ...to && { to },
11563
+ ...afterStartsAt && { afterStartsAt },
11564
+ ...afterId && { afterId },
11565
+ ...stage && { stage },
11566
+ ...categoryIds && { categoryIds },
11567
+ ...venueId && { venueId },
11568
+ ...staffMemberId && { staffMemberId },
11569
+ ...kind && { kind },
11570
+ ...eventSurface && { eventSurface },
11571
+ ...eventPresets && { eventPresets },
11572
+ ...scheduleScope && { scheduleScope },
11573
+ ...detailLevel && { detailLevel },
11574
+ ...readProfile && { readProfile },
11575
+ ...seriesId && { seriesId },
11576
+ ...includeOccurrenceId && { includeOccurrenceId }
11577
+ },
11578
+ options: { signal: sig }
11579
+ });
11580
+ }, {
11581
+ signal,
11582
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicEvents", { siteId })
11583
+ });
11584
+ },
11585
+ async getPublicEventDetails(params) {
11586
+ const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, seriesId, includeOccurrenceId, signal } = params;
11587
+ if (!siteId) throw new Error("getPublicEventDetails() requires siteId");
11588
+ return resilientFetchData("getPublicEventDetails", `public-event-details:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
11589
+ const requestId = "eventDetails";
11590
+ return normalizeBatchBlockLoaderResult(await apiClient({
11591
+ endpoint: "batchBlockLoaders",
11592
+ params: {
11593
+ siteId,
11594
+ ...stage && { stage }
11595
+ },
11596
+ body: { requests: [{
11597
+ id: requestId,
11598
+ endpoint: "getPublicEventDetails",
11599
+ params: {
11600
+ ...typeof limit === "number" && { limit: String(limit) },
11601
+ ...from && { from },
11602
+ ...to && { to },
11603
+ ...afterStartsAt && { afterStartsAt },
11604
+ ...afterId && { afterId },
11605
+ ...categoryIds && { categoryIds },
11606
+ ...venueId && { venueId },
11607
+ ...staffMemberId && { staffMemberId },
11608
+ ...kind && { kind },
11609
+ ...eventSurface && { eventSurface },
11610
+ ...eventPresets && { eventPresets },
11611
+ ...scheduleScope && { scheduleScope },
11612
+ ...seriesId && { seriesId },
11613
+ ...includeOccurrenceId && { includeOccurrenceId }
11614
+ }
11615
+ }] },
11616
+ options: { signal: sig }
11617
+ }), requestId);
11618
+ }, {
11619
+ signal,
11620
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicEventDetails", { siteId })
11621
+ });
11622
+ },
11623
+ async listPublicTeamMembers(params) {
11624
+ const { siteId, stage, signal } = params;
11625
+ if (!siteId) throw new Error("listPublicTeamMembers() requires siteId");
11626
+ return resilientFetchData("listPublicTeamMembers", `public-team-members:${siteId}:${stage ?? ""}`, async (sig) => {
11627
+ return await apiClient({
11628
+ endpoint: "listPublicTeamMembers",
11629
+ params: {
11630
+ siteId,
11631
+ ...stage && { stage }
11632
+ },
11633
+ options: { signal: sig }
11634
+ });
11635
+ }, {
11636
+ signal,
11637
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicTeamMembers", { siteId })
11638
+ });
11639
+ },
11640
+ async listPublicProducts(params) {
11641
+ const { siteId, stage, categorySelector, signal } = params;
11642
+ if (!siteId) throw new Error("listPublicProducts() requires siteId");
11643
+ const selectorKey = categorySelector ? categorySelector.kind === "category" ? `category:${categorySelector.productCategoryId}` : `current-category-page:${categorySelector.productCategoryEntryId}` : "";
11644
+ return resilientFetchData("listPublicProducts", `public-products:${siteId}:${stage ?? ""}:${selectorKey}`, async (sig) => {
11645
+ return await apiClient({
11646
+ endpoint: "listPublicProducts",
11647
+ params: {
11648
+ siteId,
11649
+ ...stage && { stage },
11650
+ ...encodePublicProductCategorySelector(categorySelector)
11651
+ },
11652
+ options: { signal: sig }
11653
+ });
11654
+ }, {
11655
+ signal,
11656
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicProducts", { siteId })
11657
+ });
11658
+ },
11659
+ async listPublicPasses(params) {
11660
+ const { siteId, categories, signal } = params;
11661
+ if (!siteId) throw new Error("listPublicPasses() requires siteId");
11662
+ return resilientFetchData("listPublicPasses", `public-passes:${siteId}:${categories ?? ""}`, async (sig) => {
11663
+ return await apiClient({
11664
+ endpoint: "listPublicPasses",
11665
+ params: {
11666
+ siteId,
11667
+ ...categories && { categories }
11668
+ },
11669
+ options: { signal: sig }
11670
+ });
11671
+ }, {
11672
+ signal,
11673
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicPasses", { siteId })
11674
+ });
11675
+ },
11676
+ async listPublicMemberships(params) {
11677
+ const { siteId, categories, signal } = params;
11678
+ if (!siteId) throw new Error("listPublicMemberships() requires siteId");
11679
+ return resilientFetchData("listPublicMemberships", `public-memberships:${siteId}:${categories ?? ""}`, async (sig) => {
11680
+ return await apiClient({
11681
+ endpoint: "listPublicMemberships",
11682
+ params: {
11683
+ siteId,
11684
+ ...categories && { categories }
11685
+ },
11686
+ options: { signal: sig }
11687
+ });
11688
+ }, {
11689
+ signal,
11690
+ cacheTags: buildPublicReadMemoryCacheTags("listPublicMemberships", { siteId })
11691
+ });
11692
+ },
11693
+ ...eventReads,
11694
+ async checkRedirect(params) {
11695
+ const { siteId, path, signal } = params;
11696
+ if (!siteId || !path) throw new Error("checkRedirect() requires siteId and path");
11697
+ return resilientFetchData("checkRedirect", `redirect:${siteId}:${path}`, async (sig) => {
11698
+ return await apiClient({
11699
+ endpoint: "checkRedirect",
11700
+ params: {
11701
+ site: siteId,
11702
+ path
11703
+ },
11704
+ options: { signal: sig }
11705
+ });
11706
+ }, {
11707
+ signal,
11708
+ cacheTags: buildPublicReadMemoryCacheTags("checkRedirect", { site: siteId })
11709
+ });
11710
+ },
11711
+ async resolveRouteOutcome(params) {
11712
+ const { siteId, path, preview = false, signal } = params;
11713
+ if (!siteId || !path) throw new Error("resolveRouteOutcome() requires siteId and path");
11714
+ return unwrapResponse(await apiClient({
11715
+ endpoint: "resolveRouteOutcome",
11716
+ params: {
11717
+ siteId,
11718
+ path,
11719
+ preview: String(preview)
11720
+ },
11721
+ options: { signal }
11722
+ }));
11723
+ },
11724
+ async resolveRouteDecision(params) {
11725
+ const { siteId, path, preview = false, signal } = params;
11726
+ if (!siteId || !path) throw new Error("resolveRouteDecision() requires siteId and path");
11727
+ return unwrapResponse(await apiClient({
11728
+ endpoint: "resolveRouteDecision",
11729
+ params: {
11730
+ siteId,
11731
+ path,
11732
+ preview: String(preview)
11733
+ },
11734
+ options: { signal }
11735
+ }));
11736
+ },
11737
+ async getAllPublishedRoutes(params) {
11738
+ const { siteId, signal } = params;
11739
+ if (!siteId) throw new Error("getAllPublishedRoutes() requires siteId");
11740
+ return resilientFetchData("getPublicRoutableContent", `routable-content:${siteId}:published`, async (sig) => {
11741
+ return await apiClient({
11742
+ endpoint: "getPublicRoutableContent",
11743
+ params: {
11744
+ siteId,
11745
+ publishedOnly: "true"
11746
+ },
11747
+ options: { signal: sig }
11748
+ });
11749
+ }, {
11750
+ signal,
11751
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicRoutableContent", { siteId })
11752
+ });
11753
+ },
11754
+ async getSitemapRoutes(params) {
11755
+ const { siteId, page, pageSize, signal } = params;
11756
+ if (!siteId) throw new Error("getSitemapRoutes() requires siteId");
11757
+ return resilientFetchData("getPublicSitemapRoutes", `sitemap:${siteId}:${page ?? 1}:${pageSize ?? "default"}`, async (sig) => {
11758
+ return await apiClient({
11759
+ endpoint: "getPublicSitemapRoutes",
11760
+ params: {
11761
+ siteId,
11762
+ ...page ? { page: String(page) } : {},
11763
+ ...pageSize ? { pageSize: String(pageSize) } : {}
11764
+ },
11765
+ options: { signal: sig }
11766
+ });
11767
+ }, {
11768
+ signal,
11769
+ cacheTags: buildPublicReadMemoryCacheTags("getPublicSitemapRoutes", { siteId })
11770
+ });
11771
+ },
11772
+ clearCacheForTags(tags) {
11773
+ cache.clearForTags(tags);
11774
+ },
11775
+ clearCache() {
11776
+ cache.clear();
11777
+ },
11778
+ getKeyType() {
11779
+ return keyType;
11780
+ },
11781
+ getLastEmittedStatus() {
11782
+ return lastStatus;
11783
+ },
11784
+ getCircuitState() {
11785
+ return circuitBreaker.getState();
11786
+ },
11787
+ getBaseUrl() {
11788
+ return config.baseUrl;
11789
+ }
9655
11790
  };
9656
11791
  }
9657
11792
  //#endregion
9658
- export { isPublicReadEndpoint as _, setSdkVersion as a, isApiError as c, TAG_TEMPLATES as d, buildPublicReadMemoryCacheTags as f, getPublicReadCachePolicy as g, isSupportedLoaderEndpoint as h, createInternalAPIClient as i, unwrapResponse as l, SUPPORTED_LOADER_ENDPOINTS as m, parsePublicProductCategorySelector as n, ApiRequestError as o, buildSiteReadTags as p, createBearerAPIClient as r, ApiEnvelopeError as s, encodePublicProductCategorySelector as t, PUBLIC_READ_ENDPOINT_DEFINITIONS as u, publicReadFreshnessSeconds as v };
11793
+ 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 };