@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,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
1
|
+
import { n as parseSurfaceTree } from "./accessibleSurfaces-B_Y_dA20.mjs";
|
|
2
|
+
import { t as parseSiteId } from "./identity-Bn9OQiT1.mjs";
|
|
3
|
+
import { o as isSupportedLoaderEndpoint, r as encodePublicProductCategorySelector, t as materializeEntriesMedia } from "./responseMedia-D8J3VAFs.mjs";
|
|
4
|
+
import { t as SDK_VERSION } from "./version-BLXZ31S-.mjs";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
const PUBLIC_CONTENT_FRESHNESS_SECONDS = 3600;
|
|
5
7
|
function availability(transport) {
|
|
@@ -63,29 +65,46 @@ const committedWriteProofSchema = z.object({
|
|
|
63
65
|
resultingRevision: z.number().int().nonnegative()
|
|
64
66
|
});
|
|
65
67
|
//#endregion
|
|
66
|
-
//#region ../blocks/src/system/data/loaderEndpoints.ts
|
|
67
|
-
const SUPPORTED_LOADER_ENDPOINTS = [
|
|
68
|
-
"listPublishedEntries",
|
|
69
|
-
"getPublishedEntryPreview",
|
|
70
|
-
"listPublicEvents",
|
|
71
|
-
"listPublicEventCalendarWindow",
|
|
72
|
-
"listPublicRecurringSchedule",
|
|
73
|
-
"getPublicEventDetails",
|
|
74
|
-
"listPublicRouteCandidates",
|
|
75
|
-
"listPublicTeamMembers",
|
|
76
|
-
"listPublicProducts",
|
|
77
|
-
"listPublicPasses",
|
|
78
|
-
"listPublicMemberships",
|
|
79
|
-
"getPublicFormById",
|
|
80
|
-
"getPublicBookingServices",
|
|
81
|
-
"getPublicWeeklySlotAvailability"
|
|
82
|
-
];
|
|
83
|
-
function isSupportedLoaderEndpoint(endpoint) {
|
|
84
|
-
return SUPPORTED_LOADER_ENDPOINTS.includes(endpoint);
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
68
|
//#region ../api/src/pageJournalEndpoints.ts
|
|
88
69
|
const PAGE_JOURNAL_ENDPOINT_DEFINITIONS = {
|
|
70
|
+
discardAssistantPage: {
|
|
71
|
+
path: "/sites/{siteId}/pages/{pageId}/assistant-discard",
|
|
72
|
+
method: "POST",
|
|
73
|
+
auth: "user",
|
|
74
|
+
responseKind: "json",
|
|
75
|
+
editLease: "unleased-editor",
|
|
76
|
+
errors: [
|
|
77
|
+
"validation:invalid_input",
|
|
78
|
+
"auth:forbidden",
|
|
79
|
+
"server:internal_error"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
constructAssistantPage: {
|
|
83
|
+
path: "/sites/{siteId}/pages/assistant",
|
|
84
|
+
method: "POST",
|
|
85
|
+
auth: "user",
|
|
86
|
+
responseKind: "json",
|
|
87
|
+
editLease: "unleased-editor",
|
|
88
|
+
errors: [
|
|
89
|
+
"validation:invalid_input",
|
|
90
|
+
"auth:forbidden",
|
|
91
|
+
"resource:conflict",
|
|
92
|
+
"server:internal_error"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
commitPageChangeBatch: {
|
|
96
|
+
path: "/sites/{siteId}/pages/{pageId}/journal",
|
|
97
|
+
method: "PUT",
|
|
98
|
+
auth: "user",
|
|
99
|
+
responseKind: "json",
|
|
100
|
+
editLease: "managed",
|
|
101
|
+
errors: [
|
|
102
|
+
"validation:invalid_input",
|
|
103
|
+
"resource:not_found",
|
|
104
|
+
"resource:conflict",
|
|
105
|
+
"server:internal_error"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
89
108
|
getPagePublishReadinessFacts: {
|
|
90
109
|
path: "/sites/{siteId}/pages/readiness-facts",
|
|
91
110
|
method: "POST",
|
|
@@ -1909,48 +1928,6 @@ const NEWSLETTER_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
1909
1928
|
auth: "user",
|
|
1910
1929
|
responseKind: "json"
|
|
1911
1930
|
},
|
|
1912
|
-
listNewsletterTemplates: {
|
|
1913
|
-
path: "/sites/{siteId}/newsletter/templates",
|
|
1914
|
-
method: "GET",
|
|
1915
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1916
|
-
auth: "user",
|
|
1917
|
-
responseKind: "json"
|
|
1918
|
-
},
|
|
1919
|
-
createNewsletterTemplate: {
|
|
1920
|
-
path: "/sites/{siteId}/newsletter/templates",
|
|
1921
|
-
method: "POST",
|
|
1922
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1923
|
-
auth: "user",
|
|
1924
|
-
responseKind: "json"
|
|
1925
|
-
},
|
|
1926
|
-
getNewsletterTemplate: {
|
|
1927
|
-
path: "/sites/{siteId}/newsletter/templates/{templateId}",
|
|
1928
|
-
method: "GET",
|
|
1929
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1930
|
-
auth: "user",
|
|
1931
|
-
responseKind: "json"
|
|
1932
|
-
},
|
|
1933
|
-
updateNewsletterTemplate: {
|
|
1934
|
-
path: "/sites/{siteId}/newsletter/templates/{templateId}",
|
|
1935
|
-
method: "PATCH",
|
|
1936
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1937
|
-
auth: "user",
|
|
1938
|
-
responseKind: "json"
|
|
1939
|
-
},
|
|
1940
|
-
deleteNewsletterTemplate: {
|
|
1941
|
-
path: "/sites/{siteId}/newsletter/templates/{templateId}",
|
|
1942
|
-
method: "DELETE",
|
|
1943
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1944
|
-
auth: "user",
|
|
1945
|
-
responseKind: "json"
|
|
1946
|
-
},
|
|
1947
|
-
previewNewsletterTemplate: {
|
|
1948
|
-
path: "/sites/{siteId}/newsletter/templates/{templateId}/preview",
|
|
1949
|
-
method: "POST",
|
|
1950
|
-
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1951
|
-
auth: "user",
|
|
1952
|
-
responseKind: "json"
|
|
1953
|
-
},
|
|
1954
1931
|
listNewsletterCampaigns: {
|
|
1955
1932
|
path: "/sites/{siteId}/newsletter/campaigns",
|
|
1956
1933
|
method: "GET",
|
|
@@ -2008,6 +1985,38 @@ const NEWSLETTER_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
2008
1985
|
responseKind: "json",
|
|
2009
1986
|
demoMutation: DEMO_MUTATION_BLOCKED_HIDDEN
|
|
2010
1987
|
},
|
|
1988
|
+
listNewsletterWebsitePicker: {
|
|
1989
|
+
path: "/sites/{siteId}/newsletter/website-picker",
|
|
1990
|
+
method: "GET",
|
|
1991
|
+
auth: "user",
|
|
1992
|
+
responseKind: "json",
|
|
1993
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
1994
|
+
errors: []
|
|
1995
|
+
},
|
|
1996
|
+
renderNewsletterCampaignDraft: {
|
|
1997
|
+
path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/render-draft",
|
|
1998
|
+
method: "POST",
|
|
1999
|
+
auth: "user",
|
|
2000
|
+
responseKind: "json",
|
|
2001
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
2002
|
+
errors: []
|
|
2003
|
+
},
|
|
2004
|
+
reviewNewsletterCampaign: {
|
|
2005
|
+
path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/review",
|
|
2006
|
+
method: "POST",
|
|
2007
|
+
auth: "user",
|
|
2008
|
+
responseKind: "json",
|
|
2009
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
2010
|
+
errors: []
|
|
2011
|
+
},
|
|
2012
|
+
duplicateNewsletterCampaign: {
|
|
2013
|
+
path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/duplicate",
|
|
2014
|
+
method: "POST",
|
|
2015
|
+
auth: "user",
|
|
2016
|
+
responseKind: "json",
|
|
2017
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteNewsletter],
|
|
2018
|
+
errors: []
|
|
2019
|
+
},
|
|
2011
2020
|
scheduleNewsletterCampaign: {
|
|
2012
2021
|
path: "/sites/{siteId}/newsletter/campaigns/{campaignId}/schedule",
|
|
2013
2022
|
method: "POST",
|
|
@@ -2563,29 +2572,6 @@ const EVENT_MANAGEMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
2563
2572
|
"server:internal_error"
|
|
2564
2573
|
]
|
|
2565
2574
|
},
|
|
2566
|
-
/**
|
|
2567
|
-
* The web address of an event's own page. A course page belongs to the
|
|
2568
|
-
* event itself, so its address is written here rather than through a run.
|
|
2569
|
-
*/
|
|
2570
|
-
updateEventAddress: {
|
|
2571
|
-
editLease: "managed",
|
|
2572
|
-
path: "/sites/{siteId}/bookings/events/{eventId}/address",
|
|
2573
|
-
method: "PATCH",
|
|
2574
|
-
tags: [
|
|
2575
|
-
"site-{siteId}",
|
|
2576
|
-
"event-series-{siteId}",
|
|
2577
|
-
TAG_TEMPLATES.siteRoutableContent,
|
|
2578
|
-
TAG_TEMPLATES.siteRedirects
|
|
2579
|
-
],
|
|
2580
|
-
auth: "user",
|
|
2581
|
-
responseKind: "json",
|
|
2582
|
-
errors: [
|
|
2583
|
-
"validation:invalid_input",
|
|
2584
|
-
"resource:not_found",
|
|
2585
|
-
"resource:conflict",
|
|
2586
|
-
"server:internal_error"
|
|
2587
|
-
]
|
|
2588
|
-
},
|
|
2589
2575
|
createWholeSeriesRun: {
|
|
2590
2576
|
path: "/sites/{siteId}/bookings/events/{eventId}/runs",
|
|
2591
2577
|
method: "POST",
|
|
@@ -3159,6 +3145,15 @@ const BILLING_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
3159
3145
|
auth: "admin",
|
|
3160
3146
|
responseKind: "json"
|
|
3161
3147
|
},
|
|
3148
|
+
/** Give a self-serve subscription free time: its trial ends on the chosen date. */
|
|
3149
|
+
adminGrantTrial: {
|
|
3150
|
+
path: "/admin/billing/trial-grant",
|
|
3151
|
+
method: "POST",
|
|
3152
|
+
tags: ["admin", "billing"],
|
|
3153
|
+
auth: "admin",
|
|
3154
|
+
responseKind: "json",
|
|
3155
|
+
errors: []
|
|
3156
|
+
},
|
|
3162
3157
|
changePlan: {
|
|
3163
3158
|
path: "/billing/plan/change",
|
|
3164
3159
|
method: "POST",
|
|
@@ -3545,6 +3540,54 @@ const PAGE_SURFACE_EDITOR_ENDPOINT_DEFINITIONS = {
|
|
|
3545
3540
|
* person when nothing is attached to them.
|
|
3546
3541
|
*/
|
|
3547
3542
|
const BOOKING_PEOPLE_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
3543
|
+
previewPersonRemoval: {
|
|
3544
|
+
path: "/sites/{siteId}/bookings/people/{personId}/removal-preview",
|
|
3545
|
+
method: "GET",
|
|
3546
|
+
auth: "user",
|
|
3547
|
+
responseKind: "json",
|
|
3548
|
+
tags: ["site-{siteId}", "customers-{siteId}"],
|
|
3549
|
+
errors: [
|
|
3550
|
+
"auth:forbidden",
|
|
3551
|
+
"resource:not_found",
|
|
3552
|
+
"server:internal_error"
|
|
3553
|
+
]
|
|
3554
|
+
},
|
|
3555
|
+
removePerson: {
|
|
3556
|
+
path: "/sites/{siteId}/bookings/people/{personId}/removal",
|
|
3557
|
+
method: "POST",
|
|
3558
|
+
auth: "user",
|
|
3559
|
+
responseKind: "json",
|
|
3560
|
+
tags: ["site-{siteId}", "customers-{siteId}"],
|
|
3561
|
+
errors: [
|
|
3562
|
+
"auth:forbidden",
|
|
3563
|
+
"resource:not_found",
|
|
3564
|
+
"server:internal_error"
|
|
3565
|
+
]
|
|
3566
|
+
},
|
|
3567
|
+
getPersonRemovalStatus: {
|
|
3568
|
+
path: "/sites/{siteId}/bookings/people/{personId}/removal",
|
|
3569
|
+
method: "GET",
|
|
3570
|
+
auth: "user",
|
|
3571
|
+
responseKind: "json",
|
|
3572
|
+
tags: ["site-{siteId}", "customers-{siteId}"],
|
|
3573
|
+
errors: [
|
|
3574
|
+
"auth:forbidden",
|
|
3575
|
+
"resource:not_found",
|
|
3576
|
+
"server:internal_error"
|
|
3577
|
+
]
|
|
3578
|
+
},
|
|
3579
|
+
exportPersonData: {
|
|
3580
|
+
path: "/sites/{siteId}/bookings/people/{personId}/export.json",
|
|
3581
|
+
method: "GET",
|
|
3582
|
+
auth: "user",
|
|
3583
|
+
responseKind: "blob",
|
|
3584
|
+
tags: ["site-{siteId}", "customers-{siteId}"],
|
|
3585
|
+
errors: [
|
|
3586
|
+
"auth:forbidden",
|
|
3587
|
+
"resource:not_found",
|
|
3588
|
+
"server:internal_error"
|
|
3589
|
+
]
|
|
3590
|
+
},
|
|
3548
3591
|
getBookingPerson: {
|
|
3549
3592
|
path: "/sites/{siteId}/bookings/people/{personId}",
|
|
3550
3593
|
method: "GET",
|
|
@@ -3640,7 +3683,7 @@ z.object({
|
|
|
3640
3683
|
ageMs: z.number().int().min(0).max(CLIENT_ERROR_REPORT_LIMITS.navigationAgeMs)
|
|
3641
3684
|
}).strict().nullable().optional()
|
|
3642
3685
|
}).strict();
|
|
3643
|
-
const API_ENDPOINTS = {
|
|
3686
|
+
const API_ENDPOINTS$1 = {
|
|
3644
3687
|
...PAGE_JOURNAL_ENDPOINT_DEFINITIONS,
|
|
3645
3688
|
...PREVIEW_AUTH_ENDPOINT_DEFINITIONS,
|
|
3646
3689
|
...SITE_LIFECYCLE_ENDPOINT_DEFINITIONS,
|
|
@@ -3662,20 +3705,22 @@ const API_ENDPOINTS = {
|
|
|
3662
3705
|
auth: "user",
|
|
3663
3706
|
responseKind: "json"
|
|
3664
3707
|
},
|
|
3665
|
-
|
|
3666
|
-
path: "/
|
|
3708
|
+
assistantConversation: {
|
|
3709
|
+
path: "/assistant/conversation",
|
|
3667
3710
|
method: "POST",
|
|
3668
3711
|
auth: "user",
|
|
3669
|
-
responseKind: "
|
|
3712
|
+
responseKind: "json",
|
|
3713
|
+
errors: []
|
|
3670
3714
|
},
|
|
3671
|
-
|
|
3672
|
-
path: "/
|
|
3673
|
-
method: "
|
|
3715
|
+
assistantNewConversation: {
|
|
3716
|
+
path: "/assistant/conversation/new",
|
|
3717
|
+
method: "POST",
|
|
3674
3718
|
auth: "user",
|
|
3675
|
-
responseKind: "
|
|
3719
|
+
responseKind: "json",
|
|
3720
|
+
errors: []
|
|
3676
3721
|
},
|
|
3677
|
-
|
|
3678
|
-
path: "/assistant/
|
|
3722
|
+
assistantOutcome: {
|
|
3723
|
+
path: "/assistant/outcome",
|
|
3679
3724
|
method: "POST",
|
|
3680
3725
|
auth: "user",
|
|
3681
3726
|
responseKind: "json",
|
|
@@ -3702,42 +3747,6 @@ const API_ENDPOINTS = {
|
|
|
3702
3747
|
responseKind: "stream",
|
|
3703
3748
|
errors: []
|
|
3704
3749
|
},
|
|
3705
|
-
aiPlaygroundPageConvert: {
|
|
3706
|
-
path: "/sites/{siteId}/ai/playground/page-convert",
|
|
3707
|
-
method: "POST",
|
|
3708
|
-
auth: "user",
|
|
3709
|
-
responseKind: "json"
|
|
3710
|
-
},
|
|
3711
|
-
aiPlaygroundPageConvertJobsCreate: {
|
|
3712
|
-
path: "/sites/{siteId}/ai/playground/page-convert/jobs",
|
|
3713
|
-
method: "POST",
|
|
3714
|
-
auth: "user",
|
|
3715
|
-
responseKind: "json"
|
|
3716
|
-
},
|
|
3717
|
-
aiPlaygroundPageConvertJobsList: {
|
|
3718
|
-
path: "/sites/{siteId}/ai/playground/page-convert/jobs",
|
|
3719
|
-
method: "GET",
|
|
3720
|
-
auth: "user",
|
|
3721
|
-
responseKind: "json"
|
|
3722
|
-
},
|
|
3723
|
-
aiPlaygroundPageConvertJobGet: {
|
|
3724
|
-
path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}",
|
|
3725
|
-
method: "GET",
|
|
3726
|
-
auth: "user",
|
|
3727
|
-
responseKind: "json"
|
|
3728
|
-
},
|
|
3729
|
-
aiPlaygroundPageConvertJobRun: {
|
|
3730
|
-
path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}/run",
|
|
3731
|
-
method: "POST",
|
|
3732
|
-
auth: "user",
|
|
3733
|
-
responseKind: "json"
|
|
3734
|
-
},
|
|
3735
|
-
aiPlaygroundPageConvertJobEvents: {
|
|
3736
|
-
path: "/sites/{siteId}/ai/playground/page-convert/jobs/{jobId}/events",
|
|
3737
|
-
method: "GET",
|
|
3738
|
-
auth: "user",
|
|
3739
|
-
responseKind: "json"
|
|
3740
|
-
},
|
|
3741
3750
|
aiGenerateSite: {
|
|
3742
3751
|
path: "/sites/{siteId}/ai/generate",
|
|
3743
3752
|
method: "POST",
|
|
@@ -4520,6 +4529,32 @@ const API_ENDPOINTS = {
|
|
|
4520
4529
|
auth: "user",
|
|
4521
4530
|
responseKind: "json"
|
|
4522
4531
|
},
|
|
4532
|
+
getRouteAddress: {
|
|
4533
|
+
path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
|
|
4534
|
+
method: "GET",
|
|
4535
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteRoutableContent],
|
|
4536
|
+
auth: "user",
|
|
4537
|
+
responseKind: "json",
|
|
4538
|
+
errors: ["resource:not_found", "resource:conflict"]
|
|
4539
|
+
},
|
|
4540
|
+
changeRouteAddress: {
|
|
4541
|
+
editLease: "managed",
|
|
4542
|
+
path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
|
|
4543
|
+
method: "PATCH",
|
|
4544
|
+
tags: [
|
|
4545
|
+
TAG_TEMPLATES.site,
|
|
4546
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
4547
|
+
TAG_TEMPLATES.siteRedirects
|
|
4548
|
+
],
|
|
4549
|
+
auth: "user",
|
|
4550
|
+
responseKind: "json",
|
|
4551
|
+
errors: [
|
|
4552
|
+
"validation:invalid_input",
|
|
4553
|
+
"resource:not_found",
|
|
4554
|
+
"resource:conflict",
|
|
4555
|
+
"server:internal_error"
|
|
4556
|
+
]
|
|
4557
|
+
},
|
|
4523
4558
|
updateRouteMetadata: {
|
|
4524
4559
|
editLease: "managed",
|
|
4525
4560
|
path: "/sites/{siteId}/routes/{routeId}/metadata",
|
|
@@ -4710,6 +4745,30 @@ const API_ENDPOINTS = {
|
|
|
4710
4745
|
auth: "user",
|
|
4711
4746
|
responseKind: "json"
|
|
4712
4747
|
},
|
|
4748
|
+
previewWebsiteOperation: {
|
|
4749
|
+
path: "/sites/{siteId}/website/preview",
|
|
4750
|
+
method: "POST",
|
|
4751
|
+
auth: "user",
|
|
4752
|
+
responseKind: "json",
|
|
4753
|
+
errors: [
|
|
4754
|
+
"validation:invalid_input",
|
|
4755
|
+
"auth:insufficient_permissions",
|
|
4756
|
+
"server:internal_error"
|
|
4757
|
+
]
|
|
4758
|
+
},
|
|
4759
|
+
confirmWebsiteOperation: {
|
|
4760
|
+
editLease: "unleased-editor",
|
|
4761
|
+
path: "/sites/{siteId}/website/confirm",
|
|
4762
|
+
method: "POST",
|
|
4763
|
+
auth: "user",
|
|
4764
|
+
responseKind: "json",
|
|
4765
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteSettings],
|
|
4766
|
+
errors: [
|
|
4767
|
+
"validation:invalid_input",
|
|
4768
|
+
"auth:insufficient_permissions",
|
|
4769
|
+
"server:internal_error"
|
|
4770
|
+
]
|
|
4771
|
+
},
|
|
4713
4772
|
previewSiteBrandingOperation: {
|
|
4714
4773
|
path: "/sites/{siteId}/settings/general/preview",
|
|
4715
4774
|
method: "POST",
|
|
@@ -4927,6 +4986,20 @@ const API_ENDPOINTS = {
|
|
|
4927
4986
|
errors: ["resource:not_found", "server:internal_error"],
|
|
4928
4987
|
responseKind: "json"
|
|
4929
4988
|
},
|
|
4989
|
+
updateFooterCredit: {
|
|
4990
|
+
path: "/sites/{siteId}/settings/footer-credit",
|
|
4991
|
+
method: "POST",
|
|
4992
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteSettings],
|
|
4993
|
+
auth: "user",
|
|
4994
|
+
demoMutation: DEMO_MUTATION_ALLOWED,
|
|
4995
|
+
errors: [
|
|
4996
|
+
"auth:forbidden",
|
|
4997
|
+
"validation:invalid_input",
|
|
4998
|
+
"resource:not_found",
|
|
4999
|
+
"server:internal_error"
|
|
5000
|
+
],
|
|
5001
|
+
responseKind: "json"
|
|
5002
|
+
},
|
|
4930
5003
|
updateFooterComposition: {
|
|
4931
5004
|
editLease: "unleased-editor",
|
|
4932
5005
|
path: "/sites/{siteId}/settings/footer-composition",
|
|
@@ -5284,6 +5357,18 @@ const API_ENDPOINTS = {
|
|
|
5284
5357
|
auth: "user",
|
|
5285
5358
|
responseKind: "json"
|
|
5286
5359
|
},
|
|
5360
|
+
accountAnswerHeardFrom: {
|
|
5361
|
+
path: "/account/heard-from",
|
|
5362
|
+
method: "POST",
|
|
5363
|
+
tags: ["account"],
|
|
5364
|
+
auth: "user",
|
|
5365
|
+
errors: [
|
|
5366
|
+
"auth:unauthenticated",
|
|
5367
|
+
"validation:invalid_input",
|
|
5368
|
+
"server:internal_error"
|
|
5369
|
+
],
|
|
5370
|
+
responseKind: "json"
|
|
5371
|
+
},
|
|
5287
5372
|
accountRevokeSessions: {
|
|
5288
5373
|
path: "/account/sessions/revoke",
|
|
5289
5374
|
method: "POST",
|
|
@@ -7856,14 +7941,6 @@ const API_ENDPOINTS = {
|
|
|
7856
7941
|
auth: "user",
|
|
7857
7942
|
responseKind: "json"
|
|
7858
7943
|
},
|
|
7859
|
-
aiPlaygroundApply: {
|
|
7860
|
-
editLease: "unleased-editor",
|
|
7861
|
-
path: "/sites/{siteId}/ai/playground/apply",
|
|
7862
|
-
method: "POST",
|
|
7863
|
-
tags: ["site-{siteId}"],
|
|
7864
|
-
auth: "user",
|
|
7865
|
-
responseKind: "json"
|
|
7866
|
-
},
|
|
7867
7944
|
billingStatus: {
|
|
7868
7945
|
path: "/billing/status",
|
|
7869
7946
|
method: "GET",
|
|
@@ -8816,6 +8893,7 @@ const API_ENDPOINTS = {
|
|
|
8816
8893
|
responseKind: "json",
|
|
8817
8894
|
errors: [
|
|
8818
8895
|
"resource:not_found",
|
|
8896
|
+
"resource:conflict",
|
|
8819
8897
|
"validation:invalid_input",
|
|
8820
8898
|
"server:internal_error"
|
|
8821
8899
|
]
|
|
@@ -9020,142 +9098,6 @@ var ApiRequestError = class extends Error {
|
|
|
9020
9098
|
}
|
|
9021
9099
|
};
|
|
9022
9100
|
//#endregion
|
|
9023
|
-
//#region ../surfaces/src/index.ts
|
|
9024
|
-
const SURFACE_IDS = ["core", "macadamia"];
|
|
9025
|
-
/**
|
|
9026
|
-
* Deployment tier of a surface root host: `local` = the dev-host entry
|
|
9027
|
-
* (e.g. `localhost`, `macadamia.localhost`); `prod` = the public production
|
|
9028
|
-
* entry; `demo` = the shared Demo deployment. Used to pair
|
|
9029
|
-
* surfaces by tier when rewriting hosts so a dev request stays on the
|
|
9030
|
-
* dev tier of the target surface and prod stays on prod.
|
|
9031
|
-
*/
|
|
9032
|
-
const SURFACE_TIERS = [
|
|
9033
|
-
"local",
|
|
9034
|
-
"demo",
|
|
9035
|
-
"prod"
|
|
9036
|
-
];
|
|
9037
|
-
/**
|
|
9038
|
-
* Root hosts for each surface, keyed by deployment tier. The tier-keyed shape
|
|
9039
|
-
* makes it impossible to mis-order entries: callers like
|
|
9040
|
-
* `buildSurfaceAwareDashboardOriginForSurfaceId` look up by tier directly
|
|
9041
|
-
* rather than relying on positional alignment between arrays.
|
|
9042
|
-
*/
|
|
9043
|
-
const SURFACE_ROOT_HOSTS = {
|
|
9044
|
-
core: {
|
|
9045
|
-
local: "localhost",
|
|
9046
|
-
demo: "demo.macadamia.studio",
|
|
9047
|
-
prod: "riverbankcms.com"
|
|
9048
|
-
},
|
|
9049
|
-
macadamia: {
|
|
9050
|
-
local: "macadamia.localhost",
|
|
9051
|
-
demo: "demo.macadamia.studio",
|
|
9052
|
-
prod: "macadamia.studio"
|
|
9053
|
-
}
|
|
9054
|
-
};
|
|
9055
|
-
const SURFACE_SITE_ROOT_HOSTS = {
|
|
9056
|
-
core: {
|
|
9057
|
-
local: "localhost",
|
|
9058
|
-
demo: "demo.macadamia.studio",
|
|
9059
|
-
prod: "riverbanksites.com"
|
|
9060
|
-
},
|
|
9061
|
-
macadamia: {
|
|
9062
|
-
local: "macadamia.localhost",
|
|
9063
|
-
demo: "demo.macadamia.studio",
|
|
9064
|
-
prod: "macadamia.studio"
|
|
9065
|
-
}
|
|
9066
|
-
};
|
|
9067
|
-
const SURFACE_SITE_ROOT_HOST_ALIASES = { core: { prod: ["preview.riverbanksites.com"] } };
|
|
9068
|
-
function surfaceHostTableValues(table) {
|
|
9069
|
-
return Object.values(table).flatMap((byTier) => Object.values(byTier).flat());
|
|
9070
|
-
}
|
|
9071
|
-
function siteSlugLabelUnderRoot(host, siteRootHost) {
|
|
9072
|
-
if (!host.endsWith(`.${siteRootHost}`)) return [];
|
|
9073
|
-
return host.slice(0, host.length - siteRootHost.length - 1).split(".").slice(-1);
|
|
9074
|
-
}
|
|
9075
|
-
function deriveSurfaceOwnedSiteSlugs() {
|
|
9076
|
-
const siteRootHosts = [...surfaceHostTableValues(SURFACE_SITE_ROOT_HOSTS), ...surfaceHostTableValues(SURFACE_SITE_ROOT_HOST_ALIASES)];
|
|
9077
|
-
const labels = [
|
|
9078
|
-
...surfaceHostTableValues(SURFACE_ROOT_HOSTS),
|
|
9079
|
-
...siteRootHosts,
|
|
9080
|
-
...SURFACE_IDS.map((surfaceId) => new URL(resolveSurfaceMarketingCanonicalOrigin(surfaceId)).hostname)
|
|
9081
|
-
].flatMap((host) => siteRootHosts.flatMap((root) => siteSlugLabelUnderRoot(host, root)));
|
|
9082
|
-
return [.../* @__PURE__ */ new Set([...labels, "draft-preview"])].sort();
|
|
9083
|
-
}
|
|
9084
|
-
deriveSurfaceOwnedSiteSlugs();
|
|
9085
|
-
const HOST_CANDIDATES = [...SURFACE_IDS.flatMap((surfaceId) => SURFACE_TIERS.flatMap((tier) => [
|
|
9086
|
-
{
|
|
9087
|
-
surfaceId,
|
|
9088
|
-
tier,
|
|
9089
|
-
role: "dashboard",
|
|
9090
|
-
surfaceRootHost: SURFACE_ROOT_HOSTS[surfaceId][tier]
|
|
9091
|
-
},
|
|
9092
|
-
{
|
|
9093
|
-
surfaceId,
|
|
9094
|
-
tier,
|
|
9095
|
-
role: "site",
|
|
9096
|
-
surfaceRootHost: SURFACE_SITE_ROOT_HOSTS[surfaceId][tier]
|
|
9097
|
-
},
|
|
9098
|
-
...(SURFACE_SITE_ROOT_HOST_ALIASES[surfaceId]?.[tier] ?? []).map((surfaceRootHost) => ({
|
|
9099
|
-
surfaceId,
|
|
9100
|
-
tier,
|
|
9101
|
-
role: "site",
|
|
9102
|
-
surfaceRootHost
|
|
9103
|
-
}))
|
|
9104
|
-
])), ...SURFACE_IDS.map((surfaceId) => ({
|
|
9105
|
-
surfaceId,
|
|
9106
|
-
tier: "prod",
|
|
9107
|
-
role: "dashboard",
|
|
9108
|
-
surfaceRootHost: new URL(resolveSurfaceMarketingCanonicalOrigin(surfaceId)).hostname
|
|
9109
|
-
}))];
|
|
9110
|
-
function siteContextForCandidates(candidates) {
|
|
9111
|
-
const sites = candidates.filter((candidate) => candidate.role === "site");
|
|
9112
|
-
const first = sites[0];
|
|
9113
|
-
if (first === void 0) return null;
|
|
9114
|
-
const surfaceIds = [...new Set(sites.map((candidate) => candidate.surfaceId))];
|
|
9115
|
-
const base = {
|
|
9116
|
-
surfaceRootHost: first.surfaceRootHost,
|
|
9117
|
-
tier: first.tier
|
|
9118
|
-
};
|
|
9119
|
-
return surfaceIds.length > 1 ? {
|
|
9120
|
-
...base,
|
|
9121
|
-
kind: "shared",
|
|
9122
|
-
surfaceIds
|
|
9123
|
-
} : {
|
|
9124
|
-
...base,
|
|
9125
|
-
kind: "surface",
|
|
9126
|
-
surfaceId: first.surfaceId
|
|
9127
|
-
};
|
|
9128
|
-
}
|
|
9129
|
-
function dashboardContextForCandidates(candidates) {
|
|
9130
|
-
const dashboard = candidates.find((candidate) => candidate.role === "dashboard" && (candidate.tier !== "demo" || candidate.surfaceId === "macadamia"));
|
|
9131
|
-
return dashboard !== void 0 ? {
|
|
9132
|
-
surfaceId: dashboard.surfaceId,
|
|
9133
|
-
surfaceRootHost: dashboard.surfaceRootHost,
|
|
9134
|
-
tier: dashboard.tier
|
|
9135
|
-
} : null;
|
|
9136
|
-
}
|
|
9137
|
-
[...new Set(HOST_CANDIDATES.map((candidate) => candidate.surfaceRootHost))].map((surfaceRootHost) => {
|
|
9138
|
-
const candidates = HOST_CANDIDATES.filter((candidate) => candidate.surfaceRootHost === surfaceRootHost);
|
|
9139
|
-
return {
|
|
9140
|
-
surfaceRootHost,
|
|
9141
|
-
site: siteContextForCandidates(candidates),
|
|
9142
|
-
dashboard: dashboardContextForCandidates(candidates)
|
|
9143
|
-
};
|
|
9144
|
-
}).sort((a, b) => b.surfaceRootHost.length - a.surfaceRootHost.length);
|
|
9145
|
-
function buildSurfaceDashboardHostname(input) {
|
|
9146
|
-
return SURFACE_ROOT_HOSTS[input.surfaceId][input.tier];
|
|
9147
|
-
}
|
|
9148
|
-
function buildSurfaceDashboardOrigin(input) {
|
|
9149
|
-
const host = buildSurfaceDashboardHostname(input);
|
|
9150
|
-
return `${input.protocol ?? (input.tier === "local" ? "http" : "https")}://${host}${input.port != null && input.port.length > 0 ? `:${input.port}` : ""}`;
|
|
9151
|
-
}
|
|
9152
|
-
function resolveSurfaceMarketingCanonicalOrigin(surfaceId) {
|
|
9153
|
-
return surfaceId === "macadamia" ? "https://www.macadamia.studio" : buildSurfaceDashboardOrigin({
|
|
9154
|
-
surfaceId,
|
|
9155
|
-
tier: "prod"
|
|
9156
|
-
});
|
|
9157
|
-
}
|
|
9158
|
-
//#endregion
|
|
9159
9101
|
//#region ../api/src/url.ts
|
|
9160
9102
|
function looksLikeLocalAuthority(authority) {
|
|
9161
9103
|
const normalized = authority.toLowerCase();
|
|
@@ -9213,7 +9155,7 @@ z.uuid();
|
|
|
9213
9155
|
/** One client command owns this id; network retries retain the same header. */
|
|
9214
9156
|
function commandHeaders(endpoint, headers, operationId) {
|
|
9215
9157
|
const result = new Headers(headers);
|
|
9216
|
-
if (API_ENDPOINTS[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
|
|
9158
|
+
if (API_ENDPOINTS$1[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
|
|
9217
9159
|
return result;
|
|
9218
9160
|
}
|
|
9219
9161
|
//#endregion
|
|
@@ -9262,6 +9204,7 @@ z.enum([
|
|
|
9262
9204
|
"invalid-document",
|
|
9263
9205
|
"invalid-history",
|
|
9264
9206
|
"path-unavailable",
|
|
9207
|
+
"homepage-publication-required",
|
|
9265
9208
|
"invalid-page-version",
|
|
9266
9209
|
"invalid-block-reference",
|
|
9267
9210
|
"invalid-content-reference",
|
|
@@ -9289,11 +9232,10 @@ function getRevalidateTag() {
|
|
|
9289
9232
|
}
|
|
9290
9233
|
return revalidateTag;
|
|
9291
9234
|
}
|
|
9292
|
-
let sdkVersion;
|
|
9293
9235
|
/**
|
|
9294
9236
|
* Generate a UUID, with fallback for environments where crypto.randomUUID isn't available.
|
|
9295
9237
|
*/
|
|
9296
|
-
function generateRequestId() {
|
|
9238
|
+
function generateRequestId$1() {
|
|
9297
9239
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
9298
9240
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
9299
9241
|
const r = Math.random() * 16 | 0;
|
|
@@ -9301,13 +9243,6 @@ function generateRequestId() {
|
|
|
9301
9243
|
});
|
|
9302
9244
|
}
|
|
9303
9245
|
/**
|
|
9304
|
-
* Set the SDK version to be included in API request headers
|
|
9305
|
-
* Called by the SDK during initialization
|
|
9306
|
-
*/
|
|
9307
|
-
function setSdkVersion(version) {
|
|
9308
|
-
sdkVersion = version;
|
|
9309
|
-
}
|
|
9310
|
-
/**
|
|
9311
9246
|
* Parse the Retry-After header value to milliseconds.
|
|
9312
9247
|
* The header can be either:
|
|
9313
9248
|
* - A number of seconds (e.g., "120")
|
|
@@ -9325,8 +9260,8 @@ function parseRetryAfterHeader(headerValue) {
|
|
|
9325
9260
|
return delayMs > 0 ? delayMs : void 0;
|
|
9326
9261
|
}
|
|
9327
9262
|
}
|
|
9328
|
-
function buildEndpointURL(baseURL, endpoint) {
|
|
9329
|
-
return baseURL + API_ENDPOINTS[endpoint].path;
|
|
9263
|
+
function buildEndpointURL$1(baseURL, endpoint) {
|
|
9264
|
+
return baseURL + API_ENDPOINTS$1[endpoint].path;
|
|
9330
9265
|
}
|
|
9331
9266
|
function isFormDataBody(value) {
|
|
9332
9267
|
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
@@ -9414,7 +9349,7 @@ function buildSuccessEnvelope(data, requestId) {
|
|
|
9414
9349
|
success: true,
|
|
9415
9350
|
data,
|
|
9416
9351
|
meta: {
|
|
9417
|
-
requestId: requestId ?? generateRequestId(),
|
|
9352
|
+
requestId: requestId ?? generateRequestId$1(),
|
|
9418
9353
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9419
9354
|
apiVersion: "2025-01-01"
|
|
9420
9355
|
}
|
|
@@ -9429,7 +9364,7 @@ function buildErrorEnvelope(code, message, status, requestId) {
|
|
|
9429
9364
|
error: {
|
|
9430
9365
|
code,
|
|
9431
9366
|
message,
|
|
9432
|
-
requestId: requestId ?? generateRequestId(),
|
|
9367
|
+
requestId: requestId ?? generateRequestId$1(),
|
|
9433
9368
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9434
9369
|
status
|
|
9435
9370
|
}
|
|
@@ -9482,7 +9417,7 @@ async function parseSuccessResponse(endpoint, response, config) {
|
|
|
9482
9417
|
default: return buildSuccessEnvelope(void 0, requestId);
|
|
9483
9418
|
}
|
|
9484
9419
|
}
|
|
9485
|
-
function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
|
|
9420
|
+
function createRawCMSClient(getHeaders = () => ({}), baseUrl, { sdkVersion } = {}) {
|
|
9486
9421
|
return ({ endpoint, body, params, options = {} }) => {
|
|
9487
9422
|
const plan = buildApiRequestPlan({
|
|
9488
9423
|
endpoint,
|
|
@@ -9490,7 +9425,7 @@ function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
|
|
|
9490
9425
|
params,
|
|
9491
9426
|
options: {
|
|
9492
9427
|
...options,
|
|
9493
|
-
headers: commandHeaders(endpoint, options.headers, generateRequestId())
|
|
9428
|
+
headers: commandHeaders(endpoint, options.headers, generateRequestId$1())
|
|
9494
9429
|
},
|
|
9495
9430
|
headers: getHeaders(),
|
|
9496
9431
|
baseUrl: normalizeCmsApiBaseUrl(baseUrl ?? resolveApiBaseUrl()),
|
|
@@ -9510,8 +9445,8 @@ function surfaceTransportCapability(endpoint) {
|
|
|
9510
9445
|
function buildApiRequestPlan(input) {
|
|
9511
9446
|
const { endpoint, body, params, headers = {}, baseUrl } = input;
|
|
9512
9447
|
const options = input.options ?? {};
|
|
9513
|
-
let url = buildEndpointURL(baseUrl, endpoint);
|
|
9514
|
-
const originalPath = API_ENDPOINTS[endpoint].path;
|
|
9448
|
+
let url = buildEndpointURL$1(baseUrl, endpoint);
|
|
9449
|
+
const originalPath = API_ENDPOINTS$1[endpoint].path;
|
|
9515
9450
|
const unusedParams = {};
|
|
9516
9451
|
if (params) Object.entries(params).forEach(([key, value]) => {
|
|
9517
9452
|
const bracePlaceholder = `{${key}}`;
|
|
@@ -9530,7 +9465,7 @@ function buildApiRequestPlan(input) {
|
|
|
9530
9465
|
})));
|
|
9531
9466
|
throw new Error(`Missing required path params for endpoint ${String(endpoint)}: ${missingParams.join(", ")}`);
|
|
9532
9467
|
}
|
|
9533
|
-
const endpointConfig = API_ENDPOINTS[endpoint];
|
|
9468
|
+
const endpointConfig = API_ENDPOINTS$1[endpoint];
|
|
9534
9469
|
const method = endpointConfig.method;
|
|
9535
9470
|
const isGetOrHead = method === "GET" || method === "HEAD";
|
|
9536
9471
|
const queryParams = new URLSearchParams();
|
|
@@ -9571,7 +9506,7 @@ function buildApiRequestPlan(input) {
|
|
|
9571
9506
|
async function createApiRequestError(response, endpoint, fallbackMessage) {
|
|
9572
9507
|
const body = await parseErrorBody(response);
|
|
9573
9508
|
const details = extractApiEnvelopeErrorDetails(body);
|
|
9574
|
-
const config = API_ENDPOINTS[endpoint];
|
|
9509
|
+
const config = API_ENDPOINTS$1[endpoint];
|
|
9575
9510
|
return new ApiRequestError(details.message ?? fallbackMessage ?? `Request to ${String(endpoint)} failed with status ${response.status}`, {
|
|
9576
9511
|
endpoint,
|
|
9577
9512
|
status: response.status,
|
|
@@ -9588,19 +9523,19 @@ function createParsedClient(rawClient) {
|
|
|
9588
9523
|
return async (params) => {
|
|
9589
9524
|
const response = await rawClient(params);
|
|
9590
9525
|
const endpoint = params.endpoint;
|
|
9591
|
-
const config = API_ENDPOINTS[endpoint];
|
|
9526
|
+
const config = API_ENDPOINTS$1[endpoint];
|
|
9592
9527
|
if (!response.ok) throw await createApiRequestError(response, endpoint);
|
|
9593
9528
|
return parseSuccessResponse(endpoint, response, config);
|
|
9594
9529
|
};
|
|
9595
9530
|
}
|
|
9596
|
-
function createCMSClient(headers = {}, baseUrl) {
|
|
9597
|
-
return createParsedClient(createRawCMSClient(() => headers, baseUrl));
|
|
9531
|
+
function createCMSClient(headers = {}, baseUrl, options) {
|
|
9532
|
+
return createParsedClient(createRawCMSClient(() => headers, baseUrl, options));
|
|
9598
9533
|
}
|
|
9599
|
-
function createInternalAPIClient(baseUrl) {
|
|
9600
|
-
return createCMSClient({}, baseUrl);
|
|
9534
|
+
function createInternalAPIClient(baseUrl, options) {
|
|
9535
|
+
return createCMSClient({}, baseUrl, options);
|
|
9601
9536
|
}
|
|
9602
|
-
function createBearerAPIClient(token, baseUrl) {
|
|
9603
|
-
return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl));
|
|
9537
|
+
function createBearerAPIClient(token, baseUrl, options) {
|
|
9538
|
+
return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
|
|
9604
9539
|
}
|
|
9605
9540
|
/** Positive receipt evidence is kept distinct from an HTTP or request failure. */
|
|
9606
9541
|
function requireUsableCommitProjection(response, parsed) {
|
|
@@ -9608,54 +9543,2334 @@ function requireUsableCommitProjection(response, parsed) {
|
|
|
9608
9543
|
throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
|
|
9609
9544
|
}
|
|
9610
9545
|
//#endregion
|
|
9611
|
-
//#region
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9546
|
+
//#region src/client/error.ts
|
|
9547
|
+
let _Symbol$for;
|
|
9548
|
+
_Symbol$for = Symbol.for("nodejs.util.inspect.custom");
|
|
9549
|
+
/**
|
|
9550
|
+
* Error thrown by SDK when API returns an error response
|
|
9551
|
+
*
|
|
9552
|
+
* @example
|
|
9553
|
+
* ```ts
|
|
9554
|
+
* try {
|
|
9555
|
+
* await client.getSite({ slug: 'my-site' });
|
|
9556
|
+
* } catch (error) {
|
|
9557
|
+
* if (error instanceof RiverbankApiError) {
|
|
9558
|
+
* console.log('Error code:', error.code);
|
|
9559
|
+
* console.log('Request ID:', error.requestId);
|
|
9560
|
+
*
|
|
9561
|
+
* if (error.isAuthError()) {
|
|
9562
|
+
* // Handle authentication error
|
|
9563
|
+
* }
|
|
9564
|
+
*
|
|
9565
|
+
* if (error.isValidationError() && error.fieldErrors) {
|
|
9566
|
+
* // Handle field-level validation errors
|
|
9567
|
+
* error.fieldErrors.forEach(fe => {
|
|
9568
|
+
* console.log(`${fe.field}: ${fe.message}`);
|
|
9569
|
+
* });
|
|
9570
|
+
* }
|
|
9571
|
+
*
|
|
9572
|
+
* // Check if error can be retried
|
|
9573
|
+
* if (error.isRetryable) {
|
|
9574
|
+
* const delay = error.retryAfterMs ?? 1000;
|
|
9575
|
+
* console.log(`Retrying after ${delay}ms...`);
|
|
9576
|
+
* }
|
|
9577
|
+
* }
|
|
9578
|
+
* }
|
|
9579
|
+
* ```
|
|
9580
|
+
*/
|
|
9581
|
+
var RiverbankApiError = class RiverbankApiError extends Error {
|
|
9582
|
+
constructor(apiError) {
|
|
9583
|
+
super(apiError.message);
|
|
9584
|
+
this.name = "RiverbankApiError";
|
|
9585
|
+
if ("cause" in apiError && apiError.cause) this.cause = apiError.cause;
|
|
9586
|
+
this.code = apiError.code;
|
|
9587
|
+
this.requestId = apiError.requestId;
|
|
9588
|
+
this.status = apiError.status;
|
|
9589
|
+
this.fieldErrors = apiError.fieldErrors;
|
|
9590
|
+
this.timestamp = apiError.timestamp;
|
|
9591
|
+
this.retryAfterMs = "retryAfterMs" in apiError ? apiError.retryAfterMs : void 0;
|
|
9592
|
+
this.isRetryable = this.computeRetryable();
|
|
9593
|
+
Object.setPrototypeOf(this, RiverbankApiError.prototype);
|
|
9594
|
+
}
|
|
9595
|
+
/**
|
|
9596
|
+
* Compute whether this error is retryable based on HTTP status code.
|
|
9597
|
+
* - 0 (network errors - no HTTP response): retryable
|
|
9598
|
+
* - 429 (rate limit): retryable
|
|
9599
|
+
* - 5xx (server errors): retryable
|
|
9600
|
+
* - 4xx (client errors, except 429): NOT retryable
|
|
9601
|
+
*/
|
|
9602
|
+
computeRetryable() {
|
|
9603
|
+
if (this.status === 0) return true;
|
|
9604
|
+
if (this.status === 429) return true;
|
|
9605
|
+
if (this.status >= 500) return true;
|
|
9606
|
+
return false;
|
|
9607
|
+
}
|
|
9608
|
+
/**
|
|
9609
|
+
* Check if this is a network error (no HTTP response received)
|
|
9610
|
+
*
|
|
9611
|
+
* Matches: network:connection_error, network:timeout, network:dns_error
|
|
9612
|
+
*/
|
|
9613
|
+
isNetworkError() {
|
|
9614
|
+
return this.code.startsWith("network:");
|
|
9615
|
+
}
|
|
9616
|
+
/**
|
|
9617
|
+
* Check if this error matches a specific error code
|
|
9618
|
+
*
|
|
9619
|
+
* @example
|
|
9620
|
+
* ```ts
|
|
9621
|
+
* if (error.is('auth:unauthenticated')) {
|
|
9622
|
+
* // Redirect to login
|
|
9623
|
+
* }
|
|
9624
|
+
* ```
|
|
9625
|
+
*/
|
|
9626
|
+
is(code) {
|
|
9627
|
+
return this.code === code;
|
|
9628
|
+
}
|
|
9629
|
+
/**
|
|
9630
|
+
* Check if this is an authentication or authorization error
|
|
9631
|
+
*
|
|
9632
|
+
* Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
|
|
9633
|
+
* auth:forbidden, auth:mfa_required, auth:insufficient_permissions
|
|
9634
|
+
*/
|
|
9635
|
+
isAuthError() {
|
|
9636
|
+
return this.code.startsWith("auth:");
|
|
9637
|
+
}
|
|
9638
|
+
/**
|
|
9639
|
+
* Check if this is a validation error
|
|
9640
|
+
*
|
|
9641
|
+
* Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
|
|
9642
|
+
*/
|
|
9643
|
+
isValidationError() {
|
|
9644
|
+
return this.code.startsWith("validation:");
|
|
9645
|
+
}
|
|
9646
|
+
/**
|
|
9647
|
+
* Check if this is a resource error (not found, conflict, etc.)
|
|
9648
|
+
*
|
|
9649
|
+
* Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
|
|
9650
|
+
*/
|
|
9651
|
+
isResourceError() {
|
|
9652
|
+
return this.code.startsWith("resource:");
|
|
9653
|
+
}
|
|
9654
|
+
/**
|
|
9655
|
+
* Check if this is a rate limiting error
|
|
9656
|
+
*/
|
|
9657
|
+
isRateLimitError() {
|
|
9658
|
+
return this.code.startsWith("rate_limit:");
|
|
9659
|
+
}
|
|
9660
|
+
/**
|
|
9661
|
+
* Check if this is a billing/payment error
|
|
9662
|
+
*/
|
|
9663
|
+
isBillingError() {
|
|
9664
|
+
return this.code.startsWith("billing:");
|
|
9665
|
+
}
|
|
9666
|
+
/**
|
|
9667
|
+
* Check if this is a server error
|
|
9668
|
+
*/
|
|
9669
|
+
isServerError() {
|
|
9670
|
+
return this.code.startsWith("server:");
|
|
9671
|
+
}
|
|
9672
|
+
/**
|
|
9673
|
+
* Returns a human-readable string representation of the error.
|
|
9674
|
+
* Includes all key details for debugging.
|
|
9675
|
+
*
|
|
9676
|
+
* @example
|
|
9677
|
+
* "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
|
|
9678
|
+
*/
|
|
9679
|
+
toString() {
|
|
9680
|
+
const parts = [`RiverbankApiError: ${this.message}`];
|
|
9681
|
+
if (this.code) parts.push(`Code: ${this.code}`);
|
|
9682
|
+
if (this.status) parts.push(`Status: ${this.status}`);
|
|
9683
|
+
if (this.requestId) parts.push(`RequestId: ${this.requestId}`);
|
|
9684
|
+
return parts.join(" | ");
|
|
9685
|
+
}
|
|
9686
|
+
/**
|
|
9687
|
+
* Custom Node.js inspect output for better console.log display.
|
|
9688
|
+
* This ensures that console.log(error) shows all relevant details
|
|
9689
|
+
* instead of just "[Object]" for nested properties.
|
|
9690
|
+
*/
|
|
9691
|
+
[_Symbol$for]() {
|
|
9692
|
+
return this.toDetailedString();
|
|
9693
|
+
}
|
|
9694
|
+
/**
|
|
9695
|
+
* Returns a detailed multi-line string for debugging.
|
|
9696
|
+
* Used by the Node.js inspect symbol for console output.
|
|
9697
|
+
*/
|
|
9698
|
+
toDetailedString() {
|
|
9699
|
+
const lines = [
|
|
9700
|
+
`RiverbankApiError: ${this.message}`,
|
|
9701
|
+
` Code: ${this.code}`,
|
|
9702
|
+
` Status: ${this.status}`,
|
|
9703
|
+
` RequestId: ${this.requestId}`,
|
|
9704
|
+
` Timestamp: ${this.timestamp}`
|
|
9705
|
+
];
|
|
9706
|
+
if (this.isRetryable) {
|
|
9707
|
+
lines.push(` Retryable: true`);
|
|
9708
|
+
if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
|
|
9709
|
+
}
|
|
9710
|
+
if (this.fieldErrors && this.fieldErrors.length > 0) {
|
|
9711
|
+
lines.push(" FieldErrors:");
|
|
9712
|
+
this.fieldErrors.forEach((fe) => {
|
|
9713
|
+
lines.push(` - ${fe.field}: ${fe.message}`);
|
|
9714
|
+
});
|
|
9715
|
+
}
|
|
9716
|
+
return lines.join("\n");
|
|
9717
|
+
}
|
|
9616
9718
|
};
|
|
9617
|
-
|
|
9719
|
+
const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
|
|
9720
|
+
function attachResilienceStatusToError(error, resilienceStatus) {
|
|
9721
|
+
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");
|
|
9722
|
+
Object.defineProperty(target, resilienceStatusSymbol, {
|
|
9723
|
+
configurable: true,
|
|
9724
|
+
enumerable: false,
|
|
9725
|
+
value: resilienceStatus
|
|
9726
|
+
});
|
|
9727
|
+
return target;
|
|
9728
|
+
}
|
|
9729
|
+
function getResilienceStatusFromError(error) {
|
|
9730
|
+
if (error === null || typeof error !== "object" && typeof error !== "function") return;
|
|
9731
|
+
return error[resilienceStatusSymbol];
|
|
9732
|
+
}
|
|
9618
9733
|
//#endregion
|
|
9619
|
-
//#region
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9734
|
+
//#region src/client/resilience.ts
|
|
9735
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
9736
|
+
maxAttempts: 3,
|
|
9737
|
+
baseDelayMs: 200,
|
|
9738
|
+
maxDelayMs: 2e3,
|
|
9739
|
+
jitter: "full"
|
|
9740
|
+
};
|
|
9741
|
+
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
9742
|
+
failureThreshold: 5,
|
|
9743
|
+
resetTimeoutMs: 3e4,
|
|
9744
|
+
halfOpenMaxRequests: 2
|
|
9745
|
+
};
|
|
9746
|
+
/**
|
|
9747
|
+
* Error codes that indicate permanent infrastructure failures.
|
|
9748
|
+
* These should NOT be retried as the server is definitively unreachable.
|
|
9749
|
+
*/
|
|
9750
|
+
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9751
|
+
"ECONNREFUSED",
|
|
9752
|
+
"ENOTFOUND",
|
|
9753
|
+
"EAI_AGAIN"
|
|
9754
|
+
]);
|
|
9755
|
+
/**
|
|
9756
|
+
* Error codes that indicate transient network issues.
|
|
9757
|
+
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
9758
|
+
*/
|
|
9759
|
+
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9760
|
+
"ECONNRESET",
|
|
9761
|
+
"EPIPE",
|
|
9762
|
+
"ETIMEDOUT",
|
|
9763
|
+
"ESOCKETTIMEDOUT"
|
|
9764
|
+
]);
|
|
9765
|
+
/**
|
|
9766
|
+
* Node.js network error codes (POSIX style).
|
|
9767
|
+
* These are the codes we're looking for in the cause chain.
|
|
9768
|
+
*/
|
|
9769
|
+
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9770
|
+
"ECONNREFUSED",
|
|
9771
|
+
"ENOTFOUND",
|
|
9772
|
+
"EAI_AGAIN",
|
|
9773
|
+
"ECONNRESET",
|
|
9774
|
+
"EPIPE",
|
|
9775
|
+
"ETIMEDOUT",
|
|
9776
|
+
"ESOCKETTIMEDOUT"
|
|
9777
|
+
]);
|
|
9778
|
+
/**
|
|
9779
|
+
* Check if a string is a Node.js network error code (not an API error code).
|
|
9780
|
+
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
9781
|
+
*/
|
|
9782
|
+
function isNodeNetworkErrorCode(code) {
|
|
9783
|
+
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
9784
|
+
}
|
|
9785
|
+
/**
|
|
9786
|
+
* Extract the Node.js error code from an error's cause chain.
|
|
9787
|
+
* Handles nested cause chains like:
|
|
9788
|
+
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
9789
|
+
*
|
|
9790
|
+
* Skips API error codes (like 'network:connection_error') and only returns
|
|
9791
|
+
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
9792
|
+
*
|
|
9793
|
+
* @example
|
|
9794
|
+
* RiverbankApiError: Network request failed
|
|
9795
|
+
* [cause]: TypeError: fetch failed
|
|
9796
|
+
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
9797
|
+
* code: 'ECONNREFUSED'
|
|
9798
|
+
*/
|
|
9799
|
+
function getErrorCodeFromCause(error) {
|
|
9800
|
+
let current = error;
|
|
9801
|
+
while (current) {
|
|
9802
|
+
const nodeError = current;
|
|
9803
|
+
if (nodeError.code && typeof nodeError.code === "string") {
|
|
9804
|
+
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
9805
|
+
}
|
|
9806
|
+
current = current.cause;
|
|
9625
9807
|
}
|
|
9626
9808
|
}
|
|
9627
|
-
|
|
9628
|
-
|
|
9809
|
+
/**
|
|
9810
|
+
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
9811
|
+
*
|
|
9812
|
+
* Transient (opens circuit, triggers retry):
|
|
9813
|
+
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
9814
|
+
* - 5xx server errors
|
|
9815
|
+
* - 429 rate limit
|
|
9816
|
+
* - Connection reset, broken pipe, timeout
|
|
9817
|
+
*
|
|
9818
|
+
* Permanent (does NOT open circuit, no retry):
|
|
9819
|
+
* - 4xx client errors (400, 401, 403, 404)
|
|
9820
|
+
* - Validation errors
|
|
9821
|
+
* - ECONNREFUSED (server not running)
|
|
9822
|
+
* - ENOTFOUND (DNS failure)
|
|
9823
|
+
*/
|
|
9824
|
+
function isTransientError(error) {
|
|
9825
|
+
if (error instanceof RiverbankApiError) {
|
|
9826
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
9827
|
+
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
9828
|
+
if (error.status === 0) return true;
|
|
9829
|
+
if (error.status === 429) return true;
|
|
9830
|
+
if (error.status >= 500) return true;
|
|
9831
|
+
return false;
|
|
9832
|
+
}
|
|
9833
|
+
if (error instanceof TypeError) {
|
|
9834
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
9835
|
+
if (errorCode) {
|
|
9836
|
+
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
9837
|
+
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
9838
|
+
}
|
|
9839
|
+
return true;
|
|
9840
|
+
}
|
|
9841
|
+
return true;
|
|
9629
9842
|
}
|
|
9630
|
-
|
|
9631
|
-
|
|
9843
|
+
/**
|
|
9844
|
+
* Calculate backoff delay for retry attempt
|
|
9845
|
+
*
|
|
9846
|
+
* Uses exponential backoff with optional full jitter.
|
|
9847
|
+
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
9848
|
+
*/
|
|
9849
|
+
function calculateBackoff(attempt, config) {
|
|
9850
|
+
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
9851
|
+
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
9852
|
+
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
9853
|
+
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
9854
|
+
const capped = Math.min(exponential, maxDelayMs);
|
|
9855
|
+
if (jitter === "full") return Math.random() * capped;
|
|
9856
|
+
return capped;
|
|
9632
9857
|
}
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9858
|
+
/**
|
|
9859
|
+
* Circuit breaker for fail-fast behavior
|
|
9860
|
+
*
|
|
9861
|
+
* States:
|
|
9862
|
+
* - closed: Normal operation, requests allowed
|
|
9863
|
+
* - open: Too many failures, requests blocked
|
|
9864
|
+
* - half-open: Testing if service recovered, limited requests allowed
|
|
9865
|
+
*/
|
|
9866
|
+
var CircuitBreaker = class {
|
|
9867
|
+
constructor(config) {
|
|
9868
|
+
this.state = "closed";
|
|
9869
|
+
this.failureCount = 0;
|
|
9870
|
+
this.successCount = 0;
|
|
9871
|
+
this.openUntil = 0;
|
|
9872
|
+
this.halfOpenRequests = 0;
|
|
9873
|
+
this.config = {
|
|
9874
|
+
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
9875
|
+
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
9876
|
+
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
9639
9877
|
};
|
|
9640
|
-
case "current-category-page":
|
|
9641
|
-
if (selector.productCategoryEntryId.trim().length === 0) return {};
|
|
9642
|
-
return {
|
|
9643
|
-
productCategoryScope: "current-category-page",
|
|
9644
|
-
productCategoryEntryId: selector.productCategoryEntryId
|
|
9645
|
-
};
|
|
9646
9878
|
}
|
|
9879
|
+
/**
|
|
9880
|
+
* Check if circuit is open (requests should be blocked)
|
|
9881
|
+
* Also handles automatic transition from open to half-open after timeout
|
|
9882
|
+
*/
|
|
9883
|
+
isOpen() {
|
|
9884
|
+
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
9885
|
+
return this.state === "open";
|
|
9886
|
+
}
|
|
9887
|
+
/**
|
|
9888
|
+
* Check if a request can be attempted
|
|
9889
|
+
* - closed: always yes
|
|
9890
|
+
* - open: always no
|
|
9891
|
+
* - half-open: limited number of probes
|
|
9892
|
+
*/
|
|
9893
|
+
canAttempt() {
|
|
9894
|
+
if (this.state === "closed") return true;
|
|
9895
|
+
if (this.state === "open") return false;
|
|
9896
|
+
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
9897
|
+
}
|
|
9898
|
+
/**
|
|
9899
|
+
* Increment half-open request counter (call before making request in half-open)
|
|
9900
|
+
*/
|
|
9901
|
+
incrementHalfOpenRequests() {
|
|
9902
|
+
if (this.state === "half-open") this.halfOpenRequests++;
|
|
9903
|
+
}
|
|
9904
|
+
/**
|
|
9905
|
+
* Record a successful request
|
|
9906
|
+
*/
|
|
9907
|
+
recordSuccess() {
|
|
9908
|
+
if (this.state === "half-open") {
|
|
9909
|
+
this.successCount++;
|
|
9910
|
+
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
9911
|
+
} else this.failureCount = 0;
|
|
9912
|
+
}
|
|
9913
|
+
/**
|
|
9914
|
+
* Record a failed request
|
|
9915
|
+
* Only counts transient failures toward circuit breaker threshold
|
|
9916
|
+
*/
|
|
9917
|
+
recordFailure(error) {
|
|
9918
|
+
if (!isTransientError(error)) return;
|
|
9919
|
+
this.failureCount++;
|
|
9920
|
+
if (this.state === "half-open") this.transitionTo("open");
|
|
9921
|
+
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
9922
|
+
}
|
|
9923
|
+
/**
|
|
9924
|
+
* Get current circuit state
|
|
9925
|
+
*/
|
|
9926
|
+
getState() {
|
|
9927
|
+
return {
|
|
9928
|
+
state: this.state,
|
|
9929
|
+
failureCount: this.failureCount,
|
|
9930
|
+
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
9931
|
+
};
|
|
9932
|
+
}
|
|
9933
|
+
/**
|
|
9934
|
+
* Transition to a new state
|
|
9935
|
+
*/
|
|
9936
|
+
transitionTo(newState) {
|
|
9937
|
+
this.state = newState;
|
|
9938
|
+
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
9939
|
+
else if (newState === "half-open") {
|
|
9940
|
+
this.halfOpenRequests = 0;
|
|
9941
|
+
this.successCount = 0;
|
|
9942
|
+
} else if (newState === "closed") {
|
|
9943
|
+
this.failureCount = 0;
|
|
9944
|
+
this.successCount = 0;
|
|
9945
|
+
this.halfOpenRequests = 0;
|
|
9946
|
+
}
|
|
9947
|
+
}
|
|
9948
|
+
};
|
|
9949
|
+
/**
|
|
9950
|
+
* Fetch with timeout and retry logic
|
|
9951
|
+
*
|
|
9952
|
+
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
9953
|
+
* @param config - Retry configuration
|
|
9954
|
+
* @returns Result from successful fetch
|
|
9955
|
+
* @throws Last error after all retries exhausted
|
|
9956
|
+
*/
|
|
9957
|
+
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
9958
|
+
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
9959
|
+
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
9960
|
+
let lastError;
|
|
9961
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
9962
|
+
const controller = new AbortController();
|
|
9963
|
+
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
9964
|
+
try {
|
|
9965
|
+
return await fetcher(controller.signal);
|
|
9966
|
+
} finally {
|
|
9967
|
+
clearTimeout(timeoutId);
|
|
9968
|
+
}
|
|
9969
|
+
} catch (error) {
|
|
9970
|
+
lastError = error;
|
|
9971
|
+
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
9972
|
+
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
9973
|
+
}
|
|
9974
|
+
throw lastError;
|
|
9975
|
+
}
|
|
9976
|
+
/**
|
|
9977
|
+
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
9978
|
+
*/
|
|
9979
|
+
function isAbortError$1(error) {
|
|
9980
|
+
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
9981
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
9982
|
+
return false;
|
|
9983
|
+
}
|
|
9984
|
+
/**
|
|
9985
|
+
* Check if an error should be retried
|
|
9986
|
+
*/
|
|
9987
|
+
function shouldRetryError(error, customRetryOn) {
|
|
9988
|
+
if (isAbortError$1(error)) return false;
|
|
9989
|
+
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
9990
|
+
return isTransientError(error);
|
|
9991
|
+
}
|
|
9992
|
+
/**
|
|
9993
|
+
* Get delay before retrying, respecting Retry-After if present
|
|
9994
|
+
*/
|
|
9995
|
+
function getRetryDelay(error, attempt, config) {
|
|
9996
|
+
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
9997
|
+
return calculateBackoff(attempt, config);
|
|
9998
|
+
}
|
|
9999
|
+
/**
|
|
10000
|
+
* Sleep for specified milliseconds
|
|
10001
|
+
*/
|
|
10002
|
+
function sleep(ms) {
|
|
10003
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
10004
|
+
}
|
|
10005
|
+
/**
|
|
10006
|
+
* Error thrown when circuit breaker is open
|
|
10007
|
+
*/
|
|
10008
|
+
var CircuitOpenError = class extends Error {
|
|
10009
|
+
constructor(state) {
|
|
10010
|
+
super("Circuit breaker is open");
|
|
10011
|
+
this.name = "CircuitOpenError";
|
|
10012
|
+
this.circuitState = state;
|
|
10013
|
+
}
|
|
10014
|
+
};
|
|
10015
|
+
//#endregion
|
|
10016
|
+
//#region src/client/entryListReadRequest.ts
|
|
10017
|
+
const entryOrder = {
|
|
10018
|
+
newest: "published_at.desc",
|
|
10019
|
+
oldest: "published_at.asc",
|
|
10020
|
+
title: "title.asc",
|
|
10021
|
+
manual: "manual.asc"
|
|
10022
|
+
};
|
|
10023
|
+
function entrySelection(input) {
|
|
10024
|
+
return input.mode === "manual" && input.entryIds?.length ? {
|
|
10025
|
+
keyPart: input.entryIds.join(","),
|
|
10026
|
+
params: {
|
|
10027
|
+
mode: "manual",
|
|
10028
|
+
entryIds: JSON.stringify(input.entryIds)
|
|
10029
|
+
}
|
|
10030
|
+
} : {
|
|
10031
|
+
keyPart: "",
|
|
10032
|
+
params: {}
|
|
10033
|
+
};
|
|
9647
10034
|
}
|
|
9648
|
-
function
|
|
9649
|
-
const
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
10035
|
+
function entryListMemoryKey(input, selection) {
|
|
10036
|
+
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
10037
|
+
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
10038
|
+
}
|
|
10039
|
+
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
10040
|
+
function buildEntryListReadRequest(input) {
|
|
10041
|
+
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
10042
|
+
const selection = entrySelection(input);
|
|
10043
|
+
const orderParam = order ? entryOrder[order] : void 0;
|
|
10044
|
+
return {
|
|
10045
|
+
cacheKey: entryListMemoryKey(input, selection),
|
|
10046
|
+
params: {
|
|
10047
|
+
siteId,
|
|
10048
|
+
type: contentType,
|
|
10049
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
10050
|
+
...typeof offset === "number" && { offset: String(offset) },
|
|
10051
|
+
...includeMeta && { meta: "true" },
|
|
10052
|
+
...orderParam && { order: orderParam },
|
|
10053
|
+
...preview && { stage: "preview" },
|
|
10054
|
+
...selection.params
|
|
10055
|
+
}
|
|
9654
10056
|
};
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
10057
|
+
}
|
|
10058
|
+
//#endregion
|
|
10059
|
+
//#region src/client/cache.ts
|
|
10060
|
+
var SimpleCache = class {
|
|
10061
|
+
constructor(options = {}) {
|
|
10062
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
10063
|
+
this.maxSize = options.maxSize ?? 100;
|
|
10064
|
+
this.ttl = options.ttl ?? 3e5;
|
|
10065
|
+
this.staleTtl = options.staleTtl ?? 3e5;
|
|
10066
|
+
}
|
|
10067
|
+
/**
|
|
10068
|
+
* Get a fresh value (within TTL)
|
|
10069
|
+
* @returns The value if fresh, null otherwise
|
|
10070
|
+
*/
|
|
10071
|
+
getFresh(key) {
|
|
10072
|
+
const entry = this.cache.get(key);
|
|
10073
|
+
if (!entry) return null;
|
|
10074
|
+
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
10075
|
+
return null;
|
|
10076
|
+
}
|
|
10077
|
+
/**
|
|
10078
|
+
* Get a value that may be stale (past TTL but within staleTtl)
|
|
10079
|
+
* @returns Object with value and stale age, or null if expired
|
|
10080
|
+
*/
|
|
10081
|
+
getStale(key) {
|
|
10082
|
+
const entry = this.cache.get(key);
|
|
10083
|
+
if (!entry) return null;
|
|
10084
|
+
const now = Date.now();
|
|
10085
|
+
if (now > entry.staleUntil) {
|
|
10086
|
+
this.cache.delete(key);
|
|
10087
|
+
return null;
|
|
10088
|
+
}
|
|
10089
|
+
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
10090
|
+
return {
|
|
10091
|
+
value: entry.value,
|
|
10092
|
+
staleAgeSec
|
|
10093
|
+
};
|
|
10094
|
+
}
|
|
10095
|
+
/**
|
|
10096
|
+
* Store a value with TTL and stale window
|
|
10097
|
+
*/
|
|
10098
|
+
set(key, value, options) {
|
|
10099
|
+
const ttl = options?.ttl ?? this.ttl;
|
|
10100
|
+
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
10101
|
+
const now = Date.now();
|
|
10102
|
+
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
10103
|
+
this.cache.set(key, {
|
|
10104
|
+
value,
|
|
10105
|
+
tags: options?.tags ?? [],
|
|
10106
|
+
createdAt: now,
|
|
10107
|
+
freshUntil: now + ttl,
|
|
10108
|
+
staleUntil: now + ttl + staleTtl
|
|
10109
|
+
});
|
|
10110
|
+
}
|
|
10111
|
+
/**
|
|
10112
|
+
* Evict one entry to make room for a new one
|
|
10113
|
+
* Priority: oldest stale entry, then oldest fresh entry
|
|
10114
|
+
*/
|
|
10115
|
+
evictOne(now) {
|
|
10116
|
+
let oldestStaleKey = null;
|
|
10117
|
+
let oldestStaleTime = Infinity;
|
|
10118
|
+
let oldestFreshKey = null;
|
|
10119
|
+
let oldestFreshTime = Infinity;
|
|
10120
|
+
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
10121
|
+
if (entry.createdAt < oldestStaleTime) {
|
|
10122
|
+
oldestStaleTime = entry.createdAt;
|
|
10123
|
+
oldestStaleKey = key;
|
|
10124
|
+
}
|
|
10125
|
+
} else if (entry.createdAt < oldestFreshTime) {
|
|
10126
|
+
oldestFreshTime = entry.createdAt;
|
|
10127
|
+
oldestFreshKey = key;
|
|
10128
|
+
}
|
|
10129
|
+
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
10130
|
+
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
10131
|
+
}
|
|
10132
|
+
/**
|
|
10133
|
+
* Remove all fully expired entries (past staleUntil)
|
|
10134
|
+
*/
|
|
10135
|
+
prune() {
|
|
10136
|
+
const now = Date.now();
|
|
10137
|
+
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
10138
|
+
}
|
|
10139
|
+
/**
|
|
10140
|
+
* Clear all entries
|
|
10141
|
+
*/
|
|
10142
|
+
clearForTags(tags) {
|
|
10143
|
+
if (tags.includes("riverbank")) {
|
|
10144
|
+
this.clear();
|
|
10145
|
+
return;
|
|
10146
|
+
}
|
|
10147
|
+
const selected = new Set(tags);
|
|
10148
|
+
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
10149
|
+
}
|
|
10150
|
+
clear() {
|
|
10151
|
+
this.cache.clear();
|
|
10152
|
+
}
|
|
10153
|
+
/**
|
|
10154
|
+
* Check if a key exists and is not fully expired
|
|
10155
|
+
*/
|
|
10156
|
+
has(key) {
|
|
10157
|
+
const entry = this.cache.get(key);
|
|
10158
|
+
if (!entry) return false;
|
|
10159
|
+
const now = Date.now();
|
|
10160
|
+
if (now > entry.staleUntil) {
|
|
10161
|
+
this.cache.delete(key);
|
|
10162
|
+
return false;
|
|
10163
|
+
}
|
|
10164
|
+
return now <= entry.freshUntil;
|
|
10165
|
+
}
|
|
10166
|
+
};
|
|
10167
|
+
//#endregion
|
|
10168
|
+
//#region src/request-options.ts
|
|
10169
|
+
/** Every API client the SDK creates sends its version as `x-sdk-version`. */
|
|
10170
|
+
const sdkRequestOptions = { sdkVersion: SDK_VERSION };
|
|
10171
|
+
//#endregion
|
|
10172
|
+
//#region src/public-api/runtime.ts
|
|
10173
|
+
const PUBLIC_ENDPOINT_NAMES = [
|
|
10174
|
+
"getSite",
|
|
10175
|
+
"getContentByPath",
|
|
10176
|
+
"resolveRouteOutcome",
|
|
10177
|
+
"resolveRouteDecision",
|
|
10178
|
+
"listPublishedEntries",
|
|
10179
|
+
"getPublishedEntryPreview",
|
|
10180
|
+
"getPublicFormById",
|
|
10181
|
+
"listPublicForms",
|
|
10182
|
+
"getPublicBookingServices",
|
|
10183
|
+
"getPublicWeeklySlotAvailability",
|
|
10184
|
+
"getPublicChallenge",
|
|
10185
|
+
"listPublicEvents",
|
|
10186
|
+
"batchBlockLoaders",
|
|
10187
|
+
"listPublicTeamMembers",
|
|
10188
|
+
"listPublicProducts",
|
|
10189
|
+
"listPublicPasses",
|
|
10190
|
+
"listPublicMemberships",
|
|
10191
|
+
"resolveEventSubroute",
|
|
10192
|
+
"checkRedirect",
|
|
10193
|
+
"getRoutableContent",
|
|
10194
|
+
"getPublicRoutableContent",
|
|
10195
|
+
"getPublicSitemapRoutes"
|
|
10196
|
+
];
|
|
10197
|
+
const API_ENDPOINTS = Object.freeze({
|
|
10198
|
+
getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
|
|
10199
|
+
getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
|
|
10200
|
+
getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
|
|
10201
|
+
getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
|
|
10202
|
+
getContentByPath: {
|
|
10203
|
+
path: "/sites/{siteId}/pages",
|
|
10204
|
+
method: "GET",
|
|
10205
|
+
tags: [TAG_TEMPLATES.siteRoutableContent],
|
|
10206
|
+
auth: "public",
|
|
10207
|
+
responseKind: "json"
|
|
10208
|
+
},
|
|
10209
|
+
resolveRouteOutcome: {
|
|
10210
|
+
path: "/sites/{siteId}/route-outcome",
|
|
10211
|
+
method: "GET",
|
|
10212
|
+
tags: [
|
|
10213
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
10214
|
+
TAG_TEMPLATES.siteRedirects,
|
|
10215
|
+
TAG_TEMPLATES.siteRouteOutcomes
|
|
10216
|
+
],
|
|
10217
|
+
auth: "public",
|
|
10218
|
+
responseKind: "json"
|
|
10219
|
+
},
|
|
10220
|
+
resolveRouteDecision: {
|
|
10221
|
+
path: "/sites/{siteId}/route-decision",
|
|
10222
|
+
method: "GET",
|
|
10223
|
+
tags: [
|
|
10224
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
10225
|
+
TAG_TEMPLATES.siteRedirects,
|
|
10226
|
+
TAG_TEMPLATES.siteRouteOutcomes
|
|
10227
|
+
],
|
|
10228
|
+
auth: "public",
|
|
10229
|
+
responseKind: "json"
|
|
10230
|
+
},
|
|
10231
|
+
listPublishedEntries: {
|
|
10232
|
+
path: "/public/content/{siteId}/{type}/entries",
|
|
10233
|
+
method: "GET",
|
|
10234
|
+
revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
|
|
10235
|
+
tags: ["content-{siteId}-{type}"],
|
|
10236
|
+
auth: "public",
|
|
10237
|
+
responseKind: "json"
|
|
10238
|
+
},
|
|
10239
|
+
getPublishedEntryPreview: {
|
|
10240
|
+
path: "/public/content/{siteId}/{type}/{slug}/preview",
|
|
10241
|
+
method: "GET",
|
|
10242
|
+
revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
|
|
10243
|
+
tags: ["content-{siteId}-{type}-{slug}"],
|
|
10244
|
+
auth: "public",
|
|
10245
|
+
responseKind: "json"
|
|
10246
|
+
},
|
|
10247
|
+
getPublicFormById: {
|
|
10248
|
+
path: "/public/forms/{formId}",
|
|
10249
|
+
method: "GET",
|
|
10250
|
+
revalidate: publicReadFreshnessSeconds("getPublicFormById"),
|
|
10251
|
+
tags: [TAG_TEMPLATES.formById],
|
|
10252
|
+
auth: "public",
|
|
10253
|
+
responseKind: "json"
|
|
10254
|
+
},
|
|
10255
|
+
listPublicForms: {
|
|
10256
|
+
path: "/public/sites/{siteId}/forms",
|
|
10257
|
+
method: "GET",
|
|
10258
|
+
revalidate: 60,
|
|
10259
|
+
tags: [TAG_TEMPLATES.siteForms],
|
|
10260
|
+
auth: "public",
|
|
10261
|
+
responseKind: "json"
|
|
10262
|
+
},
|
|
10263
|
+
getPublicBookingServices: {
|
|
10264
|
+
path: "/public/bookings/services",
|
|
10265
|
+
method: "GET",
|
|
10266
|
+
revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
|
|
10267
|
+
tags: [TAG_TEMPLATES.publicBookingServices],
|
|
10268
|
+
auth: "public",
|
|
10269
|
+
responseKind: "json"
|
|
10270
|
+
},
|
|
10271
|
+
getPublicWeeklySlotAvailability: {
|
|
10272
|
+
path: "/public/bookings/weekly-slot-availability",
|
|
10273
|
+
method: "GET",
|
|
10274
|
+
revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
|
|
10275
|
+
tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
|
|
10276
|
+
auth: "public",
|
|
10277
|
+
responseKind: "json"
|
|
10278
|
+
},
|
|
10279
|
+
getPublicChallenge: {
|
|
10280
|
+
path: "/public/challenge",
|
|
10281
|
+
method: "GET",
|
|
10282
|
+
auth: "public",
|
|
10283
|
+
responseKind: "text"
|
|
10284
|
+
},
|
|
10285
|
+
listPublicEvents: {
|
|
10286
|
+
path: "/public/sites/{siteId}/events",
|
|
10287
|
+
method: "GET",
|
|
10288
|
+
revalidate: publicReadFreshnessSeconds("listPublicEvents"),
|
|
10289
|
+
tags: [TAG_TEMPLATES.publicEvents],
|
|
10290
|
+
auth: "public",
|
|
10291
|
+
responseKind: "json"
|
|
10292
|
+
},
|
|
10293
|
+
batchBlockLoaders: {
|
|
10294
|
+
path: "/public/sites/{siteId}/block-loaders/batch",
|
|
10295
|
+
method: "POST",
|
|
10296
|
+
auth: "public",
|
|
10297
|
+
responseKind: "json"
|
|
10298
|
+
},
|
|
10299
|
+
listPublicTeamMembers: {
|
|
10300
|
+
path: "/public/sites/{siteId}/team-members",
|
|
10301
|
+
method: "GET",
|
|
10302
|
+
revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
|
|
10303
|
+
tags: [TAG_TEMPLATES.publicTeamMembers],
|
|
10304
|
+
auth: "public",
|
|
10305
|
+
responseKind: "json"
|
|
10306
|
+
},
|
|
10307
|
+
listPublicProducts: {
|
|
10308
|
+
path: "/public/sites/{siteId}/products",
|
|
10309
|
+
method: "GET",
|
|
10310
|
+
revalidate: publicReadFreshnessSeconds("listPublicProducts"),
|
|
10311
|
+
tags: [TAG_TEMPLATES.publicProducts],
|
|
10312
|
+
auth: "public",
|
|
10313
|
+
responseKind: "json"
|
|
10314
|
+
},
|
|
10315
|
+
listPublicPasses: {
|
|
10316
|
+
path: "/public/sites/{siteId}/bookings/products/passes",
|
|
10317
|
+
method: "GET",
|
|
10318
|
+
revalidate: publicReadFreshnessSeconds("listPublicPasses"),
|
|
10319
|
+
tags: [TAG_TEMPLATES.publicPasses],
|
|
10320
|
+
auth: "public",
|
|
10321
|
+
responseKind: "json"
|
|
10322
|
+
},
|
|
10323
|
+
listPublicMemberships: {
|
|
10324
|
+
path: "/public/sites/{siteId}/bookings/products/memberships",
|
|
10325
|
+
method: "GET",
|
|
10326
|
+
revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
|
|
10327
|
+
tags: [TAG_TEMPLATES.publicMemberships],
|
|
10328
|
+
auth: "public",
|
|
10329
|
+
responseKind: "json"
|
|
10330
|
+
},
|
|
10331
|
+
resolveEventSubroute: {
|
|
10332
|
+
path: "/public/sites/{siteId}/events/subroutes/resolve",
|
|
10333
|
+
method: "GET",
|
|
10334
|
+
revalidate: 60,
|
|
10335
|
+
tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
|
|
10336
|
+
auth: "public",
|
|
10337
|
+
responseKind: "json"
|
|
10338
|
+
},
|
|
10339
|
+
checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
|
|
10340
|
+
});
|
|
10341
|
+
function buildEndpointURL(baseURL, endpoint) {
|
|
10342
|
+
return baseURL + API_ENDPOINTS[endpoint].path;
|
|
10343
|
+
}
|
|
10344
|
+
function publicSiteReadDefinition(definition) {
|
|
10345
|
+
return {
|
|
10346
|
+
path: definition.path,
|
|
10347
|
+
method: definition.method,
|
|
10348
|
+
revalidate: definition.revalidate,
|
|
10349
|
+
tags: definition.tags,
|
|
10350
|
+
auth: definition.auth,
|
|
10351
|
+
responseKind: definition.responseKind
|
|
10352
|
+
};
|
|
10353
|
+
}
|
|
10354
|
+
//#endregion
|
|
10355
|
+
//#region src/client/runtimeCacheKeys.ts
|
|
10356
|
+
/**
|
|
10357
|
+
* Bump when a cached payload's shape changes incompatibly, so readers skip
|
|
10358
|
+
* entries written in the old shape until publish or a live success rewrites
|
|
10359
|
+
* them.
|
|
10360
|
+
*
|
|
10361
|
+
* - 4: owned surface inputs use the shared revision transport envelope (#1627).
|
|
10362
|
+
* - 3: hidden business-source maps and private locations are removed before public projection (#1611).
|
|
10363
|
+
* - 2: pages carry intent-only `runtimeJoins` in place of compiled
|
|
10364
|
+
* `runtimeBoundaries` (issue 1422).
|
|
10365
|
+
*/
|
|
10366
|
+
const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 4;
|
|
10367
|
+
function toNonEmptyString(value) {
|
|
10368
|
+
if (value === null || value === void 0) return null;
|
|
10369
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
|
|
10370
|
+
const normalized = String(value).trim();
|
|
10371
|
+
return normalized.length > 0 ? normalized : null;
|
|
10372
|
+
}
|
|
10373
|
+
function normalizeRuntimePublicPath(value) {
|
|
10374
|
+
const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
|
|
10375
|
+
const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
|
|
10376
|
+
return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
|
|
10377
|
+
}
|
|
10378
|
+
function normalizeRuntimeHostname(value) {
|
|
10379
|
+
const trimmed = value.trim().toLowerCase();
|
|
10380
|
+
return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
|
|
10381
|
+
}
|
|
10382
|
+
function normalizeScalar(value) {
|
|
10383
|
+
return value.trim().toLowerCase();
|
|
10384
|
+
}
|
|
10385
|
+
function unsafeAsPublishedRuntimeCacheKey(value) {
|
|
10386
|
+
return value;
|
|
10387
|
+
}
|
|
10388
|
+
function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
|
|
10389
|
+
return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
|
|
10390
|
+
}
|
|
10391
|
+
function selectSiteRuntimeIdentity(params) {
|
|
10392
|
+
const slug = toNonEmptyString(params.slug);
|
|
10393
|
+
if (slug !== null) return { slug: normalizeScalar(slug) };
|
|
10394
|
+
const domain = toNonEmptyString(params.domain);
|
|
10395
|
+
if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
|
|
10396
|
+
const id = toNonEmptyString(params.id);
|
|
10397
|
+
if (id !== null) return { id: normalizeScalar(id) };
|
|
10398
|
+
return null;
|
|
10399
|
+
}
|
|
10400
|
+
function deriveGetSiteKey(params) {
|
|
10401
|
+
const identity = selectSiteRuntimeIdentity(params);
|
|
10402
|
+
if (identity === null) return {
|
|
10403
|
+
ok: false,
|
|
10404
|
+
error: {
|
|
10405
|
+
kind: "missing_site_identity",
|
|
10406
|
+
acceptedParams: [
|
|
10407
|
+
"slug",
|
|
10408
|
+
"domain",
|
|
10409
|
+
"id"
|
|
10410
|
+
]
|
|
10411
|
+
}
|
|
10412
|
+
};
|
|
10413
|
+
const normalizedParams = {
|
|
10414
|
+
...identity,
|
|
10415
|
+
currentPath: normalizeRuntimePublicPath(params.currentPath)
|
|
10416
|
+
};
|
|
10417
|
+
return {
|
|
10418
|
+
ok: true,
|
|
10419
|
+
endpoint: "getSite",
|
|
10420
|
+
key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
|
|
10421
|
+
normalizedParams
|
|
10422
|
+
};
|
|
10423
|
+
}
|
|
10424
|
+
function deriveGetContentByPathKey(params) {
|
|
10425
|
+
const siteId = toNonEmptyString(params.siteId);
|
|
10426
|
+
if (siteId === null) return {
|
|
10427
|
+
ok: false,
|
|
10428
|
+
error: {
|
|
10429
|
+
kind: "missing_required_param",
|
|
10430
|
+
endpoint: "getContentByPath",
|
|
10431
|
+
param: "siteId"
|
|
10432
|
+
}
|
|
10433
|
+
};
|
|
10434
|
+
const normalizedParams = {
|
|
10435
|
+
siteId: normalizeScalar(siteId),
|
|
10436
|
+
path: normalizeRuntimePublicPath(params.path),
|
|
10437
|
+
contentContract: "native"
|
|
10438
|
+
};
|
|
10439
|
+
return {
|
|
10440
|
+
ok: true,
|
|
10441
|
+
endpoint: "getContentByPath",
|
|
10442
|
+
key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
|
|
10443
|
+
normalizedParams
|
|
10444
|
+
};
|
|
10445
|
+
}
|
|
10446
|
+
function deriveDurableRuntimeCacheKey(input) {
|
|
10447
|
+
switch (input.endpoint) {
|
|
10448
|
+
case "getSite": return deriveGetSiteKey(input.params);
|
|
10449
|
+
case "getContentByPath": return deriveGetContentByPathKey(input.params);
|
|
10450
|
+
}
|
|
10451
|
+
}
|
|
10452
|
+
function isPublishedRuntimeCacheKeyEndpoint(value) {
|
|
10453
|
+
return value === "getSite" || value === "getContentByPath";
|
|
10454
|
+
}
|
|
10455
|
+
function parsePublishedRuntimeCacheKey(value) {
|
|
10456
|
+
const details = parsePublishedRuntimeCacheKeyDetails(value);
|
|
10457
|
+
if (!details.ok) return details;
|
|
10458
|
+
return {
|
|
10459
|
+
ok: true,
|
|
10460
|
+
key: details.key,
|
|
10461
|
+
endpoint: details.endpoint
|
|
10462
|
+
};
|
|
10463
|
+
}
|
|
10464
|
+
function parsePublishedRuntimeCacheKeyDetails(value) {
|
|
10465
|
+
if (typeof value !== "string") return {
|
|
10466
|
+
ok: false,
|
|
10467
|
+
error: "not_string"
|
|
10468
|
+
};
|
|
10469
|
+
const parts = value.split(":");
|
|
10470
|
+
if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
|
|
10471
|
+
ok: false,
|
|
10472
|
+
error: "invalid_prefix"
|
|
10473
|
+
};
|
|
10474
|
+
const endpoint = parts[2];
|
|
10475
|
+
if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
|
|
10476
|
+
ok: false,
|
|
10477
|
+
error: "unknown_endpoint"
|
|
10478
|
+
};
|
|
10479
|
+
const normalizedParams = {};
|
|
10480
|
+
for (const part of parts.slice(3)) {
|
|
10481
|
+
const separatorIndex = part.indexOf("=");
|
|
10482
|
+
if (separatorIndex <= 0) return {
|
|
10483
|
+
ok: false,
|
|
10484
|
+
error: "invalid_param_encoding"
|
|
10485
|
+
};
|
|
10486
|
+
try {
|
|
10487
|
+
const key = decodeURIComponent(part.slice(0, separatorIndex));
|
|
10488
|
+
normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
|
|
10489
|
+
} catch {
|
|
10490
|
+
return {
|
|
10491
|
+
ok: false,
|
|
10492
|
+
error: "invalid_param_encoding"
|
|
10493
|
+
};
|
|
10494
|
+
}
|
|
10495
|
+
}
|
|
10496
|
+
if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
|
|
10497
|
+
ok: false,
|
|
10498
|
+
error: "invalid_param_encoding"
|
|
10499
|
+
};
|
|
10500
|
+
return {
|
|
10501
|
+
ok: true,
|
|
10502
|
+
key: unsafeAsPublishedRuntimeCacheKey(value),
|
|
10503
|
+
endpoint,
|
|
10504
|
+
normalizedParams
|
|
10505
|
+
};
|
|
10506
|
+
}
|
|
10507
|
+
function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
|
|
10508
|
+
const keys = Object.keys(normalizedParams).sort();
|
|
10509
|
+
switch (endpoint) {
|
|
10510
|
+
case "getSite": return [
|
|
10511
|
+
"domain",
|
|
10512
|
+
"id",
|
|
10513
|
+
"slug"
|
|
10514
|
+
].filter((key) => normalizedParams[key] !== void 0).length === 1 && normalizedParams.currentPath !== void 0 && keys.every((key) => [
|
|
10515
|
+
"currentPath",
|
|
10516
|
+
"domain",
|
|
10517
|
+
"id",
|
|
10518
|
+
"slug"
|
|
10519
|
+
].includes(key));
|
|
10520
|
+
case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
|
|
10521
|
+
"contentContract",
|
|
10522
|
+
"path",
|
|
10523
|
+
"siteId"
|
|
10524
|
+
].includes(key));
|
|
10525
|
+
}
|
|
10526
|
+
}
|
|
10527
|
+
function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
|
|
10528
|
+
if (typeof value !== "number") return {
|
|
10529
|
+
ok: false,
|
|
10530
|
+
error: "not_number"
|
|
10531
|
+
};
|
|
10532
|
+
if (!Number.isInteger(value)) return {
|
|
10533
|
+
ok: false,
|
|
10534
|
+
error: "not_integer"
|
|
10535
|
+
};
|
|
10536
|
+
if (value <= 0) return {
|
|
10537
|
+
ok: false,
|
|
10538
|
+
error: "not_positive"
|
|
10539
|
+
};
|
|
10540
|
+
return {
|
|
10541
|
+
ok: true,
|
|
10542
|
+
value
|
|
10543
|
+
};
|
|
10544
|
+
}
|
|
10545
|
+
//#endregion
|
|
10546
|
+
//#region src/client/runtimeCachePolicy.ts
|
|
10547
|
+
const DEFAULT_STALE_TTL_SEC = 1440 * 60;
|
|
10548
|
+
const DEFAULT_MEMORY_TTL_SEC = 60;
|
|
10549
|
+
const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
|
|
10550
|
+
getSite: {
|
|
10551
|
+
kind: "durable-public-stale",
|
|
10552
|
+
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
10553
|
+
},
|
|
10554
|
+
getContentByPath: {
|
|
10555
|
+
kind: "durable-public-stale",
|
|
10556
|
+
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
10557
|
+
},
|
|
10558
|
+
resolveRouteOutcome: {
|
|
10559
|
+
kind: "memory-only",
|
|
10560
|
+
reason: "durable_rollout_pending"
|
|
10561
|
+
},
|
|
10562
|
+
resolveRouteDecision: {
|
|
10563
|
+
kind: "memory-only",
|
|
10564
|
+
reason: "durable_rollout_pending"
|
|
10565
|
+
},
|
|
10566
|
+
listPublishedEntries: {
|
|
10567
|
+
kind: "memory-only",
|
|
10568
|
+
reason: "durable_rollout_pending"
|
|
10569
|
+
},
|
|
10570
|
+
getPublishedEntryPreview: {
|
|
10571
|
+
kind: "memory-only",
|
|
10572
|
+
reason: "durable_rollout_pending"
|
|
10573
|
+
},
|
|
10574
|
+
getPublicFormById: {
|
|
10575
|
+
kind: "memory-only",
|
|
10576
|
+
reason: "durable_rollout_pending"
|
|
10577
|
+
},
|
|
10578
|
+
listPublicForms: {
|
|
10579
|
+
kind: "memory-only",
|
|
10580
|
+
reason: "durable_rollout_pending"
|
|
10581
|
+
},
|
|
10582
|
+
getPublicBookingServices: {
|
|
10583
|
+
kind: "live-only",
|
|
10584
|
+
reason: "safety_sensitive_booking"
|
|
10585
|
+
},
|
|
10586
|
+
getPublicWeeklySlotAvailability: {
|
|
10587
|
+
kind: "live-only",
|
|
10588
|
+
reason: "safety_sensitive_booking"
|
|
10589
|
+
},
|
|
10590
|
+
getPublicChallenge: {
|
|
10591
|
+
kind: "live-only",
|
|
10592
|
+
reason: "challenge_endpoint"
|
|
10593
|
+
},
|
|
10594
|
+
listPublicEvents: {
|
|
10595
|
+
kind: "memory-only",
|
|
10596
|
+
reason: "durable_rollout_pending"
|
|
10597
|
+
},
|
|
10598
|
+
batchBlockLoaders: {
|
|
10599
|
+
kind: "live-only",
|
|
10600
|
+
reason: "opaque_batch_loader"
|
|
10601
|
+
},
|
|
10602
|
+
listPublicTeamMembers: {
|
|
10603
|
+
kind: "memory-only",
|
|
10604
|
+
reason: "durable_rollout_pending"
|
|
10605
|
+
},
|
|
10606
|
+
listPublicProducts: {
|
|
10607
|
+
kind: "memory-only",
|
|
10608
|
+
reason: "durable_rollout_pending"
|
|
10609
|
+
},
|
|
10610
|
+
listPublicPasses: {
|
|
10611
|
+
kind: "live-only",
|
|
10612
|
+
reason: "safety_sensitive_booking"
|
|
10613
|
+
},
|
|
10614
|
+
listPublicMemberships: {
|
|
10615
|
+
kind: "live-only",
|
|
10616
|
+
reason: "safety_sensitive_booking"
|
|
10617
|
+
},
|
|
10618
|
+
resolveEventSubroute: {
|
|
10619
|
+
kind: "memory-only",
|
|
10620
|
+
reason: "durable_rollout_pending"
|
|
10621
|
+
},
|
|
10622
|
+
checkRedirect: {
|
|
10623
|
+
kind: "memory-only",
|
|
10624
|
+
reason: "durable_rollout_pending"
|
|
10625
|
+
},
|
|
10626
|
+
getRoutableContent: {
|
|
10627
|
+
kind: "live-only",
|
|
10628
|
+
reason: "auth_required"
|
|
10629
|
+
},
|
|
10630
|
+
getPublicRoutableContent: {
|
|
10631
|
+
kind: "memory-only",
|
|
10632
|
+
reason: "durable_rollout_pending"
|
|
10633
|
+
},
|
|
10634
|
+
getPublicSitemapRoutes: {
|
|
10635
|
+
kind: "memory-only",
|
|
10636
|
+
reason: "durable_rollout_pending"
|
|
10637
|
+
}
|
|
10638
|
+
};
|
|
10639
|
+
const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
|
|
10640
|
+
function isPublicEndpointName(endpoint) {
|
|
10641
|
+
return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
|
|
10642
|
+
}
|
|
10643
|
+
function isTruthyParam(value) {
|
|
10644
|
+
return value === true || value === "true" || value === 1 || value === "1";
|
|
10645
|
+
}
|
|
10646
|
+
function isPreviewRequest(endpoint, params) {
|
|
10647
|
+
if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
|
|
10648
|
+
if (endpoint === "listPublishedEntries" || endpoint === "resolveEventSubroute") return params.stage === "preview";
|
|
10649
|
+
return false;
|
|
10650
|
+
}
|
|
10651
|
+
function getEndpointFreshTtlSec(endpoint) {
|
|
10652
|
+
return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
|
|
10653
|
+
}
|
|
10654
|
+
function assertNever(value) {
|
|
10655
|
+
throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
|
|
10656
|
+
}
|
|
10657
|
+
function resolveKnownEndpointPolicy(endpoint, params) {
|
|
10658
|
+
if (isPreviewRequest(endpoint, params)) return {
|
|
10659
|
+
kind: "live-only",
|
|
10660
|
+
endpoint,
|
|
10661
|
+
reason: "preview_request"
|
|
10662
|
+
};
|
|
10663
|
+
if (endpoint === "getSite" && isTruthyParam(params.force)) return {
|
|
10664
|
+
kind: "live-only",
|
|
10665
|
+
endpoint,
|
|
10666
|
+
reason: "force_refresh"
|
|
10667
|
+
};
|
|
10668
|
+
if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
|
|
10669
|
+
kind: "live-only",
|
|
10670
|
+
endpoint,
|
|
10671
|
+
reason: "safety_sensitive_booking"
|
|
10672
|
+
};
|
|
10673
|
+
const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
|
|
10674
|
+
if (override.kind === "live-only") return {
|
|
10675
|
+
kind: "live-only",
|
|
10676
|
+
endpoint,
|
|
10677
|
+
reason: override.reason
|
|
10678
|
+
};
|
|
10679
|
+
const endpointDefinition = API_ENDPOINTS[endpoint];
|
|
10680
|
+
if (endpointDefinition.method !== "GET") return {
|
|
10681
|
+
kind: "live-only",
|
|
10682
|
+
endpoint,
|
|
10683
|
+
reason: "non_get_request"
|
|
10684
|
+
};
|
|
10685
|
+
if (endpointDefinition.auth === "user") return {
|
|
10686
|
+
kind: "live-only",
|
|
10687
|
+
endpoint,
|
|
10688
|
+
reason: "auth_required"
|
|
10689
|
+
};
|
|
10690
|
+
switch (override.kind) {
|
|
10691
|
+
case "durable-public-stale": return {
|
|
10692
|
+
kind: "durable-public-stale",
|
|
10693
|
+
endpoint,
|
|
10694
|
+
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
10695
|
+
staleTtlSec: override.staleTtlSec
|
|
10696
|
+
};
|
|
10697
|
+
case "memory-only": return {
|
|
10698
|
+
kind: "memory-only",
|
|
10699
|
+
endpoint,
|
|
10700
|
+
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
10701
|
+
reason: override.reason
|
|
10702
|
+
};
|
|
10703
|
+
default: return assertNever(override);
|
|
10704
|
+
}
|
|
10705
|
+
}
|
|
10706
|
+
function resolveRuntimeCachePolicy(input) {
|
|
10707
|
+
if (input.method && input.method.toUpperCase() !== "GET") return {
|
|
10708
|
+
kind: "live-only",
|
|
10709
|
+
endpoint: input.endpoint,
|
|
10710
|
+
reason: "non_get_request"
|
|
10711
|
+
};
|
|
10712
|
+
if (!isPublicEndpointName(input.endpoint)) return {
|
|
10713
|
+
kind: "live-only",
|
|
10714
|
+
endpoint: input.endpoint,
|
|
10715
|
+
reason: "unknown_endpoint"
|
|
10716
|
+
};
|
|
10717
|
+
return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
|
|
10718
|
+
}
|
|
10719
|
+
function classifyPublishedRuntimeCacheFreshness(input) {
|
|
10720
|
+
const freshUntilMs = Date.parse(input.freshUntil);
|
|
10721
|
+
const staleUntilMs = Date.parse(input.staleUntil);
|
|
10722
|
+
if (Number.isNaN(freshUntilMs)) return {
|
|
10723
|
+
kind: "invalid_timestamp",
|
|
10724
|
+
field: "freshUntil"
|
|
10725
|
+
};
|
|
10726
|
+
if (Number.isNaN(staleUntilMs)) return {
|
|
10727
|
+
kind: "invalid_timestamp",
|
|
10728
|
+
field: "staleUntil"
|
|
10729
|
+
};
|
|
10730
|
+
const nowMs = input.now.getTime();
|
|
10731
|
+
if (nowMs > staleUntilMs) return { kind: "expired" };
|
|
10732
|
+
if (nowMs <= freshUntilMs) return {
|
|
10733
|
+
kind: "fresh",
|
|
10734
|
+
staleAgeSec: 0
|
|
10735
|
+
};
|
|
10736
|
+
return {
|
|
10737
|
+
kind: "stale",
|
|
10738
|
+
staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
|
|
10739
|
+
};
|
|
10740
|
+
}
|
|
10741
|
+
function derivePublishedRuntimeCacheKey(input) {
|
|
10742
|
+
const policy = resolveRuntimeCachePolicy({
|
|
10743
|
+
endpoint: input.endpoint,
|
|
10744
|
+
method: "GET",
|
|
10745
|
+
params: input.params
|
|
10746
|
+
});
|
|
10747
|
+
if (policy.kind !== "durable-public-stale") return {
|
|
10748
|
+
ok: false,
|
|
10749
|
+
error: {
|
|
10750
|
+
kind: "not_durable_eligible",
|
|
10751
|
+
policy
|
|
10752
|
+
}
|
|
10753
|
+
};
|
|
10754
|
+
return deriveDurableRuntimeCacheKey(input);
|
|
10755
|
+
}
|
|
10756
|
+
//#endregion
|
|
10757
|
+
//#region src/client/contentReadOperations.ts
|
|
10758
|
+
function planPublishedRuntimeCache(input) {
|
|
10759
|
+
const policy = resolveRuntimeCachePolicy({
|
|
10760
|
+
endpoint: input.endpoint,
|
|
10761
|
+
method: "GET",
|
|
10762
|
+
params: input.params
|
|
10763
|
+
});
|
|
10764
|
+
if (policy.kind !== "durable-public-stale") return null;
|
|
10765
|
+
const keyResult = derivePublishedRuntimeCacheKey(input);
|
|
10766
|
+
if (!keyResult.ok) return null;
|
|
10767
|
+
return {
|
|
10768
|
+
cacheKey: keyResult.key,
|
|
10769
|
+
endpoint: keyResult.endpoint,
|
|
10770
|
+
normalizedParams: keyResult.normalizedParams,
|
|
10771
|
+
freshTtlSec: policy.freshTtlSec,
|
|
10772
|
+
staleTtlSec: policy.staleTtlSec,
|
|
10773
|
+
siteId: input.siteId ?? null
|
|
10774
|
+
};
|
|
10775
|
+
}
|
|
10776
|
+
function siteApiParams(params) {
|
|
10777
|
+
return {
|
|
10778
|
+
...params.slug ? { slug: params.slug } : {},
|
|
10779
|
+
...params.domain ? { domain: params.domain } : {},
|
|
10780
|
+
...params.id ? { id: params.id } : {},
|
|
10781
|
+
...params.currentPath ? { currentPath: params.currentPath } : {},
|
|
10782
|
+
...params.force ? { force: "true" } : {}
|
|
10783
|
+
};
|
|
10784
|
+
}
|
|
10785
|
+
function siteReadIdentity(params) {
|
|
10786
|
+
const identifier = params.slug || params.domain || params.id;
|
|
10787
|
+
if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
|
|
10788
|
+
return identifier;
|
|
10789
|
+
}
|
|
10790
|
+
function planSiteRead(params) {
|
|
10791
|
+
const identifier = siteReadIdentity(params);
|
|
10792
|
+
const { slug, domain, id, currentPath, force } = params;
|
|
10793
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
10794
|
+
endpoint: "getSite",
|
|
10795
|
+
params: {
|
|
10796
|
+
slug,
|
|
10797
|
+
domain,
|
|
10798
|
+
id,
|
|
10799
|
+
currentPath,
|
|
10800
|
+
force
|
|
10801
|
+
}
|
|
10802
|
+
});
|
|
10803
|
+
return {
|
|
10804
|
+
publishedRuntimeCache,
|
|
10805
|
+
prebuildIdentifier: id || slug || domain,
|
|
10806
|
+
cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
|
|
10807
|
+
};
|
|
10808
|
+
}
|
|
10809
|
+
async function readSiteWithResilience(input, params) {
|
|
10810
|
+
const { slug, domain, id, signal, force } = params;
|
|
10811
|
+
const plan = planSiteRead(params);
|
|
10812
|
+
const prebuildId = plan.prebuildIdentifier;
|
|
10813
|
+
const prebuild = input.prebuildLoader;
|
|
10814
|
+
return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
|
|
10815
|
+
endpoint: "getSite",
|
|
10816
|
+
params: siteApiParams(params),
|
|
10817
|
+
options: {
|
|
10818
|
+
signal: requestSignal,
|
|
10819
|
+
...force ? { cache: "no-store" } : {}
|
|
10820
|
+
}
|
|
10821
|
+
}), {
|
|
10822
|
+
signal,
|
|
10823
|
+
force,
|
|
10824
|
+
publishedRuntimeCache: plan.publishedRuntimeCache,
|
|
10825
|
+
cacheTags: buildSiteReadTags({
|
|
10826
|
+
slug,
|
|
10827
|
+
domain,
|
|
10828
|
+
id
|
|
10829
|
+
}),
|
|
10830
|
+
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
10831
|
+
});
|
|
10832
|
+
}
|
|
10833
|
+
async function readPageWithResilience(input, params) {
|
|
10834
|
+
const { siteId, path, preview = false, signal } = params;
|
|
10835
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
10836
|
+
endpoint: "getContentByPath",
|
|
10837
|
+
params: {
|
|
10838
|
+
siteId,
|
|
10839
|
+
path,
|
|
10840
|
+
preview
|
|
10841
|
+
},
|
|
10842
|
+
siteId
|
|
10843
|
+
});
|
|
10844
|
+
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
10845
|
+
return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
10846
|
+
endpoint: "getContentByPath",
|
|
10847
|
+
params: {
|
|
10848
|
+
siteId,
|
|
10849
|
+
path,
|
|
10850
|
+
preview: String(preview)
|
|
10851
|
+
},
|
|
10852
|
+
options: { signal: requestSignal }
|
|
10853
|
+
}), {
|
|
10854
|
+
preview,
|
|
10855
|
+
signal,
|
|
10856
|
+
publishedRuntimeCache,
|
|
10857
|
+
cacheTags: buildSiteReadTags({ siteId }),
|
|
10858
|
+
prebuildFallback: void 0
|
|
10859
|
+
});
|
|
10860
|
+
}
|
|
10861
|
+
function createContentReadOperations(input) {
|
|
10862
|
+
return {
|
|
10863
|
+
getSiteWithResilience: (params) => readSiteWithResilience(input, params),
|
|
10864
|
+
getPageWithResilience: (params) => readPageWithResilience(input, params)
|
|
10865
|
+
};
|
|
10866
|
+
}
|
|
10867
|
+
//#endregion
|
|
10868
|
+
//#region src/client/publicAppointmentReadOperations.ts
|
|
10869
|
+
function createPublicAppointmentReadOperations(deps) {
|
|
10870
|
+
return {
|
|
10871
|
+
async getPublicBookingServices(params) {
|
|
10872
|
+
const { siteId, ids, signal } = params;
|
|
10873
|
+
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
10874
|
+
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
10875
|
+
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
10876
|
+
const apiParams = {
|
|
10877
|
+
siteId,
|
|
10878
|
+
...ids && { ids }
|
|
10879
|
+
};
|
|
10880
|
+
return await deps.apiClient({
|
|
10881
|
+
endpoint: "getPublicBookingServices",
|
|
10882
|
+
params: apiParams,
|
|
10883
|
+
options: { signal: requestSignal }
|
|
10884
|
+
});
|
|
10885
|
+
}, {
|
|
10886
|
+
signal,
|
|
10887
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
10888
|
+
});
|
|
10889
|
+
},
|
|
10890
|
+
async getPublicWeeklySlotAvailability(params) {
|
|
10891
|
+
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
10892
|
+
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
10893
|
+
const cacheKey = [
|
|
10894
|
+
"public-weekly-slot-availability",
|
|
10895
|
+
siteId,
|
|
10896
|
+
serviceId,
|
|
10897
|
+
resourceId ?? "",
|
|
10898
|
+
horizonWeeks ?? "",
|
|
10899
|
+
timezone ?? ""
|
|
10900
|
+
].join(":");
|
|
10901
|
+
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
10902
|
+
const apiParams = {
|
|
10903
|
+
siteId,
|
|
10904
|
+
serviceId,
|
|
10905
|
+
...resourceId && { resourceId },
|
|
10906
|
+
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
10907
|
+
...timezone && { timezone }
|
|
10908
|
+
};
|
|
10909
|
+
return await deps.apiClient({
|
|
10910
|
+
endpoint: "getPublicWeeklySlotAvailability",
|
|
10911
|
+
params: apiParams,
|
|
10912
|
+
options: { signal: requestSignal }
|
|
10913
|
+
});
|
|
10914
|
+
}, {
|
|
10915
|
+
signal,
|
|
10916
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
10917
|
+
});
|
|
10918
|
+
}
|
|
10919
|
+
};
|
|
10920
|
+
}
|
|
10921
|
+
//#endregion
|
|
10922
|
+
//#region src/client/publicEventReadOperations.ts
|
|
10923
|
+
function createPublicEventReadOperations(deps) {
|
|
10924
|
+
async function resolveEventSubroute(params, kind) {
|
|
10925
|
+
const { siteId, subject, segment, signal, preview = false } = params;
|
|
10926
|
+
if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
|
|
10927
|
+
const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
|
|
10928
|
+
return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
|
|
10929
|
+
endpoint: "resolveEventSubroute",
|
|
10930
|
+
params: {
|
|
10931
|
+
siteId,
|
|
10932
|
+
kind,
|
|
10933
|
+
subjectKind: subject.kind,
|
|
10934
|
+
subjectId,
|
|
10935
|
+
segment,
|
|
10936
|
+
stage: preview ? "preview" : "published"
|
|
10937
|
+
},
|
|
10938
|
+
options: { signal: requestSignal }
|
|
10939
|
+
}), {
|
|
10940
|
+
signal,
|
|
10941
|
+
preview,
|
|
10942
|
+
cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
|
|
10943
|
+
});
|
|
10944
|
+
}
|
|
10945
|
+
return {
|
|
10946
|
+
async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
10947
|
+
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
10948
|
+
endpoint: "listPublicEventCalendarWindow",
|
|
10949
|
+
params: {
|
|
10950
|
+
...params,
|
|
10951
|
+
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
10952
|
+
},
|
|
10953
|
+
options: { signal: requestSignal }
|
|
10954
|
+
}), {
|
|
10955
|
+
signal,
|
|
10956
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
10957
|
+
});
|
|
10958
|
+
},
|
|
10959
|
+
async resolveEventOccurrence(params) {
|
|
10960
|
+
const response = await resolveEventSubroute(params, "event-occurrence");
|
|
10961
|
+
return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
|
|
10962
|
+
},
|
|
10963
|
+
async resolveEventRun(params) {
|
|
10964
|
+
const response = await resolveEventSubroute(params, "event-run");
|
|
10965
|
+
return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
|
|
10966
|
+
}
|
|
10967
|
+
};
|
|
10968
|
+
}
|
|
10969
|
+
//#endregion
|
|
10970
|
+
//#region src/client/combineAbortSignals.ts
|
|
10971
|
+
/** Combine signals into one that aborts when any input aborts. */
|
|
10972
|
+
function combineAbortSignals(...signals) {
|
|
10973
|
+
const controller = new AbortController();
|
|
10974
|
+
for (const signal of signals) {
|
|
10975
|
+
if (signal.aborted) {
|
|
10976
|
+
controller.abort(signal.reason);
|
|
10977
|
+
break;
|
|
10978
|
+
}
|
|
10979
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
10980
|
+
}
|
|
10981
|
+
return controller.signal;
|
|
10982
|
+
}
|
|
10983
|
+
//#endregion
|
|
10984
|
+
//#region src/client/publicLoaderCacheAccess.ts
|
|
10985
|
+
function shouldWrite(cacheEnabled, force) {
|
|
10986
|
+
return cacheEnabled && !force;
|
|
10987
|
+
}
|
|
10988
|
+
/**
|
|
10989
|
+
* Applies the canonical block-loader freshness policy at the SDK fetch seam.
|
|
10990
|
+
*
|
|
10991
|
+
* Callers provide the endpoint identity, but do not opt into live behavior.
|
|
10992
|
+
* This makes a newly-live endpoint bypass memory and fallback caches without a
|
|
10993
|
+
* second method-level wiring change.
|
|
10994
|
+
*/
|
|
10995
|
+
function applyPublicLoaderCachePolicy(endpoint, options) {
|
|
10996
|
+
if (!isPublicReadEndpoint(endpoint) || getPublicReadCachePolicy(endpoint).kind !== "live") return options;
|
|
10997
|
+
return {
|
|
10998
|
+
...options,
|
|
10999
|
+
force: true
|
|
11000
|
+
};
|
|
11001
|
+
}
|
|
11002
|
+
//#endregion
|
|
11003
|
+
//#region src/client/index.ts
|
|
11004
|
+
let prebuildModule = null;
|
|
11005
|
+
function tryRequire(modulePath) {
|
|
11006
|
+
try {
|
|
11007
|
+
const req = new Function("return typeof require === \"function\" ? require : null")();
|
|
11008
|
+
return req ? req(modulePath) : null;
|
|
11009
|
+
} catch {
|
|
11010
|
+
return null;
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
11013
|
+
function isNodeRuntime() {
|
|
11014
|
+
if (typeof globalThis !== "object" || globalThis === null) return false;
|
|
11015
|
+
return typeof globalThis.process?.versions?.node === "string";
|
|
11016
|
+
}
|
|
11017
|
+
function getPrebuildModule() {
|
|
11018
|
+
if (prebuildModule !== null) return prebuildModule;
|
|
11019
|
+
if (!isNodeRuntime()) return null;
|
|
11020
|
+
try {
|
|
11021
|
+
prebuildModule = tryRequire("../prebuild/loader");
|
|
11022
|
+
return prebuildModule;
|
|
11023
|
+
} catch {
|
|
11024
|
+
return null;
|
|
11025
|
+
}
|
|
11026
|
+
}
|
|
11027
|
+
function mergeDefaultHeaders(defaultHeaders, options) {
|
|
11028
|
+
if (!defaultHeaders || Object.keys(defaultHeaders).length === 0) return options;
|
|
11029
|
+
return {
|
|
11030
|
+
...options,
|
|
11031
|
+
headers: {
|
|
11032
|
+
...defaultHeaders,
|
|
11033
|
+
...Object.fromEntries(new Headers(options?.headers).entries())
|
|
11034
|
+
}
|
|
11035
|
+
};
|
|
11036
|
+
}
|
|
11037
|
+
function withDefaultHeaders(apiClient, defaultHeaders) {
|
|
11038
|
+
return async (params) => apiClient({
|
|
11039
|
+
...params,
|
|
11040
|
+
options: mergeDefaultHeaders(defaultHeaders, params.options)
|
|
11041
|
+
});
|
|
11042
|
+
}
|
|
11043
|
+
const DEFAULT_BROWSER_TIMEOUT_MS = 5e3;
|
|
11044
|
+
const DEFAULT_SERVER_TIMEOUT_MS = 8e3;
|
|
11045
|
+
const MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS = 50;
|
|
11046
|
+
function isDurableRuntimeCacheTier(cacheTier) {
|
|
11047
|
+
return cacheTier === "durable-fresh" || cacheTier === "durable-stale";
|
|
11048
|
+
}
|
|
11049
|
+
function isDegradedResilienceStatus(source, details) {
|
|
11050
|
+
return source === "stale" || source === "error" || isDurableRuntimeCacheTier(details.cacheTier) && details.error !== void 0;
|
|
11051
|
+
}
|
|
11052
|
+
/**
|
|
11053
|
+
* Generate a unique request ID for tracing
|
|
11054
|
+
*/
|
|
11055
|
+
function generateRequestId() {
|
|
11056
|
+
return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
11057
|
+
}
|
|
11058
|
+
function toRecord(value) {
|
|
11059
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
11060
|
+
}
|
|
11061
|
+
function getRuntimePayloadSiteId(value) {
|
|
11062
|
+
const site = toRecord(value).site;
|
|
11063
|
+
if (!site || typeof site !== "object" || Array.isArray(site)) return null;
|
|
11064
|
+
const id = site.id;
|
|
11065
|
+
return typeof id === "string" && id.trim().length > 0 ? id : null;
|
|
11066
|
+
}
|
|
11067
|
+
function getRiverbankErrorInfo(error) {
|
|
11068
|
+
if (error instanceof RiverbankApiError) return {
|
|
11069
|
+
code: error.code,
|
|
11070
|
+
message: error.message,
|
|
11071
|
+
status: error.status
|
|
11072
|
+
};
|
|
11073
|
+
if (error instanceof Error) return { message: error.message };
|
|
11074
|
+
return { message: String(error) };
|
|
11075
|
+
}
|
|
11076
|
+
function normalizeEntryIdentifierRefs(identifiers) {
|
|
11077
|
+
const trimmed = identifiers.map((identifier) => identifier.trim()).filter((identifier) => identifier.length > 0);
|
|
11078
|
+
if (trimmed.length === 0) return { kind: "empty" };
|
|
11079
|
+
if (trimmed.length > MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS) throw new Error(`getEntriesByIdentifiers() accepts at most ${MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS} identifiers`);
|
|
11080
|
+
const refs = [];
|
|
11081
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11082
|
+
for (const ref of trimmed) {
|
|
11083
|
+
if (seen.has(ref)) continue;
|
|
11084
|
+
seen.add(ref);
|
|
11085
|
+
refs.push(ref);
|
|
11086
|
+
}
|
|
11087
|
+
return {
|
|
11088
|
+
kind: "refs",
|
|
11089
|
+
refs
|
|
11090
|
+
};
|
|
11091
|
+
}
|
|
11092
|
+
function normalizePublicForm(form) {
|
|
11093
|
+
return {
|
|
11094
|
+
id: form.id,
|
|
11095
|
+
slug: form.slug,
|
|
11096
|
+
name: form.name,
|
|
11097
|
+
schema: toRecord(form.schemaJson),
|
|
11098
|
+
settings: toRecord(form.settingsJson),
|
|
11099
|
+
schemaJson: toRecord(form.schemaJson),
|
|
11100
|
+
settingsJson: toRecord(form.settingsJson),
|
|
11101
|
+
createdAt: form.createdAt ?? null,
|
|
11102
|
+
updatedAt: form.updatedAt ?? null,
|
|
11103
|
+
...form.siteId ? { siteId: form.siteId } : {},
|
|
11104
|
+
...form.userId ? { userId: form.userId } : {}
|
|
11105
|
+
};
|
|
11106
|
+
}
|
|
11107
|
+
function normalizePublicFormResponse(response) {
|
|
11108
|
+
return { form: response.form ? normalizePublicForm(response.form) : null };
|
|
11109
|
+
}
|
|
11110
|
+
function normalizePublicFormResult(result) {
|
|
11111
|
+
if (isApiError(result)) return result;
|
|
11112
|
+
return {
|
|
11113
|
+
...result,
|
|
11114
|
+
data: normalizePublicFormResponse(result.data)
|
|
11115
|
+
};
|
|
11116
|
+
}
|
|
11117
|
+
function normalizePublicFormsResponse(response) {
|
|
11118
|
+
return { forms: response.forms.map((form) => normalizePublicForm(form)) };
|
|
11119
|
+
}
|
|
11120
|
+
function normalizePublicFormsResult(result) {
|
|
11121
|
+
if (isApiError(result)) return result;
|
|
11122
|
+
return {
|
|
11123
|
+
...result,
|
|
11124
|
+
data: normalizePublicFormsResponse(result.data)
|
|
11125
|
+
};
|
|
11126
|
+
}
|
|
11127
|
+
function normalizeBatchBlockLoaderResult(response, requestId) {
|
|
11128
|
+
if (isApiError(response)) return response;
|
|
11129
|
+
const result = response.data.results[requestId];
|
|
11130
|
+
if (!result) throw new Error(`Missing batch block loader result for "${requestId}"`);
|
|
11131
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
11132
|
+
return {
|
|
11133
|
+
...response,
|
|
11134
|
+
data: result.data
|
|
11135
|
+
};
|
|
11136
|
+
}
|
|
11137
|
+
/**
|
|
11138
|
+
* Check if an error is an AbortError (from AbortController.abort())
|
|
11139
|
+
*/
|
|
11140
|
+
function isAbortError(error) {
|
|
11141
|
+
if (error instanceof DOMException && error.name === "AbortError") return true;
|
|
11142
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
11143
|
+
return false;
|
|
11144
|
+
}
|
|
11145
|
+
/**
|
|
11146
|
+
* Determine the network error code based on error type, code, and message.
|
|
11147
|
+
* Uses multiple detection strategies for cross-runtime compatibility:
|
|
11148
|
+
* 1. Error name (TimeoutError, AbortError) - reliable in browsers
|
|
11149
|
+
* 2. Node.js error code (ETIMEDOUT, ENOTFOUND, etc.) - most reliable in Node
|
|
11150
|
+
* 3. Message matching - fallback for edge cases
|
|
11151
|
+
*/
|
|
11152
|
+
function getNetworkErrorCode(error) {
|
|
11153
|
+
if (error.name === "TimeoutError" || error.name === "AbortError") return "network:timeout";
|
|
11154
|
+
const nodeError = error;
|
|
11155
|
+
if (nodeError.code) switch (nodeError.code) {
|
|
11156
|
+
case "ETIMEDOUT":
|
|
11157
|
+
case "ESOCKETTIMEDOUT": return "network:timeout";
|
|
11158
|
+
case "ENOTFOUND":
|
|
11159
|
+
case "EAI_AGAIN": return "network:dns_error";
|
|
11160
|
+
case "ECONNREFUSED":
|
|
11161
|
+
case "ECONNRESET":
|
|
11162
|
+
case "EPIPE": return "network:connection_error";
|
|
11163
|
+
}
|
|
11164
|
+
const message = error.message.toLowerCase();
|
|
11165
|
+
if (message.includes("timeout") || message.includes("timed out")) return "network:timeout";
|
|
11166
|
+
if (message.includes("dns") || message.includes("getaddrinfo") || message.includes("enotfound")) return "network:dns_error";
|
|
11167
|
+
return "network:connection_error";
|
|
11168
|
+
}
|
|
11169
|
+
/**
|
|
11170
|
+
* Convert API errors to RiverbankApiError for consistent SDK error handling.
|
|
11171
|
+
* Handles:
|
|
11172
|
+
* - ApiEnvelopeError (from unwrapResponse)
|
|
11173
|
+
* - ApiRequestError (from fetch with HTTP error)
|
|
11174
|
+
* - Network errors (TypeError, etc. - wrapped with status 0)
|
|
11175
|
+
* - AbortError (let propagate raw for consumer detection)
|
|
11176
|
+
*/
|
|
11177
|
+
function convertToTypedError(error) {
|
|
11178
|
+
if (isAbortError(error)) throw error;
|
|
11179
|
+
if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
|
|
11180
|
+
code: error.code,
|
|
11181
|
+
message: error.message,
|
|
11182
|
+
requestId: error.requestId,
|
|
11183
|
+
timestamp: error.timestamp,
|
|
11184
|
+
status: error.status,
|
|
11185
|
+
fieldErrors: error.fieldErrors
|
|
11186
|
+
});
|
|
11187
|
+
if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
|
|
11188
|
+
const body = error.body;
|
|
11189
|
+
if (isApiError(body)) {
|
|
11190
|
+
const envelopeError = body.error;
|
|
11191
|
+
throw new RiverbankApiError({
|
|
11192
|
+
...envelopeError,
|
|
11193
|
+
retryAfterMs: error.retryAfterMs
|
|
11194
|
+
});
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
if (error instanceof TypeError || error instanceof Error && !("status" in error)) {
|
|
11198
|
+
const networkError = error;
|
|
11199
|
+
throw new RiverbankApiError({
|
|
11200
|
+
code: getNetworkErrorCode(networkError),
|
|
11201
|
+
message: networkError.message || "Network request failed",
|
|
11202
|
+
requestId: `local-${Date.now()}`,
|
|
11203
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11204
|
+
status: 0,
|
|
11205
|
+
cause: networkError
|
|
11206
|
+
});
|
|
11207
|
+
}
|
|
11208
|
+
throw error;
|
|
11209
|
+
}
|
|
11210
|
+
/**
|
|
11211
|
+
* Detect API key type from prefix.
|
|
11212
|
+
*
|
|
11213
|
+
* Key prefixes:
|
|
11214
|
+
* - bld_live_sk_* / bld_test_sk_* → 'content' (published content)
|
|
11215
|
+
* - bld_preview_sk_* → 'preview' (draft content)
|
|
11216
|
+
*/
|
|
11217
|
+
function detectKeyType(apiKey) {
|
|
11218
|
+
if (apiKey.startsWith("bld_live_sk_") || apiKey.startsWith("bld_test_sk_")) return "content";
|
|
11219
|
+
if (apiKey.startsWith("bld_preview_sk_")) return "preview";
|
|
11220
|
+
return "unknown";
|
|
11221
|
+
}
|
|
11222
|
+
/**
|
|
11223
|
+
* Resolve auth configuration from config, handling backward compatibility.
|
|
11224
|
+
* Throws if neither `auth` nor `apiKey` is provided.
|
|
11225
|
+
*/
|
|
11226
|
+
function resolveAuth(config) {
|
|
11227
|
+
if (config.auth) return config.auth;
|
|
11228
|
+
if (config.apiKey) return {
|
|
11229
|
+
type: "api-key",
|
|
11230
|
+
key: config.apiKey
|
|
11231
|
+
};
|
|
11232
|
+
throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
|
|
11233
|
+
}
|
|
11234
|
+
const defaultRiverbankClientDeps = {
|
|
11235
|
+
createBearerAPIClient,
|
|
11236
|
+
createInternalAPIClient
|
|
11237
|
+
};
|
|
11238
|
+
/**
|
|
11239
|
+
* Create a Riverbank CMS client for fetching content
|
|
11240
|
+
*
|
|
11241
|
+
* @example
|
|
11242
|
+
* ```ts
|
|
11243
|
+
* const client = createRiverbankClient({
|
|
11244
|
+
* apiKey: 'bld_live_sk_...',
|
|
11245
|
+
* baseUrl: 'https://dashboard.example.com/api',
|
|
11246
|
+
* });
|
|
11247
|
+
*
|
|
11248
|
+
* const site = await client.getSite({ slug: 'my-site' });
|
|
11249
|
+
* ```
|
|
11250
|
+
*/
|
|
11251
|
+
function createRiverbankClient(config) {
|
|
11252
|
+
return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
|
|
11253
|
+
}
|
|
11254
|
+
function createRiverbankClientWithDeps(deps, config) {
|
|
11255
|
+
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)");
|
|
11256
|
+
if (!config.baseUrl.endsWith("/api")) throw new Error(`baseUrl must end with '/api'. Received: ${config.baseUrl}. Expected format: https://dashboard.example.com/api`);
|
|
11257
|
+
const cacheEnabled = config.cache?.enabled ?? true;
|
|
11258
|
+
const cacheTTL = (config.cache?.ttl ?? 300) * 1e3;
|
|
11259
|
+
const cacheMaxSize = config.cache?.maxSize ?? 100;
|
|
11260
|
+
const resilienceEnabled = config.resilience?.enabled ?? true;
|
|
11261
|
+
const staleIfError = config.resilience?.staleIfError ?? true;
|
|
11262
|
+
const staleTtlMs = (config.resilience?.staleTtlSec ?? 300) * 1e3;
|
|
11263
|
+
const requestTimeoutMs = config.resilience?.requestTimeoutMs ?? (typeof window !== "undefined" ? DEFAULT_BROWSER_TIMEOUT_MS : DEFAULT_SERVER_TIMEOUT_MS);
|
|
11264
|
+
const retryConfig = {
|
|
11265
|
+
maxAttempts: config.resilience?.retry?.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts,
|
|
11266
|
+
baseDelayMs: config.resilience?.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
|
|
11267
|
+
maxDelayMs: config.resilience?.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,
|
|
11268
|
+
jitter: config.resilience?.retry?.jitter ?? DEFAULT_RETRY_CONFIG.jitter,
|
|
11269
|
+
retryOn: config.resilience?.retry?.retryOn
|
|
11270
|
+
};
|
|
11271
|
+
const circuitBreakerConfig = {
|
|
11272
|
+
failureThreshold: config.resilience?.circuitBreaker?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
11273
|
+
resetTimeoutMs: config.resilience?.circuitBreaker?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
11274
|
+
halfOpenMaxRequests: config.resilience?.circuitBreaker?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
11275
|
+
};
|
|
11276
|
+
const authConfig = resolveAuth(config);
|
|
11277
|
+
let keyType;
|
|
11278
|
+
switch (authConfig.type) {
|
|
11279
|
+
case "none":
|
|
11280
|
+
keyType = "unknown";
|
|
11281
|
+
break;
|
|
11282
|
+
case "api-key":
|
|
11283
|
+
keyType = detectKeyType(authConfig.key);
|
|
11284
|
+
break;
|
|
11285
|
+
case "bearer":
|
|
11286
|
+
keyType = "preview";
|
|
11287
|
+
break;
|
|
11288
|
+
}
|
|
11289
|
+
const apiClient = withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, sdkRequestOptions) : authConfig.type === "api-key" ? deps.createBearerAPIClient(authConfig.key, config.baseUrl, sdkRequestOptions) : deps.createBearerAPIClient(authConfig.token, config.baseUrl, sdkRequestOptions), config.defaultHeaders);
|
|
11290
|
+
const cache = new SimpleCache({
|
|
11291
|
+
maxSize: cacheMaxSize,
|
|
11292
|
+
ttl: cacheTTL,
|
|
11293
|
+
staleTtl: staleTtlMs
|
|
11294
|
+
});
|
|
11295
|
+
const circuitBreaker = new CircuitBreaker(circuitBreakerConfig);
|
|
11296
|
+
const prebuildDir = config.resilience?.prebuildDir;
|
|
11297
|
+
const prebuildMod = prebuildDir ? getPrebuildModule() : null;
|
|
11298
|
+
const prebuildLoader = (prebuildMod?.canUsePrebuild() ?? false) && prebuildMod && prebuildDir ? new prebuildMod.PrebuildLoader({
|
|
11299
|
+
prebuildDir,
|
|
11300
|
+
maxPrebuildAgeSec: config.resilience?.maxPrebuildAgeSec
|
|
11301
|
+
}) : null;
|
|
11302
|
+
let lastStatus = null;
|
|
11303
|
+
let isDegraded = false;
|
|
11304
|
+
/**
|
|
11305
|
+
* Emit a status update and trigger callbacks
|
|
11306
|
+
*/
|
|
11307
|
+
function emitStatus(source, data, details) {
|
|
11308
|
+
const status = {
|
|
11309
|
+
source,
|
|
11310
|
+
isPreview: details.isPreview,
|
|
11311
|
+
cacheKey: details.cacheKey,
|
|
11312
|
+
cacheTier: details.cacheTier,
|
|
11313
|
+
durableCache: details.durableCache,
|
|
11314
|
+
error: details.error,
|
|
11315
|
+
staleAgeSec: details.staleAgeSec,
|
|
11316
|
+
prebuildAgeSec: details.prebuildAgeSec,
|
|
11317
|
+
circuit: circuitBreaker.getState(),
|
|
11318
|
+
requestId: details.requestId,
|
|
11319
|
+
durationMs: details.durationMs
|
|
11320
|
+
};
|
|
11321
|
+
lastStatus = status;
|
|
11322
|
+
config.resilience?.onStatusChange?.(status);
|
|
11323
|
+
const nowDegraded = isDegradedResilienceStatus(source, details);
|
|
11324
|
+
if (nowDegraded !== isDegraded) {
|
|
11325
|
+
isDegraded = nowDegraded;
|
|
11326
|
+
config.resilience?.onDegradedMode?.(nowDegraded, status);
|
|
11327
|
+
}
|
|
11328
|
+
return {
|
|
11329
|
+
data,
|
|
11330
|
+
resilience: status
|
|
11331
|
+
};
|
|
11332
|
+
}
|
|
11333
|
+
async function tryPublishedRuntimeCacheFallback(plan, statusDetails, errorInfo) {
|
|
11334
|
+
const reader = config.publishedRuntimeCache?.read;
|
|
11335
|
+
if (!plan || !reader) return null;
|
|
11336
|
+
try {
|
|
11337
|
+
const result = await reader({
|
|
11338
|
+
cacheKey: plan.cacheKey,
|
|
11339
|
+
endpoint: plan.endpoint,
|
|
11340
|
+
payloadSchemaVersion: 4
|
|
11341
|
+
});
|
|
11342
|
+
if (result.kind === "miss") return {
|
|
11343
|
+
kind: "miss",
|
|
11344
|
+
diagnostic: {
|
|
11345
|
+
outcome: "miss",
|
|
11346
|
+
reason: result.reason
|
|
11347
|
+
}
|
|
11348
|
+
};
|
|
11349
|
+
if (result.kind === "error") return {
|
|
11350
|
+
kind: "error",
|
|
11351
|
+
diagnostic: {
|
|
11352
|
+
outcome: "error",
|
|
11353
|
+
error: result.error
|
|
11354
|
+
}
|
|
11355
|
+
};
|
|
11356
|
+
return {
|
|
11357
|
+
kind: "hit",
|
|
11358
|
+
result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
|
|
11359
|
+
error: errorInfo,
|
|
11360
|
+
staleAgeSec: result.staleAgeSec,
|
|
11361
|
+
cacheTier: result.freshness === "fresh" ? "durable-fresh" : "durable-stale"
|
|
11362
|
+
}))
|
|
11363
|
+
};
|
|
11364
|
+
} catch (error) {
|
|
11365
|
+
return {
|
|
11366
|
+
kind: "error",
|
|
11367
|
+
diagnostic: {
|
|
11368
|
+
outcome: "error",
|
|
11369
|
+
error: {
|
|
11370
|
+
kind: "adapter_exception",
|
|
11371
|
+
message: error instanceof Error ? error.message : String(error)
|
|
11372
|
+
}
|
|
11373
|
+
}
|
|
11374
|
+
};
|
|
11375
|
+
}
|
|
11376
|
+
}
|
|
11377
|
+
async function writePublishedRuntimeCache(plan, payload) {
|
|
11378
|
+
const writer = config.publishedRuntimeCache?.write;
|
|
11379
|
+
if (!plan || !writer) return;
|
|
11380
|
+
try {
|
|
11381
|
+
await writer({
|
|
11382
|
+
cacheKey: plan.cacheKey,
|
|
11383
|
+
endpoint: plan.endpoint,
|
|
11384
|
+
normalizedParams: plan.normalizedParams,
|
|
11385
|
+
payload,
|
|
11386
|
+
siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
|
|
11387
|
+
freshTtlSec: plan.freshTtlSec,
|
|
11388
|
+
staleTtlSec: plan.staleTtlSec,
|
|
11389
|
+
payloadSchemaVersion: 4,
|
|
11390
|
+
writeReason: "live_success"
|
|
11391
|
+
});
|
|
11392
|
+
} catch {}
|
|
11393
|
+
}
|
|
11394
|
+
async function resilientFetch(cacheKey, fetcher, options) {
|
|
11395
|
+
const requestId = generateRequestId();
|
|
11396
|
+
const startTime = Date.now();
|
|
11397
|
+
const isPreview = options.preview ?? false;
|
|
11398
|
+
const allowFallbacks = !options.force;
|
|
11399
|
+
const statusDetails = (extra = {}) => ({
|
|
11400
|
+
requestId,
|
|
11401
|
+
cacheKey,
|
|
11402
|
+
isPreview,
|
|
11403
|
+
durationMs: Date.now() - startTime,
|
|
11404
|
+
...extra
|
|
11405
|
+
});
|
|
11406
|
+
if (cacheEnabled && !options.force) {
|
|
11407
|
+
const fresh = cache.getFresh(cacheKey);
|
|
11408
|
+
if (fresh !== null) return emitStatus("cache", fresh, statusDetails({ cacheTier: "memory-fresh" }));
|
|
11409
|
+
}
|
|
11410
|
+
if (resilienceEnabled && circuitBreaker.isOpen()) {
|
|
11411
|
+
if (allowFallbacks && !isPreview && staleIfError) {
|
|
11412
|
+
const stale = cache.getStale(cacheKey);
|
|
11413
|
+
if (stale) return emitStatus("stale", stale.value, statusDetails({
|
|
11414
|
+
staleAgeSec: stale.staleAgeSec,
|
|
11415
|
+
cacheTier: "memory-stale",
|
|
11416
|
+
error: {
|
|
11417
|
+
code: "circuit_open",
|
|
11418
|
+
message: "Circuit breaker is open"
|
|
11419
|
+
}
|
|
11420
|
+
}));
|
|
11421
|
+
}
|
|
11422
|
+
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, {
|
|
11423
|
+
code: "circuit_open",
|
|
11424
|
+
message: "Circuit breaker is open"
|
|
11425
|
+
}) : null;
|
|
11426
|
+
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
11427
|
+
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
11428
|
+
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
11429
|
+
const prebuildResult = options.prebuildFallback();
|
|
11430
|
+
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
11431
|
+
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
11432
|
+
cacheTier: "prebuild",
|
|
11433
|
+
durableCache,
|
|
11434
|
+
error: {
|
|
11435
|
+
code: "circuit_open",
|
|
11436
|
+
message: "Circuit breaker is open"
|
|
11437
|
+
}
|
|
11438
|
+
}));
|
|
11439
|
+
}
|
|
11440
|
+
const circuitState = circuitBreaker.getState();
|
|
11441
|
+
emitStatus("error", null, statusDetails({
|
|
11442
|
+
durableCache,
|
|
11443
|
+
error: {
|
|
11444
|
+
code: "circuit_open",
|
|
11445
|
+
message: "Circuit breaker is open"
|
|
11446
|
+
}
|
|
11447
|
+
}));
|
|
11448
|
+
throw new CircuitOpenError(circuitState);
|
|
11449
|
+
}
|
|
11450
|
+
try {
|
|
11451
|
+
let data;
|
|
11452
|
+
if (resilienceEnabled) {
|
|
11453
|
+
if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
|
|
11454
|
+
data = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
|
|
11455
|
+
const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
|
|
11456
|
+
try {
|
|
11457
|
+
return unwrapResponse(await fetcher(combinedSignal));
|
|
11458
|
+
} catch (error) {
|
|
11459
|
+
convertToTypedError(error);
|
|
11460
|
+
}
|
|
11461
|
+
}, {
|
|
11462
|
+
...retryConfig,
|
|
11463
|
+
requestTimeoutMs
|
|
11464
|
+
});
|
|
11465
|
+
circuitBreaker.recordSuccess();
|
|
11466
|
+
} else try {
|
|
11467
|
+
data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
|
|
11468
|
+
} catch (error) {
|
|
11469
|
+
convertToTypedError(error);
|
|
11470
|
+
}
|
|
11471
|
+
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, { tags: options.cacheTags });
|
|
11472
|
+
if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
|
|
11473
|
+
return emitStatus("live", data, statusDetails());
|
|
11474
|
+
} catch (error) {
|
|
11475
|
+
if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
|
|
11476
|
+
if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
|
|
11477
|
+
const stale = cache.getStale(cacheKey);
|
|
11478
|
+
if (stale) {
|
|
11479
|
+
const errorInfo = getRiverbankErrorInfo(error);
|
|
11480
|
+
return emitStatus("stale", stale.value, statusDetails({
|
|
11481
|
+
staleAgeSec: stale.staleAgeSec,
|
|
11482
|
+
cacheTier: "memory-stale",
|
|
11483
|
+
error: errorInfo
|
|
11484
|
+
}));
|
|
11485
|
+
}
|
|
11486
|
+
}
|
|
11487
|
+
const errorInfo = getRiverbankErrorInfo(error);
|
|
11488
|
+
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
|
|
11489
|
+
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
11490
|
+
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
11491
|
+
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
11492
|
+
const prebuildResult = options.prebuildFallback();
|
|
11493
|
+
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
11494
|
+
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
11495
|
+
cacheTier: "prebuild",
|
|
11496
|
+
durableCache,
|
|
11497
|
+
error: errorInfo
|
|
11498
|
+
}));
|
|
11499
|
+
}
|
|
11500
|
+
throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
|
|
11501
|
+
error: errorInfo,
|
|
11502
|
+
durableCache
|
|
11503
|
+
})).resilience);
|
|
11504
|
+
}
|
|
11505
|
+
}
|
|
11506
|
+
async function resilientFetchData(policyEndpoint, cacheKey, fetcher, options) {
|
|
11507
|
+
return (await resilientFetch(cacheKey, fetcher, applyPublicLoaderCachePolicy(policyEndpoint, options))).data;
|
|
11508
|
+
}
|
|
11509
|
+
const contentReads = createContentReadOperations({
|
|
11510
|
+
apiClient,
|
|
11511
|
+
resilientFetch,
|
|
11512
|
+
prebuildLoader
|
|
11513
|
+
});
|
|
11514
|
+
const eventReads = createPublicEventReadOperations({
|
|
11515
|
+
apiClient,
|
|
11516
|
+
resilientFetchData
|
|
11517
|
+
});
|
|
11518
|
+
const publicAppointmentReads = createPublicAppointmentReadOperations({
|
|
11519
|
+
apiClient,
|
|
11520
|
+
resilientFetchData
|
|
11521
|
+
});
|
|
11522
|
+
async function getEntriesInternal(params) {
|
|
11523
|
+
const { siteId, preview = false, signal } = params;
|
|
11524
|
+
const request = buildEntryListReadRequest(params);
|
|
11525
|
+
return materializeEntriesMedia(await resilientFetchData("listPublishedEntries", request.cacheKey, (sig) => apiClient({
|
|
11526
|
+
endpoint: "listPublishedEntries",
|
|
11527
|
+
params: request.params,
|
|
11528
|
+
options: { signal: sig }
|
|
11529
|
+
}), {
|
|
11530
|
+
preview,
|
|
11531
|
+
signal,
|
|
11532
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublishedEntries", { siteId }),
|
|
11533
|
+
prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
|
|
11534
|
+
}));
|
|
11535
|
+
}
|
|
11536
|
+
return {
|
|
11537
|
+
async getSite(params) {
|
|
11538
|
+
return (await contentReads.getSiteWithResilience(params)).data;
|
|
11539
|
+
},
|
|
11540
|
+
async getSiteWithResilience(params) {
|
|
11541
|
+
return contentReads.getSiteWithResilience(params);
|
|
11542
|
+
},
|
|
11543
|
+
async getPage(params) {
|
|
11544
|
+
return (await contentReads.getPageWithResilience(params)).data;
|
|
11545
|
+
},
|
|
11546
|
+
async getPageWithResilience(params) {
|
|
11547
|
+
return contentReads.getPageWithResilience(params);
|
|
11548
|
+
},
|
|
11549
|
+
async getEntries(params) {
|
|
11550
|
+
return getEntriesInternal(params);
|
|
11551
|
+
},
|
|
11552
|
+
async getEntriesByIdentifiers(params) {
|
|
11553
|
+
const { siteId, contentType, identifiers, preview, signal } = params;
|
|
11554
|
+
const normalized = normalizeEntryIdentifierRefs(identifiers);
|
|
11555
|
+
if (normalized.kind === "empty") return { entries: [] };
|
|
11556
|
+
return getEntriesInternal({
|
|
11557
|
+
siteId,
|
|
11558
|
+
contentType,
|
|
11559
|
+
preview,
|
|
11560
|
+
signal,
|
|
11561
|
+
mode: "manual",
|
|
11562
|
+
entryIds: normalized.refs
|
|
11563
|
+
});
|
|
11564
|
+
},
|
|
11565
|
+
async getEntry(params) {
|
|
11566
|
+
const { siteId, contentType, slug, signal } = params;
|
|
11567
|
+
return resilientFetchData("getPublishedEntryPreview", `entry:${siteId}:${contentType}:${slug}`, async (sig) => {
|
|
11568
|
+
return await apiClient({
|
|
11569
|
+
endpoint: "getPublishedEntryPreview",
|
|
11570
|
+
params: {
|
|
11571
|
+
siteId,
|
|
11572
|
+
type: contentType,
|
|
11573
|
+
slug
|
|
11574
|
+
},
|
|
11575
|
+
options: { signal: sig }
|
|
11576
|
+
});
|
|
11577
|
+
}, {
|
|
11578
|
+
signal,
|
|
11579
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublishedEntryPreview", { siteId })
|
|
11580
|
+
});
|
|
11581
|
+
},
|
|
11582
|
+
async getPublicFormById(params) {
|
|
11583
|
+
const { formId, siteId, signal } = params;
|
|
11584
|
+
if (!formId || !siteId) throw new Error("getPublicFormById() requires formId and siteId");
|
|
11585
|
+
return resilientFetchData("getPublicFormById", `public-form:${siteId}:${formId}`, async (sig) => {
|
|
11586
|
+
return normalizePublicFormResult(await apiClient({
|
|
11587
|
+
endpoint: "getPublicFormById",
|
|
11588
|
+
params: {
|
|
11589
|
+
formId,
|
|
11590
|
+
siteId
|
|
11591
|
+
},
|
|
11592
|
+
options: { signal: sig }
|
|
11593
|
+
}));
|
|
11594
|
+
}, {
|
|
11595
|
+
signal,
|
|
11596
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicFormById", {
|
|
11597
|
+
siteId,
|
|
11598
|
+
formId
|
|
11599
|
+
})
|
|
11600
|
+
});
|
|
11601
|
+
},
|
|
11602
|
+
async getForms(params) {
|
|
11603
|
+
const { siteId, signal } = params;
|
|
11604
|
+
if (!siteId) throw new Error("getForms() requires siteId");
|
|
11605
|
+
return resilientFetchData("listPublicForms", `forms:${siteId}`, async (sig) => {
|
|
11606
|
+
return normalizePublicFormsResult(await apiClient({
|
|
11607
|
+
endpoint: "listPublicForms",
|
|
11608
|
+
params: { siteId },
|
|
11609
|
+
options: { signal: sig }
|
|
11610
|
+
}));
|
|
11611
|
+
}, {
|
|
11612
|
+
signal,
|
|
11613
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicForms", { siteId }),
|
|
11614
|
+
prebuildFallback: prebuildLoader ? () => {
|
|
11615
|
+
const result = prebuildLoader.loadForms();
|
|
11616
|
+
if (result) return {
|
|
11617
|
+
data: { forms: result.data.map((form) => ({
|
|
11618
|
+
id: form.id,
|
|
11619
|
+
slug: form.slug,
|
|
11620
|
+
name: form.name,
|
|
11621
|
+
schema: form.schema,
|
|
11622
|
+
settings: form.settings,
|
|
11623
|
+
schemaJson: form.schema,
|
|
11624
|
+
settingsJson: form.settings,
|
|
11625
|
+
createdAt: null,
|
|
11626
|
+
updatedAt: null
|
|
11627
|
+
})) },
|
|
11628
|
+
prebuildAgeSec: result.prebuildAgeSec
|
|
11629
|
+
};
|
|
11630
|
+
return null;
|
|
11631
|
+
} : void 0
|
|
11632
|
+
});
|
|
11633
|
+
},
|
|
11634
|
+
...publicAppointmentReads,
|
|
11635
|
+
async listPublicEvents(params) {
|
|
11636
|
+
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, detailLevel, readProfile, seriesId, includeOccurrenceId, signal } = params;
|
|
11637
|
+
if (!siteId) throw new Error("listPublicEvents() requires siteId");
|
|
11638
|
+
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) => {
|
|
11639
|
+
return await apiClient({
|
|
11640
|
+
endpoint: "listPublicEvents",
|
|
11641
|
+
params: {
|
|
11642
|
+
siteId,
|
|
11643
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
11644
|
+
...from && { from },
|
|
11645
|
+
...to && { to },
|
|
11646
|
+
...afterStartsAt && { afterStartsAt },
|
|
11647
|
+
...afterId && { afterId },
|
|
11648
|
+
...stage && { stage },
|
|
11649
|
+
...categoryIds && { categoryIds },
|
|
11650
|
+
...venueId && { venueId },
|
|
11651
|
+
...staffMemberId && { staffMemberId },
|
|
11652
|
+
...kind && { kind },
|
|
11653
|
+
...eventSurface && { eventSurface },
|
|
11654
|
+
...eventPresets && { eventPresets },
|
|
11655
|
+
...scheduleScope && { scheduleScope },
|
|
11656
|
+
...detailLevel && { detailLevel },
|
|
11657
|
+
...readProfile && { readProfile },
|
|
11658
|
+
...seriesId && { seriesId },
|
|
11659
|
+
...includeOccurrenceId && { includeOccurrenceId }
|
|
11660
|
+
},
|
|
11661
|
+
options: { signal: sig }
|
|
11662
|
+
});
|
|
11663
|
+
}, {
|
|
11664
|
+
signal,
|
|
11665
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEvents", { siteId })
|
|
11666
|
+
});
|
|
11667
|
+
},
|
|
11668
|
+
async getPublicEventDetails(params) {
|
|
11669
|
+
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, seriesId, includeOccurrenceId, signal } = params;
|
|
11670
|
+
if (!siteId) throw new Error("getPublicEventDetails() requires siteId");
|
|
11671
|
+
return resilientFetchData("getPublicEventDetails", `public-event-details:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
|
|
11672
|
+
const requestId = "eventDetails";
|
|
11673
|
+
return normalizeBatchBlockLoaderResult(await apiClient({
|
|
11674
|
+
endpoint: "batchBlockLoaders",
|
|
11675
|
+
params: {
|
|
11676
|
+
siteId,
|
|
11677
|
+
...stage && { stage }
|
|
11678
|
+
},
|
|
11679
|
+
body: { requests: [{
|
|
11680
|
+
id: requestId,
|
|
11681
|
+
endpoint: "getPublicEventDetails",
|
|
11682
|
+
params: {
|
|
11683
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
11684
|
+
...from && { from },
|
|
11685
|
+
...to && { to },
|
|
11686
|
+
...afterStartsAt && { afterStartsAt },
|
|
11687
|
+
...afterId && { afterId },
|
|
11688
|
+
...categoryIds && { categoryIds },
|
|
11689
|
+
...venueId && { venueId },
|
|
11690
|
+
...staffMemberId && { staffMemberId },
|
|
11691
|
+
...kind && { kind },
|
|
11692
|
+
...eventSurface && { eventSurface },
|
|
11693
|
+
...eventPresets && { eventPresets },
|
|
11694
|
+
...scheduleScope && { scheduleScope },
|
|
11695
|
+
...seriesId && { seriesId },
|
|
11696
|
+
...includeOccurrenceId && { includeOccurrenceId }
|
|
11697
|
+
}
|
|
11698
|
+
}] },
|
|
11699
|
+
options: { signal: sig }
|
|
11700
|
+
}), requestId);
|
|
11701
|
+
}, {
|
|
11702
|
+
signal,
|
|
11703
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicEventDetails", { siteId })
|
|
11704
|
+
});
|
|
11705
|
+
},
|
|
11706
|
+
async listPublicTeamMembers(params) {
|
|
11707
|
+
const { siteId, stage, signal } = params;
|
|
11708
|
+
if (!siteId) throw new Error("listPublicTeamMembers() requires siteId");
|
|
11709
|
+
return resilientFetchData("listPublicTeamMembers", `public-team-members:${siteId}:${stage ?? ""}`, async (sig) => {
|
|
11710
|
+
return await apiClient({
|
|
11711
|
+
endpoint: "listPublicTeamMembers",
|
|
11712
|
+
params: {
|
|
11713
|
+
siteId,
|
|
11714
|
+
...stage && { stage }
|
|
11715
|
+
},
|
|
11716
|
+
options: { signal: sig }
|
|
11717
|
+
});
|
|
11718
|
+
}, {
|
|
11719
|
+
signal,
|
|
11720
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicTeamMembers", { siteId })
|
|
11721
|
+
});
|
|
11722
|
+
},
|
|
11723
|
+
async listPublicProducts(params) {
|
|
11724
|
+
const { siteId, stage, categorySelector, signal } = params;
|
|
11725
|
+
if (!siteId) throw new Error("listPublicProducts() requires siteId");
|
|
11726
|
+
const selectorKey = categorySelector ? categorySelector.kind === "category" ? `category:${categorySelector.productCategoryId}` : `current-category-page:${categorySelector.productCategoryEntryId}` : "";
|
|
11727
|
+
return resilientFetchData("listPublicProducts", `public-products:${siteId}:${stage ?? ""}:${selectorKey}`, async (sig) => {
|
|
11728
|
+
return await apiClient({
|
|
11729
|
+
endpoint: "listPublicProducts",
|
|
11730
|
+
params: {
|
|
11731
|
+
siteId,
|
|
11732
|
+
...stage && { stage },
|
|
11733
|
+
...encodePublicProductCategorySelector(categorySelector)
|
|
11734
|
+
},
|
|
11735
|
+
options: { signal: sig }
|
|
11736
|
+
});
|
|
11737
|
+
}, {
|
|
11738
|
+
signal,
|
|
11739
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicProducts", { siteId })
|
|
11740
|
+
});
|
|
11741
|
+
},
|
|
11742
|
+
async listPublicPasses(params) {
|
|
11743
|
+
const { siteId, categories, signal } = params;
|
|
11744
|
+
if (!siteId) throw new Error("listPublicPasses() requires siteId");
|
|
11745
|
+
return resilientFetchData("listPublicPasses", `public-passes:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
11746
|
+
return await apiClient({
|
|
11747
|
+
endpoint: "listPublicPasses",
|
|
11748
|
+
params: {
|
|
11749
|
+
siteId,
|
|
11750
|
+
...categories && { categories }
|
|
11751
|
+
},
|
|
11752
|
+
options: { signal: sig }
|
|
11753
|
+
});
|
|
11754
|
+
}, {
|
|
11755
|
+
signal,
|
|
11756
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicPasses", { siteId })
|
|
11757
|
+
});
|
|
11758
|
+
},
|
|
11759
|
+
async listPublicMemberships(params) {
|
|
11760
|
+
const { siteId, categories, signal } = params;
|
|
11761
|
+
if (!siteId) throw new Error("listPublicMemberships() requires siteId");
|
|
11762
|
+
return resilientFetchData("listPublicMemberships", `public-memberships:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
11763
|
+
return await apiClient({
|
|
11764
|
+
endpoint: "listPublicMemberships",
|
|
11765
|
+
params: {
|
|
11766
|
+
siteId,
|
|
11767
|
+
...categories && { categories }
|
|
11768
|
+
},
|
|
11769
|
+
options: { signal: sig }
|
|
11770
|
+
});
|
|
11771
|
+
}, {
|
|
11772
|
+
signal,
|
|
11773
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicMemberships", { siteId })
|
|
11774
|
+
});
|
|
11775
|
+
},
|
|
11776
|
+
...eventReads,
|
|
11777
|
+
async checkRedirect(params) {
|
|
11778
|
+
const { siteId, path, signal } = params;
|
|
11779
|
+
if (!siteId || !path) throw new Error("checkRedirect() requires siteId and path");
|
|
11780
|
+
return resilientFetchData("checkRedirect", `redirect:${siteId}:${path}`, async (sig) => {
|
|
11781
|
+
return await apiClient({
|
|
11782
|
+
endpoint: "checkRedirect",
|
|
11783
|
+
params: {
|
|
11784
|
+
site: siteId,
|
|
11785
|
+
path
|
|
11786
|
+
},
|
|
11787
|
+
options: { signal: sig }
|
|
11788
|
+
});
|
|
11789
|
+
}, {
|
|
11790
|
+
signal,
|
|
11791
|
+
cacheTags: buildPublicReadMemoryCacheTags("checkRedirect", { site: siteId })
|
|
11792
|
+
});
|
|
11793
|
+
},
|
|
11794
|
+
async resolveRouteOutcome(params) {
|
|
11795
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11796
|
+
if (!siteId || !path) throw new Error("resolveRouteOutcome() requires siteId and path");
|
|
11797
|
+
return unwrapResponse(await apiClient({
|
|
11798
|
+
endpoint: "resolveRouteOutcome",
|
|
11799
|
+
params: {
|
|
11800
|
+
siteId,
|
|
11801
|
+
path,
|
|
11802
|
+
preview: String(preview)
|
|
11803
|
+
},
|
|
11804
|
+
options: { signal }
|
|
11805
|
+
}));
|
|
11806
|
+
},
|
|
11807
|
+
async resolveRouteDecision(params) {
|
|
11808
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11809
|
+
if (!siteId || !path) throw new Error("resolveRouteDecision() requires siteId and path");
|
|
11810
|
+
return unwrapResponse(await apiClient({
|
|
11811
|
+
endpoint: "resolveRouteDecision",
|
|
11812
|
+
params: {
|
|
11813
|
+
siteId,
|
|
11814
|
+
path,
|
|
11815
|
+
preview: String(preview)
|
|
11816
|
+
},
|
|
11817
|
+
options: { signal }
|
|
11818
|
+
}));
|
|
11819
|
+
},
|
|
11820
|
+
async getAllPublishedRoutes(params) {
|
|
11821
|
+
const { siteId, signal } = params;
|
|
11822
|
+
if (!siteId) throw new Error("getAllPublishedRoutes() requires siteId");
|
|
11823
|
+
return resilientFetchData("getPublicRoutableContent", `routable-content:${siteId}:published`, async (sig) => {
|
|
11824
|
+
return await apiClient({
|
|
11825
|
+
endpoint: "getPublicRoutableContent",
|
|
11826
|
+
params: {
|
|
11827
|
+
siteId,
|
|
11828
|
+
publishedOnly: "true"
|
|
11829
|
+
},
|
|
11830
|
+
options: { signal: sig }
|
|
11831
|
+
});
|
|
11832
|
+
}, {
|
|
11833
|
+
signal,
|
|
11834
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicRoutableContent", { siteId })
|
|
11835
|
+
});
|
|
11836
|
+
},
|
|
11837
|
+
async getSitemapRoutes(params) {
|
|
11838
|
+
const { siteId, page, pageSize, signal } = params;
|
|
11839
|
+
if (!siteId) throw new Error("getSitemapRoutes() requires siteId");
|
|
11840
|
+
return resilientFetchData("getPublicSitemapRoutes", `sitemap:${siteId}:${page ?? 1}:${pageSize ?? "default"}`, async (sig) => {
|
|
11841
|
+
return await apiClient({
|
|
11842
|
+
endpoint: "getPublicSitemapRoutes",
|
|
11843
|
+
params: {
|
|
11844
|
+
siteId,
|
|
11845
|
+
...page ? { page: String(page) } : {},
|
|
11846
|
+
...pageSize ? { pageSize: String(pageSize) } : {}
|
|
11847
|
+
},
|
|
11848
|
+
options: { signal: sig }
|
|
11849
|
+
});
|
|
11850
|
+
}, {
|
|
11851
|
+
signal,
|
|
11852
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicSitemapRoutes", { siteId })
|
|
11853
|
+
});
|
|
11854
|
+
},
|
|
11855
|
+
clearCacheForTags(tags) {
|
|
11856
|
+
cache.clearForTags(tags);
|
|
11857
|
+
},
|
|
11858
|
+
clearCache() {
|
|
11859
|
+
cache.clear();
|
|
11860
|
+
},
|
|
11861
|
+
getKeyType() {
|
|
11862
|
+
return keyType;
|
|
11863
|
+
},
|
|
11864
|
+
getLastEmittedStatus() {
|
|
11865
|
+
return lastStatus;
|
|
11866
|
+
},
|
|
11867
|
+
getCircuitState() {
|
|
11868
|
+
return circuitBreaker.getState();
|
|
11869
|
+
},
|
|
11870
|
+
getBaseUrl() {
|
|
11871
|
+
return config.baseUrl;
|
|
11872
|
+
}
|
|
9658
11873
|
};
|
|
9659
11874
|
}
|
|
9660
11875
|
//#endregion
|
|
9661
|
-
export {
|
|
11876
|
+
export { createBearerAPIClient as _, DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, getResilienceStatusFromError as g, RiverbankApiError as h, resolveRuntimeCachePolicy as i, parsePublishedRuntimeCacheKeyDetails as l, CircuitOpenError as m, classifyPublishedRuntimeCacheFreshness as n, isPublishedRuntimeCacheKeyEndpoint as o, sdkRequestOptions as p, derivePublishedRuntimeCacheKey as r, normalizeRuntimePublicPath as s, createRiverbankClient as t, parsePublishedRuntimeCachePayloadSchemaVersion as u, ApiRequestError as v, unwrapResponse as y };
|