@fayz-ai/storefront 0.84.3 → 0.85.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/CheckoutPage-4MFKLBEI.js +12 -0
- package/dist/{CheckoutPage-G5NYJF3Z.js.map → CheckoutPage-4MFKLBEI.js.map} +1 -1
- package/dist/MyPurchasesPage-F25MIFXT.js +11 -0
- package/dist/{MyPurchasesPage-GOK2RO7K.js.map → MyPurchasesPage-F25MIFXT.js.map} +1 -1
- package/dist/OrderConfirmationPage-SOQDD767.js +10 -0
- package/dist/{OrderConfirmationPage-DGLW5W75.js.map → OrderConfirmationPage-SOQDD767.js.map} +1 -1
- package/dist/{chunk-P4RRFQQX.js → chunk-BR3XHNVM.js} +5 -5
- package/dist/{chunk-P4RRFQQX.js.map → chunk-BR3XHNVM.js.map} +1 -1
- package/dist/{chunk-RZWTEC6H.js → chunk-C4XATNI2.js} +3 -3
- package/dist/{chunk-RZWTEC6H.js.map → chunk-C4XATNI2.js.map} +1 -1
- package/dist/{chunk-45R7CIEA.js → chunk-CE4U65TZ.js} +4 -4
- package/dist/{chunk-45R7CIEA.js.map → chunk-CE4U65TZ.js.map} +1 -1
- package/dist/{chunk-2D5BEM43.js → chunk-EFHQ5MAJ.js} +3 -3
- package/dist/{chunk-2D5BEM43.js.map → chunk-EFHQ5MAJ.js.map} +1 -1
- package/dist/{chunk-UJ2TIM4V.js → chunk-ELW7QWDJ.js} +13 -12
- package/dist/chunk-ELW7QWDJ.js.map +1 -0
- package/dist/{chunk-F3U4KZC7.js → chunk-IUP5SDTX.js} +5 -5
- package/dist/{chunk-F3U4KZC7.js.map → chunk-IUP5SDTX.js.map} +1 -1
- package/dist/{chunk-ZSNKJGE5.js → chunk-NS6UPIJ3.js} +3 -3
- package/dist/{chunk-ZSNKJGE5.js.map → chunk-NS6UPIJ3.js.map} +1 -1
- package/dist/{chunk-FPFGRUCS.js → chunk-OOQRYH3N.js} +6 -6
- package/dist/{chunk-FPFGRUCS.js.map → chunk-OOQRYH3N.js.map} +1 -1
- package/dist/{chunk-GVZ2SAOI.js → chunk-PSDR5TZD.js} +3 -2
- package/dist/chunk-PSDR5TZD.js.map +1 -0
- package/dist/{chunk-PURHMU2W.js → chunk-RJUEUMR6.js} +4 -4
- package/dist/{chunk-PURHMU2W.js.map → chunk-RJUEUMR6.js.map} +1 -1
- package/dist/{chunk-BKO2AQ3Q.js → chunk-SLJ4BRXD.js} +3 -3
- package/dist/{chunk-BKO2AQ3Q.js.map → chunk-SLJ4BRXD.js.map} +1 -1
- package/dist/{chunk-YSQBZ3RM.js → chunk-YCAWAON6.js} +7 -7
- package/dist/{chunk-YSQBZ3RM.js.map → chunk-YCAWAON6.js.map} +1 -1
- package/dist/{chunk-554XAQWK.js → chunk-YDZU2SZL.js} +4 -4
- package/dist/{chunk-554XAQWK.js.map → chunk-YDZU2SZL.js.map} +1 -1
- package/dist/{chunk-WSHCQ3Y6.js → chunk-Z5JT7T4I.js} +8 -8
- package/dist/{chunk-WSHCQ3Y6.js.map → chunk-Z5JT7T4I.js.map} +1 -1
- package/dist/components/delivery/StoreCover.d.ts.map +1 -1
- package/dist/document/config.d.ts +8 -0
- package/dist/document/config.d.ts.map +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.d.ts.map +1 -1
- package/dist/edge.js +19 -2
- package/dist/edge.js.map +1 -1
- package/dist/host/edge-handler.d.ts +26 -0
- package/dist/host/edge-handler.d.ts.map +1 -1
- package/dist/host.js +4 -4
- package/dist/index.js +22 -22
- package/dist/render.js +9 -9
- package/dist/tanstack.js +8 -8
- package/package.json +1 -1
- package/dist/CheckoutPage-G5NYJF3Z.js +0 -12
- package/dist/MyPurchasesPage-GOK2RO7K.js +0 -11
- package/dist/OrderConfirmationPage-DGLW5W75.js +0 -10
- package/dist/chunk-GVZ2SAOI.js.map +0 -1
- package/dist/chunk-UJ2TIM4V.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/document/sections.ts","../src/extend/component-contracts.ts","../src/document/validate.ts","../src/document/round-trip.ts"],"names":[],"mappings":";;;;;;;AAuCO,IAAM,mBAAA,GAAsB;AAM5B,IAAM,oBAAA,GAAuB,CAAC,UAAA,EAAY,SAAA,EAAW,WAAW,UAAU;AAS1E,IAAM,mBAAA,GAAsB,CAAC,MAAA,EAAQ,iBAAA,EAAmB,SAAS;AAIjE,IAAM,0BAAA,GAA6B;AAAA,EACxC,KAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAMO,IAAM,uBAAA,GAA0B,CAAC,MAAA,EAAQ,UAAA,EAAY,aAAa,QAAQ;AAK1E,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF;AAKO,IAAM,mBAAA,GAAsB,CAAC,SAAA,EAAW,SAAA,EAAW,SAAS;AAK5D,IAAM,iBAAA,GAAoB,CAAC,MAAA,EAAQ,MAAA,EAAQ,SAAS,MAAM,CAAA;AAuLjE,IAAM,CAAA,GAAI,CACR,IAAA,EACA,WAAA,EACA,KAAA,GAAiC,EAAC,MACd,EAAE,IAAA,EAAM,WAAA,EAAa,GAAG,KAAA,EAAM,CAAA;AAE7C,IAAM,cAAA,GAA6D;AAAA,EACxE,KAAA,EAAO;AAAA,IACL,WAAA,EAAa,yCAAA;AAAA,IACb,QAAA,EAAU,CAAC,CAAC,CAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,MACN,MAAM,CAAA,CAAE,QAAA,EAAU,4CAA4C,EAAE,QAAA,EAAU,MAAM,CAAA;AAAA,MAChF,QAAA,EAAU,CAAA,CAAE,QAAA,EAAU,8CAAyC,CAAA;AAAA,MAC/D,MAAA,EAAQ,CAAA,CAAE,QAAA,EAAU,+DAA0D;AAAA;AAChF,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,IAAA,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,YAAA,CAAa,MAAM,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,MAAA;AACT","file":"chunk-P4RRFQQX.js","sourcesContent":["import type { EntityDeclarationInput, JsonSchema } from '@fayz-ai/core'\nimport type { PaymentMethodKind } from '@fayz-ai/shop/types'\nimport type { MockShopSeed } from '@fayz-ai/shop/mock'\nimport type { Promotion } from '@fayz-ai/shop/rules'\nimport type {\n StorefrontCommerceMode,\n StorefrontConfig,\n StorefrontDiscountConfig,\n StorefrontEnquiryConfig,\n StorefrontImageLoadingConfig,\n StorefrontRouteChrome,\n StorefrontRouteKind,\n StorefrontSearchConfig,\n} from './config'\nimport type { StorefrontTheme } from '../lib/theme'\nimport type { HomeConfig, NavLink, FooterConfig } from '../blocks/sections'\nimport type { StorefrontPagesConfig } from '../blocks/page-blocks'\nimport type { StorefrontSlots } from '../extend/slots'\nimport type { StorefrontAuthConfig } from '../data/auth'\n\n// ---------------------------------------------------------------------------\n// Store Document v1 — the section vocabulary.\n//\n// `fayz.store.json` is the serializable form of a whole storefront: every\n// StorefrontConfig field either lives in a section here as data, or is\n// referenced from the `code` section by a registered handle name. The document\n// plus the handle registry reconstitutes the store; nothing is restored from\n// an in-memory side channel.\n//\n// Per-SECTION schema version, following WooCommerce Blueprint's\n// `get_schema(int $version)` (packages/php/blueprint/src/Steps/Step.php:24-36):\n// each top-level section carries its own `version`, so the commerce section\n// can evolve without invalidating a stored theme section and vice versa. A\n// version this module does not know is a hard error naming the supported set.\n//\n// This is a LEAF module: types, field specs and enum vocabularies only, so the\n// exporter, the validator and the describer can all import it without cycles.\n// ---------------------------------------------------------------------------\n\nexport const STORE_DOCUMENT_KIND = 'fayz.store'\n\n// --- Enum vocabularies, as runtime values -------------------------------------\n// Each mirrors a type union elsewhere; the `satisfies` + exhaustiveness pair\n// makes it a compile error for the two to drift.\n\nexport const STORE_COMMERCE_MODES = ['checkout', 'catalog', 'enquiry', 'delivery'] as const satisfies readonly StorefrontCommerceMode[]\ntype MissingCommerceMode = Exclude<StorefrontCommerceMode, (typeof STORE_COMMERCE_MODES)[number]>\nconst _commerceModesExhaustive: [MissingCommerceMode] extends [never] ? true : never = true\nvoid _commerceModesExhaustive\n\n// Same exhaustiveness guard as the commerce modes above: this list is what the\n// document validator accepts, and it had already drifted once — a mode the type\n// allows but this array omits is rejected at load with no useful message.\ntype StorePaymentMode = NonNullable<NonNullable<StorefrontConfig['payments']>['mode']>\nexport const STORE_PAYMENT_MODES = ['mock', 'pix-mercadopago', 'gateway'] as const satisfies readonly StorePaymentMode[]\ntype MissingPaymentMode = Exclude<StorePaymentMode, (typeof STORE_PAYMENT_MODES)[number]>\nconst _paymentModesExhaustive: [MissingPaymentMode] extends [never] ? true : never = true\nvoid _paymentModesExhaustive\nexport const STORE_PAYMENT_METHOD_KINDS = [\n 'pix',\n 'credit_card',\n 'debit_card',\n 'boleto',\n 'cash',\n 'other',\n] as const satisfies readonly PaymentMethodKind[]\ntype MissingPaymentKind = Exclude<PaymentMethodKind, (typeof STORE_PAYMENT_METHOD_KINDS)[number]>\nconst _paymentKindsExhaustive: [MissingPaymentKind] extends [never] ? true : never = true\nvoid _paymentKindsExhaustive\n\ntype ConfiguredBackendProvider = NonNullable<NonNullable<StorefrontConfig['backend']>['provider']>\nexport const STORE_BACKEND_PROVIDERS = ['mock', 'fayz-api', 'fayz-shop', 'custom'] as const satisfies readonly ConfiguredBackendProvider[]\ntype MissingBackendProvider = Exclude<ConfiguredBackendProvider, (typeof STORE_BACKEND_PROVIDERS)[number]>\nconst _backendProvidersExhaustive: [MissingBackendProvider] extends [never] ? true : never = true\nvoid _backendProvidersExhaustive\n\nexport const STORE_ROUTE_KINDS = [\n 'home',\n 'catalog',\n 'product',\n 'checkout',\n 'account',\n 'order',\n 'custom',\n] as const satisfies readonly StorefrontRouteKind[]\ntype MissingRouteKind = Exclude<StorefrontRouteKind, (typeof STORE_ROUTE_KINDS)[number]>\nconst _routeKindsExhaustive: [MissingRouteKind] extends [never] ? true : never = true\nvoid _routeKindsExhaustive\n\nexport const STORE_ROUTE_CHROMES = ['default', 'minimal', 'focused'] as const satisfies readonly StorefrontRouteChrome[]\ntype MissingRouteChrome = Exclude<StorefrontRouteChrome, (typeof STORE_ROUTE_CHROMES)[number]>\nconst _routeChromesExhaustive: [MissingRouteChrome] extends [never] ? true : never = true\nvoid _routeChromesExhaustive\n\nexport const STORE_THEME_RADII = ['none', 'soft', 'round', 'pill'] as const\n\n// --- Section shapes -----------------------------------------------------------\n\ninterface StoreSectionBase {\n /** This section's own schema version — sections evolve independently. */\n version: number\n}\n\n/** Identity: who the store is. The only mandatory section. */\nexport interface StoreIdentitySection extends StoreSectionBase {\n name: string\n /** ISO 4217 — default 'BRL'. */\n currency?: string\n /** Intl locale — default 'pt-BR'. */\n locale?: string\n}\n\n/** Visual identity — StorefrontTheme, spread into the section. */\nexport interface StoreThemeSection extends StoreSectionBase, StorefrontTheme {}\n\n/** Commercial behavior: mode, money, offers. */\nexport interface StoreCommerceSection extends StoreSectionBase {\n commerceMode?: StorefrontCommerceMode\n shipping?: StorefrontConfig['shipping']\n payments?: StorefrontConfig['payments']\n discounts?: StorefrontDiscountConfig[]\n enquiry?: StorefrontEnquiryConfig\n features?: StorefrontConfig['features']\n}\n\n/** What the shopper sees: composed pages, slots, chrome. `footer` here holds\n * only the serializable part — a non-string `credit` node moves to\n * `code.footerCredit`. */\nexport interface StorePresentationSection extends StoreSectionBase {\n announcement?: string\n /** Text logo. A JSX logo is code — it lives at `code.logo`. */\n logo?: string\n home?: HomeConfig\n pages?: StorefrontPagesConfig\n slots?: StorefrontSlots\n nav?: NavLink[]\n footer?: FooterConfig\n imageLoading?: StorefrontImageLoadingConfig\n catalogFacets?: StorefrontConfig['catalogFacets']\n productSpecs?: StorefrontConfig['productSpecs']\n /** Header search knobs. `renderSuggestion` is code — it lives at\n * `code.searchRenderSuggestion`. */\n search?: Omit<StorefrontSearchConfig, 'renderSuggestion'>\n}\n\n/** Long-form content: legal/institutional pages and store-supplied reviews. */\nexport interface StoreContentSection extends StoreSectionBase {\n legal?: StorefrontConfig['legal']\n reviews?: StorefrontConfig['reviews']\n}\n\n/** The mock catalog seed (products/categories/discounts). */\nexport interface StoreCatalogSection extends StoreSectionBase, MockShopSeed {}\n\n/** Rule-engine promotions (spine M6): serializable Promotion values —\n * eligibility rules + application method, attributes drawn from the\n * rule_attribute vocabulary. \"Buy 3 pay 2\" and \"REVENDA10 = 10% off\" are\n * both entries here, as pure data. */\nexport interface StorePromotionsSection extends StoreSectionBase {\n promotions?: Promotion[]\n}\n\n/** Custom entity declarations (spine M4): the defineEntity inputs, keyed by\n * entity key. Pure data — hydration re-declares them through defineEntity,\n * which re-derives the schema, storage, RLS and loaders from the same input. */\nexport interface StoreEntitiesSection extends StoreSectionBase {\n definitions?: Record<string, EntityDeclarationInput>\n}\n\n/** Backend descriptor. The deprecated supabase fields ride along so a legacy\n * config still round-trips losslessly; new stores use `auth.supabase`. */\nexport interface StoreBackendSection extends StoreSectionBase {\n provider?: ConfiguredBackendProvider\n url?: string\n /** @deprecated legacy StorefrontConfig field, kept for lossless round-trip. */\n supabaseUrl?: string\n /** @deprecated legacy StorefrontConfig field, kept for lossless round-trip. */\n supabaseAnonKey?: string\n}\n\n/** Customer auth, when it is expressible as data ('mock' / 'supabase' + urls).\n * An auth config carrying code (an AuthAdapter object, a supabase client)\n * moves whole to `code.auth`. */\nexport interface StoreAuthSection extends StoreSectionBase, StorefrontAuthConfig {}\n\n/** A custom route whose component is referenced by handle name. */\nexport interface StoreCodeRouteRef {\n id: string\n path: string\n kind?: StorefrontRouteKind\n chrome?: StorefrontRouteChrome\n /** Handle name of the route component. */\n component: string\n}\n\n/**\n * The code sidecar: every config field that holds code, referenced by the\n * handle NAME it was registered under. Hydration resolves these through the\n * handle registry — an unknown name is a hard error naming the valid set (I2),\n * never a silent drop.\n */\nexport interface StoreCodeSection extends StoreSectionBase {\n /** Handle → React.ReactNode (JSX logo). */\n logo?: string\n /** Handle → ShopProvider. */\n provider?: string\n /** Handle → StorefrontAuthConfig carrying code. */\n auth?: string\n /** Handle → React.ReactNode rendered as the footer credit line. */\n footerCredit?: string\n /** Handle → the `(product) => ReactNode` renderer for a search suggestion. */\n searchRenderSuggestion?: string\n /** Component-slot name → handle of its ComponentOverride. */\n components?: Record<string, string>\n routes?: StoreCodeRouteRef[]\n}\n\n/** Store Document v1 — the serializable form of a whole storefront. */\nexport interface StoreDocument {\n $kind: typeof STORE_DOCUMENT_KIND\n store: StoreIdentitySection\n theme?: StoreThemeSection\n commerce?: StoreCommerceSection\n presentation?: StorePresentationSection\n content?: StoreContentSection\n catalog?: StoreCatalogSection\n entities?: StoreEntitiesSection\n promotions?: StorePromotionsSection\n backend?: StoreBackendSection\n auth?: StoreAuthSection\n code?: StoreCodeSection\n}\n\nexport type StoreSectionName = Exclude<keyof StoreDocument, '$kind'>\n\n// --- Field specs: one declaration → validator + JSON Schema -------------------\n// Same pattern as block `settings` → `propsSchema` (block-schema.ts): the spec\n// is authored once and compiled, so the validator and the schema an agent reads\n// cannot drift apart. Coarse on purpose — deep shapes (theme colors, block\n// trees) are checked by the dedicated validators, not restated here.\n\n/**\n * A field that is on its way out (spine I10).\n *\n * The section VERSION is what makes this mechanical rather than advisory:\n * while the section is at a version below `removedAtVersion` the field is\n * accepted and the store keeps working; a document that has been through the\n * codemod carries the higher version, and at that version the field is a hard\n * validation error naming `replacement` (I2). That is what lets one SDK serve\n * both a migrated and an unmigrated fleet without a flag.\n */\nexport interface StoreFieldDeprecation {\n /** Row id in @fayz-ai/sdk's deprecation registry — the single source of the\n * version window, the shim prose and the codemod id. */\n id: string\n /** Section version at which this field stops being accepted. */\n removedAtVersion: number\n /** Document path to write instead. */\n replacement: string\n}\n\nexport interface StoreFieldSpec {\n type: 'string' | 'number' | 'boolean' | 'object' | 'array'\n description: string\n required?: boolean\n enum?: readonly string[]\n /** Present when the field is deprecated. See {@link StoreFieldDeprecation}. */\n deprecated?: StoreFieldDeprecation\n}\n\nexport interface StoreSectionSpec {\n description: string\n /** Versions of this section this SDK understands, ascending. */\n versions: readonly number[]\n fields: Record<string, StoreFieldSpec>\n}\n\nconst f = (\n type: StoreFieldSpec['type'],\n description: string,\n extra: Partial<StoreFieldSpec> = {},\n): StoreFieldSpec => ({ type, description, ...extra })\n\nexport const STORE_SECTIONS: Record<StoreSectionName, StoreSectionSpec> = {\n store: {\n description: 'Store identity: name, currency, locale.',\n versions: [1],\n fields: {\n name: f('string', 'Store display name (header, page title).', { required: true }),\n currency: f('string', \"ISO 4217 currency code — default 'BRL'.\"),\n locale: f('string', \"Intl locale for money/date formatting — default 'pt-BR'.\"),\n },\n },\n theme: {\n description: 'Visual identity: colors, fonts, radius, header/card personality.',\n versions: [1],\n fields: {\n name: f('string', 'Theme name.', { required: true }),\n colors: f('object', 'HSL token triplets (background, primary, …).'),\n font: f('object', 'Google Fonts pairing (heading, body, display, serif).'),\n radius: f('string', 'Corner radius scale.', { enum: STORE_THEME_RADII }),\n header: f('object', 'Header treatment (variant, uppercaseNav, search).'),\n productCard: f('object', 'Card style and image aspect.'),\n uppercaseButtons: f('boolean', 'Uppercase CTA buttons with letter-spacing.'),\n spacing: f('object', \"Spacing scale (key → CSS length), emitted as --sf-space-<key>. e.g. {sm:'8px', md:'16px'}.\"),\n typeScale: f('object', \"Type scale (key → CSS font-size), emitted as --sf-text-<key>. e.g. {body:'1rem', h1:'clamp(40px,6vw,66px)'}.\"),\n breakpoints: f('object', \"Layout breakpoints (key → CSS length), emitted as --sf-breakpoint-<key> for JS/generated-style consumers.\"),\n motion: f('object', \"Motion tokens (key → duration or easing), emitted as --sf-motion-<key>. e.g. {fast:'150ms', reveal:'cubic-bezier(0.22,1,0.36,1)'}.\"),\n tokens: f('object', 'Free-form brand-token passthrough, emitted verbatim as CSS custom properties.'),\n },\n },\n commerce: {\n description: 'Commercial behavior: mode, shipping, payments, discounts, enquiry, feature toggles.',\n // v2 = the legacy `discounts` coupon list has been migrated onto the rule\n // engine (codemod commerce.discounts-to-promotions). Both versions are\n // understood, which is the whole point: the fleet migrates store by store.\n versions: [1, 2],\n fields: {\n commerceMode: f('string', 'Checkout-first, catalog-only browsing, or product enquiry.', {\n enum: STORE_COMMERCE_MODES,\n }),\n shipping: f('object', 'Flat rate and free-above threshold.'),\n payments: f('object', 'Payment mode and offered methods.'),\n discounts: f('array', 'DEPRECATED — store-level discount codes ({code, percent, title?}). Use promotions.promotions.', {\n deprecated: {\n id: 'storefront.commerce.discounts',\n removedAtVersion: 2,\n replacement: 'promotions.promotions',\n },\n }),\n enquiry: f('object', 'Product enquiry behavior for catalog/enquiry stores.'),\n features: f('object', 'Feature toggles (discounts, accounts, cart, checkout).'),\n },\n },\n presentation: {\n description: 'What the shopper sees: composed pages, slots, nav, footer, chrome.',\n versions: [1],\n fields: {\n announcement: f('string', 'Promo message above the header.'),\n logo: f('string', 'Text logo. A JSX logo is code and lives at code.logo.'),\n home: f('object', 'Home page blueprint (legacy short form of pages.home).'),\n pages: f('object', 'Pages composed from blocks, keyed by page kind.'),\n slots: f('object', 'Blocks grafted into named positions inside SDK pages.'),\n nav: f('array', 'Header nav links ({label, to}).'),\n footer: f('object', 'Footer content (about, contact, social, labels).'),\n imageLoading: f('object', 'Global image reveal behavior.'),\n catalogFacets: f(\n 'array',\n 'Catalog refinements over product.metadata ({key, label, values[]}), rendered in the filters panel and mirrored into ?<key>=<value>.',\n ),\n productSpecs: f(\n 'object',\n 'PDP specification table rules: `exclude` hides metadata keys, `labels` renames the rest.',\n ),\n search: f(\n 'object',\n \"Header search: mode ('inline' live filter, the default, or 'overlay'), plus placeholder, resultsPath, suggestionsLimit, minChars and labels. A custom suggestion renderer is code and lives at code.searchRenderSuggestion.\",\n ),\n },\n },\n content: {\n description: 'Long-form content: legal/institutional pages, product reviews.',\n versions: [1],\n fields: {\n legal: f('object', 'Privacy / terms / returns page text.'),\n reviews: f(\n 'object',\n 'Store-supplied product reviews ({items, enabled, emptyText}). Nothing is invented — with no items the PDP renders an honest empty state.',\n ),\n },\n },\n catalog: {\n description: 'Mock catalog seed for stores without a live backend.',\n versions: [1],\n fields: {\n products: f('array', 'Seed products.'),\n categories: f('array', 'Seed categories.'),\n discounts: f('array', 'Seed discounts.'),\n promotions: f('array', 'Seed rule-engine promotions for the mock provider. Prefer the top-level promotions section.'),\n },\n },\n entities: {\n description: 'Custom entity declarations (defineEntity inputs), keyed by entity key.',\n versions: [1],\n fields: {\n definitions: f('object', 'Entity key → declaration ({fields, scope, access, indexes, …}).'),\n },\n },\n promotions: {\n description: 'Rule-engine promotions: eligibility rules + application method, as pure data (spine M6).',\n versions: [1],\n fields: {\n promotions: f('array', 'Promotions ({id, code?, isAutomatic?, rules?, applicationMethod}). Rule attributes come from the rule_attribute vocabulary.'),\n },\n },\n backend: {\n description: 'Backend descriptor: which provider serves the store.',\n // v2 = the legacy supabaseUrl/supabaseAnonKey pair has moved to\n // auth.supabase (codemod backend.supabase-to-auth).\n versions: [1, 2],\n fields: {\n provider: f('string', 'Backend provider family.', { enum: STORE_BACKEND_PROVIDERS }),\n url: f('string', 'Backend URL, when the provider needs one.'),\n supabaseUrl: f('string', 'DEPRECATED legacy field, kept for lossless round-trip. Use auth.supabase.url.', {\n deprecated: {\n id: 'storefront.backend.supabaseUrl',\n removedAtVersion: 2,\n replacement: 'auth.supabase.url',\n },\n }),\n supabaseAnonKey: f('string', 'DEPRECATED legacy field, kept for lossless round-trip. Use auth.supabase.anonKey.', {\n deprecated: {\n id: 'storefront.backend.supabaseAnonKey',\n removedAtVersion: 2,\n replacement: 'auth.supabase.anonKey',\n },\n }),\n },\n },\n auth: {\n description: 'Customer auth, when expressible as data. Code-bearing auth lives at code.auth.',\n versions: [1],\n fields: {\n adapter: f('string', \"Adapter id ('mock' | 'supabase').\"),\n provider: f('string', \"Provider id ('mock' | 'supabase').\"),\n routes: f('object', 'Auth route overrides.'),\n supabase: f('object', 'Supabase connection (url, anonKey, callback urls).'),\n },\n },\n code: {\n description: 'The code sidecar: config fields that hold code, referenced by registered handle name.',\n versions: [1],\n fields: {\n logo: f('string', 'Handle of the JSX logo node.'),\n provider: f('string', 'Handle of the explicit ShopProvider.'),\n auth: f('string', 'Handle of a code-bearing auth config.'),\n footerCredit: f('string', 'Handle of the footer credit node.'),\n searchRenderSuggestion: f('string', 'Handle of the custom search-suggestion renderer.'),\n components: f('object', 'Component-slot name → handle of its override.'),\n routes: f('array', 'Custom routes; each component is a handle name.'),\n },\n },\n}\n\nexport const STORE_SECTION_NAMES = Object.keys(STORE_SECTIONS) as StoreSectionName[]\n\n/** Compile a section's field spec to JSON Schema — the same one-declaration\n * principle as `settingsToJsonSchema` (I1). */\nexport function sectionToJsonSchema(name: StoreSectionName): JsonSchema {\n const spec = STORE_SECTIONS[name]\n const properties: Record<string, JsonSchema> = {\n version: {\n type: 'integer',\n description: `Schema version of the ${name} section. Supported: ${spec.versions.join(', ')}.`,\n enum: [...spec.versions],\n },\n }\n const required: string[] = ['version']\n for (const [field, fieldSpec] of Object.entries(spec.fields)) {\n const node: JsonSchema = { type: fieldSpec.type, description: fieldSpec.description }\n if (fieldSpec.enum) node.enum = [...fieldSpec.enum]\n if (fieldSpec.deprecated) {\n // `deprecated` is the JSON Schema 2019-09 keyword, so generic tooling\n // understands it; the x- pair carries the registry id and the exact\n // replacement path, which is what an agent needs to fix it (I2).\n node.deprecated = true\n node['x-fayz-deprecation'] = fieldSpec.deprecated.id\n node['x-fayz-replacement'] = fieldSpec.deprecated.replacement\n node['x-fayz-removed-at-section-version'] = fieldSpec.deprecated.removedAtVersion\n }\n properties[field] = node\n if (fieldSpec.required) required.push(field)\n }\n return {\n type: 'object',\n description: spec.description,\n properties,\n required,\n }\n}\n\n// --- Shared helpers -----------------------------------------------------------\n\n/**\n * True when a value survives JSON serialization unchanged: the test that\n * routes a config field into a data section versus the code sidecar. React\n * elements (`$$typeof`), functions, class instances (providers, adapters,\n * supabase clients) all fail it.\n */\nexport function isJsonValue(value: unknown): boolean {\n if (value === null) return true\n const t = typeof value\n if (t === 'string' || t === 'number' || t === 'boolean') return true\n if (Array.isArray(value)) return value.every(isJsonValue)\n if (t === 'object') {\n const record = value as Record<string, unknown>\n if ('$$typeof' in record) return false // React element\n const proto = Object.getPrototypeOf(record)\n if (proto !== Object.prototype && proto !== null) return false // class instance\n // `undefined` property values are allowed: JSON drops the key, which is\n // semantically the same config.\n return Object.values(record).every((v) => v === undefined || isJsonValue(v))\n }\n return false\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Copy of `obj` without `undefined`-valued keys, so a document holds exactly\n * what JSON can carry and object equality means what it looks like. */\nexport function compact<T extends Record<string, unknown>>(obj: T): T {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) out[key] = value\n }\n return out as T\n}\n","import type React from 'react'\nimport type { Category, CreateProductEnquiryInput, Product, ProductEnquiry, ProductImage } from '@fayz-ai/shop/types'\nimport type { ProductOptionGroup, ProductOptionSelection } from '../data/product-options'\nimport type { ResolvedStorefrontConfig, StorefrontCommerceMode, StorefrontRouteChrome } from '../document/config'\nimport type { MediaCarouselItem } from '../blocks/sections'\nimport type { CartState } from '../stores/cart.store'\nimport type { ComponentOverride } from './component-override'\n\nexport interface StorefrontComponentBaseProps {\n config: ResolvedStorefrontConfig\n commerceMode: StorefrontCommerceMode\n className?: string\n testId?: string\n}\n\nexport interface StorefrontActions {\n navigateTo: (to: string) => void\n addToCart: (product: Product, quantity?: number, options?: ProductOptionSelection) => void\n openCart: () => void\n closeCart: () => void\n createProductEnquiry: (input: CreateProductEnquiryInput) => Promise<ProductEnquiry>\n}\n\n/**\n * Which photo the CARD shows — the grid-side counterpart of\n * {@link ProductGalleryOrder}.\n *\n * primary the first `is_primary` row, else the first row (the default;\n * byte-identical to what the card has always done)\n * position the lowest `sortOrder`, ties broken by image id\n *\n * `position` exists because `is_primary` is not a unique constraint: artorious\n * carries products with TWO primary rows, which made the card's pick depend on\n * PostgREST's tie order — the same card could show a different photo between\n * two loads. The gallery got `order` in M2; the card had no equivalent and a\n * store fork was the only way to sort by position.\n */\nexport type ProductCardImageOrder = 'primary' | 'position'\n\nexport interface ProductCardProps extends StorefrontComponentBaseProps {\n product: Product\n actions: Pick<StorefrontActions, 'navigateTo' | 'addToCart' | 'openCart'>\n /** Defaults to 'primary' — see {@link ProductCardImageOrder}. */\n imageOrder?: ProductCardImageOrder\n}\n\nexport interface ProductDetailProps extends StorefrontComponentBaseProps {\n product: Product\n primaryImage?: ProductImage\n optionGroups: ProductOptionGroup[]\n selectedOptions: ProductOptionSelection\n setSelectedOptions: React.Dispatch<React.SetStateAction<ProductOptionSelection>>\n quantity: number\n setQuantity: React.Dispatch<React.SetStateAction<number>>\n soldOut: boolean\n lowStock: boolean\n actions: Pick<StorefrontActions, 'addToCart' | 'createProductEnquiry' | 'navigateTo'>\n addToCart: () => void\n openEnquiry: () => void\n}\n\n/**\n * Which photo leads the gallery.\n *\n * primary the merchant's pick: isPrimary first, then sortOrder ascending (default)\n * position sortOrder ascending, ignoring the primary flag\n * newest sortOrder descending — the most recently added photo leads\n *\n * `newest` exists because of a real fork: artorious reimplemented the entire\n * 158-line gallery to change ONLY this rule (its Supabase rows carried two\n * conflicting is_primary flags, so sort_order was the only trustworthy signal).\n * A props-only override (`components.ProductGallery.props.order`) now does it.\n */\nexport type ProductGalleryOrder = 'primary' | 'position' | 'newest'\n\nexport interface ProductGalleryProps extends StorefrontComponentBaseProps {\n product: Product\n images: ProductImage[]\n primaryImage?: ProductImage\n order?: ProductGalleryOrder\n}\n\nexport interface ProductPriceProps extends StorefrontComponentBaseProps {\n product: Product\n value: number\n compareAt?: number | null\n}\n\nexport interface ProductActionsProps extends StorefrontComponentBaseProps {\n product: Product\n quantity: number\n setQuantity: React.Dispatch<React.SetStateAction<number>>\n soldOut: boolean\n actions: Pick<StorefrontActions, 'addToCart' | 'createProductEnquiry' | 'navigateTo'>\n addToCart: () => void\n openEnquiry: () => void\n}\n\nexport interface ProductEnquiryFormContractProps extends StorefrontComponentBaseProps {\n product: Product\n onSuccess?: () => void\n}\n\nexport interface CategoryCardProps extends StorefrontComponentBaseProps {\n category: Category\n actions: Pick<StorefrontActions, 'navigateTo'>\n}\n\nexport interface CollectionSectionProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n products: Product[]\n category?: Category\n children?: React.ReactNode\n}\n\nexport interface HeroSectionContractProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n eyebrow?: string\n image?: string\n cta?: string\n href?: string\n children?: React.ReactNode\n}\n\nexport interface MediaCarouselProps extends StorefrontComponentBaseProps {\n items: MediaCarouselItem[]\n height?: 'medium' | 'tall' | 'screen'\n autoplayMs?: number\n overlay?: 'dark' | 'soft' | 'none'\n}\n\nexport interface ProductSliderProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n eyebrow?: string\n filter?: 'sale' | 'new' | 'all'\n categoryName?: string\n collection?: string\n limit?: number\n cta?: string\n href?: string\n}\n\nexport interface StorefrontChromeProps extends StorefrontComponentBaseProps {\n children?: React.ReactNode\n /**\n * Quanta moldura esta rota pediu. Um cabeçalho customizado que ignore isto\n * continua funcionando como antes — por isso é opcional — mas quem honra\n * `minimal` recolhe a navegação de marketing e deixa marca, busca e carrinho.\n */\n chrome?: StorefrontRouteChrome\n}\n\nexport interface StorefrontStateProps extends StorefrontComponentBaseProps {\n title?: string\n message?: string\n children?: React.ReactNode\n}\n\n/**\n * Extra content rendered inside CartDrawer's footer, right after the\n * \"Finalizar compra\" button — e.g. an alternative checkout path like\n * \"Finalizar via WhatsApp\". Unlike every other entry in\n * StorefrontComponents, this isn't a whole-component replacement:\n * CartDrawer is always the SDK's own, this only adds optional content\n * inside it. Only rendered when the cart has lines (same condition as the\n * checkout button itself).\n */\nexport interface CartDrawerFooterExtraProps extends StorefrontComponentBaseProps {\n cart: CartState\n}\n\n/**\n * Code-level component replacements.\n *\n * Each entry accepts either the component (what stores write today) or\n * `{ component?, props? }`. Passing only `props` keeps the SDK component and\n * forces some of its props — which is what four of five customizing stores\n * actually wanted when they replaced a whole card instead.\n *\n * Every field takes the union rather than only the two surfaces stores have\n * overridden so far: \"why can I pass props to ProductCard but not CategoryCard\"\n * is a worse surface than one extra type.\n */\nexport interface StorefrontComponents {\n ProductCard?: ComponentOverride<ProductCardProps>\n ProductDetail?: ComponentOverride<ProductDetailProps>\n ProductGallery?: ComponentOverride<ProductGalleryProps>\n ProductPrice?: ComponentOverride<ProductPriceProps>\n ProductActions?: ComponentOverride<ProductActionsProps>\n ProductEnquiryForm?: ComponentOverride<ProductEnquiryFormContractProps>\n CategoryCard?: ComponentOverride<CategoryCardProps>\n CollectionSection?: ComponentOverride<CollectionSectionProps>\n HeroSection?: ComponentOverride<HeroSectionContractProps>\n MediaCarousel?: ComponentOverride<MediaCarouselProps>\n ProductSlider?: ComponentOverride<ProductSliderProps>\n Header?: ComponentOverride<StorefrontChromeProps>\n Footer?: ComponentOverride<StorefrontChromeProps>\n Shell?: ComponentOverride<StorefrontChromeProps>\n EmptyState?: ComponentOverride<StorefrontStateProps>\n LoadingState?: ComponentOverride<StorefrontStateProps>\n ErrorState?: ComponentOverride<StorefrontStateProps>\n CartDrawerFooterExtra?: ComponentOverride<CartDrawerFooterExtraProps>\n}\n\n/**\n * The override surface as a runtime value, for validators and catalogs: a\n * store document referencing an unknown component slot must be told the valid\n * set (I2), and a type alone cannot say it at runtime. The `satisfies` +\n * exhaustiveness pair keeps this list impossible to leave stale when a key is\n * added to {@link StorefrontComponents}.\n */\nexport const STOREFRONT_COMPONENT_KEYS = [\n 'ProductCard',\n 'ProductDetail',\n 'ProductGallery',\n 'ProductPrice',\n 'ProductActions',\n 'ProductEnquiryForm',\n 'CategoryCard',\n 'CollectionSection',\n 'HeroSection',\n 'MediaCarousel',\n 'ProductSlider',\n 'Header',\n 'Footer',\n 'Shell',\n 'EmptyState',\n 'LoadingState',\n 'ErrorState',\n 'CartDrawerFooterExtra',\n] as const satisfies readonly (keyof StorefrontComponents)[]\ntype MissingComponentKey = Exclude<keyof StorefrontComponents, (typeof STOREFRONT_COMPONENT_KEYS)[number]>\nconst _componentKeysExhaustive: [MissingComponentKey] extends [never] ? true : never = true\nvoid _componentKeysExhaustive\n","import {\n blockRegistry,\n checkBlockConstraints,\n getBlockMeta,\n listHandles,\n hasHandle,\n loaderRegistry,\n listLoaders,\n isLoaderParamRef,\n isLoaderPropRef,\n ENTITY_FIELD_TYPES,\n RESERVED_ENTITY_FIELDS,\n listEntityDeclarations,\n} from '@fayz-ai/core'\nimport type { BlockSetting } from '@fayz-ai/core'\nimport {\n APPLICATION_METHOD_ALLOCATIONS,\n APPLICATION_METHOD_TARGET_TYPES,\n APPLICATION_METHOD_TYPES,\n PROMOTION_STATUSES,\n PROMOTION_TYPES,\n RULE_OPERATORS,\n hasRuleAttribute,\n listRuleAttributeKeys,\n resolveRuleAttribute,\n} from '@fayz-ai/shop/rules'\nimport { registerStorefrontBlocks } from '../blocks/registry'\nimport { routePathParams, toBlockNodes } from '../blocks/page-blocks'\nimport type { StorefrontBlockLike } from '../blocks/page-blocks'\nimport { THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX } from '../lib/theme'\nimport { STOREFRONT_COMPONENT_KEYS } from '../extend/component-contracts'\nimport { STOREFRONT_SLOTS } from '../extend/slots'\nimport type { StorefrontSlotArea } from '../extend/slots'\nimport {\n STORE_DOCUMENT_KIND,\n STORE_SECTIONS,\n STORE_SECTION_NAMES,\n STORE_PAYMENT_MODES,\n STORE_PAYMENT_METHOD_KINDS,\n STORE_ROUTE_KINDS,\n STORE_ROUTE_CHROMES,\n isRecord,\n} from './sections'\nimport type { StoreSectionName } from './sections'\n\n// ---------------------------------------------------------------------------\n// validateStore — the gate between an authored document and a rendered store.\n//\n// I2 everywhere: an unknown id — section, field, page kind, block type, block\n// setting, slot, handle, component slot — is a hard error that NAMES the valid\n// set. The report is machine-readable on purpose: the AI corrects on `valid`,\n// not on prose. Silent failure is the single most expensive property for\n// AI-generated configuration, because the agent gets no signal to correct on\n// (spine doc §2, the Medusa widget-drop evidence).\n//\n// Errors only, no warnings channel: everything reported here misdescribes the\n// store. Advisory findings (a block placed off its declared surface, a missing\n// page body) stay with `checkPageBlocks`/`auditBlocks`, which already own the\n// warning vocabulary.\n// ---------------------------------------------------------------------------\n\nexport interface StoreValidationError {\n /** Dotted path into the document ('presentation.pages.home.blocks[2].type'). */\n path: string\n /** Stable machine-readable code ('unknown-block', 'unsupported-section-version', …). */\n code: string\n message: string\n /** The valid set, present on every unknown-id error — what the AI corrects on. */\n valid?: string[]\n}\n\nexport interface StoreValidationReport {\n ok: boolean\n errors: StoreValidationError[]\n}\n\nexport const STOREFRONT_PAGE_KINDS = ['home', 'catalog', 'product', 'collection', 'content'] as const\n\nconst STRUCTURAL_BLOCK_KEYS = new Set(['type', 'id', 'props', 'children', 'data'])\n\n/** The whole of a `data` need — what page-data reads, and therefore the whole\n * of what an author may write there. */\nconst DATA_NEED_KEYS = ['loader', 'params']\n\n/** The whole of a `code.routes[]` entry — what hydrateStore reads back. */\nconst CODE_ROUTE_KEYS = ['id', 'path', 'kind', 'chrome', 'component']\n\nconst SLOT_AREAS = [...new Set(STOREFRONT_SLOTS.map((slot) => slot.area))]\n\nfunction slotNamesFor(area: string): string[] {\n return STOREFRONT_SLOTS.filter((slot) => slot.area === area).map((slot) => slot.name)\n}\n\n/** Route params available to each singular page kind's `$param` bindings.\n * Content pages declare their own through their path pattern. */\nconst PAGE_KIND_PARAMS: Record<string, readonly string[]> = {\n home: [],\n catalog: [],\n product: ['slug'],\n collection: ['slug'],\n}\n\n/** Route params a slot AREA's trees may bind: slots render inside a page, so\n * only areas pinned to a param-carrying page see its params. */\nconst SLOT_AREA_PARAMS: Record<string, readonly string[]> = {\n productDetail: ['slug'],\n}\n\ntype Errors = StoreValidationError[]\n\n// The entity vocabulary the CURRENT validateStore call checks `entity`-typed\n// values against: everything registered (the app's defineEntity calls) plus\n// everything the document itself declares — a document is allowed to declare\n// an entity and place a block over it in the same file. Module state is safe\n// because validation is synchronous and reset on entry.\nlet knownEntities: Set<string> = new Set()\n\nfunction checkEntityRef(errors: Errors, path: string, value: unknown): void {\n if (typeof value !== 'string' || !value) return // type errors are reported by the generic leg\n if (!knownEntities.has(value)) {\n push(\n errors,\n path,\n 'unknown-entity',\n `entity \"${value}\" is not declared (defineEntity or the entities section)`,\n [...knownEntities].sort(),\n )\n }\n}\n\nfunction push(errors: Errors, path: string, code: string, message: string, valid?: readonly string[]): void {\n errors.push(valid ? { path, code, message, valid: [...valid] } : { path, code, message })\n}\n\n/** Prop keys of one authored block entry, honouring both authoring forms\n * (nested `{type, props}` and the flat StorefrontSection shape). */\nfunction blockPropKeys(entry: Record<string, unknown>): string[] {\n if ('props' in entry) {\n const props = entry.props\n return isRecord(props) ? Object.keys(props) : []\n }\n return Object.keys(entry).filter((key) => !STRUCTURAL_BLOCK_KEYS.has(key))\n}\n\n/** Who declares the settings a value is being judged against — so one walk can\n * speak the block vocabulary ('block \"seals\" declares no setting …') and the\n * loader vocabulary ('loader \"products.list\" declares no param …') without\n * either growing a second error style. */\ninterface SettingOwner {\n /** Message subject, already quoted: `block \"seals\"`, `loader \"products.list\"`. */\n subject: string\n /** What the owner declares: `setting` / `param`. */\n noun: string\n /** The unknown-key code this owner's top-level check already uses. */\n code: string\n}\n\n/**\n * Prop values against their declared settings, at EVERY depth.\n *\n * A `list` setting declares its item shape in `of`, and an item is just another\n * settings level: an unknown key inside one drops exactly like an unknown key\n * at the top — the block renders without it and nothing tells the author why.\n * That is the silent-drop failure the validator exists to end (I2), so the same\n * error is reported there, naming the valid set of THAT position, all the way\n * down through lists of lists.\n *\n * `labelPrefix` builds the dotted setting position the message names\n * (`items[].tone`), matching how `auditBlocks` already talks about `of:` items.\n * `valuesPath` stays the document path, so the report points at the offending\n * key and not at the declaration.\n */\nfunction validateSettingValues(\n errors: Errors,\n valuesPath: string,\n settings: readonly BlockSetting[],\n values: Record<string, unknown>,\n owner: SettingOwner,\n labelPrefix = '',\n): void {\n for (const setting of settings) {\n const value = values[setting.id]\n if (value === undefined) continue\n const valuePath = `${valuesPath}.${setting.id}`\n const label = `${labelPrefix}${setting.id}`\n if (setting.type === 'entity') {\n checkEntityRef(errors, valuePath, value)\n continue\n }\n // A list with no declared item shape accepts anything — the same rule\n // `settingsToJsonSchema` compiles. Nothing to name, so nothing to reject.\n if (setting.type !== 'list' || !setting.of?.length || !Array.isArray(value)) continue\n const of = setting.of\n const declared = collectSettingIds(of)\n value.forEach((item, index) => {\n // A non-object item is a type error, not an unknown key: prop TYPES are\n // not this validator's leg at any depth, so it stays out of the report.\n if (!isRecord(item)) return\n const itemPath = `${valuePath}[${index}]`\n for (const key of Object.keys(item)) {\n if (!declared.has(key)) {\n push(\n errors,\n `${itemPath}.${key}`,\n owner.code,\n `${owner.subject} declares no ${owner.noun} \"${label}[].${key}\"`,\n [...declared].sort(),\n )\n }\n }\n validateSettingValues(errors, itemPath, of, item, owner, `${label}[].`)\n })\n }\n}\n\n/**\n * A literal loader-param value against its declared setting. Bindings are\n * checked by the caller; this is the \"document-level constant\" leg.\n */\nfunction checkLiteralParam(\n errors: Errors,\n path: string,\n containerPath: string,\n loaderId: string,\n setting: BlockSetting,\n value: unknown,\n): void {\n const expected =\n setting.type === 'number' ? 'number' : setting.type === 'boolean' ? 'boolean' : setting.type === 'list' ? 'array' : 'string'\n const actual = Array.isArray(value) ? 'array' : typeof value\n if (actual !== expected) {\n push(\n errors,\n path,\n 'invalid-value',\n `loader \"${loaderId}\" param \"${setting.id}\" expects ${expected}, got ${actual}`,\n )\n return\n }\n if (setting.type === 'select' && setting.options?.length && typeof value === 'string') {\n const allowed = setting.options.map((option) => option.value)\n if (!allowed.includes(value)) {\n push(errors, path, 'invalid-value', `\"${value}\" is not a valid ${setting.id}`, allowed)\n }\n }\n if (setting.type === 'entity') checkEntityRef(errors, path, value)\n // A list-shaped param has the same nested position a block's list prop does,\n // so it gets the same walk — an unknown key inside a param's items is named\n // rather than dropped.\n if (setting.type === 'list') {\n validateSettingValues(\n errors,\n containerPath,\n [setting],\n { [setting.id]: value },\n { subject: `loader \"${loaderId}\"`, noun: 'param', code: 'unknown-loader-param' },\n )\n }\n}\n\n/**\n * One block entry's `data` declaration (I2 everywhere): the loader must exist,\n * every param must be declared by the loader's schema, every `$param` binding\n * must name a route param the page declares, every `$prop` binding a setting\n * the block declares, and every literal must fit the param's type.\n */\nfunction validateDataNeeds(\n errors: Errors,\n entryPath: string,\n blockType: string,\n value: unknown,\n declaredParams: readonly string[],\n): void {\n if (!isRecord(value)) {\n push(errors, `${entryPath}.data`, 'invalid-value', '`data` maps need names to {loader, params?}')\n return\n }\n const blockSettings = getBlockMeta(blockType)?.settings\n for (const [name, need] of Object.entries(value)) {\n const needPath = `${entryPath}.data.${name}`\n if (!isRecord(need) || typeof need.loader !== 'string' || !need.loader) {\n push(errors, needPath, 'invalid-value', 'a data need is {loader: string, params?: object}')\n continue\n }\n if (!loaderRegistry.has(need.loader)) {\n push(errors, `${needPath}.loader`, 'unknown-loader', `loader \"${need.loader}\" is not registered`, listLoaders())\n continue\n }\n // The need object itself is a CLOSED shape — page-data reads `loader` and\n // `params` and nothing else. A misspelt `parms` therefore drops the whole\n // param set and the block loads everything, which is the same silent drop\n // an unknown key anywhere else in the document is.\n for (const key of Object.keys(need)) {\n if (!DATA_NEED_KEYS.includes(key)) {\n push(errors, `${needPath}.${key}`, 'unknown-field', `a data need has no field \"${key}\"`, DATA_NEED_KEYS)\n }\n }\n if (need.params === undefined) continue\n if (!isRecord(need.params)) {\n push(errors, `${needPath}.params`, 'invalid-value', 'loader params are an object')\n continue\n }\n const loaderSettings = loaderRegistry.getEntry(need.loader)?.meta.settings\n const declaredLoaderParams = loaderSettings ? collectSettingIds(loaderSettings) : null\n for (const [param, paramValue] of Object.entries(need.params)) {\n const paramPath = `${needPath}.params.${param}`\n const setting = loaderSettings?.find((s) => s.id === param)\n if (declaredLoaderParams && !declaredLoaderParams.has(param)) {\n push(\n errors,\n paramPath,\n 'unknown-loader-param',\n `loader \"${need.loader}\" declares no param \"${param}\"`,\n [...declaredLoaderParams].sort(),\n )\n continue\n }\n if (isLoaderParamRef(paramValue)) {\n if (!declaredParams.includes(paramValue.$param)) {\n push(\n errors,\n paramPath,\n 'unbound-route-param',\n declaredParams.length\n ? `$param \"${paramValue.$param}\" is not a route param of this page`\n : `$param \"${paramValue.$param}\" cannot bind — this page declares no route params`,\n declaredParams,\n )\n }\n continue\n }\n if (isLoaderPropRef(paramValue)) {\n const settingIds = blockSettings ? collectSettingIds(blockSettings) : null\n if (settingIds && !settingIds.has(paramValue.$prop)) {\n push(\n errors,\n paramPath,\n 'unknown-prop-binding',\n `$prop \"${paramValue.$prop}\" is not a setting of block \"${blockType}\"`,\n [...settingIds].sort(),\n )\n }\n continue\n }\n if (setting) {\n checkLiteralParam(errors, paramPath, `${needPath}.params`, need.loader, setting, paramValue)\n }\n }\n }\n}\n\nfunction validateBlockList(\n errors: Errors,\n path: string,\n value: unknown,\n declaredParams: readonly string[],\n): void {\n if (!Array.isArray(value)) {\n push(errors, path, 'invalid-value', `expected an array of blocks, got ${typeof value}`)\n return\n }\n value.forEach((entry, index) => {\n const entryPath = `${path}[${index}]`\n if (!isRecord(entry)) {\n push(errors, entryPath, 'invalid-value', 'a block entry must be an object with a `type`')\n return\n }\n const type = entry.type\n if (typeof type !== 'string' || !type) {\n push(errors, `${entryPath}.type`, 'invalid-value', 'a block entry must declare a string `type`')\n return\n }\n if (!blockRegistry.has(type)) {\n push(\n errors,\n `${entryPath}.type`,\n 'unknown-block',\n `block \"${type}\" is not registered`,\n blockRegistry.ids().sort(),\n )\n return\n }\n const settings = getBlockMeta(type)?.settings\n if (settings) {\n const declared = collectSettingIds(settings)\n for (const key of blockPropKeys(entry)) {\n if (!declared.has(key)) {\n push(\n errors,\n `${entryPath}.props.${key}`,\n 'unknown-setting',\n `block \"${type}\" declares no setting \"${key}\"`,\n [...declared].sort(),\n )\n }\n }\n // Below the top level: `entity`-typed settings are semantic ids (I2) — a\n // block naming an undeclared entity WILL fail at render — and every\n // `list` item is judged against its declared `of` shape, so an unknown\n // key inside an item is named instead of silently dropped.\n const props = isRecord(entry.props) ? entry.props : entry\n validateSettingValues(errors, `${entryPath}.props`, settings, props, {\n subject: `block \"${type}\"`,\n noun: 'setting',\n code: 'unknown-setting',\n })\n }\n if ('data' in entry && entry.data !== undefined) {\n validateDataNeeds(errors, entryPath, type, entry.data, declaredParams)\n }\n if ('children' in entry && entry.children !== undefined) {\n validateBlockList(errors, `${entryPath}.children`, entry.children, declaredParams)\n }\n })\n}\n\n/**\n * One authored block tree: per-entry checks plus composition constraints.\n *\n * Constraints (parent, ancestor, allowMultiple) are a property of the WHOLE\n * tree, so they run once here — over the same normalized nodes the renderer\n * sees — and never inside the per-entry recursion, which would judge a child\n * list without its ancestry. Structural violations are errors: the renderer\n * will keep the block off the shopper's page, which means the document\n * misdescribes the store. Advisory findings (context) stay with\n * checkPageBlocks, which owns the warning vocabulary.\n */\nfunction validateBlockTree(\n errors: Errors,\n path: string,\n value: unknown,\n declaredParams: readonly string[] = [],\n): void {\n validateBlockList(errors, path, value, declaredParams)\n if (!Array.isArray(value)) return\n const nodes = toBlockNodes(value as StorefrontBlockLike[])\n for (const violation of checkBlockConstraints(nodes)) {\n push(errors, `${path}${violation.path}`, violation.rule, violation.detail, violation.valid)\n }\n}\n\nfunction collectSettingIds(settings: readonly BlockSetting[]): Set<string> {\n return new Set(settings.map((setting) => setting.id))\n}\n\n// --- Section validators -------------------------------------------------------\n\n// A token key must survive as a CSS custom-property suffix (`--sf-space-<key>`),\n// so it is slug-shaped. The value side stays a free string: CSS is the schema\n// there, and restating it would be a worse validator than the browser's.\nconst TOKEN_KEY = /^[a-zA-Z][a-zA-Z0-9-]*$/\n\nfunction validateTheme(errors: Errors, section: Record<string, unknown>): void {\n for (const field of THEME_SCALE_FIELDS) {\n const scale = section[field]\n if (scale === undefined) continue\n if (!isRecord(scale)) continue // wrong type already reported by the envelope\n for (const [key, value] of Object.entries(scale)) {\n const path = `theme.${field}.${key}`\n if (!TOKEN_KEY.test(key)) {\n push(\n errors,\n path,\n 'invalid-token-key',\n `\"${key}\" cannot become the CSS custom property ${THEME_SCALE_VAR_PREFIX[field]}-${key} — token keys match ${TOKEN_KEY}`,\n )\n }\n if (typeof value !== 'string') {\n push(errors, path, 'invalid-value', `a ${field} token is a CSS value string, got ${typeof value}`)\n }\n }\n }\n}\n\nfunction validateSectionEnvelope(\n errors: Errors,\n name: StoreSectionName,\n section: Record<string, unknown>,\n): boolean {\n const spec = STORE_SECTIONS[name]\n const version = section.version\n if (typeof version !== 'number' || !spec.versions.includes(version)) {\n push(\n errors,\n `${name}.version`,\n 'unsupported-section-version',\n `section \"${name}\" declares version ${JSON.stringify(version)}, which this SDK does not understand`,\n spec.versions.map(String),\n )\n return false\n }\n const fieldNames = Object.keys(spec.fields)\n for (const key of Object.keys(section)) {\n if (key === 'version') continue\n const fieldSpec = spec.fields[key]\n if (!fieldSpec) {\n push(errors, `${name}.${key}`, 'unknown-field', `section \"${name}\" has no field \"${key}\"`, fieldNames)\n continue\n }\n // A deprecated field is ACCEPTED while the section is below the version\n // that retires it — that is the shim (I10). At or past that version the\n // document has been through the codemod, so the field being back is a\n // hard error that names where it moved to (I2). One SDK therefore serves a\n // migrated and an unmigrated store without a flag.\n const deprecated = fieldSpec.deprecated\n if (deprecated && version >= deprecated.removedAtVersion) {\n push(\n errors,\n `${name}.${key}`,\n 'removed-field',\n `field \"${name}.${key}\" was removed at ${name} version ${deprecated.removedAtVersion} ` +\n `(deprecation ${deprecated.id}); this section declares version ${version}`,\n [deprecated.replacement],\n )\n continue\n }\n const value = section[key]\n const actual = Array.isArray(value) ? 'array' : typeof value\n if (actual !== fieldSpec.type) {\n push(\n errors,\n `${name}.${key}`,\n 'invalid-value',\n `field \"${name}.${key}\" expects ${fieldSpec.type}, got ${actual}`,\n )\n continue\n }\n if (fieldSpec.enum && typeof value === 'string' && !fieldSpec.enum.includes(value)) {\n push(\n errors,\n `${name}.${key}`,\n 'invalid-value',\n `\"${value}\" is not a valid ${name}.${key}`,\n fieldSpec.enum,\n )\n }\n }\n for (const [field, fieldSpec] of Object.entries(spec.fields)) {\n if (fieldSpec.required && section[field] === undefined) {\n push(errors, `${name}.${field}`, 'missing-field', `section \"${name}\" requires \"${field}\"`)\n }\n }\n return true\n}\n\nfunction validateCommerce(errors: Errors, section: Record<string, unknown>): void {\n const payments = section.payments\n if (isRecord(payments)) {\n if (payments.mode !== undefined) {\n if (typeof payments.mode !== 'string' || !(STORE_PAYMENT_MODES as readonly string[]).includes(payments.mode)) {\n push(\n errors,\n 'commerce.payments.mode',\n 'invalid-value',\n `\"${String(payments.mode)}\" is not a payment mode`,\n STORE_PAYMENT_MODES,\n )\n }\n }\n if (payments.methods !== undefined) {\n if (!Array.isArray(payments.methods)) {\n push(errors, 'commerce.payments.methods', 'invalid-value', 'payments.methods must be an array')\n } else {\n payments.methods.forEach((method, index) => {\n if (typeof method !== 'string' || !(STORE_PAYMENT_METHOD_KINDS as readonly string[]).includes(method)) {\n push(\n errors,\n `commerce.payments.methods[${index}]`,\n 'invalid-value',\n `\"${String(method)}\" is not a payment method`,\n STORE_PAYMENT_METHOD_KINDS,\n )\n }\n })\n }\n }\n }\n const discounts = section.discounts\n if (Array.isArray(discounts)) {\n discounts.forEach((discount, index) => {\n if (!isRecord(discount) || typeof discount.code !== 'string' || typeof discount.percent !== 'number') {\n push(\n errors,\n `commerce.discounts[${index}]`,\n 'invalid-value',\n 'a discount is {code: string, percent: number, title?: string}',\n )\n }\n })\n }\n}\n\n// A content-page slug becomes its default route (`/<slug>`), so it is url-shaped.\nconst CONTENT_SLUG = /^[a-z0-9][a-z0-9-]*$/\n\nfunction validateContentPages(errors: Errors, basePath: string, value: unknown): void {\n if (!isRecord(value)) {\n push(errors, basePath, 'invalid-value', 'pages.content maps slugs to {title?, path?, blocks: [...]}')\n return\n }\n const pathOwners = new Map<string, string>()\n for (const [slug, page] of Object.entries(value)) {\n const pagePath = `${basePath}.${slug}`\n if (!CONTENT_SLUG.test(slug)) {\n push(\n errors,\n pagePath,\n 'invalid-value',\n `\"${slug}\" cannot become the route \"/${slug}\" — content slugs match ${CONTENT_SLUG}`,\n )\n }\n if (!isRecord(page) || page.blocks === undefined) {\n push(errors, pagePath, 'invalid-value', 'a content page is {title?, path?, blocks: [...]}')\n continue\n }\n if (page.title !== undefined && typeof page.title !== 'string') {\n push(errors, `${pagePath}.title`, 'invalid-value', `title expects string, got ${typeof page.title}`)\n }\n let routePath = `/${slug}`\n if (page.path !== undefined) {\n if (typeof page.path !== 'string' || !page.path.startsWith('/')) {\n push(errors, `${pagePath}.path`, 'invalid-value', `path is an absolute route ('/${slug}'), got ${JSON.stringify(page.path)}`)\n } else {\n routePath = page.path\n }\n }\n // Two pages resolving to one route means one of them silently never\n // renders — exactly the class of failure this validator exists to end.\n const owner = pathOwners.get(routePath)\n if (owner) {\n push(\n errors,\n `${pagePath}.path`,\n 'duplicate-content-path',\n `content pages \"${owner}\" and \"${slug}\" both resolve to \"${routePath}\" — one of them can never render`,\n )\n } else {\n pathOwners.set(routePath, slug)\n }\n // A content page's path pattern is its param declaration (M3): blocks on\n // '/categoria/:slug' may bind { $param: 'slug' }; a param-less page's\n // blocks may bind nothing.\n validateBlockTree(errors, `${pagePath}.blocks`, page.blocks, routePathParams(routePath))\n }\n}\n\nfunction validatePresentation(errors: Errors, section: Record<string, unknown>): void {\n const home = section.home\n if (isRecord(home) && home.sections !== undefined) {\n validateBlockTree(errors, 'presentation.home.sections', home.sections)\n }\n\n const pages = section.pages\n if (isRecord(pages)) {\n const validKinds = [...STOREFRONT_PAGE_KINDS]\n for (const [kind, page] of Object.entries(pages)) {\n const pagePath = `presentation.pages.${kind}`\n if (!(validKinds as string[]).includes(kind)) {\n push(errors, pagePath, 'unknown-page-kind', `\"${kind}\" is not a composable page kind`, validKinds)\n continue\n }\n // `content` holds a MAP of editorial pages, not one page.\n if (kind === 'content') {\n validateContentPages(errors, pagePath, page)\n continue\n }\n if (!isRecord(page) || page.blocks === undefined) {\n push(errors, pagePath, 'invalid-value', 'a composed page is {blocks: [...]}')\n continue\n }\n validateBlockTree(errors, `${pagePath}.blocks`, page.blocks, PAGE_KIND_PARAMS[kind] ?? [])\n }\n }\n\n const slots = section.slots\n if (isRecord(slots)) {\n for (const [area, areaSlots] of Object.entries(slots)) {\n const areaPath = `presentation.slots.${area}`\n if (!(SLOT_AREAS as string[]).includes(area)) {\n push(errors, areaPath, 'unknown-slot-area', `\"${area}\" is not a slot area`, SLOT_AREAS)\n continue\n }\n if (!isRecord(areaSlots)) {\n push(errors, areaPath, 'invalid-value', 'a slot area maps slot names to block lists')\n continue\n }\n const validNames = slotNamesFor(area as StorefrontSlotArea)\n for (const [slotName, blocks] of Object.entries(areaSlots)) {\n const slotPath = `${areaPath}.${slotName}`\n if (!validNames.includes(slotName)) {\n push(errors, slotPath, 'unknown-slot', `\"${area}.${slotName}\" is not a slot`, validNames)\n continue\n }\n validateBlockTree(errors, slotPath, blocks, SLOT_AREA_PARAMS[area] ?? [])\n }\n }\n }\n}\n\nconst ENTITY_KEY_RE = /^[a-z][a-z0-9_]*$/\nconst ENTITY_FIELD_RE = /^[a-z][a-z0-9_]*$/\n\n/**\n * The entities section holds defineEntity INPUTS as data. Validation mirrors\n * what defineEntity enforces at registration — same rules, same valid sets —\n * so a document that validates clean is a document whose hydration cannot\n * throw. I2 on every id: field types, access levels, field references.\n */\nfunction validateEntitiesSection(errors: Errors, section: Record<string, unknown>): void {\n const definitions = section.definitions\n if (definitions === undefined || !isRecord(definitions)) return // envelope reported the type\n for (const [key, declaration] of Object.entries(definitions)) {\n const path = `entities.definitions.${key}`\n if (!ENTITY_KEY_RE.test(key)) {\n push(errors, path, 'invalid-value', `\"${key}\" is not a valid entity key — keys are snake_case`)\n }\n if (!isRecord(declaration) || !isRecord(declaration.fields) || Object.keys(declaration.fields).length === 0) {\n push(errors, path, 'invalid-value', 'an entity declaration is {fields: {<name>: {type, …}}, scope?, access?, indexes?}')\n continue\n }\n const fields = declaration.fields\n const fieldNames = Object.keys(fields)\n for (const [name, field] of Object.entries(fields)) {\n const fieldPath = `${path}.fields.${name}`\n if (!ENTITY_FIELD_RE.test(name)) {\n push(errors, fieldPath, 'invalid-value', `\"${name}\" is not a valid field name — fields are snake_case`)\n }\n if ((RESERVED_ENTITY_FIELDS as readonly string[]).includes(name)) {\n push(errors, fieldPath, 'invalid-value', `\"${name}\" is a structural record column`, RESERVED_ENTITY_FIELDS)\n continue\n }\n if (!isRecord(field) || typeof field.type !== 'string') {\n push(errors, fieldPath, 'invalid-value', 'a field is {type: <entity field type>, label?, required?, …}')\n continue\n }\n if (!(ENTITY_FIELD_TYPES as readonly string[]).includes(field.type)) {\n push(errors, `${fieldPath}.type`, 'unknown-entity-field-type', `\"${field.type}\" is not an entity field type`, ENTITY_FIELD_TYPES)\n continue\n }\n if (field.type === 'ref') {\n if (typeof field.entity !== 'string' || !field.entity) {\n push(errors, fieldPath, 'invalid-value', `a ref field names its target: {type: 'ref', entity: '<key>'}`)\n } else {\n checkEntityRef(errors, `${fieldPath}.entity`, field.entity)\n }\n }\n }\n const scope = declaration.scope\n if (scope !== undefined && scope !== 'tenant') {\n push(errors, `${path}.scope`, 'invalid-value', `\"${String(scope)}\" is not an entity scope`, ['tenant'])\n }\n const access = declaration.access\n if (access !== undefined) {\n if (!isRecord(access)) {\n push(errors, `${path}.access`, 'invalid-value', \"access is {read: 'public'|'staff', write: 'staff'}\")\n } else {\n if (access.read !== undefined && access.read !== 'public' && access.read !== 'staff') {\n push(errors, `${path}.access.read`, 'invalid-value', `\"${String(access.read)}\" is not a read access level`, ['public', 'staff'])\n }\n if (access.write !== undefined && access.write !== 'staff') {\n push(errors, `${path}.access.write`, 'invalid-value', `\"${String(access.write)}\" is not a write access level — shopper writes go through actions (M7), not RLS`, ['staff'])\n }\n }\n }\n const references = (where: string, name: unknown): void => {\n if (typeof name !== 'string' || !fieldNames.includes(name)) {\n push(errors, `${path}.${where}`, 'invalid-value', `${where} references undeclared field \"${String(name)}\"`, fieldNames)\n }\n }\n if (Array.isArray(declaration.indexes)) {\n declaration.indexes.forEach((tuple, i) => {\n if (!Array.isArray(tuple)) {\n push(errors, `${path}.indexes[${i}]`, 'invalid-value', 'an index is an array of declared field names')\n return\n }\n for (const name of tuple) references(`indexes[${i}]`, name)\n })\n }\n if (declaration.titleField !== undefined) references('titleField', declaration.titleField)\n if (Array.isArray(declaration.displayFields)) {\n for (const name of declaration.displayFields) references('displayFields', name)\n }\n }\n}\n\n/**\n * One rule (`{attribute, operator, values}`) against the rule_attribute\n * vocabulary (I9/I2): an unknown attribute names the registered keys, an\n * operator the attribute does not support names the supported subset. The\n * vocabulary is read at validation time, so attributes widened by context\n * providers (defineRuleContextProvider) validate exactly like core ones.\n */\nfunction validatePromotionRule(errors: Errors, path: string, rule: unknown): void {\n if (!isRecord(rule) || typeof rule.attribute !== 'string' || typeof rule.operator !== 'string') {\n push(errors, path, 'invalid-value', 'a rule is {attribute, operator, values: [...]}')\n return\n }\n if (!hasRuleAttribute(rule.attribute)) {\n push(\n errors,\n `${path}.attribute`,\n 'unknown-rule-attribute',\n `\"${rule.attribute}\" is not in the rule attribute vocabulary`,\n listRuleAttributeKeys(),\n )\n return\n }\n if (!(RULE_OPERATORS as readonly string[]).includes(rule.operator)) {\n push(errors, `${path}.operator`, 'unknown-rule-operator', `\"${rule.operator}\" is not a rule operator`, RULE_OPERATORS)\n return\n }\n const attribute = resolveRuleAttribute(rule.attribute)\n if (!(attribute.operators as readonly string[]).includes(rule.operator)) {\n push(\n errors,\n `${path}.operator`,\n 'unsupported-rule-operator',\n `attribute \"${rule.attribute}\" does not support operator \"${rule.operator}\"`,\n attribute.operators,\n )\n }\n if (!Array.isArray(rule.values) || rule.values.length === 0) {\n push(errors, `${path}.values`, 'invalid-value', 'rule values are a non-empty array of scalars')\n return\n }\n rule.values.forEach((value, index) => {\n const t = typeof value\n if (t !== 'string' && t !== 'number' && t !== 'boolean') {\n push(errors, `${path}.values[${index}]`, 'invalid-value', `a rule value is a JSON scalar, got ${t}`)\n }\n })\n}\n\nfunction validateRuleList(errors: Errors, path: string, value: unknown): void {\n if (value === undefined) return\n if (!Array.isArray(value)) {\n push(errors, path, 'invalid-value', `expected an array of rules, got ${typeof value}`)\n return\n }\n value.forEach((rule, index) => validatePromotionRule(errors, `${path}[${index}]`, rule))\n}\n\nfunction validatePromotionsSection(errors: Errors, section: Record<string, unknown>): void {\n const promotions = section.promotions\n if (promotions === undefined || !Array.isArray(promotions)) return // envelope reported the type\n promotions.forEach((promotion, index) => {\n const path = `promotions.promotions[${index}]`\n if (!isRecord(promotion) || typeof promotion.id !== 'string' || !promotion.id) {\n push(errors, path, 'invalid-value', 'a promotion is {id, code?, isAutomatic?, rules?, applicationMethod}')\n return\n }\n if (promotion.type !== undefined && !(PROMOTION_TYPES as readonly string[]).includes(promotion.type as string)) {\n push(errors, `${path}.type`, 'invalid-value', `\"${String(promotion.type)}\" is not a promotion type`, PROMOTION_TYPES)\n }\n if (promotion.status !== undefined && !(PROMOTION_STATUSES as readonly string[]).includes(promotion.status as string)) {\n push(errors, `${path}.status`, 'invalid-value', `\"${String(promotion.status)}\" is not a promotion status`, PROMOTION_STATUSES)\n }\n if (promotion.code === undefined && promotion.isAutomatic !== true) {\n push(\n errors,\n `${path}.code`,\n 'invalid-value',\n 'a promotion needs a code or isAutomatic: true — otherwise nothing can ever trigger it',\n )\n }\n validateRuleList(errors, `${path}.rules`, promotion.rules)\n const method = promotion.applicationMethod\n if (!isRecord(method)) {\n push(errors, `${path}.applicationMethod`, 'invalid-value', 'a promotion carries an applicationMethod ({type, value, targetType, …})')\n return\n }\n const methodPath = `${path}.applicationMethod`\n if (typeof method.type !== 'string' || !(APPLICATION_METHOD_TYPES as readonly string[]).includes(method.type)) {\n push(errors, `${methodPath}.type`, 'invalid-value', `\"${String(method.type)}\" is not an application method type`, APPLICATION_METHOD_TYPES)\n }\n if (typeof method.value !== 'number' || method.value < 0) {\n push(errors, `${methodPath}.value`, 'invalid-value', 'applicationMethod.value is a non-negative number')\n }\n if (typeof method.targetType !== 'string' || !(APPLICATION_METHOD_TARGET_TYPES as readonly string[]).includes(method.targetType)) {\n push(errors, `${methodPath}.targetType`, 'invalid-value', `\"${String(method.targetType)}\" is not a target type`, APPLICATION_METHOD_TARGET_TYPES)\n }\n if (method.allocation !== undefined && !(APPLICATION_METHOD_ALLOCATIONS as readonly string[]).includes(method.allocation as string)) {\n push(errors, `${methodPath}.allocation`, 'invalid-value', `\"${String(method.allocation)}\" is not an allocation`, APPLICATION_METHOD_ALLOCATIONS)\n }\n for (const field of ['maxQuantity', 'applyToQuantity', 'buyRulesMinQuantity'] as const) {\n const value = method[field]\n if (value !== undefined && value !== null && (typeof value !== 'number' || value < 1)) {\n push(errors, `${methodPath}.${field}`, 'invalid-value', `${field} is a positive integer when set`)\n }\n }\n validateRuleList(errors, `${methodPath}.targetRules`, method.targetRules)\n validateRuleList(errors, `${methodPath}.buyRules`, method.buyRules)\n })\n}\n\nfunction validateHandleRef(errors: Errors, path: string, name: unknown): void {\n if (typeof name !== 'string' || !name) {\n push(errors, path, 'invalid-value', 'a code reference is a registered handle name (string)')\n return\n }\n if (!hasHandle(name)) {\n push(errors, path, 'unknown-handle', `handle \"${name}\" is not registered`, listHandles())\n }\n}\n\nfunction validateCode(errors: Errors, section: Record<string, unknown>): void {\n for (const field of ['logo', 'provider', 'auth', 'footerCredit'] as const) {\n if (section[field] !== undefined) validateHandleRef(errors, `code.${field}`, section[field])\n }\n\n const components = section.components\n if (isRecord(components)) {\n for (const [slot, handle] of Object.entries(components)) {\n const slotPath = `code.components.${slot}`\n if (!(STOREFRONT_COMPONENT_KEYS as readonly string[]).includes(slot)) {\n push(\n errors,\n slotPath,\n 'unknown-component-slot',\n `\"${slot}\" is not an overridable storefront component`,\n STOREFRONT_COMPONENT_KEYS,\n )\n continue\n }\n validateHandleRef(errors, slotPath, handle)\n }\n }\n\n const routes = section.routes\n if (Array.isArray(routes)) {\n routes.forEach((route, index) => {\n const routePath = `code.routes[${index}]`\n if (!isRecord(route)) {\n push(errors, routePath, 'invalid-value', 'a route is {id, path, kind?, chrome?, component}')\n return\n }\n for (const required of ['id', 'path'] as const) {\n if (typeof route[required] !== 'string' || !route[required]) {\n push(errors, `${routePath}.${required}`, 'missing-field', `route requires a string \"${required}\"`)\n }\n }\n // Closed shape, same reasoning as a data need: hydrateStore rebuilds a\n // route from exactly these five keys, so anything else the author wrote\n // is discarded without a word.\n for (const key of Object.keys(route)) {\n if (!CODE_ROUTE_KEYS.includes(key)) {\n push(errors, `${routePath}.${key}`, 'unknown-field', `a route has no field \"${key}\"`, CODE_ROUTE_KEYS)\n }\n }\n if (route.kind !== undefined && !(STORE_ROUTE_KINDS as readonly string[]).includes(route.kind as string)) {\n push(\n errors,\n `${routePath}.kind`,\n 'invalid-value',\n `\"${String(route.kind)}\" is not a route kind`,\n STORE_ROUTE_KINDS,\n )\n }\n if (\n route.chrome !== undefined &&\n !(STORE_ROUTE_CHROMES as readonly string[]).includes(route.chrome as string)\n ) {\n push(\n errors,\n `${routePath}.chrome`,\n 'invalid-value',\n `\"${String(route.chrome)}\" is not a route chrome`,\n STORE_ROUTE_CHROMES,\n )\n }\n validateHandleRef(errors, `${routePath}.component`, route.component)\n })\n }\n}\n\n// --- The gate -----------------------------------------------------------------\n\n/**\n * Validate a Store Document against the registries and section schemas.\n *\n * Self-sufficient: registers the SDK blocks before checking, so \"unknown\n * block\" always names the true valid set. App-local blocks and handles must be\n * registered by the app's own modules before this runs — which is the same\n * precondition rendering has.\n */\nexport function validateStore(doc: unknown): StoreValidationReport {\n registerStorefrontBlocks()\n const errors: Errors = []\n\n // The entity vocabulary for THIS document: registered declarations plus the\n // document's own entities section, collected before any block is judged so\n // an entityList above the section in file order still validates.\n knownEntities = new Set(listEntityDeclarations())\n if (isRecord(doc)) {\n const entitiesSection = (doc as Record<string, unknown>).entities\n if (isRecord(entitiesSection) && isRecord(entitiesSection.definitions)) {\n for (const key of Object.keys(entitiesSection.definitions)) knownEntities.add(key)\n }\n }\n\n if (!isRecord(doc)) {\n push(errors, '', 'invalid-document', `a store document is an object, got ${doc === null ? 'null' : typeof doc}`)\n return { ok: false, errors }\n }\n\n if (doc.$kind !== STORE_DOCUMENT_KIND) {\n push(\n errors,\n '$kind',\n 'invalid-document',\n `expected $kind \"${STORE_DOCUMENT_KIND}\", got ${JSON.stringify(doc.$kind)}`,\n [STORE_DOCUMENT_KIND],\n )\n }\n\n if (doc.store === undefined) {\n push(errors, 'store', 'missing-section', 'the \"store\" section (name/currency/locale) is required', [\n ...STORE_SECTION_NAMES,\n ])\n }\n\n for (const [name, section] of Object.entries(doc)) {\n if (name === '$kind') continue\n if (!(STORE_SECTION_NAMES as string[]).includes(name)) {\n push(errors, name, 'unknown-section', `\"${name}\" is not a document section`, STORE_SECTION_NAMES)\n continue\n }\n if (!isRecord(section)) {\n push(errors, name, 'invalid-value', `section \"${name}\" must be an object with a version`)\n continue\n }\n const sectionName = name as StoreSectionName\n // A version this SDK does not understand makes the section's contents\n // unjudgeable — skip the deep checks rather than reporting noise against\n // the wrong schema.\n if (!validateSectionEnvelope(errors, sectionName, section)) continue\n if (sectionName === 'theme') validateTheme(errors, section)\n if (sectionName === 'entities') validateEntitiesSection(errors, section)\n if (sectionName === 'promotions') validatePromotionsSection(errors, section)\n if (sectionName === 'commerce') validateCommerce(errors, section)\n if (sectionName === 'presentation') validatePresentation(errors, section)\n if (sectionName === 'code') validateCode(errors, section)\n }\n\n return { ok: errors.length === 0, errors }\n}\n","import { errorMessage } from '@fayz-ai/core'\nimport type { ComponentType } from 'react'\nimport { handleNameFor, registerHandle, resolveHandle } from '@fayz-ai/core'\nimport type { ShopProvider } from '@fayz-ai/shop/provider'\nimport type {\n StorefrontConfig,\n StorefrontRouteDefinition,\n StorefrontRouteComponentProps,\n StorefrontSearchConfig,\n} from './config'\nimport type { StorefrontComponents } from '../extend/component-contracts'\nimport type { StorefrontAuthConfig } from '../data/auth'\nimport type { StorefrontTheme } from '../lib/theme'\nimport type { FooterConfig } from '../blocks/sections'\nimport { STORE_DOCUMENT_KIND, compact, isJsonValue } from './sections'\nimport type { StoreCodeRouteRef, StoreCodeSection, StoreDocument } from './sections'\nimport { validateStore } from './validate'\n\n// ---------------------------------------------------------------------------\n// exportStore / hydrateStoreDocument — the round-trip.\n//\n// Export is a first-class operation (spine §3 L0): if a live store cannot be\n// serialized, the agent cannot read one before changing it. The acceptance\n// test for this module is exact: defineStorefront(config) → exportStore() →\n// hydrate → resolveConfig deep-equals the original resolved config, with code\n// fields compared by handle name.\n//\n// Code never enters the document. A code-valued field is serialized as the\n// handle NAME it is registered under (reverse lookup), and hydration resolves\n// the name through the handle registry — where an unknown name is a hard\n// error naming the valid set (I2). This replaces the in-memory config Map the\n// scaffold used to keep, which could only reconstitute a store inside the\n// session that authored it.\n// ---------------------------------------------------------------------------\n\nexport function slugifyStoreName(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'app'\n}\n\nexport interface ExportStoreOptions {\n /** Namespace for auto-registered handles. Default: slug of the store name. */\n appId?: string\n /**\n * Register a deterministic handle (`<appId>.<config-path>`) for any code\n * value that has none, instead of failing. `defineStorefront` turns this on\n * so a store written today keeps working; a store that names its own handles\n * (registerHandle) keeps its names — explicit registration always wins the\n * reverse lookup.\n */\n registerMissingHandles?: boolean\n}\n\ninterface CodeRefContext {\n appId: string\n autoRegister: boolean\n}\n\n/** The handle name for a code value, auto-registering when allowed. */\nfunction codeRef(value: unknown, configPath: string, handleSuffix: string, ctx: CodeRefContext): string {\n const existing = handleNameFor(value)\n if (existing) return existing\n const name = `${ctx.appId}.${handleSuffix}`\n if (!ctx.autoRegister) {\n throw new Error(\n `exportStore: config.${configPath} holds code that is not a registered handle. ` +\n `Call registerHandle('${name}', value) before exporting, or export with ` +\n `{ registerMissingHandles: true } (defineStorefront does).`,\n )\n }\n registerHandle(\n name,\n value,\n { description: `Auto-registered from config.${configPath}`, source: 'app' },\n // The app re-declaring its config (module re-evaluation, HMR) re-derives\n // the same name for a fresh value; replacing is the correct semantics.\n { replace: true },\n )\n return name\n}\n\n/** First path inside `value` that is not JSON-representable, or null. */\nfunction findNonJsonPath(value: unknown, path: string): string | null {\n if (value === null || value === undefined) return null\n const t = typeof value\n if (t === 'string' || t === 'number' || t === 'boolean') return null\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const found = findNonJsonPath(value[i], `${path}[${i}]`)\n if (found) return found\n }\n return null\n }\n if (t === 'object') {\n const record = value as Record<string, unknown>\n if ('$$typeof' in record) return path\n const proto = Object.getPrototypeOf(record)\n if (proto !== Object.prototype && proto !== null) return path\n for (const [key, child] of Object.entries(record)) {\n const found = findNonJsonPath(child, `${path}.${key}`)\n if (found) return found\n }\n return null\n }\n return path\n}\n\nfunction hasContent(section: Record<string, unknown>): boolean {\n return Object.keys(section).some((key) => key !== 'version')\n}\n\n/**\n * Serialize a defined/live store to Store Document v1.\n *\n * Data fields map to sections verbatim (the authored block form is preserved,\n * flat or nested — both are data). Code fields become handle names in the\n * `code` section. A data field smuggling code (JSX inside a page tree) is a\n * hard error naming the offending path rather than a document that lies.\n */\nexport function exportStore(config: StorefrontConfig, options: ExportStoreOptions = {}): StoreDocument {\n const ctx: CodeRefContext = {\n appId: options.appId ?? slugifyStoreName(config.name),\n autoRegister: options.registerMissingHandles ?? false,\n }\n\n const code: StoreCodeSection = { version: 1 }\n\n // --- logo: string stays data; anything else is code ------------------------\n let presentationLogo: string | undefined\n if (config.logo !== undefined) {\n if (typeof config.logo === 'string') presentationLogo = config.logo\n else code.logo = codeRef(config.logo, 'logo', 'logo', ctx)\n }\n\n // --- footer: the credit node may be code; the rest is data -----------------\n let footerData: FooterConfig | undefined\n if (config.footer !== undefined) {\n const { credit, ...rest } = config.footer\n if (credit === undefined || typeof credit === 'string') {\n footerData = config.footer\n } else {\n footerData = rest\n code.footerCredit = codeRef(credit, 'footer.credit', 'footer-credit', ctx)\n }\n }\n\n // --- search: the knobs are data, a custom suggestion renderer is code ------\n let searchData: Omit<StorefrontSearchConfig, 'renderSuggestion'> | undefined\n if (config.search !== undefined) {\n const { renderSuggestion, ...rest } = config.search\n searchData = rest\n if (renderSuggestion !== undefined) {\n code.searchRenderSuggestion = codeRef(\n renderSuggestion,\n 'search.renderSuggestion',\n 'search-render-suggestion',\n ctx,\n )\n }\n }\n\n // --- auth: whole value is data or whole value is code ----------------------\n // Split across two sections it would stop being one config object; an auth\n // config carrying ANY code (adapter object, supabase client) moves whole.\n let authData: StorefrontAuthConfig | undefined\n if (config.auth !== undefined) {\n if (isJsonValue(config.auth)) authData = config.auth\n else code.auth = codeRef(config.auth, 'auth', 'auth', ctx)\n }\n\n if (config.provider !== undefined) {\n code.provider = codeRef(config.provider, 'provider', 'provider', ctx)\n }\n\n if (config.components !== undefined) {\n const componentRefs: Record<string, string> = {}\n for (const [key, override] of Object.entries(config.components)) {\n if (override === undefined) continue\n componentRefs[key] = codeRef(override, `components.${key}`, `components.${key}`, ctx)\n }\n if (Object.keys(componentRefs).length > 0) code.components = componentRefs\n }\n\n if (config.routes !== undefined && config.routes.length > 0) {\n code.routes = config.routes.map(\n (route): StoreCodeRouteRef =>\n compact({\n id: route.id,\n path: route.path,\n kind: route.kind,\n chrome: route.chrome,\n component: codeRef(route.component, `routes[${route.id}].component`, `routes.${route.id}`, ctx),\n }),\n )\n }\n\n const sections = {\n store: compact({\n version: 1,\n name: config.name,\n currency: config.currency,\n locale: config.locale,\n }),\n theme: config.theme\n ? { version: 1, ...compact(config.theme as unknown as Record<string, unknown>) }\n : { version: 1 },\n commerce: compact({\n version: 1,\n commerceMode: config.commerceMode,\n shipping: config.shipping,\n payments: config.payments,\n discounts: config.discounts,\n enquiry: config.enquiry,\n features: config.features,\n }),\n presentation: compact({\n version: 1,\n announcement: config.announcement,\n logo: presentationLogo,\n home: config.home,\n pages: config.pages,\n slots: config.slots,\n nav: config.nav,\n footer: footerData,\n imageLoading: config.imageLoading,\n catalogFacets: config.catalogFacets,\n productSpecs: config.productSpecs,\n search: searchData,\n }),\n content: compact({ version: 1, legal: config.legal, reviews: config.reviews }),\n catalog: config.catalog ? { version: 1, ...compact(config.catalog as Record<string, unknown>) } : { version: 1 },\n entities: config.entities ? { version: 1, definitions: config.entities } : { version: 1 },\n promotions: config.promotions ? { version: 1, promotions: config.promotions } : { version: 1 },\n backend: compact({\n version: 1,\n provider: config.backend?.provider,\n url: config.backend?.url,\n supabaseUrl: config.supabaseUrl,\n supabaseAnonKey: config.supabaseAnonKey,\n }),\n auth: authData ? { version: 1, ...compact(authData as Record<string, unknown>) } : { version: 1 },\n code: compact(code as unknown as Record<string, unknown>) as unknown as StoreCodeSection,\n }\n\n // A section rides only when it says something. theme/catalog/auth key off the\n // config field instead of content so an EMPTY configured object (catalog: {})\n // still round-trips as the empty object it is, not as absence.\n const include: Record<string, boolean> = {\n theme: config.theme !== undefined,\n catalog: config.catalog !== undefined,\n entities: config.entities !== undefined,\n promotions: config.promotions !== undefined,\n auth: authData !== undefined,\n commerce: hasContent(sections.commerce),\n presentation: hasContent(sections.presentation),\n content: hasContent(sections.content),\n backend: hasContent(sections.backend),\n code: hasContent(sections.code as unknown as Record<string, unknown>),\n }\n const doc: Record<string, unknown> = { $kind: STORE_DOCUMENT_KIND, store: sections.store }\n for (const name of ['theme', 'commerce', 'presentation', 'content', 'catalog', 'entities', 'promotions', 'backend', 'auth', 'code'] as const) {\n if (include[name]) doc[name] = sections[name]\n }\n\n // The document must be strictly JSON: a page tree or seed catalog smuggling\n // a function/JSX would produce a document that LOOKS complete and cannot be\n // hydrated anywhere else. Fail here, naming the path (I2 spirit).\n for (const [name, section] of Object.entries(doc)) {\n if (name === '$kind') continue\n const offending = findNonJsonPath(section, name)\n if (offending) {\n throw new Error(\n `exportStore: ${offending} holds a non-serializable value. Code belongs in a registered ` +\n `handle (registerHandle) referenced from the document's code section — data sections must be pure JSON.`,\n )\n }\n }\n\n return doc as unknown as StoreDocument\n}\n\nexport interface HydrateStoreOptions {\n /**\n * 'throw' (default): a document that fails validation aborts hydration with\n * an error listing every finding — the authoring-loop contract (I2).\n * 'report': log the findings and hydrate best-effort, dropping unresolvable\n * code refs — the shopper-facing contract (I7: a broken document degrades\n * instead of white-screening the store). The scaffold uses 'report'.\n */\n onError?: 'throw' | 'report'\n}\n\nfunction formatErrors(errors: ReturnType<typeof validateStore>['errors']): string {\n return errors\n .map((e) => ` - ${e.path || '(document)'}: ${e.message}${e.valid ? ` (valid: ${e.valid.join(', ')})` : ''}`)\n .join('\\n')\n}\n\n/**\n * Reconstitute a StorefrontConfig from a Store Document.\n *\n * Every code reference resolves through the handle registry by NAME — the\n * document alone plus the app's registered handles is the whole story; there\n * is no in-memory side channel keyed by app id anymore.\n */\nexport function hydrateStoreDocument(\n input: StoreDocument | Record<string, unknown>,\n options: HydrateStoreOptions = {},\n): StorefrontConfig {\n const onError = options.onError ?? 'throw'\n const report = validateStore(input)\n if (!report.ok) {\n const message = `Store document failed validation:\\n${formatErrors(report.errors)}`\n if (onError === 'throw') throw new Error(message)\n console.error(`[storefront] ${message}`)\n }\n\n const doc = input as unknown as StoreDocument\n const resolve = <T>(name: string, path: string): T | undefined => {\n try {\n return resolveHandle<T>(name)\n } catch (err) {\n if (onError === 'throw') throw err\n console.error(`[storefront] dropping ${path}: ${errorMessage(err)}`)\n return undefined\n }\n }\n\n const config: StorefrontConfig = { name: doc.store?.name ?? '' }\n const set = <K extends keyof StorefrontConfig>(key: K, value: StorefrontConfig[K] | undefined): void => {\n if (value !== undefined) config[key] = value\n }\n\n set('currency', doc.store?.currency)\n set('locale', doc.store?.locale)\n\n if (doc.theme) {\n const { version: _v, ...theme } = doc.theme\n set('theme', theme as StorefrontTheme)\n }\n\n if (doc.commerce) {\n set('commerceMode', doc.commerce.commerceMode)\n set('shipping', doc.commerce.shipping)\n set('payments', doc.commerce.payments)\n set('discounts', doc.commerce.discounts)\n set('enquiry', doc.commerce.enquiry)\n set('features', doc.commerce.features)\n }\n\n if (doc.presentation) {\n set('announcement', doc.presentation.announcement)\n set('home', doc.presentation.home)\n set('pages', doc.presentation.pages)\n set('slots', doc.presentation.slots)\n set('nav', doc.presentation.nav)\n set('imageLoading', doc.presentation.imageLoading)\n set('catalogFacets', doc.presentation.catalogFacets)\n set('productSpecs', doc.presentation.productSpecs)\n set('search', doc.presentation.search)\n if (doc.presentation.logo !== undefined) set('logo', doc.presentation.logo)\n }\n\n if (doc.content) {\n set('legal', doc.content.legal)\n set('reviews', doc.content.reviews)\n }\n\n if (doc.catalog) {\n const { version: _v, ...seed } = doc.catalog\n set('catalog', seed)\n }\n\n if (doc.entities?.definitions) set('entities', doc.entities.definitions)\n\n if (doc.promotions?.promotions) set('promotions', doc.promotions.promotions)\n\n if (doc.backend) {\n const { provider, url, supabaseUrl, supabaseAnonKey } = doc.backend\n if (provider !== undefined || url !== undefined) set('backend', compact({ provider, url }))\n set('supabaseUrl', supabaseUrl)\n set('supabaseAnonKey', supabaseAnonKey)\n }\n\n if (doc.auth) {\n const { version: _v, ...auth } = doc.auth\n set('auth', auth)\n }\n\n const code = doc.code\n if (code) {\n if (code.logo) set('logo', resolve<StorefrontConfig['logo']>(code.logo, 'code.logo'))\n if (code.provider) set('provider', resolve<ShopProvider>(code.provider, 'code.provider'))\n if (code.auth) set('auth', resolve<StorefrontAuthConfig>(code.auth, 'code.auth'))\n if (code.components) {\n const components: Record<string, unknown> = {}\n for (const [key, handle] of Object.entries(code.components)) {\n const value = resolve(handle, `code.components.${key}`)\n if (value !== undefined) components[key] = value\n }\n if (Object.keys(components).length > 0) set('components', components as StorefrontComponents)\n }\n if (code.routes) {\n const routes: StorefrontRouteDefinition[] = []\n for (const route of code.routes) {\n const component = resolve<ComponentType<StorefrontRouteComponentProps>>(\n route.component,\n `code.routes[${route.id}].component`,\n )\n if (component === undefined) continue\n routes.push(\n compact({\n id: route.id,\n path: route.path,\n kind: route.kind,\n chrome: route.chrome,\n component,\n }) as unknown as StorefrontRouteDefinition,\n )\n }\n if (routes.length > 0) set('routes', routes)\n }\n if (code.searchRenderSuggestion) {\n const renderSuggestion = resolve<NonNullable<StorefrontSearchConfig['renderSuggestion']>>(\n code.searchRenderSuggestion,\n 'code.searchRenderSuggestion',\n )\n if (renderSuggestion !== undefined) {\n set('search', { ...(doc.presentation?.search ?? {}), renderSuggestion })\n }\n }\n if (code.footerCredit) {\n const credit = resolve<FooterConfig['credit']>(code.footerCredit, 'code.footerCredit')\n if (credit !== undefined) {\n set('footer', { ...(doc.presentation?.footer ?? {}), credit })\n }\n }\n }\n if (config.footer === undefined && doc.presentation?.footer !== undefined) {\n set('footer', doc.presentation.footer)\n }\n\n return config\n}\n\n/** Re-export so document consumers need one import. */\nexport { STORE_DOCUMENT_KIND }\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/document/sections.ts","../src/extend/component-contracts.ts","../src/document/validate.ts","../src/document/round-trip.ts"],"names":[],"mappings":";;;;;;;AAuCO,IAAM,mBAAA,GAAsB;AAM5B,IAAM,oBAAA,GAAuB,CAAC,UAAA,EAAY,SAAA,EAAW,WAAW,UAAU;AAS1E,IAAM,mBAAA,GAAsB,CAAC,MAAA,EAAQ,iBAAA,EAAmB,SAAS;AAIjE,IAAM,0BAAA,GAA6B;AAAA,EACxC,KAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAMO,IAAM,uBAAA,GAA0B,CAAC,MAAA,EAAQ,UAAA,EAAY,aAAa,QAAQ;AAK1E,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF;AAKO,IAAM,mBAAA,GAAsB,CAAC,SAAA,EAAW,SAAA,EAAW,SAA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AAA,OACF;AACA,MAAA,IAAI,qBAAqB,MAAA,EAAW;AAClC,QAAA,GAAA,CAAI,QAAA,EAAU,EAAE,GAAI,GAAA,CAAI,cAAc,MAAA,IAAU,EAAC,EAAI,gBAAA,EAAkB,CAAA;AAAA,MACzE;AAAA,IACF;AACA,IAAA,IAAI,KAAK,YAAA,EAAc;AACrB,MAAA,MAAM,MAAA,GAAS,OAAA,CAAgC,IAAA,CAAK,YAAA,EAAc,mBAAmB,CAAA;AACrF,MAAA,IAAI,WAAW,MAAA,EAAW;AACxB,QAAA,GAAA,CAAI,QAAA,EAAU,EAAE,GAAI,GAAA,CAAI,cAAc,MAAA,IAAU,EAAC,EAAI,MAAA,EAAQ,CAAA;AAAA,MAC/D;AAAA,IACF;AAAA,EACF;AACA,EAAA,IAAI,OAAO,MAAA,KAAW,MAAA,IAAa,GAAA,CAAI,YAAA,EAAc,WAAW,MAAA,EAAW;AACzE,IAAA,GAAA,CAAI,QAAA,EAAU,GAAA,CAAI,YAAA,CAAa,MAAM,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,MAAA;AACT","file":"chunk-BR3XHNVM.js","sourcesContent":["import type { EntityDeclarationInput, JsonSchema } from '@fayz-ai/core'\nimport type { PaymentMethodKind } from '@fayz-ai/shop/types'\nimport type { MockShopSeed } from '@fayz-ai/shop/mock'\nimport type { Promotion } from '@fayz-ai/shop/rules'\nimport type {\n StorefrontCommerceMode,\n StorefrontConfig,\n StorefrontDiscountConfig,\n StorefrontEnquiryConfig,\n StorefrontImageLoadingConfig,\n StorefrontRouteChrome,\n StorefrontRouteKind,\n StorefrontSearchConfig,\n} from './config'\nimport type { StorefrontTheme } from '../lib/theme'\nimport type { HomeConfig, NavLink, FooterConfig } from '../blocks/sections'\nimport type { StorefrontPagesConfig } from '../blocks/page-blocks'\nimport type { StorefrontSlots } from '../extend/slots'\nimport type { StorefrontAuthConfig } from '../data/auth'\n\n// ---------------------------------------------------------------------------\n// Store Document v1 — the section vocabulary.\n//\n// `fayz.store.json` is the serializable form of a whole storefront: every\n// StorefrontConfig field either lives in a section here as data, or is\n// referenced from the `code` section by a registered handle name. The document\n// plus the handle registry reconstitutes the store; nothing is restored from\n// an in-memory side channel.\n//\n// Per-SECTION schema version, following WooCommerce Blueprint's\n// `get_schema(int $version)` (packages/php/blueprint/src/Steps/Step.php:24-36):\n// each top-level section carries its own `version`, so the commerce section\n// can evolve without invalidating a stored theme section and vice versa. A\n// version this module does not know is a hard error naming the supported set.\n//\n// This is a LEAF module: types, field specs and enum vocabularies only, so the\n// exporter, the validator and the describer can all import it without cycles.\n// ---------------------------------------------------------------------------\n\nexport const STORE_DOCUMENT_KIND = 'fayz.store'\n\n// --- Enum vocabularies, as runtime values -------------------------------------\n// Each mirrors a type union elsewhere; the `satisfies` + exhaustiveness pair\n// makes it a compile error for the two to drift.\n\nexport const STORE_COMMERCE_MODES = ['checkout', 'catalog', 'enquiry', 'delivery'] as const satisfies readonly StorefrontCommerceMode[]\ntype MissingCommerceMode = Exclude<StorefrontCommerceMode, (typeof STORE_COMMERCE_MODES)[number]>\nconst _commerceModesExhaustive: [MissingCommerceMode] extends [never] ? true : never = true\nvoid _commerceModesExhaustive\n\n// Same exhaustiveness guard as the commerce modes above: this list is what the\n// document validator accepts, and it had already drifted once — a mode the type\n// allows but this array omits is rejected at load with no useful message.\ntype StorePaymentMode = NonNullable<NonNullable<StorefrontConfig['payments']>['mode']>\nexport const STORE_PAYMENT_MODES = ['mock', 'pix-mercadopago', 'gateway'] as const satisfies readonly StorePaymentMode[]\ntype MissingPaymentMode = Exclude<StorePaymentMode, (typeof STORE_PAYMENT_MODES)[number]>\nconst _paymentModesExhaustive: [MissingPaymentMode] extends [never] ? true : never = true\nvoid _paymentModesExhaustive\nexport const STORE_PAYMENT_METHOD_KINDS = [\n 'pix',\n 'credit_card',\n 'debit_card',\n 'boleto',\n 'cash',\n 'other',\n] as const satisfies readonly PaymentMethodKind[]\ntype MissingPaymentKind = Exclude<PaymentMethodKind, (typeof STORE_PAYMENT_METHOD_KINDS)[number]>\nconst _paymentKindsExhaustive: [MissingPaymentKind] extends [never] ? true : never = true\nvoid _paymentKindsExhaustive\n\ntype ConfiguredBackendProvider = NonNullable<NonNullable<StorefrontConfig['backend']>['provider']>\nexport const STORE_BACKEND_PROVIDERS = ['mock', 'fayz-api', 'fayz-shop', 'custom'] as const satisfies readonly ConfiguredBackendProvider[]\ntype MissingBackendProvider = Exclude<ConfiguredBackendProvider, (typeof STORE_BACKEND_PROVIDERS)[number]>\nconst _backendProvidersExhaustive: [MissingBackendProvider] extends [never] ? true : never = true\nvoid _backendProvidersExhaustive\n\nexport const STORE_ROUTE_KINDS = [\n 'home',\n 'catalog',\n 'product',\n 'checkout',\n 'account',\n 'order',\n 'custom',\n] as const satisfies readonly StorefrontRouteKind[]\ntype MissingRouteKind = Exclude<StorefrontRouteKind, (typeof STORE_ROUTE_KINDS)[number]>\nconst _routeKindsExhaustive: [MissingRouteKind] extends [never] ? true : never = true\nvoid _routeKindsExhaustive\n\nexport const STORE_ROUTE_CHROMES = ['default', 'minimal', 'focused'] as const satisfies readonly StorefrontRouteChrome[]\ntype MissingRouteChrome = Exclude<StorefrontRouteChrome, (typeof STORE_ROUTE_CHROMES)[number]>\nconst _routeChromesExhaustive: [MissingRouteChrome] extends [never] ? true : never = true\nvoid _routeChromesExhaustive\n\nexport const STORE_THEME_RADII = ['none', 'soft', 'round', 'pill'] as const\n\n// --- Section shapes -----------------------------------------------------------\n\ninterface StoreSectionBase {\n /** This section's own schema version — sections evolve independently. */\n version: number\n}\n\n/** Identity: who the store is. The only mandatory section. */\nexport interface StoreIdentitySection extends StoreSectionBase {\n name: string\n /** ISO 4217 — default 'BRL'. */\n currency?: string\n /** Intl locale — default 'pt-BR'. */\n locale?: string\n}\n\n/** Visual identity — StorefrontTheme, spread into the section. */\nexport interface StoreThemeSection extends StoreSectionBase, StorefrontTheme {}\n\n/** Commercial behavior: mode, money, offers. */\nexport interface StoreCommerceSection extends StoreSectionBase {\n commerceMode?: StorefrontCommerceMode\n shipping?: StorefrontConfig['shipping']\n payments?: StorefrontConfig['payments']\n discounts?: StorefrontDiscountConfig[]\n enquiry?: StorefrontEnquiryConfig\n features?: StorefrontConfig['features']\n}\n\n/** What the shopper sees: composed pages, slots, chrome. `footer` here holds\n * only the serializable part — a non-string `credit` node moves to\n * `code.footerCredit`. */\nexport interface StorePresentationSection extends StoreSectionBase {\n announcement?: string\n /** Text logo. A JSX logo is code — it lives at `code.logo`. */\n logo?: string\n home?: HomeConfig\n pages?: StorefrontPagesConfig\n slots?: StorefrontSlots\n nav?: NavLink[]\n footer?: FooterConfig\n imageLoading?: StorefrontImageLoadingConfig\n catalogFacets?: StorefrontConfig['catalogFacets']\n productSpecs?: StorefrontConfig['productSpecs']\n /** Header search knobs. `renderSuggestion` is code — it lives at\n * `code.searchRenderSuggestion`. */\n search?: Omit<StorefrontSearchConfig, 'renderSuggestion'>\n}\n\n/** Long-form content: legal/institutional pages and store-supplied reviews. */\nexport interface StoreContentSection extends StoreSectionBase {\n legal?: StorefrontConfig['legal']\n reviews?: StorefrontConfig['reviews']\n}\n\n/** The mock catalog seed (products/categories/discounts). */\nexport interface StoreCatalogSection extends StoreSectionBase, MockShopSeed {}\n\n/** Rule-engine promotions (spine M6): serializable Promotion values —\n * eligibility rules + application method, attributes drawn from the\n * rule_attribute vocabulary. \"Buy 3 pay 2\" and \"REVENDA10 = 10% off\" are\n * both entries here, as pure data. */\nexport interface StorePromotionsSection extends StoreSectionBase {\n promotions?: Promotion[]\n}\n\n/** Custom entity declarations (spine M4): the defineEntity inputs, keyed by\n * entity key. Pure data — hydration re-declares them through defineEntity,\n * which re-derives the schema, storage, RLS and loaders from the same input. */\nexport interface StoreEntitiesSection extends StoreSectionBase {\n definitions?: Record<string, EntityDeclarationInput>\n}\n\n/** Backend descriptor. The deprecated supabase fields ride along so a legacy\n * config still round-trips losslessly; new stores use `auth.supabase`. */\nexport interface StoreBackendSection extends StoreSectionBase {\n provider?: ConfiguredBackendProvider\n url?: string\n /** @deprecated legacy StorefrontConfig field, kept for lossless round-trip. */\n supabaseUrl?: string\n /** @deprecated legacy StorefrontConfig field, kept for lossless round-trip. */\n supabaseAnonKey?: string\n}\n\n/** Customer auth, when it is expressible as data ('mock' / 'supabase' + urls).\n * An auth config carrying code (an AuthAdapter object, a supabase client)\n * moves whole to `code.auth`. */\nexport interface StoreAuthSection extends StoreSectionBase, StorefrontAuthConfig {}\n\n/** A custom route whose component is referenced by handle name. */\nexport interface StoreCodeRouteRef {\n id: string\n path: string\n kind?: StorefrontRouteKind\n chrome?: StorefrontRouteChrome\n /** Handle name of the route component. */\n component: string\n}\n\n/**\n * The code sidecar: every config field that holds code, referenced by the\n * handle NAME it was registered under. Hydration resolves these through the\n * handle registry — an unknown name is a hard error naming the valid set (I2),\n * never a silent drop.\n */\nexport interface StoreCodeSection extends StoreSectionBase {\n /** Handle → React.ReactNode (JSX logo). */\n logo?: string\n /** Handle → ShopProvider. */\n provider?: string\n /** Handle → StorefrontAuthConfig carrying code. */\n auth?: string\n /** Handle → React.ReactNode rendered as the footer credit line. */\n footerCredit?: string\n /** Handle → the `(product) => ReactNode` renderer for a search suggestion. */\n searchRenderSuggestion?: string\n /** Component-slot name → handle of its ComponentOverride. */\n components?: Record<string, string>\n routes?: StoreCodeRouteRef[]\n}\n\n/** Store Document v1 — the serializable form of a whole storefront. */\nexport interface StoreDocument {\n $kind: typeof STORE_DOCUMENT_KIND\n store: StoreIdentitySection\n theme?: StoreThemeSection\n commerce?: StoreCommerceSection\n presentation?: StorePresentationSection\n content?: StoreContentSection\n catalog?: StoreCatalogSection\n entities?: StoreEntitiesSection\n promotions?: StorePromotionsSection\n backend?: StoreBackendSection\n auth?: StoreAuthSection\n code?: StoreCodeSection\n}\n\nexport type StoreSectionName = Exclude<keyof StoreDocument, '$kind'>\n\n// --- Field specs: one declaration → validator + JSON Schema -------------------\n// Same pattern as block `settings` → `propsSchema` (block-schema.ts): the spec\n// is authored once and compiled, so the validator and the schema an agent reads\n// cannot drift apart. Coarse on purpose — deep shapes (theme colors, block\n// trees) are checked by the dedicated validators, not restated here.\n\n/**\n * A field that is on its way out (spine I10).\n *\n * The section VERSION is what makes this mechanical rather than advisory:\n * while the section is at a version below `removedAtVersion` the field is\n * accepted and the store keeps working; a document that has been through the\n * codemod carries the higher version, and at that version the field is a hard\n * validation error naming `replacement` (I2). That is what lets one SDK serve\n * both a migrated and an unmigrated fleet without a flag.\n */\nexport interface StoreFieldDeprecation {\n /** Row id in @fayz-ai/sdk's deprecation registry — the single source of the\n * version window, the shim prose and the codemod id. */\n id: string\n /** Section version at which this field stops being accepted. */\n removedAtVersion: number\n /** Document path to write instead. */\n replacement: string\n}\n\nexport interface StoreFieldSpec {\n type: 'string' | 'number' | 'boolean' | 'object' | 'array'\n description: string\n required?: boolean\n enum?: readonly string[]\n /** Present when the field is deprecated. See {@link StoreFieldDeprecation}. */\n deprecated?: StoreFieldDeprecation\n}\n\nexport interface StoreSectionSpec {\n description: string\n /** Versions of this section this SDK understands, ascending. */\n versions: readonly number[]\n fields: Record<string, StoreFieldSpec>\n}\n\nconst f = (\n type: StoreFieldSpec['type'],\n description: string,\n extra: Partial<StoreFieldSpec> = {},\n): StoreFieldSpec => ({ type, description, ...extra })\n\nexport const STORE_SECTIONS: Record<StoreSectionName, StoreSectionSpec> = {\n store: {\n description: 'Store identity: name, currency, locale.',\n versions: [1],\n fields: {\n name: f('string', 'Store display name (header, page title).', { required: true }),\n currency: f('string', \"ISO 4217 currency code — default 'BRL'.\"),\n locale: f('string', \"Intl locale for money/date formatting — default 'pt-BR'.\"),\n },\n },\n theme: {\n description: 'Visual identity: colors, fonts, radius, header/card personality.',\n versions: [1],\n fields: {\n name: f('string', 'Theme name.', { required: true }),\n colors: f('object', 'HSL token triplets (background, primary, …).'),\n font: f('object', 'Google Fonts pairing (heading, body, display, serif).'),\n radius: f('string', 'Corner radius scale.', { enum: STORE_THEME_RADII }),\n header: f('object', 'Header treatment (variant, uppercaseNav, search).'),\n productCard: f('object', 'Card style and image aspect.'),\n uppercaseButtons: f('boolean', 'Uppercase CTA buttons with letter-spacing.'),\n spacing: f('object', \"Spacing scale (key → CSS length), emitted as --sf-space-<key>. e.g. {sm:'8px', md:'16px'}.\"),\n typeScale: f('object', \"Type scale (key → CSS font-size), emitted as --sf-text-<key>. e.g. {body:'1rem', h1:'clamp(40px,6vw,66px)'}.\"),\n breakpoints: f('object', \"Layout breakpoints (key → CSS length), emitted as --sf-breakpoint-<key> for JS/generated-style consumers.\"),\n motion: f('object', \"Motion tokens (key → duration or easing), emitted as --sf-motion-<key>. e.g. {fast:'150ms', reveal:'cubic-bezier(0.22,1,0.36,1)'}.\"),\n tokens: f('object', 'Free-form brand-token passthrough, emitted verbatim as CSS custom properties.'),\n },\n },\n commerce: {\n description: 'Commercial behavior: mode, shipping, payments, discounts, enquiry, feature toggles.',\n // v2 = the legacy `discounts` coupon list has been migrated onto the rule\n // engine (codemod commerce.discounts-to-promotions). Both versions are\n // understood, which is the whole point: the fleet migrates store by store.\n versions: [1, 2],\n fields: {\n commerceMode: f('string', 'Checkout-first, catalog-only browsing, or product enquiry.', {\n enum: STORE_COMMERCE_MODES,\n }),\n shipping: f('object', 'Flat rate and free-above threshold.'),\n payments: f('object', 'Payment mode and offered methods.'),\n discounts: f('array', 'DEPRECATED — store-level discount codes ({code, percent, title?}). Use promotions.promotions.', {\n deprecated: {\n id: 'storefront.commerce.discounts',\n removedAtVersion: 2,\n replacement: 'promotions.promotions',\n },\n }),\n enquiry: f('object', 'Product enquiry behavior for catalog/enquiry stores.'),\n features: f('object', 'Feature toggles (discounts, accounts, cart, checkout).'),\n },\n },\n presentation: {\n description: 'What the shopper sees: composed pages, slots, nav, footer, chrome.',\n versions: [1],\n fields: {\n announcement: f('string', 'Promo message above the header.'),\n logo: f('string', 'Text logo. A JSX logo is code and lives at code.logo.'),\n home: f('object', 'Home page blueprint (legacy short form of pages.home).'),\n pages: f('object', 'Pages composed from blocks, keyed by page kind.'),\n slots: f('object', 'Blocks grafted into named positions inside SDK pages.'),\n nav: f('array', 'Header nav links ({label, to}).'),\n footer: f('object', 'Footer content (about, contact, social, labels).'),\n imageLoading: f('object', 'Global image reveal behavior.'),\n catalogFacets: f(\n 'array',\n 'Catalog refinements over product.metadata ({key, label, values[]}), rendered in the filters panel and mirrored into ?<key>=<value>.',\n ),\n productSpecs: f(\n 'object',\n 'PDP specification table rules: `exclude` hides metadata keys, `labels` renames the rest.',\n ),\n search: f(\n 'object',\n \"Header search: mode ('inline' live filter, the default, or 'overlay'), plus placeholder, resultsPath, suggestionsLimit, minChars and labels. A custom suggestion renderer is code and lives at code.searchRenderSuggestion.\",\n ),\n },\n },\n content: {\n description: 'Long-form content: legal/institutional pages, product reviews.',\n versions: [1],\n fields: {\n legal: f('object', 'Privacy / terms / returns page text.'),\n reviews: f(\n 'object',\n 'Store-supplied product reviews ({items, enabled, emptyText}). Nothing is invented — with no items the PDP renders an honest empty state.',\n ),\n },\n },\n catalog: {\n description: 'Mock catalog seed for stores without a live backend.',\n versions: [1],\n fields: {\n products: f('array', 'Seed products.'),\n categories: f('array', 'Seed categories.'),\n discounts: f('array', 'Seed discounts.'),\n promotions: f('array', 'Seed rule-engine promotions for the mock provider. Prefer the top-level promotions section.'),\n },\n },\n entities: {\n description: 'Custom entity declarations (defineEntity inputs), keyed by entity key.',\n versions: [1],\n fields: {\n definitions: f('object', 'Entity key → declaration ({fields, scope, access, indexes, …}).'),\n },\n },\n promotions: {\n description: 'Rule-engine promotions: eligibility rules + application method, as pure data (spine M6).',\n versions: [1],\n fields: {\n promotions: f('array', 'Promotions ({id, code?, isAutomatic?, rules?, applicationMethod}). Rule attributes come from the rule_attribute vocabulary.'),\n },\n },\n backend: {\n description: 'Backend descriptor: which provider serves the store.',\n // v2 = the legacy supabaseUrl/supabaseAnonKey pair has moved to\n // auth.supabase (codemod backend.supabase-to-auth).\n versions: [1, 2],\n fields: {\n provider: f('string', 'Backend provider family.', { enum: STORE_BACKEND_PROVIDERS }),\n url: f('string', 'Backend URL, when the provider needs one.'),\n supabaseUrl: f('string', 'DEPRECATED legacy field, kept for lossless round-trip. Use auth.supabase.url.', {\n deprecated: {\n id: 'storefront.backend.supabaseUrl',\n removedAtVersion: 2,\n replacement: 'auth.supabase.url',\n },\n }),\n supabaseAnonKey: f('string', 'DEPRECATED legacy field, kept for lossless round-trip. Use auth.supabase.anonKey.', {\n deprecated: {\n id: 'storefront.backend.supabaseAnonKey',\n removedAtVersion: 2,\n replacement: 'auth.supabase.anonKey',\n },\n }),\n },\n },\n auth: {\n description: 'Customer auth, when expressible as data. Code-bearing auth lives at code.auth.',\n versions: [1],\n fields: {\n adapter: f('string', \"Adapter id ('mock' | 'supabase').\"),\n provider: f('string', \"Provider id ('mock' | 'supabase').\"),\n routes: f('object', 'Auth route overrides.'),\n supabase: f('object', 'Supabase connection (url, anonKey, callback urls).'),\n },\n },\n code: {\n description: 'The code sidecar: config fields that hold code, referenced by registered handle name.',\n versions: [1],\n fields: {\n logo: f('string', 'Handle of the JSX logo node.'),\n provider: f('string', 'Handle of the explicit ShopProvider.'),\n auth: f('string', 'Handle of a code-bearing auth config.'),\n footerCredit: f('string', 'Handle of the footer credit node.'),\n searchRenderSuggestion: f('string', 'Handle of the custom search-suggestion renderer.'),\n components: f('object', 'Component-slot name → handle of its override.'),\n routes: f('array', 'Custom routes; each component is a handle name.'),\n },\n },\n}\n\nexport const STORE_SECTION_NAMES = Object.keys(STORE_SECTIONS) as StoreSectionName[]\n\n/** Compile a section's field spec to JSON Schema — the same one-declaration\n * principle as `settingsToJsonSchema` (I1). */\nexport function sectionToJsonSchema(name: StoreSectionName): JsonSchema {\n const spec = STORE_SECTIONS[name]\n const properties: Record<string, JsonSchema> = {\n version: {\n type: 'integer',\n description: `Schema version of the ${name} section. Supported: ${spec.versions.join(', ')}.`,\n enum: [...spec.versions],\n },\n }\n const required: string[] = ['version']\n for (const [field, fieldSpec] of Object.entries(spec.fields)) {\n const node: JsonSchema = { type: fieldSpec.type, description: fieldSpec.description }\n if (fieldSpec.enum) node.enum = [...fieldSpec.enum]\n if (fieldSpec.deprecated) {\n // `deprecated` is the JSON Schema 2019-09 keyword, so generic tooling\n // understands it; the x- pair carries the registry id and the exact\n // replacement path, which is what an agent needs to fix it (I2).\n node.deprecated = true\n node['x-fayz-deprecation'] = fieldSpec.deprecated.id\n node['x-fayz-replacement'] = fieldSpec.deprecated.replacement\n node['x-fayz-removed-at-section-version'] = fieldSpec.deprecated.removedAtVersion\n }\n properties[field] = node\n if (fieldSpec.required) required.push(field)\n }\n return {\n type: 'object',\n description: spec.description,\n properties,\n required,\n }\n}\n\n// --- Shared helpers -----------------------------------------------------------\n\n/**\n * True when a value survives JSON serialization unchanged: the test that\n * routes a config field into a data section versus the code sidecar. React\n * elements (`$$typeof`), functions, class instances (providers, adapters,\n * supabase clients) all fail it.\n */\nexport function isJsonValue(value: unknown): boolean {\n if (value === null) return true\n const t = typeof value\n if (t === 'string' || t === 'number' || t === 'boolean') return true\n if (Array.isArray(value)) return value.every(isJsonValue)\n if (t === 'object') {\n const record = value as Record<string, unknown>\n if ('$$typeof' in record) return false // React element\n const proto = Object.getPrototypeOf(record)\n if (proto !== Object.prototype && proto !== null) return false // class instance\n // `undefined` property values are allowed: JSON drops the key, which is\n // semantically the same config.\n return Object.values(record).every((v) => v === undefined || isJsonValue(v))\n }\n return false\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Copy of `obj` without `undefined`-valued keys, so a document holds exactly\n * what JSON can carry and object equality means what it looks like. */\nexport function compact<T extends Record<string, unknown>>(obj: T): T {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) out[key] = value\n }\n return out as T\n}\n","import type React from 'react'\nimport type { Category, CreateProductEnquiryInput, Product, ProductEnquiry, ProductImage } from '@fayz-ai/shop/types'\nimport type { ProductOptionGroup, ProductOptionSelection } from '../data/product-options'\nimport type { ResolvedStorefrontConfig, StorefrontCommerceMode, StorefrontRouteChrome } from '../document/config'\nimport type { MediaCarouselItem } from '../blocks/sections'\nimport type { CartState } from '../stores/cart.store'\nimport type { ComponentOverride } from './component-override'\n\nexport interface StorefrontComponentBaseProps {\n config: ResolvedStorefrontConfig\n commerceMode: StorefrontCommerceMode\n className?: string\n testId?: string\n}\n\nexport interface StorefrontActions {\n navigateTo: (to: string) => void\n addToCart: (product: Product, quantity?: number, options?: ProductOptionSelection) => void\n openCart: () => void\n closeCart: () => void\n createProductEnquiry: (input: CreateProductEnquiryInput) => Promise<ProductEnquiry>\n}\n\n/**\n * Which photo the CARD shows — the grid-side counterpart of\n * {@link ProductGalleryOrder}.\n *\n * primary the first `is_primary` row, else the first row (the default;\n * byte-identical to what the card has always done)\n * position the lowest `sortOrder`, ties broken by image id\n *\n * `position` exists because `is_primary` is not a unique constraint: artorious\n * carries products with TWO primary rows, which made the card's pick depend on\n * PostgREST's tie order — the same card could show a different photo between\n * two loads. The gallery got `order` in M2; the card had no equivalent and a\n * store fork was the only way to sort by position.\n */\nexport type ProductCardImageOrder = 'primary' | 'position'\n\nexport interface ProductCardProps extends StorefrontComponentBaseProps {\n product: Product\n actions: Pick<StorefrontActions, 'navigateTo' | 'addToCart' | 'openCart'>\n /** Defaults to 'primary' — see {@link ProductCardImageOrder}. */\n imageOrder?: ProductCardImageOrder\n}\n\nexport interface ProductDetailProps extends StorefrontComponentBaseProps {\n product: Product\n primaryImage?: ProductImage\n optionGroups: ProductOptionGroup[]\n selectedOptions: ProductOptionSelection\n setSelectedOptions: React.Dispatch<React.SetStateAction<ProductOptionSelection>>\n quantity: number\n setQuantity: React.Dispatch<React.SetStateAction<number>>\n soldOut: boolean\n lowStock: boolean\n actions: Pick<StorefrontActions, 'addToCart' | 'createProductEnquiry' | 'navigateTo'>\n addToCart: () => void\n openEnquiry: () => void\n}\n\n/**\n * Which photo leads the gallery.\n *\n * primary the merchant's pick: isPrimary first, then sortOrder ascending (default)\n * position sortOrder ascending, ignoring the primary flag\n * newest sortOrder descending — the most recently added photo leads\n *\n * `newest` exists because of a real fork: artorious reimplemented the entire\n * 158-line gallery to change ONLY this rule (its Supabase rows carried two\n * conflicting is_primary flags, so sort_order was the only trustworthy signal).\n * A props-only override (`components.ProductGallery.props.order`) now does it.\n */\nexport type ProductGalleryOrder = 'primary' | 'position' | 'newest'\n\nexport interface ProductGalleryProps extends StorefrontComponentBaseProps {\n product: Product\n images: ProductImage[]\n primaryImage?: ProductImage\n order?: ProductGalleryOrder\n}\n\nexport interface ProductPriceProps extends StorefrontComponentBaseProps {\n product: Product\n value: number\n compareAt?: number | null\n}\n\nexport interface ProductActionsProps extends StorefrontComponentBaseProps {\n product: Product\n quantity: number\n setQuantity: React.Dispatch<React.SetStateAction<number>>\n soldOut: boolean\n actions: Pick<StorefrontActions, 'addToCart' | 'createProductEnquiry' | 'navigateTo'>\n addToCart: () => void\n openEnquiry: () => void\n}\n\nexport interface ProductEnquiryFormContractProps extends StorefrontComponentBaseProps {\n product: Product\n onSuccess?: () => void\n}\n\nexport interface CategoryCardProps extends StorefrontComponentBaseProps {\n category: Category\n actions: Pick<StorefrontActions, 'navigateTo'>\n}\n\nexport interface CollectionSectionProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n products: Product[]\n category?: Category\n children?: React.ReactNode\n}\n\nexport interface HeroSectionContractProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n eyebrow?: string\n image?: string\n cta?: string\n href?: string\n children?: React.ReactNode\n}\n\nexport interface MediaCarouselProps extends StorefrontComponentBaseProps {\n items: MediaCarouselItem[]\n height?: 'medium' | 'tall' | 'screen'\n autoplayMs?: number\n overlay?: 'dark' | 'soft' | 'none'\n}\n\nexport interface ProductSliderProps extends StorefrontComponentBaseProps {\n title: string\n subtitle?: string\n eyebrow?: string\n filter?: 'sale' | 'new' | 'all'\n categoryName?: string\n collection?: string\n limit?: number\n cta?: string\n href?: string\n}\n\nexport interface StorefrontChromeProps extends StorefrontComponentBaseProps {\n children?: React.ReactNode\n /**\n * Quanta moldura esta rota pediu. Um cabeçalho customizado que ignore isto\n * continua funcionando como antes — por isso é opcional — mas quem honra\n * `minimal` recolhe a navegação de marketing e deixa marca, busca e carrinho.\n */\n chrome?: StorefrontRouteChrome\n}\n\nexport interface StorefrontStateProps extends StorefrontComponentBaseProps {\n title?: string\n message?: string\n children?: React.ReactNode\n}\n\n/**\n * Extra content rendered inside CartDrawer's footer, right after the\n * \"Finalizar compra\" button — e.g. an alternative checkout path like\n * \"Finalizar via WhatsApp\". Unlike every other entry in\n * StorefrontComponents, this isn't a whole-component replacement:\n * CartDrawer is always the SDK's own, this only adds optional content\n * inside it. Only rendered when the cart has lines (same condition as the\n * checkout button itself).\n */\nexport interface CartDrawerFooterExtraProps extends StorefrontComponentBaseProps {\n cart: CartState\n}\n\n/**\n * Code-level component replacements.\n *\n * Each entry accepts either the component (what stores write today) or\n * `{ component?, props? }`. Passing only `props` keeps the SDK component and\n * forces some of its props — which is what four of five customizing stores\n * actually wanted when they replaced a whole card instead.\n *\n * Every field takes the union rather than only the two surfaces stores have\n * overridden so far: \"why can I pass props to ProductCard but not CategoryCard\"\n * is a worse surface than one extra type.\n */\nexport interface StorefrontComponents {\n ProductCard?: ComponentOverride<ProductCardProps>\n ProductDetail?: ComponentOverride<ProductDetailProps>\n ProductGallery?: ComponentOverride<ProductGalleryProps>\n ProductPrice?: ComponentOverride<ProductPriceProps>\n ProductActions?: ComponentOverride<ProductActionsProps>\n ProductEnquiryForm?: ComponentOverride<ProductEnquiryFormContractProps>\n CategoryCard?: ComponentOverride<CategoryCardProps>\n CollectionSection?: ComponentOverride<CollectionSectionProps>\n HeroSection?: ComponentOverride<HeroSectionContractProps>\n MediaCarousel?: ComponentOverride<MediaCarouselProps>\n ProductSlider?: ComponentOverride<ProductSliderProps>\n Header?: ComponentOverride<StorefrontChromeProps>\n Footer?: ComponentOverride<StorefrontChromeProps>\n Shell?: ComponentOverride<StorefrontChromeProps>\n EmptyState?: ComponentOverride<StorefrontStateProps>\n LoadingState?: ComponentOverride<StorefrontStateProps>\n ErrorState?: ComponentOverride<StorefrontStateProps>\n CartDrawerFooterExtra?: ComponentOverride<CartDrawerFooterExtraProps>\n}\n\n/**\n * The override surface as a runtime value, for validators and catalogs: a\n * store document referencing an unknown component slot must be told the valid\n * set (I2), and a type alone cannot say it at runtime. The `satisfies` +\n * exhaustiveness pair keeps this list impossible to leave stale when a key is\n * added to {@link StorefrontComponents}.\n */\nexport const STOREFRONT_COMPONENT_KEYS = [\n 'ProductCard',\n 'ProductDetail',\n 'ProductGallery',\n 'ProductPrice',\n 'ProductActions',\n 'ProductEnquiryForm',\n 'CategoryCard',\n 'CollectionSection',\n 'HeroSection',\n 'MediaCarousel',\n 'ProductSlider',\n 'Header',\n 'Footer',\n 'Shell',\n 'EmptyState',\n 'LoadingState',\n 'ErrorState',\n 'CartDrawerFooterExtra',\n] as const satisfies readonly (keyof StorefrontComponents)[]\ntype MissingComponentKey = Exclude<keyof StorefrontComponents, (typeof STOREFRONT_COMPONENT_KEYS)[number]>\nconst _componentKeysExhaustive: [MissingComponentKey] extends [never] ? true : never = true\nvoid _componentKeysExhaustive\n","import {\n blockRegistry,\n checkBlockConstraints,\n getBlockMeta,\n listHandles,\n hasHandle,\n loaderRegistry,\n listLoaders,\n isLoaderParamRef,\n isLoaderPropRef,\n ENTITY_FIELD_TYPES,\n RESERVED_ENTITY_FIELDS,\n listEntityDeclarations,\n} from '@fayz-ai/core'\nimport type { BlockSetting } from '@fayz-ai/core'\nimport {\n APPLICATION_METHOD_ALLOCATIONS,\n APPLICATION_METHOD_TARGET_TYPES,\n APPLICATION_METHOD_TYPES,\n PROMOTION_STATUSES,\n PROMOTION_TYPES,\n RULE_OPERATORS,\n hasRuleAttribute,\n listRuleAttributeKeys,\n resolveRuleAttribute,\n} from '@fayz-ai/shop/rules'\nimport { registerStorefrontBlocks } from '../blocks/registry'\nimport { routePathParams, toBlockNodes } from '../blocks/page-blocks'\nimport type { StorefrontBlockLike } from '../blocks/page-blocks'\nimport { THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX } from '../lib/theme'\nimport { STOREFRONT_COMPONENT_KEYS } from '../extend/component-contracts'\nimport { STOREFRONT_SLOTS } from '../extend/slots'\nimport type { StorefrontSlotArea } from '../extend/slots'\nimport {\n STORE_DOCUMENT_KIND,\n STORE_SECTIONS,\n STORE_SECTION_NAMES,\n STORE_PAYMENT_MODES,\n STORE_PAYMENT_METHOD_KINDS,\n STORE_ROUTE_KINDS,\n STORE_ROUTE_CHROMES,\n isRecord,\n} from './sections'\nimport type { StoreSectionName } from './sections'\n\n// ---------------------------------------------------------------------------\n// validateStore — the gate between an authored document and a rendered store.\n//\n// I2 everywhere: an unknown id — section, field, page kind, block type, block\n// setting, slot, handle, component slot — is a hard error that NAMES the valid\n// set. The report is machine-readable on purpose: the AI corrects on `valid`,\n// not on prose. Silent failure is the single most expensive property for\n// AI-generated configuration, because the agent gets no signal to correct on\n// (spine doc §2, the Medusa widget-drop evidence).\n//\n// Errors only, no warnings channel: everything reported here misdescribes the\n// store. Advisory findings (a block placed off its declared surface, a missing\n// page body) stay with `checkPageBlocks`/`auditBlocks`, which already own the\n// warning vocabulary.\n// ---------------------------------------------------------------------------\n\nexport interface StoreValidationError {\n /** Dotted path into the document ('presentation.pages.home.blocks[2].type'). */\n path: string\n /** Stable machine-readable code ('unknown-block', 'unsupported-section-version', …). */\n code: string\n message: string\n /** The valid set, present on every unknown-id error — what the AI corrects on. */\n valid?: string[]\n}\n\nexport interface StoreValidationReport {\n ok: boolean\n errors: StoreValidationError[]\n}\n\nexport const STOREFRONT_PAGE_KINDS = ['home', 'catalog', 'product', 'collection', 'content'] as const\n\nconst STRUCTURAL_BLOCK_KEYS = new Set(['type', 'id', 'props', 'children', 'data'])\n\n/** The whole of a `data` need — what page-data reads, and therefore the whole\n * of what an author may write there. */\nconst DATA_NEED_KEYS = ['loader', 'params']\n\n/** The whole of a `code.routes[]` entry — what hydrateStore reads back. */\nconst CODE_ROUTE_KEYS = ['id', 'path', 'kind', 'chrome', 'component']\n\nconst SLOT_AREAS = [...new Set(STOREFRONT_SLOTS.map((slot) => slot.area))]\n\nfunction slotNamesFor(area: string): string[] {\n return STOREFRONT_SLOTS.filter((slot) => slot.area === area).map((slot) => slot.name)\n}\n\n/** Route params available to each singular page kind's `$param` bindings.\n * Content pages declare their own through their path pattern. */\nconst PAGE_KIND_PARAMS: Record<string, readonly string[]> = {\n home: [],\n catalog: [],\n product: ['slug'],\n collection: ['slug'],\n}\n\n/** Route params a slot AREA's trees may bind: slots render inside a page, so\n * only areas pinned to a param-carrying page see its params. */\nconst SLOT_AREA_PARAMS: Record<string, readonly string[]> = {\n productDetail: ['slug'],\n}\n\ntype Errors = StoreValidationError[]\n\n// The entity vocabulary the CURRENT validateStore call checks `entity`-typed\n// values against: everything registered (the app's defineEntity calls) plus\n// everything the document itself declares — a document is allowed to declare\n// an entity and place a block over it in the same file. Module state is safe\n// because validation is synchronous and reset on entry.\nlet knownEntities: Set<string> = new Set()\n\nfunction checkEntityRef(errors: Errors, path: string, value: unknown): void {\n if (typeof value !== 'string' || !value) return // type errors are reported by the generic leg\n if (!knownEntities.has(value)) {\n push(\n errors,\n path,\n 'unknown-entity',\n `entity \"${value}\" is not declared (defineEntity or the entities section)`,\n [...knownEntities].sort(),\n )\n }\n}\n\nfunction push(errors: Errors, path: string, code: string, message: string, valid?: readonly string[]): void {\n errors.push(valid ? { path, code, message, valid: [...valid] } : { path, code, message })\n}\n\n/** Prop keys of one authored block entry, honouring both authoring forms\n * (nested `{type, props}` and the flat StorefrontSection shape). */\nfunction blockPropKeys(entry: Record<string, unknown>): string[] {\n if ('props' in entry) {\n const props = entry.props\n return isRecord(props) ? Object.keys(props) : []\n }\n return Object.keys(entry).filter((key) => !STRUCTURAL_BLOCK_KEYS.has(key))\n}\n\n/** Who declares the settings a value is being judged against — so one walk can\n * speak the block vocabulary ('block \"seals\" declares no setting …') and the\n * loader vocabulary ('loader \"products.list\" declares no param …') without\n * either growing a second error style. */\ninterface SettingOwner {\n /** Message subject, already quoted: `block \"seals\"`, `loader \"products.list\"`. */\n subject: string\n /** What the owner declares: `setting` / `param`. */\n noun: string\n /** The unknown-key code this owner's top-level check already uses. */\n code: string\n}\n\n/**\n * Prop values against their declared settings, at EVERY depth.\n *\n * A `list` setting declares its item shape in `of`, and an item is just another\n * settings level: an unknown key inside one drops exactly like an unknown key\n * at the top — the block renders without it and nothing tells the author why.\n * That is the silent-drop failure the validator exists to end (I2), so the same\n * error is reported there, naming the valid set of THAT position, all the way\n * down through lists of lists.\n *\n * `labelPrefix` builds the dotted setting position the message names\n * (`items[].tone`), matching how `auditBlocks` already talks about `of:` items.\n * `valuesPath` stays the document path, so the report points at the offending\n * key and not at the declaration.\n */\nfunction validateSettingValues(\n errors: Errors,\n valuesPath: string,\n settings: readonly BlockSetting[],\n values: Record<string, unknown>,\n owner: SettingOwner,\n labelPrefix = '',\n): void {\n for (const setting of settings) {\n const value = values[setting.id]\n if (value === undefined) continue\n const valuePath = `${valuesPath}.${setting.id}`\n const label = `${labelPrefix}${setting.id}`\n if (setting.type === 'entity') {\n checkEntityRef(errors, valuePath, value)\n continue\n }\n // A list with no declared item shape accepts anything — the same rule\n // `settingsToJsonSchema` compiles. Nothing to name, so nothing to reject.\n if (setting.type !== 'list' || !setting.of?.length || !Array.isArray(value)) continue\n const of = setting.of\n const declared = collectSettingIds(of)\n value.forEach((item, index) => {\n // A non-object item is a type error, not an unknown key: prop TYPES are\n // not this validator's leg at any depth, so it stays out of the report.\n if (!isRecord(item)) return\n const itemPath = `${valuePath}[${index}]`\n for (const key of Object.keys(item)) {\n if (!declared.has(key)) {\n push(\n errors,\n `${itemPath}.${key}`,\n owner.code,\n `${owner.subject} declares no ${owner.noun} \"${label}[].${key}\"`,\n [...declared].sort(),\n )\n }\n }\n validateSettingValues(errors, itemPath, of, item, owner, `${label}[].`)\n })\n }\n}\n\n/**\n * A literal loader-param value against its declared setting. Bindings are\n * checked by the caller; this is the \"document-level constant\" leg.\n */\nfunction checkLiteralParam(\n errors: Errors,\n path: string,\n containerPath: string,\n loaderId: string,\n setting: BlockSetting,\n value: unknown,\n): void {\n const expected =\n setting.type === 'number' ? 'number' : setting.type === 'boolean' ? 'boolean' : setting.type === 'list' ? 'array' : 'string'\n const actual = Array.isArray(value) ? 'array' : typeof value\n if (actual !== expected) {\n push(\n errors,\n path,\n 'invalid-value',\n `loader \"${loaderId}\" param \"${setting.id}\" expects ${expected}, got ${actual}`,\n )\n return\n }\n if (setting.type === 'select' && setting.options?.length && typeof value === 'string') {\n const allowed = setting.options.map((option) => option.value)\n if (!allowed.includes(value)) {\n push(errors, path, 'invalid-value', `\"${value}\" is not a valid ${setting.id}`, allowed)\n }\n }\n if (setting.type === 'entity') checkEntityRef(errors, path, value)\n // A list-shaped param has the same nested position a block's list prop does,\n // so it gets the same walk — an unknown key inside a param's items is named\n // rather than dropped.\n if (setting.type === 'list') {\n validateSettingValues(\n errors,\n containerPath,\n [setting],\n { [setting.id]: value },\n { subject: `loader \"${loaderId}\"`, noun: 'param', code: 'unknown-loader-param' },\n )\n }\n}\n\n/**\n * One block entry's `data` declaration (I2 everywhere): the loader must exist,\n * every param must be declared by the loader's schema, every `$param` binding\n * must name a route param the page declares, every `$prop` binding a setting\n * the block declares, and every literal must fit the param's type.\n */\nfunction validateDataNeeds(\n errors: Errors,\n entryPath: string,\n blockType: string,\n value: unknown,\n declaredParams: readonly string[],\n): void {\n if (!isRecord(value)) {\n push(errors, `${entryPath}.data`, 'invalid-value', '`data` maps need names to {loader, params?}')\n return\n }\n const blockSettings = getBlockMeta(blockType)?.settings\n for (const [name, need] of Object.entries(value)) {\n const needPath = `${entryPath}.data.${name}`\n if (!isRecord(need) || typeof need.loader !== 'string' || !need.loader) {\n push(errors, needPath, 'invalid-value', 'a data need is {loader: string, params?: object}')\n continue\n }\n if (!loaderRegistry.has(need.loader)) {\n push(errors, `${needPath}.loader`, 'unknown-loader', `loader \"${need.loader}\" is not registered`, listLoaders())\n continue\n }\n // The need object itself is a CLOSED shape — page-data reads `loader` and\n // `params` and nothing else. A misspelt `parms` therefore drops the whole\n // param set and the block loads everything, which is the same silent drop\n // an unknown key anywhere else in the document is.\n for (const key of Object.keys(need)) {\n if (!DATA_NEED_KEYS.includes(key)) {\n push(errors, `${needPath}.${key}`, 'unknown-field', `a data need has no field \"${key}\"`, DATA_NEED_KEYS)\n }\n }\n if (need.params === undefined) continue\n if (!isRecord(need.params)) {\n push(errors, `${needPath}.params`, 'invalid-value', 'loader params are an object')\n continue\n }\n const loaderSettings = loaderRegistry.getEntry(need.loader)?.meta.settings\n const declaredLoaderParams = loaderSettings ? collectSettingIds(loaderSettings) : null\n for (const [param, paramValue] of Object.entries(need.params)) {\n const paramPath = `${needPath}.params.${param}`\n const setting = loaderSettings?.find((s) => s.id === param)\n if (declaredLoaderParams && !declaredLoaderParams.has(param)) {\n push(\n errors,\n paramPath,\n 'unknown-loader-param',\n `loader \"${need.loader}\" declares no param \"${param}\"`,\n [...declaredLoaderParams].sort(),\n )\n continue\n }\n if (isLoaderParamRef(paramValue)) {\n if (!declaredParams.includes(paramValue.$param)) {\n push(\n errors,\n paramPath,\n 'unbound-route-param',\n declaredParams.length\n ? `$param \"${paramValue.$param}\" is not a route param of this page`\n : `$param \"${paramValue.$param}\" cannot bind — this page declares no route params`,\n declaredParams,\n )\n }\n continue\n }\n if (isLoaderPropRef(paramValue)) {\n const settingIds = blockSettings ? collectSettingIds(blockSettings) : null\n if (settingIds && !settingIds.has(paramValue.$prop)) {\n push(\n errors,\n paramPath,\n 'unknown-prop-binding',\n `$prop \"${paramValue.$prop}\" is not a setting of block \"${blockType}\"`,\n [...settingIds].sort(),\n )\n }\n continue\n }\n if (setting) {\n checkLiteralParam(errors, paramPath, `${needPath}.params`, need.loader, setting, paramValue)\n }\n }\n }\n}\n\nfunction validateBlockList(\n errors: Errors,\n path: string,\n value: unknown,\n declaredParams: readonly string[],\n): void {\n if (!Array.isArray(value)) {\n push(errors, path, 'invalid-value', `expected an array of blocks, got ${typeof value}`)\n return\n }\n value.forEach((entry, index) => {\n const entryPath = `${path}[${index}]`\n if (!isRecord(entry)) {\n push(errors, entryPath, 'invalid-value', 'a block entry must be an object with a `type`')\n return\n }\n const type = entry.type\n if (typeof type !== 'string' || !type) {\n push(errors, `${entryPath}.type`, 'invalid-value', 'a block entry must declare a string `type`')\n return\n }\n if (!blockRegistry.has(type)) {\n push(\n errors,\n `${entryPath}.type`,\n 'unknown-block',\n `block \"${type}\" is not registered`,\n blockRegistry.ids().sort(),\n )\n return\n }\n const settings = getBlockMeta(type)?.settings\n if (settings) {\n const declared = collectSettingIds(settings)\n for (const key of blockPropKeys(entry)) {\n if (!declared.has(key)) {\n push(\n errors,\n `${entryPath}.props.${key}`,\n 'unknown-setting',\n `block \"${type}\" declares no setting \"${key}\"`,\n [...declared].sort(),\n )\n }\n }\n // Below the top level: `entity`-typed settings are semantic ids (I2) — a\n // block naming an undeclared entity WILL fail at render — and every\n // `list` item is judged against its declared `of` shape, so an unknown\n // key inside an item is named instead of silently dropped.\n const props = isRecord(entry.props) ? entry.props : entry\n validateSettingValues(errors, `${entryPath}.props`, settings, props, {\n subject: `block \"${type}\"`,\n noun: 'setting',\n code: 'unknown-setting',\n })\n }\n if ('data' in entry && entry.data !== undefined) {\n validateDataNeeds(errors, entryPath, type, entry.data, declaredParams)\n }\n if ('children' in entry && entry.children !== undefined) {\n validateBlockList(errors, `${entryPath}.children`, entry.children, declaredParams)\n }\n })\n}\n\n/**\n * One authored block tree: per-entry checks plus composition constraints.\n *\n * Constraints (parent, ancestor, allowMultiple) are a property of the WHOLE\n * tree, so they run once here — over the same normalized nodes the renderer\n * sees — and never inside the per-entry recursion, which would judge a child\n * list without its ancestry. Structural violations are errors: the renderer\n * will keep the block off the shopper's page, which means the document\n * misdescribes the store. Advisory findings (context) stay with\n * checkPageBlocks, which owns the warning vocabulary.\n */\nfunction validateBlockTree(\n errors: Errors,\n path: string,\n value: unknown,\n declaredParams: readonly string[] = [],\n): void {\n validateBlockList(errors, path, value, declaredParams)\n if (!Array.isArray(value)) return\n const nodes = toBlockNodes(value as StorefrontBlockLike[])\n for (const violation of checkBlockConstraints(nodes)) {\n push(errors, `${path}${violation.path}`, violation.rule, violation.detail, violation.valid)\n }\n}\n\nfunction collectSettingIds(settings: readonly BlockSetting[]): Set<string> {\n return new Set(settings.map((setting) => setting.id))\n}\n\n// --- Section validators -------------------------------------------------------\n\n// A token key must survive as a CSS custom-property suffix (`--sf-space-<key>`),\n// so it is slug-shaped. The value side stays a free string: CSS is the schema\n// there, and restating it would be a worse validator than the browser's.\nconst TOKEN_KEY = /^[a-zA-Z][a-zA-Z0-9-]*$/\n\nfunction validateTheme(errors: Errors, section: Record<string, unknown>): void {\n for (const field of THEME_SCALE_FIELDS) {\n const scale = section[field]\n if (scale === undefined) continue\n if (!isRecord(scale)) continue // wrong type already reported by the envelope\n for (const [key, value] of Object.entries(scale)) {\n const path = `theme.${field}.${key}`\n if (!TOKEN_KEY.test(key)) {\n push(\n errors,\n path,\n 'invalid-token-key',\n `\"${key}\" cannot become the CSS custom property ${THEME_SCALE_VAR_PREFIX[field]}-${key} — token keys match ${TOKEN_KEY}`,\n )\n }\n if (typeof value !== 'string') {\n push(errors, path, 'invalid-value', `a ${field} token is a CSS value string, got ${typeof value}`)\n }\n }\n }\n}\n\nfunction validateSectionEnvelope(\n errors: Errors,\n name: StoreSectionName,\n section: Record<string, unknown>,\n): boolean {\n const spec = STORE_SECTIONS[name]\n const version = section.version\n if (typeof version !== 'number' || !spec.versions.includes(version)) {\n push(\n errors,\n `${name}.version`,\n 'unsupported-section-version',\n `section \"${name}\" declares version ${JSON.stringify(version)}, which this SDK does not understand`,\n spec.versions.map(String),\n )\n return false\n }\n const fieldNames = Object.keys(spec.fields)\n for (const key of Object.keys(section)) {\n if (key === 'version') continue\n const fieldSpec = spec.fields[key]\n if (!fieldSpec) {\n push(errors, `${name}.${key}`, 'unknown-field', `section \"${name}\" has no field \"${key}\"`, fieldNames)\n continue\n }\n // A deprecated field is ACCEPTED while the section is below the version\n // that retires it — that is the shim (I10). At or past that version the\n // document has been through the codemod, so the field being back is a\n // hard error that names where it moved to (I2). One SDK therefore serves a\n // migrated and an unmigrated store without a flag.\n const deprecated = fieldSpec.deprecated\n if (deprecated && version >= deprecated.removedAtVersion) {\n push(\n errors,\n `${name}.${key}`,\n 'removed-field',\n `field \"${name}.${key}\" was removed at ${name} version ${deprecated.removedAtVersion} ` +\n `(deprecation ${deprecated.id}); this section declares version ${version}`,\n [deprecated.replacement],\n )\n continue\n }\n const value = section[key]\n const actual = Array.isArray(value) ? 'array' : typeof value\n if (actual !== fieldSpec.type) {\n push(\n errors,\n `${name}.${key}`,\n 'invalid-value',\n `field \"${name}.${key}\" expects ${fieldSpec.type}, got ${actual}`,\n )\n continue\n }\n if (fieldSpec.enum && typeof value === 'string' && !fieldSpec.enum.includes(value)) {\n push(\n errors,\n `${name}.${key}`,\n 'invalid-value',\n `\"${value}\" is not a valid ${name}.${key}`,\n fieldSpec.enum,\n )\n }\n }\n for (const [field, fieldSpec] of Object.entries(spec.fields)) {\n if (fieldSpec.required && section[field] === undefined) {\n push(errors, `${name}.${field}`, 'missing-field', `section \"${name}\" requires \"${field}\"`)\n }\n }\n return true\n}\n\nfunction validateCommerce(errors: Errors, section: Record<string, unknown>): void {\n const payments = section.payments\n if (isRecord(payments)) {\n if (payments.mode !== undefined) {\n if (typeof payments.mode !== 'string' || !(STORE_PAYMENT_MODES as readonly string[]).includes(payments.mode)) {\n push(\n errors,\n 'commerce.payments.mode',\n 'invalid-value',\n `\"${String(payments.mode)}\" is not a payment mode`,\n STORE_PAYMENT_MODES,\n )\n }\n }\n if (payments.methods !== undefined) {\n if (!Array.isArray(payments.methods)) {\n push(errors, 'commerce.payments.methods', 'invalid-value', 'payments.methods must be an array')\n } else {\n payments.methods.forEach((method, index) => {\n if (typeof method !== 'string' || !(STORE_PAYMENT_METHOD_KINDS as readonly string[]).includes(method)) {\n push(\n errors,\n `commerce.payments.methods[${index}]`,\n 'invalid-value',\n `\"${String(method)}\" is not a payment method`,\n STORE_PAYMENT_METHOD_KINDS,\n )\n }\n })\n }\n }\n }\n const discounts = section.discounts\n if (Array.isArray(discounts)) {\n discounts.forEach((discount, index) => {\n if (!isRecord(discount) || typeof discount.code !== 'string' || typeof discount.percent !== 'number') {\n push(\n errors,\n `commerce.discounts[${index}]`,\n 'invalid-value',\n 'a discount is {code: string, percent: number, title?: string}',\n )\n }\n })\n }\n}\n\n// A content-page slug becomes its default route (`/<slug>`), so it is url-shaped.\nconst CONTENT_SLUG = /^[a-z0-9][a-z0-9-]*$/\n\nfunction validateContentPages(errors: Errors, basePath: string, value: unknown): void {\n if (!isRecord(value)) {\n push(errors, basePath, 'invalid-value', 'pages.content maps slugs to {title?, path?, blocks: [...]}')\n return\n }\n const pathOwners = new Map<string, string>()\n for (const [slug, page] of Object.entries(value)) {\n const pagePath = `${basePath}.${slug}`\n if (!CONTENT_SLUG.test(slug)) {\n push(\n errors,\n pagePath,\n 'invalid-value',\n `\"${slug}\" cannot become the route \"/${slug}\" — content slugs match ${CONTENT_SLUG}`,\n )\n }\n if (!isRecord(page) || page.blocks === undefined) {\n push(errors, pagePath, 'invalid-value', 'a content page is {title?, path?, blocks: [...]}')\n continue\n }\n if (page.title !== undefined && typeof page.title !== 'string') {\n push(errors, `${pagePath}.title`, 'invalid-value', `title expects string, got ${typeof page.title}`)\n }\n let routePath = `/${slug}`\n if (page.path !== undefined) {\n if (typeof page.path !== 'string' || !page.path.startsWith('/')) {\n push(errors, `${pagePath}.path`, 'invalid-value', `path is an absolute route ('/${slug}'), got ${JSON.stringify(page.path)}`)\n } else {\n routePath = page.path\n }\n }\n // Two pages resolving to one route means one of them silently never\n // renders — exactly the class of failure this validator exists to end.\n const owner = pathOwners.get(routePath)\n if (owner) {\n push(\n errors,\n `${pagePath}.path`,\n 'duplicate-content-path',\n `content pages \"${owner}\" and \"${slug}\" both resolve to \"${routePath}\" — one of them can never render`,\n )\n } else {\n pathOwners.set(routePath, slug)\n }\n // A content page's path pattern is its param declaration (M3): blocks on\n // '/categoria/:slug' may bind { $param: 'slug' }; a param-less page's\n // blocks may bind nothing.\n validateBlockTree(errors, `${pagePath}.blocks`, page.blocks, routePathParams(routePath))\n }\n}\n\nfunction validatePresentation(errors: Errors, section: Record<string, unknown>): void {\n const home = section.home\n if (isRecord(home) && home.sections !== undefined) {\n validateBlockTree(errors, 'presentation.home.sections', home.sections)\n }\n\n const pages = section.pages\n if (isRecord(pages)) {\n const validKinds = [...STOREFRONT_PAGE_KINDS]\n for (const [kind, page] of Object.entries(pages)) {\n const pagePath = `presentation.pages.${kind}`\n if (!(validKinds as string[]).includes(kind)) {\n push(errors, pagePath, 'unknown-page-kind', `\"${kind}\" is not a composable page kind`, validKinds)\n continue\n }\n // `content` holds a MAP of editorial pages, not one page.\n if (kind === 'content') {\n validateContentPages(errors, pagePath, page)\n continue\n }\n if (!isRecord(page) || page.blocks === undefined) {\n push(errors, pagePath, 'invalid-value', 'a composed page is {blocks: [...]}')\n continue\n }\n validateBlockTree(errors, `${pagePath}.blocks`, page.blocks, PAGE_KIND_PARAMS[kind] ?? [])\n }\n }\n\n const slots = section.slots\n if (isRecord(slots)) {\n for (const [area, areaSlots] of Object.entries(slots)) {\n const areaPath = `presentation.slots.${area}`\n if (!(SLOT_AREAS as string[]).includes(area)) {\n push(errors, areaPath, 'unknown-slot-area', `\"${area}\" is not a slot area`, SLOT_AREAS)\n continue\n }\n if (!isRecord(areaSlots)) {\n push(errors, areaPath, 'invalid-value', 'a slot area maps slot names to block lists')\n continue\n }\n const validNames = slotNamesFor(area as StorefrontSlotArea)\n for (const [slotName, blocks] of Object.entries(areaSlots)) {\n const slotPath = `${areaPath}.${slotName}`\n if (!validNames.includes(slotName)) {\n push(errors, slotPath, 'unknown-slot', `\"${area}.${slotName}\" is not a slot`, validNames)\n continue\n }\n validateBlockTree(errors, slotPath, blocks, SLOT_AREA_PARAMS[area] ?? [])\n }\n }\n }\n}\n\nconst ENTITY_KEY_RE = /^[a-z][a-z0-9_]*$/\nconst ENTITY_FIELD_RE = /^[a-z][a-z0-9_]*$/\n\n/**\n * The entities section holds defineEntity INPUTS as data. Validation mirrors\n * what defineEntity enforces at registration — same rules, same valid sets —\n * so a document that validates clean is a document whose hydration cannot\n * throw. I2 on every id: field types, access levels, field references.\n */\nfunction validateEntitiesSection(errors: Errors, section: Record<string, unknown>): void {\n const definitions = section.definitions\n if (definitions === undefined || !isRecord(definitions)) return // envelope reported the type\n for (const [key, declaration] of Object.entries(definitions)) {\n const path = `entities.definitions.${key}`\n if (!ENTITY_KEY_RE.test(key)) {\n push(errors, path, 'invalid-value', `\"${key}\" is not a valid entity key — keys are snake_case`)\n }\n if (!isRecord(declaration) || !isRecord(declaration.fields) || Object.keys(declaration.fields).length === 0) {\n push(errors, path, 'invalid-value', 'an entity declaration is {fields: {<name>: {type, …}}, scope?, access?, indexes?}')\n continue\n }\n const fields = declaration.fields\n const fieldNames = Object.keys(fields)\n for (const [name, field] of Object.entries(fields)) {\n const fieldPath = `${path}.fields.${name}`\n if (!ENTITY_FIELD_RE.test(name)) {\n push(errors, fieldPath, 'invalid-value', `\"${name}\" is not a valid field name — fields are snake_case`)\n }\n if ((RESERVED_ENTITY_FIELDS as readonly string[]).includes(name)) {\n push(errors, fieldPath, 'invalid-value', `\"${name}\" is a structural record column`, RESERVED_ENTITY_FIELDS)\n continue\n }\n if (!isRecord(field) || typeof field.type !== 'string') {\n push(errors, fieldPath, 'invalid-value', 'a field is {type: <entity field type>, label?, required?, …}')\n continue\n }\n if (!(ENTITY_FIELD_TYPES as readonly string[]).includes(field.type)) {\n push(errors, `${fieldPath}.type`, 'unknown-entity-field-type', `\"${field.type}\" is not an entity field type`, ENTITY_FIELD_TYPES)\n continue\n }\n if (field.type === 'ref') {\n if (typeof field.entity !== 'string' || !field.entity) {\n push(errors, fieldPath, 'invalid-value', `a ref field names its target: {type: 'ref', entity: '<key>'}`)\n } else {\n checkEntityRef(errors, `${fieldPath}.entity`, field.entity)\n }\n }\n }\n const scope = declaration.scope\n if (scope !== undefined && scope !== 'tenant') {\n push(errors, `${path}.scope`, 'invalid-value', `\"${String(scope)}\" is not an entity scope`, ['tenant'])\n }\n const access = declaration.access\n if (access !== undefined) {\n if (!isRecord(access)) {\n push(errors, `${path}.access`, 'invalid-value', \"access is {read: 'public'|'staff', write: 'staff'}\")\n } else {\n if (access.read !== undefined && access.read !== 'public' && access.read !== 'staff') {\n push(errors, `${path}.access.read`, 'invalid-value', `\"${String(access.read)}\" is not a read access level`, ['public', 'staff'])\n }\n if (access.write !== undefined && access.write !== 'staff') {\n push(errors, `${path}.access.write`, 'invalid-value', `\"${String(access.write)}\" is not a write access level — shopper writes go through actions (M7), not RLS`, ['staff'])\n }\n }\n }\n const references = (where: string, name: unknown): void => {\n if (typeof name !== 'string' || !fieldNames.includes(name)) {\n push(errors, `${path}.${where}`, 'invalid-value', `${where} references undeclared field \"${String(name)}\"`, fieldNames)\n }\n }\n if (Array.isArray(declaration.indexes)) {\n declaration.indexes.forEach((tuple, i) => {\n if (!Array.isArray(tuple)) {\n push(errors, `${path}.indexes[${i}]`, 'invalid-value', 'an index is an array of declared field names')\n return\n }\n for (const name of tuple) references(`indexes[${i}]`, name)\n })\n }\n if (declaration.titleField !== undefined) references('titleField', declaration.titleField)\n if (Array.isArray(declaration.displayFields)) {\n for (const name of declaration.displayFields) references('displayFields', name)\n }\n }\n}\n\n/**\n * One rule (`{attribute, operator, values}`) against the rule_attribute\n * vocabulary (I9/I2): an unknown attribute names the registered keys, an\n * operator the attribute does not support names the supported subset. The\n * vocabulary is read at validation time, so attributes widened by context\n * providers (defineRuleContextProvider) validate exactly like core ones.\n */\nfunction validatePromotionRule(errors: Errors, path: string, rule: unknown): void {\n if (!isRecord(rule) || typeof rule.attribute !== 'string' || typeof rule.operator !== 'string') {\n push(errors, path, 'invalid-value', 'a rule is {attribute, operator, values: [...]}')\n return\n }\n if (!hasRuleAttribute(rule.attribute)) {\n push(\n errors,\n `${path}.attribute`,\n 'unknown-rule-attribute',\n `\"${rule.attribute}\" is not in the rule attribute vocabulary`,\n listRuleAttributeKeys(),\n )\n return\n }\n if (!(RULE_OPERATORS as readonly string[]).includes(rule.operator)) {\n push(errors, `${path}.operator`, 'unknown-rule-operator', `\"${rule.operator}\" is not a rule operator`, RULE_OPERATORS)\n return\n }\n const attribute = resolveRuleAttribute(rule.attribute)\n if (!(attribute.operators as readonly string[]).includes(rule.operator)) {\n push(\n errors,\n `${path}.operator`,\n 'unsupported-rule-operator',\n `attribute \"${rule.attribute}\" does not support operator \"${rule.operator}\"`,\n attribute.operators,\n )\n }\n if (!Array.isArray(rule.values) || rule.values.length === 0) {\n push(errors, `${path}.values`, 'invalid-value', 'rule values are a non-empty array of scalars')\n return\n }\n rule.values.forEach((value, index) => {\n const t = typeof value\n if (t !== 'string' && t !== 'number' && t !== 'boolean') {\n push(errors, `${path}.values[${index}]`, 'invalid-value', `a rule value is a JSON scalar, got ${t}`)\n }\n })\n}\n\nfunction validateRuleList(errors: Errors, path: string, value: unknown): void {\n if (value === undefined) return\n if (!Array.isArray(value)) {\n push(errors, path, 'invalid-value', `expected an array of rules, got ${typeof value}`)\n return\n }\n value.forEach((rule, index) => validatePromotionRule(errors, `${path}[${index}]`, rule))\n}\n\nfunction validatePromotionsSection(errors: Errors, section: Record<string, unknown>): void {\n const promotions = section.promotions\n if (promotions === undefined || !Array.isArray(promotions)) return // envelope reported the type\n promotions.forEach((promotion, index) => {\n const path = `promotions.promotions[${index}]`\n if (!isRecord(promotion) || typeof promotion.id !== 'string' || !promotion.id) {\n push(errors, path, 'invalid-value', 'a promotion is {id, code?, isAutomatic?, rules?, applicationMethod}')\n return\n }\n if (promotion.type !== undefined && !(PROMOTION_TYPES as readonly string[]).includes(promotion.type as string)) {\n push(errors, `${path}.type`, 'invalid-value', `\"${String(promotion.type)}\" is not a promotion type`, PROMOTION_TYPES)\n }\n if (promotion.status !== undefined && !(PROMOTION_STATUSES as readonly string[]).includes(promotion.status as string)) {\n push(errors, `${path}.status`, 'invalid-value', `\"${String(promotion.status)}\" is not a promotion status`, PROMOTION_STATUSES)\n }\n if (promotion.code === undefined && promotion.isAutomatic !== true) {\n push(\n errors,\n `${path}.code`,\n 'invalid-value',\n 'a promotion needs a code or isAutomatic: true — otherwise nothing can ever trigger it',\n )\n }\n validateRuleList(errors, `${path}.rules`, promotion.rules)\n const method = promotion.applicationMethod\n if (!isRecord(method)) {\n push(errors, `${path}.applicationMethod`, 'invalid-value', 'a promotion carries an applicationMethod ({type, value, targetType, …})')\n return\n }\n const methodPath = `${path}.applicationMethod`\n if (typeof method.type !== 'string' || !(APPLICATION_METHOD_TYPES as readonly string[]).includes(method.type)) {\n push(errors, `${methodPath}.type`, 'invalid-value', `\"${String(method.type)}\" is not an application method type`, APPLICATION_METHOD_TYPES)\n }\n if (typeof method.value !== 'number' || method.value < 0) {\n push(errors, `${methodPath}.value`, 'invalid-value', 'applicationMethod.value is a non-negative number')\n }\n if (typeof method.targetType !== 'string' || !(APPLICATION_METHOD_TARGET_TYPES as readonly string[]).includes(method.targetType)) {\n push(errors, `${methodPath}.targetType`, 'invalid-value', `\"${String(method.targetType)}\" is not a target type`, APPLICATION_METHOD_TARGET_TYPES)\n }\n if (method.allocation !== undefined && !(APPLICATION_METHOD_ALLOCATIONS as readonly string[]).includes(method.allocation as string)) {\n push(errors, `${methodPath}.allocation`, 'invalid-value', `\"${String(method.allocation)}\" is not an allocation`, APPLICATION_METHOD_ALLOCATIONS)\n }\n for (const field of ['maxQuantity', 'applyToQuantity', 'buyRulesMinQuantity'] as const) {\n const value = method[field]\n if (value !== undefined && value !== null && (typeof value !== 'number' || value < 1)) {\n push(errors, `${methodPath}.${field}`, 'invalid-value', `${field} is a positive integer when set`)\n }\n }\n validateRuleList(errors, `${methodPath}.targetRules`, method.targetRules)\n validateRuleList(errors, `${methodPath}.buyRules`, method.buyRules)\n })\n}\n\nfunction validateHandleRef(errors: Errors, path: string, name: unknown): void {\n if (typeof name !== 'string' || !name) {\n push(errors, path, 'invalid-value', 'a code reference is a registered handle name (string)')\n return\n }\n if (!hasHandle(name)) {\n push(errors, path, 'unknown-handle', `handle \"${name}\" is not registered`, listHandles())\n }\n}\n\nfunction validateCode(errors: Errors, section: Record<string, unknown>): void {\n for (const field of ['logo', 'provider', 'auth', 'footerCredit'] as const) {\n if (section[field] !== undefined) validateHandleRef(errors, `code.${field}`, section[field])\n }\n\n const components = section.components\n if (isRecord(components)) {\n for (const [slot, handle] of Object.entries(components)) {\n const slotPath = `code.components.${slot}`\n if (!(STOREFRONT_COMPONENT_KEYS as readonly string[]).includes(slot)) {\n push(\n errors,\n slotPath,\n 'unknown-component-slot',\n `\"${slot}\" is not an overridable storefront component`,\n STOREFRONT_COMPONENT_KEYS,\n )\n continue\n }\n validateHandleRef(errors, slotPath, handle)\n }\n }\n\n const routes = section.routes\n if (Array.isArray(routes)) {\n routes.forEach((route, index) => {\n const routePath = `code.routes[${index}]`\n if (!isRecord(route)) {\n push(errors, routePath, 'invalid-value', 'a route is {id, path, kind?, chrome?, component}')\n return\n }\n for (const required of ['id', 'path'] as const) {\n if (typeof route[required] !== 'string' || !route[required]) {\n push(errors, `${routePath}.${required}`, 'missing-field', `route requires a string \"${required}\"`)\n }\n }\n // Closed shape, same reasoning as a data need: hydrateStore rebuilds a\n // route from exactly these five keys, so anything else the author wrote\n // is discarded without a word.\n for (const key of Object.keys(route)) {\n if (!CODE_ROUTE_KEYS.includes(key)) {\n push(errors, `${routePath}.${key}`, 'unknown-field', `a route has no field \"${key}\"`, CODE_ROUTE_KEYS)\n }\n }\n if (route.kind !== undefined && !(STORE_ROUTE_KINDS as readonly string[]).includes(route.kind as string)) {\n push(\n errors,\n `${routePath}.kind`,\n 'invalid-value',\n `\"${String(route.kind)}\" is not a route kind`,\n STORE_ROUTE_KINDS,\n )\n }\n if (\n route.chrome !== undefined &&\n !(STORE_ROUTE_CHROMES as readonly string[]).includes(route.chrome as string)\n ) {\n push(\n errors,\n `${routePath}.chrome`,\n 'invalid-value',\n `\"${String(route.chrome)}\" is not a route chrome`,\n STORE_ROUTE_CHROMES,\n )\n }\n validateHandleRef(errors, `${routePath}.component`, route.component)\n })\n }\n}\n\n// --- The gate -----------------------------------------------------------------\n\n/**\n * Validate a Store Document against the registries and section schemas.\n *\n * Self-sufficient: registers the SDK blocks before checking, so \"unknown\n * block\" always names the true valid set. App-local blocks and handles must be\n * registered by the app's own modules before this runs — which is the same\n * precondition rendering has.\n */\nexport function validateStore(doc: unknown): StoreValidationReport {\n registerStorefrontBlocks()\n const errors: Errors = []\n\n // The entity vocabulary for THIS document: registered declarations plus the\n // document's own entities section, collected before any block is judged so\n // an entityList above the section in file order still validates.\n knownEntities = new Set(listEntityDeclarations())\n if (isRecord(doc)) {\n const entitiesSection = (doc as Record<string, unknown>).entities\n if (isRecord(entitiesSection) && isRecord(entitiesSection.definitions)) {\n for (const key of Object.keys(entitiesSection.definitions)) knownEntities.add(key)\n }\n }\n\n if (!isRecord(doc)) {\n push(errors, '', 'invalid-document', `a store document is an object, got ${doc === null ? 'null' : typeof doc}`)\n return { ok: false, errors }\n }\n\n if (doc.$kind !== STORE_DOCUMENT_KIND) {\n push(\n errors,\n '$kind',\n 'invalid-document',\n `expected $kind \"${STORE_DOCUMENT_KIND}\", got ${JSON.stringify(doc.$kind)}`,\n [STORE_DOCUMENT_KIND],\n )\n }\n\n if (doc.store === undefined) {\n push(errors, 'store', 'missing-section', 'the \"store\" section (name/currency/locale) is required', [\n ...STORE_SECTION_NAMES,\n ])\n }\n\n for (const [name, section] of Object.entries(doc)) {\n if (name === '$kind') continue\n if (!(STORE_SECTION_NAMES as string[]).includes(name)) {\n push(errors, name, 'unknown-section', `\"${name}\" is not a document section`, STORE_SECTION_NAMES)\n continue\n }\n if (!isRecord(section)) {\n push(errors, name, 'invalid-value', `section \"${name}\" must be an object with a version`)\n continue\n }\n const sectionName = name as StoreSectionName\n // A version this SDK does not understand makes the section's contents\n // unjudgeable — skip the deep checks rather than reporting noise against\n // the wrong schema.\n if (!validateSectionEnvelope(errors, sectionName, section)) continue\n if (sectionName === 'theme') validateTheme(errors, section)\n if (sectionName === 'entities') validateEntitiesSection(errors, section)\n if (sectionName === 'promotions') validatePromotionsSection(errors, section)\n if (sectionName === 'commerce') validateCommerce(errors, section)\n if (sectionName === 'presentation') validatePresentation(errors, section)\n if (sectionName === 'code') validateCode(errors, section)\n }\n\n return { ok: errors.length === 0, errors }\n}\n","import { errorMessage } from '@fayz-ai/core'\nimport type { ComponentType } from 'react'\nimport { handleNameFor, registerHandle, resolveHandle } from '@fayz-ai/core'\nimport type { ShopProvider } from '@fayz-ai/shop/provider'\nimport type {\n StorefrontConfig,\n StorefrontRouteDefinition,\n StorefrontRouteComponentProps,\n StorefrontSearchConfig,\n} from './config'\nimport type { StorefrontComponents } from '../extend/component-contracts'\nimport type { StorefrontAuthConfig } from '../data/auth'\nimport type { StorefrontTheme } from '../lib/theme'\nimport type { FooterConfig } from '../blocks/sections'\nimport { STORE_DOCUMENT_KIND, compact, isJsonValue } from './sections'\nimport type { StoreCodeRouteRef, StoreCodeSection, StoreDocument } from './sections'\nimport { validateStore } from './validate'\n\n// ---------------------------------------------------------------------------\n// exportStore / hydrateStoreDocument — the round-trip.\n//\n// Export is a first-class operation (spine §3 L0): if a live store cannot be\n// serialized, the agent cannot read one before changing it. The acceptance\n// test for this module is exact: defineStorefront(config) → exportStore() →\n// hydrate → resolveConfig deep-equals the original resolved config, with code\n// fields compared by handle name.\n//\n// Code never enters the document. A code-valued field is serialized as the\n// handle NAME it is registered under (reverse lookup), and hydration resolves\n// the name through the handle registry — where an unknown name is a hard\n// error naming the valid set (I2). This replaces the in-memory config Map the\n// scaffold used to keep, which could only reconstitute a store inside the\n// session that authored it.\n// ---------------------------------------------------------------------------\n\nexport function slugifyStoreName(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'app'\n}\n\nexport interface ExportStoreOptions {\n /** Namespace for auto-registered handles. Default: slug of the store name. */\n appId?: string\n /**\n * Register a deterministic handle (`<appId>.<config-path>`) for any code\n * value that has none, instead of failing. `defineStorefront` turns this on\n * so a store written today keeps working; a store that names its own handles\n * (registerHandle) keeps its names — explicit registration always wins the\n * reverse lookup.\n */\n registerMissingHandles?: boolean\n}\n\ninterface CodeRefContext {\n appId: string\n autoRegister: boolean\n}\n\n/** The handle name for a code value, auto-registering when allowed. */\nfunction codeRef(value: unknown, configPath: string, handleSuffix: string, ctx: CodeRefContext): string {\n const existing = handleNameFor(value)\n if (existing) return existing\n const name = `${ctx.appId}.${handleSuffix}`\n if (!ctx.autoRegister) {\n throw new Error(\n `exportStore: config.${configPath} holds code that is not a registered handle. ` +\n `Call registerHandle('${name}', value) before exporting, or export with ` +\n `{ registerMissingHandles: true } (defineStorefront does).`,\n )\n }\n registerHandle(\n name,\n value,\n { description: `Auto-registered from config.${configPath}`, source: 'app' },\n // The app re-declaring its config (module re-evaluation, HMR) re-derives\n // the same name for a fresh value; replacing is the correct semantics.\n { replace: true },\n )\n return name\n}\n\n/** First path inside `value` that is not JSON-representable, or null. */\nfunction findNonJsonPath(value: unknown, path: string): string | null {\n if (value === null || value === undefined) return null\n const t = typeof value\n if (t === 'string' || t === 'number' || t === 'boolean') return null\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const found = findNonJsonPath(value[i], `${path}[${i}]`)\n if (found) return found\n }\n return null\n }\n if (t === 'object') {\n const record = value as Record<string, unknown>\n if ('$$typeof' in record) return path\n const proto = Object.getPrototypeOf(record)\n if (proto !== Object.prototype && proto !== null) return path\n for (const [key, child] of Object.entries(record)) {\n const found = findNonJsonPath(child, `${path}.${key}`)\n if (found) return found\n }\n return null\n }\n return path\n}\n\nfunction hasContent(section: Record<string, unknown>): boolean {\n return Object.keys(section).some((key) => key !== 'version')\n}\n\n/**\n * Serialize a defined/live store to Store Document v1.\n *\n * Data fields map to sections verbatim (the authored block form is preserved,\n * flat or nested — both are data). Code fields become handle names in the\n * `code` section. A data field smuggling code (JSX inside a page tree) is a\n * hard error naming the offending path rather than a document that lies.\n */\nexport function exportStore(config: StorefrontConfig, options: ExportStoreOptions = {}): StoreDocument {\n const ctx: CodeRefContext = {\n appId: options.appId ?? slugifyStoreName(config.name),\n autoRegister: options.registerMissingHandles ?? false,\n }\n\n const code: StoreCodeSection = { version: 1 }\n\n // --- logo: string stays data; anything else is code ------------------------\n let presentationLogo: string | undefined\n if (config.logo !== undefined) {\n if (typeof config.logo === 'string') presentationLogo = config.logo\n else code.logo = codeRef(config.logo, 'logo', 'logo', ctx)\n }\n\n // --- footer: the credit node may be code; the rest is data -----------------\n let footerData: FooterConfig | undefined\n if (config.footer !== undefined) {\n const { credit, ...rest } = config.footer\n if (credit === undefined || typeof credit === 'string') {\n footerData = config.footer\n } else {\n footerData = rest\n code.footerCredit = codeRef(credit, 'footer.credit', 'footer-credit', ctx)\n }\n }\n\n // --- search: the knobs are data, a custom suggestion renderer is code ------\n let searchData: Omit<StorefrontSearchConfig, 'renderSuggestion'> | undefined\n if (config.search !== undefined) {\n const { renderSuggestion, ...rest } = config.search\n searchData = rest\n if (renderSuggestion !== undefined) {\n code.searchRenderSuggestion = codeRef(\n renderSuggestion,\n 'search.renderSuggestion',\n 'search-render-suggestion',\n ctx,\n )\n }\n }\n\n // --- auth: whole value is data or whole value is code ----------------------\n // Split across two sections it would stop being one config object; an auth\n // config carrying ANY code (adapter object, supabase client) moves whole.\n let authData: StorefrontAuthConfig | undefined\n if (config.auth !== undefined) {\n if (isJsonValue(config.auth)) authData = config.auth\n else code.auth = codeRef(config.auth, 'auth', 'auth', ctx)\n }\n\n if (config.provider !== undefined) {\n code.provider = codeRef(config.provider, 'provider', 'provider', ctx)\n }\n\n if (config.components !== undefined) {\n const componentRefs: Record<string, string> = {}\n for (const [key, override] of Object.entries(config.components)) {\n if (override === undefined) continue\n componentRefs[key] = codeRef(override, `components.${key}`, `components.${key}`, ctx)\n }\n if (Object.keys(componentRefs).length > 0) code.components = componentRefs\n }\n\n if (config.routes !== undefined && config.routes.length > 0) {\n code.routes = config.routes.map(\n (route): StoreCodeRouteRef =>\n compact({\n id: route.id,\n path: route.path,\n kind: route.kind,\n chrome: route.chrome,\n component: codeRef(route.component, `routes[${route.id}].component`, `routes.${route.id}`, ctx),\n }),\n )\n }\n\n const sections = {\n store: compact({\n version: 1,\n name: config.name,\n currency: config.currency,\n locale: config.locale,\n }),\n theme: config.theme\n ? { version: 1, ...compact(config.theme as unknown as Record<string, unknown>) }\n : { version: 1 },\n commerce: compact({\n version: 1,\n commerceMode: config.commerceMode,\n shipping: config.shipping,\n payments: config.payments,\n discounts: config.discounts,\n enquiry: config.enquiry,\n features: config.features,\n }),\n presentation: compact({\n version: 1,\n announcement: config.announcement,\n logo: presentationLogo,\n home: config.home,\n pages: config.pages,\n slots: config.slots,\n nav: config.nav,\n footer: footerData,\n imageLoading: config.imageLoading,\n catalogFacets: config.catalogFacets,\n productSpecs: config.productSpecs,\n search: searchData,\n }),\n content: compact({ version: 1, legal: config.legal, reviews: config.reviews }),\n catalog: config.catalog ? { version: 1, ...compact(config.catalog as Record<string, unknown>) } : { version: 1 },\n entities: config.entities ? { version: 1, definitions: config.entities } : { version: 1 },\n promotions: config.promotions ? { version: 1, promotions: config.promotions } : { version: 1 },\n backend: compact({\n version: 1,\n provider: config.backend?.provider,\n url: config.backend?.url,\n supabaseUrl: config.supabaseUrl,\n supabaseAnonKey: config.supabaseAnonKey,\n }),\n auth: authData ? { version: 1, ...compact(authData as Record<string, unknown>) } : { version: 1 },\n code: compact(code as unknown as Record<string, unknown>) as unknown as StoreCodeSection,\n }\n\n // A section rides only when it says something. theme/catalog/auth key off the\n // config field instead of content so an EMPTY configured object (catalog: {})\n // still round-trips as the empty object it is, not as absence.\n const include: Record<string, boolean> = {\n theme: config.theme !== undefined,\n catalog: config.catalog !== undefined,\n entities: config.entities !== undefined,\n promotions: config.promotions !== undefined,\n auth: authData !== undefined,\n commerce: hasContent(sections.commerce),\n presentation: hasContent(sections.presentation),\n content: hasContent(sections.content),\n backend: hasContent(sections.backend),\n code: hasContent(sections.code as unknown as Record<string, unknown>),\n }\n const doc: Record<string, unknown> = { $kind: STORE_DOCUMENT_KIND, store: sections.store }\n for (const name of ['theme', 'commerce', 'presentation', 'content', 'catalog', 'entities', 'promotions', 'backend', 'auth', 'code'] as const) {\n if (include[name]) doc[name] = sections[name]\n }\n\n // The document must be strictly JSON: a page tree or seed catalog smuggling\n // a function/JSX would produce a document that LOOKS complete and cannot be\n // hydrated anywhere else. Fail here, naming the path (I2 spirit).\n for (const [name, section] of Object.entries(doc)) {\n if (name === '$kind') continue\n const offending = findNonJsonPath(section, name)\n if (offending) {\n throw new Error(\n `exportStore: ${offending} holds a non-serializable value. Code belongs in a registered ` +\n `handle (registerHandle) referenced from the document's code section — data sections must be pure JSON.`,\n )\n }\n }\n\n return doc as unknown as StoreDocument\n}\n\nexport interface HydrateStoreOptions {\n /**\n * 'throw' (default): a document that fails validation aborts hydration with\n * an error listing every finding — the authoring-loop contract (I2).\n * 'report': log the findings and hydrate best-effort, dropping unresolvable\n * code refs — the shopper-facing contract (I7: a broken document degrades\n * instead of white-screening the store). The scaffold uses 'report'.\n */\n onError?: 'throw' | 'report'\n}\n\nfunction formatErrors(errors: ReturnType<typeof validateStore>['errors']): string {\n return errors\n .map((e) => ` - ${e.path || '(document)'}: ${e.message}${e.valid ? ` (valid: ${e.valid.join(', ')})` : ''}`)\n .join('\\n')\n}\n\n/**\n * Reconstitute a StorefrontConfig from a Store Document.\n *\n * Every code reference resolves through the handle registry by NAME — the\n * document alone plus the app's registered handles is the whole story; there\n * is no in-memory side channel keyed by app id anymore.\n */\nexport function hydrateStoreDocument(\n input: StoreDocument | Record<string, unknown>,\n options: HydrateStoreOptions = {},\n): StorefrontConfig {\n const onError = options.onError ?? 'throw'\n const report = validateStore(input)\n if (!report.ok) {\n const message = `Store document failed validation:\\n${formatErrors(report.errors)}`\n if (onError === 'throw') throw new Error(message)\n console.error(`[storefront] ${message}`)\n }\n\n const doc = input as unknown as StoreDocument\n const resolve = <T>(name: string, path: string): T | undefined => {\n try {\n return resolveHandle<T>(name)\n } catch (err) {\n if (onError === 'throw') throw err\n console.error(`[storefront] dropping ${path}: ${errorMessage(err)}`)\n return undefined\n }\n }\n\n const config: StorefrontConfig = { name: doc.store?.name ?? '' }\n const set = <K extends keyof StorefrontConfig>(key: K, value: StorefrontConfig[K] | undefined): void => {\n if (value !== undefined) config[key] = value\n }\n\n set('currency', doc.store?.currency)\n set('locale', doc.store?.locale)\n\n if (doc.theme) {\n const { version: _v, ...theme } = doc.theme\n set('theme', theme as StorefrontTheme)\n }\n\n if (doc.commerce) {\n set('commerceMode', doc.commerce.commerceMode)\n set('shipping', doc.commerce.shipping)\n set('payments', doc.commerce.payments)\n set('discounts', doc.commerce.discounts)\n set('enquiry', doc.commerce.enquiry)\n set('features', doc.commerce.features)\n }\n\n if (doc.presentation) {\n set('announcement', doc.presentation.announcement)\n set('home', doc.presentation.home)\n set('pages', doc.presentation.pages)\n set('slots', doc.presentation.slots)\n set('nav', doc.presentation.nav)\n set('imageLoading', doc.presentation.imageLoading)\n set('catalogFacets', doc.presentation.catalogFacets)\n set('productSpecs', doc.presentation.productSpecs)\n set('search', doc.presentation.search)\n if (doc.presentation.logo !== undefined) set('logo', doc.presentation.logo)\n }\n\n if (doc.content) {\n set('legal', doc.content.legal)\n set('reviews', doc.content.reviews)\n }\n\n if (doc.catalog) {\n const { version: _v, ...seed } = doc.catalog\n set('catalog', seed)\n }\n\n if (doc.entities?.definitions) set('entities', doc.entities.definitions)\n\n if (doc.promotions?.promotions) set('promotions', doc.promotions.promotions)\n\n if (doc.backend) {\n const { provider, url, supabaseUrl, supabaseAnonKey } = doc.backend\n if (provider !== undefined || url !== undefined) set('backend', compact({ provider, url }))\n set('supabaseUrl', supabaseUrl)\n set('supabaseAnonKey', supabaseAnonKey)\n }\n\n if (doc.auth) {\n const { version: _v, ...auth } = doc.auth\n set('auth', auth)\n }\n\n const code = doc.code\n if (code) {\n if (code.logo) set('logo', resolve<StorefrontConfig['logo']>(code.logo, 'code.logo'))\n if (code.provider) set('provider', resolve<ShopProvider>(code.provider, 'code.provider'))\n if (code.auth) set('auth', resolve<StorefrontAuthConfig>(code.auth, 'code.auth'))\n if (code.components) {\n const components: Record<string, unknown> = {}\n for (const [key, handle] of Object.entries(code.components)) {\n const value = resolve(handle, `code.components.${key}`)\n if (value !== undefined) components[key] = value\n }\n if (Object.keys(components).length > 0) set('components', components as StorefrontComponents)\n }\n if (code.routes) {\n const routes: StorefrontRouteDefinition[] = []\n for (const route of code.routes) {\n const component = resolve<ComponentType<StorefrontRouteComponentProps>>(\n route.component,\n `code.routes[${route.id}].component`,\n )\n if (component === undefined) continue\n routes.push(\n compact({\n id: route.id,\n path: route.path,\n kind: route.kind,\n chrome: route.chrome,\n component,\n }) as unknown as StorefrontRouteDefinition,\n )\n }\n if (routes.length > 0) set('routes', routes)\n }\n if (code.searchRenderSuggestion) {\n const renderSuggestion = resolve<NonNullable<StorefrontSearchConfig['renderSuggestion']>>(\n code.searchRenderSuggestion,\n 'code.searchRenderSuggestion',\n )\n if (renderSuggestion !== undefined) {\n set('search', { ...(doc.presentation?.search ?? {}), renderSuggestion })\n }\n }\n if (code.footerCredit) {\n const credit = resolve<FooterConfig['credit']>(code.footerCredit, 'code.footerCredit')\n if (credit !== undefined) {\n set('footer', { ...(doc.presentation?.footer ?? {}), credit })\n }\n }\n }\n if (config.footer === undefined && doc.presentation?.footer !== undefined) {\n set('footer', doc.presentation.footer)\n }\n\n return config\n}\n\n/** Re-export so document consumers need one import. */\nexport { STORE_DOCUMENT_KIND }\n"]}
|