@riverbankcms/sdk 0.165.0 → 0.166.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_dts/{BlocksIslandsHydrator-CdsSMQEv.d.ts → BlocksIslandsHydrator-CPvN6RBW.d.ts} +1 -1
- package/dist/_dts/{Page-D6gp2Ipb.d.ts → Page-rW0xgQCA.d.ts} +18 -256
- package/dist/_dts/{SdkPreviewMode-DNXAvnet.d.ts → SdkPreviewMode-BWZh2WCk.d.ts} +26 -3
- package/dist/_dts/{client-BkkExozE.d.ts → client-D4BXQEZc.d.ts} +5 -1
- package/dist/_dts/{content-types-CXNAD7ef.d.ts → content-types-MUzta0l9.d.ts} +3 -3
- package/dist/_dts/{contracts-XRXhbLWP.d.ts → contracts-Cl9Xh1DO.d.ts} +4 -4
- package/dist/_dts/{footerPageOutline-BP2bJYdY.d.ts → footerPageOutline-4BgLKehl.d.ts} +6 -6
- package/dist/_dts/{generatePageMetadata-DcMtbztV.d.ts → generatePageMetadata-BsmJ0qKh.d.ts} +2 -2
- package/dist/_dts/{index-RXkE3a7M.d.ts → index--qflsCiy.d.ts} +4 -3
- package/dist/_dts/{index-C_3kdrUb.d.ts → index-BgJ2aU5c.d.ts} +2 -2
- package/dist/_dts/{index-CQfJhOEA.d.ts → index-Bmboeb49.d.ts} +1 -1
- package/dist/_dts/{index-CRRiddNp.d.ts → index-DdcwPqQN.d.ts} +4 -4
- package/dist/_dts/{index-DKNEgSOS.d.ts → index-ahxQCUc7.d.ts} +2 -2
- package/dist/_dts/{index-BdkHhyf8.d.ts → index-kQ5xkM6X.d.ts} +1 -1
- package/dist/_dts/{index-DAPTSmBM.d.ts → index-mMMvLLAJ.d.ts} +2596 -2511
- package/dist/_dts/{index-B4ozSzFP.d.ts → index-wbBZ0awa.d.ts} +9248 -8251
- package/dist/_dts/{loadContent-B9vJMq3s.d.ts → loadContent-BG5IAV-V.d.ts} +9 -6
- package/dist/_dts/resolveBlockData-Cmcle_zV.d.ts +136 -0
- package/dist/_dts/{resolvePageContent-DIQyYUi-.d.ts → resolvePageContent-BRJUTFoH.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 +1 -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 +257 -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-Cl0nP6al.d.ts → types-BX3Y-EW3.d.ts} +3 -3
- package/dist/_dts/{types-mstFvhK4.d.ts → types-DF54stxv.d.ts} +8 -7
- package/dist/_dts/{types-BDF73NzM.d.ts → types-DuiHLiPo.d.ts} +2 -2
- package/dist/_dts/{validation-DVWqSvjK.d.ts → validation-Bxi0f81D.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-CzKpH9Pm.mjs → BlocksIslandsHydrator-DwiRGtgh.mjs} +31 -24
- package/dist/client/{BookingMailingListNote-rUqsBN7L.mjs → BookingMailingListNote-DOWOZYlK.mjs} +2 -2
- package/dist/client/{CalendarNavigationChevron-YGzw2IPB.mjs → CalendarNavigationChevron-5a0x0vcC.mjs} +7 -7
- package/dist/client/{CheckboxChoice-DlTC4J2a.mjs → CheckboxChoice-CZ-anOqV.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-D2LyS_Bi.mjs → DemoBookingPortalAccess-B2qLkPRB.mjs} +6 -6
- package/dist/client/{DemoPortalSignInLink-BaFg2Uit.mjs → DemoPortalSignInLink-B9YrzZt2.mjs} +1 -1
- package/dist/client/{EventCalendar.client-tRrhPscX.mjs → EventCalendar.client-BhADnDCg.mjs} +9 -9
- package/dist/client/{EventCombined.client-6cfAVtnZ.mjs → EventCombined.client-jik34zTb.mjs} +8 -8
- package/dist/client/{EventEmbeddedCheckoutStep-CDNUpI0S.mjs → EventEmbeddedCheckoutStep-D_14yqAU.mjs} +27 -2
- package/dist/client/{EventItem-dILw2PN_.mjs → EventItem-CMKrtkT7.mjs} +26 -11
- package/dist/client/{EventListWeekNavigation-ClgLtjNY.mjs → EventListWeekNavigation-AGHjxy6C.mjs} +1 -1
- package/dist/client/{EventListing.client-BNueAHmU.mjs → EventListing.client-DZeDM0Qt.mjs} +3 -3
- package/dist/client/{EventListing.view-DtVbKVkt.mjs → EventListing.view-3BBRdNVa.mjs} +31 -20
- package/dist/client/{EventRegistrationPayment-CzkG0NSJ.mjs → EventRegistrationPayment-CpNcpga4.mjs} +108 -11
- package/dist/client/{LocationMapActions-zWQsJhE5.mjs → LocationMapActions-D5-H9ooQ.mjs} +2 -2
- package/dist/client/{MapDrawingSvg-D1AO_o4h.mjs → MapDrawingSvg-C30geMl-.mjs} +1 -1
- package/dist/client/{Page-DUr2YhFR.mjs → Page-DNDZLRlB.mjs} +1894 -11322
- package/dist/client/{ProtectedSubmitButton-2fJqT_NR.mjs → ProtectedSubmitButton-8DuDw2ag.mjs} +1 -1
- package/dist/client/{StepIndicator-udNHcpOT.mjs → StepIndicator-Bin7YR0A.mjs} +3 -3
- package/dist/client/{TabBarFragment-C_kt-PXh.mjs → TabBarFragment-_IAthZVM.mjs} +1 -1
- package/dist/client/{ThemedButton-Cfbo1bfh.mjs → ThemedButton-8jUc02mZ.mjs} +64 -2
- package/dist/client/{accordion-3CYNWzTS.mjs → accordion-uVqNowRX.mjs} +1 -1
- package/dist/client/{booking-form.client-BSbWgLyx.mjs → booking-form.client-w-PvyWBv.mjs} +19 -14
- package/dist/client/{bookingForm-2MoFBWSt.mjs → bookingForm-DNMojb6A.mjs} +4 -4
- package/dist/client/bookings.mjs +6 -6
- package/dist/client/{carousel-Cu5mcpO-.mjs → carousel-C8kxI3Dm.mjs} +2 -2
- package/dist/client/{carousel.client-CQLV8_Al.mjs → carousel.client-BO7sCEpH.mjs} +1 -1
- package/dist/client/{cart-CDc6x9cR.mjs → cart-DCxjE3Is.mjs} +3 -3
- package/dist/client/{cart.client-BWS2r5Ef.mjs → cart.client-Ceeng8fB.mjs} +1 -1
- package/dist/client/{checkout-CkxPqSwD.mjs → checkout-B0EKbeVv.mjs} +3 -3
- package/dist/client/{checkout.client-DJfomKQc.mjs → checkout.client-DtPj3fYk.mjs} +1 -1
- package/dist/client/client.mjs +9465 -15
- package/dist/client/{context-CBV21-9L.mjs → context-n6IZigd3.mjs} +8 -6
- package/dist/client/{cta-Bw-al3cs.mjs → cta-CDeAwYoN.mjs} +45 -28
- package/dist/client/{dateFormatting-CFIUJ4Uf.mjs → dateFormatting-BWPzdeZE.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-D0veHJyi.mjs → demoPortalMagicLink-BdXu0fj-.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-CEqqq92r.mjs → enhanceHeaderSection-VHfv8M6-.mjs} +3 -3
- package/dist/client/{event-details.client-Bk2kQ7ax.mjs → event-details.client-Cfr1_Cj4.mjs} +2 -2
- package/dist/client/{event-registration.client-QMqtIywj.mjs → event-registration.client-BhygihpQ.mjs} +33 -16
- package/dist/client/{eventCalendar-BTDTMosr.mjs → eventCalendar-B4XCL9u6.mjs} +4 -4
- package/dist/client/{eventCombined-BC7a709c.mjs → eventCombined-DVjz4wdf.mjs} +4 -4
- package/dist/client/{eventDetails-DL08GpUc.mjs → eventDetails-B0DA1Nw1.mjs} +2 -2
- package/dist/client/{eventListing-BfzuEQp_.mjs → eventListing-2-xjn2nz.mjs} +4 -4
- package/dist/client/{eventRegistration-Lfyzh1Ab.mjs → eventRegistration-ng4iGo9O.mjs} +4 -4
- package/dist/client/{form-L-xZOBUS.mjs → form-BeNQiZ2V.mjs} +3 -3
- package/dist/client/{form.client-BtpK3TZW.mjs → form.client-BFdCKlp7.mjs} +5 -5
- package/dist/client/{form.parts-Djos5Un4.mjs → form.parts-C7gLK3jh.mjs} +3 -3
- package/dist/client/{formatDate-DGmrm7YB.mjs → formatDate-CWfelfMt.mjs} +1 -1
- package/dist/client/gifting/client.mjs +3 -4
- package/dist/client/{headerSection-f16OGkz-.mjs → headerSection-CalNAShx.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-Dq7GHGXU.mjs} +6 -6
- package/dist/client/{newsletter-form.parts-CLGH20PL.mjs → newsletter-form.parts-BSMDYQiS.mjs} +2 -2
- package/dist/client/{newsletterForm-BEU0Ocu9.mjs → newsletterForm-snzZ4L6i.mjs} +3 -3
- package/dist/client/{noop-CQU7tiMg.mjs → noop-D-RG9eR3.mjs} +394 -168
- package/dist/client/portal/client.mjs +13 -14
- package/dist/client/{product-detail.client-Be-om1BT.mjs → product-detail.client-Gu0INDb7.mjs} +1 -1
- package/dist/client/{product-list.client-DR7hD5Vs.mjs → product-list.client-BmH40fNf.mjs} +1 -1
- package/dist/client/{productDetail-BD42UOmG.mjs → productDetail-DsPUmJ0z.mjs} +3 -3
- package/dist/client/{productList-CSk8sXCl.mjs → productList-DjGrjOwD.mjs} +3 -3
- package/dist/client/{propsDecoder-C_Y6VYnF.mjs → propsDecoder-kTVPMnfD.mjs} +4 -4
- package/dist/client/{registry.server-CIKtTsCl.mjs → registry.server-CKK_RXZo.mjs} +213 -314
- 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-BcjTX-7h.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-CROHPlYS.mjs → routeIslandApiConfig-CaXesATK.mjs} +1 -1
- package/dist/client/{shop-DscvMz86.mjs → shop-DLufMauE.mjs} +3 -3
- package/dist/client/{shop-commerce-CDUohm_2.mjs → shop-commerce-BxYYXLNK.mjs} +12 -12
- package/dist/client/{shop-commerce-store-B9nw4lRP.mjs → shop-commerce-store-Dp3Nl5YK.mjs} +1 -1
- package/dist/client/{shop.client-M3kNsVPi.mjs → shop.client-CBy9_alG.mjs} +13 -13
- package/dist/client/{shop.interactive-BGmkdIAZ.mjs → shop.interactive-BM0NRsFQ.mjs} +48 -34
- package/dist/client/{shopShared-BdWp6LHa.mjs → shopShared-lS23OQE-.mjs} +2 -2
- package/dist/client/site-styles-D8jEPGxA.mjs +3 -0
- package/dist/{preview-next/client/ThemedButton-Dc6aJ34Z.mjs → client/site-styles-DELkUk9s.mjs} +25468 -17264
- 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-DzRWikCU.mjs} +157 -139
- package/dist/client/types-sF-IrGQr.mjs +633 -0
- package/dist/client/{useAvailableSlots-Cw9paRPY.mjs → useAvailableSlots-C3LphWDX.mjs} +8 -5
- package/dist/client/{useBookingNowIso-C9SF2rC6.mjs → useBookingNowIso-Da-f9iHw.mjs} +1 -1
- package/dist/client/{useDiscountApply-B-QJfBg0.mjs → useDiscountApply-SLoWhcen.mjs} +3 -3
- package/dist/client/{useDiscountCodeUi-Uvum8q9d.mjs → useDiscountCodeUi-D6a2BJij.mjs} +1 -1
- package/dist/client/{useEventPagination-BfM3xk6j.mjs → useEventPagination-Ccr4TZlm.mjs} +9 -9
- package/dist/client/{view-DXOuduIr.mjs → view-8w4GA8rf.mjs} +4 -4
- package/dist/client/{view-DlkCDfuN.mjs → view-DAVEoe8A.mjs} +277 -227
- package/dist/client/{wizardSteps-DManVJpc.mjs → wizardSteps-DNpajrAH.mjs} +453 -141
- package/dist/preview-next/before-render.mjs +3 -140
- package/dist/preview-next/client/ArrangementLookControls-DY5TzhEa.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-DdnhmdFO.mjs +37049 -0
- package/dist/preview-next/client/{PreviewEditorUI-CxwlLBGw.mjs → PreviewEditorUI-C7ZmYE33.mjs} +45 -17
- package/dist/preview-next/client/PreviewShell-DnO38NaL.mjs +4707 -0
- package/dist/preview-next/client/SdkPreviewModeRuntime-D2OtoRMB.mjs +4258 -0
- package/dist/preview-next/client/SiteChromeCustomizeButton-eIu2RejJ.mjs +71144 -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-Bp1AlAxx.mjs +110560 -0
- package/dist/preview-next/client/{previewChromeSurface-yuwnDP3B.mjs → previewChromeSurface-D2cREDJ5.mjs} +90 -28
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/sdk-runtime-DK0PUhLL.mjs +5 -0
- package/dist/preview-next/client/{editorStatusDecision-DR4BBKhy.mjs → useAutosaveStatus--Pw8vnef.mjs} +40 -3
- package/dist/preview-next/client/useBlockCustomizeControls-C1Rl73N4.mjs +2724 -0
- package/dist/preview-next/client/useOpenBlockForSetup-CL3842FM.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-Bq7SUX3K.mjs} +132 -118
- package/dist/server/{Block.shared-ClFI3qpX.mjs → Block.shared-wXr7Iwhs.mjs} +7 -4
- package/dist/server/{src-DsYPhTbs.mjs → ThemeScopeCore-BI2mld9R.mjs} +178 -2532
- package/dist/server/accessibleSurfaces-CuN8U_iU.mjs +2102 -0
- package/dist/server/{bindings-Bi8EoRZD.mjs → bindings-DjdUq9FR.mjs} +2 -3
- package/dist/server/{publicProducts-Bz8loTRn.mjs → client-07UeMDzA.mjs} +2483 -351
- 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-ClpaSlBb.mjs} +6 -5
- package/dist/server/{loadPage-DBFBad8A.mjs → loadPage-BwtVqpaA.mjs} +4 -2
- package/dist/server/manifest.mjs +1 -1
- package/dist/server/media-DnlczCMA.mjs +231 -0
- package/dist/server/mode-Cv_TG9gP.mjs +63 -0
- package/dist/server/next.mjs +11 -11
- package/dist/server/opaqueSurface-3YSDPtDe.mjs +54 -0
- package/dist/server/{overrideResolution-BIJbiXYc.mjs → overrideResolution-Du_w3LY4.mjs} +2 -1
- package/dist/server/overrides-CD4d-1w7.mjs +177 -0
- package/dist/server/page-converter.mjs +243 -91
- package/dist/server/pageRenderPlan-BShULdc2.mjs +4055 -0
- package/dist/server/{themeAdmission-CSknYpxk.mjs → pageRuntimeSupport-C4Dh5-mB.mjs} +13 -28
- package/dist/server/{overrides-DhF87Vsd.mjs → pageShared-HdKFBpaX.mjs} +3472 -1795
- package/dist/server/parseThemeForPersistence-CJMrEkze.mjs +52 -0
- package/dist/server/{prebuild-DaemmWQL.mjs → prebuild-Cl-bkaMA.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/prefetchBlockData-C4yUmz-r.mjs +786 -0
- package/dist/server/publicProducts-W9hDRwjz.mjs +64 -0
- package/dist/server/{registry-Cdvz1OtL.mjs → registry-TFPJdGQi.mjs} +20624 -640
- 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-OHlOXlOE.mjs} +6 -48
- package/dist/server/resolveButtonColourStates-lry2ORwX.mjs +2672 -0
- package/dist/server/{richTextSchema-YYc85FX4.mjs → richTextSchema-Euhuj-7V.mjs} +26 -1
- package/dist/server/routing.mjs +1 -1
- package/dist/server/schema-C2PqHrMo.mjs +2523 -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-DIBFZeMB.mjs} +419 -3
- package/dist/server/{version-Beu4q-Gv.mjs → version-DZWZM1H6.mjs} +1 -1
- package/dist/styles/index.css +14 -4
- package/package.json +39 -1
- 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-CuN8U_iU.mjs";
|
|
2
|
+
import { t as parseSiteId } from "./identity-Bn9OQiT1.mjs";
|
|
3
|
+
import { i as isSupportedLoaderEndpoint, t as encodePublicProductCategorySelector } from "./publicProducts-W9hDRwjz.mjs";
|
|
4
|
+
import { t as SDK_VERSION } from "./version-DZWZM1H6.mjs";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
const PUBLIC_CONTENT_FRESHNESS_SECONDS = 3600;
|
|
5
7
|
function availability(transport) {
|
|
@@ -63,29 +65,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",
|
|
@@ -3640,7 +3626,7 @@ z.object({
|
|
|
3640
3626
|
ageMs: z.number().int().min(0).max(CLIENT_ERROR_REPORT_LIMITS.navigationAgeMs)
|
|
3641
3627
|
}).strict().nullable().optional()
|
|
3642
3628
|
}).strict();
|
|
3643
|
-
const API_ENDPOINTS = {
|
|
3629
|
+
const API_ENDPOINTS$1 = {
|
|
3644
3630
|
...PAGE_JOURNAL_ENDPOINT_DEFINITIONS,
|
|
3645
3631
|
...PREVIEW_AUTH_ENDPOINT_DEFINITIONS,
|
|
3646
3632
|
...SITE_LIFECYCLE_ENDPOINT_DEFINITIONS,
|
|
@@ -3662,20 +3648,22 @@ const API_ENDPOINTS = {
|
|
|
3662
3648
|
auth: "user",
|
|
3663
3649
|
responseKind: "json"
|
|
3664
3650
|
},
|
|
3665
|
-
|
|
3666
|
-
path: "/
|
|
3651
|
+
assistantConversation: {
|
|
3652
|
+
path: "/assistant/conversation",
|
|
3667
3653
|
method: "POST",
|
|
3668
3654
|
auth: "user",
|
|
3669
|
-
responseKind: "
|
|
3655
|
+
responseKind: "json",
|
|
3656
|
+
errors: []
|
|
3670
3657
|
},
|
|
3671
|
-
|
|
3672
|
-
path: "/
|
|
3673
|
-
method: "
|
|
3658
|
+
assistantNewConversation: {
|
|
3659
|
+
path: "/assistant/conversation/new",
|
|
3660
|
+
method: "POST",
|
|
3674
3661
|
auth: "user",
|
|
3675
|
-
responseKind: "
|
|
3662
|
+
responseKind: "json",
|
|
3663
|
+
errors: []
|
|
3676
3664
|
},
|
|
3677
|
-
|
|
3678
|
-
path: "/assistant/
|
|
3665
|
+
assistantOutcome: {
|
|
3666
|
+
path: "/assistant/outcome",
|
|
3679
3667
|
method: "POST",
|
|
3680
3668
|
auth: "user",
|
|
3681
3669
|
responseKind: "json",
|
|
@@ -3702,42 +3690,6 @@ const API_ENDPOINTS = {
|
|
|
3702
3690
|
responseKind: "stream",
|
|
3703
3691
|
errors: []
|
|
3704
3692
|
},
|
|
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
3693
|
aiGenerateSite: {
|
|
3742
3694
|
path: "/sites/{siteId}/ai/generate",
|
|
3743
3695
|
method: "POST",
|
|
@@ -4520,6 +4472,32 @@ const API_ENDPOINTS = {
|
|
|
4520
4472
|
auth: "user",
|
|
4521
4473
|
responseKind: "json"
|
|
4522
4474
|
},
|
|
4475
|
+
getRouteAddress: {
|
|
4476
|
+
path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
|
|
4477
|
+
method: "GET",
|
|
4478
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteRoutableContent],
|
|
4479
|
+
auth: "user",
|
|
4480
|
+
responseKind: "json",
|
|
4481
|
+
errors: ["resource:not_found", "resource:conflict"]
|
|
4482
|
+
},
|
|
4483
|
+
changeRouteAddress: {
|
|
4484
|
+
editLease: "managed",
|
|
4485
|
+
path: "/sites/{siteId}/content-address/{targetKind}/{targetId}",
|
|
4486
|
+
method: "PATCH",
|
|
4487
|
+
tags: [
|
|
4488
|
+
TAG_TEMPLATES.site,
|
|
4489
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
4490
|
+
TAG_TEMPLATES.siteRedirects
|
|
4491
|
+
],
|
|
4492
|
+
auth: "user",
|
|
4493
|
+
responseKind: "json",
|
|
4494
|
+
errors: [
|
|
4495
|
+
"validation:invalid_input",
|
|
4496
|
+
"resource:not_found",
|
|
4497
|
+
"resource:conflict",
|
|
4498
|
+
"server:internal_error"
|
|
4499
|
+
]
|
|
4500
|
+
},
|
|
4523
4501
|
updateRouteMetadata: {
|
|
4524
4502
|
editLease: "managed",
|
|
4525
4503
|
path: "/sites/{siteId}/routes/{routeId}/metadata",
|
|
@@ -4710,6 +4688,30 @@ const API_ENDPOINTS = {
|
|
|
4710
4688
|
auth: "user",
|
|
4711
4689
|
responseKind: "json"
|
|
4712
4690
|
},
|
|
4691
|
+
previewWebsiteOperation: {
|
|
4692
|
+
path: "/sites/{siteId}/website/preview",
|
|
4693
|
+
method: "POST",
|
|
4694
|
+
auth: "user",
|
|
4695
|
+
responseKind: "json",
|
|
4696
|
+
errors: [
|
|
4697
|
+
"validation:invalid_input",
|
|
4698
|
+
"auth:insufficient_permissions",
|
|
4699
|
+
"server:internal_error"
|
|
4700
|
+
]
|
|
4701
|
+
},
|
|
4702
|
+
confirmWebsiteOperation: {
|
|
4703
|
+
editLease: "unleased-editor",
|
|
4704
|
+
path: "/sites/{siteId}/website/confirm",
|
|
4705
|
+
method: "POST",
|
|
4706
|
+
auth: "user",
|
|
4707
|
+
responseKind: "json",
|
|
4708
|
+
tags: [TAG_TEMPLATES.site, TAG_TEMPLATES.siteSettings],
|
|
4709
|
+
errors: [
|
|
4710
|
+
"validation:invalid_input",
|
|
4711
|
+
"auth:insufficient_permissions",
|
|
4712
|
+
"server:internal_error"
|
|
4713
|
+
]
|
|
4714
|
+
},
|
|
4713
4715
|
previewSiteBrandingOperation: {
|
|
4714
4716
|
path: "/sites/{siteId}/settings/general/preview",
|
|
4715
4717
|
method: "POST",
|
|
@@ -7856,14 +7858,6 @@ const API_ENDPOINTS = {
|
|
|
7856
7858
|
auth: "user",
|
|
7857
7859
|
responseKind: "json"
|
|
7858
7860
|
},
|
|
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
7861
|
billingStatus: {
|
|
7868
7862
|
path: "/billing/status",
|
|
7869
7863
|
method: "GET",
|
|
@@ -8816,6 +8810,7 @@ const API_ENDPOINTS = {
|
|
|
8816
8810
|
responseKind: "json",
|
|
8817
8811
|
errors: [
|
|
8818
8812
|
"resource:not_found",
|
|
8813
|
+
"resource:conflict",
|
|
8819
8814
|
"validation:invalid_input",
|
|
8820
8815
|
"server:internal_error"
|
|
8821
8816
|
]
|
|
@@ -9020,142 +9015,6 @@ var ApiRequestError = class extends Error {
|
|
|
9020
9015
|
}
|
|
9021
9016
|
};
|
|
9022
9017
|
//#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
9018
|
//#region ../api/src/url.ts
|
|
9160
9019
|
function looksLikeLocalAuthority(authority) {
|
|
9161
9020
|
const normalized = authority.toLowerCase();
|
|
@@ -9213,7 +9072,7 @@ z.uuid();
|
|
|
9213
9072
|
/** One client command owns this id; network retries retain the same header. */
|
|
9214
9073
|
function commandHeaders(endpoint, headers, operationId) {
|
|
9215
9074
|
const result = new Headers(headers);
|
|
9216
|
-
if (API_ENDPOINTS[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
|
|
9075
|
+
if (API_ENDPOINTS$1[endpoint].method !== "GET" && !result.has("X-Riverbank-Operation-Id")) result.set(OPERATION_ID_HEADER, operationId);
|
|
9217
9076
|
return result;
|
|
9218
9077
|
}
|
|
9219
9078
|
//#endregion
|
|
@@ -9262,6 +9121,7 @@ z.enum([
|
|
|
9262
9121
|
"invalid-document",
|
|
9263
9122
|
"invalid-history",
|
|
9264
9123
|
"path-unavailable",
|
|
9124
|
+
"homepage-publication-required",
|
|
9265
9125
|
"invalid-page-version",
|
|
9266
9126
|
"invalid-block-reference",
|
|
9267
9127
|
"invalid-content-reference",
|
|
@@ -9289,11 +9149,10 @@ function getRevalidateTag() {
|
|
|
9289
9149
|
}
|
|
9290
9150
|
return revalidateTag;
|
|
9291
9151
|
}
|
|
9292
|
-
let sdkVersion;
|
|
9293
9152
|
/**
|
|
9294
9153
|
* Generate a UUID, with fallback for environments where crypto.randomUUID isn't available.
|
|
9295
9154
|
*/
|
|
9296
|
-
function generateRequestId() {
|
|
9155
|
+
function generateRequestId$1() {
|
|
9297
9156
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
9298
9157
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
9299
9158
|
const r = Math.random() * 16 | 0;
|
|
@@ -9301,13 +9160,6 @@ function generateRequestId() {
|
|
|
9301
9160
|
});
|
|
9302
9161
|
}
|
|
9303
9162
|
/**
|
|
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
9163
|
* Parse the Retry-After header value to milliseconds.
|
|
9312
9164
|
* The header can be either:
|
|
9313
9165
|
* - A number of seconds (e.g., "120")
|
|
@@ -9325,8 +9177,8 @@ function parseRetryAfterHeader(headerValue) {
|
|
|
9325
9177
|
return delayMs > 0 ? delayMs : void 0;
|
|
9326
9178
|
}
|
|
9327
9179
|
}
|
|
9328
|
-
function buildEndpointURL(baseURL, endpoint) {
|
|
9329
|
-
return baseURL + API_ENDPOINTS[endpoint].path;
|
|
9180
|
+
function buildEndpointURL$1(baseURL, endpoint) {
|
|
9181
|
+
return baseURL + API_ENDPOINTS$1[endpoint].path;
|
|
9330
9182
|
}
|
|
9331
9183
|
function isFormDataBody(value) {
|
|
9332
9184
|
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
@@ -9414,7 +9266,7 @@ function buildSuccessEnvelope(data, requestId) {
|
|
|
9414
9266
|
success: true,
|
|
9415
9267
|
data,
|
|
9416
9268
|
meta: {
|
|
9417
|
-
requestId: requestId ?? generateRequestId(),
|
|
9269
|
+
requestId: requestId ?? generateRequestId$1(),
|
|
9418
9270
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9419
9271
|
apiVersion: "2025-01-01"
|
|
9420
9272
|
}
|
|
@@ -9429,7 +9281,7 @@ function buildErrorEnvelope(code, message, status, requestId) {
|
|
|
9429
9281
|
error: {
|
|
9430
9282
|
code,
|
|
9431
9283
|
message,
|
|
9432
|
-
requestId: requestId ?? generateRequestId(),
|
|
9284
|
+
requestId: requestId ?? generateRequestId$1(),
|
|
9433
9285
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9434
9286
|
status
|
|
9435
9287
|
}
|
|
@@ -9482,7 +9334,7 @@ async function parseSuccessResponse(endpoint, response, config) {
|
|
|
9482
9334
|
default: return buildSuccessEnvelope(void 0, requestId);
|
|
9483
9335
|
}
|
|
9484
9336
|
}
|
|
9485
|
-
function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
|
|
9337
|
+
function createRawCMSClient(getHeaders = () => ({}), baseUrl, { sdkVersion } = {}) {
|
|
9486
9338
|
return ({ endpoint, body, params, options = {} }) => {
|
|
9487
9339
|
const plan = buildApiRequestPlan({
|
|
9488
9340
|
endpoint,
|
|
@@ -9490,7 +9342,7 @@ function createRawCMSClient(getHeaders = () => ({}), baseUrl) {
|
|
|
9490
9342
|
params,
|
|
9491
9343
|
options: {
|
|
9492
9344
|
...options,
|
|
9493
|
-
headers: commandHeaders(endpoint, options.headers, generateRequestId())
|
|
9345
|
+
headers: commandHeaders(endpoint, options.headers, generateRequestId$1())
|
|
9494
9346
|
},
|
|
9495
9347
|
headers: getHeaders(),
|
|
9496
9348
|
baseUrl: normalizeCmsApiBaseUrl(baseUrl ?? resolveApiBaseUrl()),
|
|
@@ -9510,8 +9362,8 @@ function surfaceTransportCapability(endpoint) {
|
|
|
9510
9362
|
function buildApiRequestPlan(input) {
|
|
9511
9363
|
const { endpoint, body, params, headers = {}, baseUrl } = input;
|
|
9512
9364
|
const options = input.options ?? {};
|
|
9513
|
-
let url = buildEndpointURL(baseUrl, endpoint);
|
|
9514
|
-
const originalPath = API_ENDPOINTS[endpoint].path;
|
|
9365
|
+
let url = buildEndpointURL$1(baseUrl, endpoint);
|
|
9366
|
+
const originalPath = API_ENDPOINTS$1[endpoint].path;
|
|
9515
9367
|
const unusedParams = {};
|
|
9516
9368
|
if (params) Object.entries(params).forEach(([key, value]) => {
|
|
9517
9369
|
const bracePlaceholder = `{${key}}`;
|
|
@@ -9530,7 +9382,7 @@ function buildApiRequestPlan(input) {
|
|
|
9530
9382
|
})));
|
|
9531
9383
|
throw new Error(`Missing required path params for endpoint ${String(endpoint)}: ${missingParams.join(", ")}`);
|
|
9532
9384
|
}
|
|
9533
|
-
const endpointConfig = API_ENDPOINTS[endpoint];
|
|
9385
|
+
const endpointConfig = API_ENDPOINTS$1[endpoint];
|
|
9534
9386
|
const method = endpointConfig.method;
|
|
9535
9387
|
const isGetOrHead = method === "GET" || method === "HEAD";
|
|
9536
9388
|
const queryParams = new URLSearchParams();
|
|
@@ -9571,7 +9423,7 @@ function buildApiRequestPlan(input) {
|
|
|
9571
9423
|
async function createApiRequestError(response, endpoint, fallbackMessage) {
|
|
9572
9424
|
const body = await parseErrorBody(response);
|
|
9573
9425
|
const details = extractApiEnvelopeErrorDetails(body);
|
|
9574
|
-
const config = API_ENDPOINTS[endpoint];
|
|
9426
|
+
const config = API_ENDPOINTS$1[endpoint];
|
|
9575
9427
|
return new ApiRequestError(details.message ?? fallbackMessage ?? `Request to ${String(endpoint)} failed with status ${response.status}`, {
|
|
9576
9428
|
endpoint,
|
|
9577
9429
|
status: response.status,
|
|
@@ -9588,19 +9440,19 @@ function createParsedClient(rawClient) {
|
|
|
9588
9440
|
return async (params) => {
|
|
9589
9441
|
const response = await rawClient(params);
|
|
9590
9442
|
const endpoint = params.endpoint;
|
|
9591
|
-
const config = API_ENDPOINTS[endpoint];
|
|
9443
|
+
const config = API_ENDPOINTS$1[endpoint];
|
|
9592
9444
|
if (!response.ok) throw await createApiRequestError(response, endpoint);
|
|
9593
9445
|
return parseSuccessResponse(endpoint, response, config);
|
|
9594
9446
|
};
|
|
9595
9447
|
}
|
|
9596
|
-
function createCMSClient(headers = {}, baseUrl) {
|
|
9597
|
-
return createParsedClient(createRawCMSClient(() => headers, baseUrl));
|
|
9448
|
+
function createCMSClient(headers = {}, baseUrl, options) {
|
|
9449
|
+
return createParsedClient(createRawCMSClient(() => headers, baseUrl, options));
|
|
9598
9450
|
}
|
|
9599
|
-
function createInternalAPIClient(baseUrl) {
|
|
9600
|
-
return createCMSClient({}, baseUrl);
|
|
9451
|
+
function createInternalAPIClient(baseUrl, options) {
|
|
9452
|
+
return createCMSClient({}, baseUrl, options);
|
|
9601
9453
|
}
|
|
9602
|
-
function createBearerAPIClient(token, baseUrl) {
|
|
9603
|
-
return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl));
|
|
9454
|
+
function createBearerAPIClient(token, baseUrl, options) {
|
|
9455
|
+
return createParsedClient(createRawCMSClient(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
|
|
9604
9456
|
}
|
|
9605
9457
|
/** Positive receipt evidence is kept distinct from an HTTP or request failure. */
|
|
9606
9458
|
function requireUsableCommitProjection(response, parsed) {
|
|
@@ -9608,54 +9460,2334 @@ function requireUsableCommitProjection(response, parsed) {
|
|
|
9608
9460
|
throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
|
|
9609
9461
|
}
|
|
9610
9462
|
//#endregion
|
|
9611
|
-
//#region
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9463
|
+
//#region src/client/error.ts
|
|
9464
|
+
let _Symbol$for;
|
|
9465
|
+
_Symbol$for = Symbol.for("nodejs.util.inspect.custom");
|
|
9466
|
+
/**
|
|
9467
|
+
* Error thrown by SDK when API returns an error response
|
|
9468
|
+
*
|
|
9469
|
+
* @example
|
|
9470
|
+
* ```ts
|
|
9471
|
+
* try {
|
|
9472
|
+
* await client.getSite({ slug: 'my-site' });
|
|
9473
|
+
* } catch (error) {
|
|
9474
|
+
* if (error instanceof RiverbankApiError) {
|
|
9475
|
+
* console.log('Error code:', error.code);
|
|
9476
|
+
* console.log('Request ID:', error.requestId);
|
|
9477
|
+
*
|
|
9478
|
+
* if (error.isAuthError()) {
|
|
9479
|
+
* // Handle authentication error
|
|
9480
|
+
* }
|
|
9481
|
+
*
|
|
9482
|
+
* if (error.isValidationError() && error.fieldErrors) {
|
|
9483
|
+
* // Handle field-level validation errors
|
|
9484
|
+
* error.fieldErrors.forEach(fe => {
|
|
9485
|
+
* console.log(`${fe.field}: ${fe.message}`);
|
|
9486
|
+
* });
|
|
9487
|
+
* }
|
|
9488
|
+
*
|
|
9489
|
+
* // Check if error can be retried
|
|
9490
|
+
* if (error.isRetryable) {
|
|
9491
|
+
* const delay = error.retryAfterMs ?? 1000;
|
|
9492
|
+
* console.log(`Retrying after ${delay}ms...`);
|
|
9493
|
+
* }
|
|
9494
|
+
* }
|
|
9495
|
+
* }
|
|
9496
|
+
* ```
|
|
9497
|
+
*/
|
|
9498
|
+
var RiverbankApiError = class RiverbankApiError extends Error {
|
|
9499
|
+
constructor(apiError) {
|
|
9500
|
+
super(apiError.message);
|
|
9501
|
+
this.name = "RiverbankApiError";
|
|
9502
|
+
if ("cause" in apiError && apiError.cause) this.cause = apiError.cause;
|
|
9503
|
+
this.code = apiError.code;
|
|
9504
|
+
this.requestId = apiError.requestId;
|
|
9505
|
+
this.status = apiError.status;
|
|
9506
|
+
this.fieldErrors = apiError.fieldErrors;
|
|
9507
|
+
this.timestamp = apiError.timestamp;
|
|
9508
|
+
this.retryAfterMs = "retryAfterMs" in apiError ? apiError.retryAfterMs : void 0;
|
|
9509
|
+
this.isRetryable = this.computeRetryable();
|
|
9510
|
+
Object.setPrototypeOf(this, RiverbankApiError.prototype);
|
|
9625
9511
|
}
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
productCategoryId: selector.productCategoryId
|
|
9639
|
-
};
|
|
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
|
-
};
|
|
9512
|
+
/**
|
|
9513
|
+
* Compute whether this error is retryable based on HTTP status code.
|
|
9514
|
+
* - 0 (network errors - no HTTP response): retryable
|
|
9515
|
+
* - 429 (rate limit): retryable
|
|
9516
|
+
* - 5xx (server errors): retryable
|
|
9517
|
+
* - 4xx (client errors, except 429): NOT retryable
|
|
9518
|
+
*/
|
|
9519
|
+
computeRetryable() {
|
|
9520
|
+
if (this.status === 0) return true;
|
|
9521
|
+
if (this.status === 429) return true;
|
|
9522
|
+
if (this.status >= 500) return true;
|
|
9523
|
+
return false;
|
|
9646
9524
|
}
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
}
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9525
|
+
/**
|
|
9526
|
+
* Check if this is a network error (no HTTP response received)
|
|
9527
|
+
*
|
|
9528
|
+
* Matches: network:connection_error, network:timeout, network:dns_error
|
|
9529
|
+
*/
|
|
9530
|
+
isNetworkError() {
|
|
9531
|
+
return this.code.startsWith("network:");
|
|
9532
|
+
}
|
|
9533
|
+
/**
|
|
9534
|
+
* Check if this error matches a specific error code
|
|
9535
|
+
*
|
|
9536
|
+
* @example
|
|
9537
|
+
* ```ts
|
|
9538
|
+
* if (error.is('auth:unauthenticated')) {
|
|
9539
|
+
* // Redirect to login
|
|
9540
|
+
* }
|
|
9541
|
+
* ```
|
|
9542
|
+
*/
|
|
9543
|
+
is(code) {
|
|
9544
|
+
return this.code === code;
|
|
9545
|
+
}
|
|
9546
|
+
/**
|
|
9547
|
+
* Check if this is an authentication or authorization error
|
|
9548
|
+
*
|
|
9549
|
+
* Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
|
|
9550
|
+
* auth:forbidden, auth:mfa_required, auth:insufficient_permissions
|
|
9551
|
+
*/
|
|
9552
|
+
isAuthError() {
|
|
9553
|
+
return this.code.startsWith("auth:");
|
|
9554
|
+
}
|
|
9555
|
+
/**
|
|
9556
|
+
* Check if this is a validation error
|
|
9557
|
+
*
|
|
9558
|
+
* Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
|
|
9559
|
+
*/
|
|
9560
|
+
isValidationError() {
|
|
9561
|
+
return this.code.startsWith("validation:");
|
|
9562
|
+
}
|
|
9563
|
+
/**
|
|
9564
|
+
* Check if this is a resource error (not found, conflict, etc.)
|
|
9565
|
+
*
|
|
9566
|
+
* Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
|
|
9567
|
+
*/
|
|
9568
|
+
isResourceError() {
|
|
9569
|
+
return this.code.startsWith("resource:");
|
|
9570
|
+
}
|
|
9571
|
+
/**
|
|
9572
|
+
* Check if this is a rate limiting error
|
|
9573
|
+
*/
|
|
9574
|
+
isRateLimitError() {
|
|
9575
|
+
return this.code.startsWith("rate_limit:");
|
|
9576
|
+
}
|
|
9577
|
+
/**
|
|
9578
|
+
* Check if this is a billing/payment error
|
|
9579
|
+
*/
|
|
9580
|
+
isBillingError() {
|
|
9581
|
+
return this.code.startsWith("billing:");
|
|
9582
|
+
}
|
|
9583
|
+
/**
|
|
9584
|
+
* Check if this is a server error
|
|
9585
|
+
*/
|
|
9586
|
+
isServerError() {
|
|
9587
|
+
return this.code.startsWith("server:");
|
|
9588
|
+
}
|
|
9589
|
+
/**
|
|
9590
|
+
* Returns a human-readable string representation of the error.
|
|
9591
|
+
* Includes all key details for debugging.
|
|
9592
|
+
*
|
|
9593
|
+
* @example
|
|
9594
|
+
* "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
|
|
9595
|
+
*/
|
|
9596
|
+
toString() {
|
|
9597
|
+
const parts = [`RiverbankApiError: ${this.message}`];
|
|
9598
|
+
if (this.code) parts.push(`Code: ${this.code}`);
|
|
9599
|
+
if (this.status) parts.push(`Status: ${this.status}`);
|
|
9600
|
+
if (this.requestId) parts.push(`RequestId: ${this.requestId}`);
|
|
9601
|
+
return parts.join(" | ");
|
|
9602
|
+
}
|
|
9603
|
+
/**
|
|
9604
|
+
* Custom Node.js inspect output for better console.log display.
|
|
9605
|
+
* This ensures that console.log(error) shows all relevant details
|
|
9606
|
+
* instead of just "[Object]" for nested properties.
|
|
9607
|
+
*/
|
|
9608
|
+
[_Symbol$for]() {
|
|
9609
|
+
return this.toDetailedString();
|
|
9610
|
+
}
|
|
9611
|
+
/**
|
|
9612
|
+
* Returns a detailed multi-line string for debugging.
|
|
9613
|
+
* Used by the Node.js inspect symbol for console output.
|
|
9614
|
+
*/
|
|
9615
|
+
toDetailedString() {
|
|
9616
|
+
const lines = [
|
|
9617
|
+
`RiverbankApiError: ${this.message}`,
|
|
9618
|
+
` Code: ${this.code}`,
|
|
9619
|
+
` Status: ${this.status}`,
|
|
9620
|
+
` RequestId: ${this.requestId}`,
|
|
9621
|
+
` Timestamp: ${this.timestamp}`
|
|
9622
|
+
];
|
|
9623
|
+
if (this.isRetryable) {
|
|
9624
|
+
lines.push(` Retryable: true`);
|
|
9625
|
+
if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
|
|
9626
|
+
}
|
|
9627
|
+
if (this.fieldErrors && this.fieldErrors.length > 0) {
|
|
9628
|
+
lines.push(" FieldErrors:");
|
|
9629
|
+
this.fieldErrors.forEach((fe) => {
|
|
9630
|
+
lines.push(` - ${fe.field}: ${fe.message}`);
|
|
9631
|
+
});
|
|
9632
|
+
}
|
|
9633
|
+
return lines.join("\n");
|
|
9634
|
+
}
|
|
9635
|
+
};
|
|
9636
|
+
const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
|
|
9637
|
+
function attachResilienceStatusToError(error, resilienceStatus) {
|
|
9638
|
+
const target = error !== null && (typeof error === "object" || typeof error === "function") ? error : new Error(typeof error === "string" || typeof error === "number" || typeof error === "boolean" || typeof error === "bigint" ? String(error) : "Unknown error");
|
|
9639
|
+
Object.defineProperty(target, resilienceStatusSymbol, {
|
|
9640
|
+
configurable: true,
|
|
9641
|
+
enumerable: false,
|
|
9642
|
+
value: resilienceStatus
|
|
9643
|
+
});
|
|
9644
|
+
return target;
|
|
9645
|
+
}
|
|
9646
|
+
function getResilienceStatusFromError(error) {
|
|
9647
|
+
if (error === null || typeof error !== "object" && typeof error !== "function") return;
|
|
9648
|
+
return error[resilienceStatusSymbol];
|
|
9649
|
+
}
|
|
9650
|
+
//#endregion
|
|
9651
|
+
//#region src/client/resilience.ts
|
|
9652
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
9653
|
+
maxAttempts: 3,
|
|
9654
|
+
baseDelayMs: 200,
|
|
9655
|
+
maxDelayMs: 2e3,
|
|
9656
|
+
jitter: "full"
|
|
9657
|
+
};
|
|
9658
|
+
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
9659
|
+
failureThreshold: 5,
|
|
9660
|
+
resetTimeoutMs: 3e4,
|
|
9661
|
+
halfOpenMaxRequests: 2
|
|
9662
|
+
};
|
|
9663
|
+
/**
|
|
9664
|
+
* Error codes that indicate permanent infrastructure failures.
|
|
9665
|
+
* These should NOT be retried as the server is definitively unreachable.
|
|
9666
|
+
*/
|
|
9667
|
+
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9668
|
+
"ECONNREFUSED",
|
|
9669
|
+
"ENOTFOUND",
|
|
9670
|
+
"EAI_AGAIN"
|
|
9671
|
+
]);
|
|
9672
|
+
/**
|
|
9673
|
+
* Error codes that indicate transient network issues.
|
|
9674
|
+
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
9675
|
+
*/
|
|
9676
|
+
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9677
|
+
"ECONNRESET",
|
|
9678
|
+
"EPIPE",
|
|
9679
|
+
"ETIMEDOUT",
|
|
9680
|
+
"ESOCKETTIMEDOUT"
|
|
9681
|
+
]);
|
|
9682
|
+
/**
|
|
9683
|
+
* Node.js network error codes (POSIX style).
|
|
9684
|
+
* These are the codes we're looking for in the cause chain.
|
|
9685
|
+
*/
|
|
9686
|
+
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
9687
|
+
"ECONNREFUSED",
|
|
9688
|
+
"ENOTFOUND",
|
|
9689
|
+
"EAI_AGAIN",
|
|
9690
|
+
"ECONNRESET",
|
|
9691
|
+
"EPIPE",
|
|
9692
|
+
"ETIMEDOUT",
|
|
9693
|
+
"ESOCKETTIMEDOUT"
|
|
9694
|
+
]);
|
|
9695
|
+
/**
|
|
9696
|
+
* Check if a string is a Node.js network error code (not an API error code).
|
|
9697
|
+
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
9698
|
+
*/
|
|
9699
|
+
function isNodeNetworkErrorCode(code) {
|
|
9700
|
+
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
9701
|
+
}
|
|
9702
|
+
/**
|
|
9703
|
+
* Extract the Node.js error code from an error's cause chain.
|
|
9704
|
+
* Handles nested cause chains like:
|
|
9705
|
+
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
9706
|
+
*
|
|
9707
|
+
* Skips API error codes (like 'network:connection_error') and only returns
|
|
9708
|
+
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
9709
|
+
*
|
|
9710
|
+
* @example
|
|
9711
|
+
* RiverbankApiError: Network request failed
|
|
9712
|
+
* [cause]: TypeError: fetch failed
|
|
9713
|
+
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
9714
|
+
* code: 'ECONNREFUSED'
|
|
9715
|
+
*/
|
|
9716
|
+
function getErrorCodeFromCause(error) {
|
|
9717
|
+
let current = error;
|
|
9718
|
+
while (current) {
|
|
9719
|
+
const nodeError = current;
|
|
9720
|
+
if (nodeError.code && typeof nodeError.code === "string") {
|
|
9721
|
+
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
9722
|
+
}
|
|
9723
|
+
current = current.cause;
|
|
9724
|
+
}
|
|
9725
|
+
}
|
|
9726
|
+
/**
|
|
9727
|
+
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
9728
|
+
*
|
|
9729
|
+
* Transient (opens circuit, triggers retry):
|
|
9730
|
+
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
9731
|
+
* - 5xx server errors
|
|
9732
|
+
* - 429 rate limit
|
|
9733
|
+
* - Connection reset, broken pipe, timeout
|
|
9734
|
+
*
|
|
9735
|
+
* Permanent (does NOT open circuit, no retry):
|
|
9736
|
+
* - 4xx client errors (400, 401, 403, 404)
|
|
9737
|
+
* - Validation errors
|
|
9738
|
+
* - ECONNREFUSED (server not running)
|
|
9739
|
+
* - ENOTFOUND (DNS failure)
|
|
9740
|
+
*/
|
|
9741
|
+
function isTransientError(error) {
|
|
9742
|
+
if (error instanceof RiverbankApiError) {
|
|
9743
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
9744
|
+
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
9745
|
+
if (error.status === 0) return true;
|
|
9746
|
+
if (error.status === 429) return true;
|
|
9747
|
+
if (error.status >= 500) return true;
|
|
9748
|
+
return false;
|
|
9749
|
+
}
|
|
9750
|
+
if (error instanceof TypeError) {
|
|
9751
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
9752
|
+
if (errorCode) {
|
|
9753
|
+
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
9754
|
+
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
9755
|
+
}
|
|
9756
|
+
return true;
|
|
9757
|
+
}
|
|
9758
|
+
return true;
|
|
9759
|
+
}
|
|
9760
|
+
/**
|
|
9761
|
+
* Calculate backoff delay for retry attempt
|
|
9762
|
+
*
|
|
9763
|
+
* Uses exponential backoff with optional full jitter.
|
|
9764
|
+
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
9765
|
+
*/
|
|
9766
|
+
function calculateBackoff(attempt, config) {
|
|
9767
|
+
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
9768
|
+
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
9769
|
+
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
9770
|
+
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
9771
|
+
const capped = Math.min(exponential, maxDelayMs);
|
|
9772
|
+
if (jitter === "full") return Math.random() * capped;
|
|
9773
|
+
return capped;
|
|
9774
|
+
}
|
|
9775
|
+
/**
|
|
9776
|
+
* Circuit breaker for fail-fast behavior
|
|
9777
|
+
*
|
|
9778
|
+
* States:
|
|
9779
|
+
* - closed: Normal operation, requests allowed
|
|
9780
|
+
* - open: Too many failures, requests blocked
|
|
9781
|
+
* - half-open: Testing if service recovered, limited requests allowed
|
|
9782
|
+
*/
|
|
9783
|
+
var CircuitBreaker = class {
|
|
9784
|
+
constructor(config) {
|
|
9785
|
+
this.state = "closed";
|
|
9786
|
+
this.failureCount = 0;
|
|
9787
|
+
this.successCount = 0;
|
|
9788
|
+
this.openUntil = 0;
|
|
9789
|
+
this.halfOpenRequests = 0;
|
|
9790
|
+
this.config = {
|
|
9791
|
+
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
9792
|
+
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
9793
|
+
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
9794
|
+
};
|
|
9795
|
+
}
|
|
9796
|
+
/**
|
|
9797
|
+
* Check if circuit is open (requests should be blocked)
|
|
9798
|
+
* Also handles automatic transition from open to half-open after timeout
|
|
9799
|
+
*/
|
|
9800
|
+
isOpen() {
|
|
9801
|
+
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
9802
|
+
return this.state === "open";
|
|
9803
|
+
}
|
|
9804
|
+
/**
|
|
9805
|
+
* Check if a request can be attempted
|
|
9806
|
+
* - closed: always yes
|
|
9807
|
+
* - open: always no
|
|
9808
|
+
* - half-open: limited number of probes
|
|
9809
|
+
*/
|
|
9810
|
+
canAttempt() {
|
|
9811
|
+
if (this.state === "closed") return true;
|
|
9812
|
+
if (this.state === "open") return false;
|
|
9813
|
+
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
9814
|
+
}
|
|
9815
|
+
/**
|
|
9816
|
+
* Increment half-open request counter (call before making request in half-open)
|
|
9817
|
+
*/
|
|
9818
|
+
incrementHalfOpenRequests() {
|
|
9819
|
+
if (this.state === "half-open") this.halfOpenRequests++;
|
|
9820
|
+
}
|
|
9821
|
+
/**
|
|
9822
|
+
* Record a successful request
|
|
9823
|
+
*/
|
|
9824
|
+
recordSuccess() {
|
|
9825
|
+
if (this.state === "half-open") {
|
|
9826
|
+
this.successCount++;
|
|
9827
|
+
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
9828
|
+
} else this.failureCount = 0;
|
|
9829
|
+
}
|
|
9830
|
+
/**
|
|
9831
|
+
* Record a failed request
|
|
9832
|
+
* Only counts transient failures toward circuit breaker threshold
|
|
9833
|
+
*/
|
|
9834
|
+
recordFailure(error) {
|
|
9835
|
+
if (!isTransientError(error)) return;
|
|
9836
|
+
this.failureCount++;
|
|
9837
|
+
if (this.state === "half-open") this.transitionTo("open");
|
|
9838
|
+
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
9839
|
+
}
|
|
9840
|
+
/**
|
|
9841
|
+
* Get current circuit state
|
|
9842
|
+
*/
|
|
9843
|
+
getState() {
|
|
9844
|
+
return {
|
|
9845
|
+
state: this.state,
|
|
9846
|
+
failureCount: this.failureCount,
|
|
9847
|
+
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
9848
|
+
};
|
|
9849
|
+
}
|
|
9850
|
+
/**
|
|
9851
|
+
* Transition to a new state
|
|
9852
|
+
*/
|
|
9853
|
+
transitionTo(newState) {
|
|
9854
|
+
this.state = newState;
|
|
9855
|
+
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
9856
|
+
else if (newState === "half-open") {
|
|
9857
|
+
this.halfOpenRequests = 0;
|
|
9858
|
+
this.successCount = 0;
|
|
9859
|
+
} else if (newState === "closed") {
|
|
9860
|
+
this.failureCount = 0;
|
|
9861
|
+
this.successCount = 0;
|
|
9862
|
+
this.halfOpenRequests = 0;
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
};
|
|
9866
|
+
/**
|
|
9867
|
+
* Fetch with timeout and retry logic
|
|
9868
|
+
*
|
|
9869
|
+
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
9870
|
+
* @param config - Retry configuration
|
|
9871
|
+
* @returns Result from successful fetch
|
|
9872
|
+
* @throws Last error after all retries exhausted
|
|
9873
|
+
*/
|
|
9874
|
+
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
9875
|
+
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
9876
|
+
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
9877
|
+
let lastError;
|
|
9878
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
9879
|
+
const controller = new AbortController();
|
|
9880
|
+
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
9881
|
+
try {
|
|
9882
|
+
return await fetcher(controller.signal);
|
|
9883
|
+
} finally {
|
|
9884
|
+
clearTimeout(timeoutId);
|
|
9885
|
+
}
|
|
9886
|
+
} catch (error) {
|
|
9887
|
+
lastError = error;
|
|
9888
|
+
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
9889
|
+
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
9890
|
+
}
|
|
9891
|
+
throw lastError;
|
|
9892
|
+
}
|
|
9893
|
+
/**
|
|
9894
|
+
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
9895
|
+
*/
|
|
9896
|
+
function isAbortError$1(error) {
|
|
9897
|
+
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
9898
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
9899
|
+
return false;
|
|
9900
|
+
}
|
|
9901
|
+
/**
|
|
9902
|
+
* Check if an error should be retried
|
|
9903
|
+
*/
|
|
9904
|
+
function shouldRetryError(error, customRetryOn) {
|
|
9905
|
+
if (isAbortError$1(error)) return false;
|
|
9906
|
+
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
9907
|
+
return isTransientError(error);
|
|
9908
|
+
}
|
|
9909
|
+
/**
|
|
9910
|
+
* Get delay before retrying, respecting Retry-After if present
|
|
9911
|
+
*/
|
|
9912
|
+
function getRetryDelay(error, attempt, config) {
|
|
9913
|
+
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
9914
|
+
return calculateBackoff(attempt, config);
|
|
9915
|
+
}
|
|
9916
|
+
/**
|
|
9917
|
+
* Sleep for specified milliseconds
|
|
9918
|
+
*/
|
|
9919
|
+
function sleep(ms) {
|
|
9920
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9921
|
+
}
|
|
9922
|
+
/**
|
|
9923
|
+
* Error thrown when circuit breaker is open
|
|
9924
|
+
*/
|
|
9925
|
+
var CircuitOpenError = class extends Error {
|
|
9926
|
+
constructor(state) {
|
|
9927
|
+
super("Circuit breaker is open");
|
|
9928
|
+
this.name = "CircuitOpenError";
|
|
9929
|
+
this.circuitState = state;
|
|
9930
|
+
}
|
|
9931
|
+
};
|
|
9932
|
+
//#endregion
|
|
9933
|
+
//#region src/client/entryListReadRequest.ts
|
|
9934
|
+
const entryOrder = {
|
|
9935
|
+
newest: "published_at.desc",
|
|
9936
|
+
oldest: "published_at.asc",
|
|
9937
|
+
title: "title.asc",
|
|
9938
|
+
manual: "manual.asc"
|
|
9939
|
+
};
|
|
9940
|
+
function entrySelection(input) {
|
|
9941
|
+
return input.mode === "manual" && input.entryIds?.length ? {
|
|
9942
|
+
keyPart: input.entryIds.join(","),
|
|
9943
|
+
params: {
|
|
9944
|
+
mode: "manual",
|
|
9945
|
+
entryIds: JSON.stringify(input.entryIds)
|
|
9946
|
+
}
|
|
9947
|
+
} : {
|
|
9948
|
+
keyPart: "",
|
|
9949
|
+
params: {}
|
|
9950
|
+
};
|
|
9951
|
+
}
|
|
9952
|
+
function entryListMemoryKey(input, selection) {
|
|
9953
|
+
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
9954
|
+
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
9955
|
+
}
|
|
9956
|
+
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
9957
|
+
function buildEntryListReadRequest(input) {
|
|
9958
|
+
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
9959
|
+
const selection = entrySelection(input);
|
|
9960
|
+
const orderParam = order ? entryOrder[order] : void 0;
|
|
9961
|
+
return {
|
|
9962
|
+
cacheKey: entryListMemoryKey(input, selection),
|
|
9963
|
+
params: {
|
|
9964
|
+
siteId,
|
|
9965
|
+
type: contentType,
|
|
9966
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
9967
|
+
...typeof offset === "number" && { offset: String(offset) },
|
|
9968
|
+
...includeMeta && { meta: "true" },
|
|
9969
|
+
...orderParam && { order: orderParam },
|
|
9970
|
+
...preview && { stage: "preview" },
|
|
9971
|
+
...selection.params
|
|
9972
|
+
}
|
|
9973
|
+
};
|
|
9974
|
+
}
|
|
9975
|
+
//#endregion
|
|
9976
|
+
//#region src/client/cache.ts
|
|
9977
|
+
var SimpleCache = class {
|
|
9978
|
+
constructor(options = {}) {
|
|
9979
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
9980
|
+
this.maxSize = options.maxSize ?? 100;
|
|
9981
|
+
this.ttl = options.ttl ?? 3e5;
|
|
9982
|
+
this.staleTtl = options.staleTtl ?? 3e5;
|
|
9983
|
+
}
|
|
9984
|
+
/**
|
|
9985
|
+
* Get a fresh value (within TTL)
|
|
9986
|
+
* @returns The value if fresh, null otherwise
|
|
9987
|
+
*/
|
|
9988
|
+
getFresh(key) {
|
|
9989
|
+
const entry = this.cache.get(key);
|
|
9990
|
+
if (!entry) return null;
|
|
9991
|
+
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
9992
|
+
return null;
|
|
9993
|
+
}
|
|
9994
|
+
/**
|
|
9995
|
+
* Get a value that may be stale (past TTL but within staleTtl)
|
|
9996
|
+
* @returns Object with value and stale age, or null if expired
|
|
9997
|
+
*/
|
|
9998
|
+
getStale(key) {
|
|
9999
|
+
const entry = this.cache.get(key);
|
|
10000
|
+
if (!entry) return null;
|
|
10001
|
+
const now = Date.now();
|
|
10002
|
+
if (now > entry.staleUntil) {
|
|
10003
|
+
this.cache.delete(key);
|
|
10004
|
+
return null;
|
|
10005
|
+
}
|
|
10006
|
+
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
10007
|
+
return {
|
|
10008
|
+
value: entry.value,
|
|
10009
|
+
staleAgeSec
|
|
10010
|
+
};
|
|
10011
|
+
}
|
|
10012
|
+
/**
|
|
10013
|
+
* Store a value with TTL and stale window
|
|
10014
|
+
*/
|
|
10015
|
+
set(key, value, options) {
|
|
10016
|
+
const ttl = options?.ttl ?? this.ttl;
|
|
10017
|
+
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
10018
|
+
const now = Date.now();
|
|
10019
|
+
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
10020
|
+
this.cache.set(key, {
|
|
10021
|
+
value,
|
|
10022
|
+
tags: options?.tags ?? [],
|
|
10023
|
+
createdAt: now,
|
|
10024
|
+
freshUntil: now + ttl,
|
|
10025
|
+
staleUntil: now + ttl + staleTtl
|
|
10026
|
+
});
|
|
10027
|
+
}
|
|
10028
|
+
/**
|
|
10029
|
+
* Evict one entry to make room for a new one
|
|
10030
|
+
* Priority: oldest stale entry, then oldest fresh entry
|
|
10031
|
+
*/
|
|
10032
|
+
evictOne(now) {
|
|
10033
|
+
let oldestStaleKey = null;
|
|
10034
|
+
let oldestStaleTime = Infinity;
|
|
10035
|
+
let oldestFreshKey = null;
|
|
10036
|
+
let oldestFreshTime = Infinity;
|
|
10037
|
+
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
10038
|
+
if (entry.createdAt < oldestStaleTime) {
|
|
10039
|
+
oldestStaleTime = entry.createdAt;
|
|
10040
|
+
oldestStaleKey = key;
|
|
10041
|
+
}
|
|
10042
|
+
} else if (entry.createdAt < oldestFreshTime) {
|
|
10043
|
+
oldestFreshTime = entry.createdAt;
|
|
10044
|
+
oldestFreshKey = key;
|
|
10045
|
+
}
|
|
10046
|
+
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
10047
|
+
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
10048
|
+
}
|
|
10049
|
+
/**
|
|
10050
|
+
* Remove all fully expired entries (past staleUntil)
|
|
10051
|
+
*/
|
|
10052
|
+
prune() {
|
|
10053
|
+
const now = Date.now();
|
|
10054
|
+
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
10055
|
+
}
|
|
10056
|
+
/**
|
|
10057
|
+
* Clear all entries
|
|
10058
|
+
*/
|
|
10059
|
+
clearForTags(tags) {
|
|
10060
|
+
if (tags.includes("riverbank")) {
|
|
10061
|
+
this.clear();
|
|
10062
|
+
return;
|
|
10063
|
+
}
|
|
10064
|
+
const selected = new Set(tags);
|
|
10065
|
+
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
10066
|
+
}
|
|
10067
|
+
clear() {
|
|
10068
|
+
this.cache.clear();
|
|
10069
|
+
}
|
|
10070
|
+
/**
|
|
10071
|
+
* Check if a key exists and is not fully expired
|
|
10072
|
+
*/
|
|
10073
|
+
has(key) {
|
|
10074
|
+
const entry = this.cache.get(key);
|
|
10075
|
+
if (!entry) return false;
|
|
10076
|
+
const now = Date.now();
|
|
10077
|
+
if (now > entry.staleUntil) {
|
|
10078
|
+
this.cache.delete(key);
|
|
10079
|
+
return false;
|
|
10080
|
+
}
|
|
10081
|
+
return now <= entry.freshUntil;
|
|
10082
|
+
}
|
|
10083
|
+
};
|
|
10084
|
+
//#endregion
|
|
10085
|
+
//#region src/request-options.ts
|
|
10086
|
+
/** Every API client the SDK creates sends its version as `x-sdk-version`. */
|
|
10087
|
+
const sdkRequestOptions = { sdkVersion: SDK_VERSION };
|
|
10088
|
+
//#endregion
|
|
10089
|
+
//#region src/public-api/runtime.ts
|
|
10090
|
+
const PUBLIC_ENDPOINT_NAMES = [
|
|
10091
|
+
"getSite",
|
|
10092
|
+
"getContentByPath",
|
|
10093
|
+
"resolveRouteOutcome",
|
|
10094
|
+
"resolveRouteDecision",
|
|
10095
|
+
"listPublishedEntries",
|
|
10096
|
+
"getPublishedEntryPreview",
|
|
10097
|
+
"getPublicFormById",
|
|
10098
|
+
"listPublicForms",
|
|
10099
|
+
"getPublicBookingServices",
|
|
10100
|
+
"getPublicWeeklySlotAvailability",
|
|
10101
|
+
"getPublicChallenge",
|
|
10102
|
+
"listPublicEvents",
|
|
10103
|
+
"batchBlockLoaders",
|
|
10104
|
+
"listPublicTeamMembers",
|
|
10105
|
+
"listPublicProducts",
|
|
10106
|
+
"listPublicPasses",
|
|
10107
|
+
"listPublicMemberships",
|
|
10108
|
+
"resolveEventSubroute",
|
|
10109
|
+
"checkRedirect",
|
|
10110
|
+
"getRoutableContent",
|
|
10111
|
+
"getPublicRoutableContent",
|
|
10112
|
+
"getPublicSitemapRoutes"
|
|
10113
|
+
];
|
|
10114
|
+
const API_ENDPOINTS = Object.freeze({
|
|
10115
|
+
getSite: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getSite),
|
|
10116
|
+
getRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getRoutableContent),
|
|
10117
|
+
getPublicRoutableContent: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicRoutableContent),
|
|
10118
|
+
getPublicSitemapRoutes: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.getPublicSitemapRoutes),
|
|
10119
|
+
getContentByPath: {
|
|
10120
|
+
path: "/sites/{siteId}/pages",
|
|
10121
|
+
method: "GET",
|
|
10122
|
+
tags: [TAG_TEMPLATES.siteRoutableContent],
|
|
10123
|
+
auth: "public",
|
|
10124
|
+
responseKind: "json"
|
|
10125
|
+
},
|
|
10126
|
+
resolveRouteOutcome: {
|
|
10127
|
+
path: "/sites/{siteId}/route-outcome",
|
|
10128
|
+
method: "GET",
|
|
10129
|
+
tags: [
|
|
10130
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
10131
|
+
TAG_TEMPLATES.siteRedirects,
|
|
10132
|
+
TAG_TEMPLATES.siteRouteOutcomes
|
|
10133
|
+
],
|
|
10134
|
+
auth: "public",
|
|
10135
|
+
responseKind: "json"
|
|
10136
|
+
},
|
|
10137
|
+
resolveRouteDecision: {
|
|
10138
|
+
path: "/sites/{siteId}/route-decision",
|
|
10139
|
+
method: "GET",
|
|
10140
|
+
tags: [
|
|
10141
|
+
TAG_TEMPLATES.siteRoutableContent,
|
|
10142
|
+
TAG_TEMPLATES.siteRedirects,
|
|
10143
|
+
TAG_TEMPLATES.siteRouteOutcomes
|
|
10144
|
+
],
|
|
10145
|
+
auth: "public",
|
|
10146
|
+
responseKind: "json"
|
|
10147
|
+
},
|
|
10148
|
+
listPublishedEntries: {
|
|
10149
|
+
path: "/public/content/{siteId}/{type}/entries",
|
|
10150
|
+
method: "GET",
|
|
10151
|
+
revalidate: publicReadFreshnessSeconds("listPublishedEntries"),
|
|
10152
|
+
tags: ["content-{siteId}-{type}"],
|
|
10153
|
+
auth: "public",
|
|
10154
|
+
responseKind: "json"
|
|
10155
|
+
},
|
|
10156
|
+
getPublishedEntryPreview: {
|
|
10157
|
+
path: "/public/content/{siteId}/{type}/{slug}/preview",
|
|
10158
|
+
method: "GET",
|
|
10159
|
+
revalidate: publicReadFreshnessSeconds("getPublishedEntryPreview"),
|
|
10160
|
+
tags: ["content-{siteId}-{type}-{slug}"],
|
|
10161
|
+
auth: "public",
|
|
10162
|
+
responseKind: "json"
|
|
10163
|
+
},
|
|
10164
|
+
getPublicFormById: {
|
|
10165
|
+
path: "/public/forms/{formId}",
|
|
10166
|
+
method: "GET",
|
|
10167
|
+
revalidate: publicReadFreshnessSeconds("getPublicFormById"),
|
|
10168
|
+
tags: [TAG_TEMPLATES.formById],
|
|
10169
|
+
auth: "public",
|
|
10170
|
+
responseKind: "json"
|
|
10171
|
+
},
|
|
10172
|
+
listPublicForms: {
|
|
10173
|
+
path: "/public/sites/{siteId}/forms",
|
|
10174
|
+
method: "GET",
|
|
10175
|
+
revalidate: 60,
|
|
10176
|
+
tags: [TAG_TEMPLATES.siteForms],
|
|
10177
|
+
auth: "public",
|
|
10178
|
+
responseKind: "json"
|
|
10179
|
+
},
|
|
10180
|
+
getPublicBookingServices: {
|
|
10181
|
+
path: "/public/bookings/services",
|
|
10182
|
+
method: "GET",
|
|
10183
|
+
revalidate: publicReadFreshnessSeconds("getPublicBookingServices"),
|
|
10184
|
+
tags: [TAG_TEMPLATES.publicBookingServices],
|
|
10185
|
+
auth: "public",
|
|
10186
|
+
responseKind: "json"
|
|
10187
|
+
},
|
|
10188
|
+
getPublicWeeklySlotAvailability: {
|
|
10189
|
+
path: "/public/bookings/weekly-slot-availability",
|
|
10190
|
+
method: "GET",
|
|
10191
|
+
revalidate: publicReadFreshnessSeconds("getPublicWeeklySlotAvailability"),
|
|
10192
|
+
tags: [TAG_TEMPLATES.publicBookingAvailability, TAG_TEMPLATES.publicBookingServices],
|
|
10193
|
+
auth: "public",
|
|
10194
|
+
responseKind: "json"
|
|
10195
|
+
},
|
|
10196
|
+
getPublicChallenge: {
|
|
10197
|
+
path: "/public/challenge",
|
|
10198
|
+
method: "GET",
|
|
10199
|
+
auth: "public",
|
|
10200
|
+
responseKind: "text"
|
|
10201
|
+
},
|
|
10202
|
+
listPublicEvents: {
|
|
10203
|
+
path: "/public/sites/{siteId}/events",
|
|
10204
|
+
method: "GET",
|
|
10205
|
+
revalidate: publicReadFreshnessSeconds("listPublicEvents"),
|
|
10206
|
+
tags: [TAG_TEMPLATES.publicEvents],
|
|
10207
|
+
auth: "public",
|
|
10208
|
+
responseKind: "json"
|
|
10209
|
+
},
|
|
10210
|
+
batchBlockLoaders: {
|
|
10211
|
+
path: "/public/sites/{siteId}/block-loaders/batch",
|
|
10212
|
+
method: "POST",
|
|
10213
|
+
auth: "public",
|
|
10214
|
+
responseKind: "json"
|
|
10215
|
+
},
|
|
10216
|
+
listPublicTeamMembers: {
|
|
10217
|
+
path: "/public/sites/{siteId}/team-members",
|
|
10218
|
+
method: "GET",
|
|
10219
|
+
revalidate: publicReadFreshnessSeconds("listPublicTeamMembers"),
|
|
10220
|
+
tags: [TAG_TEMPLATES.publicTeamMembers],
|
|
10221
|
+
auth: "public",
|
|
10222
|
+
responseKind: "json"
|
|
10223
|
+
},
|
|
10224
|
+
listPublicProducts: {
|
|
10225
|
+
path: "/public/sites/{siteId}/products",
|
|
10226
|
+
method: "GET",
|
|
10227
|
+
revalidate: publicReadFreshnessSeconds("listPublicProducts"),
|
|
10228
|
+
tags: [TAG_TEMPLATES.publicProducts],
|
|
10229
|
+
auth: "public",
|
|
10230
|
+
responseKind: "json"
|
|
10231
|
+
},
|
|
10232
|
+
listPublicPasses: {
|
|
10233
|
+
path: "/public/sites/{siteId}/bookings/products/passes",
|
|
10234
|
+
method: "GET",
|
|
10235
|
+
revalidate: publicReadFreshnessSeconds("listPublicPasses"),
|
|
10236
|
+
tags: [TAG_TEMPLATES.publicPasses],
|
|
10237
|
+
auth: "public",
|
|
10238
|
+
responseKind: "json"
|
|
10239
|
+
},
|
|
10240
|
+
listPublicMemberships: {
|
|
10241
|
+
path: "/public/sites/{siteId}/bookings/products/memberships",
|
|
10242
|
+
method: "GET",
|
|
10243
|
+
revalidate: publicReadFreshnessSeconds("listPublicMemberships"),
|
|
10244
|
+
tags: [TAG_TEMPLATES.publicMemberships],
|
|
10245
|
+
auth: "public",
|
|
10246
|
+
responseKind: "json"
|
|
10247
|
+
},
|
|
10248
|
+
resolveEventSubroute: {
|
|
10249
|
+
path: "/public/sites/{siteId}/events/subroutes/resolve",
|
|
10250
|
+
method: "GET",
|
|
10251
|
+
revalidate: 60,
|
|
10252
|
+
tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
|
|
10253
|
+
auth: "public",
|
|
10254
|
+
responseKind: "json"
|
|
10255
|
+
},
|
|
10256
|
+
checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
|
|
10257
|
+
});
|
|
10258
|
+
function buildEndpointURL(baseURL, endpoint) {
|
|
10259
|
+
return baseURL + API_ENDPOINTS[endpoint].path;
|
|
10260
|
+
}
|
|
10261
|
+
function publicSiteReadDefinition(definition) {
|
|
10262
|
+
return {
|
|
10263
|
+
path: definition.path,
|
|
10264
|
+
method: definition.method,
|
|
10265
|
+
revalidate: definition.revalidate,
|
|
10266
|
+
tags: definition.tags,
|
|
10267
|
+
auth: definition.auth,
|
|
10268
|
+
responseKind: definition.responseKind
|
|
10269
|
+
};
|
|
10270
|
+
}
|
|
10271
|
+
//#endregion
|
|
10272
|
+
//#region src/client/runtimeCacheKeys.ts
|
|
10273
|
+
/**
|
|
10274
|
+
* Bump when a cached payload's shape changes incompatibly, so readers skip
|
|
10275
|
+
* entries written in the old shape until publish or a live success rewrites
|
|
10276
|
+
* them.
|
|
10277
|
+
*
|
|
10278
|
+
* - 4: owned surface inputs use the shared revision transport envelope (#1627).
|
|
10279
|
+
* - 3: hidden business-source maps and private locations are removed before public projection (#1611).
|
|
10280
|
+
* - 2: pages carry intent-only `runtimeJoins` in place of compiled
|
|
10281
|
+
* `runtimeBoundaries` (issue 1422).
|
|
10282
|
+
*/
|
|
10283
|
+
const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 4;
|
|
10284
|
+
function toNonEmptyString(value) {
|
|
10285
|
+
if (value === null || value === void 0) return null;
|
|
10286
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
|
|
10287
|
+
const normalized = String(value).trim();
|
|
10288
|
+
return normalized.length > 0 ? normalized : null;
|
|
10289
|
+
}
|
|
10290
|
+
function normalizeRuntimePublicPath(value) {
|
|
10291
|
+
const withoutQuery = (toNonEmptyString(value) ?? "/").split(/[?#]/, 1)[0] ?? "/";
|
|
10292
|
+
const collapsed = (withoutQuery.startsWith("/") ? withoutQuery : `/${withoutQuery}`).replace(/\/{2,}/g, "/");
|
|
10293
|
+
return (collapsed.length > 1 ? collapsed.replace(/\/+$/g, "") : collapsed) || "/";
|
|
10294
|
+
}
|
|
10295
|
+
function normalizeRuntimeHostname(value) {
|
|
10296
|
+
const trimmed = value.trim().toLowerCase();
|
|
10297
|
+
return (/^[a-z][a-z0-9+.-]*:\/\//.test(trimmed) ? new URL(trimmed) : new URL(`http://${trimmed}`)).hostname.replace(/\.$/, "");
|
|
10298
|
+
}
|
|
10299
|
+
function normalizeScalar(value) {
|
|
10300
|
+
return value.trim().toLowerCase();
|
|
10301
|
+
}
|
|
10302
|
+
function unsafeAsPublishedRuntimeCacheKey(value) {
|
|
10303
|
+
return value;
|
|
10304
|
+
}
|
|
10305
|
+
function buildPublishedRuntimeCacheKey(endpoint, normalizedParams) {
|
|
10306
|
+
return unsafeAsPublishedRuntimeCacheKey(`published-runtime:v1:${endpoint}:${Object.entries(normalizedParams).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join(":")}`);
|
|
10307
|
+
}
|
|
10308
|
+
function selectSiteRuntimeIdentity(params) {
|
|
10309
|
+
const slug = toNonEmptyString(params.slug);
|
|
10310
|
+
if (slug !== null) return { slug: normalizeScalar(slug) };
|
|
10311
|
+
const domain = toNonEmptyString(params.domain);
|
|
10312
|
+
if (domain !== null) return { domain: normalizeRuntimeHostname(domain) };
|
|
10313
|
+
const id = toNonEmptyString(params.id);
|
|
10314
|
+
if (id !== null) return { id: normalizeScalar(id) };
|
|
10315
|
+
return null;
|
|
10316
|
+
}
|
|
10317
|
+
function deriveGetSiteKey(params) {
|
|
10318
|
+
const identity = selectSiteRuntimeIdentity(params);
|
|
10319
|
+
if (identity === null) return {
|
|
10320
|
+
ok: false,
|
|
10321
|
+
error: {
|
|
10322
|
+
kind: "missing_site_identity",
|
|
10323
|
+
acceptedParams: [
|
|
10324
|
+
"slug",
|
|
10325
|
+
"domain",
|
|
10326
|
+
"id"
|
|
10327
|
+
]
|
|
10328
|
+
}
|
|
10329
|
+
};
|
|
10330
|
+
const normalizedParams = {
|
|
10331
|
+
...identity,
|
|
10332
|
+
currentPath: normalizeRuntimePublicPath(params.currentPath)
|
|
10333
|
+
};
|
|
10334
|
+
return {
|
|
10335
|
+
ok: true,
|
|
10336
|
+
endpoint: "getSite",
|
|
10337
|
+
key: buildPublishedRuntimeCacheKey("getSite", normalizedParams),
|
|
10338
|
+
normalizedParams
|
|
10339
|
+
};
|
|
10340
|
+
}
|
|
10341
|
+
function deriveGetContentByPathKey(params) {
|
|
10342
|
+
const siteId = toNonEmptyString(params.siteId);
|
|
10343
|
+
if (siteId === null) return {
|
|
10344
|
+
ok: false,
|
|
10345
|
+
error: {
|
|
10346
|
+
kind: "missing_required_param",
|
|
10347
|
+
endpoint: "getContentByPath",
|
|
10348
|
+
param: "siteId"
|
|
10349
|
+
}
|
|
10350
|
+
};
|
|
10351
|
+
const normalizedParams = {
|
|
10352
|
+
siteId: normalizeScalar(siteId),
|
|
10353
|
+
path: normalizeRuntimePublicPath(params.path),
|
|
10354
|
+
contentContract: "native"
|
|
10355
|
+
};
|
|
10356
|
+
return {
|
|
10357
|
+
ok: true,
|
|
10358
|
+
endpoint: "getContentByPath",
|
|
10359
|
+
key: buildPublishedRuntimeCacheKey("getContentByPath", normalizedParams),
|
|
10360
|
+
normalizedParams
|
|
10361
|
+
};
|
|
10362
|
+
}
|
|
10363
|
+
function deriveDurableRuntimeCacheKey(input) {
|
|
10364
|
+
switch (input.endpoint) {
|
|
10365
|
+
case "getSite": return deriveGetSiteKey(input.params);
|
|
10366
|
+
case "getContentByPath": return deriveGetContentByPathKey(input.params);
|
|
10367
|
+
}
|
|
10368
|
+
}
|
|
10369
|
+
function isPublishedRuntimeCacheKeyEndpoint(value) {
|
|
10370
|
+
return value === "getSite" || value === "getContentByPath";
|
|
10371
|
+
}
|
|
10372
|
+
function parsePublishedRuntimeCacheKey(value) {
|
|
10373
|
+
const details = parsePublishedRuntimeCacheKeyDetails(value);
|
|
10374
|
+
if (!details.ok) return details;
|
|
10375
|
+
return {
|
|
10376
|
+
ok: true,
|
|
10377
|
+
key: details.key,
|
|
10378
|
+
endpoint: details.endpoint
|
|
10379
|
+
};
|
|
10380
|
+
}
|
|
10381
|
+
function parsePublishedRuntimeCacheKeyDetails(value) {
|
|
10382
|
+
if (typeof value !== "string") return {
|
|
10383
|
+
ok: false,
|
|
10384
|
+
error: "not_string"
|
|
10385
|
+
};
|
|
10386
|
+
const parts = value.split(":");
|
|
10387
|
+
if (parts[0] !== "published-runtime" || parts[1] !== "v1") return {
|
|
10388
|
+
ok: false,
|
|
10389
|
+
error: "invalid_prefix"
|
|
10390
|
+
};
|
|
10391
|
+
const endpoint = parts[2];
|
|
10392
|
+
if (!isPublishedRuntimeCacheKeyEndpoint(endpoint)) return {
|
|
10393
|
+
ok: false,
|
|
10394
|
+
error: "unknown_endpoint"
|
|
10395
|
+
};
|
|
10396
|
+
const normalizedParams = {};
|
|
10397
|
+
for (const part of parts.slice(3)) {
|
|
10398
|
+
const separatorIndex = part.indexOf("=");
|
|
10399
|
+
if (separatorIndex <= 0) return {
|
|
10400
|
+
ok: false,
|
|
10401
|
+
error: "invalid_param_encoding"
|
|
10402
|
+
};
|
|
10403
|
+
try {
|
|
10404
|
+
const key = decodeURIComponent(part.slice(0, separatorIndex));
|
|
10405
|
+
normalizedParams[key] = decodeURIComponent(part.slice(separatorIndex + 1));
|
|
10406
|
+
} catch {
|
|
10407
|
+
return {
|
|
10408
|
+
ok: false,
|
|
10409
|
+
error: "invalid_param_encoding"
|
|
10410
|
+
};
|
|
10411
|
+
}
|
|
10412
|
+
}
|
|
10413
|
+
if (!hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams)) return {
|
|
10414
|
+
ok: false,
|
|
10415
|
+
error: "invalid_param_encoding"
|
|
10416
|
+
};
|
|
10417
|
+
return {
|
|
10418
|
+
ok: true,
|
|
10419
|
+
key: unsafeAsPublishedRuntimeCacheKey(value),
|
|
10420
|
+
endpoint,
|
|
10421
|
+
normalizedParams
|
|
10422
|
+
};
|
|
10423
|
+
}
|
|
10424
|
+
function hasExpectedPublishedRuntimeCacheKeyParams(endpoint, normalizedParams) {
|
|
10425
|
+
const keys = Object.keys(normalizedParams).sort();
|
|
10426
|
+
switch (endpoint) {
|
|
10427
|
+
case "getSite": return [
|
|
10428
|
+
"domain",
|
|
10429
|
+
"id",
|
|
10430
|
+
"slug"
|
|
10431
|
+
].filter((key) => normalizedParams[key] !== void 0).length === 1 && normalizedParams.currentPath !== void 0 && keys.every((key) => [
|
|
10432
|
+
"currentPath",
|
|
10433
|
+
"domain",
|
|
10434
|
+
"id",
|
|
10435
|
+
"slug"
|
|
10436
|
+
].includes(key));
|
|
10437
|
+
case "getContentByPath": return normalizedParams.path !== void 0 && normalizedParams.siteId !== void 0 && normalizedParams.contentContract === "native" && keys.every((key) => [
|
|
10438
|
+
"contentContract",
|
|
10439
|
+
"path",
|
|
10440
|
+
"siteId"
|
|
10441
|
+
].includes(key));
|
|
10442
|
+
}
|
|
10443
|
+
}
|
|
10444
|
+
function parsePublishedRuntimeCachePayloadSchemaVersion(value) {
|
|
10445
|
+
if (typeof value !== "number") return {
|
|
10446
|
+
ok: false,
|
|
10447
|
+
error: "not_number"
|
|
10448
|
+
};
|
|
10449
|
+
if (!Number.isInteger(value)) return {
|
|
10450
|
+
ok: false,
|
|
10451
|
+
error: "not_integer"
|
|
10452
|
+
};
|
|
10453
|
+
if (value <= 0) return {
|
|
10454
|
+
ok: false,
|
|
10455
|
+
error: "not_positive"
|
|
10456
|
+
};
|
|
10457
|
+
return {
|
|
10458
|
+
ok: true,
|
|
10459
|
+
value
|
|
10460
|
+
};
|
|
10461
|
+
}
|
|
10462
|
+
//#endregion
|
|
10463
|
+
//#region src/client/runtimeCachePolicy.ts
|
|
10464
|
+
const DEFAULT_STALE_TTL_SEC = 1440 * 60;
|
|
10465
|
+
const DEFAULT_MEMORY_TTL_SEC = 60;
|
|
10466
|
+
const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
|
|
10467
|
+
getSite: {
|
|
10468
|
+
kind: "durable-public-stale",
|
|
10469
|
+
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
10470
|
+
},
|
|
10471
|
+
getContentByPath: {
|
|
10472
|
+
kind: "durable-public-stale",
|
|
10473
|
+
staleTtlSec: DEFAULT_STALE_TTL_SEC
|
|
10474
|
+
},
|
|
10475
|
+
resolveRouteOutcome: {
|
|
10476
|
+
kind: "memory-only",
|
|
10477
|
+
reason: "durable_rollout_pending"
|
|
10478
|
+
},
|
|
10479
|
+
resolveRouteDecision: {
|
|
10480
|
+
kind: "memory-only",
|
|
10481
|
+
reason: "durable_rollout_pending"
|
|
10482
|
+
},
|
|
10483
|
+
listPublishedEntries: {
|
|
10484
|
+
kind: "memory-only",
|
|
10485
|
+
reason: "durable_rollout_pending"
|
|
10486
|
+
},
|
|
10487
|
+
getPublishedEntryPreview: {
|
|
10488
|
+
kind: "memory-only",
|
|
10489
|
+
reason: "durable_rollout_pending"
|
|
10490
|
+
},
|
|
10491
|
+
getPublicFormById: {
|
|
10492
|
+
kind: "memory-only",
|
|
10493
|
+
reason: "durable_rollout_pending"
|
|
10494
|
+
},
|
|
10495
|
+
listPublicForms: {
|
|
10496
|
+
kind: "memory-only",
|
|
10497
|
+
reason: "durable_rollout_pending"
|
|
10498
|
+
},
|
|
10499
|
+
getPublicBookingServices: {
|
|
10500
|
+
kind: "live-only",
|
|
10501
|
+
reason: "safety_sensitive_booking"
|
|
10502
|
+
},
|
|
10503
|
+
getPublicWeeklySlotAvailability: {
|
|
10504
|
+
kind: "live-only",
|
|
10505
|
+
reason: "safety_sensitive_booking"
|
|
10506
|
+
},
|
|
10507
|
+
getPublicChallenge: {
|
|
10508
|
+
kind: "live-only",
|
|
10509
|
+
reason: "challenge_endpoint"
|
|
10510
|
+
},
|
|
10511
|
+
listPublicEvents: {
|
|
10512
|
+
kind: "memory-only",
|
|
10513
|
+
reason: "durable_rollout_pending"
|
|
10514
|
+
},
|
|
10515
|
+
batchBlockLoaders: {
|
|
10516
|
+
kind: "live-only",
|
|
10517
|
+
reason: "opaque_batch_loader"
|
|
10518
|
+
},
|
|
10519
|
+
listPublicTeamMembers: {
|
|
10520
|
+
kind: "memory-only",
|
|
10521
|
+
reason: "durable_rollout_pending"
|
|
10522
|
+
},
|
|
10523
|
+
listPublicProducts: {
|
|
10524
|
+
kind: "memory-only",
|
|
10525
|
+
reason: "durable_rollout_pending"
|
|
10526
|
+
},
|
|
10527
|
+
listPublicPasses: {
|
|
10528
|
+
kind: "live-only",
|
|
10529
|
+
reason: "safety_sensitive_booking"
|
|
10530
|
+
},
|
|
10531
|
+
listPublicMemberships: {
|
|
10532
|
+
kind: "live-only",
|
|
10533
|
+
reason: "safety_sensitive_booking"
|
|
10534
|
+
},
|
|
10535
|
+
resolveEventSubroute: {
|
|
10536
|
+
kind: "memory-only",
|
|
10537
|
+
reason: "durable_rollout_pending"
|
|
10538
|
+
},
|
|
10539
|
+
checkRedirect: {
|
|
10540
|
+
kind: "memory-only",
|
|
10541
|
+
reason: "durable_rollout_pending"
|
|
10542
|
+
},
|
|
10543
|
+
getRoutableContent: {
|
|
10544
|
+
kind: "live-only",
|
|
10545
|
+
reason: "auth_required"
|
|
10546
|
+
},
|
|
10547
|
+
getPublicRoutableContent: {
|
|
10548
|
+
kind: "memory-only",
|
|
10549
|
+
reason: "durable_rollout_pending"
|
|
10550
|
+
},
|
|
10551
|
+
getPublicSitemapRoutes: {
|
|
10552
|
+
kind: "memory-only",
|
|
10553
|
+
reason: "durable_rollout_pending"
|
|
10554
|
+
}
|
|
10555
|
+
};
|
|
10556
|
+
const PUBLIC_ENDPOINT_NAME_SET = new Set(PUBLIC_ENDPOINT_NAMES);
|
|
10557
|
+
function isPublicEndpointName(endpoint) {
|
|
10558
|
+
return PUBLIC_ENDPOINT_NAME_SET.has(endpoint);
|
|
10559
|
+
}
|
|
10560
|
+
function isTruthyParam(value) {
|
|
10561
|
+
return value === true || value === "true" || value === 1 || value === "1";
|
|
10562
|
+
}
|
|
10563
|
+
function isPreviewRequest(endpoint, params) {
|
|
10564
|
+
if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
|
|
10565
|
+
if (endpoint === "listPublishedEntries" || endpoint === "resolveEventSubroute") return params.stage === "preview";
|
|
10566
|
+
return false;
|
|
10567
|
+
}
|
|
10568
|
+
function getEndpointFreshTtlSec(endpoint) {
|
|
10569
|
+
return API_ENDPOINTS[endpoint].revalidate ?? DEFAULT_MEMORY_TTL_SEC;
|
|
10570
|
+
}
|
|
10571
|
+
function assertNever(value) {
|
|
10572
|
+
throw new Error(`Unhandled runtime cache policy override: ${String(value)}`);
|
|
10573
|
+
}
|
|
10574
|
+
function resolveKnownEndpointPolicy(endpoint, params) {
|
|
10575
|
+
if (isPreviewRequest(endpoint, params)) return {
|
|
10576
|
+
kind: "live-only",
|
|
10577
|
+
endpoint,
|
|
10578
|
+
reason: "preview_request"
|
|
10579
|
+
};
|
|
10580
|
+
if (endpoint === "getSite" && isTruthyParam(params.force)) return {
|
|
10581
|
+
kind: "live-only",
|
|
10582
|
+
endpoint,
|
|
10583
|
+
reason: "force_refresh"
|
|
10584
|
+
};
|
|
10585
|
+
if (isSupportedLoaderEndpoint(endpoint) && getPublicReadCachePolicy(endpoint).kind === "live") return {
|
|
10586
|
+
kind: "live-only",
|
|
10587
|
+
endpoint,
|
|
10588
|
+
reason: "safety_sensitive_booking"
|
|
10589
|
+
};
|
|
10590
|
+
const override = RUNTIME_CACHE_DURABILITY_OVERRIDES[endpoint];
|
|
10591
|
+
if (override.kind === "live-only") return {
|
|
10592
|
+
kind: "live-only",
|
|
10593
|
+
endpoint,
|
|
10594
|
+
reason: override.reason
|
|
10595
|
+
};
|
|
10596
|
+
const endpointDefinition = API_ENDPOINTS[endpoint];
|
|
10597
|
+
if (endpointDefinition.method !== "GET") return {
|
|
10598
|
+
kind: "live-only",
|
|
10599
|
+
endpoint,
|
|
10600
|
+
reason: "non_get_request"
|
|
10601
|
+
};
|
|
10602
|
+
if (endpointDefinition.auth === "user") return {
|
|
10603
|
+
kind: "live-only",
|
|
10604
|
+
endpoint,
|
|
10605
|
+
reason: "auth_required"
|
|
10606
|
+
};
|
|
10607
|
+
switch (override.kind) {
|
|
10608
|
+
case "durable-public-stale": return {
|
|
10609
|
+
kind: "durable-public-stale",
|
|
10610
|
+
endpoint,
|
|
10611
|
+
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
10612
|
+
staleTtlSec: override.staleTtlSec
|
|
10613
|
+
};
|
|
10614
|
+
case "memory-only": return {
|
|
10615
|
+
kind: "memory-only",
|
|
10616
|
+
endpoint,
|
|
10617
|
+
freshTtlSec: getEndpointFreshTtlSec(endpoint),
|
|
10618
|
+
reason: override.reason
|
|
10619
|
+
};
|
|
10620
|
+
default: return assertNever(override);
|
|
10621
|
+
}
|
|
10622
|
+
}
|
|
10623
|
+
function resolveRuntimeCachePolicy(input) {
|
|
10624
|
+
if (input.method && input.method.toUpperCase() !== "GET") return {
|
|
10625
|
+
kind: "live-only",
|
|
10626
|
+
endpoint: input.endpoint,
|
|
10627
|
+
reason: "non_get_request"
|
|
10628
|
+
};
|
|
10629
|
+
if (!isPublicEndpointName(input.endpoint)) return {
|
|
10630
|
+
kind: "live-only",
|
|
10631
|
+
endpoint: input.endpoint,
|
|
10632
|
+
reason: "unknown_endpoint"
|
|
10633
|
+
};
|
|
10634
|
+
return resolveKnownEndpointPolicy(input.endpoint, input.params ?? {});
|
|
10635
|
+
}
|
|
10636
|
+
function classifyPublishedRuntimeCacheFreshness(input) {
|
|
10637
|
+
const freshUntilMs = Date.parse(input.freshUntil);
|
|
10638
|
+
const staleUntilMs = Date.parse(input.staleUntil);
|
|
10639
|
+
if (Number.isNaN(freshUntilMs)) return {
|
|
10640
|
+
kind: "invalid_timestamp",
|
|
10641
|
+
field: "freshUntil"
|
|
10642
|
+
};
|
|
10643
|
+
if (Number.isNaN(staleUntilMs)) return {
|
|
10644
|
+
kind: "invalid_timestamp",
|
|
10645
|
+
field: "staleUntil"
|
|
10646
|
+
};
|
|
10647
|
+
const nowMs = input.now.getTime();
|
|
10648
|
+
if (nowMs > staleUntilMs) return { kind: "expired" };
|
|
10649
|
+
if (nowMs <= freshUntilMs) return {
|
|
10650
|
+
kind: "fresh",
|
|
10651
|
+
staleAgeSec: 0
|
|
10652
|
+
};
|
|
10653
|
+
return {
|
|
10654
|
+
kind: "stale",
|
|
10655
|
+
staleAgeSec: Math.floor((nowMs - freshUntilMs) / 1e3)
|
|
10656
|
+
};
|
|
10657
|
+
}
|
|
10658
|
+
function derivePublishedRuntimeCacheKey(input) {
|
|
10659
|
+
const policy = resolveRuntimeCachePolicy({
|
|
10660
|
+
endpoint: input.endpoint,
|
|
10661
|
+
method: "GET",
|
|
10662
|
+
params: input.params
|
|
10663
|
+
});
|
|
10664
|
+
if (policy.kind !== "durable-public-stale") return {
|
|
10665
|
+
ok: false,
|
|
10666
|
+
error: {
|
|
10667
|
+
kind: "not_durable_eligible",
|
|
10668
|
+
policy
|
|
10669
|
+
}
|
|
10670
|
+
};
|
|
10671
|
+
return deriveDurableRuntimeCacheKey(input);
|
|
10672
|
+
}
|
|
10673
|
+
//#endregion
|
|
10674
|
+
//#region src/client/contentReadOperations.ts
|
|
10675
|
+
function planPublishedRuntimeCache(input) {
|
|
10676
|
+
const policy = resolveRuntimeCachePolicy({
|
|
10677
|
+
endpoint: input.endpoint,
|
|
10678
|
+
method: "GET",
|
|
10679
|
+
params: input.params
|
|
10680
|
+
});
|
|
10681
|
+
if (policy.kind !== "durable-public-stale") return null;
|
|
10682
|
+
const keyResult = derivePublishedRuntimeCacheKey(input);
|
|
10683
|
+
if (!keyResult.ok) return null;
|
|
10684
|
+
return {
|
|
10685
|
+
cacheKey: keyResult.key,
|
|
10686
|
+
endpoint: keyResult.endpoint,
|
|
10687
|
+
normalizedParams: keyResult.normalizedParams,
|
|
10688
|
+
freshTtlSec: policy.freshTtlSec,
|
|
10689
|
+
staleTtlSec: policy.staleTtlSec,
|
|
10690
|
+
siteId: input.siteId ?? null
|
|
10691
|
+
};
|
|
10692
|
+
}
|
|
10693
|
+
function siteApiParams(params) {
|
|
10694
|
+
return {
|
|
10695
|
+
...params.slug ? { slug: params.slug } : {},
|
|
10696
|
+
...params.domain ? { domain: params.domain } : {},
|
|
10697
|
+
...params.id ? { id: params.id } : {},
|
|
10698
|
+
...params.currentPath ? { currentPath: params.currentPath } : {},
|
|
10699
|
+
...params.force ? { force: "true" } : {}
|
|
10700
|
+
};
|
|
10701
|
+
}
|
|
10702
|
+
function siteReadIdentity(params) {
|
|
10703
|
+
const identifier = params.slug || params.domain || params.id;
|
|
10704
|
+
if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
|
|
10705
|
+
return identifier;
|
|
10706
|
+
}
|
|
10707
|
+
function planSiteRead(params) {
|
|
10708
|
+
const identifier = siteReadIdentity(params);
|
|
10709
|
+
const { slug, domain, id, currentPath, force } = params;
|
|
10710
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
10711
|
+
endpoint: "getSite",
|
|
10712
|
+
params: {
|
|
10713
|
+
slug,
|
|
10714
|
+
domain,
|
|
10715
|
+
id,
|
|
10716
|
+
currentPath,
|
|
10717
|
+
force
|
|
10718
|
+
}
|
|
10719
|
+
});
|
|
10720
|
+
return {
|
|
10721
|
+
publishedRuntimeCache,
|
|
10722
|
+
prebuildIdentifier: id || slug || domain,
|
|
10723
|
+
cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
|
|
10724
|
+
};
|
|
10725
|
+
}
|
|
10726
|
+
async function readSiteWithResilience(input, params) {
|
|
10727
|
+
const { slug, domain, id, signal, force } = params;
|
|
10728
|
+
const plan = planSiteRead(params);
|
|
10729
|
+
const prebuildId = plan.prebuildIdentifier;
|
|
10730
|
+
const prebuild = input.prebuildLoader;
|
|
10731
|
+
return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
|
|
10732
|
+
endpoint: "getSite",
|
|
10733
|
+
params: siteApiParams(params),
|
|
10734
|
+
options: {
|
|
10735
|
+
signal: requestSignal,
|
|
10736
|
+
...force ? { cache: "no-store" } : {}
|
|
10737
|
+
}
|
|
10738
|
+
}), {
|
|
10739
|
+
signal,
|
|
10740
|
+
force,
|
|
10741
|
+
publishedRuntimeCache: plan.publishedRuntimeCache,
|
|
10742
|
+
cacheTags: buildSiteReadTags({
|
|
10743
|
+
slug,
|
|
10744
|
+
domain,
|
|
10745
|
+
id
|
|
10746
|
+
}),
|
|
10747
|
+
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
10748
|
+
});
|
|
10749
|
+
}
|
|
10750
|
+
async function readPageWithResilience(input, params) {
|
|
10751
|
+
const { siteId, path, preview = false, signal } = params;
|
|
10752
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
10753
|
+
endpoint: "getContentByPath",
|
|
10754
|
+
params: {
|
|
10755
|
+
siteId,
|
|
10756
|
+
path,
|
|
10757
|
+
preview
|
|
10758
|
+
},
|
|
10759
|
+
siteId
|
|
10760
|
+
});
|
|
10761
|
+
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
10762
|
+
return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
10763
|
+
endpoint: "getContentByPath",
|
|
10764
|
+
params: {
|
|
10765
|
+
siteId,
|
|
10766
|
+
path,
|
|
10767
|
+
preview: String(preview)
|
|
10768
|
+
},
|
|
10769
|
+
options: { signal: requestSignal }
|
|
10770
|
+
}), {
|
|
10771
|
+
preview,
|
|
10772
|
+
signal,
|
|
10773
|
+
publishedRuntimeCache,
|
|
10774
|
+
cacheTags: buildSiteReadTags({ siteId }),
|
|
10775
|
+
prebuildFallback: void 0
|
|
10776
|
+
});
|
|
10777
|
+
}
|
|
10778
|
+
function createContentReadOperations(input) {
|
|
10779
|
+
return {
|
|
10780
|
+
getSiteWithResilience: (params) => readSiteWithResilience(input, params),
|
|
10781
|
+
getPageWithResilience: (params) => readPageWithResilience(input, params)
|
|
10782
|
+
};
|
|
10783
|
+
}
|
|
10784
|
+
//#endregion
|
|
10785
|
+
//#region src/client/publicAppointmentReadOperations.ts
|
|
10786
|
+
function createPublicAppointmentReadOperations(deps) {
|
|
10787
|
+
return {
|
|
10788
|
+
async getPublicBookingServices(params) {
|
|
10789
|
+
const { siteId, ids, signal } = params;
|
|
10790
|
+
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
10791
|
+
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
10792
|
+
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
10793
|
+
const apiParams = {
|
|
10794
|
+
siteId,
|
|
10795
|
+
...ids && { ids }
|
|
10796
|
+
};
|
|
10797
|
+
return await deps.apiClient({
|
|
10798
|
+
endpoint: "getPublicBookingServices",
|
|
10799
|
+
params: apiParams,
|
|
10800
|
+
options: { signal: requestSignal }
|
|
10801
|
+
});
|
|
10802
|
+
}, {
|
|
10803
|
+
signal,
|
|
10804
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
10805
|
+
});
|
|
10806
|
+
},
|
|
10807
|
+
async getPublicWeeklySlotAvailability(params) {
|
|
10808
|
+
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
10809
|
+
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
10810
|
+
const cacheKey = [
|
|
10811
|
+
"public-weekly-slot-availability",
|
|
10812
|
+
siteId,
|
|
10813
|
+
serviceId,
|
|
10814
|
+
resourceId ?? "",
|
|
10815
|
+
horizonWeeks ?? "",
|
|
10816
|
+
timezone ?? ""
|
|
10817
|
+
].join(":");
|
|
10818
|
+
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
10819
|
+
const apiParams = {
|
|
10820
|
+
siteId,
|
|
10821
|
+
serviceId,
|
|
10822
|
+
...resourceId && { resourceId },
|
|
10823
|
+
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
10824
|
+
...timezone && { timezone }
|
|
10825
|
+
};
|
|
10826
|
+
return await deps.apiClient({
|
|
10827
|
+
endpoint: "getPublicWeeklySlotAvailability",
|
|
10828
|
+
params: apiParams,
|
|
10829
|
+
options: { signal: requestSignal }
|
|
10830
|
+
});
|
|
10831
|
+
}, {
|
|
10832
|
+
signal,
|
|
10833
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
10834
|
+
});
|
|
10835
|
+
}
|
|
10836
|
+
};
|
|
10837
|
+
}
|
|
10838
|
+
//#endregion
|
|
10839
|
+
//#region src/client/publicEventReadOperations.ts
|
|
10840
|
+
function createPublicEventReadOperations(deps) {
|
|
10841
|
+
async function resolveEventSubroute(params, kind) {
|
|
10842
|
+
const { siteId, subject, segment, signal, preview = false } = params;
|
|
10843
|
+
if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
|
|
10844
|
+
const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
|
|
10845
|
+
return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
|
|
10846
|
+
endpoint: "resolveEventSubroute",
|
|
10847
|
+
params: {
|
|
10848
|
+
siteId,
|
|
10849
|
+
kind,
|
|
10850
|
+
subjectKind: subject.kind,
|
|
10851
|
+
subjectId,
|
|
10852
|
+
segment,
|
|
10853
|
+
stage: preview ? "preview" : "published"
|
|
10854
|
+
},
|
|
10855
|
+
options: { signal: requestSignal }
|
|
10856
|
+
}), {
|
|
10857
|
+
signal,
|
|
10858
|
+
preview,
|
|
10859
|
+
cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
|
|
10860
|
+
});
|
|
10861
|
+
}
|
|
10862
|
+
return {
|
|
10863
|
+
async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
10864
|
+
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
10865
|
+
endpoint: "listPublicEventCalendarWindow",
|
|
10866
|
+
params: {
|
|
10867
|
+
...params,
|
|
10868
|
+
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
10869
|
+
},
|
|
10870
|
+
options: { signal: requestSignal }
|
|
10871
|
+
}), {
|
|
10872
|
+
signal,
|
|
10873
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
10874
|
+
});
|
|
10875
|
+
},
|
|
10876
|
+
async resolveEventOccurrence(params) {
|
|
10877
|
+
const response = await resolveEventSubroute(params, "event-occurrence");
|
|
10878
|
+
return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
|
|
10879
|
+
},
|
|
10880
|
+
async resolveEventRun(params) {
|
|
10881
|
+
const response = await resolveEventSubroute(params, "event-run");
|
|
10882
|
+
return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
|
|
10883
|
+
}
|
|
10884
|
+
};
|
|
10885
|
+
}
|
|
10886
|
+
//#endregion
|
|
10887
|
+
//#region src/client/combineAbortSignals.ts
|
|
10888
|
+
/** Combine signals into one that aborts when any input aborts. */
|
|
10889
|
+
function combineAbortSignals(...signals) {
|
|
10890
|
+
const controller = new AbortController();
|
|
10891
|
+
for (const signal of signals) {
|
|
10892
|
+
if (signal.aborted) {
|
|
10893
|
+
controller.abort(signal.reason);
|
|
10894
|
+
break;
|
|
10895
|
+
}
|
|
10896
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
10897
|
+
}
|
|
10898
|
+
return controller.signal;
|
|
10899
|
+
}
|
|
10900
|
+
//#endregion
|
|
10901
|
+
//#region src/client/publicLoaderCacheAccess.ts
|
|
10902
|
+
function shouldWrite(cacheEnabled, force) {
|
|
10903
|
+
return cacheEnabled && !force;
|
|
10904
|
+
}
|
|
10905
|
+
/**
|
|
10906
|
+
* Applies the canonical block-loader freshness policy at the SDK fetch seam.
|
|
10907
|
+
*
|
|
10908
|
+
* Callers provide the endpoint identity, but do not opt into live behavior.
|
|
10909
|
+
* This makes a newly-live endpoint bypass memory and fallback caches without a
|
|
10910
|
+
* second method-level wiring change.
|
|
10911
|
+
*/
|
|
10912
|
+
function applyPublicLoaderCachePolicy(endpoint, options) {
|
|
10913
|
+
if (!isPublicReadEndpoint(endpoint) || getPublicReadCachePolicy(endpoint).kind !== "live") return options;
|
|
10914
|
+
return {
|
|
10915
|
+
...options,
|
|
10916
|
+
force: true
|
|
10917
|
+
};
|
|
10918
|
+
}
|
|
10919
|
+
//#endregion
|
|
10920
|
+
//#region src/client/index.ts
|
|
10921
|
+
let prebuildModule = null;
|
|
10922
|
+
function tryRequire(modulePath) {
|
|
10923
|
+
try {
|
|
10924
|
+
const req = new Function("return typeof require === \"function\" ? require : null")();
|
|
10925
|
+
return req ? req(modulePath) : null;
|
|
10926
|
+
} catch {
|
|
10927
|
+
return null;
|
|
10928
|
+
}
|
|
10929
|
+
}
|
|
10930
|
+
function isNodeRuntime() {
|
|
10931
|
+
if (typeof globalThis !== "object" || globalThis === null) return false;
|
|
10932
|
+
return typeof globalThis.process?.versions?.node === "string";
|
|
10933
|
+
}
|
|
10934
|
+
function getPrebuildModule() {
|
|
10935
|
+
if (prebuildModule !== null) return prebuildModule;
|
|
10936
|
+
if (!isNodeRuntime()) return null;
|
|
10937
|
+
try {
|
|
10938
|
+
prebuildModule = tryRequire("../prebuild/loader");
|
|
10939
|
+
return prebuildModule;
|
|
10940
|
+
} catch {
|
|
10941
|
+
return null;
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
function mergeDefaultHeaders(defaultHeaders, options) {
|
|
10945
|
+
if (!defaultHeaders || Object.keys(defaultHeaders).length === 0) return options;
|
|
10946
|
+
return {
|
|
10947
|
+
...options,
|
|
10948
|
+
headers: {
|
|
10949
|
+
...defaultHeaders,
|
|
10950
|
+
...Object.fromEntries(new Headers(options?.headers).entries())
|
|
10951
|
+
}
|
|
10952
|
+
};
|
|
10953
|
+
}
|
|
10954
|
+
function withDefaultHeaders(apiClient, defaultHeaders) {
|
|
10955
|
+
return async (params) => apiClient({
|
|
10956
|
+
...params,
|
|
10957
|
+
options: mergeDefaultHeaders(defaultHeaders, params.options)
|
|
10958
|
+
});
|
|
10959
|
+
}
|
|
10960
|
+
const DEFAULT_BROWSER_TIMEOUT_MS = 5e3;
|
|
10961
|
+
const DEFAULT_SERVER_TIMEOUT_MS = 8e3;
|
|
10962
|
+
const MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS = 50;
|
|
10963
|
+
function isDurableRuntimeCacheTier(cacheTier) {
|
|
10964
|
+
return cacheTier === "durable-fresh" || cacheTier === "durable-stale";
|
|
10965
|
+
}
|
|
10966
|
+
function isDegradedResilienceStatus(source, details) {
|
|
10967
|
+
return source === "stale" || source === "error" || isDurableRuntimeCacheTier(details.cacheTier) && details.error !== void 0;
|
|
10968
|
+
}
|
|
10969
|
+
/**
|
|
10970
|
+
* Generate a unique request ID for tracing
|
|
10971
|
+
*/
|
|
10972
|
+
function generateRequestId() {
|
|
10973
|
+
return `req-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
10974
|
+
}
|
|
10975
|
+
function toRecord(value) {
|
|
10976
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
10977
|
+
}
|
|
10978
|
+
function getRuntimePayloadSiteId(value) {
|
|
10979
|
+
const site = toRecord(value).site;
|
|
10980
|
+
if (!site || typeof site !== "object" || Array.isArray(site)) return null;
|
|
10981
|
+
const id = site.id;
|
|
10982
|
+
return typeof id === "string" && id.trim().length > 0 ? id : null;
|
|
10983
|
+
}
|
|
10984
|
+
function getRiverbankErrorInfo(error) {
|
|
10985
|
+
if (error instanceof RiverbankApiError) return {
|
|
10986
|
+
code: error.code,
|
|
10987
|
+
message: error.message,
|
|
10988
|
+
status: error.status
|
|
10989
|
+
};
|
|
10990
|
+
if (error instanceof Error) return { message: error.message };
|
|
10991
|
+
return { message: String(error) };
|
|
10992
|
+
}
|
|
10993
|
+
function normalizeEntryIdentifierRefs(identifiers) {
|
|
10994
|
+
const trimmed = identifiers.map((identifier) => identifier.trim()).filter((identifier) => identifier.length > 0);
|
|
10995
|
+
if (trimmed.length === 0) return { kind: "empty" };
|
|
10996
|
+
if (trimmed.length > MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS) throw new Error(`getEntriesByIdentifiers() accepts at most ${MAX_GET_ENTRIES_BY_IDENTIFIERS_REFS} identifiers`);
|
|
10997
|
+
const refs = [];
|
|
10998
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10999
|
+
for (const ref of trimmed) {
|
|
11000
|
+
if (seen.has(ref)) continue;
|
|
11001
|
+
seen.add(ref);
|
|
11002
|
+
refs.push(ref);
|
|
11003
|
+
}
|
|
11004
|
+
return {
|
|
11005
|
+
kind: "refs",
|
|
11006
|
+
refs
|
|
11007
|
+
};
|
|
11008
|
+
}
|
|
11009
|
+
function normalizePublicForm(form) {
|
|
11010
|
+
return {
|
|
11011
|
+
id: form.id,
|
|
11012
|
+
slug: form.slug,
|
|
11013
|
+
name: form.name,
|
|
11014
|
+
schema: toRecord(form.schemaJson),
|
|
11015
|
+
settings: toRecord(form.settingsJson),
|
|
11016
|
+
schemaJson: toRecord(form.schemaJson),
|
|
11017
|
+
settingsJson: toRecord(form.settingsJson),
|
|
11018
|
+
createdAt: form.createdAt ?? null,
|
|
11019
|
+
updatedAt: form.updatedAt ?? null,
|
|
11020
|
+
...form.siteId ? { siteId: form.siteId } : {},
|
|
11021
|
+
...form.userId ? { userId: form.userId } : {}
|
|
11022
|
+
};
|
|
11023
|
+
}
|
|
11024
|
+
function normalizePublicFormResponse(response) {
|
|
11025
|
+
return { form: response.form ? normalizePublicForm(response.form) : null };
|
|
11026
|
+
}
|
|
11027
|
+
function normalizePublicFormResult(result) {
|
|
11028
|
+
if (isApiError(result)) return result;
|
|
11029
|
+
return {
|
|
11030
|
+
...result,
|
|
11031
|
+
data: normalizePublicFormResponse(result.data)
|
|
11032
|
+
};
|
|
11033
|
+
}
|
|
11034
|
+
function normalizePublicFormsResponse(response) {
|
|
11035
|
+
return { forms: response.forms.map((form) => normalizePublicForm(form)) };
|
|
11036
|
+
}
|
|
11037
|
+
function normalizePublicFormsResult(result) {
|
|
11038
|
+
if (isApiError(result)) return result;
|
|
11039
|
+
return {
|
|
11040
|
+
...result,
|
|
11041
|
+
data: normalizePublicFormsResponse(result.data)
|
|
11042
|
+
};
|
|
11043
|
+
}
|
|
11044
|
+
function normalizeBatchBlockLoaderResult(response, requestId) {
|
|
11045
|
+
if (isApiError(response)) return response;
|
|
11046
|
+
const result = response.data.results[requestId];
|
|
11047
|
+
if (!result) throw new Error(`Missing batch block loader result for "${requestId}"`);
|
|
11048
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
11049
|
+
return {
|
|
11050
|
+
...response,
|
|
11051
|
+
data: result.data
|
|
11052
|
+
};
|
|
11053
|
+
}
|
|
11054
|
+
/**
|
|
11055
|
+
* Check if an error is an AbortError (from AbortController.abort())
|
|
11056
|
+
*/
|
|
11057
|
+
function isAbortError(error) {
|
|
11058
|
+
if (error instanceof DOMException && error.name === "AbortError") return true;
|
|
11059
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
11060
|
+
return false;
|
|
11061
|
+
}
|
|
11062
|
+
/**
|
|
11063
|
+
* Determine the network error code based on error type, code, and message.
|
|
11064
|
+
* Uses multiple detection strategies for cross-runtime compatibility:
|
|
11065
|
+
* 1. Error name (TimeoutError, AbortError) - reliable in browsers
|
|
11066
|
+
* 2. Node.js error code (ETIMEDOUT, ENOTFOUND, etc.) - most reliable in Node
|
|
11067
|
+
* 3. Message matching - fallback for edge cases
|
|
11068
|
+
*/
|
|
11069
|
+
function getNetworkErrorCode(error) {
|
|
11070
|
+
if (error.name === "TimeoutError" || error.name === "AbortError") return "network:timeout";
|
|
11071
|
+
const nodeError = error;
|
|
11072
|
+
if (nodeError.code) switch (nodeError.code) {
|
|
11073
|
+
case "ETIMEDOUT":
|
|
11074
|
+
case "ESOCKETTIMEDOUT": return "network:timeout";
|
|
11075
|
+
case "ENOTFOUND":
|
|
11076
|
+
case "EAI_AGAIN": return "network:dns_error";
|
|
11077
|
+
case "ECONNREFUSED":
|
|
11078
|
+
case "ECONNRESET":
|
|
11079
|
+
case "EPIPE": return "network:connection_error";
|
|
11080
|
+
}
|
|
11081
|
+
const message = error.message.toLowerCase();
|
|
11082
|
+
if (message.includes("timeout") || message.includes("timed out")) return "network:timeout";
|
|
11083
|
+
if (message.includes("dns") || message.includes("getaddrinfo") || message.includes("enotfound")) return "network:dns_error";
|
|
11084
|
+
return "network:connection_error";
|
|
11085
|
+
}
|
|
11086
|
+
/**
|
|
11087
|
+
* Convert API errors to RiverbankApiError for consistent SDK error handling.
|
|
11088
|
+
* Handles:
|
|
11089
|
+
* - ApiEnvelopeError (from unwrapResponse)
|
|
11090
|
+
* - ApiRequestError (from fetch with HTTP error)
|
|
11091
|
+
* - Network errors (TypeError, etc. - wrapped with status 0)
|
|
11092
|
+
* - AbortError (let propagate raw for consumer detection)
|
|
11093
|
+
*/
|
|
11094
|
+
function convertToTypedError(error) {
|
|
11095
|
+
if (isAbortError(error)) throw error;
|
|
11096
|
+
if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
|
|
11097
|
+
code: error.code,
|
|
11098
|
+
message: error.message,
|
|
11099
|
+
requestId: error.requestId,
|
|
11100
|
+
timestamp: error.timestamp,
|
|
11101
|
+
status: error.status,
|
|
11102
|
+
fieldErrors: error.fieldErrors
|
|
11103
|
+
});
|
|
11104
|
+
if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
|
|
11105
|
+
const body = error.body;
|
|
11106
|
+
if (isApiError(body)) {
|
|
11107
|
+
const envelopeError = body.error;
|
|
11108
|
+
throw new RiverbankApiError({
|
|
11109
|
+
...envelopeError,
|
|
11110
|
+
retryAfterMs: error.retryAfterMs
|
|
11111
|
+
});
|
|
11112
|
+
}
|
|
11113
|
+
}
|
|
11114
|
+
if (error instanceof TypeError || error instanceof Error && !("status" in error)) {
|
|
11115
|
+
const networkError = error;
|
|
11116
|
+
throw new RiverbankApiError({
|
|
11117
|
+
code: getNetworkErrorCode(networkError),
|
|
11118
|
+
message: networkError.message || "Network request failed",
|
|
11119
|
+
requestId: `local-${Date.now()}`,
|
|
11120
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11121
|
+
status: 0,
|
|
11122
|
+
cause: networkError
|
|
11123
|
+
});
|
|
11124
|
+
}
|
|
11125
|
+
throw error;
|
|
11126
|
+
}
|
|
11127
|
+
/**
|
|
11128
|
+
* Detect API key type from prefix.
|
|
11129
|
+
*
|
|
11130
|
+
* Key prefixes:
|
|
11131
|
+
* - bld_live_sk_* / bld_test_sk_* → 'content' (published content)
|
|
11132
|
+
* - bld_preview_sk_* → 'preview' (draft content)
|
|
11133
|
+
*/
|
|
11134
|
+
function detectKeyType(apiKey) {
|
|
11135
|
+
if (apiKey.startsWith("bld_live_sk_") || apiKey.startsWith("bld_test_sk_")) return "content";
|
|
11136
|
+
if (apiKey.startsWith("bld_preview_sk_")) return "preview";
|
|
11137
|
+
return "unknown";
|
|
11138
|
+
}
|
|
11139
|
+
/**
|
|
11140
|
+
* Resolve auth configuration from config, handling backward compatibility.
|
|
11141
|
+
* Throws if neither `auth` nor `apiKey` is provided.
|
|
11142
|
+
*/
|
|
11143
|
+
function resolveAuth(config) {
|
|
11144
|
+
if (config.auth) return config.auth;
|
|
11145
|
+
if (config.apiKey) return {
|
|
11146
|
+
type: "api-key",
|
|
11147
|
+
key: config.apiKey
|
|
11148
|
+
};
|
|
11149
|
+
throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
|
|
11150
|
+
}
|
|
11151
|
+
const defaultRiverbankClientDeps = {
|
|
11152
|
+
createBearerAPIClient,
|
|
11153
|
+
createInternalAPIClient
|
|
11154
|
+
};
|
|
11155
|
+
/**
|
|
11156
|
+
* Create a Riverbank CMS client for fetching content
|
|
11157
|
+
*
|
|
11158
|
+
* @example
|
|
11159
|
+
* ```ts
|
|
11160
|
+
* const client = createRiverbankClient({
|
|
11161
|
+
* apiKey: 'bld_live_sk_...',
|
|
11162
|
+
* baseUrl: 'https://dashboard.example.com/api',
|
|
11163
|
+
* });
|
|
11164
|
+
*
|
|
11165
|
+
* const site = await client.getSite({ slug: 'my-site' });
|
|
11166
|
+
* ```
|
|
11167
|
+
*/
|
|
11168
|
+
function createRiverbankClient(config) {
|
|
11169
|
+
return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
|
|
11170
|
+
}
|
|
11171
|
+
function createRiverbankClientWithDeps(deps, config) {
|
|
11172
|
+
if (!config.baseUrl) throw new Error("baseUrl is required when creating a Riverbank client. Expected format: https://dashboard.example.com/api (must include /api path)");
|
|
11173
|
+
if (!config.baseUrl.endsWith("/api")) throw new Error(`baseUrl must end with '/api'. Received: ${config.baseUrl}. Expected format: https://dashboard.example.com/api`);
|
|
11174
|
+
const cacheEnabled = config.cache?.enabled ?? true;
|
|
11175
|
+
const cacheTTL = (config.cache?.ttl ?? 300) * 1e3;
|
|
11176
|
+
const cacheMaxSize = config.cache?.maxSize ?? 100;
|
|
11177
|
+
const resilienceEnabled = config.resilience?.enabled ?? true;
|
|
11178
|
+
const staleIfError = config.resilience?.staleIfError ?? true;
|
|
11179
|
+
const staleTtlMs = (config.resilience?.staleTtlSec ?? 300) * 1e3;
|
|
11180
|
+
const requestTimeoutMs = config.resilience?.requestTimeoutMs ?? (typeof window !== "undefined" ? DEFAULT_BROWSER_TIMEOUT_MS : DEFAULT_SERVER_TIMEOUT_MS);
|
|
11181
|
+
const retryConfig = {
|
|
11182
|
+
maxAttempts: config.resilience?.retry?.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts,
|
|
11183
|
+
baseDelayMs: config.resilience?.retry?.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs,
|
|
11184
|
+
maxDelayMs: config.resilience?.retry?.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs,
|
|
11185
|
+
jitter: config.resilience?.retry?.jitter ?? DEFAULT_RETRY_CONFIG.jitter,
|
|
11186
|
+
retryOn: config.resilience?.retry?.retryOn
|
|
11187
|
+
};
|
|
11188
|
+
const circuitBreakerConfig = {
|
|
11189
|
+
failureThreshold: config.resilience?.circuitBreaker?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
11190
|
+
resetTimeoutMs: config.resilience?.circuitBreaker?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
11191
|
+
halfOpenMaxRequests: config.resilience?.circuitBreaker?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
11192
|
+
};
|
|
11193
|
+
const authConfig = resolveAuth(config);
|
|
11194
|
+
let keyType;
|
|
11195
|
+
switch (authConfig.type) {
|
|
11196
|
+
case "none":
|
|
11197
|
+
keyType = "unknown";
|
|
11198
|
+
break;
|
|
11199
|
+
case "api-key":
|
|
11200
|
+
keyType = detectKeyType(authConfig.key);
|
|
11201
|
+
break;
|
|
11202
|
+
case "bearer":
|
|
11203
|
+
keyType = "preview";
|
|
11204
|
+
break;
|
|
11205
|
+
}
|
|
11206
|
+
const apiClient = withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, sdkRequestOptions) : authConfig.type === "api-key" ? deps.createBearerAPIClient(authConfig.key, config.baseUrl, sdkRequestOptions) : deps.createBearerAPIClient(authConfig.token, config.baseUrl, sdkRequestOptions), config.defaultHeaders);
|
|
11207
|
+
const cache = new SimpleCache({
|
|
11208
|
+
maxSize: cacheMaxSize,
|
|
11209
|
+
ttl: cacheTTL,
|
|
11210
|
+
staleTtl: staleTtlMs
|
|
11211
|
+
});
|
|
11212
|
+
const circuitBreaker = new CircuitBreaker(circuitBreakerConfig);
|
|
11213
|
+
const prebuildDir = config.resilience?.prebuildDir;
|
|
11214
|
+
const prebuildMod = prebuildDir ? getPrebuildModule() : null;
|
|
11215
|
+
const prebuildLoader = (prebuildMod?.canUsePrebuild() ?? false) && prebuildMod && prebuildDir ? new prebuildMod.PrebuildLoader({
|
|
11216
|
+
prebuildDir,
|
|
11217
|
+
maxPrebuildAgeSec: config.resilience?.maxPrebuildAgeSec
|
|
11218
|
+
}) : null;
|
|
11219
|
+
let lastStatus = null;
|
|
11220
|
+
let isDegraded = false;
|
|
11221
|
+
/**
|
|
11222
|
+
* Emit a status update and trigger callbacks
|
|
11223
|
+
*/
|
|
11224
|
+
function emitStatus(source, data, details) {
|
|
11225
|
+
const status = {
|
|
11226
|
+
source,
|
|
11227
|
+
isPreview: details.isPreview,
|
|
11228
|
+
cacheKey: details.cacheKey,
|
|
11229
|
+
cacheTier: details.cacheTier,
|
|
11230
|
+
durableCache: details.durableCache,
|
|
11231
|
+
error: details.error,
|
|
11232
|
+
staleAgeSec: details.staleAgeSec,
|
|
11233
|
+
prebuildAgeSec: details.prebuildAgeSec,
|
|
11234
|
+
circuit: circuitBreaker.getState(),
|
|
11235
|
+
requestId: details.requestId,
|
|
11236
|
+
durationMs: details.durationMs
|
|
11237
|
+
};
|
|
11238
|
+
lastStatus = status;
|
|
11239
|
+
config.resilience?.onStatusChange?.(status);
|
|
11240
|
+
const nowDegraded = isDegradedResilienceStatus(source, details);
|
|
11241
|
+
if (nowDegraded !== isDegraded) {
|
|
11242
|
+
isDegraded = nowDegraded;
|
|
11243
|
+
config.resilience?.onDegradedMode?.(nowDegraded, status);
|
|
11244
|
+
}
|
|
11245
|
+
return {
|
|
11246
|
+
data,
|
|
11247
|
+
resilience: status
|
|
11248
|
+
};
|
|
11249
|
+
}
|
|
11250
|
+
async function tryPublishedRuntimeCacheFallback(plan, statusDetails, errorInfo) {
|
|
11251
|
+
const reader = config.publishedRuntimeCache?.read;
|
|
11252
|
+
if (!plan || !reader) return null;
|
|
11253
|
+
try {
|
|
11254
|
+
const result = await reader({
|
|
11255
|
+
cacheKey: plan.cacheKey,
|
|
11256
|
+
endpoint: plan.endpoint,
|
|
11257
|
+
payloadSchemaVersion: 4
|
|
11258
|
+
});
|
|
11259
|
+
if (result.kind === "miss") return {
|
|
11260
|
+
kind: "miss",
|
|
11261
|
+
diagnostic: {
|
|
11262
|
+
outcome: "miss",
|
|
11263
|
+
reason: result.reason
|
|
11264
|
+
}
|
|
11265
|
+
};
|
|
11266
|
+
if (result.kind === "error") return {
|
|
11267
|
+
kind: "error",
|
|
11268
|
+
diagnostic: {
|
|
11269
|
+
outcome: "error",
|
|
11270
|
+
error: result.error
|
|
11271
|
+
}
|
|
11272
|
+
};
|
|
11273
|
+
return {
|
|
11274
|
+
kind: "hit",
|
|
11275
|
+
result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
|
|
11276
|
+
error: errorInfo,
|
|
11277
|
+
staleAgeSec: result.staleAgeSec,
|
|
11278
|
+
cacheTier: result.freshness === "fresh" ? "durable-fresh" : "durable-stale"
|
|
11279
|
+
}))
|
|
11280
|
+
};
|
|
11281
|
+
} catch (error) {
|
|
11282
|
+
return {
|
|
11283
|
+
kind: "error",
|
|
11284
|
+
diagnostic: {
|
|
11285
|
+
outcome: "error",
|
|
11286
|
+
error: {
|
|
11287
|
+
kind: "adapter_exception",
|
|
11288
|
+
message: error instanceof Error ? error.message : String(error)
|
|
11289
|
+
}
|
|
11290
|
+
}
|
|
11291
|
+
};
|
|
11292
|
+
}
|
|
11293
|
+
}
|
|
11294
|
+
async function writePublishedRuntimeCache(plan, payload) {
|
|
11295
|
+
const writer = config.publishedRuntimeCache?.write;
|
|
11296
|
+
if (!plan || !writer) return;
|
|
11297
|
+
try {
|
|
11298
|
+
await writer({
|
|
11299
|
+
cacheKey: plan.cacheKey,
|
|
11300
|
+
endpoint: plan.endpoint,
|
|
11301
|
+
normalizedParams: plan.normalizedParams,
|
|
11302
|
+
payload,
|
|
11303
|
+
siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
|
|
11304
|
+
freshTtlSec: plan.freshTtlSec,
|
|
11305
|
+
staleTtlSec: plan.staleTtlSec,
|
|
11306
|
+
payloadSchemaVersion: 4,
|
|
11307
|
+
writeReason: "live_success"
|
|
11308
|
+
});
|
|
11309
|
+
} catch {}
|
|
11310
|
+
}
|
|
11311
|
+
async function resilientFetch(cacheKey, fetcher, options) {
|
|
11312
|
+
const requestId = generateRequestId();
|
|
11313
|
+
const startTime = Date.now();
|
|
11314
|
+
const isPreview = options.preview ?? false;
|
|
11315
|
+
const allowFallbacks = !options.force;
|
|
11316
|
+
const statusDetails = (extra = {}) => ({
|
|
11317
|
+
requestId,
|
|
11318
|
+
cacheKey,
|
|
11319
|
+
isPreview,
|
|
11320
|
+
durationMs: Date.now() - startTime,
|
|
11321
|
+
...extra
|
|
11322
|
+
});
|
|
11323
|
+
if (cacheEnabled && !options.force) {
|
|
11324
|
+
const fresh = cache.getFresh(cacheKey);
|
|
11325
|
+
if (fresh !== null) return emitStatus("cache", fresh, statusDetails({ cacheTier: "memory-fresh" }));
|
|
11326
|
+
}
|
|
11327
|
+
if (resilienceEnabled && circuitBreaker.isOpen()) {
|
|
11328
|
+
if (allowFallbacks && !isPreview && staleIfError) {
|
|
11329
|
+
const stale = cache.getStale(cacheKey);
|
|
11330
|
+
if (stale) return emitStatus("stale", stale.value, statusDetails({
|
|
11331
|
+
staleAgeSec: stale.staleAgeSec,
|
|
11332
|
+
cacheTier: "memory-stale",
|
|
11333
|
+
error: {
|
|
11334
|
+
code: "circuit_open",
|
|
11335
|
+
message: "Circuit breaker is open"
|
|
11336
|
+
}
|
|
11337
|
+
}));
|
|
11338
|
+
}
|
|
11339
|
+
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, {
|
|
11340
|
+
code: "circuit_open",
|
|
11341
|
+
message: "Circuit breaker is open"
|
|
11342
|
+
}) : null;
|
|
11343
|
+
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
11344
|
+
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
11345
|
+
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
11346
|
+
const prebuildResult = options.prebuildFallback();
|
|
11347
|
+
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
11348
|
+
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
11349
|
+
cacheTier: "prebuild",
|
|
11350
|
+
durableCache,
|
|
11351
|
+
error: {
|
|
11352
|
+
code: "circuit_open",
|
|
11353
|
+
message: "Circuit breaker is open"
|
|
11354
|
+
}
|
|
11355
|
+
}));
|
|
11356
|
+
}
|
|
11357
|
+
const circuitState = circuitBreaker.getState();
|
|
11358
|
+
emitStatus("error", null, statusDetails({
|
|
11359
|
+
durableCache,
|
|
11360
|
+
error: {
|
|
11361
|
+
code: "circuit_open",
|
|
11362
|
+
message: "Circuit breaker is open"
|
|
11363
|
+
}
|
|
11364
|
+
}));
|
|
11365
|
+
throw new CircuitOpenError(circuitState);
|
|
11366
|
+
}
|
|
11367
|
+
try {
|
|
11368
|
+
let data;
|
|
11369
|
+
if (resilienceEnabled) {
|
|
11370
|
+
if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
|
|
11371
|
+
data = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
|
|
11372
|
+
const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
|
|
11373
|
+
try {
|
|
11374
|
+
return unwrapResponse(await fetcher(combinedSignal));
|
|
11375
|
+
} catch (error) {
|
|
11376
|
+
convertToTypedError(error);
|
|
11377
|
+
}
|
|
11378
|
+
}, {
|
|
11379
|
+
...retryConfig,
|
|
11380
|
+
requestTimeoutMs
|
|
11381
|
+
});
|
|
11382
|
+
circuitBreaker.recordSuccess();
|
|
11383
|
+
} else try {
|
|
11384
|
+
data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
|
|
11385
|
+
} catch (error) {
|
|
11386
|
+
convertToTypedError(error);
|
|
11387
|
+
}
|
|
11388
|
+
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, { tags: options.cacheTags });
|
|
11389
|
+
if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
|
|
11390
|
+
return emitStatus("live", data, statusDetails());
|
|
11391
|
+
} catch (error) {
|
|
11392
|
+
if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
|
|
11393
|
+
if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
|
|
11394
|
+
const stale = cache.getStale(cacheKey);
|
|
11395
|
+
if (stale) {
|
|
11396
|
+
const errorInfo = getRiverbankErrorInfo(error);
|
|
11397
|
+
return emitStatus("stale", stale.value, statusDetails({
|
|
11398
|
+
staleAgeSec: stale.staleAgeSec,
|
|
11399
|
+
cacheTier: "memory-stale",
|
|
11400
|
+
error: errorInfo
|
|
11401
|
+
}));
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
const errorInfo = getRiverbankErrorInfo(error);
|
|
11405
|
+
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
|
|
11406
|
+
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
11407
|
+
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
11408
|
+
if (allowFallbacks && !isPreview && options.prebuildFallback) {
|
|
11409
|
+
const prebuildResult = options.prebuildFallback();
|
|
11410
|
+
if (prebuildResult) return emitStatus("prebuild", prebuildResult.data, statusDetails({
|
|
11411
|
+
prebuildAgeSec: prebuildResult.prebuildAgeSec,
|
|
11412
|
+
cacheTier: "prebuild",
|
|
11413
|
+
durableCache,
|
|
11414
|
+
error: errorInfo
|
|
11415
|
+
}));
|
|
11416
|
+
}
|
|
11417
|
+
throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
|
|
11418
|
+
error: errorInfo,
|
|
11419
|
+
durableCache
|
|
11420
|
+
})).resilience);
|
|
11421
|
+
}
|
|
11422
|
+
}
|
|
11423
|
+
async function resilientFetchData(policyEndpoint, cacheKey, fetcher, options) {
|
|
11424
|
+
return (await resilientFetch(cacheKey, fetcher, applyPublicLoaderCachePolicy(policyEndpoint, options))).data;
|
|
11425
|
+
}
|
|
11426
|
+
const contentReads = createContentReadOperations({
|
|
11427
|
+
apiClient,
|
|
11428
|
+
resilientFetch,
|
|
11429
|
+
prebuildLoader
|
|
11430
|
+
});
|
|
11431
|
+
const eventReads = createPublicEventReadOperations({
|
|
11432
|
+
apiClient,
|
|
11433
|
+
resilientFetchData
|
|
11434
|
+
});
|
|
11435
|
+
const publicAppointmentReads = createPublicAppointmentReadOperations({
|
|
11436
|
+
apiClient,
|
|
11437
|
+
resilientFetchData
|
|
11438
|
+
});
|
|
11439
|
+
async function getEntriesInternal(params) {
|
|
11440
|
+
const { siteId, preview = false, signal } = params;
|
|
11441
|
+
const request = buildEntryListReadRequest(params);
|
|
11442
|
+
return resilientFetchData("listPublishedEntries", request.cacheKey, (sig) => apiClient({
|
|
11443
|
+
endpoint: "listPublishedEntries",
|
|
11444
|
+
params: request.params,
|
|
11445
|
+
options: { signal: sig }
|
|
11446
|
+
}), {
|
|
11447
|
+
preview,
|
|
11448
|
+
signal,
|
|
11449
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublishedEntries", { siteId }),
|
|
11450
|
+
prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
|
|
11451
|
+
});
|
|
11452
|
+
}
|
|
11453
|
+
return {
|
|
11454
|
+
async getSite(params) {
|
|
11455
|
+
return (await contentReads.getSiteWithResilience(params)).data;
|
|
11456
|
+
},
|
|
11457
|
+
async getSiteWithResilience(params) {
|
|
11458
|
+
return contentReads.getSiteWithResilience(params);
|
|
11459
|
+
},
|
|
11460
|
+
async getPage(params) {
|
|
11461
|
+
return (await contentReads.getPageWithResilience(params)).data;
|
|
11462
|
+
},
|
|
11463
|
+
async getPageWithResilience(params) {
|
|
11464
|
+
return contentReads.getPageWithResilience(params);
|
|
11465
|
+
},
|
|
11466
|
+
async getEntries(params) {
|
|
11467
|
+
return getEntriesInternal(params);
|
|
11468
|
+
},
|
|
11469
|
+
async getEntriesByIdentifiers(params) {
|
|
11470
|
+
const { siteId, contentType, identifiers, preview, signal } = params;
|
|
11471
|
+
const normalized = normalizeEntryIdentifierRefs(identifiers);
|
|
11472
|
+
if (normalized.kind === "empty") return { entries: [] };
|
|
11473
|
+
return getEntriesInternal({
|
|
11474
|
+
siteId,
|
|
11475
|
+
contentType,
|
|
11476
|
+
preview,
|
|
11477
|
+
signal,
|
|
11478
|
+
mode: "manual",
|
|
11479
|
+
entryIds: normalized.refs
|
|
11480
|
+
});
|
|
11481
|
+
},
|
|
11482
|
+
async getEntry(params) {
|
|
11483
|
+
const { siteId, contentType, slug, signal } = params;
|
|
11484
|
+
return resilientFetchData("getPublishedEntryPreview", `entry:${siteId}:${contentType}:${slug}`, async (sig) => {
|
|
11485
|
+
return await apiClient({
|
|
11486
|
+
endpoint: "getPublishedEntryPreview",
|
|
11487
|
+
params: {
|
|
11488
|
+
siteId,
|
|
11489
|
+
type: contentType,
|
|
11490
|
+
slug
|
|
11491
|
+
},
|
|
11492
|
+
options: { signal: sig }
|
|
11493
|
+
});
|
|
11494
|
+
}, {
|
|
11495
|
+
signal,
|
|
11496
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublishedEntryPreview", { siteId })
|
|
11497
|
+
});
|
|
11498
|
+
},
|
|
11499
|
+
async getPublicFormById(params) {
|
|
11500
|
+
const { formId, siteId, signal } = params;
|
|
11501
|
+
if (!formId || !siteId) throw new Error("getPublicFormById() requires formId and siteId");
|
|
11502
|
+
return resilientFetchData("getPublicFormById", `public-form:${siteId}:${formId}`, async (sig) => {
|
|
11503
|
+
return normalizePublicFormResult(await apiClient({
|
|
11504
|
+
endpoint: "getPublicFormById",
|
|
11505
|
+
params: {
|
|
11506
|
+
formId,
|
|
11507
|
+
siteId
|
|
11508
|
+
},
|
|
11509
|
+
options: { signal: sig }
|
|
11510
|
+
}));
|
|
11511
|
+
}, {
|
|
11512
|
+
signal,
|
|
11513
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicFormById", {
|
|
11514
|
+
siteId,
|
|
11515
|
+
formId
|
|
11516
|
+
})
|
|
11517
|
+
});
|
|
11518
|
+
},
|
|
11519
|
+
async getForms(params) {
|
|
11520
|
+
const { siteId, signal } = params;
|
|
11521
|
+
if (!siteId) throw new Error("getForms() requires siteId");
|
|
11522
|
+
return resilientFetchData("listPublicForms", `forms:${siteId}`, async (sig) => {
|
|
11523
|
+
return normalizePublicFormsResult(await apiClient({
|
|
11524
|
+
endpoint: "listPublicForms",
|
|
11525
|
+
params: { siteId },
|
|
11526
|
+
options: { signal: sig }
|
|
11527
|
+
}));
|
|
11528
|
+
}, {
|
|
11529
|
+
signal,
|
|
11530
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicForms", { siteId }),
|
|
11531
|
+
prebuildFallback: prebuildLoader ? () => {
|
|
11532
|
+
const result = prebuildLoader.loadForms();
|
|
11533
|
+
if (result) return {
|
|
11534
|
+
data: { forms: result.data.map((form) => ({
|
|
11535
|
+
id: form.id,
|
|
11536
|
+
slug: form.slug,
|
|
11537
|
+
name: form.name,
|
|
11538
|
+
schema: form.schema,
|
|
11539
|
+
settings: form.settings,
|
|
11540
|
+
schemaJson: form.schema,
|
|
11541
|
+
settingsJson: form.settings,
|
|
11542
|
+
createdAt: null,
|
|
11543
|
+
updatedAt: null
|
|
11544
|
+
})) },
|
|
11545
|
+
prebuildAgeSec: result.prebuildAgeSec
|
|
11546
|
+
};
|
|
11547
|
+
return null;
|
|
11548
|
+
} : void 0
|
|
11549
|
+
});
|
|
11550
|
+
},
|
|
11551
|
+
...publicAppointmentReads,
|
|
11552
|
+
async listPublicEvents(params) {
|
|
11553
|
+
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, detailLevel, readProfile, seriesId, includeOccurrenceId, signal } = params;
|
|
11554
|
+
if (!siteId) throw new Error("listPublicEvents() requires siteId");
|
|
11555
|
+
return resilientFetchData("listPublicEvents", `public-events:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${detailLevel ?? ""}:${readProfile ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
|
|
11556
|
+
return await apiClient({
|
|
11557
|
+
endpoint: "listPublicEvents",
|
|
11558
|
+
params: {
|
|
11559
|
+
siteId,
|
|
11560
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
11561
|
+
...from && { from },
|
|
11562
|
+
...to && { to },
|
|
11563
|
+
...afterStartsAt && { afterStartsAt },
|
|
11564
|
+
...afterId && { afterId },
|
|
11565
|
+
...stage && { stage },
|
|
11566
|
+
...categoryIds && { categoryIds },
|
|
11567
|
+
...venueId && { venueId },
|
|
11568
|
+
...staffMemberId && { staffMemberId },
|
|
11569
|
+
...kind && { kind },
|
|
11570
|
+
...eventSurface && { eventSurface },
|
|
11571
|
+
...eventPresets && { eventPresets },
|
|
11572
|
+
...scheduleScope && { scheduleScope },
|
|
11573
|
+
...detailLevel && { detailLevel },
|
|
11574
|
+
...readProfile && { readProfile },
|
|
11575
|
+
...seriesId && { seriesId },
|
|
11576
|
+
...includeOccurrenceId && { includeOccurrenceId }
|
|
11577
|
+
},
|
|
11578
|
+
options: { signal: sig }
|
|
11579
|
+
});
|
|
11580
|
+
}, {
|
|
11581
|
+
signal,
|
|
11582
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEvents", { siteId })
|
|
11583
|
+
});
|
|
11584
|
+
},
|
|
11585
|
+
async getPublicEventDetails(params) {
|
|
11586
|
+
const { siteId, limit, from, to, afterStartsAt, afterId, stage, categoryIds, venueId, staffMemberId, kind, eventSurface, eventPresets, scheduleScope, seriesId, includeOccurrenceId, signal } = params;
|
|
11587
|
+
if (!siteId) throw new Error("getPublicEventDetails() requires siteId");
|
|
11588
|
+
return resilientFetchData("getPublicEventDetails", `public-event-details:${siteId}:${limit ?? ""}:${from ?? ""}:${to ?? ""}:${afterStartsAt ?? ""}:${afterId ?? ""}:${stage ?? ""}:${categoryIds ?? ""}:${venueId ?? ""}:${staffMemberId ?? ""}:${kind ?? ""}:${eventSurface ?? ""}:${eventPresets ?? ""}:${scheduleScope ?? ""}:${seriesId ?? ""}:${includeOccurrenceId ?? ""}`, async (sig) => {
|
|
11589
|
+
const requestId = "eventDetails";
|
|
11590
|
+
return normalizeBatchBlockLoaderResult(await apiClient({
|
|
11591
|
+
endpoint: "batchBlockLoaders",
|
|
11592
|
+
params: {
|
|
11593
|
+
siteId,
|
|
11594
|
+
...stage && { stage }
|
|
11595
|
+
},
|
|
11596
|
+
body: { requests: [{
|
|
11597
|
+
id: requestId,
|
|
11598
|
+
endpoint: "getPublicEventDetails",
|
|
11599
|
+
params: {
|
|
11600
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
11601
|
+
...from && { from },
|
|
11602
|
+
...to && { to },
|
|
11603
|
+
...afterStartsAt && { afterStartsAt },
|
|
11604
|
+
...afterId && { afterId },
|
|
11605
|
+
...categoryIds && { categoryIds },
|
|
11606
|
+
...venueId && { venueId },
|
|
11607
|
+
...staffMemberId && { staffMemberId },
|
|
11608
|
+
...kind && { kind },
|
|
11609
|
+
...eventSurface && { eventSurface },
|
|
11610
|
+
...eventPresets && { eventPresets },
|
|
11611
|
+
...scheduleScope && { scheduleScope },
|
|
11612
|
+
...seriesId && { seriesId },
|
|
11613
|
+
...includeOccurrenceId && { includeOccurrenceId }
|
|
11614
|
+
}
|
|
11615
|
+
}] },
|
|
11616
|
+
options: { signal: sig }
|
|
11617
|
+
}), requestId);
|
|
11618
|
+
}, {
|
|
11619
|
+
signal,
|
|
11620
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicEventDetails", { siteId })
|
|
11621
|
+
});
|
|
11622
|
+
},
|
|
11623
|
+
async listPublicTeamMembers(params) {
|
|
11624
|
+
const { siteId, stage, signal } = params;
|
|
11625
|
+
if (!siteId) throw new Error("listPublicTeamMembers() requires siteId");
|
|
11626
|
+
return resilientFetchData("listPublicTeamMembers", `public-team-members:${siteId}:${stage ?? ""}`, async (sig) => {
|
|
11627
|
+
return await apiClient({
|
|
11628
|
+
endpoint: "listPublicTeamMembers",
|
|
11629
|
+
params: {
|
|
11630
|
+
siteId,
|
|
11631
|
+
...stage && { stage }
|
|
11632
|
+
},
|
|
11633
|
+
options: { signal: sig }
|
|
11634
|
+
});
|
|
11635
|
+
}, {
|
|
11636
|
+
signal,
|
|
11637
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicTeamMembers", { siteId })
|
|
11638
|
+
});
|
|
11639
|
+
},
|
|
11640
|
+
async listPublicProducts(params) {
|
|
11641
|
+
const { siteId, stage, categorySelector, signal } = params;
|
|
11642
|
+
if (!siteId) throw new Error("listPublicProducts() requires siteId");
|
|
11643
|
+
const selectorKey = categorySelector ? categorySelector.kind === "category" ? `category:${categorySelector.productCategoryId}` : `current-category-page:${categorySelector.productCategoryEntryId}` : "";
|
|
11644
|
+
return resilientFetchData("listPublicProducts", `public-products:${siteId}:${stage ?? ""}:${selectorKey}`, async (sig) => {
|
|
11645
|
+
return await apiClient({
|
|
11646
|
+
endpoint: "listPublicProducts",
|
|
11647
|
+
params: {
|
|
11648
|
+
siteId,
|
|
11649
|
+
...stage && { stage },
|
|
11650
|
+
...encodePublicProductCategorySelector(categorySelector)
|
|
11651
|
+
},
|
|
11652
|
+
options: { signal: sig }
|
|
11653
|
+
});
|
|
11654
|
+
}, {
|
|
11655
|
+
signal,
|
|
11656
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicProducts", { siteId })
|
|
11657
|
+
});
|
|
11658
|
+
},
|
|
11659
|
+
async listPublicPasses(params) {
|
|
11660
|
+
const { siteId, categories, signal } = params;
|
|
11661
|
+
if (!siteId) throw new Error("listPublicPasses() requires siteId");
|
|
11662
|
+
return resilientFetchData("listPublicPasses", `public-passes:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
11663
|
+
return await apiClient({
|
|
11664
|
+
endpoint: "listPublicPasses",
|
|
11665
|
+
params: {
|
|
11666
|
+
siteId,
|
|
11667
|
+
...categories && { categories }
|
|
11668
|
+
},
|
|
11669
|
+
options: { signal: sig }
|
|
11670
|
+
});
|
|
11671
|
+
}, {
|
|
11672
|
+
signal,
|
|
11673
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicPasses", { siteId })
|
|
11674
|
+
});
|
|
11675
|
+
},
|
|
11676
|
+
async listPublicMemberships(params) {
|
|
11677
|
+
const { siteId, categories, signal } = params;
|
|
11678
|
+
if (!siteId) throw new Error("listPublicMemberships() requires siteId");
|
|
11679
|
+
return resilientFetchData("listPublicMemberships", `public-memberships:${siteId}:${categories ?? ""}`, async (sig) => {
|
|
11680
|
+
return await apiClient({
|
|
11681
|
+
endpoint: "listPublicMemberships",
|
|
11682
|
+
params: {
|
|
11683
|
+
siteId,
|
|
11684
|
+
...categories && { categories }
|
|
11685
|
+
},
|
|
11686
|
+
options: { signal: sig }
|
|
11687
|
+
});
|
|
11688
|
+
}, {
|
|
11689
|
+
signal,
|
|
11690
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicMemberships", { siteId })
|
|
11691
|
+
});
|
|
11692
|
+
},
|
|
11693
|
+
...eventReads,
|
|
11694
|
+
async checkRedirect(params) {
|
|
11695
|
+
const { siteId, path, signal } = params;
|
|
11696
|
+
if (!siteId || !path) throw new Error("checkRedirect() requires siteId and path");
|
|
11697
|
+
return resilientFetchData("checkRedirect", `redirect:${siteId}:${path}`, async (sig) => {
|
|
11698
|
+
return await apiClient({
|
|
11699
|
+
endpoint: "checkRedirect",
|
|
11700
|
+
params: {
|
|
11701
|
+
site: siteId,
|
|
11702
|
+
path
|
|
11703
|
+
},
|
|
11704
|
+
options: { signal: sig }
|
|
11705
|
+
});
|
|
11706
|
+
}, {
|
|
11707
|
+
signal,
|
|
11708
|
+
cacheTags: buildPublicReadMemoryCacheTags("checkRedirect", { site: siteId })
|
|
11709
|
+
});
|
|
11710
|
+
},
|
|
11711
|
+
async resolveRouteOutcome(params) {
|
|
11712
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11713
|
+
if (!siteId || !path) throw new Error("resolveRouteOutcome() requires siteId and path");
|
|
11714
|
+
return unwrapResponse(await apiClient({
|
|
11715
|
+
endpoint: "resolveRouteOutcome",
|
|
11716
|
+
params: {
|
|
11717
|
+
siteId,
|
|
11718
|
+
path,
|
|
11719
|
+
preview: String(preview)
|
|
11720
|
+
},
|
|
11721
|
+
options: { signal }
|
|
11722
|
+
}));
|
|
11723
|
+
},
|
|
11724
|
+
async resolveRouteDecision(params) {
|
|
11725
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11726
|
+
if (!siteId || !path) throw new Error("resolveRouteDecision() requires siteId and path");
|
|
11727
|
+
return unwrapResponse(await apiClient({
|
|
11728
|
+
endpoint: "resolveRouteDecision",
|
|
11729
|
+
params: {
|
|
11730
|
+
siteId,
|
|
11731
|
+
path,
|
|
11732
|
+
preview: String(preview)
|
|
11733
|
+
},
|
|
11734
|
+
options: { signal }
|
|
11735
|
+
}));
|
|
11736
|
+
},
|
|
11737
|
+
async getAllPublishedRoutes(params) {
|
|
11738
|
+
const { siteId, signal } = params;
|
|
11739
|
+
if (!siteId) throw new Error("getAllPublishedRoutes() requires siteId");
|
|
11740
|
+
return resilientFetchData("getPublicRoutableContent", `routable-content:${siteId}:published`, async (sig) => {
|
|
11741
|
+
return await apiClient({
|
|
11742
|
+
endpoint: "getPublicRoutableContent",
|
|
11743
|
+
params: {
|
|
11744
|
+
siteId,
|
|
11745
|
+
publishedOnly: "true"
|
|
11746
|
+
},
|
|
11747
|
+
options: { signal: sig }
|
|
11748
|
+
});
|
|
11749
|
+
}, {
|
|
11750
|
+
signal,
|
|
11751
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicRoutableContent", { siteId })
|
|
11752
|
+
});
|
|
11753
|
+
},
|
|
11754
|
+
async getSitemapRoutes(params) {
|
|
11755
|
+
const { siteId, page, pageSize, signal } = params;
|
|
11756
|
+
if (!siteId) throw new Error("getSitemapRoutes() requires siteId");
|
|
11757
|
+
return resilientFetchData("getPublicSitemapRoutes", `sitemap:${siteId}:${page ?? 1}:${pageSize ?? "default"}`, async (sig) => {
|
|
11758
|
+
return await apiClient({
|
|
11759
|
+
endpoint: "getPublicSitemapRoutes",
|
|
11760
|
+
params: {
|
|
11761
|
+
siteId,
|
|
11762
|
+
...page ? { page: String(page) } : {},
|
|
11763
|
+
...pageSize ? { pageSize: String(pageSize) } : {}
|
|
11764
|
+
},
|
|
11765
|
+
options: { signal: sig }
|
|
11766
|
+
});
|
|
11767
|
+
}, {
|
|
11768
|
+
signal,
|
|
11769
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicSitemapRoutes", { siteId })
|
|
11770
|
+
});
|
|
11771
|
+
},
|
|
11772
|
+
clearCacheForTags(tags) {
|
|
11773
|
+
cache.clearForTags(tags);
|
|
11774
|
+
},
|
|
11775
|
+
clearCache() {
|
|
11776
|
+
cache.clear();
|
|
11777
|
+
},
|
|
11778
|
+
getKeyType() {
|
|
11779
|
+
return keyType;
|
|
11780
|
+
},
|
|
11781
|
+
getLastEmittedStatus() {
|
|
11782
|
+
return lastStatus;
|
|
11783
|
+
},
|
|
11784
|
+
getCircuitState() {
|
|
11785
|
+
return circuitBreaker.getState();
|
|
11786
|
+
},
|
|
11787
|
+
getBaseUrl() {
|
|
11788
|
+
return config.baseUrl;
|
|
11789
|
+
}
|
|
9658
11790
|
};
|
|
9659
11791
|
}
|
|
9660
11792
|
//#endregion
|
|
9661
|
-
export {
|
|
11793
|
+
export { createBearerAPIClient as _, DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, getResilienceStatusFromError as g, RiverbankApiError as h, resolveRuntimeCachePolicy as i, parsePublishedRuntimeCacheKeyDetails as l, CircuitOpenError as m, classifyPublishedRuntimeCacheFreshness as n, isPublishedRuntimeCacheKeyEndpoint as o, sdkRequestOptions as p, derivePublishedRuntimeCacheKey as r, normalizeRuntimePublicPath as s, createRiverbankClient as t, parsePublishedRuntimeCachePayloadSchemaVersion as u, ApiRequestError as v, unwrapResponse as y };
|