import { UIDLEcommerceDiscountEngine, UIDLEcommerceSettings } from '@teleporthq/teleport-types'; /** * The storefront half of the discount engine — vouchers with conditions, * stacking, and automatic (code-less) rules — as the source fragments * `ecommerce-context-generator.ts` splices into `EcommerceProvider`. * * Two layers, deliberately: * - the ENGINE ITSELF (`generateDiscountProjectionCode`) is emitted for every * store. The provider always prices vouchers through it, in `legacy` mode * for a checkout built before the engine — which reproduces, to the cent, * the flat voucher rule that checkout's baked place-order workflow charges. * The same block carries the row parsers `enrichCartItems` stamps * categories and the gift-card flag with, so those exist regardless. * - the RULE FEED (`generateDiscountEngineModuleCode` + * `generateDiscountEngineProviderCode`) is emitted only when the UIDL * carries the `discountEngine` block: the `teleport_discounts` loader, the * shopper context the checkout page-load workflow writes, and the mirror of * both into `workflow_cart_settings` for `cart-get-total`. * * The arithmetic is `DiscountEngine.generateDiscountEngineHelperCode`, shared * with `cart-get-total` and (byte for byte) with the editor: the discount the * summary shows, the discount the workflow re-prices at submit and the discount * stored on the order come from one rule. */ /** * The feature's baked settings when this store runs the engine's rule feed, or * null. Needs a datasource: automatic rules are read through * `/api/data//select`, and a project without one has nowhere to keep them. */ export declare const resolveDiscountEngine: (ecommerceSettings: UIDLEcommerceSettings, dataSourceId: string | null | undefined) => UIDLEcommerceDiscountEngine | null; /** * Module-scope declarations emitted for EVERY store: the shared engine and the * projection from its result to what the provider's totals and the pages read. * * Must sit before `enrichCartItems`, which stamps categories and the gift-card * flag onto every hydrated line with the `__de` row parsers. */ export declare const generateDiscountProjectionCode: () => string; /** * Module-scope declarations for a store with the rule feed: the baked engine * settings, the automatic-rules loader and the shopper-context reader. */ export declare const generateDiscountEngineModuleCode: (engine: UIDLEcommerceDiscountEngine) => string; /** * Provider-body state and effects for a store with the rule feed. Declares * `discountRules` (the live automatic rules, normalized) and * `discountCustomerContext` (what the engine knows about the shopper), which * the `discountMeta` memo reads. * * Emitted AFTER `cartItems` exists and after the provider's own * `workflow_cart_settings` writer, whose whole-key write this MERGES into. */ export declare const generateDiscountEngineProviderCode: () => string; /** * Provider-body state for the shopper's discount choice, emitted for every * store: read on mount, re-read when the checkout's "Select Discount" workflow * announces a change or another tab writes the key, and cleared with the cart. */ export declare const generateDiscountChoiceProviderCode: () => string; export interface DiscountMetaCodeOptions { /** The cart lines the engine prices, e.g. `cartItems`. */ itemsExpression: string; /** The tax rate those lines still need, `0` when they are already gross. */ taxRateExpression: string; /** Memo deps the items expression reads, with a trailing comma. */ itemsDeps: string; /** Whether the rule feed is emitted, i.e. the engine runs in full. */ engineEnabled: boolean; } /** * The `discountMeta` memo the provider's totals are built from, in its two * shapes: over the live rules and shopper context when the rule feed exists, * or in `legacy` mode — no rules, no conditions — for a checkout built before * the engine, which is exactly what its baked place-order workflow charges. */ export declare const generateDiscountMetaCode: (options: DiscountMetaCodeOptions) => string; //# sourceMappingURL=ecommerce-discount-engine-code.d.ts.map