@riverbankcms/sdk 0.165.0 → 0.167.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.
- package/CHANGELOG.md +7 -0
- package/README.md +5 -0
- package/dist/_dts/{BlocksIslandsHydrator-CdsSMQEv.d.ts → BlocksIslandsHydrator-Dgb-ptph.d.ts} +1 -1
- package/dist/_dts/{Page-D6gp2Ipb.d.ts → Page-Bs3WxFgr.d.ts} +20 -258
- package/dist/_dts/{SdkPreviewMode-DNXAvnet.d.ts → SdkPreviewMode-DtUCsaHY.d.ts} +26 -3
- package/dist/_dts/{client-BkkExozE.d.ts → client-CwsI23pj.d.ts} +13 -1
- package/dist/_dts/{content-types-CXNAD7ef.d.ts → content-types-CAeP_-cV.d.ts} +3 -3
- package/dist/_dts/{contracts-XRXhbLWP.d.ts → contracts-BXHCiF-b.d.ts} +8 -5
- package/dist/_dts/{footerPageOutline-BP2bJYdY.d.ts → footerPageOutline-Bb2gbppW.d.ts} +6 -6
- package/dist/_dts/{generatePageMetadata-DcMtbztV.d.ts → generatePageMetadata-DaBBDx7M.d.ts} +2 -2
- package/dist/_dts/{index-DKNEgSOS.d.ts → index-5_jf52sZ.d.ts} +2 -2
- package/dist/_dts/{index-CQfJhOEA.d.ts → index-C20yUyob.d.ts} +1 -1
- package/dist/_dts/{index-CRRiddNp.d.ts → index-CS6b1B-c.d.ts} +4 -4
- package/dist/_dts/{index-B4ozSzFP.d.ts → index-ChpjHK0U.d.ts} +9737 -8316
- package/dist/_dts/{index-BdkHhyf8.d.ts → index-D7EbliE3.d.ts} +1 -1
- package/dist/_dts/{index-RXkE3a7M.d.ts → index-DeHDwMfu.d.ts} +4 -3
- package/dist/_dts/{index-DAPTSmBM.d.ts → index-RugyUnqR.d.ts} +2499 -2218
- package/dist/_dts/{index-C_3kdrUb.d.ts → index-bDln38Hm.d.ts} +2 -2
- package/dist/_dts/{loadContent-B9vJMq3s.d.ts → loadContent-CTqcL7CS.d.ts} +9 -6
- package/dist/_dts/resolveBlockData-C3s9WMPs.d.ts +136 -0
- package/dist/_dts/{resolvePageContent-DIQyYUi-.d.ts → resolvePageContent-JPwgRxwh.d.ts} +3 -2
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +9 -6
- package/dist/_dts/sdk/src/config/index.d.ts +6 -6
- package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
- package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
- package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +20 -0
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +2 -0
- package/dist/_dts/sdk/src/data/types.d.ts +54 -0
- package/dist/_dts/sdk/src/index.d.ts +8 -8
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +6 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
- package/dist/_dts/sdk/src/next/index.d.ts +9 -8
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +36 -48
- package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +2 -0
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +3 -0
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +260 -0
- package/dist/_dts/sdk/src/rendering/index.d.ts +8 -7
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +3 -3
- package/dist/_dts/{themeAdmission-D_qtGYAT.d.ts → sdk/src/rendering/themeAdmission.d.ts} +3 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
- package/dist/_dts/sdk/src/server.d.ts +7 -5
- package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
- package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
- package/dist/_dts/{types-BDF73NzM.d.ts → types-BlaCuPLr.d.ts} +2 -2
- package/dist/_dts/{types-Cl0nP6al.d.ts → types-CwtTcaQP.d.ts} +3 -3
- package/dist/_dts/{types-mstFvhK4.d.ts → types-D-WElMCy.d.ts} +8 -7
- package/dist/_dts/{validation-DVWqSvjK.d.ts → validation-Y5wD9fGK.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-CzKpH9Pm.mjs → BlocksIslandsHydrator-DFqkx158.mjs} +31 -24
- package/dist/client/{BookingMailingListNote-rUqsBN7L.mjs → BookingMailingListNote-CCVXX1LN.mjs} +2 -2
- package/dist/client/{CalendarNavigationChevron-YGzw2IPB.mjs → CalendarNavigationChevron-DQwJ7BPx.mjs} +167 -18
- package/dist/client/{CheckboxChoice-DlTC4J2a.mjs → CheckboxChoice-CZ-anOqV.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-D2LyS_Bi.mjs → DemoBookingPortalAccess-DdkY86qI.mjs} +6 -6
- package/dist/client/{DemoPortalSignInLink-BaFg2Uit.mjs → DemoPortalSignInLink-B9YrzZt2.mjs} +1 -1
- package/dist/client/{EventCalendar.client-tRrhPscX.mjs → EventCalendar.client-DAeQPV76.mjs} +11 -30
- package/dist/client/{EventCombined.client-6cfAVtnZ.mjs → EventCombined.client-Bus9R0bj.mjs} +137 -61
- package/dist/client/{EventEmbeddedCheckoutStep-CDNUpI0S.mjs → EventEmbeddedCheckoutStep-D_14yqAU.mjs} +27 -2
- package/dist/client/{EventItem-dILw2PN_.mjs → EventItem-DPBLjGwj.mjs} +75 -13
- package/dist/client/{EventListWeekNavigation-ClgLtjNY.mjs → EventListWeekNavigation-D6cwU82_.mjs} +1 -1
- package/dist/client/{EventListing.client-BNueAHmU.mjs → EventListing.client-Bogi_SnJ.mjs} +3 -3
- package/dist/client/{EventListing.view-DtVbKVkt.mjs → EventListing.view-CEumpN7i.mjs} +35 -51
- package/dist/client/{EventRegistrationPayment-CzkG0NSJ.mjs → EventRegistrationPayment-CIQw6vNy.mjs} +113 -11
- package/dist/client/{LocationMapActions-zWQsJhE5.mjs → LocationMapActions-BVO-qx4q.mjs} +2 -2
- package/dist/client/{MapDrawingSvg-D1AO_o4h.mjs → MapDrawingSvg-CcGaFawl.mjs} +22 -2
- package/dist/client/{Page-DUr2YhFR.mjs → Page-D4_H_u9V.mjs} +23892 -32266
- package/dist/client/{ProtectedSubmitButton-2fJqT_NR.mjs → ProtectedSubmitButton-8DuDw2ag.mjs} +1 -1
- package/dist/client/{StepIndicator-udNHcpOT.mjs → StepIndicator-Dptantmg.mjs} +3 -3
- package/dist/client/{TabBarFragment-C_kt-PXh.mjs → TabBarFragment-BxEGsKUx.mjs} +19 -19
- package/dist/client/{ThemedButton-Cfbo1bfh.mjs → ThemedButton-8jUc02mZ.mjs} +64 -2
- package/dist/client/{accordion-3CYNWzTS.mjs → accordion--EUHmEGa.mjs} +1 -1
- package/dist/client/{booking-form.client-BSbWgLyx.mjs → booking-form.client-BCXwOnhc.mjs} +19 -14
- package/dist/client/{bookingForm-2MoFBWSt.mjs → bookingForm-sHHcdism.mjs} +4 -4
- package/dist/client/bookings.mjs +6 -6
- package/dist/client/{carousel-Cu5mcpO-.mjs → carousel-Cp9xPBFZ.mjs} +2 -2
- package/dist/client/{carousel.client-CQLV8_Al.mjs → carousel.client-BO7sCEpH.mjs} +1 -1
- package/dist/client/{cart-CDc6x9cR.mjs → cart-CCZZC-Lq.mjs} +3 -3
- package/dist/client/{cart.client-BWS2r5Ef.mjs → cart.client-B7JfA19I.mjs} +1 -1
- package/dist/client/{checkout-CkxPqSwD.mjs → checkout-CipmYL4A.mjs} +3 -3
- package/dist/client/{checkout.client-DJfomKQc.mjs → checkout.client-DraalWdH.mjs} +1 -1
- package/dist/client/client.mjs +9550 -17
- package/dist/client/{context-CBV21-9L.mjs → context-Cv3QHjAF.mjs} +11 -6
- package/dist/client/{cta-Bw-al3cs.mjs → cta-P2vJVTEn.mjs} +45 -28
- package/dist/client/{dateFormatting-CFIUJ4Uf.mjs → dateFormatting-D8D47VT4.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-D0veHJyi.mjs → demoPortalMagicLink-CXWZoV-d.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-CEqqq92r.mjs → enhanceHeaderSection-BkAro1DJ.mjs} +4 -4
- package/dist/client/{event-details.client-Bk2kQ7ax.mjs → event-details.client-dLmyuPap.mjs} +2 -2
- package/dist/client/{event-registration.client-QMqtIywj.mjs → event-registration.client-BEhC2_-Y.mjs} +34 -20
- package/dist/client/{eventCalendar-BTDTMosr.mjs → eventCalendar-FBMS2Cpb.mjs} +4 -4
- package/dist/client/{eventCombined-BC7a709c.mjs → eventCombined-BrBhUvGe.mjs} +4 -4
- package/dist/client/{eventDetails-DL08GpUc.mjs → eventDetails-C7WUrbZ2.mjs} +2 -2
- package/dist/client/{eventListing-BfzuEQp_.mjs → eventListing-Bih-BgQM.mjs} +4 -4
- package/dist/client/{eventRegistration-Lfyzh1Ab.mjs → eventRegistration-DfTlqGbl.mjs} +4 -4
- package/dist/client/{form-L-xZOBUS.mjs → form-Bw1uuiUs.mjs} +3 -3
- package/dist/client/{form.client-BtpK3TZW.mjs → form.client-pZ-9gN33.mjs} +5 -5
- package/dist/client/{form.parts-Djos5Un4.mjs → form.parts-PXlu6XQO.mjs} +3 -3
- package/dist/client/{formatDate-DGmrm7YB.mjs → formatDate-DI3DP48e.mjs} +1 -1
- package/dist/client/gifting/client.mjs +3 -4
- package/dist/client/{headerSection-f16OGkz-.mjs → headerSection-BpJYUMd6.mjs} +2 -2
- package/dist/client/{mediaAssets-DHAmrVIi.mjs → mediaAssets-DpPauppt.mjs} +1 -1
- package/dist/client/{mediaContext-CwT6ZOm7.mjs → mediaContext-BLo4NtjP.mjs} +25 -19
- package/dist/client/{newsletter-form.client-DpHNZc7k.mjs → newsletter-form.client-CSoP0cGR.mjs} +6 -6
- package/dist/client/{newsletter-form.parts-CLGH20PL.mjs → newsletter-form.parts-DDbX_Sj0.mjs} +2 -2
- package/dist/client/{newsletterForm-BEU0Ocu9.mjs → newsletterForm-vCxYRar_.mjs} +3 -3
- package/dist/client/{noop-CQU7tiMg.mjs → noop-ByVtIWf4.mjs} +420 -170
- package/dist/client/portal/client.mjs +13 -14
- package/dist/client/{product-detail.client-Be-om1BT.mjs → product-detail.client-7Pi6avM-.mjs} +1 -1
- package/dist/client/{product-list.client-DR7hD5Vs.mjs → product-list.client-DEad-Pma.mjs} +1 -1
- package/dist/client/{productDetail-BD42UOmG.mjs → productDetail-G1SMXG13.mjs} +3 -3
- package/dist/client/{productList-CSk8sXCl.mjs → productList-B21TGdpT.mjs} +3 -3
- package/dist/client/{propsDecoder-C_Y6VYnF.mjs → propsDecoder-B3vIBkex.mjs} +4 -5
- package/dist/client/{registry.server-CIKtTsCl.mjs → registry.server-B8aQhJpO.mjs} +399 -473
- package/dist/client/rendering/client.mjs +29 -28
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +70 -8
- package/dist/client/{richText-coerce-spWtx86G.mjs → richText-coerce-DHkBtO0G.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-CROHPlYS.mjs → routeIslandApiConfig-DbHX4JOS.mjs} +1 -1
- package/dist/client/{shop-commerce-CDUohm_2.mjs → shop-commerce-B2UmrQg_.mjs} +12 -12
- package/dist/client/{shop-commerce-store-B9nw4lRP.mjs → shop-commerce-store-B7n-Z7nY.mjs} +1 -1
- package/dist/client/{shop-DscvMz86.mjs → shop-mqyoOvOK.mjs} +3 -3
- package/dist/client/{shop.client-M3kNsVPi.mjs → shop.client-BH-BBnA9.mjs} +13 -13
- package/dist/client/{shop.interactive-BGmkdIAZ.mjs → shop.interactive-mdM3UMWG.mjs} +74 -36
- package/dist/client/{shopShared-BdWp6LHa.mjs → shopShared-CXF5wxdg.mjs} +2 -2
- package/dist/client/site-styles-CMCUxsIM.mjs +3 -0
- package/dist/{preview-next/client/ThemedButton-Dc6aJ34Z.mjs → client/site-styles-D56hT2u1.mjs} +26000 -16565
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/src-DjnxOjXG.mjs +217 -0
- package/dist/client/surfaceTransportMarker-BXepAVF6.mjs +152 -0
- package/dist/client/{timetableModel-Dynh5-j4.mjs → timetableModel-CrC80EOG.mjs} +13 -140
- package/dist/client/types-sF-IrGQr.mjs +633 -0
- package/dist/client/{useAvailableSlots-Cw9paRPY.mjs → useAvailableSlots-C4LOaI_Z.mjs} +8 -5
- package/dist/client/{useBookingNowIso-C9SF2rC6.mjs → useBookingNowIso-BDmWkYUW.mjs} +1 -1
- package/dist/client/{useDiscountApply-B-QJfBg0.mjs → useDiscountApply-6Q0nToVA.mjs} +3 -3
- package/dist/client/{useDiscountCodeUi-Uvum8q9d.mjs → useDiscountCodeUi-CM-DTX5X.mjs} +1 -1
- package/dist/client/{useEventPagination-BfM3xk6j.mjs → useEventPagination-Bcs89BR5.mjs} +9 -9
- package/dist/client/{view-DlkCDfuN.mjs → view-BN-fxyfq.mjs} +287 -232
- package/dist/client/{view-DXOuduIr.mjs → view-Dh2tGoS0.mjs} +4 -4
- package/dist/client/{wizardSteps-DManVJpc.mjs → wizardSteps-DtkhwKXK.mjs} +468 -149
- package/dist/preview-next/before-render.mjs +3 -140
- package/dist/preview-next/client/ArrangementLookControls-D4VjPs-r.mjs +31197 -0
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-Die6Y25O.mjs → EventEmbeddedCheckoutStep-C_h1cMYm.mjs} +33 -4
- package/dist/preview-next/client/{LocationPickerEnvironment-Bp4BHLCL.mjs → LocationPickerEnvironment-D56RD3e_.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-Cb0JhM9p.mjs → MapLibreEditMap-DFnyCckr.mjs} +2 -2
- package/dist/preview-next/client/PreviewEditorSidebar-Ckr2zk_L.mjs +37247 -0
- package/dist/preview-next/client/{PreviewEditorUI-CxwlLBGw.mjs → PreviewEditorUI-KOZgw_gS.mjs} +45 -17
- package/dist/preview-next/client/PreviewShell-CyO2V4kB.mjs +4757 -0
- package/dist/preview-next/client/SdkPreviewModeRuntime-DW3uKvNF.mjs +4258 -0
- package/dist/preview-next/client/SiteChromeCustomizeButton-CU9VD-7O.mjs +72202 -0
- package/dist/preview-next/client/ThemedButton-C0dgGJ5k.mjs +2006 -0
- package/dist/preview-next/client/{lucide-react-CqxuVAyz.mjs → lucide-react-CPBCf6QT.mjs} +15 -2
- package/dist/preview-next/client/previewAssistantSlot-DBi-WybM.mjs +112193 -0
- package/dist/preview-next/client/{previewChromeSurface-yuwnDP3B.mjs → previewChromeSurface-BhkUJst9.mjs} +90 -28
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/sdk-runtime-BjCb6lOn.mjs +5 -0
- package/dist/preview-next/client/{editorStatusDecision-DR4BBKhy.mjs → useAutosaveStatus-CKxTaC3j.mjs} +40 -3
- package/dist/preview-next/client/useBlockCustomizeControls-B7MLTjBX.mjs +2633 -0
- package/dist/preview-next/client/useOpenBlockForSetup-BTUc0g9X.mjs +28 -0
- package/dist/preview-next/keepAlive.mjs +25 -2
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-BBAJjFIz.mjs → route-contract-Bv3nkdpV.mjs} +215 -118
- package/dist/server/{Block.shared-ClFI3qpX.mjs → Block.shared-4fMqzltx.mjs} +7 -4
- package/dist/server/{src-DsYPhTbs.mjs → ThemeScopeCore-C72VC_lR.mjs} +894 -2556
- package/dist/server/accessibleSurfaces-B_Y_dA20.mjs +2305 -0
- package/dist/server/{bindings-Bi8EoRZD.mjs → bindings-ConMYJ2U.mjs} +2 -3
- package/dist/server/{publicProducts-Bz8loTRn.mjs → client-Cot-H5fQ.mjs} +2558 -343
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +33 -2
- package/dist/server/data/dataLoaderContext.mjs +2 -0
- package/dist/server/data/resolveBlockData.mjs +2 -0
- package/dist/server/data/types.mjs +1 -0
- package/dist/server/dataLoaderContext-B3fXA54R.mjs +47 -0
- package/dist/server/identity-Bn9OQiT1.mjs +6 -0
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-dEEhQxL7.mjs → loadContent-BkaWYEwt.mjs} +6 -5
- package/dist/server/{loadPage-DBFBad8A.mjs → loadPage-kviUdH8c.mjs} +4 -2
- package/dist/server/manifest.mjs +1 -1
- package/dist/server/media-DnlczCMA.mjs +231 -0
- package/dist/server/metadata.mjs +5 -1
- package/dist/server/mode-Cv_TG9gP.mjs +63 -0
- package/dist/server/next/revalidate.mjs +9 -4
- package/dist/server/next.mjs +11 -11
- package/dist/server/opaqueSurface-BTnS09GS.mjs +54 -0
- package/dist/server/{overrideResolution-BIJbiXYc.mjs → overrideResolution-itXZCXs7.mjs} +2 -1
- package/dist/server/overrides-CD4d-1w7.mjs +177 -0
- package/dist/server/page-converter.mjs +243 -91
- package/dist/server/pageRenderPlan-CDyn7iLy.mjs +4162 -0
- package/dist/server/{themeAdmission-CSknYpxk.mjs → pageRuntimeSupport-DZ6cLxrM.mjs} +13 -28
- package/dist/server/{overrides-DhF87Vsd.mjs → pageShared-Q_Vij87H.mjs} +3808 -1928
- package/dist/server/parseThemeForPersistence-CDrF51tJ.mjs +52 -0
- package/dist/server/{prebuild-DaemmWQL.mjs → prebuild-DOG4MkOy.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/prefetchBlockData-DlprLLsc.mjs +756 -0
- package/dist/server/{registry-Cdvz1OtL.mjs → registry-BPFcpn6k.mjs} +21838 -709
- package/dist/server/rendering/components/pageShared.mjs +2 -0
- package/dist/server/rendering/helpers/loadPage.mjs +2 -0
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +2 -0
- package/dist/server/rendering/server.mjs +5 -4
- package/dist/server/rendering/themeAdmission.mjs +2 -0
- package/dist/server/rendering.mjs +11 -10
- package/dist/server/repeaterFields-MIz7r1ez.mjs +9 -0
- package/dist/server/{resolveBlockData-CLpAJWWf.mjs → resolveBlockData-BHvfGD4y.mjs} +6 -48
- package/dist/server/resolveButtonColourStates-OXFRGn5M.mjs +2682 -0
- package/dist/server/responseMedia-D8J3VAFs.mjs +115 -0
- package/dist/server/{richTextSchema-YYc85FX4.mjs → richTextSchema-Euhuj-7V.mjs} +26 -1
- package/dist/server/routing.mjs +1 -1
- package/dist/server/schema-DEizlyi4.mjs +2524 -0
- package/dist/server/server.mjs +3 -3
- package/dist/server/theme-bridge.mjs +1031 -1
- package/dist/server/theme.mjs +2 -1
- package/dist/server/themeAdmission-DGSAlFUK.mjs +18 -0
- package/dist/server/{three-pass-converter-Chnb1XD-.mjs → three-pass-converter-_j2UE2tR.mjs} +1 -1
- package/dist/server/validation-CDd6m8Ry.mjs +140 -0
- package/dist/server/{validation-DYxhLzqQ.mjs → validation-bl6WcAi_.mjs} +419 -3
- package/dist/server/{version-Beu4q-Gv.mjs → version-BLXZ31S-.mjs} +1 -1
- package/dist/styles/index.css +710 -29
- package/package.json +39 -1
- package/dist/client/events-BmqPeeQm.mjs +0 -20
- package/dist/client/purchase-BV5xfaZH.mjs +0 -894
- package/dist/client/schema-BdSglH2X.mjs +0 -16084
- package/dist/client/site-styles-CWHmlVT5.mjs +0 -14503
- package/dist/client/src-VIsPY-kw.mjs +0 -62
- package/dist/preview-next/client/PreviewEditorSidebar-DEP3xD9K.mjs +0 -5810
- package/dist/preview-next/client/SdkPreviewModeRuntime-Cpe-XP8e.mjs +0 -3
- package/dist/preview-next/client/SdkPreviewModeRuntime-QDkMPASV.mjs +0 -8059
- package/dist/preview-next/client/SiteChromeCustomizeButton-1JaoGOKX.mjs +0 -9367
- package/dist/preview-next/client/previewSidebarNavigation-AXUj9-qQ.mjs +0 -224683
- package/dist/preview-next/client/result-BjJUoxUF.mjs +0 -16
- package/dist/preview-next/client/sdk-runtime-O-eA9-rV.mjs +0 -4
- package/dist/preview-next/refresh-contract-uQ6BXgLJ.mjs +0 -25
- package/dist/server/bindings-Dgt_0goJ.mjs +0 -17
- package/dist/server/client-DfMDbZ41.mjs +0 -2330
- package/dist/server/effectiveNavLinkStyle-BHIYPVG1.mjs +0 -13713
- package/dist/server/loadPage-CnVB-aeL.mjs +0 -2
- package/dist/server/prefetchBlockData-FwcsT5H2.mjs +0 -4359
- package/dist/server/schema-uSA_x1Zh.mjs +0 -16311
- package/dist/server/site-styles-CntHn2KI.mjs +0 -793
- package/dist/server/siteChromeOverlayClearance-DqP40Ka0.mjs +0 -802
|
@@ -1,2330 +0,0 @@
|
|
|
1
|
-
import { _ as isPublicReadEndpoint, a as setSdkVersion, c as isApiError, d as TAG_TEMPLATES, f as buildPublicReadMemoryCacheTags, g as getPublicReadCachePolicy, h as isSupportedLoaderEndpoint, i as createInternalAPIClient, l as unwrapResponse, o as ApiRequestError, p as buildSiteReadTags, r as createBearerAPIClient, s as ApiEnvelopeError, t as encodePublicProductCategorySelector, u as PUBLIC_READ_ENDPOINT_DEFINITIONS, v as publicReadFreshnessSeconds } from "./publicProducts-Bz8loTRn.mjs";
|
|
2
|
-
import { t as SDK_VERSION } from "./version-Beu4q-Gv.mjs";
|
|
3
|
-
//#region src/client/error.ts
|
|
4
|
-
let _Symbol$for;
|
|
5
|
-
_Symbol$for = Symbol.for("nodejs.util.inspect.custom");
|
|
6
|
-
/**
|
|
7
|
-
* Error thrown by SDK when API returns an error response
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* try {
|
|
12
|
-
* await client.getSite({ slug: 'my-site' });
|
|
13
|
-
* } catch (error) {
|
|
14
|
-
* if (error instanceof RiverbankApiError) {
|
|
15
|
-
* console.log('Error code:', error.code);
|
|
16
|
-
* console.log('Request ID:', error.requestId);
|
|
17
|
-
*
|
|
18
|
-
* if (error.isAuthError()) {
|
|
19
|
-
* // Handle authentication error
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* if (error.isValidationError() && error.fieldErrors) {
|
|
23
|
-
* // Handle field-level validation errors
|
|
24
|
-
* error.fieldErrors.forEach(fe => {
|
|
25
|
-
* console.log(`${fe.field}: ${fe.message}`);
|
|
26
|
-
* });
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* // Check if error can be retried
|
|
30
|
-
* if (error.isRetryable) {
|
|
31
|
-
* const delay = error.retryAfterMs ?? 1000;
|
|
32
|
-
* console.log(`Retrying after ${delay}ms...`);
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
var RiverbankApiError = class RiverbankApiError extends Error {
|
|
39
|
-
constructor(apiError) {
|
|
40
|
-
super(apiError.message);
|
|
41
|
-
this.name = "RiverbankApiError";
|
|
42
|
-
if ("cause" in apiError && apiError.cause) this.cause = apiError.cause;
|
|
43
|
-
this.code = apiError.code;
|
|
44
|
-
this.requestId = apiError.requestId;
|
|
45
|
-
this.status = apiError.status;
|
|
46
|
-
this.fieldErrors = apiError.fieldErrors;
|
|
47
|
-
this.timestamp = apiError.timestamp;
|
|
48
|
-
this.retryAfterMs = "retryAfterMs" in apiError ? apiError.retryAfterMs : void 0;
|
|
49
|
-
this.isRetryable = this.computeRetryable();
|
|
50
|
-
Object.setPrototypeOf(this, RiverbankApiError.prototype);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Compute whether this error is retryable based on HTTP status code.
|
|
54
|
-
* - 0 (network errors - no HTTP response): retryable
|
|
55
|
-
* - 429 (rate limit): retryable
|
|
56
|
-
* - 5xx (server errors): retryable
|
|
57
|
-
* - 4xx (client errors, except 429): NOT retryable
|
|
58
|
-
*/
|
|
59
|
-
computeRetryable() {
|
|
60
|
-
if (this.status === 0) return true;
|
|
61
|
-
if (this.status === 429) return true;
|
|
62
|
-
if (this.status >= 500) return true;
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Check if this is a network error (no HTTP response received)
|
|
67
|
-
*
|
|
68
|
-
* Matches: network:connection_error, network:timeout, network:dns_error
|
|
69
|
-
*/
|
|
70
|
-
isNetworkError() {
|
|
71
|
-
return this.code.startsWith("network:");
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Check if this error matches a specific error code
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```ts
|
|
78
|
-
* if (error.is('auth:unauthenticated')) {
|
|
79
|
-
* // Redirect to login
|
|
80
|
-
* }
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
is(code) {
|
|
84
|
-
return this.code === code;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if this is an authentication or authorization error
|
|
88
|
-
*
|
|
89
|
-
* Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
|
|
90
|
-
* auth:forbidden, auth:mfa_required, auth:insufficient_permissions
|
|
91
|
-
*/
|
|
92
|
-
isAuthError() {
|
|
93
|
-
return this.code.startsWith("auth:");
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Check if this is a validation error
|
|
97
|
-
*
|
|
98
|
-
* Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
|
|
99
|
-
*/
|
|
100
|
-
isValidationError() {
|
|
101
|
-
return this.code.startsWith("validation:");
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Check if this is a resource error (not found, conflict, etc.)
|
|
105
|
-
*
|
|
106
|
-
* Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
|
|
107
|
-
*/
|
|
108
|
-
isResourceError() {
|
|
109
|
-
return this.code.startsWith("resource:");
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Check if this is a rate limiting error
|
|
113
|
-
*/
|
|
114
|
-
isRateLimitError() {
|
|
115
|
-
return this.code.startsWith("rate_limit:");
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Check if this is a billing/payment error
|
|
119
|
-
*/
|
|
120
|
-
isBillingError() {
|
|
121
|
-
return this.code.startsWith("billing:");
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if this is a server error
|
|
125
|
-
*/
|
|
126
|
-
isServerError() {
|
|
127
|
-
return this.code.startsWith("server:");
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Returns a human-readable string representation of the error.
|
|
131
|
-
* Includes all key details for debugging.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
|
|
135
|
-
*/
|
|
136
|
-
toString() {
|
|
137
|
-
const parts = [`RiverbankApiError: ${this.message}`];
|
|
138
|
-
if (this.code) parts.push(`Code: ${this.code}`);
|
|
139
|
-
if (this.status) parts.push(`Status: ${this.status}`);
|
|
140
|
-
if (this.requestId) parts.push(`RequestId: ${this.requestId}`);
|
|
141
|
-
return parts.join(" | ");
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Custom Node.js inspect output for better console.log display.
|
|
145
|
-
* This ensures that console.log(error) shows all relevant details
|
|
146
|
-
* instead of just "[Object]" for nested properties.
|
|
147
|
-
*/
|
|
148
|
-
[_Symbol$for]() {
|
|
149
|
-
return this.toDetailedString();
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Returns a detailed multi-line string for debugging.
|
|
153
|
-
* Used by the Node.js inspect symbol for console output.
|
|
154
|
-
*/
|
|
155
|
-
toDetailedString() {
|
|
156
|
-
const lines = [
|
|
157
|
-
`RiverbankApiError: ${this.message}`,
|
|
158
|
-
` Code: ${this.code}`,
|
|
159
|
-
` Status: ${this.status}`,
|
|
160
|
-
` RequestId: ${this.requestId}`,
|
|
161
|
-
` Timestamp: ${this.timestamp}`
|
|
162
|
-
];
|
|
163
|
-
if (this.isRetryable) {
|
|
164
|
-
lines.push(` Retryable: true`);
|
|
165
|
-
if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
|
|
166
|
-
}
|
|
167
|
-
if (this.fieldErrors && this.fieldErrors.length > 0) {
|
|
168
|
-
lines.push(" FieldErrors:");
|
|
169
|
-
this.fieldErrors.forEach((fe) => {
|
|
170
|
-
lines.push(` - ${fe.field}: ${fe.message}`);
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return lines.join("\n");
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
|
|
177
|
-
function attachResilienceStatusToError(error, resilienceStatus) {
|
|
178
|
-
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");
|
|
179
|
-
Object.defineProperty(target, resilienceStatusSymbol, {
|
|
180
|
-
configurable: true,
|
|
181
|
-
enumerable: false,
|
|
182
|
-
value: resilienceStatus
|
|
183
|
-
});
|
|
184
|
-
return target;
|
|
185
|
-
}
|
|
186
|
-
function getResilienceStatusFromError(error) {
|
|
187
|
-
if (error === null || typeof error !== "object" && typeof error !== "function") return;
|
|
188
|
-
return error[resilienceStatusSymbol];
|
|
189
|
-
}
|
|
190
|
-
//#endregion
|
|
191
|
-
//#region src/client/resilience.ts
|
|
192
|
-
const DEFAULT_RETRY_CONFIG = {
|
|
193
|
-
maxAttempts: 3,
|
|
194
|
-
baseDelayMs: 200,
|
|
195
|
-
maxDelayMs: 2e3,
|
|
196
|
-
jitter: "full"
|
|
197
|
-
};
|
|
198
|
-
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
199
|
-
failureThreshold: 5,
|
|
200
|
-
resetTimeoutMs: 3e4,
|
|
201
|
-
halfOpenMaxRequests: 2
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Error codes that indicate permanent infrastructure failures.
|
|
205
|
-
* These should NOT be retried as the server is definitively unreachable.
|
|
206
|
-
*/
|
|
207
|
-
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
208
|
-
"ECONNREFUSED",
|
|
209
|
-
"ENOTFOUND",
|
|
210
|
-
"EAI_AGAIN"
|
|
211
|
-
]);
|
|
212
|
-
/**
|
|
213
|
-
* Error codes that indicate transient network issues.
|
|
214
|
-
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
215
|
-
*/
|
|
216
|
-
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
217
|
-
"ECONNRESET",
|
|
218
|
-
"EPIPE",
|
|
219
|
-
"ETIMEDOUT",
|
|
220
|
-
"ESOCKETTIMEDOUT"
|
|
221
|
-
]);
|
|
222
|
-
/**
|
|
223
|
-
* Node.js network error codes (POSIX style).
|
|
224
|
-
* These are the codes we're looking for in the cause chain.
|
|
225
|
-
*/
|
|
226
|
-
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
227
|
-
"ECONNREFUSED",
|
|
228
|
-
"ENOTFOUND",
|
|
229
|
-
"EAI_AGAIN",
|
|
230
|
-
"ECONNRESET",
|
|
231
|
-
"EPIPE",
|
|
232
|
-
"ETIMEDOUT",
|
|
233
|
-
"ESOCKETTIMEDOUT"
|
|
234
|
-
]);
|
|
235
|
-
/**
|
|
236
|
-
* Check if a string is a Node.js network error code (not an API error code).
|
|
237
|
-
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
238
|
-
*/
|
|
239
|
-
function isNodeNetworkErrorCode(code) {
|
|
240
|
-
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Extract the Node.js error code from an error's cause chain.
|
|
244
|
-
* Handles nested cause chains like:
|
|
245
|
-
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
246
|
-
*
|
|
247
|
-
* Skips API error codes (like 'network:connection_error') and only returns
|
|
248
|
-
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* RiverbankApiError: Network request failed
|
|
252
|
-
* [cause]: TypeError: fetch failed
|
|
253
|
-
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
254
|
-
* code: 'ECONNREFUSED'
|
|
255
|
-
*/
|
|
256
|
-
function getErrorCodeFromCause(error) {
|
|
257
|
-
let current = error;
|
|
258
|
-
while (current) {
|
|
259
|
-
const nodeError = current;
|
|
260
|
-
if (nodeError.code && typeof nodeError.code === "string") {
|
|
261
|
-
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
262
|
-
}
|
|
263
|
-
current = current.cause;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
268
|
-
*
|
|
269
|
-
* Transient (opens circuit, triggers retry):
|
|
270
|
-
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
271
|
-
* - 5xx server errors
|
|
272
|
-
* - 429 rate limit
|
|
273
|
-
* - Connection reset, broken pipe, timeout
|
|
274
|
-
*
|
|
275
|
-
* Permanent (does NOT open circuit, no retry):
|
|
276
|
-
* - 4xx client errors (400, 401, 403, 404)
|
|
277
|
-
* - Validation errors
|
|
278
|
-
* - ECONNREFUSED (server not running)
|
|
279
|
-
* - ENOTFOUND (DNS failure)
|
|
280
|
-
*/
|
|
281
|
-
function isTransientError(error) {
|
|
282
|
-
if (error instanceof RiverbankApiError) {
|
|
283
|
-
const errorCode = getErrorCodeFromCause(error);
|
|
284
|
-
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
285
|
-
if (error.status === 0) return true;
|
|
286
|
-
if (error.status === 429) return true;
|
|
287
|
-
if (error.status >= 500) return true;
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
if (error instanceof TypeError) {
|
|
291
|
-
const errorCode = getErrorCodeFromCause(error);
|
|
292
|
-
if (errorCode) {
|
|
293
|
-
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
294
|
-
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
295
|
-
}
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Calculate backoff delay for retry attempt
|
|
302
|
-
*
|
|
303
|
-
* Uses exponential backoff with optional full jitter.
|
|
304
|
-
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
305
|
-
*/
|
|
306
|
-
function calculateBackoff(attempt, config) {
|
|
307
|
-
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
308
|
-
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
309
|
-
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
310
|
-
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
311
|
-
const capped = Math.min(exponential, maxDelayMs);
|
|
312
|
-
if (jitter === "full") return Math.random() * capped;
|
|
313
|
-
return capped;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Circuit breaker for fail-fast behavior
|
|
317
|
-
*
|
|
318
|
-
* States:
|
|
319
|
-
* - closed: Normal operation, requests allowed
|
|
320
|
-
* - open: Too many failures, requests blocked
|
|
321
|
-
* - half-open: Testing if service recovered, limited requests allowed
|
|
322
|
-
*/
|
|
323
|
-
var CircuitBreaker = class {
|
|
324
|
-
constructor(config) {
|
|
325
|
-
this.state = "closed";
|
|
326
|
-
this.failureCount = 0;
|
|
327
|
-
this.successCount = 0;
|
|
328
|
-
this.openUntil = 0;
|
|
329
|
-
this.halfOpenRequests = 0;
|
|
330
|
-
this.config = {
|
|
331
|
-
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
332
|
-
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
333
|
-
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Check if circuit is open (requests should be blocked)
|
|
338
|
-
* Also handles automatic transition from open to half-open after timeout
|
|
339
|
-
*/
|
|
340
|
-
isOpen() {
|
|
341
|
-
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
342
|
-
return this.state === "open";
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Check if a request can be attempted
|
|
346
|
-
* - closed: always yes
|
|
347
|
-
* - open: always no
|
|
348
|
-
* - half-open: limited number of probes
|
|
349
|
-
*/
|
|
350
|
-
canAttempt() {
|
|
351
|
-
if (this.state === "closed") return true;
|
|
352
|
-
if (this.state === "open") return false;
|
|
353
|
-
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Increment half-open request counter (call before making request in half-open)
|
|
357
|
-
*/
|
|
358
|
-
incrementHalfOpenRequests() {
|
|
359
|
-
if (this.state === "half-open") this.halfOpenRequests++;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Record a successful request
|
|
363
|
-
*/
|
|
364
|
-
recordSuccess() {
|
|
365
|
-
if (this.state === "half-open") {
|
|
366
|
-
this.successCount++;
|
|
367
|
-
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
368
|
-
} else this.failureCount = 0;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Record a failed request
|
|
372
|
-
* Only counts transient failures toward circuit breaker threshold
|
|
373
|
-
*/
|
|
374
|
-
recordFailure(error) {
|
|
375
|
-
if (!isTransientError(error)) return;
|
|
376
|
-
this.failureCount++;
|
|
377
|
-
if (this.state === "half-open") this.transitionTo("open");
|
|
378
|
-
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Get current circuit state
|
|
382
|
-
*/
|
|
383
|
-
getState() {
|
|
384
|
-
return {
|
|
385
|
-
state: this.state,
|
|
386
|
-
failureCount: this.failureCount,
|
|
387
|
-
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Transition to a new state
|
|
392
|
-
*/
|
|
393
|
-
transitionTo(newState) {
|
|
394
|
-
this.state = newState;
|
|
395
|
-
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
396
|
-
else if (newState === "half-open") {
|
|
397
|
-
this.halfOpenRequests = 0;
|
|
398
|
-
this.successCount = 0;
|
|
399
|
-
} else if (newState === "closed") {
|
|
400
|
-
this.failureCount = 0;
|
|
401
|
-
this.successCount = 0;
|
|
402
|
-
this.halfOpenRequests = 0;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* Fetch with timeout and retry logic
|
|
408
|
-
*
|
|
409
|
-
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
410
|
-
* @param config - Retry configuration
|
|
411
|
-
* @returns Result from successful fetch
|
|
412
|
-
* @throws Last error after all retries exhausted
|
|
413
|
-
*/
|
|
414
|
-
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
415
|
-
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
416
|
-
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
417
|
-
let lastError;
|
|
418
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
419
|
-
const controller = new AbortController();
|
|
420
|
-
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
421
|
-
try {
|
|
422
|
-
return await fetcher(controller.signal);
|
|
423
|
-
} finally {
|
|
424
|
-
clearTimeout(timeoutId);
|
|
425
|
-
}
|
|
426
|
-
} catch (error) {
|
|
427
|
-
lastError = error;
|
|
428
|
-
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
429
|
-
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
430
|
-
}
|
|
431
|
-
throw lastError;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
435
|
-
*/
|
|
436
|
-
function isAbortError$1(error) {
|
|
437
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
438
|
-
if (error instanceof Error && error.name === "AbortError") return true;
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Check if an error should be retried
|
|
443
|
-
*/
|
|
444
|
-
function shouldRetryError(error, customRetryOn) {
|
|
445
|
-
if (isAbortError$1(error)) return false;
|
|
446
|
-
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
447
|
-
return isTransientError(error);
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Get delay before retrying, respecting Retry-After if present
|
|
451
|
-
*/
|
|
452
|
-
function getRetryDelay(error, attempt, config) {
|
|
453
|
-
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
454
|
-
return calculateBackoff(attempt, config);
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* Sleep for specified milliseconds
|
|
458
|
-
*/
|
|
459
|
-
function sleep(ms) {
|
|
460
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Error thrown when circuit breaker is open
|
|
464
|
-
*/
|
|
465
|
-
var CircuitOpenError = class extends Error {
|
|
466
|
-
constructor(state) {
|
|
467
|
-
super("Circuit breaker is open");
|
|
468
|
-
this.name = "CircuitOpenError";
|
|
469
|
-
this.circuitState = state;
|
|
470
|
-
}
|
|
471
|
-
};
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/client/entryListReadRequest.ts
|
|
474
|
-
const entryOrder = {
|
|
475
|
-
newest: "published_at.desc",
|
|
476
|
-
oldest: "published_at.asc",
|
|
477
|
-
title: "title.asc",
|
|
478
|
-
manual: "manual.asc"
|
|
479
|
-
};
|
|
480
|
-
function entrySelection(input) {
|
|
481
|
-
return input.mode === "manual" && input.entryIds?.length ? {
|
|
482
|
-
keyPart: input.entryIds.join(","),
|
|
483
|
-
params: {
|
|
484
|
-
mode: "manual",
|
|
485
|
-
entryIds: JSON.stringify(input.entryIds)
|
|
486
|
-
}
|
|
487
|
-
} : {
|
|
488
|
-
keyPart: "",
|
|
489
|
-
params: {}
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
function entryListMemoryKey(input, selection) {
|
|
493
|
-
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
494
|
-
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
495
|
-
}
|
|
496
|
-
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
497
|
-
function buildEntryListReadRequest(input) {
|
|
498
|
-
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
499
|
-
const selection = entrySelection(input);
|
|
500
|
-
const orderParam = order ? entryOrder[order] : void 0;
|
|
501
|
-
return {
|
|
502
|
-
cacheKey: entryListMemoryKey(input, selection),
|
|
503
|
-
params: {
|
|
504
|
-
siteId,
|
|
505
|
-
type: contentType,
|
|
506
|
-
...typeof limit === "number" && { limit: String(limit) },
|
|
507
|
-
...typeof offset === "number" && { offset: String(offset) },
|
|
508
|
-
...includeMeta && { meta: "true" },
|
|
509
|
-
...orderParam && { order: orderParam },
|
|
510
|
-
...preview && { stage: "preview" },
|
|
511
|
-
...selection.params
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
//#endregion
|
|
516
|
-
//#region src/client/cache.ts
|
|
517
|
-
var SimpleCache = class {
|
|
518
|
-
constructor(options = {}) {
|
|
519
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
520
|
-
this.maxSize = options.maxSize ?? 100;
|
|
521
|
-
this.ttl = options.ttl ?? 3e5;
|
|
522
|
-
this.staleTtl = options.staleTtl ?? 3e5;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Get a fresh value (within TTL)
|
|
526
|
-
* @returns The value if fresh, null otherwise
|
|
527
|
-
*/
|
|
528
|
-
getFresh(key) {
|
|
529
|
-
const entry = this.cache.get(key);
|
|
530
|
-
if (!entry) return null;
|
|
531
|
-
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Get a value that may be stale (past TTL but within staleTtl)
|
|
536
|
-
* @returns Object with value and stale age, or null if expired
|
|
537
|
-
*/
|
|
538
|
-
getStale(key) {
|
|
539
|
-
const entry = this.cache.get(key);
|
|
540
|
-
if (!entry) return null;
|
|
541
|
-
const now = Date.now();
|
|
542
|
-
if (now > entry.staleUntil) {
|
|
543
|
-
this.cache.delete(key);
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
547
|
-
return {
|
|
548
|
-
value: entry.value,
|
|
549
|
-
staleAgeSec
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Store a value with TTL and stale window
|
|
554
|
-
*/
|
|
555
|
-
set(key, value, options) {
|
|
556
|
-
const ttl = options?.ttl ?? this.ttl;
|
|
557
|
-
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
558
|
-
const now = Date.now();
|
|
559
|
-
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
560
|
-
this.cache.set(key, {
|
|
561
|
-
value,
|
|
562
|
-
tags: options?.tags ?? [],
|
|
563
|
-
createdAt: now,
|
|
564
|
-
freshUntil: now + ttl,
|
|
565
|
-
staleUntil: now + ttl + staleTtl
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Evict one entry to make room for a new one
|
|
570
|
-
* Priority: oldest stale entry, then oldest fresh entry
|
|
571
|
-
*/
|
|
572
|
-
evictOne(now) {
|
|
573
|
-
let oldestStaleKey = null;
|
|
574
|
-
let oldestStaleTime = Infinity;
|
|
575
|
-
let oldestFreshKey = null;
|
|
576
|
-
let oldestFreshTime = Infinity;
|
|
577
|
-
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
578
|
-
if (entry.createdAt < oldestStaleTime) {
|
|
579
|
-
oldestStaleTime = entry.createdAt;
|
|
580
|
-
oldestStaleKey = key;
|
|
581
|
-
}
|
|
582
|
-
} else if (entry.createdAt < oldestFreshTime) {
|
|
583
|
-
oldestFreshTime = entry.createdAt;
|
|
584
|
-
oldestFreshKey = key;
|
|
585
|
-
}
|
|
586
|
-
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
587
|
-
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Remove all fully expired entries (past staleUntil)
|
|
591
|
-
*/
|
|
592
|
-
prune() {
|
|
593
|
-
const now = Date.now();
|
|
594
|
-
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Clear all entries
|
|
598
|
-
*/
|
|
599
|
-
clearForTags(tags) {
|
|
600
|
-
if (tags.includes("riverbank")) {
|
|
601
|
-
this.clear();
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
const selected = new Set(tags);
|
|
605
|
-
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
606
|
-
}
|
|
607
|
-
clear() {
|
|
608
|
-
this.cache.clear();
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Check if a key exists and is not fully expired
|
|
612
|
-
*/
|
|
613
|
-
has(key) {
|
|
614
|
-
const entry = this.cache.get(key);
|
|
615
|
-
if (!entry) return false;
|
|
616
|
-
const now = Date.now();
|
|
617
|
-
if (now > entry.staleUntil) {
|
|
618
|
-
this.cache.delete(key);
|
|
619
|
-
return false;
|
|
620
|
-
}
|
|
621
|
-
return now <= entry.freshUntil;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
//#endregion
|
|
625
|
-
//#region src/public-api/runtime.ts
|
|
626
|
-
const PUBLIC_ENDPOINT_NAMES = [
|
|
627
|
-
"getSite",
|
|
628
|
-
"getContentByPath",
|
|
629
|
-
"resolveRouteOutcome",
|
|
630
|
-
"resolveRouteDecision",
|
|
631
|
-
"listPublishedEntries",
|
|
632
|
-
"getPublishedEntryPreview",
|
|
633
|
-
"getPublicFormById",
|
|
634
|
-
"listPublicForms",
|
|
635
|
-
"getPublicBookingServices",
|
|
636
|
-
"getPublicWeeklySlotAvailability",
|
|
637
|
-
"getPublicChallenge",
|
|
638
|
-
"listPublicEvents",
|
|
639
|
-
"batchBlockLoaders",
|
|
640
|
-
"listPublicTeamMembers",
|
|
641
|
-
"listPublicProducts",
|
|
642
|
-
"listPublicPasses",
|
|
643
|
-
"listPublicMemberships",
|
|
644
|
-
"resolveEventSubroute",
|
|
645
|
-
"checkRedirect",
|
|
646
|
-
"getRoutableContent",
|
|
647
|
-
"getPublicRoutableContent",
|
|
648
|
-
"getPublicSitemapRoutes"
|
|
649
|
-
];
|
|
650
|
-
const API_ENDPOINTS = Object.freeze({
|
|
651
|
-
getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
|
|
652
|
-
getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
|
|
653
|
-
getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
|
|
654
|
-
getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
|
|
655
|
-
getContentByPath: {
|
|
656
|
-
path: "/sites/{siteId}/pages",
|
|
657
|
-
method: "GET",
|
|
658
|
-
tags: [TAG_TEMPLATES.siteRoutableContent],
|
|
659
|
-
auth: "public",
|
|
660
|
-
responseKind: "json"
|
|
661
|
-
},
|
|
662
|
-
resolveRouteOutcome: {
|
|
663
|
-
path: "/sites/{siteId}/route-outcome",
|
|
664
|
-
method: "GET",
|
|
665
|
-
tags: [
|
|
666
|
-
TAG_TEMPLATES.siteRoutableContent,
|
|
667
|
-
TAG_TEMPLATES.siteRedirects,
|
|
668
|
-
TAG_TEMPLATES.siteRouteOutcomes
|
|
669
|
-
],
|
|
670
|
-
auth: "public",
|
|
671
|
-
responseKind: "json"
|
|
672
|
-
},
|
|
673
|
-
resolveRouteDecision: {
|
|
674
|
-
path: "/sites/{siteId}/route-decision",
|
|
675
|
-
method: "GET",
|
|
676
|
-
tags: [
|
|
677
|
-
TAG_TEMPLATES.siteRoutableContent,
|
|
678
|
-
TAG_TEMPLATES.siteRedirects,
|
|
679
|
-
TAG_TEMPLATES.siteRouteOutcomes
|
|
680
|
-
],
|
|
681
|
-
auth: "public",
|
|
682
|
-
responseKind: "json"
|
|
683
|
-
},
|
|
684
|
-
listPublishedEntries: {
|
|
685
|
-
path: "/public/content/{siteId}/{type}/entries",
|
|
686
|
-
method: "GET",
|
|
687
|
-
revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
|
|
688
|
-
tags: ["content-{siteId}-{type}"],
|
|
689
|
-
auth: "public",
|
|
690
|
-
responseKind: "json"
|
|
691
|
-
},
|
|
692
|
-
getPublishedEntryPreview: {
|
|
693
|
-
path: "/public/content/{siteId}/{type}/{slug}/preview",
|
|
694
|
-
method: "GET",
|
|
695
|
-
revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
|
|
696
|
-
tags: ["content-{siteId}-{type}-{slug}"],
|
|
697
|
-
auth: "public",
|
|
698
|
-
responseKind: "json"
|
|
699
|
-
},
|
|
700
|
-
getPublicFormById: {
|
|
701
|
-
path: "/public/forms/{formId}",
|
|
702
|
-
method: "GET",
|
|
703
|
-
revalidate: publicReadFreshnessSeconds("getPublicFormById"),
|
|
704
|
-
tags: [TAG_TEMPLATES.formById],
|
|
705
|
-
auth: "public",
|
|
706
|
-
responseKind: "json"
|
|
707
|
-
},
|
|
708
|
-
listPublicForms: {
|
|
709
|
-
path: "/public/sites/{siteId}/forms",
|
|
710
|
-
method: "GET",
|
|
711
|
-
revalidate: 60,
|
|
712
|
-
tags: [TAG_TEMPLATES.siteForms],
|
|
713
|
-
auth: "public",
|
|
714
|
-
responseKind: "json"
|
|
715
|
-
},
|
|
716
|
-
getPublicBookingServices: {
|
|
717
|
-
path: "/public/bookings/services",
|
|
718
|
-
method: "GET",
|
|
719
|
-
revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
|
|
720
|
-
tags: [TAG_TEMPLATES.publicBookingServices],
|
|
721
|
-
auth: "public",
|
|
722
|
-
responseKind: "json"
|
|
723
|
-
},
|
|
724
|
-
getPublicWeeklySlotAvailability: {
|
|
725
|
-
path: "/public/bookings/weekly-slot-availability",
|
|
726
|
-
method: "GET",
|
|
727
|
-
revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
|
|
728
|
-
tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
|
|
729
|
-
auth: "public",
|
|
730
|
-
responseKind: "json"
|
|
731
|
-
},
|
|
732
|
-
getPublicChallenge: {
|
|
733
|
-
path: "/public/challenge",
|
|
734
|
-
method: "GET",
|
|
735
|
-
auth: "public",
|
|
736
|
-
responseKind: "text"
|
|
737
|
-
},
|
|
738
|
-
listPublicEvents: {
|
|
739
|
-
path: "/public/sites/{siteId}/events",
|
|
740
|
-
method: "GET",
|
|
741
|
-
revalidate: publicReadFreshnessSeconds("listPublicEvents"),
|
|
742
|
-
tags: [TAG_TEMPLATES.publicEvents],
|
|
743
|
-
auth: "public",
|
|
744
|
-
responseKind: "json"
|
|
745
|
-
},
|
|
746
|
-
batchBlockLoaders: {
|
|
747
|
-
path: "/public/sites/{siteId}/block-loaders/batch",
|
|
748
|
-
method: "POST",
|
|
749
|
-
auth: "public",
|
|
750
|
-
responseKind: "json"
|
|
751
|
-
},
|
|
752
|
-
listPublicTeamMembers: {
|
|
753
|
-
path: "/public/sites/{siteId}/team-members",
|
|
754
|
-
method: "GET",
|
|
755
|
-
revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
|
|
756
|
-
tags: [TAG_TEMPLATES.publicTeamMembers],
|
|
757
|
-
auth: "public",
|
|
758
|
-
responseKind: "json"
|
|
759
|
-
},
|
|
760
|
-
listPublicProducts: {
|
|
761
|
-
path: "/public/sites/{siteId}/products",
|
|
762
|
-
method: "GET",
|
|
763
|
-
revalidate: publicReadFreshnessSeconds("listPublicProducts"),
|
|
764
|
-
tags: [TAG_TEMPLATES.publicProducts],
|
|
765
|
-
auth: "public",
|
|
766
|
-
responseKind: "json"
|
|
767
|
-
},
|
|
768
|
-
listPublicPasses: {
|
|
769
|
-
path: "/public/sites/{siteId}/bookings/products/passes",
|
|
770
|
-
method: "GET",
|
|
771
|
-
revalidate: publicReadFreshnessSeconds("listPublicPasses"),
|
|
772
|
-
tags: [TAG_TEMPLATES.publicPasses],
|
|
773
|
-
auth: "public",
|
|
774
|
-
responseKind: "json"
|
|
775
|
-
},
|
|
776
|
-
listPublicMemberships: {
|
|
777
|
-
path: "/public/sites/{siteId}/bookings/products/memberships",
|
|
778
|
-
method: "GET",
|
|
779
|
-
revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
|
|
780
|
-
tags: [TAG_TEMPLATES.publicMemberships],
|
|
781
|
-
auth: "public",
|
|
782
|
-
responseKind: "json"
|
|
783
|
-
},
|
|
784
|
-
resolveEventSubroute: {
|
|
785
|
-
path: "/public/sites/{siteId}/events/subroutes/resolve",
|
|
786
|
-
method: "GET",
|
|
787
|
-
revalidate: 60,
|
|
788
|
-
tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
|
|
789
|
-
auth: "public",
|
|
790
|
-
responseKind: "json"
|
|
791
|
-
},
|
|
792
|
-
checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
|
|
793
|
-
});
|
|
794
|
-
function buildEndpointURL(baseURL, endpoint) {
|
|
795
|
-
return baseURL + API_ENDPOINTS[endpoint].path;
|
|
796
|
-
}
|
|
797
|
-
function publicSiteReadDefinition(definition) {
|
|
798
|
-
return {
|
|
799
|
-
path: definition.path,
|
|
800
|
-
method: definition.method,
|
|
801
|
-
revalidate: definition.revalidate,
|
|
802
|
-
tags: definition.tags,
|
|
803
|
-
auth: definition.auth,
|
|
804
|
-
responseKind: definition.responseKind
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
//#endregion
|
|
808
|
-
//#region src/client/runtimeCacheKeys.ts
|
|
809
|
-
/**
|
|
810
|
-
* Bump when a cached payload's shape changes incompatibly, so readers skip
|
|
811
|
-
* entries written in the old shape until publish or a live success rewrites
|
|
812
|
-
* them.
|
|
813
|
-
*
|
|
814
|
-
* - 4: owned surface inputs use the shared revision transport envelope (#1627).
|
|
815
|
-
* - 3: hidden business-source maps and private locations are removed before public projection (#1611).
|
|
816
|
-
* - 2: pages carry intent-only `runtimeJoins` in place of compiled
|
|
817
|
-
* `runtimeBoundaries` (issue 1422).
|
|
818
|
-
*/
|
|
819
|
-
const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 4;
|
|
820
|
-
function toNonEmptyString(value) {
|
|
821
|
-
if (value === null || value === void 0) return null;
|
|
822
|
-
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
|
|
823
|
-
const normalized = String(value).trim();
|
|
824
|
-
return normalized.length > 0 ? normalized : null;
|
|
825
|
-
}
|
|
826
|
-
function normalizeRuntimePublicPath(value) {
|
|
827
|
-
const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
|
|
828
|
-
const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
|
|
829
|
-
return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
|
|
830
|
-
}
|
|
831
|
-
function normalizeRuntimeHostname(value) {
|
|
832
|
-
const trimmed = value.trim().toLowerCase();
|
|
833
|
-
return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
|
|
834
|
-
}
|
|
835
|
-
function normalizeScalar(value) {
|
|
836
|
-
return value.trim().toLowerCase();
|
|
837
|
-
}
|
|
838
|
-
function unsafeAsPublishedRuntimeCacheKey(value) {
|
|
839
|
-
return value;
|
|
840
|
-
}
|
|
841
|
-
function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
|
|
842
|
-
return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
|
|
843
|
-
}
|
|
844
|
-
function selectSiteRuntimeIdentity(params) {
|
|
845
|
-
const slug = toNonEmptyString(params.slug);
|
|
846
|
-
if (slug !== null) return { slug: normalizeScalar(slug) };
|
|
847
|
-
const domain = toNonEmptyString(params.domain);
|
|
848
|
-
if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
|
|
849
|
-
const id = toNonEmptyString(params.id);
|
|
850
|
-
if (id !== null) return { id: normalizeScalar(id) };
|
|
851
|
-
return null;
|
|
852
|
-
}
|
|
853
|
-
function deriveGetSiteKey(params) {
|
|
854
|
-
const identity = selectSiteRuntimeIdentity(params);
|
|
855
|
-
if (identity === null) return {
|
|
856
|
-
ok: false,
|
|
857
|
-
error: {
|
|
858
|
-
kind: "missing_site_identity",
|
|
859
|
-
acceptedParams: [
|
|
860
|
-
"slug",
|
|
861
|
-
"domain",
|
|
862
|
-
"id"
|
|
863
|
-
]
|
|
864
|
-
}
|
|
865
|
-
};
|
|
866
|
-
const normalizedParams = {
|
|
867
|
-
...identity,
|
|
868
|
-
currentPath: normalizeRuntimePublicPath(params.currentPath)
|
|
869
|
-
};
|
|
870
|
-
return {
|
|
871
|
-
ok: true,
|
|
872
|
-
endpoint: "getSite",
|
|
873
|
-
key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
|
|
874
|
-
normalizedParams
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
function deriveGetContentByPathKey(params) {
|
|
878
|
-
const siteId = toNonEmptyString(params.siteId);
|
|
879
|
-
if (siteId === null) return {
|
|
880
|
-
ok: false,
|
|
881
|
-
error: {
|
|
882
|
-
kind: "missing_required_param",
|
|
883
|
-
endpoint: "getContentByPath",
|
|
884
|
-
param: "siteId"
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
const normalizedParams = {
|
|
888
|
-
siteId: normalizeScalar(siteId),
|
|
889
|
-
path: normalizeRuntimePublicPath(params.path),
|
|
890
|
-
contentContract: "native"
|
|
891
|
-
};
|
|
892
|
-
return {
|
|
893
|
-
ok: true,
|
|
894
|
-
endpoint: "getContentByPath",
|
|
895
|
-
key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
|
|
896
|
-
normalizedParams
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
function deriveDurableRuntimeCacheKey(input) {
|
|
900
|
-
switch (input.endpoint) {
|
|
901
|
-
case "getSite": return deriveGetSiteKey(input.params);
|
|
902
|
-
case "getContentByPath": return deriveGetContentByPathKey(input.params);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
function isPublishedRuntimeCacheKeyEndpoint(value) {
|
|
906
|
-
return value === "getSite" || value === "getContentByPath";
|
|
907
|
-
}
|
|
908
|
-
function parsePublishedRuntimeCacheKey(value) {
|
|
909
|
-
const details = parsePublishedRuntimeCacheKeyDetails(value);
|
|
910
|
-
if (!details.ok) return details;
|
|
911
|
-
return {
|
|
912
|
-
ok: true,
|
|
913
|
-
key: details.key,
|
|
914
|
-
endpoint: details.endpoint
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
function parsePublishedRuntimeCacheKeyDetails(value) {
|
|
918
|
-
if (typeof value !== "string") return {
|
|
919
|
-
ok: false,
|
|
920
|
-
error: "not_string"
|
|
921
|
-
};
|
|
922
|
-
const parts = value.split(":");
|
|
923
|
-
if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
|
|
924
|
-
ok: false,
|
|
925
|
-
error: "invalid_prefix"
|
|
926
|
-
};
|
|
927
|
-
const endpoint = parts[2];
|
|
928
|
-
if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
|
|
929
|
-
ok: false,
|
|
930
|
-
error: "unknown_endpoint"
|
|
931
|
-
};
|
|
932
|
-
const normalizedParams = {};
|
|
933
|
-
for (const part of parts.slice(3)) {
|
|
934
|
-
const separatorIndex = part.indexOf("=");
|
|
935
|
-
if (separatorIndex <= 0) return {
|
|
936
|
-
ok: false,
|
|
937
|
-
error: "invalid_param_encoding"
|
|
938
|
-
};
|
|
939
|
-
try {
|
|
940
|
-
const key = decodeURIComponent(part.slice(0, separatorIndex));
|
|
941
|
-
normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
|
|
942
|
-
} catch {
|
|
943
|
-
return {
|
|
944
|
-
ok: false,
|
|
945
|
-
error: "invalid_param_encoding"
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
|
|
950
|
-
ok: false,
|
|
951
|
-
error: "invalid_param_encoding"
|
|
952
|
-
};
|
|
953
|
-
return {
|
|
954
|
-
ok: true,
|
|
955
|
-
key: unsafeAsPublishedRuntimeCacheKey(value),
|
|
956
|
-
endpoint,
|
|
957
|
-
normalizedParams
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
|
|
961
|
-
const keys = Object.keys(normalizedParams).sort();
|
|
962
|
-
switch (endpoint) {
|
|
963
|
-
case "getSite": return [
|
|
964
|
-
"domain",
|
|
965
|
-
"id",
|
|
966
|
-
"slug"
|
|
967
|
-
].filter((key) => normalizedParams[key] !== void 0).length === 1 && normalizedParams.currentPath !== void 0 && keys.every((key) => [
|
|
968
|
-
"currentPath",
|
|
969
|
-
"domain",
|
|
970
|
-
"id",
|
|
971
|
-
"slug"
|
|
972
|
-
].includes(key));
|
|
973
|
-
case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
|
|
974
|
-
"contentContract",
|
|
975
|
-
"path",
|
|
976
|
-
"siteId"
|
|
977
|
-
].includes(key));
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
|
|
981
|
-
if (typeof value !== "number") return {
|
|
982
|
-
ok: false,
|
|
983
|
-
error: "not_number"
|
|
984
|
-
};
|
|
985
|
-
if (!Number.isInteger(value)) return {
|
|
986
|
-
ok: false,
|
|
987
|
-
error: "not_integer"
|
|
988
|
-
};
|
|
989
|
-
if (value <= 0) return {
|
|
990
|
-
ok: false,
|
|
991
|
-
error: "not_positive"
|
|
992
|
-
};
|
|
993
|
-
return {
|
|
994
|
-
ok: true,
|
|
995
|
-
value
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
//#endregion
|
|
999
|
-
//#region src/client/runtimeCachePolicy.ts
|
|
1000
|
-
const DEFAULT_STALE_TTL_SEC = 1440 * 60;
|
|
1001
|
-
const DEFAULT_MEMORY_TTL_SEC = 60;
|
|
1002
|
-
const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
|
|
1003
|
-
getSite: {
|
|
1004
|
-
kind: "durable-public-stale",
|
|
1005
|
-
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
1006
|
-
},
|
|
1007
|
-
getContentByPath: {
|
|
1008
|
-
kind: "durable-public-stale",
|
|
1009
|
-
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
1010
|
-
},
|
|
1011
|
-
resolveRouteOutcome: {
|
|
1012
|
-
kind: "memory-only",
|
|
1013
|
-
reason: "durable_rollout_pending"
|
|
1014
|
-
},
|
|
1015
|
-
resolveRouteDecision: {
|
|
1016
|
-
kind: "memory-only",
|
|
1017
|
-
reason: "durable_rollout_pending"
|
|
1018
|
-
},
|
|
1019
|
-
listPublishedEntries: {
|
|
1020
|
-
kind: "memory-only",
|
|
1021
|
-
reason: "durable_rollout_pending"
|
|
1022
|
-
},
|
|
1023
|
-
getPublishedEntryPreview: {
|
|
1024
|
-
kind: "memory-only",
|
|
1025
|
-
reason: "durable_rollout_pending"
|
|
1026
|
-
},
|
|
1027
|
-
getPublicFormById: {
|
|
1028
|
-
kind: "memory-only",
|
|
1029
|
-
reason: "durable_rollout_pending"
|
|
1030
|
-
},
|
|
1031
|
-
listPublicForms: {
|
|
1032
|
-
kind: "memory-only",
|
|
1033
|
-
reason: "durable_rollout_pending"
|
|
1034
|
-
},
|
|
1035
|
-
getPublicBookingServices: {
|
|
1036
|
-
kind: "live-only",
|
|
1037
|
-
reason: "safety_sensitive_booking"
|
|
1038
|
-
},
|
|
1039
|
-
getPublicWeeklySlotAvailability: {
|
|
1040
|
-
kind: "live-only",
|
|
1041
|
-
reason: "safety_sensitive_booking"
|
|
1042
|
-
},
|
|
1043
|
-
getPublicChallenge: {
|
|
1044
|
-
kind: "live-only",
|
|
1045
|
-
reason: "challenge_endpoint"
|
|
1046
|
-
},
|
|
1047
|
-
listPublicEvents: {
|
|
1048
|
-
kind: "memory-only",
|
|
1049
|
-
reason: "durable_rollout_pending"
|
|
1050
|
-
},
|
|
1051
|
-
batchBlockLoaders: {
|
|
1052
|
-
kind: "live-only",
|
|
1053
|
-
reason: "opaque_batch_loader"
|
|
1054
|
-
},
|
|
1055
|
-
listPublicTeamMembers: {
|
|
1056
|
-
kind: "memory-only",
|
|
1057
|
-
reason: "durable_rollout_pending"
|
|
1058
|
-
},
|
|
1059
|
-
listPublicProducts: {
|
|
1060
|
-
kind: "memory-only",
|
|
1061
|
-
reason: "durable_rollout_pending"
|
|
1062
|
-
},
|
|
1063
|
-
listPublicPasses: {
|
|
1064
|
-
kind: "live-only",
|
|
1065
|
-
reason: "safety_sensitive_booking"
|
|
1066
|
-
},
|
|
1067
|
-
listPublicMemberships: {
|
|
1068
|
-
kind: "live-only",
|
|
1069
|
-
reason: "safety_sensitive_booking"
|
|
1070
|
-
},
|
|
1071
|
-
resolveEventSubroute: {
|
|
1072
|
-
kind: "memory-only",
|
|
1073
|
-
reason: "durable_rollout_pending"
|
|
1074
|
-
},
|
|
1075
|
-
checkRedirect: {
|
|
1076
|
-
kind: "memory-only",
|
|
1077
|
-
reason: "durable_rollout_pending"
|
|
1078
|
-
},
|
|
1079
|
-
getRoutableContent: {
|
|
1080
|
-
kind: "live-only",
|
|
1081
|
-
reason: "auth_required"
|
|
1082
|
-
},
|
|
1083
|
-
getPublicRoutableContent: {
|
|
1084
|
-
kind: "memory-only",
|
|
1085
|
-
reason: "durable_rollout_pending"
|
|
1086
|
-
},
|
|
1087
|
-
getPublicSitemapRoutes: {
|
|
1088
|
-
kind: "memory-only",
|
|
1089
|
-
reason: "durable_rollout_pending"
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
|
|
1093
|
-
function isPublicEndpointName(endpoint) {
|
|
1094
|
-
return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
|
|
1095
|
-
}
|
|
1096
|
-
function isTruthyParam(value) {
|
|
1097
|
-
return value === true || value === "true" || value === 1 || value === "1";
|
|
1098
|
-
}
|
|
1099
|
-
function isPreviewRequest(endpoint, params) {
|
|
1100
|
-
if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
|
|
1101
|
-
if (endpoint === "listPublishedEntries" || endpoint === "resolveEventSubroute") return params.stage === "preview";
|
|
1102
|
-
return false;
|
|
1103
|
-
}
|
|
1104
|
-
function getEndpointFreshTtlSec(endpoint) {
|
|
1105
|
-
return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
|
|
1106
|
-
}
|
|
1107
|
-
function assertNever(value) {
|
|
1108
|
-
throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
|
|
1109
|
-
}
|
|
1110
|
-
function resolveKnownEndpointPolicy(endpoint, params) {
|
|
1111
|
-
if (isPreviewRequest(endpoint, params)) return {
|
|
1112
|
-
kind: "live-only",
|
|
1113
|
-
endpoint,
|
|
1114
|
-
reason: "preview_request"
|
|
1115
|
-
};
|
|
1116
|
-
if (endpoint === "getSite" && isTruthyParam(params.force)) return {
|
|
1117
|
-
kind: "live-only",
|
|
1118
|
-
endpoint,
|
|
1119
|
-
reason: "force_refresh"
|
|
1120
|
-
};
|
|
1121
|
-
if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
|
|
1122
|
-
kind: "live-only",
|
|
1123
|
-
endpoint,
|
|
1124
|
-
reason: "safety_sensitive_booking"
|
|
1125
|
-
};
|
|
1126
|
-
const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
|
|
1127
|
-
if (override.kind === "live-only") return {
|
|
1128
|
-
kind: "live-only",
|
|
1129
|
-
endpoint,
|
|
1130
|
-
reason: override.reason
|
|
1131
|
-
};
|
|
1132
|
-
const endpointDefinition = API_ENDPOINTS[endpoint];
|
|
1133
|
-
if (endpointDefinition.method !== "GET") return {
|
|
1134
|
-
kind: "live-only",
|
|
1135
|
-
endpoint,
|
|
1136
|
-
reason: "non_get_request"
|
|
1137
|
-
};
|
|
1138
|
-
if (endpointDefinition.auth === "user") return {
|
|
1139
|
-
kind: "live-only",
|
|
1140
|
-
endpoint,
|
|
1141
|
-
reason: "auth_required"
|
|
1142
|
-
};
|
|
1143
|
-
switch (override.kind) {
|
|
1144
|
-
case "durable-public-stale": return {
|
|
1145
|
-
kind: "durable-public-stale",
|
|
1146
|
-
endpoint,
|
|
1147
|
-
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
1148
|
-
staleTtlSec: override.staleTtlSec
|
|
1149
|
-
};
|
|
1150
|
-
case "memory-only": return {
|
|
1151
|
-
kind: "memory-only",
|
|
1152
|
-
endpoint,
|
|
1153
|
-
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
1154
|
-
reason: override.reason
|
|
1155
|
-
};
|
|
1156
|
-
default: return assertNever(override);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
function resolveRuntimeCachePolicy(input) {
|
|
1160
|
-
if (input.method && input.method.toUpperCase() !== "GET") return {
|
|
1161
|
-
kind: "live-only",
|
|
1162
|
-
endpoint: input.endpoint,
|
|
1163
|
-
reason: "non_get_request"
|
|
1164
|
-
};
|
|
1165
|
-
if (!isPublicEndpointName(input.endpoint)) return {
|
|
1166
|
-
kind: "live-only",
|
|
1167
|
-
endpoint: input.endpoint,
|
|
1168
|
-
reason: "unknown_endpoint"
|
|
1169
|
-
};
|
|
1170
|
-
return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
|
|
1171
|
-
}
|
|
1172
|
-
function classifyPublishedRuntimeCacheFreshness(input) {
|
|
1173
|
-
const freshUntilMs = Date.parse(input.freshUntil);
|
|
1174
|
-
const staleUntilMs = Date.parse(input.staleUntil);
|
|
1175
|
-
if (Number.isNaN(freshUntilMs)) return {
|
|
1176
|
-
kind: "invalid_timestamp",
|
|
1177
|
-
field: "freshUntil"
|
|
1178
|
-
};
|
|
1179
|
-
if (Number.isNaN(staleUntilMs)) return {
|
|
1180
|
-
kind: "invalid_timestamp",
|
|
1181
|
-
field: "staleUntil"
|
|
1182
|
-
};
|
|
1183
|
-
const nowMs = input.now.getTime();
|
|
1184
|
-
if (nowMs > staleUntilMs) return { kind: "expired" };
|
|
1185
|
-
if (nowMs <= freshUntilMs) return {
|
|
1186
|
-
kind: "fresh",
|
|
1187
|
-
staleAgeSec: 0
|
|
1188
|
-
};
|
|
1189
|
-
return {
|
|
1190
|
-
kind: "stale",
|
|
1191
|
-
staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
function derivePublishedRuntimeCacheKey(input) {
|
|
1195
|
-
const policy = resolveRuntimeCachePolicy({
|
|
1196
|
-
endpoint: input.endpoint,
|
|
1197
|
-
method: "GET",
|
|
1198
|
-
params: input.params
|
|
1199
|
-
});
|
|
1200
|
-
if (policy.kind !== "durable-public-stale") return {
|
|
1201
|
-
ok: false,
|
|
1202
|
-
error: {
|
|
1203
|
-
kind: "not_durable_eligible",
|
|
1204
|
-
policy
|
|
1205
|
-
}
|
|
1206
|
-
};
|
|
1207
|
-
return deriveDurableRuntimeCacheKey(input);
|
|
1208
|
-
}
|
|
1209
|
-
//#endregion
|
|
1210
|
-
//#region src/client/contentReadOperations.ts
|
|
1211
|
-
function planPublishedRuntimeCache(input) {
|
|
1212
|
-
const policy = resolveRuntimeCachePolicy({
|
|
1213
|
-
endpoint: input.endpoint,
|
|
1214
|
-
method: "GET",
|
|
1215
|
-
params: input.params
|
|
1216
|
-
});
|
|
1217
|
-
if (policy.kind !== "durable-public-stale") return null;
|
|
1218
|
-
const keyResult = derivePublishedRuntimeCacheKey(input);
|
|
1219
|
-
if (!keyResult.ok) return null;
|
|
1220
|
-
return {
|
|
1221
|
-
cacheKey: keyResult.key,
|
|
1222
|
-
endpoint: keyResult.endpoint,
|
|
1223
|
-
normalizedParams: keyResult.normalizedParams,
|
|
1224
|
-
freshTtlSec: policy.freshTtlSec,
|
|
1225
|
-
staleTtlSec: policy.staleTtlSec,
|
|
1226
|
-
siteId: input.siteId ?? null
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
function siteApiParams(params) {
|
|
1230
|
-
return {
|
|
1231
|
-
...params.slug ? { slug: params.slug } : {},
|
|
1232
|
-
...params.domain ? { domain: params.domain } : {},
|
|
1233
|
-
...params.id ? { id: params.id } : {},
|
|
1234
|
-
...params.currentPath ? { currentPath: params.currentPath } : {},
|
|
1235
|
-
...params.force ? { force: "true" } : {}
|
|
1236
|
-
};
|
|
1237
|
-
}
|
|
1238
|
-
function siteReadIdentity(params) {
|
|
1239
|
-
const identifier = params.slug || params.domain || params.id;
|
|
1240
|
-
if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
|
|
1241
|
-
return identifier;
|
|
1242
|
-
}
|
|
1243
|
-
function planSiteRead(params) {
|
|
1244
|
-
const identifier = siteReadIdentity(params);
|
|
1245
|
-
const { slug, domain, id, currentPath, force } = params;
|
|
1246
|
-
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
1247
|
-
endpoint: "getSite",
|
|
1248
|
-
params: {
|
|
1249
|
-
slug,
|
|
1250
|
-
domain,
|
|
1251
|
-
id,
|
|
1252
|
-
currentPath,
|
|
1253
|
-
force
|
|
1254
|
-
}
|
|
1255
|
-
});
|
|
1256
|
-
return {
|
|
1257
|
-
publishedRuntimeCache,
|
|
1258
|
-
prebuildIdentifier: id || slug || domain,
|
|
1259
|
-
cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
async function readSiteWithResilience(input, params) {
|
|
1263
|
-
const { slug, domain, id, signal, force } = params;
|
|
1264
|
-
const plan = planSiteRead(params);
|
|
1265
|
-
const prebuildId = plan.prebuildIdentifier;
|
|
1266
|
-
const prebuild = input.prebuildLoader;
|
|
1267
|
-
return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
|
|
1268
|
-
endpoint: "getSite",
|
|
1269
|
-
params: siteApiParams(params),
|
|
1270
|
-
options: {
|
|
1271
|
-
signal: requestSignal,
|
|
1272
|
-
...force ? { cache: "no-store" } : {}
|
|
1273
|
-
}
|
|
1274
|
-
}), {
|
|
1275
|
-
signal,
|
|
1276
|
-
force,
|
|
1277
|
-
publishedRuntimeCache: plan.publishedRuntimeCache,
|
|
1278
|
-
cacheTags: buildSiteReadTags({
|
|
1279
|
-
slug,
|
|
1280
|
-
domain,
|
|
1281
|
-
id
|
|
1282
|
-
}),
|
|
1283
|
-
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
async function readPageWithResilience(input, params) {
|
|
1287
|
-
const { siteId, path, preview = false, signal } = params;
|
|
1288
|
-
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
1289
|
-
endpoint: "getContentByPath",
|
|
1290
|
-
params: {
|
|
1291
|
-
siteId,
|
|
1292
|
-
path,
|
|
1293
|
-
preview
|
|
1294
|
-
},
|
|
1295
|
-
siteId
|
|
1296
|
-
});
|
|
1297
|
-
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
1298
|
-
return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
1299
|
-
endpoint: "getContentByPath",
|
|
1300
|
-
params: {
|
|
1301
|
-
siteId,
|
|
1302
|
-
path,
|
|
1303
|
-
preview: String(preview)
|
|
1304
|
-
},
|
|
1305
|
-
options: { signal: requestSignal }
|
|
1306
|
-
}), {
|
|
1307
|
-
preview,
|
|
1308
|
-
signal,
|
|
1309
|
-
publishedRuntimeCache,
|
|
1310
|
-
cacheTags: buildSiteReadTags({ siteId }),
|
|
1311
|
-
prebuildFallback: void 0
|
|
1312
|
-
});
|
|
1313
|
-
}
|
|
1314
|
-
function createContentReadOperations(input) {
|
|
1315
|
-
return {
|
|
1316
|
-
getSiteWithResilience: (params) => readSiteWithResilience(input, params),
|
|
1317
|
-
getPageWithResilience: (params) => readPageWithResilience(input, params)
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
//#endregion
|
|
1321
|
-
//#region src/client/publicAppointmentReadOperations.ts
|
|
1322
|
-
function createPublicAppointmentReadOperations(deps) {
|
|
1323
|
-
return {
|
|
1324
|
-
async getPublicBookingServices(params) {
|
|
1325
|
-
const { siteId, ids, signal } = params;
|
|
1326
|
-
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
1327
|
-
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
1328
|
-
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
1329
|
-
const apiParams = {
|
|
1330
|
-
siteId,
|
|
1331
|
-
...ids && { ids }
|
|
1332
|
-
};
|
|
1333
|
-
return await deps.apiClient({
|
|
1334
|
-
endpoint: "getPublicBookingServices",
|
|
1335
|
-
params: apiParams,
|
|
1336
|
-
options: { signal: requestSignal }
|
|
1337
|
-
});
|
|
1338
|
-
}, {
|
|
1339
|
-
signal,
|
|
1340
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
1341
|
-
});
|
|
1342
|
-
},
|
|
1343
|
-
async getPublicWeeklySlotAvailability(params) {
|
|
1344
|
-
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
1345
|
-
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
1346
|
-
const cacheKey = [
|
|
1347
|
-
"public-weekly-slot-availability",
|
|
1348
|
-
siteId,
|
|
1349
|
-
serviceId,
|
|
1350
|
-
resourceId ?? "",
|
|
1351
|
-
horizonWeeks ?? "",
|
|
1352
|
-
timezone ?? ""
|
|
1353
|
-
].join(":");
|
|
1354
|
-
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
1355
|
-
const apiParams = {
|
|
1356
|
-
siteId,
|
|
1357
|
-
serviceId,
|
|
1358
|
-
...resourceId && { resourceId },
|
|
1359
|
-
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
1360
|
-
...timezone && { timezone }
|
|
1361
|
-
};
|
|
1362
|
-
return await deps.apiClient({
|
|
1363
|
-
endpoint: "getPublicWeeklySlotAvailability",
|
|
1364
|
-
params: apiParams,
|
|
1365
|
-
options: { signal: requestSignal }
|
|
1366
|
-
});
|
|
1367
|
-
}, {
|
|
1368
|
-
signal,
|
|
1369
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
}
|
|
1374
|
-
//#endregion
|
|
1375
|
-
//#region src/client/publicEventReadOperations.ts
|
|
1376
|
-
function createPublicEventReadOperations(deps) {
|
|
1377
|
-
async function resolveEventSubroute(params, kind) {
|
|
1378
|
-
const { siteId, subject, segment, signal, preview = false } = params;
|
|
1379
|
-
if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
|
|
1380
|
-
const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
|
|
1381
|
-
return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
|
|
1382
|
-
endpoint: "resolveEventSubroute",
|
|
1383
|
-
params: {
|
|
1384
|
-
siteId,
|
|
1385
|
-
kind,
|
|
1386
|
-
subjectKind: subject.kind,
|
|
1387
|
-
subjectId,
|
|
1388
|
-
segment,
|
|
1389
|
-
stage: preview ? "preview" : "published"
|
|
1390
|
-
},
|
|
1391
|
-
options: { signal: requestSignal }
|
|
1392
|
-
}), {
|
|
1393
|
-
signal,
|
|
1394
|
-
preview,
|
|
1395
|
-
cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
return {
|
|
1399
|
-
async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
1400
|
-
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
1401
|
-
endpoint: "listPublicEventCalendarWindow",
|
|
1402
|
-
params: {
|
|
1403
|
-
...params,
|
|
1404
|
-
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
1405
|
-
},
|
|
1406
|
-
options: { signal: requestSignal }
|
|
1407
|
-
}), {
|
|
1408
|
-
signal,
|
|
1409
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
1410
|
-
});
|
|
1411
|
-
},
|
|
1412
|
-
async resolveEventOccurrence(params) {
|
|
1413
|
-
const response = await resolveEventSubroute(params, "event-occurrence");
|
|
1414
|
-
return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
|
|
1415
|
-
},
|
|
1416
|
-
async resolveEventRun(params) {
|
|
1417
|
-
const response = await resolveEventSubroute(params, "event-run");
|
|
1418
|
-
return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
//#endregion
|
|
1423
|
-
//#region src/client/combineAbortSignals.ts
|
|
1424
|
-
/** Combine signals into one that aborts when any input aborts. */
|
|
1425
|
-
function combineAbortSignals(...signals) {
|
|
1426
|
-
const controller = new AbortController();
|
|
1427
|
-
for (const signal of signals) {
|
|
1428
|
-
if (signal.aborted) {
|
|
1429
|
-
controller.abort(signal.reason);
|
|
1430
|
-
break;
|
|
1431
|
-
}
|
|
1432
|
-
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
1433
|
-
}
|
|
1434
|
-
return controller.signal;
|
|
1435
|
-
}
|
|
1436
|
-
//#endregion
|
|
1437
|
-
//#region src/client/publicLoaderCacheAccess.ts
|
|
1438
|
-
function shouldWrite(cacheEnabled, force) {
|
|
1439
|
-
return cacheEnabled && !force;
|
|
1440
|
-
}
|
|
1441
|
-
/**
|
|
1442
|
-
* Applies the canonical block-loader freshness policy at the SDK fetch seam.
|
|
1443
|
-
*
|
|
1444
|
-
* Callers provide the endpoint identity, but do not opt into live behavior.
|
|
1445
|
-
* This makes a newly-live endpoint bypass memory and fallback caches without a
|
|
1446
|
-
* second method-level wiring change.
|
|
1447
|
-
*/
|
|
1448
|
-
function applyPublicLoaderCachePolicy(endpoint, options) {
|
|
1449
|
-
if (!isPublicReadEndpoint(endpoint) || getPublicReadCachePolicy(endpoint).kind !== "live") return options;
|
|
1450
|
-
return {
|
|
1451
|
-
...options,
|
|
1452
|
-
force: true
|
|
1453
|
-
};
|
|
1454
|
-
}
|
|
1455
|
-
//#endregion
|
|
1456
|
-
//#region src/client/index.ts
|
|
1457
|
-
let prebuildModule = null;
|
|
1458
|
-
function tryRequire(modulePath) {
|
|
1459
|
-
try {
|
|
1460
|
-
const req = new Function("return typeof require === \"function\" ? require : null")();
|
|
1461
|
-
return req ? req(modulePath) : null;
|
|
1462
|
-
} catch {
|
|
1463
|
-
return null;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
function isNodeRuntime() {
|
|
1467
|
-
if (typeof globalThis !== "object" || globalThis === null) return false;
|
|
1468
|
-
return typeof globalThis.process?.versions?.node === "string";
|
|
1469
|
-
}
|
|
1470
|
-
function getPrebuildModule() {
|
|
1471
|
-
if (prebuildModule !== null) return prebuildModule;
|
|
1472
|
-
if (!isNodeRuntime()) return null;
|
|
1473
|
-
try {
|
|
1474
|
-
prebuildModule = tryRequire("../prebuild/loader");
|
|
1475
|
-
return prebuildModule;
|
|
1476
|
-
} catch {
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
function mergeDefaultHeaders(defaultHeaders, options) {
|
|
1481
|
-
if (!defaultHeaders || Object.keys(defaultHeaders).length === 0) return options;
|
|
1482
|
-
return {
|
|
1483
|
-
...options,
|
|
1484
|
-
headers: {
|
|
1485
|
-
...defaultHeaders,
|
|
1486
|
-
...Object.fromEntries(new Headers(options?.headers).entries())
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
}
|
|
1490
|
-
function withDefaultHeaders(apiClient, defaultHeaders) {
|
|
1491
|
-
return async (params) => apiClient({
|
|
1492
|
-
...params,
|
|
1493
|
-
options: mergeDefaultHeaders(defaultHeaders, params.options)
|
|
1494
|
-
});
|
|
1495
|
-
}
|
|
1496
|
-
setSdkVersion(SDK_VERSION);
|
|
1497
|
-
const DEFAULT_BROWSER_TIMEOUT_MS = 5e3;
|
|
1498
|
-
const DEFAULT_SERVER_TIMEOUT_MS = 8e3;
|
|
1499
|
-
const MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS = 50;
|
|
1500
|
-
function isDurableRuntimeCacheTier(cacheTier) {
|
|
1501
|
-
return cacheTier === "durable-fresh" || cacheTier === "durable-stale";
|
|
1502
|
-
}
|
|
1503
|
-
function isDegradedResilienceStatus(source, details) {
|
|
1504
|
-
return source === "stale" || source === "error" || isDurableRuntimeCacheTier(details.cacheTier) && details.error !== void 0;
|
|
1505
|
-
}
|
|
1506
|
-
/**
|
|
1507
|
-
* Generate a unique request ID for tracing
|
|
1508
|
-
*/
|
|
1509
|
-
function generateRequestId() {
|
|
1510
|
-
return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1511
|
-
}
|
|
1512
|
-
function toRecord(value) {
|
|
1513
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1514
|
-
}
|
|
1515
|
-
function getRuntimePayloadSiteId(value) {
|
|
1516
|
-
const site = toRecord(value).site;
|
|
1517
|
-
if (!site || typeof site !== "object" || Array.isArray(site)) return null;
|
|
1518
|
-
const id = site.id;
|
|
1519
|
-
return typeof id === "string" && id.trim().length > 0 ? id : null;
|
|
1520
|
-
}
|
|
1521
|
-
function getRiverbankErrorInfo(error) {
|
|
1522
|
-
if (error instanceof RiverbankApiError) return {
|
|
1523
|
-
code: error.code,
|
|
1524
|
-
message: error.message,
|
|
1525
|
-
status: error.status
|
|
1526
|
-
};
|
|
1527
|
-
if (error instanceof Error) return { message: error.message };
|
|
1528
|
-
return { message: String(error) };
|
|
1529
|
-
}
|
|
1530
|
-
function normalizeEntryIdentifierRefs(identifiers) {
|
|
1531
|
-
const trimmed = identifiers.map((identifier) => identifier.trim()).filter((identifier) => identifier.length > 0);
|
|
1532
|
-
if (trimmed.length === 0) return { kind: "empty" };
|
|
1533
|
-
if (trimmed.length > MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS) throw new Error(`getEntriesByIdentifiers() accepts at most ${MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS} identifiers`);
|
|
1534
|
-
const refs = [];
|
|
1535
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1536
|
-
for (const ref of trimmed) {
|
|
1537
|
-
if (seen.has(ref)) continue;
|
|
1538
|
-
seen.add(ref);
|
|
1539
|
-
refs.push(ref);
|
|
1540
|
-
}
|
|
1541
|
-
return {
|
|
1542
|
-
kind: "refs",
|
|
1543
|
-
refs
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
1546
|
-
function normalizePublicForm(form) {
|
|
1547
|
-
return {
|
|
1548
|
-
id: form.id,
|
|
1549
|
-
slug: form.slug,
|
|
1550
|
-
name: form.name,
|
|
1551
|
-
schema: toRecord(form.schemaJson),
|
|
1552
|
-
settings: toRecord(form.settingsJson),
|
|
1553
|
-
schemaJson: toRecord(form.schemaJson),
|
|
1554
|
-
settingsJson: toRecord(form.settingsJson),
|
|
1555
|
-
createdAt: form.createdAt ?? null,
|
|
1556
|
-
updatedAt: form.updatedAt ?? null,
|
|
1557
|
-
...form.siteId ? { siteId: form.siteId } : {},
|
|
1558
|
-
...form.userId ? { userId: form.userId } : {}
|
|
1559
|
-
};
|
|
1560
|
-
}
|
|
1561
|
-
function normalizePublicFormResponse(response) {
|
|
1562
|
-
return { form: response.form ? normalizePublicForm(response.form) : null };
|
|
1563
|
-
}
|
|
1564
|
-
function normalizePublicFormResult(result) {
|
|
1565
|
-
if (isApiError(result)) return result;
|
|
1566
|
-
return {
|
|
1567
|
-
...result,
|
|
1568
|
-
data: normalizePublicFormResponse(result.data)
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
function normalizePublicFormsResponse(response) {
|
|
1572
|
-
return { forms: response.forms.map((form) => normalizePublicForm(form)) };
|
|
1573
|
-
}
|
|
1574
|
-
function normalizePublicFormsResult(result) {
|
|
1575
|
-
if (isApiError(result)) return result;
|
|
1576
|
-
return {
|
|
1577
|
-
...result,
|
|
1578
|
-
data: normalizePublicFormsResponse(result.data)
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
function normalizeBatchBlockLoaderResult(response, requestId) {
|
|
1582
|
-
if (isApiError(response)) return response;
|
|
1583
|
-
const result = response.data.results[requestId];
|
|
1584
|
-
if (!result) throw new Error(`Missing batch block loader result for "${requestId}"`);
|
|
1585
|
-
if (!result.ok) throw new Error(result.error.message);
|
|
1586
|
-
return {
|
|
1587
|
-
...response,
|
|
1588
|
-
data: result.data
|
|
1589
|
-
};
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Check if an error is an AbortError (from AbortController.abort())
|
|
1593
|
-
*/
|
|
1594
|
-
function isAbortError(error) {
|
|
1595
|
-
if (error instanceof DOMException && error.name === "AbortError") return true;
|
|
1596
|
-
if (error instanceof Error && error.name === "AbortError") return true;
|
|
1597
|
-
return false;
|
|
1598
|
-
}
|
|
1599
|
-
/**
|
|
1600
|
-
* Determine the network error code based on error type, code, and message.
|
|
1601
|
-
* Uses multiple detection strategies for cross-runtime compatibility:
|
|
1602
|
-
* 1. Error name (TimeoutError, AbortError) - reliable in browsers
|
|
1603
|
-
* 2. Node.js error code (ETIMEDOUT, ENOTFOUND, etc.) - most reliable in Node
|
|
1604
|
-
* 3. Message matching - fallback for edge cases
|
|
1605
|
-
*/
|
|
1606
|
-
function getNetworkErrorCode(error) {
|
|
1607
|
-
if (error.name === "TimeoutError" || error.name === "AbortError") return "network:timeout";
|
|
1608
|
-
const nodeError = error;
|
|
1609
|
-
if (nodeError.code) switch (nodeError.code) {
|
|
1610
|
-
case "ETIMEDOUT":
|
|
1611
|
-
case "ESOCKETTIMEDOUT": return "network:timeout";
|
|
1612
|
-
case "ENOTFOUND":
|
|
1613
|
-
case "EAI_AGAIN": return "network:dns_error";
|
|
1614
|
-
case "ECONNREFUSED":
|
|
1615
|
-
case "ECONNRESET":
|
|
1616
|
-
case "EPIPE": return "network:connection_error";
|
|
1617
|
-
}
|
|
1618
|
-
const message = error.message.toLowerCase();
|
|
1619
|
-
if (message.includes("timeout") || message.includes("timed out")) return "network:timeout";
|
|
1620
|
-
if (message.includes("dns") || message.includes("getaddrinfo") || message.includes("enotfound")) return "network:dns_error";
|
|
1621
|
-
return "network:connection_error";
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* Convert API errors to RiverbankApiError for consistent SDK error handling.
|
|
1625
|
-
* Handles:
|
|
1626
|
-
* - ApiEnvelopeError (from unwrapResponse)
|
|
1627
|
-
* - ApiRequestError (from fetch with HTTP error)
|
|
1628
|
-
* - Network errors (TypeError, etc. - wrapped with status 0)
|
|
1629
|
-
* - AbortError (let propagate raw for consumer detection)
|
|
1630
|
-
*/
|
|
1631
|
-
function convertToTypedError(error) {
|
|
1632
|
-
if (isAbortError(error)) throw error;
|
|
1633
|
-
if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
|
|
1634
|
-
code: error.code,
|
|
1635
|
-
message: error.message,
|
|
1636
|
-
requestId: error.requestId,
|
|
1637
|
-
timestamp: error.timestamp,
|
|
1638
|
-
status: error.status,
|
|
1639
|
-
fieldErrors: error.fieldErrors
|
|
1640
|
-
});
|
|
1641
|
-
if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
|
|
1642
|
-
const body = error.body;
|
|
1643
|
-
if (isApiError(body)) {
|
|
1644
|
-
const envelopeError = body.error;
|
|
1645
|
-
throw new RiverbankApiError({
|
|
1646
|
-
...envelopeError,
|
|
1647
|
-
retryAfterMs: error.retryAfterMs
|
|
1648
|
-
});
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
if (error instanceof TypeError || error instanceof Error && !("status" in error)) {
|
|
1652
|
-
const networkError = error;
|
|
1653
|
-
throw new RiverbankApiError({
|
|
1654
|
-
code: getNetworkErrorCode(networkError),
|
|
1655
|
-
message: networkError.message || "Network request failed",
|
|
1656
|
-
requestId: `local-${Date.now()}`,
|
|
1657
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1658
|
-
status: 0,
|
|
1659
|
-
cause: networkError
|
|
1660
|
-
});
|
|
1661
|
-
}
|
|
1662
|
-
throw error;
|
|
1663
|
-
}
|
|
1664
|
-
/**
|
|
1665
|
-
* Detect API key type from prefix.
|
|
1666
|
-
*
|
|
1667
|
-
* Key prefixes:
|
|
1668
|
-
* - bld_live_sk_* / bld_test_sk_* → 'content' (published content)
|
|
1669
|
-
* - bld_preview_sk_* → 'preview' (draft content)
|
|
1670
|
-
*/
|
|
1671
|
-
function detectKeyType(apiKey) {
|
|
1672
|
-
if (apiKey.startsWith("bld_live_sk_") || apiKey.startsWith("bld_test_sk_")) return "content";
|
|
1673
|
-
if (apiKey.startsWith("bld_preview_sk_")) return "preview";
|
|
1674
|
-
return "unknown";
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* Resolve auth configuration from config, handling backward compatibility.
|
|
1678
|
-
* Throws if neither `auth` nor `apiKey` is provided.
|
|
1679
|
-
*/
|
|
1680
|
-
function resolveAuth(config) {
|
|
1681
|
-
if (config.auth) return config.auth;
|
|
1682
|
-
if (config.apiKey) return {
|
|
1683
|
-
type: "api-key",
|
|
1684
|
-
key: config.apiKey
|
|
1685
|
-
};
|
|
1686
|
-
throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
|
|
1687
|
-
}
|
|
1688
|
-
const defaultRiverbankClientDeps = {
|
|
1689
|
-
createBearerAPIClient,
|
|
1690
|
-
createInternalAPIClient
|
|
1691
|
-
};
|
|
1692
|
-
/**
|
|
1693
|
-
* Create a Riverbank CMS client for fetching content
|
|
1694
|
-
*
|
|
1695
|
-
* @example
|
|
1696
|
-
* ```ts
|
|
1697
|
-
* const client = createRiverbankClient({
|
|
1698
|
-
* apiKey: 'bld_live_sk_...',
|
|
1699
|
-
* baseUrl: 'https://dashboard.example.com/api',
|
|
1700
|
-
* });
|
|
1701
|
-
*
|
|
1702
|
-
* const site = await client.getSite({ slug: 'my-site' });
|
|
1703
|
-
* ```
|
|
1704
|
-
*/
|
|
1705
|
-
function createRiverbankClient(config) {
|
|
1706
|
-
return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
|
|
1707
|
-
}
|
|
1708
|
-
function createRiverbankClientWithDeps(deps, config) {
|
|
1709
|
-
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)");
|
|
1710
|
-
if (!config.baseUrl.endsWith("/api")) throw new Error(`baseUrl must end with '/api'. Received: ${config.baseUrl}. Expected format: https://dashboard.example.com/api`);
|
|
1711
|
-
const cacheEnabled = config.cache?.enabled ?? true;
|
|
1712
|
-
const cacheTTL = (config.cache?.ttl ?? 300) * 1e3;
|
|
1713
|
-
const cacheMaxSize = config.cache?.maxSize ?? 100;
|
|
1714
|
-
const resilienceEnabled = config.resilience?.enabled ?? true;
|
|
1715
|
-
const staleIfError = config.resilience?.staleIfError ?? true;
|
|
1716
|
-
const staleTtlMs = (config.resilience?.staleTtlSec ?? 300) * 1e3;
|
|
1717
|
-
const requestTimeoutMs = config.resilience?.requestTimeoutMs ?? (typeof window !== "undefined" ? DEFAULT_BROWSER_TIMEOUT_MS : DEFAULT_SERVER_TIMEOUT_MS);
|
|
1718
|
-
const retryConfig = {
|
|
1719
|
-
maxAttempts: config.resilience?.retry?.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts,
|
|
1720
|
-
baseDelayMs: config.resilience?.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
|
|
1721
|
-
maxDelayMs: config.resilience?.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,
|
|
1722
|
-
jitter: config.resilience?.retry?.jitter ?? DEFAULT_RETRY_CONFIG.jitter,
|
|
1723
|
-
retryOn: config.resilience?.retry?.retryOn
|
|
1724
|
-
};
|
|
1725
|
-
const circuitBreakerConfig = {
|
|
1726
|
-
failureThreshold: config.resilience?.circuitBreaker?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
1727
|
-
resetTimeoutMs: config.resilience?.circuitBreaker?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
1728
|
-
halfOpenMaxRequests: config.resilience?.circuitBreaker?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
1729
|
-
};
|
|
1730
|
-
const authConfig = resolveAuth(config);
|
|
1731
|
-
let keyType;
|
|
1732
|
-
switch (authConfig.type) {
|
|
1733
|
-
case "none":
|
|
1734
|
-
keyType = "unknown";
|
|
1735
|
-
break;
|
|
1736
|
-
case "api-key":
|
|
1737
|
-
keyType = detectKeyType(authConfig.key);
|
|
1738
|
-
break;
|
|
1739
|
-
case "bearer":
|
|
1740
|
-
keyType = "preview";
|
|
1741
|
-
break;
|
|
1742
|
-
}
|
|
1743
|
-
const apiClient = withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl) : authConfig.type === "api-key" ? deps.createBearerAPIClient(authConfig.key, config.baseUrl) : deps.createBearerAPIClient(authConfig.token, config.baseUrl), config.defaultHeaders);
|
|
1744
|
-
const cache = new SimpleCache({
|
|
1745
|
-
maxSize: cacheMaxSize,
|
|
1746
|
-
ttl: cacheTTL,
|
|
1747
|
-
staleTtl: staleTtlMs
|
|
1748
|
-
});
|
|
1749
|
-
const circuitBreaker = new CircuitBreaker(circuitBreakerConfig);
|
|
1750
|
-
const prebuildDir = config.resilience?.prebuildDir;
|
|
1751
|
-
const prebuildMod = prebuildDir ? getPrebuildModule() : null;
|
|
1752
|
-
const prebuildLoader = (prebuildMod?.canUsePrebuild() ?? false) && prebuildMod && prebuildDir ? new prebuildMod.PrebuildLoader({
|
|
1753
|
-
prebuildDir,
|
|
1754
|
-
maxPrebuildAgeSec: config.resilience?.maxPrebuildAgeSec
|
|
1755
|
-
}) : null;
|
|
1756
|
-
let lastStatus = null;
|
|
1757
|
-
let isDegraded = false;
|
|
1758
|
-
/**
|
|
1759
|
-
* Emit a status update and trigger callbacks
|
|
1760
|
-
*/
|
|
1761
|
-
function emitStatus(source, data, details) {
|
|
1762
|
-
const status = {
|
|
1763
|
-
source,
|
|
1764
|
-
isPreview: details.isPreview,
|
|
1765
|
-
cacheKey: details.cacheKey,
|
|
1766
|
-
cacheTier: details.cacheTier,
|
|
1767
|
-
durableCache: details.durableCache,
|
|
1768
|
-
error: details.error,
|
|
1769
|
-
staleAgeSec: details.staleAgeSec,
|
|
1770
|
-
prebuildAgeSec: details.prebuildAgeSec,
|
|
1771
|
-
circuit: circuitBreaker.getState(),
|
|
1772
|
-
requestId: details.requestId,
|
|
1773
|
-
durationMs: details.durationMs
|
|
1774
|
-
};
|
|
1775
|
-
lastStatus = status;
|
|
1776
|
-
config.resilience?.onStatusChange?.(status);
|
|
1777
|
-
const nowDegraded = isDegradedResilienceStatus(source, details);
|
|
1778
|
-
if (nowDegraded !== isDegraded) {
|
|
1779
|
-
isDegraded = nowDegraded;
|
|
1780
|
-
config.resilience?.onDegradedMode?.(nowDegraded, status);
|
|
1781
|
-
}
|
|
1782
|
-
return {
|
|
1783
|
-
data,
|
|
1784
|
-
resilience: status
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1787
|
-
async function tryPublishedRuntimeCacheFallback(plan, statusDetails, errorInfo) {
|
|
1788
|
-
const reader = config.publishedRuntimeCache?.read;
|
|
1789
|
-
if (!plan || !reader) return null;
|
|
1790
|
-
try {
|
|
1791
|
-
const result = await reader({
|
|
1792
|
-
cacheKey: plan.cacheKey,
|
|
1793
|
-
endpoint: plan.endpoint,
|
|
1794
|
-
payloadSchemaVersion: 4
|
|
1795
|
-
});
|
|
1796
|
-
if (result.kind === "miss") return {
|
|
1797
|
-
kind: "miss",
|
|
1798
|
-
diagnostic: {
|
|
1799
|
-
outcome: "miss",
|
|
1800
|
-
reason: result.reason
|
|
1801
|
-
}
|
|
1802
|
-
};
|
|
1803
|
-
if (result.kind === "error") return {
|
|
1804
|
-
kind: "error",
|
|
1805
|
-
diagnostic: {
|
|
1806
|
-
outcome: "error",
|
|
1807
|
-
error: result.error
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
return {
|
|
1811
|
-
kind: "hit",
|
|
1812
|
-
result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
|
|
1813
|
-
error: errorInfo,
|
|
1814
|
-
staleAgeSec: result.staleAgeSec,
|
|
1815
|
-
cacheTier: result.freshness === "fresh" ? "durable-fresh" : "durable-stale"
|
|
1816
|
-
}))
|
|
1817
|
-
};
|
|
1818
|
-
} catch (error) {
|
|
1819
|
-
return {
|
|
1820
|
-
kind: "error",
|
|
1821
|
-
diagnostic: {
|
|
1822
|
-
outcome: "error",
|
|
1823
|
-
error: {
|
|
1824
|
-
kind: "adapter_exception",
|
|
1825
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
async function writePublishedRuntimeCache(plan, payload) {
|
|
1832
|
-
const writer = config.publishedRuntimeCache?.write;
|
|
1833
|
-
if (!plan || !writer) return;
|
|
1834
|
-
try {
|
|
1835
|
-
await writer({
|
|
1836
|
-
cacheKey: plan.cacheKey,
|
|
1837
|
-
endpoint: plan.endpoint,
|
|
1838
|
-
normalizedParams: plan.normalizedParams,
|
|
1839
|
-
payload,
|
|
1840
|
-
siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
|
|
1841
|
-
freshTtlSec: plan.freshTtlSec,
|
|
1842
|
-
staleTtlSec: plan.staleTtlSec,
|
|
1843
|
-
payloadSchemaVersion: 4,
|
|
1844
|
-
writeReason: "live_success"
|
|
1845
|
-
});
|
|
1846
|
-
} catch {}
|
|
1847
|
-
}
|
|
1848
|
-
async function resilientFetch(cacheKey, fetcher, options) {
|
|
1849
|
-
const requestId = generateRequestId();
|
|
1850
|
-
const startTime = Date.now();
|
|
1851
|
-
const isPreview = options.preview ?? false;
|
|
1852
|
-
const allowFallbacks = !options.force;
|
|
1853
|
-
const statusDetails = (extra = {}) => ({
|
|
1854
|
-
requestId,
|
|
1855
|
-
cacheKey,
|
|
1856
|
-
isPreview,
|
|
1857
|
-
durationMs: Date.now() - startTime,
|
|
1858
|
-
...extra
|
|
1859
|
-
});
|
|
1860
|
-
if (cacheEnabled && !options.force) {
|
|
1861
|
-
const fresh = cache.getFresh(cacheKey);
|
|
1862
|
-
if (fresh !== null) return emitStatus("cache", fresh, statusDetails({ cacheTier: "memory-fresh" }));
|
|
1863
|
-
}
|
|
1864
|
-
if (resilienceEnabled && circuitBreaker.isOpen()) {
|
|
1865
|
-
if (allowFallbacks && !isPreview && staleIfError) {
|
|
1866
|
-
const stale = cache.getStale(cacheKey);
|
|
1867
|
-
if (stale) return emitStatus("stale", stale.value, statusDetails({
|
|
1868
|
-
staleAgeSec: stale.staleAgeSec,
|
|
1869
|
-
cacheTier: "memory-stale",
|
|
1870
|
-
error: {
|
|
1871
|
-
code: "circuit_open",
|
|
1872
|
-
message: "Circuit breaker is open"
|
|
1873
|
-
}
|
|
1874
|
-
}));
|
|
1875
|
-
}
|
|
1876
|
-
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, {
|
|
1877
|
-
code: "circuit_open",
|
|
1878
|
-
message: "Circuit breaker is open"
|
|
1879
|
-
}) : null;
|
|
1880
|
-
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
1881
|
-
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
1882
|
-
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
1883
|
-
const prebuildResult = options.prebuildFallback();
|
|
1884
|
-
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
1885
|
-
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
1886
|
-
cacheTier: "prebuild",
|
|
1887
|
-
durableCache,
|
|
1888
|
-
error: {
|
|
1889
|
-
code: "circuit_open",
|
|
1890
|
-
message: "Circuit breaker is open"
|
|
1891
|
-
}
|
|
1892
|
-
}));
|
|
1893
|
-
}
|
|
1894
|
-
const circuitState = circuitBreaker.getState();
|
|
1895
|
-
emitStatus("error", null, statusDetails({
|
|
1896
|
-
durableCache,
|
|
1897
|
-
error: {
|
|
1898
|
-
code: "circuit_open",
|
|
1899
|
-
message: "Circuit breaker is open"
|
|
1900
|
-
}
|
|
1901
|
-
}));
|
|
1902
|
-
throw new CircuitOpenError(circuitState);
|
|
1903
|
-
}
|
|
1904
|
-
try {
|
|
1905
|
-
let data;
|
|
1906
|
-
if (resilienceEnabled) {
|
|
1907
|
-
if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
|
|
1908
|
-
data = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
|
|
1909
|
-
const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
|
|
1910
|
-
try {
|
|
1911
|
-
return unwrapResponse(await fetcher(combinedSignal));
|
|
1912
|
-
} catch (error) {
|
|
1913
|
-
convertToTypedError(error);
|
|
1914
|
-
}
|
|
1915
|
-
}, {
|
|
1916
|
-
...retryConfig,
|
|
1917
|
-
requestTimeoutMs
|
|
1918
|
-
});
|
|
1919
|
-
circuitBreaker.recordSuccess();
|
|
1920
|
-
} else try {
|
|
1921
|
-
data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
|
|
1922
|
-
} catch (error) {
|
|
1923
|
-
convertToTypedError(error);
|
|
1924
|
-
}
|
|
1925
|
-
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, { tags: options.cacheTags });
|
|
1926
|
-
if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
|
|
1927
|
-
return emitStatus("live", data, statusDetails());
|
|
1928
|
-
} catch (error) {
|
|
1929
|
-
if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
|
|
1930
|
-
if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
|
|
1931
|
-
const stale = cache.getStale(cacheKey);
|
|
1932
|
-
if (stale) {
|
|
1933
|
-
const errorInfo = getRiverbankErrorInfo(error);
|
|
1934
|
-
return emitStatus("stale", stale.value, statusDetails({
|
|
1935
|
-
staleAgeSec: stale.staleAgeSec,
|
|
1936
|
-
cacheTier: "memory-stale",
|
|
1937
|
-
error: errorInfo
|
|
1938
|
-
}));
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
const errorInfo = getRiverbankErrorInfo(error);
|
|
1942
|
-
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
|
|
1943
|
-
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
1944
|
-
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
1945
|
-
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
1946
|
-
const prebuildResult = options.prebuildFallback();
|
|
1947
|
-
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
1948
|
-
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
1949
|
-
cacheTier: "prebuild",
|
|
1950
|
-
durableCache,
|
|
1951
|
-
error: errorInfo
|
|
1952
|
-
}));
|
|
1953
|
-
}
|
|
1954
|
-
throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
|
|
1955
|
-
error: errorInfo,
|
|
1956
|
-
durableCache
|
|
1957
|
-
})).resilience);
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
async function resilientFetchData(policyEndpoint, cacheKey, fetcher, options) {
|
|
1961
|
-
return (await resilientFetch(cacheKey, fetcher, applyPublicLoaderCachePolicy(policyEndpoint, options))).data;
|
|
1962
|
-
}
|
|
1963
|
-
const contentReads = createContentReadOperations({
|
|
1964
|
-
apiClient,
|
|
1965
|
-
resilientFetch,
|
|
1966
|
-
prebuildLoader
|
|
1967
|
-
});
|
|
1968
|
-
const eventReads = createPublicEventReadOperations({
|
|
1969
|
-
apiClient,
|
|
1970
|
-
resilientFetchData
|
|
1971
|
-
});
|
|
1972
|
-
const publicAppointmentReads = createPublicAppointmentReadOperations({
|
|
1973
|
-
apiClient,
|
|
1974
|
-
resilientFetchData
|
|
1975
|
-
});
|
|
1976
|
-
async function getEntriesInternal(params) {
|
|
1977
|
-
const { siteId, preview = false, signal } = params;
|
|
1978
|
-
const request = buildEntryListReadRequest(params);
|
|
1979
|
-
return resilientFetchData("listPublishedEntries", request.cacheKey, (sig) => apiClient({
|
|
1980
|
-
endpoint: "listPublishedEntries",
|
|
1981
|
-
params: request.params,
|
|
1982
|
-
options: { signal: sig }
|
|
1983
|
-
}), {
|
|
1984
|
-
preview,
|
|
1985
|
-
signal,
|
|
1986
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublishedEntries", { siteId }),
|
|
1987
|
-
prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
|
|
1988
|
-
});
|
|
1989
|
-
}
|
|
1990
|
-
return {
|
|
1991
|
-
async getSite(params) {
|
|
1992
|
-
return (await contentReads.getSiteWithResilience(params)).data;
|
|
1993
|
-
},
|
|
1994
|
-
async getSiteWithResilience(params) {
|
|
1995
|
-
return contentReads.getSiteWithResilience(params);
|
|
1996
|
-
},
|
|
1997
|
-
async getPage(params) {
|
|
1998
|
-
return (await contentReads.getPageWithResilience(params)).data;
|
|
1999
|
-
},
|
|
2000
|
-
async getPageWithResilience(params) {
|
|
2001
|
-
return contentReads.getPageWithResilience(params);
|
|
2002
|
-
},
|
|
2003
|
-
async getEntries(params) {
|
|
2004
|
-
return getEntriesInternal(params);
|
|
2005
|
-
},
|
|
2006
|
-
async getEntriesByIdentifiers(params) {
|
|
2007
|
-
const { siteId, contentType, identifiers, preview, signal } = params;
|
|
2008
|
-
const normalized = normalizeEntryIdentifierRefs(identifiers);
|
|
2009
|
-
if (normalized.kind === "empty") return { entries: [] };
|
|
2010
|
-
return getEntriesInternal({
|
|
2011
|
-
siteId,
|
|
2012
|
-
contentType,
|
|
2013
|
-
preview,
|
|
2014
|
-
signal,
|
|
2015
|
-
mode: "manual",
|
|
2016
|
-
entryIds: normalized.refs
|
|
2017
|
-
});
|
|
2018
|
-
},
|
|
2019
|
-
async getEntry(params) {
|
|
2020
|
-
const { siteId, contentType, slug, signal } = params;
|
|
2021
|
-
return resilientFetchData("getPublishedEntryPreview", `entry:${siteId}:${contentType}:${slug}`, async (sig) => {
|
|
2022
|
-
return await apiClient({
|
|
2023
|
-
endpoint: "getPublishedEntryPreview",
|
|
2024
|
-
params: {
|
|
2025
|
-
siteId,
|
|
2026
|
-
type: contentType,
|
|
2027
|
-
slug
|
|
2028
|
-
},
|
|
2029
|
-
options: { signal: sig }
|
|
2030
|
-
});
|
|
2031
|
-
}, {
|
|
2032
|
-
signal,
|
|
2033
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublishedEntryPreview", { siteId })
|
|
2034
|
-
});
|
|
2035
|
-
},
|
|
2036
|
-
async getPublicFormById(params) {
|
|
2037
|
-
const { formId, siteId, signal } = params;
|
|
2038
|
-
if (!formId || !siteId) throw new Error("getPublicFormById() requires formId and siteId");
|
|
2039
|
-
return resilientFetchData("getPublicFormById", `public-form:${siteId}:${formId}`, async (sig) => {
|
|
2040
|
-
return normalizePublicFormResult(await apiClient({
|
|
2041
|
-
endpoint: "getPublicFormById",
|
|
2042
|
-
params: {
|
|
2043
|
-
formId,
|
|
2044
|
-
siteId
|
|
2045
|
-
},
|
|
2046
|
-
options: { signal: sig }
|
|
2047
|
-
}));
|
|
2048
|
-
}, {
|
|
2049
|
-
signal,
|
|
2050
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicFormById", {
|
|
2051
|
-
siteId,
|
|
2052
|
-
formId
|
|
2053
|
-
})
|
|
2054
|
-
});
|
|
2055
|
-
},
|
|
2056
|
-
async getForms(params) {
|
|
2057
|
-
const { siteId, signal } = params;
|
|
2058
|
-
if (!siteId) throw new Error("getForms() requires siteId");
|
|
2059
|
-
return resilientFetchData("listPublicForms", `forms:${siteId}`, async (sig) => {
|
|
2060
|
-
return normalizePublicFormsResult(await apiClient({
|
|
2061
|
-
endpoint: "listPublicForms",
|
|
2062
|
-
params: { siteId },
|
|
2063
|
-
options: { signal: sig }
|
|
2064
|
-
}));
|
|
2065
|
-
}, {
|
|
2066
|
-
signal,
|
|
2067
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicForms", { siteId }),
|
|
2068
|
-
prebuildFallback: prebuildLoader ? () => {
|
|
2069
|
-
const result = prebuildLoader.loadForms();
|
|
2070
|
-
if (result) return {
|
|
2071
|
-
data: { forms: result.data.map((form) => ({
|
|
2072
|
-
id: form.id,
|
|
2073
|
-
slug: form.slug,
|
|
2074
|
-
name: form.name,
|
|
2075
|
-
schema: form.schema,
|
|
2076
|
-
settings: form.settings,
|
|
2077
|
-
schemaJson: form.schema,
|
|
2078
|
-
settingsJson: form.settings,
|
|
2079
|
-
createdAt: null,
|
|
2080
|
-
updatedAt: null
|
|
2081
|
-
})) },
|
|
2082
|
-
prebuildAgeSec: result.prebuildAgeSec
|
|
2083
|
-
};
|
|
2084
|
-
return null;
|
|
2085
|
-
} : void 0
|
|
2086
|
-
});
|
|
2087
|
-
},
|
|
2088
|
-
...publicAppointmentReads,
|
|
2089
|
-
async listPublicEvents(params) {
|
|
2090
|
-
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, detailLevel, readProfile, seriesId, includeOccurrenceId, signal } = params;
|
|
2091
|
-
if (!siteId) throw new Error("listPublicEvents() requires siteId");
|
|
2092
|
-
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) => {
|
|
2093
|
-
return await apiClient({
|
|
2094
|
-
endpoint: "listPublicEvents",
|
|
2095
|
-
params: {
|
|
2096
|
-
siteId,
|
|
2097
|
-
...typeof limit === "number" && { limit: String(limit) },
|
|
2098
|
-
...from && { from },
|
|
2099
|
-
...to && { to },
|
|
2100
|
-
...afterStartsAt && { afterStartsAt },
|
|
2101
|
-
...afterId && { afterId },
|
|
2102
|
-
...stage && { stage },
|
|
2103
|
-
...categoryIds && { categoryIds },
|
|
2104
|
-
...venueId && { venueId },
|
|
2105
|
-
...staffMemberId && { staffMemberId },
|
|
2106
|
-
...kind && { kind },
|
|
2107
|
-
...eventSurface && { eventSurface },
|
|
2108
|
-
...eventPresets && { eventPresets },
|
|
2109
|
-
...scheduleScope && { scheduleScope },
|
|
2110
|
-
...detailLevel && { detailLevel },
|
|
2111
|
-
...readProfile && { readProfile },
|
|
2112
|
-
...seriesId && { seriesId },
|
|
2113
|
-
...includeOccurrenceId && { includeOccurrenceId }
|
|
2114
|
-
},
|
|
2115
|
-
options: { signal: sig }
|
|
2116
|
-
});
|
|
2117
|
-
}, {
|
|
2118
|
-
signal,
|
|
2119
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicEvents", { siteId })
|
|
2120
|
-
});
|
|
2121
|
-
},
|
|
2122
|
-
async getPublicEventDetails(params) {
|
|
2123
|
-
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, seriesId, includeOccurrenceId, signal } = params;
|
|
2124
|
-
if (!siteId) throw new Error("getPublicEventDetails() requires siteId");
|
|
2125
|
-
return resilientFetchData("getPublicEventDetails", `public-event-details:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
|
|
2126
|
-
const requestId = "eventDetails";
|
|
2127
|
-
return normalizeBatchBlockLoaderResult(await apiClient({
|
|
2128
|
-
endpoint: "batchBlockLoaders",
|
|
2129
|
-
params: {
|
|
2130
|
-
siteId,
|
|
2131
|
-
...stage && { stage }
|
|
2132
|
-
},
|
|
2133
|
-
body: { requests: [{
|
|
2134
|
-
id: requestId,
|
|
2135
|
-
endpoint: "getPublicEventDetails",
|
|
2136
|
-
params: {
|
|
2137
|
-
...typeof limit === "number" && { limit: String(limit) },
|
|
2138
|
-
...from && { from },
|
|
2139
|
-
...to && { to },
|
|
2140
|
-
...afterStartsAt && { afterStartsAt },
|
|
2141
|
-
...afterId && { afterId },
|
|
2142
|
-
...categoryIds && { categoryIds },
|
|
2143
|
-
...venueId && { venueId },
|
|
2144
|
-
...staffMemberId && { staffMemberId },
|
|
2145
|
-
...kind && { kind },
|
|
2146
|
-
...eventSurface && { eventSurface },
|
|
2147
|
-
...eventPresets && { eventPresets },
|
|
2148
|
-
...scheduleScope && { scheduleScope },
|
|
2149
|
-
...seriesId && { seriesId },
|
|
2150
|
-
...includeOccurrenceId && { includeOccurrenceId }
|
|
2151
|
-
}
|
|
2152
|
-
}] },
|
|
2153
|
-
options: { signal: sig }
|
|
2154
|
-
}), requestId);
|
|
2155
|
-
}, {
|
|
2156
|
-
signal,
|
|
2157
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicEventDetails", { siteId })
|
|
2158
|
-
});
|
|
2159
|
-
},
|
|
2160
|
-
async listPublicTeamMembers(params) {
|
|
2161
|
-
const { siteId, stage, signal } = params;
|
|
2162
|
-
if (!siteId) throw new Error("listPublicTeamMembers() requires siteId");
|
|
2163
|
-
return resilientFetchData("listPublicTeamMembers", `public-team-members:${siteId}:${stage ?? ""}`, async (sig) => {
|
|
2164
|
-
return await apiClient({
|
|
2165
|
-
endpoint: "listPublicTeamMembers",
|
|
2166
|
-
params: {
|
|
2167
|
-
siteId,
|
|
2168
|
-
...stage && { stage }
|
|
2169
|
-
},
|
|
2170
|
-
options: { signal: sig }
|
|
2171
|
-
});
|
|
2172
|
-
}, {
|
|
2173
|
-
signal,
|
|
2174
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicTeamMembers", { siteId })
|
|
2175
|
-
});
|
|
2176
|
-
},
|
|
2177
|
-
async listPublicProducts(params) {
|
|
2178
|
-
const { siteId, stage, categorySelector, signal } = params;
|
|
2179
|
-
if (!siteId) throw new Error("listPublicProducts() requires siteId");
|
|
2180
|
-
const selectorKey = categorySelector ? categorySelector.kind === "category" ? `category:${categorySelector.productCategoryId}` : `current-category-page:${categorySelector.productCategoryEntryId}` : "";
|
|
2181
|
-
return resilientFetchData("listPublicProducts", `public-products:${siteId}:${stage ?? ""}:${selectorKey}`, async (sig) => {
|
|
2182
|
-
return await apiClient({
|
|
2183
|
-
endpoint: "listPublicProducts",
|
|
2184
|
-
params: {
|
|
2185
|
-
siteId,
|
|
2186
|
-
...stage && { stage },
|
|
2187
|
-
...encodePublicProductCategorySelector(categorySelector)
|
|
2188
|
-
},
|
|
2189
|
-
options: { signal: sig }
|
|
2190
|
-
});
|
|
2191
|
-
}, {
|
|
2192
|
-
signal,
|
|
2193
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicProducts", { siteId })
|
|
2194
|
-
});
|
|
2195
|
-
},
|
|
2196
|
-
async listPublicPasses(params) {
|
|
2197
|
-
const { siteId, categories, signal } = params;
|
|
2198
|
-
if (!siteId) throw new Error("listPublicPasses() requires siteId");
|
|
2199
|
-
return resilientFetchData("listPublicPasses", `public-passes:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
2200
|
-
return await apiClient({
|
|
2201
|
-
endpoint: "listPublicPasses",
|
|
2202
|
-
params: {
|
|
2203
|
-
siteId,
|
|
2204
|
-
...categories && { categories }
|
|
2205
|
-
},
|
|
2206
|
-
options: { signal: sig }
|
|
2207
|
-
});
|
|
2208
|
-
}, {
|
|
2209
|
-
signal,
|
|
2210
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicPasses", { siteId })
|
|
2211
|
-
});
|
|
2212
|
-
},
|
|
2213
|
-
async listPublicMemberships(params) {
|
|
2214
|
-
const { siteId, categories, signal } = params;
|
|
2215
|
-
if (!siteId) throw new Error("listPublicMemberships() requires siteId");
|
|
2216
|
-
return resilientFetchData("listPublicMemberships", `public-memberships:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
2217
|
-
return await apiClient({
|
|
2218
|
-
endpoint: "listPublicMemberships",
|
|
2219
|
-
params: {
|
|
2220
|
-
siteId,
|
|
2221
|
-
...categories && { categories }
|
|
2222
|
-
},
|
|
2223
|
-
options: { signal: sig }
|
|
2224
|
-
});
|
|
2225
|
-
}, {
|
|
2226
|
-
signal,
|
|
2227
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicMemberships", { siteId })
|
|
2228
|
-
});
|
|
2229
|
-
},
|
|
2230
|
-
...eventReads,
|
|
2231
|
-
async checkRedirect(params) {
|
|
2232
|
-
const { siteId, path, signal } = params;
|
|
2233
|
-
if (!siteId || !path) throw new Error("checkRedirect() requires siteId and path");
|
|
2234
|
-
return resilientFetchData("checkRedirect", `redirect:${siteId}:${path}`, async (sig) => {
|
|
2235
|
-
return await apiClient({
|
|
2236
|
-
endpoint: "checkRedirect",
|
|
2237
|
-
params: {
|
|
2238
|
-
site: siteId,
|
|
2239
|
-
path
|
|
2240
|
-
},
|
|
2241
|
-
options: { signal: sig }
|
|
2242
|
-
});
|
|
2243
|
-
}, {
|
|
2244
|
-
signal,
|
|
2245
|
-
cacheTags: buildPublicReadMemoryCacheTags("checkRedirect", { site: siteId })
|
|
2246
|
-
});
|
|
2247
|
-
},
|
|
2248
|
-
async resolveRouteOutcome(params) {
|
|
2249
|
-
const { siteId, path, preview = false, signal } = params;
|
|
2250
|
-
if (!siteId || !path) throw new Error("resolveRouteOutcome() requires siteId and path");
|
|
2251
|
-
return unwrapResponse(await apiClient({
|
|
2252
|
-
endpoint: "resolveRouteOutcome",
|
|
2253
|
-
params: {
|
|
2254
|
-
siteId,
|
|
2255
|
-
path,
|
|
2256
|
-
preview: String(preview)
|
|
2257
|
-
},
|
|
2258
|
-
options: { signal }
|
|
2259
|
-
}));
|
|
2260
|
-
},
|
|
2261
|
-
async resolveRouteDecision(params) {
|
|
2262
|
-
const { siteId, path, preview = false, signal } = params;
|
|
2263
|
-
if (!siteId || !path) throw new Error("resolveRouteDecision() requires siteId and path");
|
|
2264
|
-
return unwrapResponse(await apiClient({
|
|
2265
|
-
endpoint: "resolveRouteDecision",
|
|
2266
|
-
params: {
|
|
2267
|
-
siteId,
|
|
2268
|
-
path,
|
|
2269
|
-
preview: String(preview)
|
|
2270
|
-
},
|
|
2271
|
-
options: { signal }
|
|
2272
|
-
}));
|
|
2273
|
-
},
|
|
2274
|
-
async getAllPublishedRoutes(params) {
|
|
2275
|
-
const { siteId, signal } = params;
|
|
2276
|
-
if (!siteId) throw new Error("getAllPublishedRoutes() requires siteId");
|
|
2277
|
-
return resilientFetchData("getPublicRoutableContent", `routable-content:${siteId}:published`, async (sig) => {
|
|
2278
|
-
return await apiClient({
|
|
2279
|
-
endpoint: "getPublicRoutableContent",
|
|
2280
|
-
params: {
|
|
2281
|
-
siteId,
|
|
2282
|
-
publishedOnly: "true"
|
|
2283
|
-
},
|
|
2284
|
-
options: { signal: sig }
|
|
2285
|
-
});
|
|
2286
|
-
}, {
|
|
2287
|
-
signal,
|
|
2288
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicRoutableContent", { siteId })
|
|
2289
|
-
});
|
|
2290
|
-
},
|
|
2291
|
-
async getSitemapRoutes(params) {
|
|
2292
|
-
const { siteId, page, pageSize, signal } = params;
|
|
2293
|
-
if (!siteId) throw new Error("getSitemapRoutes() requires siteId");
|
|
2294
|
-
return resilientFetchData("getPublicSitemapRoutes", `sitemap:${siteId}:${page ?? 1}:${pageSize ?? "default"}`, async (sig) => {
|
|
2295
|
-
return await apiClient({
|
|
2296
|
-
endpoint: "getPublicSitemapRoutes",
|
|
2297
|
-
params: {
|
|
2298
|
-
siteId,
|
|
2299
|
-
...page ? { page: String(page) } : {},
|
|
2300
|
-
...pageSize ? { pageSize: String(pageSize) } : {}
|
|
2301
|
-
},
|
|
2302
|
-
options: { signal: sig }
|
|
2303
|
-
});
|
|
2304
|
-
}, {
|
|
2305
|
-
signal,
|
|
2306
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicSitemapRoutes", { siteId })
|
|
2307
|
-
});
|
|
2308
|
-
},
|
|
2309
|
-
clearCacheForTags(tags) {
|
|
2310
|
-
cache.clearForTags(tags);
|
|
2311
|
-
},
|
|
2312
|
-
clearCache() {
|
|
2313
|
-
cache.clear();
|
|
2314
|
-
},
|
|
2315
|
-
getKeyType() {
|
|
2316
|
-
return keyType;
|
|
2317
|
-
},
|
|
2318
|
-
getLastEmittedStatus() {
|
|
2319
|
-
return lastStatus;
|
|
2320
|
-
},
|
|
2321
|
-
getCircuitState() {
|
|
2322
|
-
return circuitBreaker.getState();
|
|
2323
|
-
},
|
|
2324
|
-
getBaseUrl() {
|
|
2325
|
-
return config.baseUrl;
|
|
2326
|
-
}
|
|
2327
|
-
};
|
|
2328
|
-
}
|
|
2329
|
-
//#endregion
|
|
2330
|
-
export { DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, getResilienceStatusFromError as h, resolveRuntimeCachePolicy as i, parsePublishedRuntimeCacheKeyDetails as l, RiverbankApiError as m, classifyPublishedRuntimeCacheFreshness as n, isPublishedRuntimeCacheKeyEndpoint as o, CircuitOpenError as p, derivePublishedRuntimeCacheKey as r, normalizeRuntimePublicPath as s, createRiverbankClient as t, parsePublishedRuntimeCachePayloadSchemaVersion as u };
|