@riverbankcms/sdk 0.179.0 → 0.180.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 +2 -2
- package/dist/_dts/{BlocksIslandsHydrator-DKwgs95u.d.ts → BlocksIslandsHydrator-DC_AvZwy.d.ts} +1 -1
- package/dist/_dts/{Page-lWenra5i.d.ts → Page-DQOxVtp3.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-BRxhRw4I.d.ts → SdkPreviewMode-DrLgY9_f.d.ts} +3 -2
- package/dist/_dts/{client-qWn7xAwJ.d.ts → client-BP7VBRvs.d.ts} +235 -56
- package/dist/_dts/{content-types-DL6GIvTm.d.ts → content-types-1-K2qi__.d.ts} +2 -2
- package/dist/_dts/{contracts-CzWyAiJj.d.ts → contracts-Dfqz0Tcu.d.ts} +3 -3
- package/dist/_dts/{generatePageMetadata-CBKd0cJ4.d.ts → generatePageMetadata-CSfAqmry.d.ts} +2 -2
- package/dist/_dts/{index-DVSipdrT.d.ts → index-B0_2-65A.d.ts} +3 -3
- package/dist/_dts/{index-DCiSHd-C.d.ts → index-BeM5Ylwf.d.ts} +5 -3
- package/dist/_dts/{index-BYnG_vF5.d.ts → index-Blrw2oVk.d.ts} +1 -1
- package/dist/_dts/{index-CaCum9mM.d.ts → index-CB5Csefo.d.ts} +2 -2
- package/dist/_dts/{index-CZgJrhzT.d.ts → index-DCcxLa8p.d.ts} +2 -2
- package/dist/_dts/{index-7CDBZGb-.d.ts → index-DQBGwBPx.d.ts} +1 -1
- package/dist/_dts/{index-BU9uAkHB.d.ts → index-DQr358-m.d.ts} +4 -4
- package/dist/_dts/{loadContent-CPKbFQyq.d.ts → loadContent-BG2tLGXj.d.ts} +7 -7
- package/dist/_dts/{request-BjKBCS7t.d.ts → request-P08l6mkr.d.ts} +2602 -821
- package/dist/_dts/{resolveBlockData-DupbMCup.d.ts → resolveBlockData-BDHc8lFs.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-BqNyCHi8.d.ts → resolvePageContent-Y3IZBbtL.d.ts} +1 -1
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +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 +2 -2
- package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
- 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 +8 -8
- 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 +3 -3
- 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 +6 -6
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +6 -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 → serviceBookingOutline-BvtNagjw.d.ts} +8 -7
- package/dist/_dts/{types-BOxSq-Bq.d.ts → types-BrK6SS5c.d.ts} +9 -8
- package/dist/_dts/{types-CT-KOxl_.d.ts → types-DpEAnP4F.d.ts} +7 -2
- package/dist/_dts/{types-B7e6Lmo5.d.ts → types-HAy1-Jjo.d.ts} +3 -3
- package/dist/_dts/{validation-Dz6qccue.d.ts → validation-D6q3tOBA.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-1XifJg6V.mjs → BlocksIslandsHydrator-DJSmdNUJ.mjs} +16 -16
- package/dist/client/{BookingMailingListNote-BsbEgagJ.mjs → BookingMailingListNote-CGxg37zx.mjs} +91 -59
- package/dist/client/{BookingQuestionFields-C8IbeLHj.mjs → BookingQuestionFields-DXegGSnS.mjs} +24 -3
- package/dist/client/{CalendarNavigationChevron-Bbqij1XQ.mjs → CalendarNavigationChevron-VfP50sYm.mjs} +5 -5
- package/dist/client/{DemoBookingPortalAccess-uA9H8LIL.mjs → DemoBookingPortalAccess-0Ua44F1j.mjs} +12 -7
- package/dist/client/{EventCalendar.client-yoSI77ov.mjs → EventCalendar.client-CrpiyDSP.mjs} +9 -9
- package/dist/client/{EventCombined.client-HeCNlliq.mjs → EventCombined.client-D0me9wnz.mjs} +8 -8
- package/dist/client/{EventItem-Duhk1vnF.mjs → EventItem-CJITrGkF.mjs} +5 -4
- package/dist/client/{EventListWeekNavigation-BiutEqPK.mjs → EventListWeekNavigation-BlEm_xjq.mjs} +1 -1
- package/dist/client/{EventListing.client-B5ln77jG.mjs → EventListing.client-BNM_HuS0.mjs} +3 -3
- package/dist/client/{EventListing.view-hUDhNtMv.mjs → EventListing.view-CXfb7RRy.mjs} +7 -210
- package/dist/client/{EventRegistrationPayment-DqtX1vB2.mjs → EventRegistrationPayment-DiD9uYs6.mjs} +1292 -224
- package/dist/client/{Page-ChJ2TGVk.mjs → Page-bX7iy_MK.mjs} +158 -50
- package/dist/client/{SiteTermsAgreementField-CDBU31xW.mjs → SiteTermsAgreementField-BAdW5DvE.mjs} +22 -15
- package/dist/client/{StepIndicator-JQA-VuEH.mjs → StepIndicator-DCfdcb7s.mjs} +1 -1
- package/dist/client/{StepIndicator-2Dl9zon2.mjs → StepIndicator-DCqorVne.mjs} +6 -6
- package/dist/client/{accordion-B6SqU49k.mjs → accordion-wofJY8xY.mjs} +1 -1
- package/dist/client/{booking-form.client-DrEOjQ3N.mjs → booking-form.client-CYl9NrqS.mjs} +410 -77
- package/dist/client/{bookingForm-drZBwEZW.mjs → bookingForm-kgVWtuMe.mjs} +4 -4
- package/dist/client/bookings.mjs +40 -10
- package/dist/client/{boxStyleClassNames-DEh45w16.mjs → boxStyleClassNames-CQHWz5gJ.mjs} +2 -2
- package/dist/client/{carousel-C-YJliD-.mjs → carousel-BE1dEFsD.mjs} +1 -1
- package/dist/client/{cart-acGFWK9R.mjs → cart-BsjsdGZE.mjs} +3 -3
- package/dist/client/{cart.client-BzlOGP2j.mjs → cart.client-DylGUWXY.mjs} +1 -1
- package/dist/client/{checkout-SEontwhy.mjs → checkout-B5KxEUDr.mjs} +3 -3
- package/dist/client/{checkout.client-C0Qvh-d4.mjs → checkout.client-C98fhch3.mjs} +1 -1
- package/dist/client/{checkoutUrls-yUKeq1N9.mjs → checkoutUrls-BMLYTf38.mjs} +1 -1
- package/dist/client/client.mjs +224 -158
- package/dist/client/constants-PfYJsEZF.mjs +101 -0
- package/dist/client/{context-DTrwaQtg.mjs → context-DtKdUdkO.mjs} +199 -27
- package/dist/client/{dateFormatting-Cg8E1r9l.mjs → dateFormatting-BaGPvQS3.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-D0kOJYOX.mjs → demoPortalMagicLink-B8eDjhuG.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-DyrpZ7ks.mjs → enhanceHeaderSection-DvhD-8eE.mjs} +3 -3
- package/dist/client/{event-registration.client-RLZQWi2V.mjs → event-registration.client-Du9a_xAN.mjs} +1980 -1517
- package/dist/client/{eventCalendar-CphYnImh.mjs → eventCalendar-Di9wDfzl.mjs} +4 -4
- package/dist/client/{eventCombined-BvqjASB_.mjs → eventCombined-CNW6nBsB.mjs} +4 -4
- package/dist/client/{eventListing-BaNAoC_M.mjs → eventListing-CQMxQ8By.mjs} +4 -4
- package/dist/client/{eventRegistration-COMHoRl6.mjs → eventRegistration-CprS9k1D.mjs} +4 -4
- package/dist/client/{form-DyH2juYT.mjs → form-Zl1_8RJ6.mjs} +3 -3
- package/dist/client/{form.client-DBwzkB0M.mjs → form.client-TaMUys6I.mjs} +4 -4
- package/dist/client/{form.parts-CY4kX3mh.mjs → form.parts-CpNPbPPM.mjs} +1 -1
- package/dist/client/{formatDate-CTEN7gxW.mjs → formatDate-hhI1-tzt.mjs} +1 -1
- package/dist/client/gifting/client.mjs +5 -5
- package/dist/client/{gifting-CIx4V378.mjs → gifting-DNVa7-Wj.mjs} +4 -4
- package/dist/client/{gifting.client-BEVPpzJM.mjs → gifting.client-CFUq3GVx.mjs} +4 -4
- package/dist/client/{gifting.parts-VnORjnZK.mjs → gifting.parts-CDQvxA4A.mjs} +2 -2
- package/dist/client/{headerSection-DGcJfRS8.mjs → headerSection-Cg6083rn.mjs} +2 -2
- package/dist/client/{lookSurfaces-IqT_SVnX.mjs → lookSurfaces-gJ3OqPf9.mjs} +92 -2
- package/dist/client/{newsletter-form.client-BvEDkjiD.mjs → newsletter-form.client-VuL9I96G.mjs} +5 -5
- package/dist/client/{newsletter-form.interactive-DCO1lErD.mjs → newsletter-form.interactive-7Of3eYn0.mjs} +18 -24
- package/dist/client/{newsletter-form.parts-BIy4IUT3.mjs → newsletter-form.parts-OBqsfT24.mjs} +1 -1
- package/dist/client/{newsletterForm-CoTXDNFS.mjs → newsletterForm-BkJe_RTv.mjs} +3 -3
- package/dist/client/portal/client.mjs +299 -115
- package/dist/client/{product-detail.client-YHQ2aKX1.mjs → product-detail.client-B2hdxqJN.mjs} +1 -1
- package/dist/client/{product-list.client-DxoZw1vF.mjs → product-list.client-CCEgu9rx.mjs} +1 -1
- package/dist/client/{productDetail-DjuFvkey.mjs → productDetail-CRX_ZRfS.mjs} +3 -3
- package/dist/client/{productList-DE9GEFoZ.mjs → productList-BAdJ6z5S.mjs} +3 -3
- package/dist/client/{propsDecoder-Cyag_HOs.mjs → propsDecoder-BLKAmX0S.mjs} +2 -2
- package/dist/client/{registry.server-BPwV-0Pp.mjs → registry.server-Bj9cmHHF.mjs} +89 -50
- package/dist/client/rendering/client.mjs +22 -22
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +4 -4
- package/dist/client/{richText-coerce-NrRqDeOg.mjs → richText-coerce-Z45OLLEX.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-BWq5gKFK.mjs → routeIslandApiConfig-DHpTTK77.mjs} +1 -1
- package/dist/client/{shop-C3wM0Hr4.mjs → shop-BKsgxm_-.mjs} +3 -3
- package/dist/client/{shop-commerce-34YvcpbX.mjs → shop-commerce-Cbtk_kUW.mjs} +12 -12
- package/dist/client/{shop-commerce-store-B7xHksOs.mjs → shop-commerce-store-B-rv2p5h.mjs} +1 -1
- package/dist/client/{shop-discount-apply.state-BiBnozfO.mjs → shop-discount-apply.state-CiCDLNh7.mjs} +2 -2
- package/dist/client/{shop.client-C0v88nLd.mjs → shop.client-Rnqa74Tk.mjs} +12 -12
- package/dist/client/{shopShared-Ct-BRNez.mjs → shopShared-BaBfhjCq.mjs} +2 -2
- package/dist/client/{src-CCtanNlD.mjs → src-o7WEvbK1.mjs} +118 -3
- package/dist/client/{timetableModel-lhE29TNT.mjs → timetableModel-BOff1Kk5.mjs} +201 -7
- package/dist/client/{useAvailableSlots-BelJviOT.mjs → useAvailableSlots-DQJNh10g.mjs} +3 -23
- package/dist/client/{useDiscountCodeUi-rQRE1-Ho.mjs → useDiscountCodeUi-BcFQRI_7.mjs} +1 -1
- package/dist/client/{useEventPagination-C4rS2Xxl.mjs → useEventPagination-BvdcexDC.mjs} +7 -7
- package/dist/client/{view-LJVHVqsy.mjs → view-CTBwSpKv.mjs} +3 -3
- package/dist/client/{wizardSteps-CNDsxeJH.mjs → wizardSteps-CWIQyRIw.mjs} +1605 -442
- package/dist/preview-next/before-render.mjs +1 -0
- package/dist/preview-next/client/{LocationPickerEnvironment-BHAT81Wx.mjs → LocationPickerEnvironment-BW3dRFIv.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-B52hkdIZ.mjs → MapLibreEditMap-Db9BHyXh.mjs} +2 -2
- package/dist/preview-next/client/{PageSectionToolbar-C4TtBPN-.mjs → PageSectionToolbar-CG6KwITA.mjs} +4 -4
- package/dist/preview-next/client/{PreviewEditorSidebar-D6fkE59-.mjs → PreviewEditorSidebar-BGBqrC9m.mjs} +8 -7
- package/dist/preview-next/client/{PreviewEditorUI-amcDlj0O.mjs → PreviewEditorUI-Bwkyx28x.mjs} +5 -5
- package/dist/preview-next/client/{PreviewShell-DeQjx4zk.mjs → PreviewShell-DB1l6JNU.mjs} +7 -7
- package/dist/preview-next/client/{SdkPreviewModeRuntime-Cx0SXnoX.mjs → SdkPreviewModeRuntime-Bs6Cwzr3.mjs} +15 -7
- package/dist/preview-next/client/{lucide-react-McYZeSMb.mjs → lucide-react-00FF_oar.mjs} +13 -1
- package/dist/preview-next/client/{previewAssistantSlot-aqpU34WI.mjs → previewAssistantSlot-T-oDD_Dd.mjs} +5735 -2073
- package/dist/preview-next/client/{previewChromeRoot-D3Gy_Rs0.mjs → previewChromeRoot-BeukcDRy.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-Dzx_RrN7.mjs → sdk-runtime-ceDW_9q2.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-LHedw83e.mjs → siteStyleAccess-CCB9bScO.mjs} +35 -23
- package/dist/preview-next/client/{useAutosaveStatus-DpSd9aVk.mjs → useAutosaveStatus-D4o0CKq7.mjs} +1 -1
- package/dist/preview-next/client/{useOpenBlockForSetup-BGZn5AT1.mjs → useOpenBlockForSetup-Seccrvwu.mjs} +2 -2
- package/dist/preview-next/container-responsive.css +103 -10
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-DnL-FgSV.mjs → route-contract-FwFj8zGL.mjs} +43 -0
- package/dist/server/{Block.shared-BEbq6EwO.mjs → Block.shared-D6WrRCxX.mjs} +4 -4
- package/dist/server/{ThemeScopeCore-DFEM1a85.mjs → ThemeScopeCore-BQzjDQ2q.mjs} +8 -1
- package/dist/server/{bindings-Bly0dRs7.mjs → bindings-CS6ih1Yc.mjs} +4 -4
- package/dist/server/{client-CGJ2ztYp.mjs → client-m0ylCj_f.mjs} +847 -786
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/index.mjs +2 -2
- package/dist/server/{loadContent-BkK1w3QQ.mjs → loadContent-vgWMz1uD.mjs} +6 -4
- package/dist/server/{loadPage-DTLe0FEs.mjs → loadPage-CIOL3-9t.mjs} +3 -3
- package/dist/server/{lookMediaFrame-CaH018pK.mjs → lookMediaFrame-m-91jGGn.mjs} +36 -0
- package/dist/server/next.mjs +43 -30
- package/dist/server/{overrideResolution-Uy9Zp2Ks.mjs → overrideResolution-BiHmsvTZ.mjs} +1 -1
- package/dist/server/page-converter.mjs +1 -1
- package/dist/server/{pageRenderPlan-JzxBnqfV.mjs → pageRenderPlan-DJo_obpi.mjs} +9 -7
- package/dist/server/{pageRuntimeSupport-DyNSd2Yj.mjs → pageRuntimeSupport-BnSuoHON.mjs} +5 -1
- package/dist/server/{pageShared-DU4ETFPS.mjs → pageShared-BJuOzxzn.mjs} +550 -258
- package/dist/server/{prebuild-8jNtDXmS.mjs → prebuild-Cr8p8T7V.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-xeMG42aw.mjs → prefetchBlockData-BZh57-ua.mjs} +4 -3
- package/dist/server/{registry-DH1VrsCl.mjs → registry-CvhFwbXJ.mjs} +240 -80
- 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 +4 -4
- package/dist/server/rendering.mjs +8 -8
- package/dist/server/{resolveBlockData-BN8tweTx.mjs → resolveBlockData-Cv_W1LVB.mjs} +39 -31
- package/dist/server/{resolvePageContent-DnM16_f9.mjs → resolvePageContent-BWKUZUIn.mjs} +1 -1
- package/dist/server/{responseMedia-F-ElH2Rd.mjs → responseMedia-KRKguBC5.mjs} +56 -1
- package/dist/server/routing.mjs +1 -1
- package/dist/server/server.mjs +3 -3
- package/dist/server/{servicePageContent-B-FezJmH.mjs → servicePageContent-CRKbTm_7.mjs} +14 -10
- package/dist/server/theme-bridge.mjs +1 -1
- package/dist/server/{validation-3jOzYdPL.mjs → validation-DCl-FCk_.mjs} +4 -4
- package/dist/server/{version-8t0o6_jd.mjs → version-DT_R5JAR.mjs} +1 -1
- package/dist/styles/index.css +504 -27
- package/package.json +1 -1
- package/dist/client/constants-4o4_hl34.mjs +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as parseSurfaceTree } from "./accessibleSurfaces-CM3QANtw.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { i as rethrowClientFrameworkSignal, l as isSupportedLoaderEndpoint, o as encodePublicProductCategorySelector, r as findFrameworkSignal, t as materializeEntriesMedia } from "./responseMedia-KRKguBC5.mjs";
|
|
3
3
|
import { f as parseSiteId, t as publicMapLocationParamsSchema } from "./mapLocation-BM5WX7FY.mjs";
|
|
4
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-
|
|
5
|
+
import { t as SDK_VERSION } from "./version-DT_R5JAR.mjs";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
/**
|
|
8
8
|
* How long a rendered page may hold availability it read through the batch
|
|
@@ -1377,6 +1377,17 @@ const APPOINTMENT_ENDPOINT_DEFINITIONS = defineEndpointDefinitions({
|
|
|
1377
1377
|
"server:internal_error"
|
|
1378
1378
|
]
|
|
1379
1379
|
},
|
|
1380
|
+
getTeamMemberTemplatePreview: {
|
|
1381
|
+
path: "/sites/{siteId}/bookings/profile-editor/{entryId}/template-preview",
|
|
1382
|
+
method: "GET",
|
|
1383
|
+
auth: "user",
|
|
1384
|
+
responseKind: "json",
|
|
1385
|
+
errors: [
|
|
1386
|
+
"auth:forbidden",
|
|
1387
|
+
"resource:not_found",
|
|
1388
|
+
"server:internal_error"
|
|
1389
|
+
]
|
|
1390
|
+
},
|
|
1380
1391
|
updateTeamMemberProfilePolicy: {
|
|
1381
1392
|
path: "/sites/{siteId}/bookings/resources/profile-policy",
|
|
1382
1393
|
method: "PUT",
|
|
@@ -7772,6 +7783,38 @@ const API_ENDPOINTS$1 = {
|
|
|
7772
7783
|
"server:internal_error"
|
|
7773
7784
|
]
|
|
7774
7785
|
},
|
|
7786
|
+
getEventRoomsRoster: {
|
|
7787
|
+
errors: [],
|
|
7788
|
+
path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms",
|
|
7789
|
+
method: "GET",
|
|
7790
|
+
tags: ["site-{siteId}", "event-series-{seriesId}"],
|
|
7791
|
+
auth: "user",
|
|
7792
|
+
responseKind: "json"
|
|
7793
|
+
},
|
|
7794
|
+
getChangeEventRoomOptions: {
|
|
7795
|
+
errors: [],
|
|
7796
|
+
path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms/change/options",
|
|
7797
|
+
method: "GET",
|
|
7798
|
+
tags: [
|
|
7799
|
+
"site-{siteId}",
|
|
7800
|
+
"event-series-{seriesId}",
|
|
7801
|
+
"bookings"
|
|
7802
|
+
],
|
|
7803
|
+
auth: "user",
|
|
7804
|
+
responseKind: "json"
|
|
7805
|
+
},
|
|
7806
|
+
changeEventRoom: {
|
|
7807
|
+
errors: [],
|
|
7808
|
+
path: "/sites/{siteId}/bookings/event-series/{seriesId}/rooms/change",
|
|
7809
|
+
method: "POST",
|
|
7810
|
+
tags: [
|
|
7811
|
+
"site-{siteId}",
|
|
7812
|
+
"event-series-{seriesId}",
|
|
7813
|
+
"bookings"
|
|
7814
|
+
],
|
|
7815
|
+
auth: "user",
|
|
7816
|
+
responseKind: "json"
|
|
7817
|
+
},
|
|
7775
7818
|
listEventSeriesAttendees: {
|
|
7776
7819
|
path: "/sites/{siteId}/bookings/event-series/{seriesId}/attendees",
|
|
7777
7820
|
method: "GET",
|
|
@@ -10124,14 +10167,6 @@ function resolveApiBaseUrl() {
|
|
|
10124
10167
|
}
|
|
10125
10168
|
//#endregion
|
|
10126
10169
|
//#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
10170
|
function isRecord(value) {
|
|
10136
10171
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10137
10172
|
}
|
|
@@ -10146,130 +10181,146 @@ function envelopePage(body) {
|
|
|
10146
10181
|
const data = isRecord(body) && body.success === true && isRecord(body.data) ? body.data : null;
|
|
10147
10182
|
return data?.type === "content" && isRecord(data.content) ? data.content : data;
|
|
10148
10183
|
}
|
|
10149
|
-
function
|
|
10184
|
+
function parseBody(body) {
|
|
10150
10185
|
try {
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10186
|
+
return JSON.parse(body);
|
|
10187
|
+
} catch {
|
|
10188
|
+
return null;
|
|
10189
|
+
}
|
|
10190
|
+
}
|
|
10191
|
+
const header = (snapshot, name) => snapshot.headers.find(([key]) => key.toLowerCase() === name)?.[1];
|
|
10192
|
+
/** Only a complete, resolved page is stored. Anything else passes through and keeps the policy its failure names. */
|
|
10193
|
+
function admit(snapshot) {
|
|
10194
|
+
const page = envelopePage(parseBody(snapshot.body));
|
|
10195
|
+
if (snapshot.status === 200 && isResolvedPage(page)) {
|
|
10196
|
+
if (header(snapshot, "x-riverbank-page-storage") === "no-store") return {
|
|
10197
|
+
kind: "pass-through",
|
|
10198
|
+
dependencies: "availability"
|
|
10199
|
+
};
|
|
10200
|
+
return {
|
|
10201
|
+
kind: "store",
|
|
10154
10202
|
dependencies: page.dependencies
|
|
10155
10203
|
};
|
|
10156
|
-
}
|
|
10204
|
+
}
|
|
10157
10205
|
return {
|
|
10158
|
-
|
|
10159
|
-
dependencies: snapshot.status === 200 || snapshot
|
|
10206
|
+
kind: "pass-through",
|
|
10207
|
+
dependencies: snapshot.status === 200 || header(snapshot, "x-riverbank-page-dependencies") === "availability" ? "availability" : "content"
|
|
10160
10208
|
};
|
|
10161
10209
|
}
|
|
10162
|
-
/**
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
}));
|
|
10174
|
-
pending.set("response", response);
|
|
10175
|
-
return response;
|
|
10210
|
+
/**
|
|
10211
|
+
* One cache entry per request, judged by the policy it is looked up with. Content is looked up first, so a
|
|
10212
|
+
* plain page costs one lookup and never registers the availability policy. A page whose snapshot depends on
|
|
10213
|
+
* availability is looked up again under that policy, which checks its tags and 60-second budget. A snapshot
|
|
10214
|
+
* past its own budget is never served: the live read replaces it.
|
|
10215
|
+
*/
|
|
10216
|
+
function planPageRead(state, now, budgetSeconds) {
|
|
10217
|
+
const subject = state.live ?? state.cached;
|
|
10218
|
+
if (!subject) return {
|
|
10219
|
+
kind: "lookup",
|
|
10220
|
+
dependencies: "content"
|
|
10176
10221
|
};
|
|
10222
|
+
const { dependencies } = admit(subject);
|
|
10223
|
+
if (!state.lookedUp.includes(dependencies)) return {
|
|
10224
|
+
kind: "lookup",
|
|
10225
|
+
dependencies
|
|
10226
|
+
};
|
|
10227
|
+
if (state.live) return {
|
|
10228
|
+
kind: "serve",
|
|
10229
|
+
snapshot: state.live
|
|
10230
|
+
};
|
|
10231
|
+
return now - subject.cachedAt < budgetSeconds(dependencies) * 1e3 ? {
|
|
10232
|
+
kind: "serve",
|
|
10233
|
+
snapshot: subject
|
|
10234
|
+
} : { kind: "read-live" };
|
|
10177
10235
|
}
|
|
10178
|
-
/**
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10236
|
+
/**
|
|
10237
|
+
* `unstable_cache` stores whatever its callback returns, so a response that must not be kept leaves the
|
|
10238
|
+
* callback by this one exception, which `lookup` turns back into a value straight away.
|
|
10239
|
+
*/
|
|
10240
|
+
var PassThroughResponse = class extends Error {
|
|
10241
|
+
constructor(snapshot) {
|
|
10242
|
+
super("Page read must not be stored");
|
|
10243
|
+
this.snapshot = snapshot;
|
|
10244
|
+
}
|
|
10245
|
+
};
|
|
10246
|
+
async function lookup(input, dependencies) {
|
|
10247
|
+
const { tags } = buildPageReadCachePolicy(input.siteId, dependencies);
|
|
10248
|
+
const load = async () => {
|
|
10249
|
+
const snapshot = await input.live();
|
|
10250
|
+
if (admit(snapshot).kind === "pass-through") throw new PassThroughResponse(snapshot);
|
|
10186
10251
|
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) {
|
|
10252
|
+
};
|
|
10214
10253
|
try {
|
|
10215
|
-
return
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10254
|
+
return {
|
|
10255
|
+
cached: await input.cache(load, ["page-read-envelope-v3", input.key], {
|
|
10256
|
+
revalidate: input.budgetSeconds(dependencies),
|
|
10257
|
+
tags
|
|
10258
|
+
})(),
|
|
10259
|
+
live: null
|
|
10260
|
+
};
|
|
10221
10261
|
} catch (error) {
|
|
10222
|
-
if (error instanceof
|
|
10262
|
+
if (error instanceof PassThroughResponse) return {
|
|
10263
|
+
cached: null,
|
|
10264
|
+
live: error.snapshot
|
|
10265
|
+
};
|
|
10223
10266
|
throw error;
|
|
10224
10267
|
}
|
|
10225
10268
|
}
|
|
10226
|
-
async function
|
|
10227
|
-
const
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
});
|
|
10234
|
-
if (candidate) try {
|
|
10235
|
-
const checked = await readPolicy({
|
|
10236
|
-
...input,
|
|
10237
|
-
dependency: admit(candidate).dependencies
|
|
10269
|
+
async function runPlan(input, state) {
|
|
10270
|
+
const step = planPageRead(state, Date.now(), input.budgetSeconds);
|
|
10271
|
+
switch (step.kind) {
|
|
10272
|
+
case "serve": return step.snapshot;
|
|
10273
|
+
case "read-live": return runPlan(input, {
|
|
10274
|
+
...state,
|
|
10275
|
+
live: await input.live()
|
|
10238
10276
|
});
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10277
|
+
case "lookup": {
|
|
10278
|
+
const found = await lookup(input, step.dependencies);
|
|
10279
|
+
return runPlan(input, {
|
|
10280
|
+
lookedUp: [...state.lookedUp, step.dependencies],
|
|
10281
|
+
cached: found.cached ?? state.cached,
|
|
10282
|
+
live: state.live ?? found.live
|
|
10283
|
+
});
|
|
10284
|
+
}
|
|
10243
10285
|
}
|
|
10244
|
-
return storeResponse(input, await readInCacheScope(input.cache, input.key, input.read));
|
|
10245
10286
|
}
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
}
|
|
10287
|
+
/**
|
|
10288
|
+
* One transport read per page read, shared by a miss, a stale entry's refresh and the live fallback.
|
|
10289
|
+
* It starts only when one of them asks for it.
|
|
10290
|
+
*/
|
|
10291
|
+
function sharedRead(read) {
|
|
10292
|
+
const transport = { started: null };
|
|
10293
|
+
return () => transport.started ?? (transport.started = read().then(async (value) => ({
|
|
10294
|
+
body: await value.text(),
|
|
10295
|
+
status: value.status,
|
|
10296
|
+
headers: [...value.headers.entries()],
|
|
10297
|
+
cachedAt: Date.now()
|
|
10298
|
+
})));
|
|
10259
10299
|
}
|
|
10260
10300
|
async function cachePageReadResponse(input) {
|
|
10261
|
-
if (!input.cache) return input.read();
|
|
10262
|
-
const
|
|
10263
|
-
|
|
10301
|
+
if (!input.cache || input.maxAge !== void 0 && input.maxAge <= 0) return input.read();
|
|
10302
|
+
const maxAge = input.maxAge;
|
|
10303
|
+
const budgetSeconds = (dependencies) => {
|
|
10304
|
+
const policy = buildPageReadCachePolicy(input.siteId, dependencies).revalidate;
|
|
10305
|
+
return maxAge === void 0 ? policy : Math.min(policy, maxAge);
|
|
10306
|
+
};
|
|
10307
|
+
const result = await runPlan({
|
|
10264
10308
|
cache: input.cache,
|
|
10265
|
-
|
|
10309
|
+
key: input.key,
|
|
10310
|
+
siteId: input.siteId,
|
|
10311
|
+
live: sharedRead(input.read),
|
|
10312
|
+
budgetSeconds
|
|
10313
|
+
}, {
|
|
10314
|
+
lookedUp: [],
|
|
10315
|
+
cached: null,
|
|
10316
|
+
live: null
|
|
10266
10317
|
});
|
|
10267
10318
|
return new Response(result.body, {
|
|
10268
10319
|
status: result.status,
|
|
10269
10320
|
headers: result.headers
|
|
10270
10321
|
});
|
|
10271
10322
|
}
|
|
10272
|
-
/** Result adapters use this
|
|
10323
|
+
/** Result adapters use this when the SDK served a page without the HTTP transport (memory, durable or prebuild fallback). */
|
|
10273
10324
|
async function observePageReadPolicy(cache, siteId, payload) {
|
|
10274
10325
|
if (!cache) return;
|
|
10275
10326
|
const dependency = pageReadDependencies(payload);
|
|
@@ -10523,7 +10574,14 @@ async function parseJsonSuccess(endpoint, response, config, decoder) {
|
|
|
10523
10574
|
if (!raw.trim()) return buildSuccessEnvelope(coerceResponse(void 0), requestId);
|
|
10524
10575
|
const parsed = decodeSuccessJson(raw, endpoint, response, config, decoder);
|
|
10525
10576
|
requireUsableCommitProjection(response, parsed);
|
|
10526
|
-
|
|
10577
|
+
const envelope = successJsonEnvelope(parsed, requestId);
|
|
10578
|
+
return envelope.success && response.headers.get("x-riverbank-page-storage") === "no-store" ? {
|
|
10579
|
+
...envelope,
|
|
10580
|
+
meta: {
|
|
10581
|
+
...envelope.meta,
|
|
10582
|
+
storage: "no-store"
|
|
10583
|
+
}
|
|
10584
|
+
} : envelope;
|
|
10527
10585
|
}
|
|
10528
10586
|
function decodeSuccessJson(raw, endpoint, response, config, decoder) {
|
|
10529
10587
|
try {
|
|
@@ -10724,208 +10782,491 @@ function requireUsableCommitProjection(response, parsed) {
|
|
|
10724
10782
|
throw new ApiCommittedWriteNotice(pageCommitConfirmationEnvelopeSchema.parse(parsed).data);
|
|
10725
10783
|
}
|
|
10726
10784
|
//#endregion
|
|
10727
|
-
//#region
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
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"
|
|
10785
|
+
//#region src/client/resilience.ts
|
|
10786
|
+
const DEFAULT_RETRY_CONFIG = {
|
|
10787
|
+
maxAttempts: 3,
|
|
10788
|
+
baseDelayMs: 200,
|
|
10789
|
+
maxDelayMs: 2e3,
|
|
10790
|
+
jitter: "full"
|
|
10761
10791
|
};
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10792
|
+
const DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
10793
|
+
failureThreshold: 5,
|
|
10794
|
+
resetTimeoutMs: 3e4,
|
|
10795
|
+
halfOpenMaxRequests: 2
|
|
10796
|
+
};
|
|
10797
|
+
/**
|
|
10798
|
+
* Error codes that indicate permanent infrastructure failures.
|
|
10799
|
+
* These should NOT be retried as the server is definitively unreachable.
|
|
10800
|
+
*/
|
|
10801
|
+
const PERMANENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10802
|
+
"ECONNREFUSED",
|
|
10803
|
+
"ENOTFOUND",
|
|
10804
|
+
"EAI_AGAIN"
|
|
10805
|
+
]);
|
|
10806
|
+
/**
|
|
10807
|
+
* Error codes that indicate transient network issues.
|
|
10808
|
+
* These MAY succeed on retry as the server was reachable but had a hiccup.
|
|
10809
|
+
*/
|
|
10810
|
+
const TRANSIENT_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10811
|
+
"ECONNRESET",
|
|
10812
|
+
"EPIPE",
|
|
10813
|
+
"ETIMEDOUT",
|
|
10814
|
+
"ESOCKETTIMEDOUT"
|
|
10815
|
+
]);
|
|
10816
|
+
/**
|
|
10817
|
+
* Node.js network error codes (POSIX style).
|
|
10818
|
+
* These are the codes we're looking for in the cause chain.
|
|
10819
|
+
*/
|
|
10820
|
+
const NODE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
10821
|
+
"ECONNREFUSED",
|
|
10822
|
+
"ENOTFOUND",
|
|
10823
|
+
"EAI_AGAIN",
|
|
10824
|
+
"ECONNRESET",
|
|
10825
|
+
"EPIPE",
|
|
10826
|
+
"ETIMEDOUT",
|
|
10827
|
+
"ESOCKETTIMEDOUT"
|
|
10828
|
+
]);
|
|
10829
|
+
/**
|
|
10830
|
+
* Check if a string is a Node.js network error code (not an API error code).
|
|
10831
|
+
* API error codes look like 'network:connection_error', Node codes look like 'ECONNREFUSED'.
|
|
10832
|
+
*/
|
|
10833
|
+
function isNodeNetworkErrorCode(code) {
|
|
10834
|
+
return !code.includes(":") && NODE_NETWORK_ERROR_CODES.has(code);
|
|
10777
10835
|
}
|
|
10778
|
-
/**
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10836
|
+
/**
|
|
10837
|
+
* Extract the Node.js error code from an error's cause chain.
|
|
10838
|
+
* Handles nested cause chains like:
|
|
10839
|
+
* RiverbankApiError -> TypeError -> Error (ECONNREFUSED)
|
|
10840
|
+
*
|
|
10841
|
+
* Skips API error codes (like 'network:connection_error') and only returns
|
|
10842
|
+
* actual Node.js error codes (like 'ECONNREFUSED', 'ENOTFOUND', etc.)
|
|
10843
|
+
*
|
|
10844
|
+
* @example
|
|
10845
|
+
* RiverbankApiError: Network request failed
|
|
10846
|
+
* [cause]: TypeError: fetch failed
|
|
10847
|
+
* [cause]: Error: connect ECONNREFUSED 127.0.0.1:4010
|
|
10848
|
+
* code: 'ECONNREFUSED'
|
|
10849
|
+
*/
|
|
10850
|
+
function getErrorCodeFromCause(error) {
|
|
10851
|
+
let current = error;
|
|
10852
|
+
while (current) {
|
|
10853
|
+
const nodeError = current;
|
|
10854
|
+
if (nodeError.code && typeof nodeError.code === "string") {
|
|
10855
|
+
if (isNodeNetworkErrorCode(nodeError.code)) return nodeError.code;
|
|
10794
10856
|
}
|
|
10795
|
-
|
|
10857
|
+
current = current.cause;
|
|
10858
|
+
}
|
|
10796
10859
|
}
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10860
|
+
/**
|
|
10861
|
+
* Determine if an error is transient and should trigger circuit breaker / retry
|
|
10862
|
+
*
|
|
10863
|
+
* Transient (opens circuit, triggers retry):
|
|
10864
|
+
* - Network errors (status 0) that are NOT permanent infrastructure failures
|
|
10865
|
+
* - 5xx server errors
|
|
10866
|
+
* - 429 rate limit
|
|
10867
|
+
* - Connection reset, broken pipe, timeout
|
|
10868
|
+
*
|
|
10869
|
+
* Permanent (does NOT open circuit, no retry):
|
|
10870
|
+
* - 4xx client errors (400, 401, 403, 404)
|
|
10871
|
+
* - Validation errors
|
|
10872
|
+
* - ECONNREFUSED (server not running)
|
|
10873
|
+
* - ENOTFOUND (DNS failure)
|
|
10874
|
+
*/
|
|
10875
|
+
function isTransientError(error) {
|
|
10876
|
+
if (error instanceof RiverbankApiError) {
|
|
10877
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
10878
|
+
if (errorCode && PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
10879
|
+
if (error.status === 0) return true;
|
|
10880
|
+
if (error.status === 429) return true;
|
|
10881
|
+
if (error.status >= 500) return true;
|
|
10882
|
+
return false;
|
|
10805
10883
|
}
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10884
|
+
if (error instanceof TypeError) {
|
|
10885
|
+
const errorCode = getErrorCodeFromCause(error);
|
|
10886
|
+
if (errorCode) {
|
|
10887
|
+
if (PERMANENT_NETWORK_ERROR_CODES.has(errorCode)) return false;
|
|
10888
|
+
if (TRANSIENT_NETWORK_ERROR_CODES.has(errorCode)) return true;
|
|
10889
|
+
}
|
|
10890
|
+
return true;
|
|
10891
|
+
}
|
|
10892
|
+
return true;
|
|
10893
|
+
}
|
|
10894
|
+
/**
|
|
10895
|
+
* Calculate backoff delay for retry attempt
|
|
10896
|
+
*
|
|
10897
|
+
* Uses exponential backoff with optional full jitter.
|
|
10898
|
+
* Formula: min(maxDelay, baseDelay * 2^(attempt-1)) * random()
|
|
10899
|
+
*/
|
|
10900
|
+
function calculateBackoff(attempt, config) {
|
|
10901
|
+
const baseDelayMs = config.baseDelayMs ?? DEFAULT_RETRY_CONFIG.baseDelayMs;
|
|
10902
|
+
const maxDelayMs = config.maxDelayMs ?? DEFAULT_RETRY_CONFIG.maxDelayMs;
|
|
10903
|
+
const jitter = config.jitter ?? DEFAULT_RETRY_CONFIG.jitter;
|
|
10904
|
+
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
10905
|
+
const capped = Math.min(exponential, maxDelayMs);
|
|
10906
|
+
if (jitter === "full") return Math.random() * capped;
|
|
10907
|
+
return capped;
|
|
10908
|
+
}
|
|
10909
|
+
/**
|
|
10910
|
+
* Circuit breaker for fail-fast behavior
|
|
10911
|
+
*
|
|
10912
|
+
* States:
|
|
10913
|
+
* - closed: Normal operation, requests allowed
|
|
10914
|
+
* - open: Too many failures, requests blocked
|
|
10915
|
+
* - half-open: Testing if service recovered, limited requests allowed
|
|
10916
|
+
*/
|
|
10917
|
+
var CircuitBreaker = class {
|
|
10918
|
+
constructor(config) {
|
|
10919
|
+
this.state = "closed";
|
|
10920
|
+
this.failureCount = 0;
|
|
10921
|
+
this.successCount = 0;
|
|
10922
|
+
this.openUntil = 0;
|
|
10923
|
+
this.halfOpenRequests = 0;
|
|
10924
|
+
this.config = {
|
|
10925
|
+
failureThreshold: config?.failureThreshold ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.failureThreshold,
|
|
10926
|
+
resetTimeoutMs: config?.resetTimeoutMs ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.resetTimeoutMs,
|
|
10927
|
+
halfOpenMaxRequests: config?.halfOpenMaxRequests ?? DEFAULT_CIRCUIT_BREAKER_CONFIG.halfOpenMaxRequests
|
|
10928
|
+
};
|
|
10815
10929
|
}
|
|
10816
10930
|
/**
|
|
10817
|
-
*
|
|
10818
|
-
*
|
|
10931
|
+
* Check if circuit is open (requests should be blocked)
|
|
10932
|
+
* Also handles automatic transition from open to half-open after timeout
|
|
10819
10933
|
*/
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
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
|
-
};
|
|
10934
|
+
isOpen() {
|
|
10935
|
+
if (this.state === "open" && Date.now() >= this.openUntil) this.transitionTo("half-open");
|
|
10936
|
+
return this.state === "open";
|
|
10833
10937
|
}
|
|
10834
10938
|
/**
|
|
10835
|
-
*
|
|
10939
|
+
* Check if a request can be attempted
|
|
10940
|
+
* - closed: always yes
|
|
10941
|
+
* - open: always no
|
|
10942
|
+
* - half-open: limited number of probes
|
|
10836
10943
|
*/
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
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
|
-
});
|
|
10944
|
+
canAttempt() {
|
|
10945
|
+
if (this.state === "closed") return true;
|
|
10946
|
+
if (this.state === "open") return false;
|
|
10947
|
+
return this.halfOpenRequests < this.config.halfOpenMaxRequests;
|
|
10849
10948
|
}
|
|
10850
10949
|
/**
|
|
10851
|
-
*
|
|
10852
|
-
* Priority: oldest stale entry, then oldest fresh entry
|
|
10950
|
+
* Increment half-open request counter (call before making request in half-open)
|
|
10853
10951
|
*/
|
|
10854
|
-
|
|
10855
|
-
|
|
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);
|
|
10952
|
+
incrementHalfOpenRequests() {
|
|
10953
|
+
if (this.state === "half-open") this.halfOpenRequests++;
|
|
10870
10954
|
}
|
|
10871
10955
|
/**
|
|
10872
|
-
*
|
|
10956
|
+
* Record a successful request
|
|
10873
10957
|
*/
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10958
|
+
recordSuccess() {
|
|
10959
|
+
if (this.state === "half-open") {
|
|
10960
|
+
this.successCount++;
|
|
10961
|
+
if (this.successCount >= this.config.halfOpenMaxRequests) this.transitionTo("closed");
|
|
10962
|
+
} else this.failureCount = 0;
|
|
10877
10963
|
}
|
|
10878
10964
|
/**
|
|
10879
|
-
*
|
|
10965
|
+
* Record a failed request
|
|
10966
|
+
* Only counts transient failures toward circuit breaker threshold
|
|
10880
10967
|
*/
|
|
10881
|
-
|
|
10882
|
-
if (
|
|
10883
|
-
|
|
10884
|
-
|
|
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));
|
|
10968
|
+
recordFailure(error) {
|
|
10969
|
+
if (!isTransientError(error)) return;
|
|
10970
|
+
this.failureCount++;
|
|
10971
|
+
if (this.state === "half-open") this.transitionTo("open");
|
|
10972
|
+
else if (this.failureCount >= this.config.failureThreshold) this.transitionTo("open");
|
|
10888
10973
|
}
|
|
10889
|
-
|
|
10890
|
-
|
|
10974
|
+
/**
|
|
10975
|
+
* Get current circuit state
|
|
10976
|
+
*/
|
|
10977
|
+
getState() {
|
|
10978
|
+
return {
|
|
10979
|
+
state: this.state,
|
|
10980
|
+
failureCount: this.failureCount,
|
|
10981
|
+
openUntil: this.state === "open" ? this.openUntil : void 0
|
|
10982
|
+
};
|
|
10891
10983
|
}
|
|
10892
10984
|
/**
|
|
10893
|
-
*
|
|
10985
|
+
* Transition to a new state
|
|
10894
10986
|
*/
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
if (
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
this.
|
|
10901
|
-
|
|
10987
|
+
transitionTo(newState) {
|
|
10988
|
+
this.state = newState;
|
|
10989
|
+
if (newState === "open") this.openUntil = Date.now() + this.config.resetTimeoutMs;
|
|
10990
|
+
else if (newState === "half-open") {
|
|
10991
|
+
this.halfOpenRequests = 0;
|
|
10992
|
+
this.successCount = 0;
|
|
10993
|
+
} else if (newState === "closed") {
|
|
10994
|
+
this.failureCount = 0;
|
|
10995
|
+
this.successCount = 0;
|
|
10996
|
+
this.halfOpenRequests = 0;
|
|
10902
10997
|
}
|
|
10903
|
-
|
|
10998
|
+
}
|
|
10999
|
+
};
|
|
11000
|
+
/**
|
|
11001
|
+
* Fetch with timeout and retry logic
|
|
11002
|
+
*
|
|
11003
|
+
* @param fetcher - Function that performs the fetch, receives AbortSignal for timeout
|
|
11004
|
+
* @param config - Retry configuration
|
|
11005
|
+
* @returns Result from successful fetch
|
|
11006
|
+
* @throws Last error after all retries exhausted
|
|
11007
|
+
*/
|
|
11008
|
+
async function fetchWithTimeoutAndRetry(fetcher, config) {
|
|
11009
|
+
const maxAttempts = config.maxAttempts ?? DEFAULT_RETRY_CONFIG.maxAttempts;
|
|
11010
|
+
const requestTimeoutMs = config.requestTimeoutMs ?? 8e3;
|
|
11011
|
+
let lastError;
|
|
11012
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
11013
|
+
const controller = new AbortController();
|
|
11014
|
+
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
11015
|
+
try {
|
|
11016
|
+
return await fetcher(controller.signal);
|
|
11017
|
+
} finally {
|
|
11018
|
+
clearTimeout(timeoutId);
|
|
11019
|
+
}
|
|
11020
|
+
} catch (error) {
|
|
11021
|
+
lastError = error;
|
|
11022
|
+
if (!shouldRetryError(error, config.retryOn)) throw error;
|
|
11023
|
+
if (attempt < maxAttempts) await sleep(getRetryDelay(error, attempt, config));
|
|
11024
|
+
}
|
|
11025
|
+
throw lastError;
|
|
11026
|
+
}
|
|
11027
|
+
/**
|
|
11028
|
+
* Check if an error is an AbortError (from AbortController.abort() or timeout)
|
|
11029
|
+
*/
|
|
11030
|
+
function isAbortError$1(error) {
|
|
11031
|
+
if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") return true;
|
|
11032
|
+
if (error instanceof Error && error.name === "AbortError") return true;
|
|
11033
|
+
return false;
|
|
11034
|
+
}
|
|
11035
|
+
/**
|
|
11036
|
+
* Check if an error should be retried
|
|
11037
|
+
*/
|
|
11038
|
+
function shouldRetryError(error, customRetryOn) {
|
|
11039
|
+
if (isAbortError$1(error)) return false;
|
|
11040
|
+
if (findFrameworkSignal(error) !== void 0) return false;
|
|
11041
|
+
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
11042
|
+
return isTransientError(error);
|
|
11043
|
+
}
|
|
11044
|
+
/**
|
|
11045
|
+
* Get delay before retrying, respecting Retry-After if present
|
|
11046
|
+
*/
|
|
11047
|
+
function getRetryDelay(error, attempt, config) {
|
|
11048
|
+
if (error instanceof RiverbankApiError && error.retryAfterMs) return error.retryAfterMs;
|
|
11049
|
+
return calculateBackoff(attempt, config);
|
|
11050
|
+
}
|
|
11051
|
+
/**
|
|
11052
|
+
* Sleep for specified milliseconds
|
|
11053
|
+
*/
|
|
11054
|
+
function sleep(ms) {
|
|
11055
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
11056
|
+
}
|
|
11057
|
+
/**
|
|
11058
|
+
* Error thrown when circuit breaker is open
|
|
11059
|
+
*/
|
|
11060
|
+
var CircuitOpenError = class extends Error {
|
|
11061
|
+
constructor(state) {
|
|
11062
|
+
super("Circuit breaker is open");
|
|
11063
|
+
this.name = "CircuitOpenError";
|
|
11064
|
+
this.circuitState = state;
|
|
10904
11065
|
}
|
|
10905
11066
|
};
|
|
10906
11067
|
//#endregion
|
|
10907
|
-
//#region src/
|
|
10908
|
-
/**
|
|
10909
|
-
|
|
11068
|
+
//#region ../site-renderer/src/runtimeResponse.ts
|
|
11069
|
+
/** Recreate owner-produced rendering values at a JSON boundary, never trust copied proofs. */
|
|
11070
|
+
function restoreRuntimeResponse(serialized) {
|
|
11071
|
+
return parseSurfaceTree(serialized);
|
|
11072
|
+
}
|
|
10910
11073
|
//#endregion
|
|
10911
|
-
//#region src/
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
11074
|
+
//#region ../site-renderer/src/runtimeClient.ts
|
|
11075
|
+
/** Only a client that reconstructs surfaces advertises revision transport. */
|
|
11076
|
+
function createRuntimeApiClient$1(transport) {
|
|
11077
|
+
const revisionTransport = (request) => transport({
|
|
11078
|
+
...request,
|
|
11079
|
+
...request.endpoint === "getContentByPath" ? { params: {
|
|
11080
|
+
...request.params,
|
|
11081
|
+
surfaceTransport: "revision-v1"
|
|
11082
|
+
} } : {}
|
|
11083
|
+
});
|
|
11084
|
+
return createParsedApiClient(revisionTransport, {
|
|
11085
|
+
representation: "restored",
|
|
11086
|
+
decode: restoreRuntimeResponse
|
|
11087
|
+
});
|
|
11088
|
+
}
|
|
11089
|
+
function createRuntimeInternalAPIClient(baseUrl, options) {
|
|
11090
|
+
return createRuntimeApiClient$1(createApiResponseTransport(() => ({}), baseUrl, options));
|
|
11091
|
+
}
|
|
11092
|
+
function createRuntimeBearerAPIClient(token, baseUrl, options) {
|
|
11093
|
+
return createRuntimeApiClient$1(createApiResponseTransport(() => ({ Authorization: `Bearer ${typeof token === "function" ? token() : token}` }), baseUrl, options));
|
|
11094
|
+
}
|
|
11095
|
+
//#endregion
|
|
11096
|
+
//#region src/client/entryListReadRequest.ts
|
|
11097
|
+
const entryOrder = {
|
|
11098
|
+
newest: "published_at.desc",
|
|
11099
|
+
oldest: "published_at.asc",
|
|
11100
|
+
title: "title.asc",
|
|
11101
|
+
manual: "manual.asc"
|
|
11102
|
+
};
|
|
11103
|
+
function entrySelection(input) {
|
|
11104
|
+
return input.mode === "manual" && input.entryIds?.length ? {
|
|
11105
|
+
keyPart: input.entryIds.join(","),
|
|
11106
|
+
params: {
|
|
11107
|
+
mode: "manual",
|
|
11108
|
+
entryIds: JSON.stringify(input.entryIds)
|
|
11109
|
+
}
|
|
11110
|
+
} : {
|
|
11111
|
+
keyPart: "",
|
|
11112
|
+
params: {}
|
|
11113
|
+
};
|
|
11114
|
+
}
|
|
11115
|
+
function entryListMemoryKey(input, selection) {
|
|
11116
|
+
const { siteId, contentType, limit, offset, order, mode, includeMeta, preview = false } = input;
|
|
11117
|
+
return `entries:${siteId}:${contentType}:${limit ?? ""}:${offset ?? ""}:${order ?? ""}:${preview}:${mode ?? ""}:${selection.keyPart}:${includeMeta ?? ""}`;
|
|
11118
|
+
}
|
|
11119
|
+
/** One interpretation of pagination, selection and preview for the transport and memory key. */
|
|
11120
|
+
function buildEntryListReadRequest(input) {
|
|
11121
|
+
const { siteId, contentType, limit, offset, order, includeMeta, preview = false } = input;
|
|
11122
|
+
const selection = entrySelection(input);
|
|
11123
|
+
const orderParam = order ? entryOrder[order] : void 0;
|
|
11124
|
+
return {
|
|
11125
|
+
cacheKey: entryListMemoryKey(input, selection),
|
|
11126
|
+
params: {
|
|
11127
|
+
siteId,
|
|
11128
|
+
type: contentType,
|
|
11129
|
+
...typeof limit === "number" && { limit: String(limit) },
|
|
11130
|
+
...typeof offset === "number" && { offset: String(offset) },
|
|
11131
|
+
...includeMeta && { meta: "true" },
|
|
11132
|
+
...orderParam && { order: orderParam },
|
|
11133
|
+
...preview && { stage: "preview" },
|
|
11134
|
+
...selection.params
|
|
11135
|
+
}
|
|
11136
|
+
};
|
|
11137
|
+
}
|
|
11138
|
+
//#endregion
|
|
11139
|
+
//#region src/client/cache.ts
|
|
11140
|
+
var SimpleCache = class {
|
|
11141
|
+
constructor(options = {}) {
|
|
11142
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
11143
|
+
this.maxSize = options.maxSize ?? 100;
|
|
11144
|
+
this.ttl = options.ttl ?? 3e5;
|
|
11145
|
+
this.staleTtl = options.staleTtl ?? 3e5;
|
|
11146
|
+
}
|
|
11147
|
+
/**
|
|
11148
|
+
* Get a fresh value (within TTL)
|
|
11149
|
+
* @returns The value if fresh, null otherwise
|
|
11150
|
+
*/
|
|
11151
|
+
getFresh(key) {
|
|
11152
|
+
const entry = this.cache.get(key);
|
|
11153
|
+
if (!entry) return null;
|
|
11154
|
+
if (Date.now() <= entry.freshUntil) return entry.value;
|
|
11155
|
+
return null;
|
|
11156
|
+
}
|
|
11157
|
+
/**
|
|
11158
|
+
* Get a value that may be stale (past TTL but within staleTtl)
|
|
11159
|
+
* @returns Object with value and stale age, or null if expired
|
|
11160
|
+
*/
|
|
11161
|
+
getStale(key) {
|
|
11162
|
+
const entry = this.cache.get(key);
|
|
11163
|
+
if (!entry) return null;
|
|
11164
|
+
const now = Date.now();
|
|
11165
|
+
if (now > entry.staleUntil) {
|
|
11166
|
+
this.cache.delete(key);
|
|
11167
|
+
return null;
|
|
11168
|
+
}
|
|
11169
|
+
const staleAgeSec = now <= entry.freshUntil ? 0 : Math.floor((now - entry.freshUntil) / 1e3);
|
|
11170
|
+
return {
|
|
11171
|
+
value: entry.value,
|
|
11172
|
+
staleAgeSec
|
|
11173
|
+
};
|
|
11174
|
+
}
|
|
11175
|
+
/**
|
|
11176
|
+
* Store a value with TTL and stale window
|
|
11177
|
+
*/
|
|
11178
|
+
set(key, value, options) {
|
|
11179
|
+
const ttl = options?.ttl ?? this.ttl;
|
|
11180
|
+
const staleTtl = options?.staleTtl ?? this.staleTtl;
|
|
11181
|
+
const now = Date.now();
|
|
11182
|
+
while (this.cache.size >= this.maxSize && !this.cache.has(key)) this.evictOne(now);
|
|
11183
|
+
this.cache.set(key, {
|
|
11184
|
+
value,
|
|
11185
|
+
tags: options?.tags ?? [],
|
|
11186
|
+
createdAt: now,
|
|
11187
|
+
freshUntil: now + ttl,
|
|
11188
|
+
staleUntil: now + ttl + staleTtl
|
|
11189
|
+
});
|
|
11190
|
+
}
|
|
11191
|
+
/**
|
|
11192
|
+
* Evict one entry to make room for a new one
|
|
11193
|
+
* Priority: oldest stale entry, then oldest fresh entry
|
|
11194
|
+
*/
|
|
11195
|
+
evictOne(now) {
|
|
11196
|
+
let oldestStaleKey = null;
|
|
11197
|
+
let oldestStaleTime = Infinity;
|
|
11198
|
+
let oldestFreshKey = null;
|
|
11199
|
+
let oldestFreshTime = Infinity;
|
|
11200
|
+
for (const [key, entry] of this.cache) if (now > entry.freshUntil) {
|
|
11201
|
+
if (entry.createdAt < oldestStaleTime) {
|
|
11202
|
+
oldestStaleTime = entry.createdAt;
|
|
11203
|
+
oldestStaleKey = key;
|
|
11204
|
+
}
|
|
11205
|
+
} else if (entry.createdAt < oldestFreshTime) {
|
|
11206
|
+
oldestFreshTime = entry.createdAt;
|
|
11207
|
+
oldestFreshKey = key;
|
|
11208
|
+
}
|
|
11209
|
+
const keyToEvict = oldestStaleKey ?? oldestFreshKey;
|
|
11210
|
+
if (keyToEvict) this.cache.delete(keyToEvict);
|
|
11211
|
+
}
|
|
11212
|
+
/**
|
|
11213
|
+
* Remove all fully expired entries (past staleUntil)
|
|
11214
|
+
*/
|
|
11215
|
+
prune() {
|
|
11216
|
+
const now = Date.now();
|
|
11217
|
+
for (const [key, entry] of this.cache) if (now > entry.staleUntil) this.cache.delete(key);
|
|
11218
|
+
}
|
|
11219
|
+
/**
|
|
11220
|
+
* Clear all entries
|
|
11221
|
+
*/
|
|
11222
|
+
clearForTags(tags) {
|
|
11223
|
+
if (tags.includes("riverbank")) {
|
|
11224
|
+
this.clear();
|
|
11225
|
+
return;
|
|
11226
|
+
}
|
|
11227
|
+
const selected = new Set(tags);
|
|
11228
|
+
[...this.cache.entries()].filter(([, entry]) => entry.tags.some((tag) => selected.has(tag))).forEach(([key]) => this.cache.delete(key));
|
|
11229
|
+
}
|
|
11230
|
+
clear() {
|
|
11231
|
+
this.cache.clear();
|
|
11232
|
+
}
|
|
11233
|
+
/**
|
|
11234
|
+
* Check if a key exists and is not fully expired
|
|
11235
|
+
*/
|
|
11236
|
+
has(key) {
|
|
11237
|
+
const entry = this.cache.get(key);
|
|
11238
|
+
if (!entry) return false;
|
|
11239
|
+
const now = Date.now();
|
|
11240
|
+
if (now > entry.staleUntil) {
|
|
11241
|
+
this.cache.delete(key);
|
|
11242
|
+
return false;
|
|
11243
|
+
}
|
|
11244
|
+
return now <= entry.freshUntil;
|
|
11245
|
+
}
|
|
11246
|
+
};
|
|
11247
|
+
//#endregion
|
|
11248
|
+
//#region src/request-options.ts
|
|
11249
|
+
/** Every API client the SDK creates sends its version as `x-sdk-version`. */
|
|
11250
|
+
const sdkRequestOptions = { sdkVersion: SDK_VERSION };
|
|
11251
|
+
//#endregion
|
|
11252
|
+
//#region src/public-api/runtime.ts
|
|
11253
|
+
const PUBLIC_ENDPOINT_NAMES = [
|
|
11254
|
+
"getSite",
|
|
11255
|
+
"getContentByPath",
|
|
11256
|
+
"resolveRouteOutcome",
|
|
11257
|
+
"resolveRouteDecision",
|
|
11258
|
+
"listPublishedEntries",
|
|
11259
|
+
"getPublishedEntryPreview",
|
|
11260
|
+
"getPublicFormById",
|
|
11261
|
+
"listPublicForms",
|
|
11262
|
+
"getPublicBookingServices",
|
|
11263
|
+
"getPublicWeeklySlotAvailability",
|
|
11264
|
+
"getPublicChallenge",
|
|
11265
|
+
"listPublicEvents",
|
|
11266
|
+
"batchBlockLoaders",
|
|
11267
|
+
"listPublicTeamMembers",
|
|
11268
|
+
"listPublicProducts",
|
|
11269
|
+
"listPublicPasses",
|
|
10929
11270
|
"listPublicMemberships",
|
|
10930
11271
|
"checkRedirect",
|
|
10931
11272
|
"getRoutableContent",
|
|
@@ -11499,470 +11840,188 @@ function planPublishedRuntimeCache(input) {
|
|
|
11499
11840
|
normalizedParams: keyResult.normalizedParams,
|
|
11500
11841
|
freshTtlSec: policy.freshTtlSec,
|
|
11501
11842
|
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;
|
|
11683
|
-
}
|
|
11684
|
-
//#endregion
|
|
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);
|
|
11735
|
-
}
|
|
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
|
-
}
|
|
11759
|
-
}
|
|
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;
|
|
11793
|
-
}
|
|
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;
|
|
11843
|
+
siteId: input.siteId ?? null
|
|
11844
|
+
};
|
|
11845
|
+
}
|
|
11846
|
+
function siteApiParams(params) {
|
|
11847
|
+
return {
|
|
11848
|
+
...params.slug ? { slug: params.slug } : {},
|
|
11849
|
+
...params.domain ? { domain: params.domain } : {},
|
|
11850
|
+
...params.id ? { id: params.id } : {},
|
|
11851
|
+
...params.currentPath ? { currentPath: params.currentPath } : {},
|
|
11852
|
+
...params.force ? { force: "true" } : {}
|
|
11853
|
+
};
|
|
11854
|
+
}
|
|
11855
|
+
function siteReadIdentity(params) {
|
|
11856
|
+
const identifier = params.slug || params.domain || params.id;
|
|
11857
|
+
if (!identifier) throw new Error(`getSite() requires at least one identifier: slug, domain, or id. Received: ${JSON.stringify(params)}`);
|
|
11858
|
+
return identifier;
|
|
11859
|
+
}
|
|
11860
|
+
function planSiteRead(params) {
|
|
11861
|
+
const identifier = siteReadIdentity(params);
|
|
11862
|
+
const { slug, domain, id, currentPath, force } = params;
|
|
11863
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
11864
|
+
endpoint: "getSite",
|
|
11865
|
+
params: {
|
|
11866
|
+
slug,
|
|
11867
|
+
domain,
|
|
11868
|
+
id,
|
|
11869
|
+
currentPath,
|
|
11870
|
+
force
|
|
11897
11871
|
}
|
|
11898
|
-
}
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
const
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
return await fetcher(controller.signal);
|
|
11917
|
-
} finally {
|
|
11918
|
-
clearTimeout(timeoutId);
|
|
11872
|
+
});
|
|
11873
|
+
return {
|
|
11874
|
+
publishedRuntimeCache,
|
|
11875
|
+
prebuildIdentifier: id || slug || domain,
|
|
11876
|
+
cacheKey: publishedRuntimeCache?.cacheKey ?? `site:${identifier}:${currentPath ?? ""}`
|
|
11877
|
+
};
|
|
11878
|
+
}
|
|
11879
|
+
async function readSiteWithResilience(input, params) {
|
|
11880
|
+
const { slug, domain, id, signal, force } = params;
|
|
11881
|
+
const plan = planSiteRead(params);
|
|
11882
|
+
const prebuildId = plan.prebuildIdentifier;
|
|
11883
|
+
const prebuild = input.prebuildLoader;
|
|
11884
|
+
return input.resilientFetch(plan.cacheKey, (requestSignal) => input.apiClient({
|
|
11885
|
+
endpoint: "getSite",
|
|
11886
|
+
params: siteApiParams(params),
|
|
11887
|
+
options: {
|
|
11888
|
+
signal: requestSignal,
|
|
11889
|
+
...force ? { cache: "no-store" } : {}
|
|
11919
11890
|
}
|
|
11920
|
-
}
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11891
|
+
}), {
|
|
11892
|
+
signal,
|
|
11893
|
+
force,
|
|
11894
|
+
publishedRuntimeCache: plan.publishedRuntimeCache,
|
|
11895
|
+
cacheTags: buildSiteReadTags({
|
|
11896
|
+
slug,
|
|
11897
|
+
domain,
|
|
11898
|
+
id
|
|
11899
|
+
}),
|
|
11900
|
+
prebuildFallback: prebuild && prebuildId ? () => prebuild.loadSite(prebuildId) : void 0
|
|
11901
|
+
});
|
|
11926
11902
|
}
|
|
11927
|
-
|
|
11928
|
-
|
|
11929
|
-
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
|
|
11903
|
+
async function readPageWithResilience(input, params) {
|
|
11904
|
+
const { siteId, path, preview = false, signal } = params;
|
|
11905
|
+
const publishedRuntimeCache = planPublishedRuntimeCache({
|
|
11906
|
+
endpoint: "getContentByPath",
|
|
11907
|
+
params: {
|
|
11908
|
+
siteId,
|
|
11909
|
+
path,
|
|
11910
|
+
preview
|
|
11911
|
+
},
|
|
11912
|
+
siteId
|
|
11913
|
+
});
|
|
11914
|
+
const cacheKey = publishedRuntimeCache?.cacheKey ?? `page:${siteId}:${path}:${preview}`;
|
|
11915
|
+
const result = await input.resilientFetch(cacheKey, (requestSignal) => input.apiClient({
|
|
11916
|
+
endpoint: "getContentByPath",
|
|
11917
|
+
params: {
|
|
11918
|
+
siteId,
|
|
11919
|
+
path,
|
|
11920
|
+
preview: String(preview)
|
|
11921
|
+
},
|
|
11922
|
+
options: { signal: requestSignal }
|
|
11923
|
+
}), {
|
|
11924
|
+
pageRead: { siteId },
|
|
11925
|
+
preview,
|
|
11926
|
+
signal,
|
|
11927
|
+
publishedRuntimeCache,
|
|
11928
|
+
cacheTags: buildSiteReadTags({ siteId }),
|
|
11929
|
+
prebuildFallback: void 0
|
|
11930
|
+
});
|
|
11931
|
+
if (!preview && result.resilience.source !== "live") await observePageReadResponse(input.frameworkCache, siteId, result.data);
|
|
11932
|
+
return result;
|
|
11934
11933
|
}
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
if (customRetryOn) return customRetryOn(error, error instanceof RiverbankApiError ? error.status : void 0);
|
|
11941
|
-
return isTransientError(error);
|
|
11934
|
+
function createContentReadOperations(input) {
|
|
11935
|
+
return {
|
|
11936
|
+
getSiteWithResilience: (params) => readSiteWithResilience(input, params),
|
|
11937
|
+
getPageWithResilience: (params) => readPageWithResilience(input, params)
|
|
11938
|
+
};
|
|
11942
11939
|
}
|
|
11943
|
-
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11940
|
+
//#endregion
|
|
11941
|
+
//#region src/client/publicAppointmentReadOperations.ts
|
|
11942
|
+
function createPublicAppointmentReadOperations(deps) {
|
|
11943
|
+
return {
|
|
11944
|
+
async getPublicBookingServices(params) {
|
|
11945
|
+
const { siteId, ids, signal } = params;
|
|
11946
|
+
if (!siteId) throw new Error("getPublicBookingServices() requires siteId");
|
|
11947
|
+
const cacheKey = `public-booking-services:${siteId}:${ids ?? ""}`;
|
|
11948
|
+
return deps.resilientFetchData("getPublicBookingServices", cacheKey, async (requestSignal) => {
|
|
11949
|
+
const apiParams = {
|
|
11950
|
+
siteId,
|
|
11951
|
+
...ids && { ids }
|
|
11952
|
+
};
|
|
11953
|
+
return await deps.apiClient({
|
|
11954
|
+
endpoint: "getPublicBookingServices",
|
|
11955
|
+
params: apiParams,
|
|
11956
|
+
options: { signal: requestSignal }
|
|
11957
|
+
});
|
|
11958
|
+
}, {
|
|
11959
|
+
signal,
|
|
11960
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicBookingServices", { siteId })
|
|
11961
|
+
});
|
|
11962
|
+
},
|
|
11963
|
+
async getPublicWeeklySlotAvailability(params) {
|
|
11964
|
+
const { siteId, serviceId, resourceId, horizonWeeks, timezone, signal } = params;
|
|
11965
|
+
if (!siteId || !serviceId) throw new Error("getPublicWeeklySlotAvailability() requires siteId and serviceId");
|
|
11966
|
+
const cacheKey = [
|
|
11967
|
+
"public-weekly-slot-availability",
|
|
11968
|
+
siteId,
|
|
11969
|
+
serviceId,
|
|
11970
|
+
resourceId ?? "",
|
|
11971
|
+
horizonWeeks ?? "",
|
|
11972
|
+
timezone ?? ""
|
|
11973
|
+
].join(":");
|
|
11974
|
+
return deps.resilientFetchData("getPublicWeeklySlotAvailability", cacheKey, async (requestSignal) => {
|
|
11975
|
+
const apiParams = {
|
|
11976
|
+
siteId,
|
|
11977
|
+
serviceId,
|
|
11978
|
+
...resourceId && { resourceId },
|
|
11979
|
+
...horizonWeeks !== void 0 && { horizonWeeks: String(horizonWeeks) },
|
|
11980
|
+
...timezone && { timezone }
|
|
11981
|
+
};
|
|
11982
|
+
return await deps.apiClient({
|
|
11983
|
+
endpoint: "getPublicWeeklySlotAvailability",
|
|
11984
|
+
params: apiParams,
|
|
11985
|
+
options: { signal: requestSignal }
|
|
11986
|
+
});
|
|
11987
|
+
}, {
|
|
11988
|
+
signal,
|
|
11989
|
+
cacheTags: buildPublicReadMemoryCacheTags("getPublicWeeklySlotAvailability", { siteId })
|
|
11990
|
+
});
|
|
11991
|
+
}
|
|
11992
|
+
};
|
|
11949
11993
|
}
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11994
|
+
//#endregion
|
|
11995
|
+
//#region src/client/publicEventReadOperations.ts
|
|
11996
|
+
function createPublicEventReadOperations(deps) {
|
|
11997
|
+
return { async listPublicEventCalendarWindow({ signal, ...params }) {
|
|
11998
|
+
return deps.resilientFetchData("listPublicEventCalendarWindow", `public-calendar-window:${JSON.stringify(params)}`, (requestSignal) => deps.apiClient({
|
|
11999
|
+
endpoint: "listPublicEventCalendarWindow",
|
|
12000
|
+
params: {
|
|
12001
|
+
...params,
|
|
12002
|
+
limit: params.limit === void 0 ? void 0 : String(params.limit)
|
|
12003
|
+
},
|
|
12004
|
+
options: { signal: requestSignal }
|
|
12005
|
+
}), {
|
|
12006
|
+
signal,
|
|
12007
|
+
cacheTags: buildPublicReadMemoryCacheTags("listPublicEventCalendarWindow", { siteId: params.siteId })
|
|
12008
|
+
});
|
|
12009
|
+
} };
|
|
11955
12010
|
}
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
*/
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
12011
|
+
//#endregion
|
|
12012
|
+
//#region src/client/combineAbortSignals.ts
|
|
12013
|
+
/** Combine signals into one that aborts when any input aborts. */
|
|
12014
|
+
function combineAbortSignals(...signals) {
|
|
12015
|
+
const controller = new AbortController();
|
|
12016
|
+
for (const signal of signals) {
|
|
12017
|
+
if (signal.aborted) {
|
|
12018
|
+
controller.abort(signal.reason);
|
|
12019
|
+
break;
|
|
12020
|
+
}
|
|
12021
|
+
signal.addEventListener("abort", () => controller.abort(signal.reason), { once: true });
|
|
11964
12022
|
}
|
|
11965
|
-
|
|
12023
|
+
return controller.signal;
|
|
12024
|
+
}
|
|
11966
12025
|
//#endregion
|
|
11967
12026
|
//#region src/client/publicLoaderCacheAccess.ts
|
|
11968
12027
|
function shouldWrite(cacheEnabled, force) {
|
|
@@ -12190,6 +12249,7 @@ function getNetworkErrorCode(error) {
|
|
|
12190
12249
|
* - AbortError (let propagate raw for consumer detection)
|
|
12191
12250
|
*/
|
|
12192
12251
|
function convertToTypedError(error) {
|
|
12252
|
+
rethrowClientFrameworkSignal(error);
|
|
12193
12253
|
if (isAbortError(error)) throw error;
|
|
12194
12254
|
if (error instanceof ApiEnvelopeError) throw new RiverbankApiError({
|
|
12195
12255
|
code: error.code,
|
|
@@ -12247,6 +12307,15 @@ function resolveAuth(config) {
|
|
|
12247
12307
|
};
|
|
12248
12308
|
throw new Error("Authentication configuration is required. Provide either `auth` (recommended) or `apiKey` (deprecated). For public endpoints without auth, use: { auth: { type: \"none\" } }");
|
|
12249
12309
|
}
|
|
12310
|
+
/** The framework adapter is fixed at construction: `@riverbankcms/sdk/next` supplies Next's. */
|
|
12311
|
+
function createRuntimeApiClient(deps, config, authConfig) {
|
|
12312
|
+
const frameworkCache = config.frameworkCache;
|
|
12313
|
+
const requestOptions = frameworkCache ? {
|
|
12314
|
+
...sdkRequestOptions,
|
|
12315
|
+
frameworkCache
|
|
12316
|
+
} : sdkRequestOptions;
|
|
12317
|
+
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);
|
|
12318
|
+
}
|
|
12250
12319
|
const defaultRiverbankClientDeps = {
|
|
12251
12320
|
createBearerAPIClient: createRuntimeBearerAPIClient,
|
|
12252
12321
|
createInternalAPIClient: createRuntimeInternalAPIClient
|
|
@@ -12278,11 +12347,12 @@ function resolveMemoryCachePolicy(config) {
|
|
|
12278
12347
|
servesFreshMemoryHits: enabled ?? !isRunningInNextServer()
|
|
12279
12348
|
};
|
|
12280
12349
|
}
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12350
|
+
/** The server marks a page built with parts missing (`x-riverbank-page-storage: no-store`); no SDK cache may keep it. */
|
|
12351
|
+
function readLive(response) {
|
|
12352
|
+
return {
|
|
12353
|
+
data: unwrapResponse(response),
|
|
12354
|
+
storable: !(response.success && response.meta?.storage === "no-store")
|
|
12355
|
+
};
|
|
12286
12356
|
}
|
|
12287
12357
|
function createRiverbankClient(config) {
|
|
12288
12358
|
return createRiverbankClientWithDeps(defaultRiverbankClientDeps, config);
|
|
@@ -12322,18 +12392,8 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12322
12392
|
keyType = "preview";
|
|
12323
12393
|
break;
|
|
12324
12394
|
}
|
|
12325
|
-
|
|
12326
|
-
|
|
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);
|
|
12395
|
+
const frameworkCache = config.frameworkCache;
|
|
12396
|
+
const apiClient = createRuntimeApiClient(deps, config, authConfig);
|
|
12337
12397
|
const cache = new SimpleCache({
|
|
12338
12398
|
maxSize: cacheMaxSize,
|
|
12339
12399
|
ttl: cacheTTL,
|
|
@@ -12503,31 +12563,37 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12503
12563
|
}));
|
|
12504
12564
|
throw new CircuitOpenError(circuitState);
|
|
12505
12565
|
}
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
if (
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
return unwrapResponse(await fetcher(combinedSignal));
|
|
12514
|
-
} catch (error) {
|
|
12515
|
-
convertToTypedError(error);
|
|
12516
|
-
}
|
|
12517
|
-
}, {
|
|
12518
|
-
...retryConfig,
|
|
12519
|
-
requestTimeoutMs
|
|
12520
|
-
});
|
|
12521
|
-
circuitBreaker.recordSuccess();
|
|
12522
|
-
} else try {
|
|
12523
|
-
data = unwrapResponse(await fetcher(options.signal ?? new AbortController().signal));
|
|
12566
|
+
const storeLive = async (data) => {
|
|
12567
|
+
if (shouldWrite(cacheEnabled, options.force)) cache.set(cacheKey, data, memoryWritePolicy(options.pageRead, data, options.cacheTags, cacheTTL));
|
|
12568
|
+
if (allowFallbacks && !isPreview) await writePublishedRuntimeCache(options.publishedRuntimeCache, data);
|
|
12569
|
+
};
|
|
12570
|
+
const fetchLive = async () => {
|
|
12571
|
+
if (!resilienceEnabled) try {
|
|
12572
|
+
return readLive(await fetcher(options.signal ?? new AbortController().signal));
|
|
12524
12573
|
} catch (error) {
|
|
12525
12574
|
convertToTypedError(error);
|
|
12526
12575
|
}
|
|
12527
|
-
if (
|
|
12528
|
-
|
|
12576
|
+
if (circuitBreaker.getState().state === "half-open") circuitBreaker.incrementHalfOpenRequests();
|
|
12577
|
+
const live = await fetchWithTimeoutAndRetry(async (timeoutSignal) => {
|
|
12578
|
+
const combinedSignal = options.signal ? combineAbortSignals(timeoutSignal, options.signal) : timeoutSignal;
|
|
12579
|
+
try {
|
|
12580
|
+
return readLive(await fetcher(combinedSignal));
|
|
12581
|
+
} catch (error) {
|
|
12582
|
+
convertToTypedError(error);
|
|
12583
|
+
}
|
|
12584
|
+
}, {
|
|
12585
|
+
...retryConfig,
|
|
12586
|
+
requestTimeoutMs
|
|
12587
|
+
});
|
|
12588
|
+
circuitBreaker.recordSuccess();
|
|
12589
|
+
return live;
|
|
12590
|
+
};
|
|
12591
|
+
try {
|
|
12592
|
+
const { data, storable } = await fetchLive();
|
|
12593
|
+
if (storable) await storeLive(data);
|
|
12529
12594
|
return emitStatus("live", data, statusDetails());
|
|
12530
12595
|
} catch (error) {
|
|
12596
|
+
rethrowClientFrameworkSignal(error);
|
|
12531
12597
|
if (isPageReadRefusal(options.pageRead, error)) throw attachResilienceStatusToError(error, emitStatus("error", null, statusDetails({ error: getRiverbankErrorInfo(error) })).resilience);
|
|
12532
12598
|
if (resilienceEnabled && error instanceof Error) circuitBreaker.recordFailure(error);
|
|
12533
12599
|
if (allowFallbacks && !isPreview && staleIfError && cacheEnabled) {
|
|
@@ -12567,9 +12633,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12567
12633
|
apiClient,
|
|
12568
12634
|
resilientFetch,
|
|
12569
12635
|
prebuildLoader,
|
|
12570
|
-
|
|
12571
|
-
return framework.adapter;
|
|
12572
|
-
}
|
|
12636
|
+
frameworkCache
|
|
12573
12637
|
});
|
|
12574
12638
|
const eventReads = createPublicEventReadOperations({
|
|
12575
12639
|
apiClient,
|
|
@@ -12593,7 +12657,7 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12593
12657
|
prebuildFallback: prebuildLoader && !preview ? () => prebuildLoader.loadEntries(siteId, params) : void 0
|
|
12594
12658
|
}));
|
|
12595
12659
|
}
|
|
12596
|
-
|
|
12660
|
+
return {
|
|
12597
12661
|
async getSite(params) {
|
|
12598
12662
|
return (await contentReads.getSiteWithResilience(params)).data;
|
|
12599
12663
|
},
|
|
@@ -12958,14 +13022,11 @@ function createRiverbankClientWithDeps(deps, config) {
|
|
|
12958
13022
|
},
|
|
12959
13023
|
getBaseUrl() {
|
|
12960
13024
|
return config.baseUrl;
|
|
13025
|
+
},
|
|
13026
|
+
hasFrameworkCache() {
|
|
13027
|
+
return frameworkCache !== void 0;
|
|
12961
13028
|
}
|
|
12962
13029
|
};
|
|
12963
|
-
frameworkCacheInstallers.set(client, (adapter) => {
|
|
12964
|
-
if (framework.adapter) return;
|
|
12965
|
-
framework.apiClient = createApiClient(adapter);
|
|
12966
|
-
framework.adapter = adapter;
|
|
12967
|
-
});
|
|
12968
|
-
return client;
|
|
12969
13030
|
}
|
|
12970
13031
|
//#endregion
|
|
12971
|
-
export {
|
|
13032
|
+
export { DEFAULT_PUBLISHED_RUNTIME_CACHE_PAYLOAD_SCHEMA_VERSION as a, parsePublishedRuntimeCacheKey as c, API_ENDPOINTS as d, buildEndpointURL as f, createBearerAPIClient as h, resolveRuntimeCachePolicy as i, parsePublishedRuntimeCacheKeyDetails as l, CircuitOpenError as m, classifyPublishedRuntimeCacheFreshness as n, isPublishedRuntimeCacheKeyEndpoint as o, sdkRequestOptions as p, derivePublishedRuntimeCacheKey as r, normalizeRuntimePublicPath as s, createRiverbankClient as t, parsePublishedRuntimeCachePayloadSchemaVersion as u };
|