@riverbankcms/sdk 0.157.0 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_dts/{BlocksIslandsHydrator-B3AHhvIn.d.ts → BlocksIslandsHydrator-BgNBtEai.d.ts} +1 -1
- package/dist/_dts/{Page-BMaOSVCP.d.ts → Page-DpCo8zXD.d.ts} +9 -6
- package/dist/_dts/{SdkPreviewMode-CEwDDqfK.d.ts → SdkPreviewMode-Bv2TMscG.d.ts} +2 -2
- package/dist/_dts/{client-BRFVhGUB.d.ts → client-B960v2gW.d.ts} +1 -1
- package/dist/_dts/{content-types-tEy1rtQ5.d.ts → content-types-CN0Wy8V6.d.ts} +26 -3
- package/dist/_dts/{contracts-BwDSOVGj.d.ts → contracts-BFUrby76.d.ts} +5 -4
- package/dist/_dts/{footerPageOutline-BVp5EPJj.d.ts → footerPageOutline-CmoqleLS.d.ts} +6 -6
- package/dist/_dts/{generatePageMetadata-BQb1mvpc.d.ts → generatePageMetadata-Dkvivc3R.d.ts} +2 -2
- package/dist/_dts/{hosted-booking-appearance-BN2Zu93B.d.ts → hosted-booking-appearance-BIbit60h.d.ts} +8976 -47
- package/dist/_dts/{index-Ca3oD2id.d.ts → index-Ba6RmuxX.d.ts} +3 -3
- package/dist/_dts/{index-Br1TNJlL.d.ts → index-DCNu_8it.d.ts} +4 -4
- package/dist/_dts/{index-CSLkIKs3.d.ts → index-DPfI2t5A.d.ts} +2 -2
- package/dist/_dts/{index-B0wsEbm3.d.ts → index-DaS_z6ir.d.ts} +1 -1
- package/dist/_dts/{index-B0DzVcrB.d.ts → index-DfkFWUxt.d.ts} +4 -1
- package/dist/_dts/{index-BF3hkKvt.d.ts → index-DpgkhY-a.d.ts} +2 -2
- package/dist/_dts/{loadContent-Dz9fOZMZ.d.ts → loadContent-DvvKF4nB.d.ts} +10 -7
- package/dist/_dts/{navigation-DOZwagCE.d.ts → navigation-n-eTVTIQ.d.ts} +75 -4
- package/dist/_dts/{resolvePageContent-oHZ8cfaF.d.ts → resolvePageContent-D0lGwVD6.d.ts} +2 -2
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +6 -6
- package/dist/_dts/sdk/src/config/index.d.ts +6 -6
- package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
- package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
- package/dist/_dts/sdk/src/index.d.ts +8 -8
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
- package/dist/_dts/sdk/src/next/index.d.ts +10 -7
- 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 +11 -4
- 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/index.d.ts +45 -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/routing/index.d.ts +5 -5
- package/dist/_dts/sdk/src/server.d.ts +5 -5
- package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
- package/dist/_dts/{types-Dy1DNdIV.d.ts → types-BJrRUaY7.d.ts} +2 -2
- package/dist/_dts/{types-6q1MDqxg.d.ts → types-BY7PgnDi.d.ts} +7 -7
- package/dist/_dts/{types-BuWOkyqw.d.ts → types-maEnXL6Z.d.ts} +3 -3
- package/dist/_dts/{validation-BumblAOO.d.ts → validation-BjuVrMrs.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-Cid8be1G.mjs → BlocksIslandsHydrator-WRLS96Ev.mjs} +17 -17
- package/dist/client/{BookingMailingListNote-BpzJTCZw.mjs → BookingMailingListNote-eovghMPa.mjs} +3 -56
- package/dist/client/{CalendarNavigationChevron-CBKHlGjE.mjs → CalendarNavigationChevron-CIcMQRc1.mjs} +5 -5
- package/dist/client/{DemoBookingPortalAccess-DpfgDMQ-.mjs → DemoBookingPortalAccess-CdnFgDyQ.mjs} +3 -3
- package/dist/client/{EventCalendar.client-DE5JHf4s.mjs → EventCalendar.client-Dc-ZLxKo.mjs} +8 -8
- package/dist/client/{EventCombined.client-DQLU3EAc.mjs → EventCombined.client-C93XqRIv.mjs} +6 -6
- package/dist/client/{EventItem-C9QTFafI.mjs → EventItem-DnCTygqk.mjs} +3 -3
- package/dist/client/{EventListWeekNavigation-6oYGdpNS.mjs → EventListWeekNavigation-9h97heuQ.mjs} +1 -1
- package/dist/client/{EventListing.client-D0N4Wj_4.mjs → EventListing.client-DFKlQvvs.mjs} +3 -3
- package/dist/client/{EventListing.view-Bish8-si.mjs → EventListing.view-pAuTDyrP.mjs} +4 -4
- package/dist/client/{EventRegistrationPayment-DLPYU2VU.mjs → EventRegistrationPayment-rgKlBvhP.mjs} +8 -7
- package/dist/client/{LeafletStaticMap-BmgEmEUS.mjs → LeafletStaticMap-3XiWSgy0.mjs} +1 -1
- package/dist/client/{Page-C-W_6VPx.mjs → Page-BmpeAwID.mjs} +750 -169
- package/dist/client/{StepIndicator-D8fvzhlS.mjs → StepIndicator-qEq6X5zP.mjs} +2 -2
- package/dist/client/{accordion-B5jBBoBC.mjs → accordion-DeObOasQ.mjs} +1 -1
- package/dist/client/{booking-form.client-xypjcfob.mjs → booking-form.client-DfWeF0lj.mjs} +36 -32
- package/dist/client/{bookingForm-CSE7NT54.mjs → bookingForm-TnzIBHx2.mjs} +4 -4
- package/dist/client/bookings.mjs +5 -5
- package/dist/client/{carousel-BrrLdGgn.mjs → carousel-kkFnbr5Z.mjs} +1 -1
- package/dist/client/{cart-QFgSKqia.mjs → cart-BAXNbFux.mjs} +3 -3
- package/dist/client/{cart.client-C6iA9v8X.mjs → cart.client-BczxUF70.mjs} +1 -1
- package/dist/client/{checkout-BAuLgA6Q.mjs → checkout-C5NRhPeP.mjs} +3 -3
- package/dist/client/{checkout.client-hbvBPpZR.mjs → checkout.client-BuDk3Td9.mjs} +1 -1
- package/dist/client/client.mjs +3 -2
- package/dist/client/{context-psG_Bwfs.mjs → context-CVsgML69.mjs} +1 -1
- package/dist/client/{cta-DrX2pzK9.mjs → cta-BWnUuJce.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-CClf0SHq.mjs → demoPortalMagicLink-CUlwvmxf.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-CqN7ig-2.mjs → enhanceHeaderSection-Cw8nnFj-.mjs} +2 -2
- package/dist/client/{event-details.client-CcYX4URD.mjs → event-details.client-Bl0E_6Vi.mjs} +2 -2
- package/dist/client/{event-registration.client-B8wVfnJ8.mjs → event-registration.client-DmfLg_LC.mjs} +15 -14
- package/dist/client/{eventCalendar-CRYN9-Vv.mjs → eventCalendar-D1Dwb9VA.mjs} +4 -4
- package/dist/client/{eventCombined-gGuj2_Vh.mjs → eventCombined-DfsqY1qR.mjs} +4 -4
- package/dist/client/{eventDetails-D1U7WEsJ.mjs → eventDetails-BmugDVoa.mjs} +2 -2
- package/dist/client/{eventListing-BY20rsvl.mjs → eventListing-BPAGJi3C.mjs} +4 -4
- package/dist/client/{eventRegistration-DnOZYpqh.mjs → eventRegistration-DBlz_x6u.mjs} +4 -4
- package/dist/client/{form-_q17Emh7.mjs → form-DVu3ZMjx.mjs} +3 -3
- package/dist/client/{form.client-BVaTf4FG.mjs → form.client-QZUyABIY.mjs} +3 -3
- package/dist/client/{form.parts-C9EmjE7U.mjs → form.parts-Bs0F3v08.mjs} +1 -1
- package/dist/client/formatDate-BD9D3dgo.mjs +26 -0
- package/dist/client/gifting/client.mjs +2 -2
- package/dist/client/{headerSection-CZ3unSkX.mjs → headerSection-BQwWW4Yy.mjs} +2 -2
- package/dist/client/{location-map.client-C_udm2_y.mjs → location-map.client-upKuwABk.mjs} +3 -10
- package/dist/client/{location-map.view-Bkd9gu_S.mjs → location-map.view-RuBCD10O.mjs} +87 -13
- package/dist/client/{locationMap-CunBAPoo.mjs → locationMap-1sCbsk0V.mjs} +2 -2
- package/dist/client/{newsletter-form.client-BkHhqPBi.mjs → newsletter-form.client-DBTU3oNv.mjs} +4 -4
- package/dist/client/{newsletter-form.parts-VGjM-NDG.mjs → newsletter-form.parts-C9I9JBhe.mjs} +1 -1
- package/dist/client/{newsletterForm-DGc1-NVR.mjs → newsletterForm-DTPtTxxG.mjs} +3 -3
- package/dist/client/{noop-D3wctocR.mjs → noop-DMFt3KdC.mjs} +19 -132
- package/dist/client/portal/client.mjs +589 -482
- package/dist/client/{product-detail.client-C_8N4OxU.mjs → product-detail.client-BX7M5o6p.mjs} +1 -1
- package/dist/client/{product-list.client-79qoSlLs.mjs → product-list.client-i32QNY4c.mjs} +1 -1
- package/dist/client/{productDetail-QGBXBpWb.mjs → productDetail-DWjE9zm7.mjs} +3 -3
- package/dist/client/{productList-Bdno11g6.mjs → productList-DZH9_brv.mjs} +3 -3
- package/dist/client/{propsDecoder-BpKsRqjG.mjs → propsDecoder-CTzHkEkh.mjs} +14 -3
- package/dist/client/{registry.server-D9GvC4EZ.mjs → registry.server-vJ5FlscU.mjs} +589 -246
- package/dist/client/rendering/client.mjs +23 -23
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +26 -4
- package/dist/client/{richText-coerce-Nln8Bw2P.mjs → richText-coerce-DXAmC72p.mjs} +1 -1
- package/dist/client/{routeIslandApiConfig-B4E30DaZ.mjs → routeIslandApiConfig-CmC7ygin.mjs} +1 -1
- package/dist/client/{shop-653-Nn74.mjs → shop-C7eL3B37.mjs} +3 -3
- package/dist/client/{shop-commerce-CfbvhT6h.mjs → shop-commerce-D8oRN0QJ.mjs} +9 -9
- package/dist/client/{shop-commerce-store-CfB26IXt.mjs → shop-commerce-store-CRnQ4M18.mjs} +1 -1
- package/dist/client/{shop.client-Bn7jUQOB.mjs → shop.client-X6d6KVmA.mjs} +9 -9
- package/dist/client/{shop.interactive-acMnyBZU.mjs → shop.interactive-DBMeM8VD.mjs} +155 -3
- package/dist/client/{shopShared-Du4efbgL.mjs → shopShared-Y182kN_s.mjs} +2 -2
- package/dist/client/{timetableModel-Duwk6gXe.mjs → timetableModel-D7PwpaBY.mjs} +5 -5
- package/dist/client/{useAvailableSlots-CbaAFr8M.mjs → useAvailableSlots-BDV6MHgJ.mjs} +2 -2
- package/dist/client/useBookingNowIso-DgJEv3ZY.mjs +58 -0
- package/dist/client/{useDiscountApply-DAl-GX21.mjs → useDiscountApply-BTu9EeT7.mjs} +1 -1
- package/dist/client/{useDiscountCodeUi-BUf9LuI6.mjs → useDiscountCodeUi-BfZxdxI-.mjs} +1 -1
- package/dist/client/{useEventPagination-hJDAEg-T.mjs → useEventPagination-pnvdHGeQ.mjs} +6 -6
- package/dist/client/{view-CFSMNvdC.mjs → view-BPEa6Okm.mjs} +8 -7
- package/dist/client/{view-4sSIJ6Ny.mjs → view-hJr_L4QC2.mjs} +3 -3
- package/dist/client/{wizardSteps-B3tRF3_2.mjs → wizardSteps-HdyGoIG3.mjs} +218 -47
- package/dist/preview-next/before-render.mjs +1 -1
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-BX5F0a_h.mjs → EventEmbeddedCheckoutStep-BFlBqSu4.mjs} +1 -1
- package/dist/preview-next/client/{PreviewEditorSidebar-DLzGdmTw.mjs → PreviewEditorSidebar-CXRUbqMp.mjs} +42 -26
- package/dist/preview-next/client/{PreviewEditorUI-Dru5AxOd.mjs → PreviewEditorUI-CxjEV0Fm.mjs} +31 -22
- package/dist/preview-next/client/{SdkPreviewModeRuntime-QVfwY0HY.mjs → SdkPreviewModeRuntime-BxI12BBS.mjs} +1310 -1226
- package/dist/preview-next/client/{SdkPreviewModeRuntime-V3absa-c.mjs → SdkPreviewModeRuntime-XdQSGGj_.mjs} +1 -1
- package/dist/preview-next/client/{SiteChromeCustomizeContext-RSPyKO_K.mjs → SiteChromeCustomizeContext-CfRQRwpH.mjs} +133891 -131593
- package/dist/preview-next/client/{ThemedButton-ADHirm0A.mjs → ThemedButton-BEOPss9H.mjs} +30 -4
- package/dist/preview-next/client/{previewChromeSurface-Cc4b9nBZ.mjs → previewChromeSurface-CH7hd5n7.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-CTLm99t6.mjs → sdk-runtime-C6xEU1LI.mjs} +1 -1
- package/dist/preview-next/client/{siteStyleAccess-YpHSMBBC.mjs → siteStyleAccess-CRXaC2oL.mjs} +2 -2
- package/dist/preview-next/client/{spinner-CsiSmy1g.mjs → spinner-BTf1CZmy.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-dR_Jzpo5.mjs → route-contract-DM22uOXM.mjs} +41 -0
- package/dist/server/{Block.shared-BNrmEY1p.mjs → Block.shared-DLoilC2J.mjs} +4 -4
- package/dist/server/{bindings-C9zgT9uX.mjs → bindings-C7DKLVx_.mjs} +1 -1
- package/dist/server/{blocks-BLm-OxTv.mjs → blocks-jlIm0PWc.mjs} +953 -324
- package/dist/server/{client-CaQ1ElR3.mjs → client-CU4wlMLE.mjs} +2 -2
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/index.mjs +2 -2
- package/dist/server/{loadContent-BFyU8YxS.mjs → loadContent-DmQ4BiiQ.mjs} +6 -4
- package/dist/server/{loadPage-DeQipVdO.mjs → loadPage-BBkDQA57.mjs} +3 -2
- package/dist/server/loadPage-ZrcfjG3X.mjs +2 -0
- package/dist/server/next.mjs +24 -12
- package/dist/server/{overrideResolution-D5nmZUYe.mjs → overrideResolution-ByeAbLSO.mjs} +1 -1
- package/dist/server/{overrides-BI13bIb7.mjs → overrides-BcA6ZPWf.mjs} +94 -30
- package/dist/server/page-converter.mjs +1 -1
- package/dist/server/{prebuild-UgDhSzy2.mjs → prebuild-8T-m7XjB.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-CLF-Y7h-.mjs → prefetchBlockData-Bjya-X9t.mjs} +6 -5
- package/dist/server/{publicProducts-vPbNQJsO.mjs → publicProducts-C3meXS2o.mjs} +41 -0
- package/dist/server/rendering/server.mjs +4 -4
- package/dist/server/rendering.mjs +26 -8
- package/dist/server/{resolveBlockData-C7J-pixy.mjs → resolveBlockData-D0ow8PRJ.mjs} +1 -1
- package/dist/server/routing.mjs +1 -1
- package/dist/server/server.mjs +3 -3
- package/dist/server/{siteChromeOverlayClearance-DLROm32h.mjs → siteChromeOverlayClearance-BangtD8A.mjs} +126 -1
- package/dist/server/{src-BZb5L4Fa.mjs → src-B935_bzN.mjs} +300 -2
- package/dist/server/theme-bridge.mjs +1 -1
- package/dist/server/{themeAdmission-x3uhdOWx.mjs → themeAdmission-D2-BnmDO.mjs} +314 -125
- package/dist/server/{validation-Ban_hxJG.mjs → validation-Cm41pDUB.mjs} +2 -2
- package/dist/server/{version-bkGVuskm.mjs → version-Bo9C3McI.mjs} +1 -1
- package/dist/styles/index.css +282 -0
- package/package.json +1 -1
- package/dist/server/loadPage-CvyKRtXK.mjs +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as parseContentVersionId, i as mediaPosterSchema, p as mediaIdentifierSchema, s as runtimeMediaSchema } from "./media-CcHwZkdJ.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Ai as resolveRepeaterGridRowFieldId, Di as projectRepeaterGridLayoutForRendering, Gi as isRecord$1, Jr as parseBlockIconValue, Oi as resolveRepeaterGridColumnFieldId, Si as linkSchema, Ti as parseRepeaterGridInteger, Wr as getBlockDefinition, _i as parseFieldDefinitions, a as sanitizeNewsletterSignupPublicContent, di as DEFAULT_MEDIA_FIELD_KINDS, fi as PUBLIC_FILE_FIELD_KINDS, ga as toUtcIsoDateTimeString, hi as normalizeSelectSource, ji as resolveRepeaterGridSpanFieldId, ki as resolveRepeaterGridColumnsForBreakpoint, li as parseInlineTextFromUnknown, pa as resolveBookingBusinessTimeZone, si as inlineTextToPlainText, ui as plainTextToInlineText, wi as buildRepeaterGridLayout } from "./blocks-jlIm0PWc.mjs";
|
|
3
3
|
import { at as boxBackgroundSchema, ot as runtimeBoxBackgroundSchema } from "./schema-Bs735S27.mjs";
|
|
4
4
|
import { r as isRichTextDoc } from "./richTextSchema-YYc85FX4.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -128,6 +128,79 @@ function isUnknownArray$1(value) {
|
|
|
128
128
|
return Array.isArray(value);
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
+
//#region ../blocks/src/system/manifest/fieldValidation/layoutGrid.ts
|
|
132
|
+
function layoutGridRecord(value) {
|
|
133
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
134
|
+
}
|
|
135
|
+
function resolveLayoutGridItemPlans(plan, item) {
|
|
136
|
+
return plan.repeatedItemVariants?.find((variant) => variant.typeId === item._type)?.fields ?? plan.repeatedItemPlan ?? [];
|
|
137
|
+
}
|
|
138
|
+
function layoutGridCoordinateFieldIds(plan) {
|
|
139
|
+
const grid = plan.layoutGrid;
|
|
140
|
+
return grid ? [
|
|
141
|
+
grid.spanField,
|
|
142
|
+
grid.rowField,
|
|
143
|
+
grid.columnField
|
|
144
|
+
] : [];
|
|
145
|
+
}
|
|
146
|
+
function acceptedSpans(plans, spanField) {
|
|
147
|
+
const span = plans.find((field) => field.fieldId === spanField);
|
|
148
|
+
if (span?.kind !== "select") return void 0;
|
|
149
|
+
const constraint = span.constraints.find((entry) => entry.kind === "selectOption");
|
|
150
|
+
return constraint?.kind === "selectOption" && constraint.source.kind === "static" ? constraint.source.values.map(Number) : [];
|
|
151
|
+
}
|
|
152
|
+
function gridIssue(plan, path, message) {
|
|
153
|
+
return {
|
|
154
|
+
kind: "invalidLayoutGrid",
|
|
155
|
+
fieldId: plan.fieldId,
|
|
156
|
+
label: plan.label,
|
|
157
|
+
path,
|
|
158
|
+
message
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function buildLayoutGridForPlan(plan, value, values, ids) {
|
|
162
|
+
const grid = plan.layoutGrid;
|
|
163
|
+
if (!grid) return null;
|
|
164
|
+
const columns = grid.columns ?? (grid.columnsFields ? resolveRepeaterGridColumnsForBreakpoint(values, grid.columnsFields, "lg") : 1);
|
|
165
|
+
return buildRepeaterGridLayout({
|
|
166
|
+
items: value.flatMap((item, index) => {
|
|
167
|
+
const row = layoutGridRecord(item);
|
|
168
|
+
return row ? [{
|
|
169
|
+
id: ids?.[index] ?? String(index),
|
|
170
|
+
startNewRow: grid.startNewRowField ? row[grid.startNewRowField] === true : false,
|
|
171
|
+
span: parseRepeaterGridInteger(row[grid.spanField]) ?? NaN,
|
|
172
|
+
row: parseRepeaterGridInteger(row[grid.rowField]) ?? NaN,
|
|
173
|
+
colStart: parseRepeaterGridInteger(row[grid.columnField]) ?? NaN,
|
|
174
|
+
acceptedSpans: acceptedSpans(resolveLayoutGridItemPlans(plan, row), grid.spanField)
|
|
175
|
+
}] : [];
|
|
176
|
+
}),
|
|
177
|
+
columns,
|
|
178
|
+
maxRows: grid.maxRows,
|
|
179
|
+
placementPolicy: grid.columns === void 0 ? "free" : "flow"
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function validateGrid(plan, value, values, path) {
|
|
183
|
+
const layout = buildLayoutGridForPlan(plan, value, values);
|
|
184
|
+
if (!layout) return [];
|
|
185
|
+
if (layout.hasCollisions || layout.overCapacity) return [gridIssue(plan, path, "Some items overlap or do not fit in this layout. Adjust their widths or positions before saving.")];
|
|
186
|
+
return layout.hasInvalidItems ? [gridIssue(plan, path, "Choose an available width and a valid position for each item before saving.")] : [];
|
|
187
|
+
}
|
|
188
|
+
/** Root values resolve the same column bindings as the editor; recurse without changing any content. */
|
|
189
|
+
function validateLayoutGridPlans(plans, value, rootValues = layoutGridRecord(value) ?? {}, parent = []) {
|
|
190
|
+
const values = layoutGridRecord(value);
|
|
191
|
+
if (!values) return [];
|
|
192
|
+
return plans.flatMap((plan) => {
|
|
193
|
+
const fieldValue = values[plan.fieldId];
|
|
194
|
+
const path = [...parent, plan.fieldId];
|
|
195
|
+
if (plan.kind === "group") return validateLayoutGridPlans(allGroupChildPlans(plan), fieldValue, rootValues, path);
|
|
196
|
+
if (plan.kind !== "repeater" || !Array.isArray(fieldValue)) return [];
|
|
197
|
+
return [...validateGrid(plan, fieldValue, rootValues, path), ...fieldValue.flatMap((item, index) => {
|
|
198
|
+
const row = layoutGridRecord(item);
|
|
199
|
+
return row ? validateLayoutGridPlans(resolveLayoutGridItemPlans(plan, row), row, rootValues, [...path, index]) : [];
|
|
200
|
+
})];
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
131
204
|
//#region ../blocks/src/system/manifest/fieldValidation/index.ts
|
|
132
205
|
const TEL_RE = /^[+()0-9\s-]{3,}$/;
|
|
133
206
|
const SLUG_PATTERN = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*)(?:\/(?:[a-z0-9]+(?:-[a-z0-9]+)*))*$/;
|
|
@@ -142,7 +215,7 @@ function validationContext(options = {}) {
|
|
|
142
215
|
const isDraft = options.mode === "draft";
|
|
143
216
|
return {
|
|
144
217
|
allowNull: options.allowNull ?? true,
|
|
145
|
-
allowIncomplete: isDraft || (options.allowIncomplete ?? false),
|
|
218
|
+
allowIncomplete: options.mode === "storable" ? false : isDraft || (options.allowIncomplete ?? false),
|
|
146
219
|
mode: options.mode ?? "strict"
|
|
147
220
|
};
|
|
148
221
|
}
|
|
@@ -165,18 +238,20 @@ function parseFieldPathKey(key) {
|
|
|
165
238
|
return Number.isInteger(numeric) && String(numeric) === segment ? numeric : segment;
|
|
166
239
|
});
|
|
167
240
|
}
|
|
241
|
+
const simpleIssueMessages = {
|
|
242
|
+
required: "This field is required",
|
|
243
|
+
invalidEmail: "Enter a valid email address",
|
|
244
|
+
invalidPhone: "Enter a valid phone number",
|
|
245
|
+
invalidPattern: "Check the format and try again",
|
|
246
|
+
invalidUrl: "Enter a valid web address",
|
|
247
|
+
invalidDate: "Choose a valid date",
|
|
248
|
+
invalidTime: "Choose a valid time",
|
|
249
|
+
invalidDateTime: "Choose a valid date and time"
|
|
250
|
+
};
|
|
168
251
|
function fieldIssueToMessage(issue) {
|
|
169
252
|
switch (issue.kind) {
|
|
170
|
-
case "required": return "This field is required";
|
|
171
253
|
case "wrongType": return `${issue.label} needs ${issue.expected}`;
|
|
172
254
|
case "tooLong": return `Use ${issue.maximum} characters or fewer`;
|
|
173
|
-
case "invalidEmail": return "Enter a valid email address";
|
|
174
|
-
case "invalidPhone": return "Enter a valid phone number";
|
|
175
|
-
case "invalidPattern": return "Check the format and try again";
|
|
176
|
-
case "invalidUrl": return "Enter a valid web address";
|
|
177
|
-
case "invalidDate": return "Choose a valid date";
|
|
178
|
-
case "invalidTime": return "Choose a valid time";
|
|
179
|
-
case "invalidDateTime": return "Choose a valid date and time";
|
|
180
255
|
case "invalidNumber": return `${issue.label} needs a number`;
|
|
181
256
|
case "tooSmall": return `${issue.label} must be ${issue.minimum} or more`;
|
|
182
257
|
case "tooLarge": return `${issue.label} must be ${issue.maximum} or less`;
|
|
@@ -189,7 +264,16 @@ function fieldIssueToMessage(issue) {
|
|
|
189
264
|
case "invalidMedia": return `${issue.label} must be a media object with an identifier`;
|
|
190
265
|
case "invalidBoxBackground": return `${issue.label} must use a valid background type and matching fields`;
|
|
191
266
|
case "invalidLink": return `${issue.label} must be a valid link`;
|
|
267
|
+
case "invalidLayoutGrid": return issue.message;
|
|
192
268
|
case "invalidReference": return `${issue.label} must reference a valid item`;
|
|
269
|
+
case "required":
|
|
270
|
+
case "invalidDate":
|
|
271
|
+
case "invalidDateTime":
|
|
272
|
+
case "invalidEmail":
|
|
273
|
+
case "invalidPattern":
|
|
274
|
+
case "invalidPhone":
|
|
275
|
+
case "invalidTime":
|
|
276
|
+
case "invalidUrl": return simpleIssueMessages[issue.kind];
|
|
193
277
|
default: return assertNever(issue);
|
|
194
278
|
}
|
|
195
279
|
}
|
|
@@ -299,11 +383,7 @@ function deriveFieldValidationPlan(field, path = [field.id]) {
|
|
|
299
383
|
};
|
|
300
384
|
case "link": return makePlan("link", "object", field, path, required, commonConstraints(required, { kind: "linkObject" }));
|
|
301
385
|
case "boolean": return makePlan("boolean", "boolean", field, path, required, requiredConstraints(required));
|
|
302
|
-
case "repeater": return
|
|
303
|
-
...makePlan("repeater", "array", field, path, required, commonConstraints(required, { kind: "arrayType" })),
|
|
304
|
-
...field.polymorphic && field.itemTypes ? { repeatedItemVariants: deriveRepeatedItemVariants(field, [...path, 0]) } : { repeatedItemPlan: deriveNestedFieldPlans(getRepeaterFields(field), [...path, 0]) },
|
|
305
|
-
constraints: withRepeaterItemConstraints(field, commonConstraints(required, { kind: "arrayType" }))
|
|
306
|
-
};
|
|
386
|
+
case "repeater": return deriveRepeaterFieldValidationPlan(field, path);
|
|
307
387
|
case "group":
|
|
308
388
|
case "modal": return {
|
|
309
389
|
...makePlan("group", "object", field, path, required, requiredConstraints(required)),
|
|
@@ -320,6 +400,27 @@ function deriveFieldValidationPlan(field, path = [field.id]) {
|
|
|
320
400
|
default: return assertNever(field);
|
|
321
401
|
}
|
|
322
402
|
}
|
|
403
|
+
function deriveRepeaterFieldValidationPlan(field, path) {
|
|
404
|
+
const required = Boolean(field.required);
|
|
405
|
+
const constraints = commonConstraints(required, { kind: "arrayType" });
|
|
406
|
+
return {
|
|
407
|
+
...makePlan("repeater", "array", field, path, required, constraints),
|
|
408
|
+
...field.ui?.repeaterPreset === "layoutGrid" ? { layoutGrid: {
|
|
409
|
+
startNewRowField: field.ui.layoutGridStartNewRowField,
|
|
410
|
+
columns: field.ui.layoutGridColumns,
|
|
411
|
+
columnsFields: field.ui.layoutGridColumnsFields,
|
|
412
|
+
spanField: resolveRepeaterGridSpanFieldId({ id: field.ui.layoutGridSpanField }),
|
|
413
|
+
rowField: resolveRepeaterGridRowFieldId({ id: field.ui.layoutGridRowField }),
|
|
414
|
+
columnField: resolveRepeaterGridColumnFieldId({ id: field.ui.layoutGridColumnField }),
|
|
415
|
+
maxRows: field.ui.layoutGridMaxRows
|
|
416
|
+
} } : {},
|
|
417
|
+
...field.polymorphic && field.itemTypes ? { repeatedItemVariants: deriveRepeatedItemVariants(field, [...path, 0]) } : {
|
|
418
|
+
repeatedItemPlan: deriveNestedFieldPlans(getRepeaterFields(field), [...path, 0]),
|
|
419
|
+
flattenedGroupIds: getFlattenedGroupIds(field.schema?.fields ?? [])
|
|
420
|
+
},
|
|
421
|
+
constraints: withRepeaterItemConstraints(field, constraints)
|
|
422
|
+
};
|
|
423
|
+
}
|
|
323
424
|
function deriveFieldValidationPlans(fields, parentPath = []) {
|
|
324
425
|
return fields.map((field) => deriveFieldValidationPlan(field, [...parentPath, field.id]));
|
|
325
426
|
}
|
|
@@ -365,7 +466,8 @@ function withRepeaterItemConstraints(field, constraints) {
|
|
|
365
466
|
function deriveRepeatedItemVariants(field, parentPath) {
|
|
366
467
|
return Object.entries(field.itemTypes ?? {}).map(([typeId, itemType]) => ({
|
|
367
468
|
typeId,
|
|
368
|
-
fields: deriveNestedFieldPlans(getFlattenedRepeaterFields(itemType.fields), parentPath)
|
|
469
|
+
fields: deriveNestedFieldPlans(getFlattenedRepeaterFields(itemType.fields), parentPath),
|
|
470
|
+
flattenedGroupIds: getFlattenedGroupIds(itemType.fields)
|
|
369
471
|
}));
|
|
370
472
|
}
|
|
371
473
|
function deriveNestedFieldPlans(fields, parentPath) {
|
|
@@ -374,6 +476,11 @@ function deriveNestedFieldPlans(fields, parentPath) {
|
|
|
374
476
|
function getRepeaterFields(field) {
|
|
375
477
|
return getFlattenedRepeaterFields(field.polymorphic && field.itemTypes ? Object.values(field.itemTypes).flatMap((itemType) => itemType.fields) : field.schema?.fields ?? []);
|
|
376
478
|
}
|
|
479
|
+
/** Only group ids absent from the actual data fields are forbidden containers. */
|
|
480
|
+
function getFlattenedGroupIds(fields) {
|
|
481
|
+
const dataIds = new Set(getFlattenedRepeaterFields(fields).map((field) => field.id));
|
|
482
|
+
return fields.flatMap((field) => field.type === "group" && field.ui?.flattenInRepeater && !dataIds.has(field.id) ? [field.id] : []);
|
|
483
|
+
}
|
|
377
484
|
function getFlattenedRepeaterFields(fields) {
|
|
378
485
|
return fields.flatMap((child) => {
|
|
379
486
|
if (child.type === "group" && child.ui?.flattenInRepeater) return child.schema?.fields ?? [];
|
|
@@ -445,7 +552,8 @@ function normalizeStoredRepeaterItems(plan, value, ctx) {
|
|
|
445
552
|
return value.map((item) => {
|
|
446
553
|
if (!item || typeof item !== "object" || Array.isArray(item)) return item;
|
|
447
554
|
const itemRecord = item;
|
|
448
|
-
const
|
|
555
|
+
const selection = selectRepeaterItemPlan(plan, itemRecord);
|
|
556
|
+
const fields = selection.kind === "fields" ? selection.fields : void 0;
|
|
449
557
|
if (!fields) return item;
|
|
450
558
|
return normalizeStoredObjectChildren(fields, itemRecord, ctx);
|
|
451
559
|
});
|
|
@@ -493,7 +601,8 @@ function normalizeRepeaterItems(plan, value, ctx) {
|
|
|
493
601
|
return value.map((item) => {
|
|
494
602
|
if (!item || typeof item !== "object" || Array.isArray(item)) return item;
|
|
495
603
|
const itemRecord = item;
|
|
496
|
-
const
|
|
604
|
+
const selection = selectRepeaterItemPlan(plan, itemRecord);
|
|
605
|
+
const fields = selection.kind === "fields" ? selection.fields : void 0;
|
|
497
606
|
if (!fields) return item;
|
|
498
607
|
return normalizeObjectChildren(fields, itemRecord, ctx);
|
|
499
608
|
});
|
|
@@ -508,11 +617,11 @@ function acceptsOptionalBlankAsMissing(plan, value) {
|
|
|
508
617
|
return plan.constraints.some((constraint) => constraint.kind === "urlFormat" || constraint.kind === "slugFormat" || constraint.kind === "emailFormat" || constraint.kind === "phoneFormat" || constraint.kind === "patternFormat");
|
|
509
618
|
}
|
|
510
619
|
function validateNormalizedFieldValue(plan, value, ctx) {
|
|
511
|
-
if (value === null && (ctx
|
|
512
|
-
if (isMissingForPlan(plan, value)) return shouldRequireValue(plan, value, ctx) ? [requiredIssue(plan, value)] : [];
|
|
620
|
+
if (value === null && acceptsNullValue(plan, ctx)) return [];
|
|
621
|
+
if (isMissingForPlan(plan, value, ctx.mode)) return shouldRequireValue(plan, value, ctx) ? [requiredIssue(plan, value)] : [];
|
|
513
622
|
switch (plan.kind) {
|
|
514
623
|
case "string": return validateStringPlan(plan, value, ctx);
|
|
515
|
-
case "number": return validateNumberPlan(plan, value);
|
|
624
|
+
case "number": return validateNumberPlan(plan, value, ctx);
|
|
516
625
|
case "boolean": return typeof value === "boolean" ? [] : [issue(plan, "wrongType", { expected: "a true/false value" })];
|
|
517
626
|
case "select": return validateSelectPlan(plan, value);
|
|
518
627
|
case "richText": return isValidRichTextDoc(value) ? [] : [issue(plan, "invalidRichText")];
|
|
@@ -536,14 +645,18 @@ function validateMediaPlan(plan, value, ctx) {
|
|
|
536
645
|
}
|
|
537
646
|
function shouldRequireValue(plan, value, ctx) {
|
|
538
647
|
if (!plan.required || ctx.allowIncomplete) return false;
|
|
539
|
-
if (value === null && ctx.allowNull) return false;
|
|
648
|
+
if (value === null && ctx.allowNull && ctx.mode !== "storable") return false;
|
|
540
649
|
return true;
|
|
541
650
|
}
|
|
651
|
+
function acceptsNullValue(plan, ctx) {
|
|
652
|
+
return ctx.mode === "storable" ? !plan.required : ctx.allowNull || acceptsOptionalNullValue(plan);
|
|
653
|
+
}
|
|
542
654
|
function acceptsOptionalNullValue(plan) {
|
|
543
655
|
return !plan.required && (plan.kind === "media" || plan.kind === "number");
|
|
544
656
|
}
|
|
545
|
-
function isMissingForPlan(plan, value) {
|
|
657
|
+
function isMissingForPlan(plan, value, mode) {
|
|
546
658
|
if (value === void 0) return true;
|
|
659
|
+
if (mode === "storable") return value === null || value === "";
|
|
547
660
|
if (value === null) return plan.required;
|
|
548
661
|
if (typeof value === "string" && value.trim() === "") return true;
|
|
549
662
|
if (Array.isArray(value) && value.length === 0) return true;
|
|
@@ -558,7 +671,7 @@ function validateStringConstraint(plan, constraint, value, ctx) {
|
|
|
558
671
|
if (constraint.kind === "required") return [];
|
|
559
672
|
if (constraint.kind === "blockIconValue") return isValidIconPickerValue(value) ? [] : [issue(plan, "wrongType", { expected: "text or icon" })];
|
|
560
673
|
if (typeof value !== "string") return [issue(plan, "wrongType", { expected: "text" })];
|
|
561
|
-
if (constraint.kind === "textType" || constraint.kind === "referenceText") return [];
|
|
674
|
+
if (constraint.kind === "textType" || constraint.kind === "referenceText" || ctx.mode === "storable") return [];
|
|
562
675
|
return constraint.kind === "maxLength" ? validateAuthoredTextLength(plan, value, constraint.maximum, ctx) : validateStringFormat(plan, constraint, value);
|
|
563
676
|
}
|
|
564
677
|
const SIMPLE_STRING_FORMATS = {
|
|
@@ -598,7 +711,7 @@ function validateStringFormat(plan, constraint, value) {
|
|
|
598
711
|
}
|
|
599
712
|
/** Authoring limits govern stored block copy; resolved entry text has its own owner. */
|
|
600
713
|
function validateAuthoredTextLength(plan, text, maximum, ctx) {
|
|
601
|
-
return ctx.mode !== "render" && maximum !== void 0 && text.length > maximum ? [issue(plan, "tooLong", { maximum })] : [];
|
|
714
|
+
return ctx.mode !== "render" && ctx.mode !== "storable" && maximum !== void 0 && text.length > maximum ? [issue(plan, "tooLong", { maximum })] : [];
|
|
602
715
|
}
|
|
603
716
|
function isValidIconPickerValue(value) {
|
|
604
717
|
if (typeof value === "string") return true;
|
|
@@ -606,8 +719,9 @@ function isValidIconPickerValue(value) {
|
|
|
606
719
|
if (value.kind === "none") return true;
|
|
607
720
|
return parseBlockIconValue(value).kind !== "none";
|
|
608
721
|
}
|
|
609
|
-
function validateNumberPlan(plan, value) {
|
|
722
|
+
function validateNumberPlan(plan, value, ctx) {
|
|
610
723
|
if (!isValidNumber(value)) return [issue(plan, "invalidNumber")];
|
|
724
|
+
if (ctx.mode === "storable") return [];
|
|
611
725
|
return plan.constraints.flatMap((constraint) => validateNumberConstraint(plan, constraint, Number(value)));
|
|
612
726
|
}
|
|
613
727
|
function validateNumberConstraint(plan, constraint, value) {
|
|
@@ -626,7 +740,7 @@ function validateSelectPlan(plan, value) {
|
|
|
626
740
|
}
|
|
627
741
|
function validateRepeaterPlan(plan, value, ctx) {
|
|
628
742
|
if (!Array.isArray(value)) return [issue(plan, "wrongType", { expected: "a list" })];
|
|
629
|
-
return [...plan.constraints.flatMap((constraint) => {
|
|
743
|
+
return [...ctx.mode === "storable" ? [] : plan.constraints.flatMap((constraint) => {
|
|
630
744
|
switch (constraint.kind) {
|
|
631
745
|
case "required":
|
|
632
746
|
case "arrayType": return [];
|
|
@@ -642,6 +756,22 @@ function validateRepeaterPlan(plan, value, ctx) {
|
|
|
642
756
|
}
|
|
643
757
|
}), ...value.flatMap((item, index) => validateRepeaterItem(plan, item, index, ctx))];
|
|
644
758
|
}
|
|
759
|
+
/** Selects both the value fields and forbidden presentation containers together. */
|
|
760
|
+
function selectRepeaterItemPlan(plan, item) {
|
|
761
|
+
if (plan.repeatedItemVariants) {
|
|
762
|
+
const variant = plan.repeatedItemVariants.find((candidate) => candidate.typeId === item._type);
|
|
763
|
+
return variant ? {
|
|
764
|
+
kind: "fields",
|
|
765
|
+
fields: variant.fields,
|
|
766
|
+
flattenedGroupIds: variant.flattenedGroupIds ?? []
|
|
767
|
+
} : { kind: "invalidType" };
|
|
768
|
+
}
|
|
769
|
+
return plan.repeatedItemPlan ? {
|
|
770
|
+
kind: "fields",
|
|
771
|
+
fields: plan.repeatedItemPlan,
|
|
772
|
+
flattenedGroupIds: plan.flattenedGroupIds ?? []
|
|
773
|
+
} : { kind: "untyped" };
|
|
774
|
+
}
|
|
645
775
|
function validateRepeaterItem(plan, item, index, ctx) {
|
|
646
776
|
if (!isPlainObject(item)) return [{
|
|
647
777
|
kind: "wrongType",
|
|
@@ -650,9 +780,8 @@ function validateRepeaterItem(plan, item, index, ctx) {
|
|
|
650
780
|
label: plan.label,
|
|
651
781
|
expected: "an object"
|
|
652
782
|
}];
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
if (plan.repeatedItemVariants && !variant) return [{
|
|
783
|
+
const selection = selectRepeaterItemPlan(plan, item);
|
|
784
|
+
if (selection.kind === "invalidType") return [{
|
|
656
785
|
kind: "invalidOption",
|
|
657
786
|
path: [
|
|
658
787
|
...plan.path,
|
|
@@ -662,11 +791,25 @@ function validateRepeaterItem(plan, item, index, ctx) {
|
|
|
662
791
|
fieldId: "_type",
|
|
663
792
|
label: `${plan.label} item type`
|
|
664
793
|
}];
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
794
|
+
if (selection.kind === "untyped") return [];
|
|
795
|
+
return [...validateFlattenedGroupContainers(selection.flattenedGroupIds, item, plan, index, ctx), ...selection.fields.flatMap((childPlan) => {
|
|
796
|
+
if (ctx.layoutGridCoordinates === "projected" && layoutGridCoordinateFieldIds(plan).includes(childPlan.fieldId)) return [];
|
|
668
797
|
return validateNormalizedFieldValue(materializeRepeaterItemPlan(childPlan, plan.path, index), item[childPlan.fieldId], ctx);
|
|
669
|
-
});
|
|
798
|
+
})];
|
|
799
|
+
}
|
|
800
|
+
function validateFlattenedGroupContainers(groupIds, item, plan, index, ctx) {
|
|
801
|
+
if (ctx.mode === "render") return [];
|
|
802
|
+
return groupIds.flatMap((fieldId) => Object.prototype.hasOwnProperty.call(item, fieldId) ? [{
|
|
803
|
+
kind: "wrongType",
|
|
804
|
+
path: [
|
|
805
|
+
...plan.path,
|
|
806
|
+
index,
|
|
807
|
+
fieldId
|
|
808
|
+
],
|
|
809
|
+
fieldId,
|
|
810
|
+
label: plan.label,
|
|
811
|
+
expected: "valid settings"
|
|
812
|
+
}] : []);
|
|
670
813
|
}
|
|
671
814
|
function validateGroupPlan(plan, value, ctx) {
|
|
672
815
|
if (!isPlainObject(value)) return [issue(plan, "wrongType", { expected: "an object" })];
|
|
@@ -761,17 +904,22 @@ function requiredIssue(plan, value) {
|
|
|
761
904
|
if (Array.isArray(value)) return issue(plan, "required", { emptyOrigin: "array" });
|
|
762
905
|
return issue(plan, "required");
|
|
763
906
|
}
|
|
764
|
-
function fieldPlanToZod(plan, options = {}) {
|
|
765
|
-
const ctx =
|
|
907
|
+
function fieldPlanToZod(plan, options = {}, layoutGridCoordinates = "validate") {
|
|
908
|
+
const ctx = {
|
|
909
|
+
...validationContext(options),
|
|
910
|
+
layoutGridCoordinates
|
|
911
|
+
};
|
|
766
912
|
return z.any().transform((value) => normalizeFieldValue(plan, value, ctx)).superRefine((value, zodCtx) => {
|
|
767
|
-
|
|
913
|
+
validateNormalizedFieldValue(plan, value, ctx).forEach((validationIssue) => {
|
|
914
|
+
addFieldIssueToZodContext(zodCtx, validationIssue, plan.path);
|
|
915
|
+
});
|
|
768
916
|
});
|
|
769
917
|
}
|
|
770
918
|
function fieldPresenceForPlan(plan) {
|
|
771
919
|
return plan.required ? { kind: "required" } : { kind: "optional" };
|
|
772
920
|
}
|
|
773
|
-
function fieldPlanToObjectPropertyZod(plan, options = {}) {
|
|
774
|
-
const schema = fieldPlanToZod(plan, options);
|
|
921
|
+
function fieldPlanToObjectPropertyZod(plan, options = {}, layoutGridCoordinates = "validate") {
|
|
922
|
+
const schema = fieldPlanToZod(plan, options, layoutGridCoordinates);
|
|
775
923
|
const presence = fieldPresenceForPlan(plan);
|
|
776
924
|
switch (presence.kind) {
|
|
777
925
|
case "required": return schema;
|
|
@@ -780,11 +928,14 @@ function fieldPlanToObjectPropertyZod(plan, options = {}) {
|
|
|
780
928
|
}
|
|
781
929
|
}
|
|
782
930
|
/** Validate stored or runtime fields without applying editor/write normalization. */
|
|
783
|
-
function fieldPlanToStrictObjectPropertyZod(plan, mode = "strict") {
|
|
784
|
-
const ctx =
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
931
|
+
function fieldPlanToStrictObjectPropertyZod(plan, mode = "strict", layoutGridCoordinates = "validate") {
|
|
932
|
+
const ctx = {
|
|
933
|
+
...strictValidationContext({
|
|
934
|
+
allowNull: false,
|
|
935
|
+
mode
|
|
936
|
+
}),
|
|
937
|
+
layoutGridCoordinates
|
|
938
|
+
};
|
|
788
939
|
const schema = z.any().superRefine((value, zodCtx) => {
|
|
789
940
|
validateNormalizedFieldValue(plan, value, ctx).forEach((validationIssue) => {
|
|
790
941
|
addFieldIssueToZodContext(zodCtx, validationIssue, plan.path);
|
|
@@ -792,76 +943,35 @@ function fieldPlanToStrictObjectPropertyZod(plan, mode = "strict") {
|
|
|
792
943
|
});
|
|
793
944
|
return plan.required ? schema : schema.optional();
|
|
794
945
|
}
|
|
795
|
-
function
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
maximum: validationIssue.maximum,
|
|
825
|
-
inclusive: true,
|
|
826
|
-
message
|
|
827
|
-
});
|
|
828
|
-
return;
|
|
829
|
-
case "invalidOption":
|
|
830
|
-
zodCtx.addIssue({
|
|
831
|
-
...issuePath,
|
|
832
|
-
code: "invalid_value",
|
|
833
|
-
values: [],
|
|
834
|
-
message
|
|
835
|
-
});
|
|
836
|
-
return;
|
|
837
|
-
case "wrongType":
|
|
838
|
-
case "invalidEmail":
|
|
839
|
-
case "invalidPhone":
|
|
840
|
-
case "invalidPattern":
|
|
841
|
-
case "invalidUrl":
|
|
842
|
-
case "invalidDate":
|
|
843
|
-
case "invalidTime":
|
|
844
|
-
case "invalidDateTime":
|
|
845
|
-
case "invalidNumber":
|
|
846
|
-
case "tooSmall":
|
|
847
|
-
case "tooLarge":
|
|
848
|
-
case "invalidSlug":
|
|
849
|
-
case "tooFewItems":
|
|
850
|
-
case "tooManyItems":
|
|
851
|
-
case "invalidRichText":
|
|
852
|
-
case "invalidInlineText":
|
|
853
|
-
case "invalidMedia":
|
|
854
|
-
case "invalidBoxBackground":
|
|
855
|
-
case "invalidLink":
|
|
856
|
-
case "invalidReference":
|
|
857
|
-
zodCtx.addIssue({
|
|
858
|
-
...issuePath,
|
|
859
|
-
code: "custom",
|
|
860
|
-
message
|
|
861
|
-
});
|
|
862
|
-
return;
|
|
863
|
-
default: assertNever(validationIssue);
|
|
864
|
-
}
|
|
946
|
+
function fieldIssueToZodDetail(issue) {
|
|
947
|
+
if (issue.kind === "required") return issue.emptyOrigin ? {
|
|
948
|
+
code: "too_small",
|
|
949
|
+
origin: issue.emptyOrigin,
|
|
950
|
+
minimum: 1,
|
|
951
|
+
inclusive: true
|
|
952
|
+
} : {
|
|
953
|
+
code: "invalid_type",
|
|
954
|
+
expected: "nonoptional"
|
|
955
|
+
};
|
|
956
|
+
if (issue.kind === "tooLong") return {
|
|
957
|
+
code: "too_big",
|
|
958
|
+
origin: "string",
|
|
959
|
+
maximum: issue.maximum,
|
|
960
|
+
inclusive: true
|
|
961
|
+
};
|
|
962
|
+
if (issue.kind === "invalidOption") return {
|
|
963
|
+
code: "invalid_value",
|
|
964
|
+
values: []
|
|
965
|
+
};
|
|
966
|
+
return { code: "custom" };
|
|
967
|
+
}
|
|
968
|
+
function addFieldIssueToZodContext(zodCtx, issue, rootPath) {
|
|
969
|
+
const detail = fieldIssueToZodDetail(issue);
|
|
970
|
+
zodCtx.addIssue({
|
|
971
|
+
...detail,
|
|
972
|
+
path: toZodIssuePath(relativeZodIssuePath(issue.path, rootPath)),
|
|
973
|
+
message: fieldIssueToMessage(issue)
|
|
974
|
+
});
|
|
865
975
|
}
|
|
866
976
|
function relativeZodIssuePath(path, rootPath) {
|
|
867
977
|
return startsWithFieldPath(path, rootPath) ? path.slice(rootPath.length) : path;
|
|
@@ -962,6 +1072,59 @@ function isEmptyRichTextDoc(value) {
|
|
|
962
1072
|
return first?.type === "paragraph" && (!Array.isArray(first.content) || first.content.length === 0);
|
|
963
1073
|
}
|
|
964
1074
|
//#endregion
|
|
1075
|
+
//#region ../blocks/src/system/manifest/fieldValidation/layoutGridRendering.ts
|
|
1076
|
+
function hasInvalidCoordinateValues(plan, items) {
|
|
1077
|
+
const ids = layoutGridCoordinateFieldIds(plan);
|
|
1078
|
+
return items.some((item) => {
|
|
1079
|
+
const row = layoutGridRecord(item);
|
|
1080
|
+
return row !== null && resolveLayoutGridItemPlans(plan, row).some((field) => ids.includes(field.fieldId) && !fieldPlanToStrictObjectPropertyZod(field).safeParse(row[field.fieldId]).success);
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
/** Shared raw-coordinate admission for editor and public rendering; retains diagnostics. */
|
|
1084
|
+
function admitLayoutGridForPlan(plan, value, rootValues, ids) {
|
|
1085
|
+
const layout = buildLayoutGridForPlan(plan, value, rootValues, ids);
|
|
1086
|
+
return layout && !layout.hasInvalidItems && hasInvalidCoordinateValues(plan, value) ? {
|
|
1087
|
+
...layout,
|
|
1088
|
+
hasInvalidItems: true
|
|
1089
|
+
} : layout;
|
|
1090
|
+
}
|
|
1091
|
+
function projectGrid(plan, value, rootValues) {
|
|
1092
|
+
const grid = plan.layoutGrid;
|
|
1093
|
+
const layout = admitLayoutGridForPlan(plan, value, rootValues);
|
|
1094
|
+
if (!grid || !layout) return value;
|
|
1095
|
+
const authored = layout;
|
|
1096
|
+
const projected = projectRepeaterGridLayoutForRendering(authored);
|
|
1097
|
+
if (projected === authored) return value;
|
|
1098
|
+
return value.map((item, index) => {
|
|
1099
|
+
const row = layoutGridRecord(item);
|
|
1100
|
+
const placement = projected.byId[String(index)];
|
|
1101
|
+
if (!row || !placement) return item;
|
|
1102
|
+
const spanPlan = resolveLayoutGridItemPlans(plan, row).find((field) => field.fieldId === grid.spanField);
|
|
1103
|
+
return {
|
|
1104
|
+
...row,
|
|
1105
|
+
[grid.spanField]: spanPlan?.kind === "number" ? placement.span : String(placement.span),
|
|
1106
|
+
[grid.rowField]: placement.row,
|
|
1107
|
+
[grid.columnField]: placement.colStart
|
|
1108
|
+
};
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
/** Only layout coordinates are projected. Array order, item data and media references remain intact. */
|
|
1112
|
+
function projectLayoutGridPlansForRendering(plans, value, rootValues = layoutGridRecord(value) ?? {}) {
|
|
1113
|
+
const values = layoutGridRecord(value);
|
|
1114
|
+
if (!values) return value;
|
|
1115
|
+
return plans.reduce((projected, plan) => {
|
|
1116
|
+
const fieldValue = projected[plan.fieldId];
|
|
1117
|
+
const next = plan.kind === "group" ? projectLayoutGridPlansForRendering(allGroupChildPlans(plan), fieldValue, rootValues) : plan.kind === "repeater" && Array.isArray(fieldValue) ? projectGrid(plan, fieldValue, rootValues).map((item) => {
|
|
1118
|
+
const row = layoutGridRecord(item);
|
|
1119
|
+
return row ? projectLayoutGridPlansForRendering(resolveLayoutGridItemPlans(plan, row), row, rootValues) : item;
|
|
1120
|
+
}) : fieldValue;
|
|
1121
|
+
return next === fieldValue ? projected : {
|
|
1122
|
+
...projected,
|
|
1123
|
+
[plan.fieldId]: next
|
|
1124
|
+
};
|
|
1125
|
+
}, values);
|
|
1126
|
+
}
|
|
1127
|
+
//#endregion
|
|
965
1128
|
//#region ../blocks/src/system/manifest/validation.ts
|
|
966
1129
|
const compiledManifestContentContract = Symbol("compiledManifestContentContract");
|
|
967
1130
|
/**
|
|
@@ -985,6 +1148,7 @@ function compileManifestContentContract(manifestOrFields, options = {}) {
|
|
|
985
1148
|
return Object.freeze({ [compiledManifestContentContract]: Object.freeze({
|
|
986
1149
|
plans,
|
|
987
1150
|
strictStoredSchema,
|
|
1151
|
+
renderSourceSchema: deriveStrictContentZodFromPlans(plans, "render-source"),
|
|
988
1152
|
writeSchema: deriveNormalizedContentZodFromPlans(plans, strictOptions, normalizeManifestContentForWrite).superRefine((value, ctx) => {
|
|
989
1153
|
if (options.unknownFields !== "reject") return;
|
|
990
1154
|
unknownManifestFieldPaths(plans, value).forEach((path) => {
|
|
@@ -1000,6 +1164,11 @@ function compileManifestContentContract(manifestOrFields, options = {}) {
|
|
|
1000
1164
|
allowIncomplete: true,
|
|
1001
1165
|
mode: "draft"
|
|
1002
1166
|
}, normalizeStoredContentValues),
|
|
1167
|
+
renderDraftSchema: deriveNormalizedContentZodFromPlans(plans, {
|
|
1168
|
+
allowNull: true,
|
|
1169
|
+
allowIncomplete: true,
|
|
1170
|
+
mode: "draft"
|
|
1171
|
+
}, normalizeStoredContentValues, false),
|
|
1003
1172
|
renderSchema: deriveStrictContentZodFromPlans(plans, "render"),
|
|
1004
1173
|
findNonPortableMediaPaths: (content) => findNonPortableMediaPaths(plans, content)
|
|
1005
1174
|
}) });
|
|
@@ -1042,29 +1211,48 @@ function validateManifestDraft(contract, data) {
|
|
|
1042
1211
|
* grants a stored proof, so hydrated media cannot flow back to persistence.
|
|
1043
1212
|
*/
|
|
1044
1213
|
function admitTransportedRenderableManifestContent(contract, content) {
|
|
1045
|
-
const
|
|
1214
|
+
const state = contract[compiledManifestContentContract];
|
|
1215
|
+
const projected = projectLayoutGridPlansForRendering(state.plans, content);
|
|
1216
|
+
const parsed = state.renderSchema.safeParse(projected);
|
|
1046
1217
|
return parsed.success ? {
|
|
1047
1218
|
ok: true,
|
|
1048
|
-
value:
|
|
1219
|
+
value: projected
|
|
1049
1220
|
} : {
|
|
1050
1221
|
ok: false,
|
|
1051
1222
|
error: zodAdmissionError(parsed.error)
|
|
1052
1223
|
};
|
|
1053
1224
|
}
|
|
1054
|
-
function deriveNormalizedContentZodFromPlans(plans, options, normalize) {
|
|
1225
|
+
function deriveNormalizedContentZodFromPlans(plans, options, normalize, validateLayoutGrids = true) {
|
|
1055
1226
|
const isDraft = options.mode === "draft";
|
|
1056
|
-
const baseSchema = deriveContentZodFromPlans(plans, options);
|
|
1227
|
+
const baseSchema = deriveContentZodFromPlans(plans, options, validateLayoutGrids);
|
|
1057
1228
|
if (isDraft) return z.preprocess((content) => preprocessEmptyValues(normalize(plans, content, options)), baseSchema);
|
|
1058
1229
|
return z.preprocess((content) => normalize(plans, content, options), baseSchema);
|
|
1059
1230
|
}
|
|
1060
|
-
function deriveContentZodFromPlans(plans, options) {
|
|
1061
|
-
const shape =
|
|
1062
|
-
|
|
1063
|
-
|
|
1231
|
+
function deriveContentZodFromPlans(plans, options, validateLayoutGrids = true) {
|
|
1232
|
+
const shape = Object.fromEntries(plans.map((plan) => [plan.fieldId, fieldPlanToObjectPropertyZod(plan, options, validateLayoutGrids ? "validate" : "projected")]));
|
|
1233
|
+
return z.object(shape).catchall(z.unknown()).passthrough().superRefine((values, ctx) => {
|
|
1234
|
+
if (!validateLayoutGrids) return;
|
|
1235
|
+
validateLayoutGridPlans(plans, values).forEach((issue) => {
|
|
1236
|
+
ctx.addIssue({
|
|
1237
|
+
code: "custom",
|
|
1238
|
+
path: [...issue.path],
|
|
1239
|
+
message: issue.message
|
|
1240
|
+
});
|
|
1241
|
+
});
|
|
1242
|
+
});
|
|
1064
1243
|
}
|
|
1065
1244
|
function deriveStrictContentZodFromPlans(plans, mode = "strict") {
|
|
1066
|
-
const shape = Object.fromEntries(plans.map((plan) => [plan.fieldId, fieldPlanToStrictObjectPropertyZod(plan, mode)]));
|
|
1067
|
-
return z.object(shape).catchall(z.unknown()).passthrough()
|
|
1245
|
+
const shape = Object.fromEntries(plans.map((plan) => [plan.fieldId, fieldPlanToStrictObjectPropertyZod(plan, mode === "render" ? "render" : "strict", mode === "strict" ? "validate" : "projected")]));
|
|
1246
|
+
return z.object(shape).catchall(z.unknown()).passthrough().superRefine((values, ctx) => {
|
|
1247
|
+
if (mode !== "strict") return;
|
|
1248
|
+
validateLayoutGridPlans(plans, values).forEach((issue) => {
|
|
1249
|
+
ctx.addIssue({
|
|
1250
|
+
code: "custom",
|
|
1251
|
+
path: [...issue.path],
|
|
1252
|
+
message: issue.message
|
|
1253
|
+
});
|
|
1254
|
+
});
|
|
1255
|
+
});
|
|
1068
1256
|
}
|
|
1069
1257
|
function derivePlansFromManifestOrFields(manifestOrFields) {
|
|
1070
1258
|
return deriveFieldValidationPlans(Array.isArray(manifestOrFields) ? manifestOrFields : manifestOrFields.fields ?? []);
|
|
@@ -1174,6 +1362,7 @@ function buildSiteRenderSupport(site, mediaAssets) {
|
|
|
1174
1362
|
site: site.site,
|
|
1175
1363
|
sdkConfig: site.sdkConfig ?? null,
|
|
1176
1364
|
bookingOfferingPresets: site.bookingOfferingPresets ?? [],
|
|
1365
|
+
openingHours: site.businessDetails?.openingHours ?? null,
|
|
1177
1366
|
siteTerms: site.siteTerms,
|
|
1178
1367
|
mailingList: site.mailingList,
|
|
1179
1368
|
bookingTimeZone: resolveBookingBusinessTimeZone(site.bookingTimeZone),
|
|
@@ -1348,4 +1537,4 @@ function requireSdkTheme(theme, siteId, reason = "cms_theme_absent") {
|
|
|
1348
1537
|
return theme;
|
|
1349
1538
|
}
|
|
1350
1539
|
//#endregion
|
|
1351
|
-
export {
|
|
1540
|
+
export { admitLayoutGridForPlan as _, buildSiteRenderSupport as a, projectRenderablePageOutline as c, resolveSdkBlockManifest as d, sanitizeSdkRuntimeBlockContent as f, validateManifestDraft as g, compileManifestContentContract as h, buildRenderablePageOutline as i, readInvalidBlockAdmission as l, admitTransportedRenderableManifestContent as m, MissingSdkThemeError as n, collectMediaAssetSidecar as o, resolveSiteCustomBlocks as p, requireSdkTheme as r, invalidRenderableBlock as s, MISSING_SDK_THEME_ERROR_CODE as t, readSdkPreviewPublishedPlacement as u, deriveFieldValidationPlan as v, readPublishedBlockPlacement as y };
|