@riverbankcms/sdk 0.177.0 → 0.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/dist/_dts/{BlocksIslandsHydrator-sYraeqm9.d.ts → BlocksIslandsHydrator-DKwgs95u.d.ts} +1 -1
- package/dist/_dts/{Page-Bp7hTDTy.d.ts → Page-lWenra5i.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-CxkCCyKw.d.ts → SdkPreviewMode-BRxhRw4I.d.ts} +2 -2
- package/dist/_dts/{client-K6UhbL3t.d.ts → client-qWn7xAwJ.d.ts} +77 -23
- package/dist/_dts/{content-types-BLAdIMyr.d.ts → content-types-DL6GIvTm.d.ts} +2 -2
- package/dist/_dts/{contracts-BG7yTZ6t.d.ts → contracts-CzWyAiJj.d.ts} +6 -116
- package/dist/_dts/{generatePageMetadata-X_WpGzZZ.d.ts → generatePageMetadata-CBKd0cJ4.d.ts} +2 -2
- package/dist/_dts/{index--n-wV8Xd.d.ts → index-7CDBZGb-.d.ts} +1 -1
- package/dist/_dts/{index-Bygd2RCg.d.ts → index-BU9uAkHB.d.ts} +4 -4
- package/dist/_dts/{index-BMGif2r3.d.ts → index-BYnG_vF5.d.ts} +1 -1
- package/dist/_dts/{index-CBRbZJ6u.d.ts → index-CZgJrhzT.d.ts} +4 -2
- package/dist/_dts/{index-BLseXObg.d.ts → index-CaCum9mM.d.ts} +2 -2
- package/dist/_dts/{index-BpAW9AKB.d.ts → index-DCiSHd-C.d.ts} +1 -1
- package/dist/_dts/{index-CX9bp60k.d.ts → index-DVSipdrT.d.ts} +3 -3
- package/dist/_dts/{loadContent-uhUThWaq.d.ts → loadContent-CPKbFQyq.d.ts} +15 -13
- package/dist/_dts/{request-Bf9YImJw.d.ts → request-BjKBCS7t.d.ts} +1687 -373
- package/dist/_dts/{resolveBlockData-D6M5NMZB.d.ts → resolveBlockData-DupbMCup.d.ts} +8 -5
- package/dist/_dts/resolvePageContent-BqNyCHi8.d.ts +61 -0
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +3 -3
- package/dist/_dts/sdk/src/client.d.ts +7 -7
- 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 +2 -2
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
- package/dist/_dts/sdk/src/data/types.d.ts +7 -2
- package/dist/_dts/sdk/src/gifting/client.d.ts +1 -2
- 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 +3 -3
- package/dist/_dts/sdk/src/next/index.d.ts +32 -12
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
- package/dist/_dts/sdk/src/portal/client.d.ts +56 -4
- package/dist/_dts/sdk/src/portal/index.d.ts +95 -13
- 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 +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
- package/dist/_dts/sdk/src/rendering/index.d.ts +7 -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/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +19 -6
- package/dist/_dts/sdk/src/server.d.ts +5 -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/serviceBookingOutline-YcsIjvn1.d.ts +582 -0
- package/dist/_dts/{types-C1l2Sm2h.d.ts → types-B7e6Lmo5.d.ts} +3 -3
- package/dist/_dts/{types-DgV8P2mz.d.ts → types-BOxSq-Bq.d.ts} +8 -7
- package/dist/_dts/{types-BdZ5pJSk.d.ts → types-CT-KOxl_.d.ts} +5 -39
- package/dist/_dts/{validation-BtbZIT5f.d.ts → validation-Dz6qccue.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-CeYQQQs7.mjs → BlocksIslandsHydrator-1XifJg6V.mjs} +17 -18
- package/dist/client/{BookingMailingListNote-CDDWrY_W.mjs → BookingMailingListNote-BsbEgagJ.mjs} +7 -7
- package/dist/client/{BookingQuestionFields-MbvIo2jS.mjs → BookingQuestionFields-C8IbeLHj.mjs} +4 -4
- package/dist/client/{CalendarNavigationChevron-C6CSVfEB.mjs → CalendarNavigationChevron-Bbqij1XQ.mjs} +43 -10
- package/dist/client/{CheckboxChoice-b-PJLEXe.mjs → CheckboxChoice-BZPLCgTU.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-C9Ggcfx3.mjs → DemoBookingPortalAccess-uA9H8LIL.mjs} +4 -4
- package/dist/client/{EventCalendar.client-BSMuSqg0.mjs → EventCalendar.client-yoSI77ov.mjs} +11 -11
- package/dist/client/{EventCombined.client-BTrmSyUB.mjs → EventCombined.client-HeCNlliq.mjs} +11 -11
- package/dist/client/{EventEmbeddedCheckoutStep-B18VbNS_.mjs → EventEmbeddedCheckoutStep-BDnicDM6.mjs} +1 -1
- package/dist/client/{EventItem-B0WjGXsH.mjs → EventItem-Duhk1vnF.mjs} +247 -7
- package/dist/client/{EventListWeekNavigation-8Ij7vuxY.mjs → EventListWeekNavigation-BiutEqPK.mjs} +1 -1
- package/dist/client/{EventListing.client-CWk2NEwd.mjs → EventListing.client-B5ln77jG.mjs} +3 -3
- package/dist/client/{EventListing.view-BEH4UbSL.mjs → EventListing.view-hUDhNtMv.mjs} +203 -9
- package/dist/client/{EventRegistrationPayment-B2EikR3f.mjs → EventRegistrationPayment-DqtX1vB2.mjs} +439 -123
- package/dist/client/{Page-C03rc6jw.mjs → Page-ChJ2TGVk.mjs} +24314 -20226
- package/dist/client/{ProtectedSubmitButton-C-ql101B.mjs → ProtectedSubmitButton-De6AzhE6.mjs} +1 -1
- package/dist/client/{SiteTermsAgreementField-BYACYP0T.mjs → SiteTermsAgreementField-CDBU31xW.mjs} +3 -3
- package/dist/client/{StepIndicator-Bb7rPtSq.mjs → StepIndicator-2Dl9zon2.mjs} +80 -33
- package/dist/client/{BookingPanelArrangement-BShQSial.mjs → StepIndicator-JQA-VuEH.mjs} +12 -12
- package/dist/client/{TabBarFragment-BqfRLojo.mjs → TabBarFragment-DlKQRhP4.mjs} +1 -1
- package/dist/client/{ThemedButton-DuaYtnvG.mjs → ThemedButton-CnSa7o-I.mjs} +66 -66
- package/dist/client/{accessibleSurfaces-DN8it_Cx.mjs → accessibleSurfaces-Wl8-_OVJ.mjs} +1 -1
- package/dist/client/{accordion-BfsOiweL.mjs → accordion-B6SqU49k.mjs} +1 -1
- package/dist/client/{booking-form.client-B8ohIj13.mjs → booking-form.client-DrEOjQ3N.mjs} +15 -15
- package/dist/client/{bookingForm-CXsck2oH.mjs → bookingForm-drZBwEZW.mjs} +4 -4
- package/dist/client/bookings.mjs +5 -5
- package/dist/client/{boxStyleClassNames-B_hcuT06.mjs → boxStyleClassNames-DEh45w16.mjs} +19 -19
- package/dist/client/{carousel-Cz5Ddbsx.mjs → carousel-C-YJliD-.mjs} +2 -2
- package/dist/client/{carousel.client-h65clfUO.mjs → carousel.client-DMtGYTTM.mjs} +1 -1
- package/dist/client/{cart-CTC2oS3p.mjs → cart-acGFWK9R.mjs} +3 -3
- package/dist/client/{cart.client-c1YkTC-Q.mjs → cart.client-BzlOGP2j.mjs} +1 -1
- package/dist/client/{checkout-BeW1ufaH.mjs → checkout-SEontwhy.mjs} +3 -3
- package/dist/client/{checkout.client-BeU32khQ.mjs → checkout.client-C0Qvh-d4.mjs} +1 -1
- package/dist/client/{checkoutUrls-DVfSUSKp.mjs → checkoutUrls-yUKeq1N9.mjs} +1 -1
- package/dist/client/client.mjs +469 -320
- package/dist/client/{context-R9p5c8IH.mjs → context-DTrwaQtg.mjs} +2 -1
- package/dist/client/{dateFormatting-CF6FWCoo.mjs → dateFormatting-Cg8E1r9l.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-tZxIm3RL.mjs → demoPortalMagicLink-D0kOJYOX.mjs} +5 -4
- package/dist/client/{enhanceHeaderSection-DEYDI54E.mjs → enhanceHeaderSection-DyrpZ7ks.mjs} +4 -4
- package/dist/client/{event-registration.client-DWvSODTI.mjs → event-registration.client-RLZQWi2V.mjs} +121 -183
- package/dist/client/{eventCalendar-C9Pn9eeZ.mjs → eventCalendar-CphYnImh.mjs} +4 -4
- package/dist/client/{eventCombined-Bdhk0fp0.mjs → eventCombined-BvqjASB_.mjs} +4 -4
- package/dist/client/{eventListing-B-bJOQUk.mjs → eventListing-BaNAoC_M.mjs} +4 -4
- package/dist/client/{eventRegistration-CbdmUiDT.mjs → eventRegistration-COMHoRl6.mjs} +4 -4
- package/dist/client/events-9LPvwbWp.mjs +28 -0
- package/dist/client/{form-BbUUt784.mjs → form-DyH2juYT.mjs} +3 -3
- package/dist/client/{form.client-BVlz-9_t.mjs → form.client-DBwzkB0M.mjs} +5 -5
- package/dist/client/{form.parts-TB4UIrML.mjs → form.parts-CY4kX3mh.mjs} +3 -3
- package/dist/client/{formatDate-TDHhFjFN.mjs → formatDate-CTEN7gxW.mjs} +1 -1
- package/dist/client/gifting/client.mjs +7 -6
- package/dist/client/{gifting-CbNSrp7C.mjs → gifting-CIx4V378.mjs} +4 -4
- package/dist/client/{gifting.client-B__bGhFc.mjs → gifting.client-BEVPpzJM.mjs} +5 -5
- package/dist/client/{gifting.parts-CTA1sDW6.mjs → gifting.parts-VnORjnZK.mjs} +2 -2
- package/dist/client/{headerSection-5Wn9nUW_.mjs → headerSection-DGcJfRS8.mjs} +2 -2
- package/dist/client/{lookSurfaces-BwiNdgMU.mjs → lookSurfaces-IqT_SVnX.mjs} +167 -85
- package/dist/client/{newsletter-form.client-B17WYHxZ.mjs → newsletter-form.client-BvEDkjiD.mjs} +6 -6
- package/dist/client/{shop.interactive-CxDJ8P2r.mjs → newsletter-form.interactive-DCO1lErD.mjs} +3970 -3997
- package/dist/client/{newsletter-form.parts-DN9wD1ZG.mjs → newsletter-form.parts-BIy4IUT3.mjs} +2 -2
- package/dist/client/{newsletterForm-DLMlxInp.mjs → newsletterForm-CoTXDNFS.mjs} +3 -3
- package/dist/client/portal/client.mjs +346 -21
- package/dist/client/{product-detail.client-Di_anRGR.mjs → product-detail.client-YHQ2aKX1.mjs} +1 -1
- package/dist/client/{product-list.client-Duhl6rtL.mjs → product-list.client-DxoZw1vF.mjs} +1 -1
- package/dist/client/{productDetail-BgKmCwA8.mjs → productDetail-DjuFvkey.mjs} +3 -3
- package/dist/client/{productList-C_wMKsYS.mjs → productList-DE9GEFoZ.mjs} +3 -3
- package/dist/client/{propsDecoder-y3LvxaiG.mjs → propsDecoder-Cyag_HOs.mjs} +2 -48
- package/dist/client/{registry.server-CIWYKz1V.mjs → registry.server-BPwV-0Pp.mjs} +10426 -9114
- package/dist/client/rendering/client.mjs +41 -27
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +23 -2836
- package/dist/client/{richText-coerce-DkPBFb_a.mjs → richText-coerce-NrRqDeOg.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-BgO0rZce.mjs → routeIslandApiConfig-BWq5gKFK.mjs} +1 -1
- package/dist/client/runtimeResponse-D2j2-mOk.mjs +3 -0
- package/dist/client/{runtimeResponse-9v8q2NBc.mjs → runtimeResponse-DtWSfWSZ.mjs} +1 -1
- package/dist/client/{shop-CFbWlv_W.mjs → shop-C3wM0Hr4.mjs} +3 -3
- package/dist/client/{shop-commerce-C-I29eaA.mjs → shop-commerce-34YvcpbX.mjs} +14 -14
- package/dist/client/{shop-commerce-store-DGcc7twO.mjs → shop-commerce-store-B7xHksOs.mjs} +1 -1
- package/dist/client/{shop-discount-apply.state-DOm7vx0X.mjs → shop-discount-apply.state-BiBnozfO.mjs} +2 -2
- package/dist/client/{shop.client-GHTWUKD6.mjs → shop.client-C0v88nLd.mjs} +14 -14
- package/dist/client/{shopShared-Be9QJJpT.mjs → shopShared-Ct-BRNez.mjs} +2 -2
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/{noop-CaQxI-Js.mjs → src-CCtanNlD.mjs} +462 -455
- package/dist/client/src-DqMbCjI1.mjs +3 -0
- package/dist/client/{src-xrjaKaCj.mjs → src-uwCpbHXG.mjs} +2 -1
- package/dist/client/{timetableModel--R0zVzZO.mjs → timetableModel-lhE29TNT.mjs} +66 -12
- package/dist/client/{types-DjWUR_O6.mjs → types-BEaKfam_.mjs} +65 -65
- package/dist/client/{useAvailableSlots-BGu_2F50.mjs → useAvailableSlots-BelJviOT.mjs} +2 -2
- package/dist/client/useDiscountCodeUi-rQRE1-Ho.mjs +196 -0
- package/dist/client/{useEventPagination-DxIJ--JZ.mjs → useEventPagination-C4rS2Xxl.mjs} +8 -8
- package/dist/client/{view-3foOzGWR.mjs → view-LJVHVqsy.mjs} +4 -4
- package/dist/client/{display-4HYOb-AK.mjs → wizardSteps-CNDsxeJH.mjs} +9168 -8981
- package/dist/preview-next/before-render.mjs +4 -3
- package/dist/preview-next/client/{PageSectionToolbar-D6-jojqh.mjs → PageSectionToolbar-C4TtBPN-.mjs} +3 -3
- package/dist/preview-next/client/{PreviewEditorSidebar-BUVFKZ4k.mjs → PreviewEditorSidebar-D6fkE59-.mjs} +15 -13
- package/dist/preview-next/client/{PreviewEditorUI-292pOiSt.mjs → PreviewEditorUI-amcDlj0O.mjs} +4 -4
- package/dist/preview-next/client/{PreviewShell-CW0Yzj3h.mjs → PreviewShell-DeQjx4zk.mjs} +5 -5
- package/dist/preview-next/client/{SdkPreviewModeRuntime-Dba7zoZK.mjs → SdkPreviewModeRuntime-Cx0SXnoX.mjs} +5 -5
- package/dist/preview-next/client/{previewAssistantSlot-B-utyhbS.mjs → previewAssistantSlot-aqpU34WI.mjs} +1764 -1090
- package/dist/preview-next/client/{previewChromeRoot-CCoGydUD.mjs → previewChromeRoot-D3Gy_Rs0.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-DCpXVcA0.mjs → sdk-runtime-Dzx_RrN7.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-sjOvRAHY.mjs → siteStyleAccess-LHedw83e.mjs} +1 -1
- package/dist/preview-next/client/src-EO5QoRlU.mjs +3 -0
- package/dist/preview-next/client/{src-DzXUmsyK.mjs → src-lX6heoDA.mjs} +2 -1
- package/dist/preview-next/client/{useAutosaveStatus-R1rZ9-IZ.mjs → useAutosaveStatus-DpSd9aVk.mjs} +1 -1
- package/dist/preview-next/client/{useOpenBlockForSetup-BS7CANPv.mjs → useOpenBlockForSetup-BGZn5AT1.mjs} +1 -1
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-BSSbtz6A.mjs → route-contract-DnL-FgSV.mjs} +83 -11
- package/dist/server/{Block.shared-Dc3DX7Cf.mjs → Block.shared-BEbq6EwO.mjs} +5 -5
- package/dist/server/{bindings-VGgS6UvF.mjs → bindings-Bly0dRs7.mjs} +36 -5
- package/dist/server/{client-BPLLL22F.mjs → client-CGJ2ztYp.mjs} +1021 -1118
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/constants-Cj7hfbrA.mjs +41 -0
- package/dist/server/contentTypeResolver-B9vy8BrF.mjs +19 -0
- package/dist/server/data/dataLoaderContext.mjs +1 -1
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/{dataLoaderContext-B3fXA54R.mjs → dataLoaderContext-lMRTfG5Z.mjs} +1 -0
- package/dist/server/error-f4g44bKx.mjs +387 -0
- package/dist/server/index.mjs +3 -2
- package/dist/server/loadContent-BkK1w3QQ.mjs +692 -0
- package/dist/server/{loadPage-CQgde5DN.mjs → loadPage-DTLe0FEs.mjs} +22 -4
- package/dist/server/{navigation-iC_hXjJI.mjs → navigation-BcNfYYuu.mjs} +1 -1
- package/dist/server/navigation.mjs +1 -1
- package/dist/server/next.mjs +103 -100
- package/dist/server/{overrideResolution-CkpwAHvW.mjs → overrideResolution-Uy9Zp2Ks.mjs} +1 -1
- package/dist/server/page-converter.mjs +1 -1
- package/dist/server/{pageRenderPlan-CfSnAkCO.mjs → pageRenderPlan-JzxBnqfV.mjs} +19 -7
- package/dist/server/{pageRuntimeSupport-uz4gzBOo.mjs → pageRuntimeSupport-DyNSd2Yj.mjs} +50 -2
- package/dist/server/{pageShared-6z6JBU41.mjs → pageShared-DU4ETFPS.mjs} +89 -83
- package/dist/server/portal-B4JVkdjc.mjs +783 -0
- package/dist/server/portal.mjs +3 -3
- package/dist/server/{prebuild-B4_Llisx.mjs → prebuild-8jNtDXmS.mjs} +5 -4
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-CCiYV8_s.mjs → prefetchBlockData-xeMG42aw.mjs} +3 -2
- package/dist/server/{registry-CXRXsFSx.mjs → registry-DH1VrsCl.mjs} +587 -329
- package/dist/server/rendering/components/pageShared.mjs +1 -1
- package/dist/server/rendering/helpers/loadPage.mjs +1 -1
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
- package/dist/server/rendering/server.mjs +5 -4
- package/dist/server/rendering.mjs +9 -8
- package/dist/server/{resolveBlockData-yfe8WLEA.mjs → resolveBlockData-BN8tweTx.mjs} +24 -5
- package/dist/server/resolvePageContent-DnM16_f9.mjs +89 -0
- package/dist/server/routing.mjs +271 -57
- package/dist/server/server.mjs +3 -3
- package/dist/server/{loadContent-CxASA3PE.mjs → servicePageContent-B-FezJmH.mjs} +709 -453
- package/dist/server/{validation-BvHio6QI.mjs → validation-3jOzYdPL.mjs} +3 -3
- package/dist/server/{version-SuFlio6n.mjs → version-8t0o6_jd.mjs} +1 -1
- package/dist/styles/index.css +19 -0
- package/package.json +1 -1
- package/dist/_dts/footerPageOutline-DwMHeYmQ.d.ts +0 -256
- package/dist/_dts/resolvePageContent-DkzWvFbG.d.ts +0 -162
- package/dist/client/LocationMapActions-myIQIvQL.mjs +0 -62
- package/dist/client/MapDrawingSvg-BfsVyPvB.mjs +0 -200
- package/dist/client/course-CUFVJEAc.mjs +0 -237
- package/dist/client/duration-Q6_QNgiv.mjs +0 -37
- package/dist/client/event-details.client-BwjBJP-f.mjs +0 -53
- package/dist/client/eventDetails-C2LfNW_o.mjs +0 -13
- package/dist/client/runtimeResponse-CVkM0dHy.mjs +0 -3
- package/dist/client/src-BozhJ43Z.mjs +0 -3
- package/dist/client/useDiscountCodeUi-I_mXI9Yd.mjs +0 -237
- package/dist/client/view-BbzH5MQb.mjs +0 -1371
- package/dist/preview-next/client/src-LUhVXBEQ.mjs +0 -3
- package/dist/server/constants-hl17xz6x.mjs +0 -22
- package/dist/server/portal-BjVHMAUC.mjs +0 -371
- package/dist/server/resolvePageContent-CAELMBEJ.mjs +0 -438
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { n as parseSurfaceTree } from "./accessibleSurfaces-CM3QANtw.mjs";
|
|
2
2
|
import { o as isSupportedLoaderEndpoint, r as encodePublicProductCategorySelector, t as materializeEntriesMedia } from "./responseMedia-F-ElH2Rd.mjs";
|
|
3
3
|
import { f as parseSiteId, t as publicMapLocationParamsSchema } from "./mapLocation-BM5WX7FY.mjs";
|
|
4
|
-
import { t as
|
|
4
|
+
import { a as ApiEnvelopeError, c as unwrapResponse, i as ApiRequestError, l as CLIENT_ERROR_REPORT_ENDPOINT_DEFINITIONS, n as attachResilienceStatusToError, o as extractApiEnvelopeErrorDetails, s as isApiError, t as RiverbankApiError, u as defineEndpointDefinitions } from "./error-f4g44bKx.mjs";
|
|
5
|
+
import { t as SDK_VERSION } from "./version-8t0o6_jd.mjs";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
/**
|
|
7
8
|
* How long a rendered page may hold availability it read through the batch
|
|
@@ -43,7 +44,6 @@ const PUBLIC_READ_CACHE_POLICIES = {
|
|
|
43
44
|
"public_memberships"
|
|
44
45
|
], "batch_only"),
|
|
45
46
|
getPublicMapLocation: availability(["public_events", "public_event_filters"], "batch_only"),
|
|
46
|
-
resolveEventSubroute: availability(["public_events", "public_event_filters"], "direct"),
|
|
47
47
|
listPublicRouteCandidates: content(["published_content"], "batch_only"),
|
|
48
48
|
listPublicTeamMembers: content(["public_team_members"]),
|
|
49
49
|
listPublicProducts: availability(["public_products"], "direct"),
|
|
@@ -95,15 +95,6 @@ const BEFORE_BOOKING_QUESTIONS_ROUTE = {
|
|
|
95
95
|
method: "POST"
|
|
96
96
|
};
|
|
97
97
|
//#endregion
|
|
98
|
-
//#region ../api/src/defineEndpointDefinitions.ts
|
|
99
|
-
/**
|
|
100
|
-
* Validates extracted endpoint descriptors while preserving each literal path,
|
|
101
|
-
* method, and parameter contract for the typed URL builders.
|
|
102
|
-
*/
|
|
103
|
-
function defineEndpointDefinitions(definitions) {
|
|
104
|
-
return definitions;
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
98
|
//#region ../api/src/apiEndpointTypes.ts
|
|
108
99
|
function allowedDemoMutationPolicy() {
|
|
109
100
|
return {
|
|
@@ -682,6 +673,23 @@ function buildFetchPolicy(siteId, reads, freshnessSeconds) {
|
|
|
682
673
|
function buildPublicReadBatchFetchPolicy(siteId, reads) {
|
|
683
674
|
return buildFetchPolicy(siteId, reads, publicReadBatchFreshnessSeconds);
|
|
684
675
|
}
|
|
676
|
+
/** A page may depend on admission even when an ordinary CMS page won precedence. */
|
|
677
|
+
function buildPageReadCachePolicy(siteId, dependencies) {
|
|
678
|
+
return dependencies === "availability" ? {
|
|
679
|
+
tags: normalizeRevalidateTags([
|
|
680
|
+
...buildCacheReadTags([TAG_TEMPLATES.siteRoutableContent], { siteId }),
|
|
681
|
+
...buildPublicReadFetchTags("listPublicEvents", { siteId }),
|
|
682
|
+
...buildPublicReadFetchTags("getPublicBookingService", { siteId })
|
|
683
|
+
]),
|
|
684
|
+
revalidate: 60
|
|
685
|
+
} : {
|
|
686
|
+
tags: buildCacheReadTags([TAG_TEMPLATES.siteRoutableContent], { siteId }),
|
|
687
|
+
revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
function pageReadDependencies(payload) {
|
|
691
|
+
return typeof payload === "object" && payload !== null && "dependencies" in payload && payload.dependencies === "content" ? "content" : "availability";
|
|
692
|
+
}
|
|
685
693
|
//#endregion
|
|
686
694
|
//#region ../api/src/sdkEntryReadEndpoints.ts
|
|
687
695
|
const SDK_ENTRY_READ_ENDPOINTS = {
|
|
@@ -851,8 +859,10 @@ const arrangementEndRequestSchema = z.object({
|
|
|
851
859
|
...recordedReturn,
|
|
852
860
|
lastDate: localDate
|
|
853
861
|
}).strict();
|
|
854
|
-
|
|
862
|
+
/** `expectedUpdatedAt` is the version the dialog was showing, so a save can't overwrite a newer change. */
|
|
863
|
+
const arrangementEditSchema = z.object({
|
|
855
864
|
...operation,
|
|
865
|
+
expectedUpdatedAt: z.string().min(1),
|
|
856
866
|
serviceId: z.string().uuid(),
|
|
857
867
|
holdsTime: z.boolean(),
|
|
858
868
|
payment: arrangementPaymentSchema
|
|
@@ -886,6 +896,11 @@ z.discriminatedUnion("kind", [
|
|
|
886
896
|
kind: z.literal("end"),
|
|
887
897
|
arrangementId: z.string().uuid(),
|
|
888
898
|
request: arrangementEndRequestSchema
|
|
899
|
+
}).strict(),
|
|
900
|
+
z.object({
|
|
901
|
+
kind: z.literal("edit"),
|
|
902
|
+
arrangementId: z.string().uuid(),
|
|
903
|
+
request: arrangementEditSchema
|
|
889
904
|
}).strict()
|
|
890
905
|
]);
|
|
891
906
|
const arrangementTimeOffChoiceSchema = z.discriminatedUnion("kind", [
|
|
@@ -1586,6 +1601,20 @@ const APPOINTMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
1586
1601
|
auth: "user",
|
|
1587
1602
|
responseKind: "json"
|
|
1588
1603
|
},
|
|
1604
|
+
listStaffServiceOnlineDetails: {
|
|
1605
|
+
path: "/sites/{siteId}/bookings/resources/{resourceId}/services/online-details",
|
|
1606
|
+
method: "GET",
|
|
1607
|
+
auth: "user",
|
|
1608
|
+
responseKind: "json",
|
|
1609
|
+
errors: []
|
|
1610
|
+
},
|
|
1611
|
+
setStaffServiceOnlineDetails: {
|
|
1612
|
+
path: "/sites/{siteId}/bookings/resources/{resourceId}/services/online-details",
|
|
1613
|
+
method: "PUT",
|
|
1614
|
+
auth: "user",
|
|
1615
|
+
responseKind: "json",
|
|
1616
|
+
errors: []
|
|
1617
|
+
},
|
|
1589
1618
|
getServiceResources: {
|
|
1590
1619
|
path: "/sites/{siteId}/bookings/services/{serviceId}/resources",
|
|
1591
1620
|
method: "GET",
|
|
@@ -1983,6 +2012,18 @@ const EVENT_SERIES_REGISTRATION_ENDPOINT_DEFINITIONS = defineEndpointDefinitions
|
|
|
1983
2012
|
"server:internal_error"
|
|
1984
2013
|
]
|
|
1985
2014
|
},
|
|
2015
|
+
setEventAttendeesNoShow: {
|
|
2016
|
+
path: "/sites/{siteId}/bookings/attendees/no-show",
|
|
2017
|
+
method: "POST",
|
|
2018
|
+
auth: "user",
|
|
2019
|
+
responseKind: "json",
|
|
2020
|
+
errors: [
|
|
2021
|
+
"validation:invalid_input",
|
|
2022
|
+
"auth:forbidden",
|
|
2023
|
+
"resource:conflict",
|
|
2024
|
+
"server:internal_error"
|
|
2025
|
+
]
|
|
2026
|
+
},
|
|
1986
2027
|
listEventOfferingCombinationPrices: {
|
|
1987
2028
|
path: "/sites/{siteId}/bookings/event-offerings/{eventOfferingId}/combination-prices",
|
|
1988
2029
|
method: "GET",
|
|
@@ -2862,15 +2903,6 @@ const PUBLIC_EVENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
2862
2903
|
"resource:conflict",
|
|
2863
2904
|
"server:internal_error"
|
|
2864
2905
|
]
|
|
2865
|
-
},
|
|
2866
|
-
resolveEventSubroute: {
|
|
2867
|
-
path: "/public/sites/{siteId}/events/subroutes/resolve",
|
|
2868
|
-
method: "GET",
|
|
2869
|
-
revalidate: publicReadFreshnessSeconds("resolveEventSubroute"),
|
|
2870
|
-
tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
|
|
2871
|
-
auth: "public",
|
|
2872
|
-
responseKind: "json",
|
|
2873
|
-
errors: []
|
|
2874
2906
|
}
|
|
2875
2907
|
});
|
|
2876
2908
|
//#endregion
|
|
@@ -4324,52 +4356,6 @@ const BOOKING_PEOPLE_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
4324
4356
|
]
|
|
4325
4357
|
}
|
|
4326
4358
|
});
|
|
4327
|
-
//#endregion
|
|
4328
|
-
//#region ../api/src/clientErrorReporting.ts
|
|
4329
|
-
const CLIENT_ERROR_REPORT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({ reportClientError: {
|
|
4330
|
-
path: "/client/error-report",
|
|
4331
|
-
method: "POST",
|
|
4332
|
-
auth: "user",
|
|
4333
|
-
errors: [],
|
|
4334
|
-
responseKind: "json"
|
|
4335
|
-
} });
|
|
4336
|
-
const CLIENT_ERROR_REPORT_LIMITS = {
|
|
4337
|
-
pathname: 1024,
|
|
4338
|
-
name: 120,
|
|
4339
|
-
message: 2e3,
|
|
4340
|
-
stack: 8e3,
|
|
4341
|
-
digest: 128,
|
|
4342
|
-
componentStack: 8e3,
|
|
4343
|
-
sourceLocation: 1024,
|
|
4344
|
-
navigationAgeMs: 6e4
|
|
4345
|
-
};
|
|
4346
|
-
const clientErrorEventSchema = z.enum([
|
|
4347
|
-
"dashboard:route-error",
|
|
4348
|
-
"dashboard:app-error",
|
|
4349
|
-
"client:error-boundary",
|
|
4350
|
-
"client:window-error",
|
|
4351
|
-
"client:unhandled-rejection"
|
|
4352
|
-
]);
|
|
4353
|
-
z.object({
|
|
4354
|
-
event: clientErrorEventSchema,
|
|
4355
|
-
pathname: z.string().startsWith("/").max(CLIENT_ERROR_REPORT_LIMITS.pathname),
|
|
4356
|
-
name: z.string().max(CLIENT_ERROR_REPORT_LIMITS.name),
|
|
4357
|
-
message: z.string().max(CLIENT_ERROR_REPORT_LIMITS.message),
|
|
4358
|
-
stack: z.string().max(CLIENT_ERROR_REPORT_LIMITS.stack).nullable(),
|
|
4359
|
-
digest: z.string().max(CLIENT_ERROR_REPORT_LIMITS.digest).nullable(),
|
|
4360
|
-
componentStack: z.string().max(CLIENT_ERROR_REPORT_LIMITS.componentStack).nullable(),
|
|
4361
|
-
sourceLocation: z.string().max(CLIENT_ERROR_REPORT_LIMITS.sourceLocation).nullable(),
|
|
4362
|
-
navigation: z.object({
|
|
4363
|
-
fromPathname: z.string().regex(/^\/[^?#]*$/).max(CLIENT_ERROR_REPORT_LIMITS.pathname),
|
|
4364
|
-
toPathname: z.string().regex(/^\/[^?#]*$/).max(CLIENT_ERROR_REPORT_LIMITS.pathname),
|
|
4365
|
-
type: z.enum([
|
|
4366
|
-
"push",
|
|
4367
|
-
"replace",
|
|
4368
|
-
"traverse"
|
|
4369
|
-
]),
|
|
4370
|
-
ageMs: z.number().int().min(0).max(CLIENT_ERROR_REPORT_LIMITS.navigationAgeMs)
|
|
4371
|
-
}).strict().nullable().optional()
|
|
4372
|
-
}).strict();
|
|
4373
4359
|
const API_ENDPOINTS$1 = {
|
|
4374
4360
|
...PAGE_SECTION_LOOK_ENDPOINT_DEFINITIONS,
|
|
4375
4361
|
...PAGE_JOURNAL_ENDPOINT_DEFINITIONS,
|
|
@@ -6076,6 +6062,14 @@ const API_ENDPOINTS$1 = {
|
|
|
6076
6062
|
responseKind: "json",
|
|
6077
6063
|
errors: []
|
|
6078
6064
|
},
|
|
6065
|
+
adminDeleteSupportTicketScreenshot: {
|
|
6066
|
+
path: "/admin/support/tickets/screenshot/delete",
|
|
6067
|
+
method: "POST",
|
|
6068
|
+
tags: ["admin", "support"],
|
|
6069
|
+
auth: "admin",
|
|
6070
|
+
responseKind: "json",
|
|
6071
|
+
errors: []
|
|
6072
|
+
},
|
|
6079
6073
|
mfaTotpEnroll: {
|
|
6080
6074
|
path: "/auth/mfa/totp/enroll",
|
|
6081
6075
|
method: "POST",
|
|
@@ -7077,6 +7071,7 @@ const API_ENDPOINTS$1 = {
|
|
|
7077
7071
|
responseKind: "json"
|
|
7078
7072
|
},
|
|
7079
7073
|
resolveRouteOutcome: {
|
|
7074
|
+
revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
|
|
7080
7075
|
path: "/sites/{siteId}/route-outcome",
|
|
7081
7076
|
method: "GET",
|
|
7082
7077
|
tags: [
|
|
@@ -8004,6 +7999,25 @@ const API_ENDPOINTS$1 = {
|
|
|
8004
7999
|
"bookings"
|
|
8005
8000
|
]
|
|
8006
8001
|
},
|
|
8002
|
+
listEventBookingTicketChoices: {
|
|
8003
|
+
errors: [],
|
|
8004
|
+
path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/ticket-choices",
|
|
8005
|
+
method: "GET",
|
|
8006
|
+
auth: "user",
|
|
8007
|
+
responseKind: "json"
|
|
8008
|
+
},
|
|
8009
|
+
changeEventBookingTickets: {
|
|
8010
|
+
errors: [],
|
|
8011
|
+
path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/change-tickets",
|
|
8012
|
+
method: "POST",
|
|
8013
|
+
auth: "user",
|
|
8014
|
+
responseKind: "json",
|
|
8015
|
+
tags: [
|
|
8016
|
+
"site-{siteId}",
|
|
8017
|
+
"event-attendee-{attendeeId}",
|
|
8018
|
+
"bookings"
|
|
8019
|
+
]
|
|
8020
|
+
},
|
|
8007
8021
|
restoreEventBooking: {
|
|
8008
8022
|
errors: [],
|
|
8009
8023
|
path: "/sites/{siteId}/bookings/event-attendees/{attendeeId}/restore",
|
|
@@ -9893,6 +9907,27 @@ const API_ENDPOINTS$1 = {
|
|
|
9893
9907
|
responseKind: "json",
|
|
9894
9908
|
errors: []
|
|
9895
9909
|
},
|
|
9910
|
+
portalEntryPreview: {
|
|
9911
|
+
path: "/portal/auth/entry/preview",
|
|
9912
|
+
method: "POST",
|
|
9913
|
+
auth: "public",
|
|
9914
|
+
responseKind: "json",
|
|
9915
|
+
errors: []
|
|
9916
|
+
},
|
|
9917
|
+
portalEntryRedeem: {
|
|
9918
|
+
path: "/portal/auth/entry/redeem",
|
|
9919
|
+
method: "POST",
|
|
9920
|
+
auth: "public",
|
|
9921
|
+
responseKind: "json",
|
|
9922
|
+
errors: []
|
|
9923
|
+
},
|
|
9924
|
+
portalEntryResend: {
|
|
9925
|
+
path: "/portal/auth/entry/resend",
|
|
9926
|
+
method: "POST",
|
|
9927
|
+
auth: "public",
|
|
9928
|
+
responseKind: "json",
|
|
9929
|
+
errors: []
|
|
9930
|
+
},
|
|
9896
9931
|
portalLogout: {
|
|
9897
9932
|
path: "/portal/auth/logout",
|
|
9898
9933
|
method: "POST",
|
|
@@ -10037,147 +10072,6 @@ const API_ENDPOINTS$1 = {
|
|
|
10037
10072
|
}
|
|
10038
10073
|
};
|
|
10039
10074
|
//#endregion
|
|
10040
|
-
//#region ../api/src/common/capacityOverride.ts
|
|
10041
|
-
const capacityOverrideRefusalSchema = z.object({
|
|
10042
|
-
booked: z.number().int().nonnegative(),
|
|
10043
|
-
held: z.number().int().nonnegative(),
|
|
10044
|
-
capacity: z.number().int().nonnegative(),
|
|
10045
|
-
name: z.string(),
|
|
10046
|
-
retryPersonId: z.string().optional()
|
|
10047
|
-
});
|
|
10048
|
-
function isCapacityOverrideRefusal(value) {
|
|
10049
|
-
return capacityOverrideRefusalSchema.safeParse(value).success;
|
|
10050
|
-
}
|
|
10051
|
-
const API_ERROR_CODE_SET = /* @__PURE__ */ new Set([
|
|
10052
|
-
"auth:unauthenticated",
|
|
10053
|
-
"auth:token_expired",
|
|
10054
|
-
"auth:token_invalid",
|
|
10055
|
-
"auth:forbidden",
|
|
10056
|
-
"auth:mfa_required",
|
|
10057
|
-
"auth:mfa_setup_required",
|
|
10058
|
-
"auth:sudo_required",
|
|
10059
|
-
"auth:insufficient_permissions",
|
|
10060
|
-
"auth:impersonation_restricted",
|
|
10061
|
-
"auth:lease_required",
|
|
10062
|
-
"auth:lease_lost",
|
|
10063
|
-
"client:editing_held",
|
|
10064
|
-
"site_terms_changed",
|
|
10065
|
-
"site_terms_agreement_missing",
|
|
10066
|
-
"validation:invalid_input",
|
|
10067
|
-
"validation:missing_field",
|
|
10068
|
-
"validation:invalid_format",
|
|
10069
|
-
"validation:payload_too_large",
|
|
10070
|
-
"resource:not_found",
|
|
10071
|
-
"resource:already_exists",
|
|
10072
|
-
"resource:conflict",
|
|
10073
|
-
"resource:gone",
|
|
10074
|
-
"rate_limit:exceeded",
|
|
10075
|
-
"billing:payment_required",
|
|
10076
|
-
"billing:plan_limit_exceeded",
|
|
10077
|
-
"billing:pass_redemption_failed",
|
|
10078
|
-
"server:internal_error",
|
|
10079
|
-
"server:unavailable",
|
|
10080
|
-
"external:service_error",
|
|
10081
|
-
"external:registrar_orphaned_contact_profile",
|
|
10082
|
-
"network:connection_error",
|
|
10083
|
-
"network:timeout",
|
|
10084
|
-
"network:dns_error"
|
|
10085
|
-
]);
|
|
10086
|
-
function isApiErrorCode(value) {
|
|
10087
|
-
return typeof value === "string" && API_ERROR_CODE_SET.has(value);
|
|
10088
|
-
}
|
|
10089
|
-
function isApiError(result) {
|
|
10090
|
-
return result.success === false;
|
|
10091
|
-
}
|
|
10092
|
-
function isApiSuccess(result) {
|
|
10093
|
-
return result.success === true;
|
|
10094
|
-
}
|
|
10095
|
-
function isRecord(value) {
|
|
10096
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10097
|
-
}
|
|
10098
|
-
function isFieldError(value) {
|
|
10099
|
-
return isRecord(value) && typeof value.field === "string" && typeof value.code === "string" && typeof value.message === "string" && (value.capacityOverride === void 0 || isCapacityOverrideRefusal(value.capacityOverride));
|
|
10100
|
-
}
|
|
10101
|
-
function fieldErrorsFromUnknown(value) {
|
|
10102
|
-
if (!Array.isArray(value)) return null;
|
|
10103
|
-
return value.every(isFieldError) ? value : null;
|
|
10104
|
-
}
|
|
10105
|
-
function extractEnvelopeErrorObject(body) {
|
|
10106
|
-
if (!isRecord(body)) return null;
|
|
10107
|
-
const error = body.error;
|
|
10108
|
-
if (!isRecord(error)) return null;
|
|
10109
|
-
if ("success" in body && body.success !== false) return null;
|
|
10110
|
-
return error;
|
|
10111
|
-
}
|
|
10112
|
-
function extractApiEnvelopeErrorDetails(body) {
|
|
10113
|
-
const error = extractEnvelopeErrorObject(body);
|
|
10114
|
-
if (!error) return {
|
|
10115
|
-
rawCode: null,
|
|
10116
|
-
code: null,
|
|
10117
|
-
tag: null,
|
|
10118
|
-
message: null,
|
|
10119
|
-
status: null,
|
|
10120
|
-
fieldErrors: null
|
|
10121
|
-
};
|
|
10122
|
-
const rawCode = typeof error.code === "string" ? error.code : null;
|
|
10123
|
-
const message = typeof error.message === "string" && error.message.trim().length > 0 ? error.message : null;
|
|
10124
|
-
return {
|
|
10125
|
-
rawCode,
|
|
10126
|
-
code: isApiErrorCode(rawCode) ? rawCode : null,
|
|
10127
|
-
tag: typeof error.tag === "string" ? error.tag : null,
|
|
10128
|
-
message,
|
|
10129
|
-
status: typeof error.status === "number" && Number.isFinite(error.status) ? error.status : null,
|
|
10130
|
-
fieldErrors: fieldErrorsFromUnknown(error.fieldErrors)
|
|
10131
|
-
};
|
|
10132
|
-
}
|
|
10133
|
-
/**
|
|
10134
|
-
* Error class for API failures that can be thrown from unwrapResponse.
|
|
10135
|
-
* Preserves all error metadata from the envelope.
|
|
10136
|
-
*/
|
|
10137
|
-
var ApiEnvelopeError = class extends Error {
|
|
10138
|
-
constructor(error) {
|
|
10139
|
-
super(error.message);
|
|
10140
|
-
this.name = "ApiEnvelopeError";
|
|
10141
|
-
this.code = error.code;
|
|
10142
|
-
this.requestId = error.requestId;
|
|
10143
|
-
this.timestamp = error.timestamp;
|
|
10144
|
-
this.status = error.status;
|
|
10145
|
-
this.tag = error.tag;
|
|
10146
|
-
this.fieldErrors = error.fieldErrors;
|
|
10147
|
-
}
|
|
10148
|
-
};
|
|
10149
|
-
/**
|
|
10150
|
-
* Unwrap a successful API response or throw on error.
|
|
10151
|
-
*
|
|
10152
|
-
* @example
|
|
10153
|
-
* ```typescript
|
|
10154
|
-
* const response = await apiClient({ endpoint: 'getUser', params: { id } });
|
|
10155
|
-
* const user = unwrapResponse(response); // Throws if not success
|
|
10156
|
-
* ```
|
|
10157
|
-
*/
|
|
10158
|
-
function unwrapResponse(result) {
|
|
10159
|
-
if (isApiSuccess(result)) return result.data;
|
|
10160
|
-
throw new ApiEnvelopeError(result.error);
|
|
10161
|
-
}
|
|
10162
|
-
//#endregion
|
|
10163
|
-
//#region ../api/src/request-error.ts
|
|
10164
|
-
var ApiRequestError = class extends Error {
|
|
10165
|
-
constructor(message, options) {
|
|
10166
|
-
super(message);
|
|
10167
|
-
this.name = "ApiRequestError";
|
|
10168
|
-
this.endpoint = options.endpoint;
|
|
10169
|
-
this.status = options.status;
|
|
10170
|
-
this.method = options.method;
|
|
10171
|
-
this.auth = options.auth;
|
|
10172
|
-
this.requestId = options.requestId;
|
|
10173
|
-
this.body = options.body;
|
|
10174
|
-
this.cause = options.cause;
|
|
10175
|
-
this.errorCode = options.errorCode;
|
|
10176
|
-
this.tag = options.tag;
|
|
10177
|
-
this.retryAfterMs = options.retryAfterMs;
|
|
10178
|
-
}
|
|
10179
|
-
};
|
|
10180
|
-
//#endregion
|
|
10181
10075
|
//#region ../api/src/url.ts
|
|
10182
10076
|
function looksLikeLocalAuthority(authority) {
|
|
10183
10077
|
const normalized = authority.toLowerCase();
|
|
@@ -10229,6 +10123,163 @@ function resolveApiBaseUrl() {
|
|
|
10229
10123
|
return getCmsApiUrl();
|
|
10230
10124
|
}
|
|
10231
10125
|
//#endregion
|
|
10126
|
+
//#region ../api/src/pageReadResponseCache.ts
|
|
10127
|
+
var CacheProbeMiss = class extends Error {};
|
|
10128
|
+
/** Next has no response-dependent fetch TTL. Only the matching policy may store a page read. */
|
|
10129
|
+
var UncachedPageRead = class extends Error {
|
|
10130
|
+
constructor(snapshot) {
|
|
10131
|
+
super("Page read belongs to another cache policy");
|
|
10132
|
+
this.snapshot = snapshot;
|
|
10133
|
+
}
|
|
10134
|
+
};
|
|
10135
|
+
function isRecord(value) {
|
|
10136
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10137
|
+
}
|
|
10138
|
+
function isResolvedPage(page) {
|
|
10139
|
+
return page?.kind === "resolved" && typeof page.requestedPath === "string" && (page.dependencies === "content" || page.dependencies === "availability") && isRecord(page.result) && [
|
|
10140
|
+
"cms",
|
|
10141
|
+
"system_event",
|
|
10142
|
+
"system_service"
|
|
10143
|
+
].includes(String(page.result.kind));
|
|
10144
|
+
}
|
|
10145
|
+
function envelopePage(body) {
|
|
10146
|
+
const data = isRecord(body) && body.success === true && isRecord(body.data) ? body.data : null;
|
|
10147
|
+
return data?.type === "content" && isRecord(data.content) ? data.content : data;
|
|
10148
|
+
}
|
|
10149
|
+
function admit(snapshot) {
|
|
10150
|
+
try {
|
|
10151
|
+
const page = envelopePage(JSON.parse(snapshot.body));
|
|
10152
|
+
if (snapshot.status === 200 && isResolvedPage(page)) return {
|
|
10153
|
+
resolved: true,
|
|
10154
|
+
dependencies: page.dependencies
|
|
10155
|
+
};
|
|
10156
|
+
} catch {}
|
|
10157
|
+
return {
|
|
10158
|
+
resolved: false,
|
|
10159
|
+
dependencies: snapshot.status === 200 || snapshot.headers.some(([key, value]) => key === "x-riverbank-page-dependencies" && value === "availability") ? "availability" : "content"
|
|
10160
|
+
};
|
|
10161
|
+
}
|
|
10162
|
+
/** A scoped transport read is shared with Next's background refresh, never across requests. */
|
|
10163
|
+
function liveResponse(read) {
|
|
10164
|
+
const pending = /* @__PURE__ */ new Map();
|
|
10165
|
+
return () => {
|
|
10166
|
+
const existing = pending.get("response");
|
|
10167
|
+
if (existing) return existing;
|
|
10168
|
+
const response = read().then(async (value) => ({
|
|
10169
|
+
body: await value.text(),
|
|
10170
|
+
status: value.status,
|
|
10171
|
+
headers: [...value.headers.entries()],
|
|
10172
|
+
cachedAt: Date.now()
|
|
10173
|
+
}));
|
|
10174
|
+
pending.set("response", response);
|
|
10175
|
+
return response;
|
|
10176
|
+
};
|
|
10177
|
+
}
|
|
10178
|
+
/** Neutral probes do not register a policy; the chosen entry is then checked with its real tags. */
|
|
10179
|
+
async function readPolicy(input, probe = false) {
|
|
10180
|
+
const policy = buildPageReadCachePolicy(input.siteId, input.dependency);
|
|
10181
|
+
const revalidate = Math.min(policy.revalidate, input.maxAge ?? policy.revalidate);
|
|
10182
|
+
const snapshot = await input.cache(async () => {
|
|
10183
|
+
const snapshot = await input.read();
|
|
10184
|
+
const admission = admit(snapshot);
|
|
10185
|
+
if (!admission.resolved || admission.dependencies !== input.dependency) throw new UncachedPageRead(snapshot);
|
|
10186
|
+
return snapshot;
|
|
10187
|
+
}, [
|
|
10188
|
+
"page-read-envelope-v2",
|
|
10189
|
+
input.key,
|
|
10190
|
+
input.dependency
|
|
10191
|
+
], probe ? {
|
|
10192
|
+
revalidate: false,
|
|
10193
|
+
tags: []
|
|
10194
|
+
} : {
|
|
10195
|
+
...policy,
|
|
10196
|
+
revalidate
|
|
10197
|
+
})();
|
|
10198
|
+
if (Date.now() - snapshot.cachedAt < revalidate * 1e3) return snapshot;
|
|
10199
|
+
return probe ? null : input.read();
|
|
10200
|
+
}
|
|
10201
|
+
async function probePolicy(input) {
|
|
10202
|
+
return readPolicy({
|
|
10203
|
+
...input,
|
|
10204
|
+
read: async () => {
|
|
10205
|
+
throw new CacheProbeMiss();
|
|
10206
|
+
}
|
|
10207
|
+
}, true).catch((error) => {
|
|
10208
|
+
if (error instanceof CacheProbeMiss) return null;
|
|
10209
|
+
throw error;
|
|
10210
|
+
});
|
|
10211
|
+
}
|
|
10212
|
+
/** Read in a framework cache scope, but never store an unclassified or failed response. */
|
|
10213
|
+
async function readInCacheScope(cache, key, read) {
|
|
10214
|
+
try {
|
|
10215
|
+
return await cache(async () => {
|
|
10216
|
+
throw new UncachedPageRead(await read());
|
|
10217
|
+
}, ["page-read-live-v2", key], {
|
|
10218
|
+
revalidate: false,
|
|
10219
|
+
tags: []
|
|
10220
|
+
})();
|
|
10221
|
+
} catch (error) {
|
|
10222
|
+
if (error instanceof UncachedPageRead) return error.snapshot;
|
|
10223
|
+
throw error;
|
|
10224
|
+
}
|
|
10225
|
+
}
|
|
10226
|
+
async function selectResponse(input) {
|
|
10227
|
+
const candidate = await probePolicy({
|
|
10228
|
+
...input,
|
|
10229
|
+
dependency: "content"
|
|
10230
|
+
}) ?? await probePolicy({
|
|
10231
|
+
...input,
|
|
10232
|
+
dependency: "availability"
|
|
10233
|
+
});
|
|
10234
|
+
if (candidate) try {
|
|
10235
|
+
const checked = await readPolicy({
|
|
10236
|
+
...input,
|
|
10237
|
+
dependency: admit(candidate).dependencies
|
|
10238
|
+
});
|
|
10239
|
+
if (checked) return checked;
|
|
10240
|
+
} catch (error) {
|
|
10241
|
+
if (error instanceof UncachedPageRead) return storeResponse(input, error.snapshot);
|
|
10242
|
+
throw error;
|
|
10243
|
+
}
|
|
10244
|
+
return storeResponse(input, await readInCacheScope(input.cache, input.key, input.read));
|
|
10245
|
+
}
|
|
10246
|
+
async function storeResponse(input, snapshot) {
|
|
10247
|
+
const admission = admit(snapshot);
|
|
10248
|
+
try {
|
|
10249
|
+
return await readPolicy({
|
|
10250
|
+
...input,
|
|
10251
|
+
key: admission.resolved ? input.key : `${input.key}:refusal:${snapshot.status}`,
|
|
10252
|
+
dependency: admission.dependencies,
|
|
10253
|
+
read: async () => snapshot
|
|
10254
|
+
}) ?? snapshot;
|
|
10255
|
+
} catch (error) {
|
|
10256
|
+
if (error instanceof UncachedPageRead) return error.snapshot;
|
|
10257
|
+
throw error;
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
10260
|
+
async function cachePageReadResponse(input) {
|
|
10261
|
+
if (!input.cache) return input.read();
|
|
10262
|
+
const result = await selectResponse({
|
|
10263
|
+
...input,
|
|
10264
|
+
cache: input.cache,
|
|
10265
|
+
read: liveResponse(input.read)
|
|
10266
|
+
});
|
|
10267
|
+
return new Response(result.body, {
|
|
10268
|
+
status: result.status,
|
|
10269
|
+
headers: result.headers
|
|
10270
|
+
});
|
|
10271
|
+
}
|
|
10272
|
+
/** Result adapters use this for cache fallbacks that did not return through the HTTP transport. */
|
|
10273
|
+
async function observePageReadPolicy(cache, siteId, payload) {
|
|
10274
|
+
if (!cache) return;
|
|
10275
|
+
const dependency = pageReadDependencies(payload);
|
|
10276
|
+
await cache(async () => true, [
|
|
10277
|
+
"page-read-policy-v2",
|
|
10278
|
+
siteId,
|
|
10279
|
+
dependency
|
|
10280
|
+
], buildPageReadCachePolicy(siteId, dependency))();
|
|
10281
|
+
}
|
|
10282
|
+
//#endregion
|
|
10232
10283
|
//#region ../api/src/common/operationId.ts
|
|
10233
10284
|
const OPERATION_ID_HEADER = "X-Riverbank-Operation-Id";
|
|
10234
10285
|
z.uuid();
|
|
@@ -10299,18 +10350,9 @@ z.enum([
|
|
|
10299
10350
|
]);
|
|
10300
10351
|
//#endregion
|
|
10301
10352
|
//#region ../api/src/request.ts
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
if (revalidateTagResolved) return revalidateTag;
|
|
10306
|
-
revalidateTagResolved = true;
|
|
10307
|
-
if (typeof window !== "undefined") return null;
|
|
10308
|
-
try {
|
|
10309
|
-
revalidateTag = new Function("modulePath", "return require(modulePath)")("next/cache").revalidateTag ?? null;
|
|
10310
|
-
} catch {
|
|
10311
|
-
revalidateTag = null;
|
|
10312
|
-
}
|
|
10313
|
-
return revalidateTag;
|
|
10353
|
+
/** Preserve the returned dependency even when the SDK served a durable fallback. */
|
|
10354
|
+
function observePageReadResponse(adapter, siteId, payload) {
|
|
10355
|
+
return observePageReadPolicy(adapter?.cache ?? null, siteId, payload);
|
|
10314
10356
|
}
|
|
10315
10357
|
/**
|
|
10316
10358
|
* Generate a UUID, with fallback for environments where crypto.randomUUID isn't available.
|
|
@@ -10400,8 +10442,8 @@ function serializePathParam(endpoint, key, value) {
|
|
|
10400
10442
|
if (typeof value === "string") return value;
|
|
10401
10443
|
throw new Error(`Invalid path param for endpoint ${String(endpoint)}: ${key} must be a string`);
|
|
10402
10444
|
}
|
|
10403
|
-
function invalidateCacheTags(tags, params) {
|
|
10404
|
-
const resolved =
|
|
10445
|
+
function invalidateCacheTags(adapter, tags, params) {
|
|
10446
|
+
const resolved = adapter?.invalidateTag;
|
|
10405
10447
|
if (typeof window !== "undefined" || !resolved || !tags) return;
|
|
10406
10448
|
tags.forEach((tag) => {
|
|
10407
10449
|
let processedTag = tag;
|
|
@@ -10409,7 +10451,7 @@ function invalidateCacheTags(tags, params) {
|
|
|
10409
10451
|
processedTag = processedTag.replace(`{${key}}`, String(value));
|
|
10410
10452
|
});
|
|
10411
10453
|
try {
|
|
10412
|
-
resolved(processedTag
|
|
10454
|
+
resolved(processedTag);
|
|
10413
10455
|
} catch {}
|
|
10414
10456
|
});
|
|
10415
10457
|
}
|
|
@@ -10502,7 +10544,7 @@ function successJsonEnvelope(parsed, requestId) {
|
|
|
10502
10544
|
if (parsed && typeof parsed === "object" && "success" in parsed && typeof parsed.success === "boolean") return parsed;
|
|
10503
10545
|
return buildSuccessEnvelope(coerceResponse(parsed), requestId);
|
|
10504
10546
|
}
|
|
10505
|
-
function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersion } = {}) {
|
|
10547
|
+
function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersion, frameworkCache } = {}) {
|
|
10506
10548
|
return ({ endpoint, body, params, options = {} }) => {
|
|
10507
10549
|
const plan = buildApiRequestPlan({
|
|
10508
10550
|
endpoint,
|
|
@@ -10516,14 +10558,31 @@ function createApiResponseTransport(getHeaders = () => ({}), baseUrl, { sdkVersi
|
|
|
10516
10558
|
baseUrl: normalizeCmsApiBaseUrl(baseUrl ?? resolveApiBaseUrl()),
|
|
10517
10559
|
sdkVersion
|
|
10518
10560
|
});
|
|
10519
|
-
const fetchPromise =
|
|
10561
|
+
const fetchPromise = executeApiRequest(plan, endpoint, params, options, frameworkCache);
|
|
10520
10562
|
if (plan.cacheInvalidationTags) return fetchPromise.then((response) => {
|
|
10521
|
-
if (response.ok) invalidateCacheTags(plan.cacheInvalidationTags, params);
|
|
10563
|
+
if (response.ok) invalidateCacheTags(frameworkCache, plan.cacheInvalidationTags, params);
|
|
10522
10564
|
return response;
|
|
10523
10565
|
});
|
|
10524
10566
|
return fetchPromise;
|
|
10525
10567
|
};
|
|
10526
10568
|
}
|
|
10569
|
+
function isPublishedPageRead(endpoint, params, options) {
|
|
10570
|
+
return (endpoint === "getContentByPath" || endpoint === "resolveRouteOutcome") && params?.preview !== true && params?.preview !== "true" && options.cache !== "no-store";
|
|
10571
|
+
}
|
|
10572
|
+
function executeApiRequest(plan, endpoint, params, options, frameworkCache) {
|
|
10573
|
+
const inputParams = params;
|
|
10574
|
+
const { next: fetchPolicy, ...uncachedInit } = plan.init;
|
|
10575
|
+
return isPublishedPageRead(endpoint, inputParams, options) ? cachePageReadResponse({
|
|
10576
|
+
cache: frameworkCache?.cache ?? null,
|
|
10577
|
+
key: JSON.stringify([plan.url, [...new Headers(plan.init.headers).entries()]]),
|
|
10578
|
+
siteId: typeof inputParams?.siteId === "string" ? inputParams.siteId : "",
|
|
10579
|
+
maxAge: typeof fetchPolicy?.revalidate === "number" ? fetchPolicy.revalidate : void 0,
|
|
10580
|
+
read: () => fetch(plan.url, {
|
|
10581
|
+
...uncachedInit,
|
|
10582
|
+
cache: "no-store"
|
|
10583
|
+
})
|
|
10584
|
+
}) : fetch(plan.url, plan.init);
|
|
10585
|
+
}
|
|
10527
10586
|
const batchReadPolicyBodySchema = z.object({ requests: z.array(z.object({
|
|
10528
10587
|
endpoint: z.string(),
|
|
10529
10588
|
params: z.record(z.string(), z.unknown()).optional()
|
|
@@ -10557,10 +10616,12 @@ function batchReadRequestOptions(params, body, options) {
|
|
|
10557
10616
|
function publicReadRequestOptions(endpoint, params, body, options) {
|
|
10558
10617
|
if (endpoint === "batchBlockLoaders") return batchReadRequestOptions(params, body, options);
|
|
10559
10618
|
const preview = params?.preview === true || params?.preview === "true";
|
|
10560
|
-
|
|
10619
|
+
if (endpoint !== "getContentByPath" && endpoint !== "resolveRouteOutcome") return options;
|
|
10620
|
+
if (preview) return {
|
|
10561
10621
|
...options,
|
|
10562
10622
|
cache: "no-store"
|
|
10563
|
-
}
|
|
10623
|
+
};
|
|
10624
|
+
return options;
|
|
10564
10625
|
}
|
|
10565
10626
|
function assertResolvedEndpointPath(endpoint, url) {
|
|
10566
10627
|
const tokens = [...url.match(/\{[^}]+\}/g) ?? [], ...url.match(/(^|\/):([A-Za-z][A-Za-z0-9_]*)\b/g) ?? []];
|
|
@@ -10663,653 +10724,183 @@ function requireUsableCommitProjection(response, parsed) {
|
|
|
10663
10724
|
throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
|
|
10664
10725
|
}
|
|
10665
10726
|
//#endregion
|
|
10666
|
-
//#region src/
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10727
|
+
//#region ../site-renderer/src/runtimeResponse.ts
|
|
10728
|
+
/** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
|
|
10729
|
+
function restoreRuntimeResponse(serialized) {
|
|
10730
|
+
return parseSurfaceTree(serialized);
|
|
10731
|
+
}
|
|
10732
|
+
//#endregion
|
|
10733
|
+
//#region ../site-renderer/src/runtimeClient.ts
|
|
10734
|
+
/** Only a client that reconstructs surfaces advertises revision transport. */
|
|
10735
|
+
function createRuntimeApiClient(transport) {
|
|
10736
|
+
const revisionTransport = (request) => transport({
|
|
10737
|
+
...request,
|
|
10738
|
+
...request.endpoint === "getContentByPath" ? { params: {
|
|
10739
|
+
...request.params,
|
|
10740
|
+
surfaceTransport: "revision-v1"
|
|
10741
|
+
} } : {}
|
|
10742
|
+
});
|
|
10743
|
+
return createParsedApiClient(revisionTransport, {
|
|
10744
|
+
representation: "restored",
|
|
10745
|
+
decode: restoreRuntimeResponse
|
|
10746
|
+
});
|
|
10747
|
+
}
|
|
10748
|
+
function createRuntimeInternalAPIClient(baseUrl, options) {
|
|
10749
|
+
return createRuntimeApiClient(createApiResponseTransport(() => ({}), baseUrl, options));
|
|
10750
|
+
}
|
|
10751
|
+
function createRuntimeBearerAPIClient(token, baseUrl, options) {
|
|
10752
|
+
return createRuntimeApiClient(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
|
|
10753
|
+
}
|
|
10754
|
+
//#endregion
|
|
10755
|
+
//#region src/client/entryListReadRequest.ts
|
|
10756
|
+
const entryOrder = {
|
|
10757
|
+
newest: "published_at.desc",
|
|
10758
|
+
oldest: "published_at.asc",
|
|
10759
|
+
title: "title.asc",
|
|
10760
|
+
manual: "manual.asc"
|
|
10761
|
+
};
|
|
10762
|
+
function entrySelection(input) {
|
|
10763
|
+
return input.mode === "manual" && input.entryIds?.length ? {
|
|
10764
|
+
keyPart: input.entryIds.join(","),
|
|
10765
|
+
params: {
|
|
10766
|
+
mode: "manual",
|
|
10767
|
+
entryIds: JSON.stringify(input.entryIds)
|
|
10768
|
+
}
|
|
10769
|
+
} : {
|
|
10770
|
+
keyPart: "",
|
|
10771
|
+
params: {}
|
|
10772
|
+
};
|
|
10773
|
+
}
|
|
10774
|
+
function entryListMemoryKey(input, selection) {
|
|
10775
|
+
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
10776
|
+
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
10777
|
+
}
|
|
10778
|
+
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
10779
|
+
function buildEntryListReadRequest(input) {
|
|
10780
|
+
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
10781
|
+
const selection = entrySelection(input);
|
|
10782
|
+
const orderParam = order ? entryOrder[order] : void 0;
|
|
10783
|
+
return {
|
|
10784
|
+
cacheKey: entryListMemoryKey(input, selection),
|
|
10785
|
+
params: {
|
|
10786
|
+
siteId,
|
|
10787
|
+
type: contentType,
|
|
10788
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
10789
|
+
...typeof offset === "number" && { offset: String(offset) },
|
|
10790
|
+
...includeMeta && { meta: "true" },
|
|
10791
|
+
...orderParam && { order: orderParam },
|
|
10792
|
+
...preview && { stage: "preview" },
|
|
10793
|
+
...selection.params
|
|
10794
|
+
}
|
|
10795
|
+
};
|
|
10796
|
+
}
|
|
10797
|
+
//#endregion
|
|
10798
|
+
//#region src/client/cache.ts
|
|
10799
|
+
var SimpleCache = class {
|
|
10800
|
+
constructor(options = {}) {
|
|
10801
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
10802
|
+
this.maxSize = options.maxSize ?? 100;
|
|
10803
|
+
this.ttl = options.ttl ?? 3e5;
|
|
10804
|
+
this.staleTtl = options.staleTtl ?? 3e5;
|
|
10714
10805
|
}
|
|
10715
10806
|
/**
|
|
10716
|
-
*
|
|
10717
|
-
*
|
|
10718
|
-
* - 429 (rate limit): retryable
|
|
10719
|
-
* - 5xx (server errors): retryable
|
|
10720
|
-
* - 4xx (client errors, except 429): NOT retryable
|
|
10807
|
+
* Get a fresh value (within TTL)
|
|
10808
|
+
* @returns The value if fresh, null otherwise
|
|
10721
10809
|
*/
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
if (
|
|
10725
|
-
if (
|
|
10726
|
-
return
|
|
10810
|
+
getFresh(key) {
|
|
10811
|
+
const entry = this.cache.get(key);
|
|
10812
|
+
if (!entry) return null;
|
|
10813
|
+
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
10814
|
+
return null;
|
|
10727
10815
|
}
|
|
10728
10816
|
/**
|
|
10729
|
-
*
|
|
10730
|
-
*
|
|
10731
|
-
* Matches: network:connection_error, network:timeout, network:dns_error
|
|
10817
|
+
* Get a value that may be stale (past TTL but within staleTtl)
|
|
10818
|
+
* @returns Object with value and stale age, or null if expired
|
|
10732
10819
|
*/
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
is(code) {
|
|
10747
|
-
return this.code === code;
|
|
10748
|
-
}
|
|
10749
|
-
/**
|
|
10750
|
-
* Check if this is an authentication or authorization error
|
|
10751
|
-
*
|
|
10752
|
-
* Matches: auth:unauthenticated, auth:token_expired, auth:token_invalid,
|
|
10753
|
-
* auth:forbidden, auth:mfa_required, auth:insufficient_permissions
|
|
10754
|
-
*/
|
|
10755
|
-
isAuthError() {
|
|
10756
|
-
return this.code.startsWith("auth:");
|
|
10757
|
-
}
|
|
10758
|
-
/**
|
|
10759
|
-
* Check if this is a validation error
|
|
10760
|
-
*
|
|
10761
|
-
* Matches: validation:invalid_input, validation:missing_field, validation:invalid_format
|
|
10762
|
-
*/
|
|
10763
|
-
isValidationError() {
|
|
10764
|
-
return this.code.startsWith("validation:");
|
|
10765
|
-
}
|
|
10766
|
-
/**
|
|
10767
|
-
* Check if this is a resource error (not found, conflict, etc.)
|
|
10768
|
-
*
|
|
10769
|
-
* Matches: resource:not_found, resource:already_exists, resource:conflict, resource:gone
|
|
10770
|
-
*/
|
|
10771
|
-
isResourceError() {
|
|
10772
|
-
return this.code.startsWith("resource:");
|
|
10820
|
+
getStale(key) {
|
|
10821
|
+
const entry = this.cache.get(key);
|
|
10822
|
+
if (!entry) return null;
|
|
10823
|
+
const now = Date.now();
|
|
10824
|
+
if (now > entry.staleUntil) {
|
|
10825
|
+
this.cache.delete(key);
|
|
10826
|
+
return null;
|
|
10827
|
+
}
|
|
10828
|
+
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
10829
|
+
return {
|
|
10830
|
+
value: entry.value,
|
|
10831
|
+
staleAgeSec
|
|
10832
|
+
};
|
|
10773
10833
|
}
|
|
10774
10834
|
/**
|
|
10775
|
-
*
|
|
10835
|
+
* Store a value with TTL and stale window
|
|
10776
10836
|
*/
|
|
10777
|
-
|
|
10778
|
-
|
|
10837
|
+
set(key, value, options) {
|
|
10838
|
+
const ttl = options?.ttl ?? this.ttl;
|
|
10839
|
+
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
10840
|
+
const now = Date.now();
|
|
10841
|
+
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
10842
|
+
this.cache.set(key, {
|
|
10843
|
+
value,
|
|
10844
|
+
tags: options?.tags ?? [],
|
|
10845
|
+
createdAt: now,
|
|
10846
|
+
freshUntil: now + ttl,
|
|
10847
|
+
staleUntil: now + ttl + staleTtl
|
|
10848
|
+
});
|
|
10779
10849
|
}
|
|
10780
10850
|
/**
|
|
10781
|
-
*
|
|
10851
|
+
* Evict one entry to make room for a new one
|
|
10852
|
+
* Priority: oldest stale entry, then oldest fresh entry
|
|
10782
10853
|
*/
|
|
10783
|
-
|
|
10784
|
-
|
|
10854
|
+
evictOne(now) {
|
|
10855
|
+
let oldestStaleKey = null;
|
|
10856
|
+
let oldestStaleTime = Infinity;
|
|
10857
|
+
let oldestFreshKey = null;
|
|
10858
|
+
let oldestFreshTime = Infinity;
|
|
10859
|
+
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
10860
|
+
if (entry.createdAt < oldestStaleTime) {
|
|
10861
|
+
oldestStaleTime = entry.createdAt;
|
|
10862
|
+
oldestStaleKey = key;
|
|
10863
|
+
}
|
|
10864
|
+
} else if (entry.createdAt < oldestFreshTime) {
|
|
10865
|
+
oldestFreshTime = entry.createdAt;
|
|
10866
|
+
oldestFreshKey = key;
|
|
10867
|
+
}
|
|
10868
|
+
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
10869
|
+
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
10785
10870
|
}
|
|
10786
10871
|
/**
|
|
10787
|
-
*
|
|
10872
|
+
* Remove all fully expired entries (past staleUntil)
|
|
10788
10873
|
*/
|
|
10789
|
-
|
|
10790
|
-
|
|
10874
|
+
prune() {
|
|
10875
|
+
const now = Date.now();
|
|
10876
|
+
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
10791
10877
|
}
|
|
10792
10878
|
/**
|
|
10793
|
-
*
|
|
10794
|
-
* Includes all key details for debugging.
|
|
10795
|
-
*
|
|
10796
|
-
* @example
|
|
10797
|
-
* "RiverbankApiError: Content keys cannot access preview content | Code: auth:forbidden | Status: 401 | RequestId: req-abc123"
|
|
10879
|
+
* Clear all entries
|
|
10798
10880
|
*/
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10881
|
+
clearForTags(tags) {
|
|
10882
|
+
if (tags.includes("riverbank")) {
|
|
10883
|
+
this.clear();
|
|
10884
|
+
return;
|
|
10885
|
+
}
|
|
10886
|
+
const selected = new Set(tags);
|
|
10887
|
+
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
10805
10888
|
}
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
* This ensures that console.log(error) shows all relevant details
|
|
10809
|
-
* instead of just "[Object]" for nested properties.
|
|
10810
|
-
*/
|
|
10811
|
-
[_Symbol$for]() {
|
|
10812
|
-
return this.toDetailedString();
|
|
10889
|
+
clear() {
|
|
10890
|
+
this.cache.clear();
|
|
10813
10891
|
}
|
|
10814
10892
|
/**
|
|
10815
|
-
*
|
|
10816
|
-
* Used by the Node.js inspect symbol for console output.
|
|
10893
|
+
* Check if a key exists and is not fully expired
|
|
10817
10894
|
*/
|
|
10818
|
-
|
|
10819
|
-
const
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
];
|
|
10826
|
-
if (this.isRetryable) {
|
|
10827
|
-
lines.push(` Retryable: true`);
|
|
10828
|
-
if (this.retryAfterMs) lines.push(` RetryAfter: ${this.retryAfterMs}ms`);
|
|
10829
|
-
}
|
|
10830
|
-
if (this.fieldErrors && this.fieldErrors.length > 0) {
|
|
10831
|
-
lines.push(" FieldErrors:");
|
|
10832
|
-
this.fieldErrors.forEach((fe) => {
|
|
10833
|
-
lines.push(` - ${fe.field}: ${fe.message}`);
|
|
10834
|
-
});
|
|
10895
|
+
has(key) {
|
|
10896
|
+
const entry = this.cache.get(key);
|
|
10897
|
+
if (!entry) return false;
|
|
10898
|
+
const now = Date.now();
|
|
10899
|
+
if (now > entry.staleUntil) {
|
|
10900
|
+
this.cache.delete(key);
|
|
10901
|
+
return false;
|
|
10835
10902
|
}
|
|
10836
|
-
return
|
|
10837
|
-
}
|
|
10838
|
-
};
|
|
10839
|
-
const resilienceStatusSymbol = Symbol.for("riverbankcms.sdk.resilienceStatus");
|
|
10840
|
-
function attachResilienceStatusToError(error, resilienceStatus) {
|
|
10841
|
-
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");
|
|
10842
|
-
Object.defineProperty(target, resilienceStatusSymbol, {
|
|
10843
|
-
configurable: true,
|
|
10844
|
-
enumerable: false,
|
|
10845
|
-
value: resilienceStatus
|
|
10846
|
-
});
|
|
10847
|
-
return target;
|
|
10848
|
-
}
|
|
10849
|
-
function getResilienceStatusFromError(error) {
|
|
10850
|
-
if (error === null || typeof error !== "object" && typeof error !== "function") return;
|
|
10851
|
-
return error[resilienceStatusSymbol];
|
|
10852
|
-
}
|
|
10853
|
-
//#endregion
|
|
10854
|
-
//#region src/client/resilience.ts
|
|
10855
|
-
const DEFAULT_RETRY_CONFIG = {
|
|
10856
|
-
maxAttempts: 3,
|
|
10857
|
-
baseDelayMs: 200,
|
|
10858
|
-
maxDelayMs: 2e3,
|
|
10859
|
-
jitter: "full"
|
|
10860
|
-
};
|
|
10861
|
-
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
10862
|
-
failureThreshold: 5,
|
|
10863
|
-
resetTimeoutMs: 3e4,
|
|
10864
|
-
halfOpenMaxRequests: 2
|
|
10865
|
-
};
|
|
10866
|
-
/**
|
|
10867
|
-
* Error codes that indicate permanent infrastructure failures.
|
|
10868
|
-
* These should NOT be retried as the server is definitively unreachable.
|
|
10869
|
-
*/
|
|
10870
|
-
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10871
|
-
"ECONNREFUSED",
|
|
10872
|
-
"ENOTFOUND",
|
|
10873
|
-
"EAI_AGAIN"
|
|
10874
|
-
]);
|
|
10875
|
-
/**
|
|
10876
|
-
* Error codes that indicate transient network issues.
|
|
10877
|
-
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
10878
|
-
*/
|
|
10879
|
-
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10880
|
-
"ECONNRESET",
|
|
10881
|
-
"EPIPE",
|
|
10882
|
-
"ETIMEDOUT",
|
|
10883
|
-
"ESOCKETTIMEDOUT"
|
|
10884
|
-
]);
|
|
10885
|
-
/**
|
|
10886
|
-
* Node.js network error codes (POSIX style).
|
|
10887
|
-
* These are the codes we're looking for in the cause chain.
|
|
10888
|
-
*/
|
|
10889
|
-
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10890
|
-
"ECONNREFUSED",
|
|
10891
|
-
"ENOTFOUND",
|
|
10892
|
-
"EAI_AGAIN",
|
|
10893
|
-
"ECONNRESET",
|
|
10894
|
-
"EPIPE",
|
|
10895
|
-
"ETIMEDOUT",
|
|
10896
|
-
"ESOCKETTIMEDOUT"
|
|
10897
|
-
]);
|
|
10898
|
-
/**
|
|
10899
|
-
* Check if a string is a Node.js network error code (not an API error code).
|
|
10900
|
-
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
10901
|
-
*/
|
|
10902
|
-
function isNodeNetworkErrorCode(code) {
|
|
10903
|
-
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
10904
|
-
}
|
|
10905
|
-
/**
|
|
10906
|
-
* Extract the Node.js error code from an error's cause chain.
|
|
10907
|
-
* Handles nested cause chains like:
|
|
10908
|
-
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
10909
|
-
*
|
|
10910
|
-
* Skips API error codes (like 'network:connection_error') and only returns
|
|
10911
|
-
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
10912
|
-
*
|
|
10913
|
-
* @example
|
|
10914
|
-
* RiverbankApiError: Network request failed
|
|
10915
|
-
* [cause]: TypeError: fetch failed
|
|
10916
|
-
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
10917
|
-
* code: 'ECONNREFUSED'
|
|
10918
|
-
*/
|
|
10919
|
-
function getErrorCodeFromCause(error) {
|
|
10920
|
-
let current = error;
|
|
10921
|
-
while (current) {
|
|
10922
|
-
const nodeError = current;
|
|
10923
|
-
if (nodeError.code && typeof nodeError.code === "string") {
|
|
10924
|
-
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
10925
|
-
}
|
|
10926
|
-
current = current.cause;
|
|
10927
|
-
}
|
|
10928
|
-
}
|
|
10929
|
-
/**
|
|
10930
|
-
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
10931
|
-
*
|
|
10932
|
-
* Transient (opens circuit, triggers retry):
|
|
10933
|
-
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
10934
|
-
* - 5xx server errors
|
|
10935
|
-
* - 429 rate limit
|
|
10936
|
-
* - Connection reset, broken pipe, timeout
|
|
10937
|
-
*
|
|
10938
|
-
* Permanent (does NOT open circuit, no retry):
|
|
10939
|
-
* - 4xx client errors (400, 401, 403, 404)
|
|
10940
|
-
* - Validation errors
|
|
10941
|
-
* - ECONNREFUSED (server not running)
|
|
10942
|
-
* - ENOTFOUND (DNS failure)
|
|
10943
|
-
*/
|
|
10944
|
-
function isTransientError(error) {
|
|
10945
|
-
if (error instanceof RiverbankApiError) {
|
|
10946
|
-
const errorCode = getErrorCodeFromCause(error);
|
|
10947
|
-
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
10948
|
-
if (error.status === 0) return true;
|
|
10949
|
-
if (error.status === 429) return true;
|
|
10950
|
-
if (error.status >= 500) return true;
|
|
10951
|
-
return false;
|
|
10952
|
-
}
|
|
10953
|
-
if (error instanceof TypeError) {
|
|
10954
|
-
const errorCode = getErrorCodeFromCause(error);
|
|
10955
|
-
if (errorCode) {
|
|
10956
|
-
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
10957
|
-
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
10958
|
-
}
|
|
10959
|
-
return true;
|
|
10960
|
-
}
|
|
10961
|
-
return true;
|
|
10962
|
-
}
|
|
10963
|
-
/**
|
|
10964
|
-
* Calculate backoff delay for retry attempt
|
|
10965
|
-
*
|
|
10966
|
-
* Uses exponential backoff with optional full jitter.
|
|
10967
|
-
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
10968
|
-
*/
|
|
10969
|
-
function calculateBackoff(attempt, config) {
|
|
10970
|
-
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
10971
|
-
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
10972
|
-
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
10973
|
-
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
10974
|
-
const capped = Math.min(exponential, maxDelayMs);
|
|
10975
|
-
if (jitter === "full") return Math.random() * capped;
|
|
10976
|
-
return capped;
|
|
10977
|
-
}
|
|
10978
|
-
/**
|
|
10979
|
-
* Circuit breaker for fail-fast behavior
|
|
10980
|
-
*
|
|
10981
|
-
* States:
|
|
10982
|
-
* - closed: Normal operation, requests allowed
|
|
10983
|
-
* - open: Too many failures, requests blocked
|
|
10984
|
-
* - half-open: Testing if service recovered, limited requests allowed
|
|
10985
|
-
*/
|
|
10986
|
-
var CircuitBreaker = class {
|
|
10987
|
-
constructor(config) {
|
|
10988
|
-
this.state = "closed";
|
|
10989
|
-
this.failureCount = 0;
|
|
10990
|
-
this.successCount = 0;
|
|
10991
|
-
this.openUntil = 0;
|
|
10992
|
-
this.halfOpenRequests = 0;
|
|
10993
|
-
this.config = {
|
|
10994
|
-
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
10995
|
-
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
10996
|
-
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
10997
|
-
};
|
|
10998
|
-
}
|
|
10999
|
-
/**
|
|
11000
|
-
* Check if circuit is open (requests should be blocked)
|
|
11001
|
-
* Also handles automatic transition from open to half-open after timeout
|
|
11002
|
-
*/
|
|
11003
|
-
isOpen() {
|
|
11004
|
-
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
11005
|
-
return this.state === "open";
|
|
11006
|
-
}
|
|
11007
|
-
/**
|
|
11008
|
-
* Check if a request can be attempted
|
|
11009
|
-
* - closed: always yes
|
|
11010
|
-
* - open: always no
|
|
11011
|
-
* - half-open: limited number of probes
|
|
11012
|
-
*/
|
|
11013
|
-
canAttempt() {
|
|
11014
|
-
if (this.state === "closed") return true;
|
|
11015
|
-
if (this.state === "open") return false;
|
|
11016
|
-
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
11017
|
-
}
|
|
11018
|
-
/**
|
|
11019
|
-
* Increment half-open request counter (call before making request in half-open)
|
|
11020
|
-
*/
|
|
11021
|
-
incrementHalfOpenRequests() {
|
|
11022
|
-
if (this.state === "half-open") this.halfOpenRequests++;
|
|
11023
|
-
}
|
|
11024
|
-
/**
|
|
11025
|
-
* Record a successful request
|
|
11026
|
-
*/
|
|
11027
|
-
recordSuccess() {
|
|
11028
|
-
if (this.state === "half-open") {
|
|
11029
|
-
this.successCount++;
|
|
11030
|
-
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
11031
|
-
} else this.failureCount = 0;
|
|
11032
|
-
}
|
|
11033
|
-
/**
|
|
11034
|
-
* Record a failed request
|
|
11035
|
-
* Only counts transient failures toward circuit breaker threshold
|
|
11036
|
-
*/
|
|
11037
|
-
recordFailure(error) {
|
|
11038
|
-
if (!isTransientError(error)) return;
|
|
11039
|
-
this.failureCount++;
|
|
11040
|
-
if (this.state === "half-open") this.transitionTo("open");
|
|
11041
|
-
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
11042
|
-
}
|
|
11043
|
-
/**
|
|
11044
|
-
* Get current circuit state
|
|
11045
|
-
*/
|
|
11046
|
-
getState() {
|
|
11047
|
-
return {
|
|
11048
|
-
state: this.state,
|
|
11049
|
-
failureCount: this.failureCount,
|
|
11050
|
-
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
11051
|
-
};
|
|
11052
|
-
}
|
|
11053
|
-
/**
|
|
11054
|
-
* Transition to a new state
|
|
11055
|
-
*/
|
|
11056
|
-
transitionTo(newState) {
|
|
11057
|
-
this.state = newState;
|
|
11058
|
-
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
11059
|
-
else if (newState === "half-open") {
|
|
11060
|
-
this.halfOpenRequests = 0;
|
|
11061
|
-
this.successCount = 0;
|
|
11062
|
-
} else if (newState === "closed") {
|
|
11063
|
-
this.failureCount = 0;
|
|
11064
|
-
this.successCount = 0;
|
|
11065
|
-
this.halfOpenRequests = 0;
|
|
11066
|
-
}
|
|
11067
|
-
}
|
|
11068
|
-
};
|
|
11069
|
-
/**
|
|
11070
|
-
* Fetch with timeout and retry logic
|
|
11071
|
-
*
|
|
11072
|
-
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
11073
|
-
* @param config - Retry configuration
|
|
11074
|
-
* @returns Result from successful fetch
|
|
11075
|
-
* @throws Last error after all retries exhausted
|
|
11076
|
-
*/
|
|
11077
|
-
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
11078
|
-
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
11079
|
-
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
11080
|
-
let lastError;
|
|
11081
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
11082
|
-
const controller = new AbortController();
|
|
11083
|
-
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
11084
|
-
try {
|
|
11085
|
-
return await fetcher(controller.signal);
|
|
11086
|
-
} finally {
|
|
11087
|
-
clearTimeout(timeoutId);
|
|
11088
|
-
}
|
|
11089
|
-
} catch (error) {
|
|
11090
|
-
lastError = error;
|
|
11091
|
-
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
11092
|
-
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
11093
|
-
}
|
|
11094
|
-
throw lastError;
|
|
11095
|
-
}
|
|
11096
|
-
/**
|
|
11097
|
-
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
11098
|
-
*/
|
|
11099
|
-
function isAbortError$1(error) {
|
|
11100
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
11101
|
-
if (error instanceof Error && error.name === "AbortError") return true;
|
|
11102
|
-
return false;
|
|
11103
|
-
}
|
|
11104
|
-
/**
|
|
11105
|
-
* Check if an error should be retried
|
|
11106
|
-
*/
|
|
11107
|
-
function shouldRetryError(error, customRetryOn) {
|
|
11108
|
-
if (isAbortError$1(error)) return false;
|
|
11109
|
-
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
11110
|
-
return isTransientError(error);
|
|
11111
|
-
}
|
|
11112
|
-
/**
|
|
11113
|
-
* Get delay before retrying, respecting Retry-After if present
|
|
11114
|
-
*/
|
|
11115
|
-
function getRetryDelay(error, attempt, config) {
|
|
11116
|
-
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
11117
|
-
return calculateBackoff(attempt, config);
|
|
11118
|
-
}
|
|
11119
|
-
/**
|
|
11120
|
-
* Sleep for specified milliseconds
|
|
11121
|
-
*/
|
|
11122
|
-
function sleep(ms) {
|
|
11123
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
11124
|
-
}
|
|
11125
|
-
/**
|
|
11126
|
-
* Error thrown when circuit breaker is open
|
|
11127
|
-
*/
|
|
11128
|
-
var CircuitOpenError = class extends Error {
|
|
11129
|
-
constructor(state) {
|
|
11130
|
-
super("Circuit breaker is open");
|
|
11131
|
-
this.name = "CircuitOpenError";
|
|
11132
|
-
this.circuitState = state;
|
|
11133
|
-
}
|
|
11134
|
-
};
|
|
11135
|
-
//#endregion
|
|
11136
|
-
//#region ../site-renderer/src/runtimeResponse.ts
|
|
11137
|
-
/** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
|
|
11138
|
-
function restoreRuntimeResponse(serialized) {
|
|
11139
|
-
return parseSurfaceTree(serialized);
|
|
11140
|
-
}
|
|
11141
|
-
//#endregion
|
|
11142
|
-
//#region ../site-renderer/src/runtimeClient.ts
|
|
11143
|
-
/** Only a client that reconstructs surfaces advertises revision transport. */
|
|
11144
|
-
function createRuntimeApiClient(transport) {
|
|
11145
|
-
const revisionTransport = (request) => transport({
|
|
11146
|
-
...request,
|
|
11147
|
-
...request.endpoint === "getContentByPath" ? { params: {
|
|
11148
|
-
...request.params,
|
|
11149
|
-
surfaceTransport: "revision-v1"
|
|
11150
|
-
} } : {}
|
|
11151
|
-
});
|
|
11152
|
-
return createParsedApiClient(revisionTransport, {
|
|
11153
|
-
representation: "restored",
|
|
11154
|
-
decode: restoreRuntimeResponse
|
|
11155
|
-
});
|
|
11156
|
-
}
|
|
11157
|
-
function createRuntimeInternalAPIClient(baseUrl, options) {
|
|
11158
|
-
return createRuntimeApiClient(createApiResponseTransport(() => ({}), baseUrl, options));
|
|
11159
|
-
}
|
|
11160
|
-
function createRuntimeBearerAPIClient(token, baseUrl, options) {
|
|
11161
|
-
return createRuntimeApiClient(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
|
|
11162
|
-
}
|
|
11163
|
-
//#endregion
|
|
11164
|
-
//#region src/client/entryListReadRequest.ts
|
|
11165
|
-
const entryOrder = {
|
|
11166
|
-
newest: "published_at.desc",
|
|
11167
|
-
oldest: "published_at.asc",
|
|
11168
|
-
title: "title.asc",
|
|
11169
|
-
manual: "manual.asc"
|
|
11170
|
-
};
|
|
11171
|
-
function entrySelection(input) {
|
|
11172
|
-
return input.mode === "manual" && input.entryIds?.length ? {
|
|
11173
|
-
keyPart: input.entryIds.join(","),
|
|
11174
|
-
params: {
|
|
11175
|
-
mode: "manual",
|
|
11176
|
-
entryIds: JSON.stringify(input.entryIds)
|
|
11177
|
-
}
|
|
11178
|
-
} : {
|
|
11179
|
-
keyPart: "",
|
|
11180
|
-
params: {}
|
|
11181
|
-
};
|
|
11182
|
-
}
|
|
11183
|
-
function entryListMemoryKey(input, selection) {
|
|
11184
|
-
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
11185
|
-
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
11186
|
-
}
|
|
11187
|
-
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
11188
|
-
function buildEntryListReadRequest(input) {
|
|
11189
|
-
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
11190
|
-
const selection = entrySelection(input);
|
|
11191
|
-
const orderParam = order ? entryOrder[order] : void 0;
|
|
11192
|
-
return {
|
|
11193
|
-
cacheKey: entryListMemoryKey(input, selection),
|
|
11194
|
-
params: {
|
|
11195
|
-
siteId,
|
|
11196
|
-
type: contentType,
|
|
11197
|
-
...typeof limit === "number" && { limit: String(limit) },
|
|
11198
|
-
...typeof offset === "number" && { offset: String(offset) },
|
|
11199
|
-
...includeMeta && { meta: "true" },
|
|
11200
|
-
...orderParam && { order: orderParam },
|
|
11201
|
-
...preview && { stage: "preview" },
|
|
11202
|
-
...selection.params
|
|
11203
|
-
}
|
|
11204
|
-
};
|
|
11205
|
-
}
|
|
11206
|
-
//#endregion
|
|
11207
|
-
//#region src/client/cache.ts
|
|
11208
|
-
var SimpleCache = class {
|
|
11209
|
-
constructor(options = {}) {
|
|
11210
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
11211
|
-
this.maxSize = options.maxSize ?? 100;
|
|
11212
|
-
this.ttl = options.ttl ?? 3e5;
|
|
11213
|
-
this.staleTtl = options.staleTtl ?? 3e5;
|
|
11214
|
-
}
|
|
11215
|
-
/**
|
|
11216
|
-
* Get a fresh value (within TTL)
|
|
11217
|
-
* @returns The value if fresh, null otherwise
|
|
11218
|
-
*/
|
|
11219
|
-
getFresh(key) {
|
|
11220
|
-
const entry = this.cache.get(key);
|
|
11221
|
-
if (!entry) return null;
|
|
11222
|
-
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
11223
|
-
return null;
|
|
11224
|
-
}
|
|
11225
|
-
/**
|
|
11226
|
-
* Get a value that may be stale (past TTL but within staleTtl)
|
|
11227
|
-
* @returns Object with value and stale age, or null if expired
|
|
11228
|
-
*/
|
|
11229
|
-
getStale(key) {
|
|
11230
|
-
const entry = this.cache.get(key);
|
|
11231
|
-
if (!entry) return null;
|
|
11232
|
-
const now = Date.now();
|
|
11233
|
-
if (now > entry.staleUntil) {
|
|
11234
|
-
this.cache.delete(key);
|
|
11235
|
-
return null;
|
|
11236
|
-
}
|
|
11237
|
-
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
11238
|
-
return {
|
|
11239
|
-
value: entry.value,
|
|
11240
|
-
staleAgeSec
|
|
11241
|
-
};
|
|
11242
|
-
}
|
|
11243
|
-
/**
|
|
11244
|
-
* Store a value with TTL and stale window
|
|
11245
|
-
*/
|
|
11246
|
-
set(key, value, options) {
|
|
11247
|
-
const ttl = options?.ttl ?? this.ttl;
|
|
11248
|
-
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
11249
|
-
const now = Date.now();
|
|
11250
|
-
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
11251
|
-
this.cache.set(key, {
|
|
11252
|
-
value,
|
|
11253
|
-
tags: options?.tags ?? [],
|
|
11254
|
-
createdAt: now,
|
|
11255
|
-
freshUntil: now + ttl,
|
|
11256
|
-
staleUntil: now + ttl + staleTtl
|
|
11257
|
-
});
|
|
11258
|
-
}
|
|
11259
|
-
/**
|
|
11260
|
-
* Evict one entry to make room for a new one
|
|
11261
|
-
* Priority: oldest stale entry, then oldest fresh entry
|
|
11262
|
-
*/
|
|
11263
|
-
evictOne(now) {
|
|
11264
|
-
let oldestStaleKey = null;
|
|
11265
|
-
let oldestStaleTime = Infinity;
|
|
11266
|
-
let oldestFreshKey = null;
|
|
11267
|
-
let oldestFreshTime = Infinity;
|
|
11268
|
-
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
11269
|
-
if (entry.createdAt < oldestStaleTime) {
|
|
11270
|
-
oldestStaleTime = entry.createdAt;
|
|
11271
|
-
oldestStaleKey = key;
|
|
11272
|
-
}
|
|
11273
|
-
} else if (entry.createdAt < oldestFreshTime) {
|
|
11274
|
-
oldestFreshTime = entry.createdAt;
|
|
11275
|
-
oldestFreshKey = key;
|
|
11276
|
-
}
|
|
11277
|
-
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
11278
|
-
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
11279
|
-
}
|
|
11280
|
-
/**
|
|
11281
|
-
* Remove all fully expired entries (past staleUntil)
|
|
11282
|
-
*/
|
|
11283
|
-
prune() {
|
|
11284
|
-
const now = Date.now();
|
|
11285
|
-
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
11286
|
-
}
|
|
11287
|
-
/**
|
|
11288
|
-
* Clear all entries
|
|
11289
|
-
*/
|
|
11290
|
-
clearForTags(tags) {
|
|
11291
|
-
if (tags.includes("riverbank")) {
|
|
11292
|
-
this.clear();
|
|
11293
|
-
return;
|
|
11294
|
-
}
|
|
11295
|
-
const selected = new Set(tags);
|
|
11296
|
-
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
11297
|
-
}
|
|
11298
|
-
clear() {
|
|
11299
|
-
this.cache.clear();
|
|
11300
|
-
}
|
|
11301
|
-
/**
|
|
11302
|
-
* Check if a key exists and is not fully expired
|
|
11303
|
-
*/
|
|
11304
|
-
has(key) {
|
|
11305
|
-
const entry = this.cache.get(key);
|
|
11306
|
-
if (!entry) return false;
|
|
11307
|
-
const now = Date.now();
|
|
11308
|
-
if (now > entry.staleUntil) {
|
|
11309
|
-
this.cache.delete(key);
|
|
11310
|
-
return false;
|
|
11311
|
-
}
|
|
11312
|
-
return now <= entry.freshUntil;
|
|
10903
|
+
return now <= entry.freshUntil;
|
|
11313
10904
|
}
|
|
11314
10905
|
};
|
|
11315
10906
|
//#endregion
|
|
@@ -11336,7 +10927,6 @@ const PUBLIC_ENDPOINT_NAMES = [
|
|
|
11336
10927
|
"listPublicProducts",
|
|
11337
10928
|
"listPublicPasses",
|
|
11338
10929
|
"listPublicMemberships",
|
|
11339
|
-
"resolveEventSubroute",
|
|
11340
10930
|
"checkRedirect",
|
|
11341
10931
|
"getRoutableContent",
|
|
11342
10932
|
"getPublicRoutableContent",
|
|
@@ -11356,6 +10946,7 @@ const API_ENDPOINTS = Object.freeze({
|
|
|
11356
10946
|
responseKind: "json"
|
|
11357
10947
|
},
|
|
11358
10948
|
resolveRouteOutcome: {
|
|
10949
|
+
revalidate: PUBLIC_CONTENT_FRESHNESS_SECONDS,
|
|
11359
10950
|
path: "/sites/{siteId}/route-outcome",
|
|
11360
10951
|
method: "GET",
|
|
11361
10952
|
tags: [
|
|
@@ -11477,14 +11068,6 @@ const API_ENDPOINTS = Object.freeze({
|
|
|
11477
11068
|
auth: "public",
|
|
11478
11069
|
responseKind: "json"
|
|
11479
11070
|
},
|
|
11480
|
-
resolveEventSubroute: {
|
|
11481
|
-
path: "/public/sites/{siteId}/events/subroutes/resolve",
|
|
11482
|
-
method: "GET",
|
|
11483
|
-
revalidate: 60,
|
|
11484
|
-
tags: [TAG_TEMPLATES.publicEvents, "event-subroute"],
|
|
11485
|
-
auth: "public",
|
|
11486
|
-
responseKind: "json"
|
|
11487
|
-
},
|
|
11488
11071
|
checkRedirect: publicSiteReadDefinition(PUBLIC_READ_ENDPOINT_DEFINITIONS.checkRedirect)
|
|
11489
11072
|
});
|
|
11490
11073
|
function buildEndpointURL(baseURL, endpoint) {
|
|
@@ -11507,12 +11090,13 @@ function publicSiteReadDefinition(definition) {
|
|
|
11507
11090
|
* entries written in the old shape until publish or a live success rewrites
|
|
11508
11091
|
* them.
|
|
11509
11092
|
*
|
|
11093
|
+
* - 5: page reads carry the admitted destination envelope and availability dependencies.
|
|
11510
11094
|
* - 4: owned surface inputs use the shared revision transport envelope (#1627).
|
|
11511
11095
|
* - 3: hidden business-source maps and private locations are removed before public projection (#1611).
|
|
11512
11096
|
* - 2: pages carry intent-only `runtimeJoins` in place of compiled
|
|
11513
11097
|
* `runtimeBoundaries` (issue 1422).
|
|
11514
11098
|
*/
|
|
11515
|
-
const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION =
|
|
11099
|
+
const DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION = 5;
|
|
11516
11100
|
function toNonEmptyString(value) {
|
|
11517
11101
|
if (value === null || value === void 0) return null;
|
|
11518
11102
|
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
|
|
@@ -11764,10 +11348,6 @@ const RUNTIME_CACHE_DURABILITY_OVERRIDES = {
|
|
|
11764
11348
|
kind: "live-only",
|
|
11765
11349
|
reason: "safety_sensitive_booking"
|
|
11766
11350
|
},
|
|
11767
|
-
resolveEventSubroute: {
|
|
11768
|
-
kind: "memory-only",
|
|
11769
|
-
reason: "durable_rollout_pending"
|
|
11770
|
-
},
|
|
11771
11351
|
checkRedirect: {
|
|
11772
11352
|
kind: "memory-only",
|
|
11773
11353
|
reason: "durable_rollout_pending"
|
|
@@ -11794,7 +11374,7 @@ function isTruthyParam(value) {
|
|
|
11794
11374
|
}
|
|
11795
11375
|
function isPreviewRequest(endpoint, params) {
|
|
11796
11376
|
if (endpoint === "getContentByPath") return isTruthyParam(params.preview);
|
|
11797
|
-
if (endpoint === "listPublishedEntries"
|
|
11377
|
+
if (endpoint === "listPublishedEntries") return params.stage === "preview";
|
|
11798
11378
|
return false;
|
|
11799
11379
|
}
|
|
11800
11380
|
function getEndpointFreshTtlSec(endpoint) {
|
|
@@ -11899,236 +11479,490 @@ function derivePublishedRuntimeCacheKey(input) {
|
|
|
11899
11479
|
kind: "not_durable_eligible",
|
|
11900
11480
|
policy
|
|
11901
11481
|
}
|
|
11902
|
-
};
|
|
11903
|
-
return deriveDurableRuntimeCacheKey(input);
|
|
11482
|
+
};
|
|
11483
|
+
return deriveDurableRuntimeCacheKey(input);
|
|
11484
|
+
}
|
|
11485
|
+
//#endregion
|
|
11486
|
+
//#region src/client/contentReadOperations.ts
|
|
11487
|
+
function planPublishedRuntimeCache(input) {
|
|
11488
|
+
const policy = resolveRuntimeCachePolicy({
|
|
11489
|
+
endpoint: input.endpoint,
|
|
11490
|
+
method: "GET",
|
|
11491
|
+
params: input.params
|
|
11492
|
+
});
|
|
11493
|
+
if (policy.kind !== "durable-public-stale") return null;
|
|
11494
|
+
const keyResult = derivePublishedRuntimeCacheKey(input);
|
|
11495
|
+
if (!keyResult.ok) return null;
|
|
11496
|
+
return {
|
|
11497
|
+
cacheKey: keyResult.key,
|
|
11498
|
+
endpoint: keyResult.endpoint,
|
|
11499
|
+
normalizedParams: keyResult.normalizedParams,
|
|
11500
|
+
freshTtlSec: policy.freshTtlSec,
|
|
11501
|
+
staleTtlSec: policy.staleTtlSec,
|
|
11502
|
+
siteId: input.siteId ?? null
|
|
11503
|
+
};
|
|
11504
|
+
}
|
|
11505
|
+
function siteApiParams(params) {
|
|
11506
|
+
return {
|
|
11507
|
+
...params.slug ? { slug: params.slug } : {},
|
|
11508
|
+
...params.domain ? { domain: params.domain } : {},
|
|
11509
|
+
...params.id ? { id: params.id } : {},
|
|
11510
|
+
...params.currentPath ? { currentPath: params.currentPath } : {},
|
|
11511
|
+
...params.force ? { force: "true" } : {}
|
|
11512
|
+
};
|
|
11513
|
+
}
|
|
11514
|
+
function siteReadIdentity(params) {
|
|
11515
|
+
const identifier = params.slug || params.domain || params.id;
|
|
11516
|
+
if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
|
|
11517
|
+
return identifier;
|
|
11518
|
+
}
|
|
11519
|
+
function planSiteRead(params) {
|
|
11520
|
+
const identifier = siteReadIdentity(params);
|
|
11521
|
+
const { slug, domain, id, currentPath, force } = params;
|
|
11522
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
11523
|
+
endpoint: "getSite",
|
|
11524
|
+
params: {
|
|
11525
|
+
slug,
|
|
11526
|
+
domain,
|
|
11527
|
+
id,
|
|
11528
|
+
currentPath,
|
|
11529
|
+
force
|
|
11530
|
+
}
|
|
11531
|
+
});
|
|
11532
|
+
return {
|
|
11533
|
+
publishedRuntimeCache,
|
|
11534
|
+
prebuildIdentifier: id || slug || domain,
|
|
11535
|
+
cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
|
|
11536
|
+
};
|
|
11537
|
+
}
|
|
11538
|
+
async function readSiteWithResilience(input, params) {
|
|
11539
|
+
const { slug, domain, id, signal, force } = params;
|
|
11540
|
+
const plan = planSiteRead(params);
|
|
11541
|
+
const prebuildId = plan.prebuildIdentifier;
|
|
11542
|
+
const prebuild = input.prebuildLoader;
|
|
11543
|
+
return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
|
|
11544
|
+
endpoint: "getSite",
|
|
11545
|
+
params: siteApiParams(params),
|
|
11546
|
+
options: {
|
|
11547
|
+
signal: requestSignal,
|
|
11548
|
+
...force ? { cache: "no-store" } : {}
|
|
11549
|
+
}
|
|
11550
|
+
}), {
|
|
11551
|
+
signal,
|
|
11552
|
+
force,
|
|
11553
|
+
publishedRuntimeCache: plan.publishedRuntimeCache,
|
|
11554
|
+
cacheTags: buildSiteReadTags({
|
|
11555
|
+
slug,
|
|
11556
|
+
domain,
|
|
11557
|
+
id
|
|
11558
|
+
}),
|
|
11559
|
+
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
11560
|
+
});
|
|
11561
|
+
}
|
|
11562
|
+
async function readPageWithResilience(input, params) {
|
|
11563
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11564
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
11565
|
+
endpoint: "getContentByPath",
|
|
11566
|
+
params: {
|
|
11567
|
+
siteId,
|
|
11568
|
+
path,
|
|
11569
|
+
preview
|
|
11570
|
+
},
|
|
11571
|
+
siteId
|
|
11572
|
+
});
|
|
11573
|
+
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
11574
|
+
const result = await input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
11575
|
+
endpoint: "getContentByPath",
|
|
11576
|
+
params: {
|
|
11577
|
+
siteId,
|
|
11578
|
+
path,
|
|
11579
|
+
preview: String(preview)
|
|
11580
|
+
},
|
|
11581
|
+
options: { signal: requestSignal }
|
|
11582
|
+
}), {
|
|
11583
|
+
pageRead: { siteId },
|
|
11584
|
+
preview,
|
|
11585
|
+
signal,
|
|
11586
|
+
publishedRuntimeCache,
|
|
11587
|
+
cacheTags: buildSiteReadTags({ siteId }),
|
|
11588
|
+
prebuildFallback: void 0
|
|
11589
|
+
});
|
|
11590
|
+
if (!preview) await observePageReadResponse(input.frameworkCache, siteId, result.data);
|
|
11591
|
+
return result;
|
|
11592
|
+
}
|
|
11593
|
+
function createContentReadOperations(input) {
|
|
11594
|
+
return {
|
|
11595
|
+
getSiteWithResilience: (params) => readSiteWithResilience(input, params),
|
|
11596
|
+
getPageWithResilience: (params) => readPageWithResilience(input, params)
|
|
11597
|
+
};
|
|
11598
|
+
}
|
|
11599
|
+
//#endregion
|
|
11600
|
+
//#region src/client/publicAppointmentReadOperations.ts
|
|
11601
|
+
function createPublicAppointmentReadOperations(deps) {
|
|
11602
|
+
return {
|
|
11603
|
+
async getPublicBookingServices(params) {
|
|
11604
|
+
const { siteId, ids, signal } = params;
|
|
11605
|
+
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
11606
|
+
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
11607
|
+
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
11608
|
+
const apiParams = {
|
|
11609
|
+
siteId,
|
|
11610
|
+
...ids && { ids }
|
|
11611
|
+
};
|
|
11612
|
+
return await deps.apiClient({
|
|
11613
|
+
endpoint: "getPublicBookingServices",
|
|
11614
|
+
params: apiParams,
|
|
11615
|
+
options: { signal: requestSignal }
|
|
11616
|
+
});
|
|
11617
|
+
}, {
|
|
11618
|
+
signal,
|
|
11619
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
11620
|
+
});
|
|
11621
|
+
},
|
|
11622
|
+
async getPublicWeeklySlotAvailability(params) {
|
|
11623
|
+
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
11624
|
+
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
11625
|
+
const cacheKey = [
|
|
11626
|
+
"public-weekly-slot-availability",
|
|
11627
|
+
siteId,
|
|
11628
|
+
serviceId,
|
|
11629
|
+
resourceId ?? "",
|
|
11630
|
+
horizonWeeks ?? "",
|
|
11631
|
+
timezone ?? ""
|
|
11632
|
+
].join(":");
|
|
11633
|
+
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
11634
|
+
const apiParams = {
|
|
11635
|
+
siteId,
|
|
11636
|
+
serviceId,
|
|
11637
|
+
...resourceId && { resourceId },
|
|
11638
|
+
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
11639
|
+
...timezone && { timezone }
|
|
11640
|
+
};
|
|
11641
|
+
return await deps.apiClient({
|
|
11642
|
+
endpoint: "getPublicWeeklySlotAvailability",
|
|
11643
|
+
params: apiParams,
|
|
11644
|
+
options: { signal: requestSignal }
|
|
11645
|
+
});
|
|
11646
|
+
}, {
|
|
11647
|
+
signal,
|
|
11648
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
11649
|
+
});
|
|
11650
|
+
}
|
|
11651
|
+
};
|
|
11652
|
+
}
|
|
11653
|
+
//#endregion
|
|
11654
|
+
//#region src/client/publicEventReadOperations.ts
|
|
11655
|
+
function createPublicEventReadOperations(deps) {
|
|
11656
|
+
return { async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
11657
|
+
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
11658
|
+
endpoint: "listPublicEventCalendarWindow",
|
|
11659
|
+
params: {
|
|
11660
|
+
...params,
|
|
11661
|
+
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
11662
|
+
},
|
|
11663
|
+
options: { signal: requestSignal }
|
|
11664
|
+
}), {
|
|
11665
|
+
signal,
|
|
11666
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
11667
|
+
});
|
|
11668
|
+
} };
|
|
11669
|
+
}
|
|
11670
|
+
//#endregion
|
|
11671
|
+
//#region src/client/combineAbortSignals.ts
|
|
11672
|
+
/** Combine signals into one that aborts when any input aborts. */
|
|
11673
|
+
function combineAbortSignals(...signals) {
|
|
11674
|
+
const controller = new AbortController();
|
|
11675
|
+
for (const signal of signals) {
|
|
11676
|
+
if (signal.aborted) {
|
|
11677
|
+
controller.abort(signal.reason);
|
|
11678
|
+
break;
|
|
11679
|
+
}
|
|
11680
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
11681
|
+
}
|
|
11682
|
+
return controller.signal;
|
|
11904
11683
|
}
|
|
11905
11684
|
//#endregion
|
|
11906
|
-
//#region src/client/
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11685
|
+
//#region src/client/resilience.ts
|
|
11686
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
11687
|
+
maxAttempts: 3,
|
|
11688
|
+
baseDelayMs: 200,
|
|
11689
|
+
maxDelayMs: 2e3,
|
|
11690
|
+
jitter: "full"
|
|
11691
|
+
};
|
|
11692
|
+
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
11693
|
+
failureThreshold: 5,
|
|
11694
|
+
resetTimeoutMs: 3e4,
|
|
11695
|
+
halfOpenMaxRequests: 2
|
|
11696
|
+
};
|
|
11697
|
+
/**
|
|
11698
|
+
* Error codes that indicate permanent infrastructure failures.
|
|
11699
|
+
* These should NOT be retried as the server is definitively unreachable.
|
|
11700
|
+
*/
|
|
11701
|
+
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
11702
|
+
"ECONNREFUSED",
|
|
11703
|
+
"ENOTFOUND",
|
|
11704
|
+
"EAI_AGAIN"
|
|
11705
|
+
]);
|
|
11706
|
+
/**
|
|
11707
|
+
* Error codes that indicate transient network issues.
|
|
11708
|
+
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
11709
|
+
*/
|
|
11710
|
+
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
11711
|
+
"ECONNRESET",
|
|
11712
|
+
"EPIPE",
|
|
11713
|
+
"ETIMEDOUT",
|
|
11714
|
+
"ESOCKETTIMEDOUT"
|
|
11715
|
+
]);
|
|
11716
|
+
/**
|
|
11717
|
+
* Node.js network error codes (POSIX style).
|
|
11718
|
+
* These are the codes we're looking for in the cause chain.
|
|
11719
|
+
*/
|
|
11720
|
+
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
11721
|
+
"ECONNREFUSED",
|
|
11722
|
+
"ENOTFOUND",
|
|
11723
|
+
"EAI_AGAIN",
|
|
11724
|
+
"ECONNRESET",
|
|
11725
|
+
"EPIPE",
|
|
11726
|
+
"ETIMEDOUT",
|
|
11727
|
+
"ESOCKETTIMEDOUT"
|
|
11728
|
+
]);
|
|
11729
|
+
/**
|
|
11730
|
+
* Check if a string is a Node.js network error code (not an API error code).
|
|
11731
|
+
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
11732
|
+
*/
|
|
11733
|
+
function isNodeNetworkErrorCode(code) {
|
|
11734
|
+
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
11924
11735
|
}
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11736
|
+
/**
|
|
11737
|
+
* Extract the Node.js error code from an error's cause chain.
|
|
11738
|
+
* Handles nested cause chains like:
|
|
11739
|
+
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
11740
|
+
*
|
|
11741
|
+
* Skips API error codes (like 'network:connection_error') and only returns
|
|
11742
|
+
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
11743
|
+
*
|
|
11744
|
+
* @example
|
|
11745
|
+
* RiverbankApiError: Network request failed
|
|
11746
|
+
* [cause]: TypeError: fetch failed
|
|
11747
|
+
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
11748
|
+
* code: 'ECONNREFUSED'
|
|
11749
|
+
*/
|
|
11750
|
+
function getErrorCodeFromCause(error) {
|
|
11751
|
+
let current = error;
|
|
11752
|
+
while (current) {
|
|
11753
|
+
const nodeError = current;
|
|
11754
|
+
if (nodeError.code && typeof nodeError.code === "string") {
|
|
11755
|
+
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
11756
|
+
}
|
|
11757
|
+
current = current.cause;
|
|
11758
|
+
}
|
|
11933
11759
|
}
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11760
|
+
/**
|
|
11761
|
+
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
11762
|
+
*
|
|
11763
|
+
* Transient (opens circuit, triggers retry):
|
|
11764
|
+
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
11765
|
+
* - 5xx server errors
|
|
11766
|
+
* - 429 rate limit
|
|
11767
|
+
* - Connection reset, broken pipe, timeout
|
|
11768
|
+
*
|
|
11769
|
+
* Permanent (does NOT open circuit, no retry):
|
|
11770
|
+
* - 4xx client errors (400, 401, 403, 404)
|
|
11771
|
+
* - Validation errors
|
|
11772
|
+
* - ECONNREFUSED (server not running)
|
|
11773
|
+
* - ENOTFOUND (DNS failure)
|
|
11774
|
+
*/
|
|
11775
|
+
function isTransientError(error) {
|
|
11776
|
+
if (error instanceof RiverbankApiError) {
|
|
11777
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
11778
|
+
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
11779
|
+
if (error.status === 0) return true;
|
|
11780
|
+
if (error.status === 429) return true;
|
|
11781
|
+
if (error.status >= 500) return true;
|
|
11782
|
+
return false;
|
|
11783
|
+
}
|
|
11784
|
+
if (error instanceof TypeError) {
|
|
11785
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
11786
|
+
if (errorCode) {
|
|
11787
|
+
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
11788
|
+
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
11789
|
+
}
|
|
11790
|
+
return true;
|
|
11791
|
+
}
|
|
11792
|
+
return true;
|
|
11938
11793
|
}
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11794
|
+
/**
|
|
11795
|
+
* Calculate backoff delay for retry attempt
|
|
11796
|
+
*
|
|
11797
|
+
* Uses exponential backoff with optional full jitter.
|
|
11798
|
+
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
11799
|
+
*/
|
|
11800
|
+
function calculateBackoff(attempt, config) {
|
|
11801
|
+
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
11802
|
+
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
11803
|
+
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
11804
|
+
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
11805
|
+
const capped = Math.min(exponential, maxDelayMs);
|
|
11806
|
+
if (jitter === "full") return Math.random() * capped;
|
|
11807
|
+
return capped;
|
|
11808
|
+
}
|
|
11809
|
+
/**
|
|
11810
|
+
* Circuit breaker for fail-fast behavior
|
|
11811
|
+
*
|
|
11812
|
+
* States:
|
|
11813
|
+
* - closed: Normal operation, requests allowed
|
|
11814
|
+
* - open: Too many failures, requests blocked
|
|
11815
|
+
* - half-open: Testing if service recovered, limited requests allowed
|
|
11816
|
+
*/
|
|
11817
|
+
var CircuitBreaker = class {
|
|
11818
|
+
constructor(config) {
|
|
11819
|
+
this.state = "closed";
|
|
11820
|
+
this.failureCount = 0;
|
|
11821
|
+
this.successCount = 0;
|
|
11822
|
+
this.openUntil = 0;
|
|
11823
|
+
this.halfOpenRequests = 0;
|
|
11824
|
+
this.config = {
|
|
11825
|
+
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
11826
|
+
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
11827
|
+
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
11828
|
+
};
|
|
11829
|
+
}
|
|
11830
|
+
/**
|
|
11831
|
+
* Check if circuit is open (requests should be blocked)
|
|
11832
|
+
* Also handles automatic transition from open to half-open after timeout
|
|
11833
|
+
*/
|
|
11834
|
+
isOpen() {
|
|
11835
|
+
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
11836
|
+
return this.state === "open";
|
|
11837
|
+
}
|
|
11838
|
+
/**
|
|
11839
|
+
* Check if a request can be attempted
|
|
11840
|
+
* - closed: always yes
|
|
11841
|
+
* - open: always no
|
|
11842
|
+
* - half-open: limited number of probes
|
|
11843
|
+
*/
|
|
11844
|
+
canAttempt() {
|
|
11845
|
+
if (this.state === "closed") return true;
|
|
11846
|
+
if (this.state === "open") return false;
|
|
11847
|
+
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
11848
|
+
}
|
|
11849
|
+
/**
|
|
11850
|
+
* Increment half-open request counter (call before making request in half-open)
|
|
11851
|
+
*/
|
|
11852
|
+
incrementHalfOpenRequests() {
|
|
11853
|
+
if (this.state === "half-open") this.halfOpenRequests++;
|
|
11854
|
+
}
|
|
11855
|
+
/**
|
|
11856
|
+
* Record a successful request
|
|
11857
|
+
*/
|
|
11858
|
+
recordSuccess() {
|
|
11859
|
+
if (this.state === "half-open") {
|
|
11860
|
+
this.successCount++;
|
|
11861
|
+
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
11862
|
+
} else this.failureCount = 0;
|
|
11863
|
+
}
|
|
11864
|
+
/**
|
|
11865
|
+
* Record a failed request
|
|
11866
|
+
* Only counts transient failures toward circuit breaker threshold
|
|
11867
|
+
*/
|
|
11868
|
+
recordFailure(error) {
|
|
11869
|
+
if (!isTransientError(error)) return;
|
|
11870
|
+
this.failureCount++;
|
|
11871
|
+
if (this.state === "half-open") this.transitionTo("open");
|
|
11872
|
+
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
11873
|
+
}
|
|
11874
|
+
/**
|
|
11875
|
+
* Get current circuit state
|
|
11876
|
+
*/
|
|
11877
|
+
getState() {
|
|
11878
|
+
return {
|
|
11879
|
+
state: this.state,
|
|
11880
|
+
failureCount: this.failureCount,
|
|
11881
|
+
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
11882
|
+
};
|
|
11883
|
+
}
|
|
11884
|
+
/**
|
|
11885
|
+
* Transition to a new state
|
|
11886
|
+
*/
|
|
11887
|
+
transitionTo(newState) {
|
|
11888
|
+
this.state = newState;
|
|
11889
|
+
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
11890
|
+
else if (newState === "half-open") {
|
|
11891
|
+
this.halfOpenRequests = 0;
|
|
11892
|
+
this.successCount = 0;
|
|
11893
|
+
} else if (newState === "closed") {
|
|
11894
|
+
this.failureCount = 0;
|
|
11895
|
+
this.successCount = 0;
|
|
11896
|
+
this.halfOpenRequests = 0;
|
|
11950
11897
|
}
|
|
11951
|
-
}
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
const
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11898
|
+
}
|
|
11899
|
+
};
|
|
11900
|
+
/**
|
|
11901
|
+
* Fetch with timeout and retry logic
|
|
11902
|
+
*
|
|
11903
|
+
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
11904
|
+
* @param config - Retry configuration
|
|
11905
|
+
* @returns Result from successful fetch
|
|
11906
|
+
* @throws Last error after all retries exhausted
|
|
11907
|
+
*/
|
|
11908
|
+
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
11909
|
+
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
11910
|
+
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
11911
|
+
let lastError;
|
|
11912
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
11913
|
+
const controller = new AbortController();
|
|
11914
|
+
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
11915
|
+
try {
|
|
11916
|
+
return await fetcher(controller.signal);
|
|
11917
|
+
} finally {
|
|
11918
|
+
clearTimeout(timeoutId);
|
|
11969
11919
|
}
|
|
11970
|
-
})
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
domain,
|
|
11977
|
-
id
|
|
11978
|
-
}),
|
|
11979
|
-
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
11980
|
-
});
|
|
11920
|
+
} catch (error) {
|
|
11921
|
+
lastError = error;
|
|
11922
|
+
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
11923
|
+
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
11924
|
+
}
|
|
11925
|
+
throw lastError;
|
|
11981
11926
|
}
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
preview
|
|
11990
|
-
},
|
|
11991
|
-
siteId
|
|
11992
|
-
});
|
|
11993
|
-
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
11994
|
-
return input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
11995
|
-
endpoint: "getContentByPath",
|
|
11996
|
-
params: {
|
|
11997
|
-
siteId,
|
|
11998
|
-
path,
|
|
11999
|
-
preview: String(preview)
|
|
12000
|
-
},
|
|
12001
|
-
options: { signal: requestSignal }
|
|
12002
|
-
}), {
|
|
12003
|
-
preview,
|
|
12004
|
-
signal,
|
|
12005
|
-
publishedRuntimeCache,
|
|
12006
|
-
cacheTags: buildSiteReadTags({ siteId }),
|
|
12007
|
-
prebuildFallback: void 0
|
|
12008
|
-
});
|
|
11927
|
+
/**
|
|
11928
|
+
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
11929
|
+
*/
|
|
11930
|
+
function isAbortError$1(error) {
|
|
11931
|
+
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
11932
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
11933
|
+
return false;
|
|
12009
11934
|
}
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
11935
|
+
/**
|
|
11936
|
+
* Check if an error should be retried
|
|
11937
|
+
*/
|
|
11938
|
+
function shouldRetryError(error, customRetryOn) {
|
|
11939
|
+
if (isAbortError$1(error)) return false;
|
|
11940
|
+
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
11941
|
+
return isTransientError(error);
|
|
12015
11942
|
}
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
12023
|
-
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
12024
|
-
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
12025
|
-
const apiParams = {
|
|
12026
|
-
siteId,
|
|
12027
|
-
...ids && { ids }
|
|
12028
|
-
};
|
|
12029
|
-
return await deps.apiClient({
|
|
12030
|
-
endpoint: "getPublicBookingServices",
|
|
12031
|
-
params: apiParams,
|
|
12032
|
-
options: { signal: requestSignal }
|
|
12033
|
-
});
|
|
12034
|
-
}, {
|
|
12035
|
-
signal,
|
|
12036
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
12037
|
-
});
|
|
12038
|
-
},
|
|
12039
|
-
async getPublicWeeklySlotAvailability(params) {
|
|
12040
|
-
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
12041
|
-
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
12042
|
-
const cacheKey = [
|
|
12043
|
-
"public-weekly-slot-availability",
|
|
12044
|
-
siteId,
|
|
12045
|
-
serviceId,
|
|
12046
|
-
resourceId ?? "",
|
|
12047
|
-
horizonWeeks ?? "",
|
|
12048
|
-
timezone ?? ""
|
|
12049
|
-
].join(":");
|
|
12050
|
-
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
12051
|
-
const apiParams = {
|
|
12052
|
-
siteId,
|
|
12053
|
-
serviceId,
|
|
12054
|
-
...resourceId && { resourceId },
|
|
12055
|
-
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
12056
|
-
...timezone && { timezone }
|
|
12057
|
-
};
|
|
12058
|
-
return await deps.apiClient({
|
|
12059
|
-
endpoint: "getPublicWeeklySlotAvailability",
|
|
12060
|
-
params: apiParams,
|
|
12061
|
-
options: { signal: requestSignal }
|
|
12062
|
-
});
|
|
12063
|
-
}, {
|
|
12064
|
-
signal,
|
|
12065
|
-
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
12066
|
-
});
|
|
12067
|
-
}
|
|
12068
|
-
};
|
|
11943
|
+
/**
|
|
11944
|
+
* Get delay before retrying, respecting Retry-After if present
|
|
11945
|
+
*/
|
|
11946
|
+
function getRetryDelay(error, attempt, config) {
|
|
11947
|
+
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
11948
|
+
return calculateBackoff(attempt, config);
|
|
12069
11949
|
}
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
if (!siteId || !segment) throw new Error(`${kind === "event-run" ? "resolveEventRun" : "resolveEventOccurrence"}() requires siteId, subject, and segment`);
|
|
12076
|
-
const subjectId = subject.kind === "eventOffering" ? subject.eventOfferingId : subject.eventSeriesId;
|
|
12077
|
-
return deps.resilientFetchData("resolveEventSubroute", `${kind}:${siteId}:${subject.kind}:${subjectId}:${segment}:${preview ? "preview" : "published"}`, (requestSignal) => deps.apiClient({
|
|
12078
|
-
endpoint: "resolveEventSubroute",
|
|
12079
|
-
params: {
|
|
12080
|
-
siteId,
|
|
12081
|
-
kind,
|
|
12082
|
-
subjectKind: subject.kind,
|
|
12083
|
-
subjectId,
|
|
12084
|
-
segment,
|
|
12085
|
-
stage: preview ? "preview" : "published"
|
|
12086
|
-
},
|
|
12087
|
-
options: { signal: requestSignal }
|
|
12088
|
-
}), {
|
|
12089
|
-
signal,
|
|
12090
|
-
preview,
|
|
12091
|
-
cacheTags: buildPublicReadMemoryCacheTags("resolveEventSubroute", { siteId })
|
|
12092
|
-
});
|
|
12093
|
-
}
|
|
12094
|
-
return {
|
|
12095
|
-
async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
12096
|
-
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
12097
|
-
endpoint: "listPublicEventCalendarWindow",
|
|
12098
|
-
params: {
|
|
12099
|
-
...params,
|
|
12100
|
-
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
12101
|
-
},
|
|
12102
|
-
options: { signal: requestSignal }
|
|
12103
|
-
}), {
|
|
12104
|
-
signal,
|
|
12105
|
-
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
12106
|
-
});
|
|
12107
|
-
},
|
|
12108
|
-
async resolveEventOccurrence(params) {
|
|
12109
|
-
const response = await resolveEventSubroute(params, "event-occurrence");
|
|
12110
|
-
return { occurrence: response.subroute?.kind === "event-occurrence" ? response.subroute.occurrence : null };
|
|
12111
|
-
},
|
|
12112
|
-
async resolveEventRun(params) {
|
|
12113
|
-
const response = await resolveEventSubroute(params, "event-run");
|
|
12114
|
-
return { run: response.subroute?.kind === "event-run" ? response.subroute.run : null };
|
|
12115
|
-
}
|
|
12116
|
-
};
|
|
11950
|
+
/**
|
|
11951
|
+
* Sleep for specified milliseconds
|
|
11952
|
+
*/
|
|
11953
|
+
function sleep(ms) {
|
|
11954
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12117
11955
|
}
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
break;
|
|
12127
|
-
}
|
|
12128
|
-
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
11956
|
+
/**
|
|
11957
|
+
* Error thrown when circuit breaker is open
|
|
11958
|
+
*/
|
|
11959
|
+
var CircuitOpenError = class extends Error {
|
|
11960
|
+
constructor(state) {
|
|
11961
|
+
super("Circuit breaker is open");
|
|
11962
|
+
this.name = "CircuitOpenError";
|
|
11963
|
+
this.circuitState = state;
|
|
12129
11964
|
}
|
|
12130
|
-
|
|
12131
|
-
}
|
|
11965
|
+
};
|
|
12132
11966
|
//#endregion
|
|
12133
11967
|
//#region src/client/publicLoaderCacheAccess.ts
|
|
12134
11968
|
function shouldWrite(cacheEnabled, force) {
|
|
@@ -12207,6 +12041,38 @@ function generateRequestId() {
|
|
|
12207
12041
|
function toRecord(value) {
|
|
12208
12042
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
12209
12043
|
}
|
|
12044
|
+
function adapterExceptionMessage(error) {
|
|
12045
|
+
return error instanceof Error ? error.message : String(error);
|
|
12046
|
+
}
|
|
12047
|
+
function publishedCacheLifetime(plan, payload) {
|
|
12048
|
+
if (plan.endpoint !== "getContentByPath" || pageReadDependencies(payload) !== "availability") return {
|
|
12049
|
+
freshTtlSec: plan.freshTtlSec,
|
|
12050
|
+
staleTtlSec: plan.staleTtlSec
|
|
12051
|
+
};
|
|
12052
|
+
const ttl = buildPageReadCachePolicy(plan.siteId ?? "", "availability").revalidate;
|
|
12053
|
+
return {
|
|
12054
|
+
freshTtlSec: ttl,
|
|
12055
|
+
staleTtlSec: ttl
|
|
12056
|
+
};
|
|
12057
|
+
}
|
|
12058
|
+
function reusableDurablePayload(plan, payload, freshness) {
|
|
12059
|
+
return plan.endpoint !== "getContentByPath" || pageReadDependencies(payload) !== "availability" || freshness === "fresh";
|
|
12060
|
+
}
|
|
12061
|
+
function memoryWritePolicy(pageRead, data, tags, cacheTTL) {
|
|
12062
|
+
if (!pageRead) return { tags };
|
|
12063
|
+
const dependency = pageReadDependencies(data);
|
|
12064
|
+
const policy = buildPageReadCachePolicy(pageRead.siteId, dependency);
|
|
12065
|
+
return {
|
|
12066
|
+
tags: policy.tags,
|
|
12067
|
+
...dependency === "availability" ? {
|
|
12068
|
+
ttl: Math.min(cacheTTL, policy.revalidate * 1e3),
|
|
12069
|
+
staleTtl: 0
|
|
12070
|
+
} : {}
|
|
12071
|
+
};
|
|
12072
|
+
}
|
|
12073
|
+
function isPageReadRefusal(pageRead, error) {
|
|
12074
|
+
return Boolean(pageRead) && error instanceof RiverbankApiError && error.status === 404;
|
|
12075
|
+
}
|
|
12210
12076
|
function getRuntimePayloadSiteId(value) {
|
|
12211
12077
|
const site = toRecord(value).site;
|
|
12212
12078
|
if (!site || typeof site !== "object" || Array.isArray(site)) return null;
|
|
@@ -12331,7 +12197,8 @@ function convertToTypedError(error) {
|
|
|
12331
12197
|
requestId: error.requestId,
|
|
12332
12198
|
timestamp: error.timestamp,
|
|
12333
12199
|
status: error.status,
|
|
12334
|
-
fieldErrors: error.fieldErrors
|
|
12200
|
+
fieldErrors: error.fieldErrors,
|
|
12201
|
+
tag: error.tag
|
|
12335
12202
|
});
|
|
12336
12203
|
if (error instanceof ApiRequestError && error.body && typeof error.body === "object") {
|
|
12337
12204
|
const body = error.body;
|
|
@@ -12398,8 +12265,8 @@ const defaultRiverbankClientDeps = {
|
|
|
12398
12265
|
* ```
|
|
12399
12266
|
*/
|
|
12400
12267
|
/**
|
|
12401
|
-
*
|
|
12402
|
-
*
|
|
12268
|
+
* Next's tagged cache owns normal reads; SDK memory remains an outage fallback by default.
|
|
12269
|
+
* Explicitly enabled admitted-page memory hits also register their returned framework policy.
|
|
12403
12270
|
*/
|
|
12404
12271
|
function isRunningInNextServer() {
|
|
12405
12272
|
return typeof window === "undefined" && typeof process !== "undefined" && Boolean(process.env.NEXT_RUNTIME);
|
|
@@ -12411,6 +12278,12 @@ function resolveMemoryCachePolicy(config) {
|
|
|
12411
12278
|
servesFreshMemoryHits: enabled ?? !isRunningInNextServer()
|
|
12412
12279
|
};
|
|
12413
12280
|
}
|
|
12281
|
+
const frameworkCacheInstallers = /* @__PURE__ */ new WeakMap();
|
|
12282
|
+
/** Install host effects on an existing SDK client without replacing its cache or resilience state. */
|
|
12283
|
+
function installFrameworkCache(client, adapter) {
|
|
12284
|
+
frameworkCacheInstallers.get(client)?.(adapter);
|
|
12285
|
+
return client;
|
|
12286
|
+
}
|
|
12414
12287
|
function createRiverbankClient(config) {
|
|
12415
12288
|
return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
|
|
12416
12289
|
}
|
|
@@ -12449,7 +12322,18 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12449
12322
|
keyType = "preview";
|
|
12450
12323
|
break;
|
|
12451
12324
|
}
|
|
12452
|
-
|
|
12325
|
+
function createApiClient(frameworkCache) {
|
|
12326
|
+
const requestOptions = frameworkCache ? {
|
|
12327
|
+
...sdkRequestOptions,
|
|
12328
|
+
frameworkCache
|
|
12329
|
+
} : sdkRequestOptions;
|
|
12330
|
+
return withDefaultHeaders(authConfig.type === "none" ? deps.createInternalAPIClient(config.baseUrl, requestOptions) : deps.createBearerAPIClient(authConfig.type === "api-key" ? authConfig.key : authConfig.token, config.baseUrl, requestOptions), config.defaultHeaders);
|
|
12331
|
+
}
|
|
12332
|
+
const framework = {
|
|
12333
|
+
adapter: config.frameworkCache,
|
|
12334
|
+
apiClient: createApiClient(config.frameworkCache)
|
|
12335
|
+
};
|
|
12336
|
+
const apiClient = (params) => framework.apiClient(params);
|
|
12453
12337
|
const cache = new SimpleCache({
|
|
12454
12338
|
maxSize: cacheMaxSize,
|
|
12455
12339
|
ttl: cacheTTL,
|
|
@@ -12500,7 +12384,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12500
12384
|
const result = await reader({
|
|
12501
12385
|
cacheKey: plan.cacheKey,
|
|
12502
12386
|
endpoint: plan.endpoint,
|
|
12503
|
-
payloadSchemaVersion:
|
|
12387
|
+
payloadSchemaVersion: 5
|
|
12504
12388
|
});
|
|
12505
12389
|
if (result.kind === "miss") return {
|
|
12506
12390
|
kind: "miss",
|
|
@@ -12516,6 +12400,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12516
12400
|
error: result.error
|
|
12517
12401
|
}
|
|
12518
12402
|
};
|
|
12403
|
+
if (!reusableDurablePayload(plan, result.payload, result.freshness)) return null;
|
|
12519
12404
|
return {
|
|
12520
12405
|
kind: "hit",
|
|
12521
12406
|
result: emitStatus(result.freshness === "fresh" ? "cache" : "stale", result.payload, statusDetails({
|
|
@@ -12531,7 +12416,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12531
12416
|
outcome: "error",
|
|
12532
12417
|
error: {
|
|
12533
12418
|
kind: "adapter_exception",
|
|
12534
|
-
message:
|
|
12419
|
+
message: adapterExceptionMessage(error)
|
|
12535
12420
|
}
|
|
12536
12421
|
}
|
|
12537
12422
|
};
|
|
@@ -12547,13 +12432,21 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12547
12432
|
normalizedParams: plan.normalizedParams,
|
|
12548
12433
|
payload,
|
|
12549
12434
|
siteId: plan.siteId ?? getRuntimePayloadSiteId(payload),
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
payloadSchemaVersion: 4,
|
|
12435
|
+
...publishedCacheLifetime(plan, payload),
|
|
12436
|
+
payloadSchemaVersion: 5,
|
|
12553
12437
|
writeReason: "live_success"
|
|
12554
12438
|
});
|
|
12555
12439
|
} catch {}
|
|
12556
12440
|
}
|
|
12441
|
+
function tryPrebuildFallback(input) {
|
|
12442
|
+
const prebuild = input.allowed && !input.preview && input.fallback ? input.fallback() : null;
|
|
12443
|
+
return prebuild ? emitStatus("prebuild", prebuild.data, input.statusDetails({
|
|
12444
|
+
prebuildAgeSec: prebuild.prebuildAgeSec,
|
|
12445
|
+
cacheTier: "prebuild",
|
|
12446
|
+
durableCache: input.durableCache,
|
|
12447
|
+
error: input.error
|
|
12448
|
+
})) : null;
|
|
12449
|
+
}
|
|
12557
12450
|
async function resilientFetch(cacheKey, fetcher, options) {
|
|
12558
12451
|
const requestId = generateRequestId();
|
|
12559
12452
|
const startTime = Date.now();
|
|
@@ -12588,18 +12481,18 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12588
12481
|
}) : null;
|
|
12589
12482
|
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
12590
12483
|
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12484
|
+
const prebuild = tryPrebuildFallback({
|
|
12485
|
+
allowed: allowFallbacks,
|
|
12486
|
+
preview: isPreview,
|
|
12487
|
+
fallback: options.prebuildFallback,
|
|
12488
|
+
statusDetails,
|
|
12489
|
+
durableCache,
|
|
12490
|
+
error: {
|
|
12491
|
+
code: "circuit_open",
|
|
12492
|
+
message: "Circuit breaker is open"
|
|
12493
|
+
}
|
|
12494
|
+
});
|
|
12495
|
+
if (prebuild) return prebuild;
|
|
12603
12496
|
const circuitState = circuitBreaker.getState();
|
|
12604
12497
|
emitStatus("error", null, statusDetails({
|
|
12605
12498
|
durableCache,
|
|
@@ -12631,10 +12524,11 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12631
12524
|
} catch (error) {
|
|
12632
12525
|
convertToTypedError(error);
|
|
12633
12526
|
}
|
|
12634
|
-
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data,
|
|
12527
|
+
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, memoryWritePolicy(options.pageRead, data, options.cacheTags, cacheTTL));
|
|
12635
12528
|
if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
|
|
12636
12529
|
return emitStatus("live", data, statusDetails());
|
|
12637
12530
|
} catch (error) {
|
|
12531
|
+
if (isPageReadRefusal(options.pageRead, error)) throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({ error: getRiverbankErrorInfo(error) })).resilience);
|
|
12638
12532
|
if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
|
|
12639
12533
|
if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
|
|
12640
12534
|
const stale = cache.getStale(cacheKey);
|
|
@@ -12651,15 +12545,15 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12651
12545
|
const durableFallback = allowFallbacks && !isPreview ? await tryPublishedRuntimeCacheFallback(options.publishedRuntimeCache, statusDetails, errorInfo) : null;
|
|
12652
12546
|
const durableCache = durableFallback?.kind === "miss" || durableFallback?.kind === "error" ? durableFallback.diagnostic : void 0;
|
|
12653
12547
|
if (durableFallback?.kind === "hit") return durableFallback.result;
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12548
|
+
const prebuild = tryPrebuildFallback({
|
|
12549
|
+
allowed: allowFallbacks,
|
|
12550
|
+
preview: isPreview,
|
|
12551
|
+
fallback: options.prebuildFallback,
|
|
12552
|
+
statusDetails,
|
|
12553
|
+
durableCache,
|
|
12554
|
+
error: errorInfo
|
|
12555
|
+
});
|
|
12556
|
+
if (prebuild) return prebuild;
|
|
12663
12557
|
throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({
|
|
12664
12558
|
error: errorInfo,
|
|
12665
12559
|
durableCache
|
|
@@ -12672,7 +12566,10 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12672
12566
|
const contentReads = createContentReadOperations({
|
|
12673
12567
|
apiClient,
|
|
12674
12568
|
resilientFetch,
|
|
12675
|
-
prebuildLoader
|
|
12569
|
+
prebuildLoader,
|
|
12570
|
+
get frameworkCache() {
|
|
12571
|
+
return framework.adapter;
|
|
12572
|
+
}
|
|
12676
12573
|
});
|
|
12677
12574
|
const eventReads = createPublicEventReadOperations({
|
|
12678
12575
|
apiClient,
|
|
@@ -12696,7 +12593,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12696
12593
|
prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
|
|
12697
12594
|
}));
|
|
12698
12595
|
}
|
|
12699
|
-
|
|
12596
|
+
const client = {
|
|
12700
12597
|
async getSite(params) {
|
|
12701
12598
|
return (await contentReads.getSiteWithResilience(params)).data;
|
|
12702
12599
|
},
|
|
@@ -13063,6 +12960,12 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
13063
12960
|
return config.baseUrl;
|
|
13064
12961
|
}
|
|
13065
12962
|
};
|
|
12963
|
+
frameworkCacheInstallers.set(client, (adapter) => {
|
|
12964
|
+
if (framework.adapter) return;
|
|
12965
|
+
framework.apiClient = createApiClient(adapter);
|
|
12966
|
+
framework.adapter = adapter;
|
|
12967
|
+
});
|
|
12968
|
+
return client;
|
|
13066
12969
|
}
|
|
13067
12970
|
//#endregion
|
|
13068
|
-
export {
|
|
12971
|
+
export { derivePublishedRuntimeCacheKey as a, isPublishedRuntimeCacheKeyEndpoint as c, parsePublishedRuntimeCacheKeyDetails as d, parsePublishedRuntimeCachePayloadSchemaVersion as f, createBearerAPIClient as g, sdkRequestOptions as h, classifyPublishedRuntimeCacheFreshness as i, normalizeRuntimePublicPath as l, buildEndpointURL as m, installFrameworkCache as n, resolveRuntimeCachePolicy as o, API_ENDPOINTS as p, CircuitOpenError as r, DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as s, createRiverbankClient as t, parsePublishedRuntimeCacheKey as u };
|