@final-commerce/command-frame 0.6.0-staging3.2 → 0.6.1

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.
@@ -1,5 +1,5 @@
1
1
  export * from './common-types';
2
- import type { Tax, Tip, Address, MetadataItem, PosDataItem, CartFeeTaxEntry, CartFeeItem, CartDiscountItem, OrderNote, NonRevenueItem, DiscountDetail, FeeDetail, DiscountLineItem, FeeLineItem, LineItem, TipPayment, RefundedTipPayment, PaymentMethod, Discount, CustomFee, Summary, CustomSale, RefundedCustomSale, RefundItem, RefundedLineItem, ActiveStation, ActiveSession, ActiveOutlet, ActiveUser, ActiveUserRole, ActiveOrder, ActiveCart, ActivePark, ActiveCompany, ActiveCustomSales, ActiveProduct, ActiveCustomer, FullProduct, ProductVariant, Inventory, ResolvedModifier, ResolvedModifierChoice, ModifierSelectionType, ModifierSelection, ModifierChoiceSelection, OrderLineItemModifier, CustomerNote, Attribute, AttributeOption, Category, Transaction, ActiveSplitPayment } from '@final-commerce/common/pos-types';
2
+ import type { Tax, Tip, Address, MetadataItem, PosDataItem, CartFeeTaxEntry, CartFeeItem, CartDiscountItem, OrderNote, NonRevenueItem, DiscountDetail, FeeDetail, DiscountLineItem, FeeLineItem, LineItem, TipPayment, RefundedTipPayment, PaymentMethod, Discount, CustomFee, Summary, CustomSale, RefundedCustomSale, RefundItem, RefundedLineItem, ActiveStation, ActiveSession, ActiveOutlet, ActiveUser, ActiveUserRole, ActiveOrder, ActiveCart, ActivePark, ActiveCompany, ActiveCustomSales, ActiveProduct, ActiveCustomer, FullProduct, ProductVariant, Inventory, CustomerNote, Attribute, AttributeOption, Category, Transaction, ActiveSplitPayment } from '@final-commerce/common/pos-types';
3
3
  export { CurrencyCode, ProductType as CFProductType, UserTypes as CFUserTypes } from '@final-commerce/common';
4
4
  /** Open record used as a base for active entities. */
5
5
  export type CFActiveEntity = Record<string, unknown>;
@@ -18,15 +18,6 @@ export type CFTransaction = Transaction;
18
18
  export type CFCategory = Category;
19
19
  export type CFProductVariant = ProductVariant;
20
20
  export type CFProduct = FullProduct;
21
- /** Modifier (the till question) resolved onto a product — `CFProduct.modifiers`. */
22
- export type CFResolvedModifier = ResolvedModifier;
23
- export type CFResolvedModifierChoice = ResolvedModifierChoice;
24
- export type CFModifierSelectionType = ModifierSelectionType;
25
- /** One selected modifier choice on an order line item (wire shape). */
26
- export type CFOrderLineItemModifier = OrderLineItemModifier;
27
- /** Cart-line modifier answer (pre-pricing) — `CFActiveProduct.modifierSelections`. */
28
- export type CFModifierSelection = ModifierSelection;
29
- export type CFModifierChoiceSelection = ModifierChoiceSelection;
30
21
  export type CFActiveProduct = ActiveProduct;
31
22
  export type CFCustomer = ActiveCustomer;
32
23
  export type CFActiveCustomer = ActiveCustomer;
@@ -53,12 +53,6 @@ export const mockAddProductToCart = async (params) => {
53
53
  note: note,
54
54
  // discount/fee could be added here to mock object if CFActiveProduct supports it
55
55
  };
56
- // Mock modifier handling: echo selections onto the line; a real host resolves the
57
- // product's modifiers, validates required/min/max in units, and prices each choice
58
- // (fee-level money: not in grossSales, not reduced by the product discount).
59
- if (params?.modifiers?.length) {
60
- activeProduct.modifierSelections = params.modifiers;
61
- }
62
56
  MOCK_CART.products.push(activeProduct);
63
57
  // Recalculate totals. extendPrice, not a raw multiply: a fractional quantity times an
64
58
  // integer-minor price leaves fractional cents, which no order may carry.
@@ -1,11 +1,5 @@
1
1
  import type { AddProductDiscountParams } from '../add-product-discount/types';
2
2
  import type { AddProductFeeParams } from '../add-product-fee/types';
3
- import type { ModifierSelection } from '../get-product-modifier-selections/types';
4
- /**
5
- * One modifier answer passed at ring-time. Same shape as the
6
- * get-product-modifier-selections `ModifierSelection` (single source of truth).
7
- */
8
- export type AddProductToCartModifierParams = ModifierSelection;
9
3
  export interface AddProductToCartParams {
10
4
  /** ID of the variant to add. */
11
5
  variantId: string;
@@ -27,15 +21,11 @@ export interface AddProductToCartParams {
27
21
  discounts?: AddProductDiscountParams[];
28
22
  /** Array of fees to apply immediately. */
29
23
  fees?: AddProductFeeParams[];
30
- /** Modifier selections to apply immediately. */
31
- modifiers?: AddProductToCartModifierParams[];
32
24
  /** Note or array of notes to add immediately. */
33
25
  notes?: string | string[];
34
26
  }
35
27
  export interface AddProductToCartResponse {
36
28
  success: boolean;
37
- /** Set when the add was rejected (e.g. a required modifier is unanswered). */
38
- reason?: string;
39
29
  productId: string;
40
30
  variantId: string;
41
31
  /** The unique identifier for the specific item instance added to the cart. */
package/dist/index.d.ts CHANGED
@@ -21,8 +21,6 @@ export declare const command: {
21
21
  readonly getFinalContext: import(".").GetFinalContext;
22
22
  readonly addProductNote: import(".").AddProductNote;
23
23
  readonly addProductFee: import(".").AddProductFee;
24
- readonly getProductModifierSelections: import(".").GetProductModifierSelections;
25
- readonly setProductModifierSelections: import(".").SetProductModifierSelections;
26
24
  readonly setActiveProductFee: import(".").SetActiveProductFee;
27
25
  readonly setActiveProductDiscount: import(".").SetActiveProductDiscount;
28
26
  readonly getActiveProduct: import(".").GetActiveProduct;
@@ -151,7 +149,7 @@ export type { CheckPermission, CheckPermissionParams, CheckPermissionResponse }
151
149
  export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from './actions/initiate-refund/types';
152
150
  export type { GetCurrentCart, GetCurrentCartResponse } from './actions/get-current-cart/types';
153
151
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse, } from './actions/add-product-discount/types';
154
- export type { AddProductToCart, AddProductToCartParams, AddProductToCartModifierParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
152
+ export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
155
153
  export type { RemoveProductFromCart, RemoveProductFromCartParams, RemoveProductFromCartResponse, } from './actions/remove-product-from-cart/types';
156
154
  export type { UpdateCartItemQuantity, UpdateCartItemQuantityParams, UpdateCartItemQuantityResponse, } from './actions/update-cart-item-quantity/types';
157
155
  export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse, } from './actions/add-cart-discount/types';
@@ -159,8 +157,6 @@ export type { GetContext, GetContextResponse, GetContextResponseManage, GetConte
159
157
  export type { GetFinalContext, GetFinalContextResponse } from './actions/get-final-context/types';
160
158
  export type { AddProductNote, AddProductNoteParams, AddProductNoteResponse } from './actions/add-product-note/types';
161
159
  export type { AddProductFee, AddProductFeeParams, AddProductFeeResponse } from './actions/add-product-fee/types';
162
- export type { GetProductModifierSelections, GetProductModifierSelectionsParams, GetProductModifierSelectionsResponse, ModifierSelection, ModifierChoiceSelection, } from './actions/get-product-modifier-selections/types';
163
- export type { SetProductModifierSelections, SetProductModifierSelectionsParams, SetProductModifierSelectionsResponse, } from './actions/set-product-modifier-selections/types';
164
160
  export type { SetActiveProductFee, SetActiveProductFeeParams, SetActiveProductFeeResponse, } from './actions/set-active-product-fee/types';
165
161
  export type { SetActiveProductDiscount, SetActiveProductDiscountParams, SetActiveProductDiscountResponse, } from './actions/set-active-product-discount/types';
166
162
  export type { GetActiveProduct, GetActiveProductResponse } from './actions/get-active-product/types';
package/dist/index.js CHANGED
@@ -20,8 +20,6 @@ import { updateCartItemQuantity } from './actions/update-cart-item-quantity/acti
20
20
  // Product Actions
21
21
  import { addProductNote } from './actions/add-product-note/action';
22
22
  import { addProductFee } from './actions/add-product-fee/action';
23
- import { getProductModifierSelections } from './actions/get-product-modifier-selections/action';
24
- import { setProductModifierSelections } from './actions/set-product-modifier-selections/action';
25
23
  import { setActiveProductFee } from './actions/set-active-product-fee/action';
26
24
  import { setActiveProductDiscount } from './actions/set-active-product-discount/action';
27
25
  import { getActiveProduct } from './actions/get-active-product/action';
@@ -159,8 +157,6 @@ export const command = {
159
157
  // Product Actions
160
158
  addProductNote,
161
159
  addProductFee,
162
- getProductModifierSelections,
163
- setProductModifierSelections,
164
160
  setActiveProductFee,
165
161
  setActiveProductDiscount,
166
162
  getActiveProduct,
@@ -12,8 +12,6 @@ import { mockAddOrderNote } from '../../actions/add-order-note/mock';
12
12
  import { mockRemoveOrderNote } from '../../actions/remove-order-note/mock';
13
13
  import { mockAddProductDiscount } from '../../actions/add-product-discount/mock';
14
14
  import { mockAddProductFee } from '../../actions/add-product-fee/mock';
15
- import { mockGetProductModifierSelections } from '../../actions/get-product-modifier-selections/mock';
16
- import { mockSetProductModifierSelections } from '../../actions/set-product-modifier-selections/mock';
17
15
  import { mockRemoveProductDiscount } from '../../actions/remove-product-discount/mock';
18
16
  import { mockRemoveProductFee } from '../../actions/remove-product-fee/mock';
19
17
  import { mockSetActiveProductFee } from '../../actions/set-active-product-fee/mock';
@@ -114,8 +112,6 @@ export const RENDER_MOCKS = {
114
112
  addOrderNote: mockAddOrderNote,
115
113
  addProductDiscount: mockAddProductDiscount,
116
114
  addProductFee: mockAddProductFee,
117
- getProductModifierSelections: mockGetProductModifierSelections,
118
- setProductModifierSelections: mockSetProductModifierSelections,
119
115
  setActiveProductFee: mockSetActiveProductFee,
120
116
  setActiveProductDiscount: mockSetActiveProductDiscount,
121
117
  getActiveProduct: mockGetActiveProduct,
@@ -1,4 +1,4 @@
1
- import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, GetProductModifierSelections, SetProductModifierSelections, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, CreatePaymentLink, ChargeMoto, GetTimeClockStatus } from '../../index';
1
+ import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms, CreatePaymentLink, ChargeMoto, GetTimeClockStatus } from '../../index';
2
2
  export interface RenderProviderActions {
3
3
  exampleFunction: ExampleFunction;
4
4
  getProducts: GetProducts;
@@ -21,8 +21,6 @@ export interface RenderProviderActions {
21
21
  getFinalContext: GetFinalContext;
22
22
  addProductNote: AddProductNote;
23
23
  addProductFee: AddProductFee;
24
- getProductModifierSelections: GetProductModifierSelections;
25
- setProductModifierSelections: SetProductModifierSelections;
26
24
  setActiveProductFee: SetActiveProductFee;
27
25
  setActiveProductDiscount: SetActiveProductDiscount;
28
26
  getActiveProduct: GetActiveProduct;
@@ -17,7 +17,6 @@ export * from "./product-fee-added/types";
17
17
  export * from "./product-fee-removed/types";
18
18
  export * from "./product-note-added/types";
19
19
  export * from "./product-note-removed/types";
20
- export * from "./product-modifiers-updated/types";
21
20
  import type { CartCreatedPayload } from "./cart-created/types";
22
21
  import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
23
22
  import type { ProductAddedPayload } from "./product-added/types";
@@ -33,6 +32,5 @@ import type { ProductFeeAddedPayload } from "./product-fee-added/types";
33
32
  import type { ProductFeeRemovedPayload } from "./product-fee-removed/types";
34
33
  import type { ProductNoteAddedPayload } from "./product-note-added/types";
35
34
  import type { ProductNoteRemovedPayload } from "./product-note-removed/types";
36
- import type { ProductModifiersUpdatedPayload } from "./product-modifiers-updated/types";
37
- export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartProductUpdatedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload | ProductDiscountAddedPayload | ProductDiscountRemovedPayload | ProductFeeAddedPayload | ProductFeeRemovedPayload | ProductNoteAddedPayload | ProductNoteRemovedPayload | ProductModifiersUpdatedPayload;
38
- export type CartEventType = "cart-created" | "customer-assigned" | "customer-unassigned" | "product-added" | "product-deleted" | "product-updated" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed" | "product-discount-added" | "product-discount-removed" | "product-fee-added" | "product-fee-removed" | "product-note-added" | "product-note-removed" | "product-modifiers-updated";
35
+ export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartProductUpdatedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload | ProductDiscountAddedPayload | ProductDiscountRemovedPayload | ProductFeeAddedPayload | ProductFeeRemovedPayload | ProductNoteAddedPayload | ProductNoteRemovedPayload;
36
+ export type CartEventType = "cart-created" | "customer-assigned" | "customer-unassigned" | "product-added" | "product-deleted" | "product-updated" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed" | "product-discount-added" | "product-discount-removed" | "product-fee-added" | "product-fee-removed" | "product-note-added" | "product-note-removed";
@@ -18,4 +18,3 @@ export * from "./product-fee-added/types";
18
18
  export * from "./product-fee-removed/types";
19
19
  export * from "./product-note-added/types";
20
20
  export * from "./product-note-removed/types";
21
- export * from "./product-modifiers-updated/types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.6.0-staging3.2",
3
+ "version": "0.6.1",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "ignoreBranchesMissingTickets": true
58
58
  },
59
59
  "dependencies": {
60
- "@final-commerce/common": "2.2.3-staging3.2"
60
+ "@final-commerce/common": "2.2.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@commitlint/cli": "^19.0.0",
@@ -1,6 +0,0 @@
1
- /**
2
- * Get product modifier selections action (read-only)
3
- * Calls the getProductModifierSelections action on the parent window
4
- */
5
- import type { GetProductModifierSelections } from "./types";
6
- export declare const getProductModifierSelections: GetProductModifierSelections;
@@ -1,8 +0,0 @@
1
- /**
2
- * Get product modifier selections action (read-only)
3
- * Calls the getProductModifierSelections action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const getProductModifierSelections = async (params) => {
7
- return await commandFrameClient.call("getProductModifierSelections", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { GetProductModifierSelections } from "./types";
2
- export declare const mockGetProductModifierSelections: GetProductModifierSelections;
@@ -1,23 +0,0 @@
1
- import { MOCK_CART } from "../../demo/database";
2
- export const mockGetProductModifierSelections = async (params) => {
3
- console.log("[Mock] getProductModifierSelections called", params);
4
- // Read the line's stored selections from the mock cart (last line when no internalId).
5
- const line = params?.internalId
6
- ? MOCK_CART.products.find((p) => p.internalId === params.internalId)
7
- : MOCK_CART.products[MOCK_CART.products.length - 1];
8
- if (!line) {
9
- return {
10
- success: false,
11
- reason: "No matching cart line",
12
- internalId: params?.internalId,
13
- selections: [],
14
- timestamp: new Date().toISOString()
15
- };
16
- }
17
- return {
18
- success: true,
19
- internalId: line.internalId,
20
- selections: line.modifierSelections ?? [],
21
- timestamp: new Date().toISOString()
22
- };
23
- };
@@ -1,30 +0,0 @@
1
- /** One chosen choice: `quantity` is units PER LINE-ITEM UNIT (1 unless the control is a stepper). */
2
- export interface ModifierChoiceSelection {
3
- choiceId: string;
4
- quantity: number;
5
- }
6
- /** The cashier's answer to one modifier. */
7
- export interface ModifierSelection {
8
- modifierId: string;
9
- choices: ModifierChoiceSelection[];
10
- }
11
- export interface GetProductModifierSelectionsParams {
12
- /** The cart line to read. Defaults to the active product's line. */
13
- internalId?: string;
14
- }
15
- export interface GetProductModifierSelectionsResponse {
16
- success: boolean;
17
- /** Set when the read failed (e.g. no such line, no active product). */
18
- reason?: string;
19
- internalId?: string;
20
- /**
21
- * The line's current modifier selections. Supplied at creation via
22
- * `addProductToCart({ modifiers })`; edit them with
23
- * `setProductModifierSelections` (full replacement, re-validated).
24
- * Modifier DEFINITIONS remain read-only — they flow one-way from
25
- * station-sync into the till.
26
- */
27
- selections: ModifierSelection[];
28
- timestamp: string;
29
- }
30
- export type GetProductModifierSelections = (params?: GetProductModifierSelectionsParams) => Promise<GetProductModifierSelectionsResponse>;
@@ -1,2 +0,0 @@
1
- // Get Product Modifier Selections Types
2
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Set product modifier selections action
3
- * Calls the setProductModifierSelections action on the parent window
4
- */
5
- import type { SetProductModifierSelections } from "./types";
6
- export declare const setProductModifierSelections: SetProductModifierSelections;
@@ -1,8 +0,0 @@
1
- /**
2
- * Set product modifier selections action
3
- * Calls the setProductModifierSelections action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const setProductModifierSelections = async (params) => {
7
- return await commandFrameClient.call("setProductModifierSelections", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { SetProductModifierSelections } from "./types";
2
- export declare const mockSetProductModifierSelections: SetProductModifierSelections;
@@ -1,34 +0,0 @@
1
- import { MOCK_CART } from "../../demo/database";
2
- export const mockSetProductModifierSelections = async (params) => {
3
- console.log("[Mock] setProductModifierSelections called", params);
4
- if (!params?.selections) {
5
- return {
6
- success: false,
7
- reason: "selections is required (pass [] to clear)",
8
- internalId: params?.internalId,
9
- selections: [],
10
- timestamp: new Date().toISOString()
11
- };
12
- }
13
- // Write the selections onto the mock cart line (last line when no internalId).
14
- // The mock does not re-run rule validation or repricing — the real host does.
15
- const line = params.internalId
16
- ? MOCK_CART.products.find((p) => p.internalId === params.internalId)
17
- : MOCK_CART.products[MOCK_CART.products.length - 1];
18
- if (!line) {
19
- return {
20
- success: false,
21
- reason: "No matching cart line",
22
- internalId: params.internalId,
23
- selections: [],
24
- timestamp: new Date().toISOString()
25
- };
26
- }
27
- line.modifierSelections = params.selections;
28
- return {
29
- success: true,
30
- internalId: line.internalId,
31
- selections: params.selections,
32
- timestamp: new Date().toISOString()
33
- };
34
- };
@@ -1,22 +0,0 @@
1
- import type { ModifierSelection } from "../get-product-modifier-selections/types";
2
- export interface SetProductModifierSelectionsParams {
3
- /** The cart line to edit. Defaults to the active product's line. */
4
- internalId?: string;
5
- /**
6
- * The line's COMPLETE new answers — replaces every existing selection on the
7
- * line (send [] to clear all optional modifiers). Validated against the
8
- * product's category-modifier rules exactly like addProductToCart({ modifiers }):
9
- * a selection that breaks a rule rejects the edit and the line is unchanged.
10
- */
11
- selections: ModifierSelection[];
12
- }
13
- export interface SetProductModifierSelectionsResponse {
14
- success: boolean;
15
- /** Set when the edit was rejected (rule violation) — the line is unchanged. */
16
- reason?: string;
17
- internalId?: string;
18
- /** The selections now on the line (the new ones on success, the old ones on rejection). */
19
- selections: ModifierSelection[];
20
- timestamp: string;
21
- }
22
- export type SetProductModifierSelections = (params?: SetProductModifierSelectionsParams) => Promise<SetProductModifierSelectionsResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import type { CFActiveProduct, CFModifierSelection } from "../../../../CommonTypes";
2
- import type { TopicEvent } from "../../../types";
3
- /**
4
- * Payload for product-modifiers-updated event (FT-0010) — fired when a cart
5
- * line's modifier selections are replaced via setProductModifierSelections.
6
- */
7
- export interface ProductModifiersUpdatedPayload {
8
- product: CFActiveProduct;
9
- internalId?: string;
10
- /** The line's complete new answers (full replacement). */
11
- selections: CFModifierSelection[];
12
- }
13
- /**
14
- * Typed event for product-modifiers-updated
15
- */
16
- export type ProductModifiersUpdatedEvent = TopicEvent<ProductModifiersUpdatedPayload>;