@final-commerce/command-frame 0.6.0-staging.5 → 0.6.0-staging3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/CommonTypes.d.ts +10 -1
- package/dist/actions/add-product-to-cart/mock.js +6 -0
- package/dist/actions/add-product-to-cart/types.d.ts +12 -2
- package/dist/actions/get-available-transitions/mock.d.ts +7 -2
- package/dist/actions/get-available-transitions/mock.js +9 -9
- package/dist/actions/get-product-modifier-selections/action.d.ts +6 -0
- package/dist/actions/get-product-modifier-selections/action.js +8 -0
- package/dist/actions/get-product-modifier-selections/mock.d.ts +2 -0
- package/dist/actions/get-product-modifier-selections/mock.js +23 -0
- package/dist/actions/get-product-modifier-selections/types.d.ts +30 -0
- package/dist/actions/get-product-modifier-selections/types.js +2 -0
- package/dist/actions/set-product-modifier-selections/action.d.ts +6 -0
- package/dist/actions/set-product-modifier-selections/action.js +8 -0
- package/dist/actions/set-product-modifier-selections/mock.d.ts +2 -0
- package/dist/actions/set-product-modifier-selections/mock.js +34 -0
- package/dist/actions/set-product-modifier-selections/types.d.ts +22 -0
- package/dist/actions/set-product-modifier-selections/types.js +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/projects/render/mocks.js +4 -0
- package/dist/projects/render/types.d.ts +3 -1
- package/dist/pubsub/topics/cart/product-modifiers-updated/types.d.ts +16 -0
- package/dist/pubsub/topics/cart/product-modifiers-updated/types.js +1 -0
- package/dist/pubsub/topics/cart/types.d.ts +4 -2
- package/dist/pubsub/topics/cart/types.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ The library provides three main capabilities:
|
|
|
18
18
|
|
|
19
19
|
Domain models (orders, cart, customers, products, and related types) are documented in **[Types reference](./src/types/README.md)**.
|
|
20
20
|
|
|
21
|
+
The order lifecycle — payment × fulfillment state pairs, display labels, the transition guard chain, and the financial invariants — is documented in **[Order state machine reference](./docs/order-state-machine.md)**. Read it before building anything that reads or moves order state (`canTransition`, `getAvailableTransitions`, `applyTransition`, park/void/resume, payments, refunds).
|
|
22
|
+
|
|
21
23
|
## Installation
|
|
22
24
|
|
|
23
25
|
### From npm (public registry)
|
package/dist/CommonTypes.d.ts
CHANGED
|
@@ -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, 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, ResolvedModifier, ResolvedModifierChoice, ModifierSelectionType, ModifierSelection, ModifierChoiceSelection, OrderLineItemModifier, 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,6 +18,15 @@ 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;
|
|
21
30
|
export type CFActiveProduct = ActiveProduct;
|
|
22
31
|
export type CFCustomer = ActiveCustomer;
|
|
23
32
|
export type CFActiveCustomer = ActiveCustomer;
|
|
@@ -53,6 +53,12 @@ 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
|
+
}
|
|
56
62
|
MOCK_CART.products.push(activeProduct);
|
|
57
63
|
// Recalculate totals. extendPrice, not a raw multiply: a fractional quantity times an
|
|
58
64
|
// integer-minor price leaves fractional cents, which no order may carry.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { AddProductDiscountParams } from
|
|
2
|
-
import type { AddProductFeeParams } from
|
|
1
|
+
import type { AddProductDiscountParams } from '../add-product-discount/types';
|
|
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;
|
|
3
9
|
export interface AddProductToCartParams {
|
|
4
10
|
/** ID of the variant to add. */
|
|
5
11
|
variantId: string;
|
|
@@ -21,11 +27,15 @@ export interface AddProductToCartParams {
|
|
|
21
27
|
discounts?: AddProductDiscountParams[];
|
|
22
28
|
/** Array of fees to apply immediately. */
|
|
23
29
|
fees?: AddProductFeeParams[];
|
|
30
|
+
/** Modifier selections to apply immediately. */
|
|
31
|
+
modifiers?: AddProductToCartModifierParams[];
|
|
24
32
|
/** Note or array of notes to add immediately. */
|
|
25
33
|
notes?: string | string[];
|
|
26
34
|
}
|
|
27
35
|
export interface AddProductToCartResponse {
|
|
28
36
|
success: boolean;
|
|
37
|
+
/** Set when the add was rejected (e.g. a required modifier is unanswered). */
|
|
38
|
+
reason?: string;
|
|
29
39
|
productId: string;
|
|
30
40
|
variantId: string;
|
|
31
41
|
/** The unique identifier for the specific item instance added to the cart. */
|
|
@@ -2,7 +2,12 @@ import type { GetAvailableTransitions } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Mock implementation: returns a fixed set of plausible transitions
|
|
4
4
|
* so the demo app has data to render. Mirrors an UNPAID order under the
|
|
5
|
-
* default (empty cross-axis rules) config
|
|
6
|
-
*
|
|
5
|
+
* default (empty cross-axis rules) config.
|
|
6
|
+
*
|
|
7
|
+
* FULFILLMENT-AXIS ONLY (common 2.1.4 contract): the payment axis never
|
|
8
|
+
* appears as an available transition — it moves exclusively through the
|
|
9
|
+
* money operations (pay / refund / void), which derive their own landing
|
|
10
|
+
* pairs. Every row keeps `to.payment` equal to the order's current payment
|
|
11
|
+
* state, exactly like the host's `getAvailableTransitions`.
|
|
7
12
|
*/
|
|
8
13
|
export declare const getAvailableTransitionsMock: GetAvailableTransitions;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mock implementation: returns a fixed set of plausible transitions
|
|
3
3
|
* so the demo app has data to render. Mirrors an UNPAID order under the
|
|
4
|
-
* default (empty cross-axis rules) config
|
|
5
|
-
*
|
|
4
|
+
* default (empty cross-axis rules) config.
|
|
5
|
+
*
|
|
6
|
+
* FULFILLMENT-AXIS ONLY (common 2.1.4 contract): the payment axis never
|
|
7
|
+
* appears as an available transition — it moves exclusively through the
|
|
8
|
+
* money operations (pay / refund / void), which derive their own landing
|
|
9
|
+
* pairs. Every row keeps `to.payment` equal to the order's current payment
|
|
10
|
+
* state, exactly like the host's `getAvailableTransitions`.
|
|
6
11
|
*/
|
|
7
12
|
export const getAvailableTransitionsMock = () => Promise.resolve({
|
|
8
13
|
transitions: [
|
|
@@ -22,13 +27,8 @@ export const getAvailableTransitionsMock = () => Promise.resolve({
|
|
|
22
27
|
conditions: [{ met: true, description: 'Order is open' }],
|
|
23
28
|
},
|
|
24
29
|
{
|
|
25
|
-
to: { payment: '
|
|
26
|
-
displayLabel: '
|
|
27
|
-
conditions: [{ met: true, description: 'Balance due > 0' }],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
to: { payment: 'voided', fulfillment: 'cancelled' },
|
|
31
|
-
displayLabel: 'Void Order',
|
|
30
|
+
to: { payment: 'unpaid', fulfillment: 'cancelled' },
|
|
31
|
+
displayLabel: 'Cancel Order',
|
|
32
32
|
conditions: [
|
|
33
33
|
{ met: true, description: 'Order exists' },
|
|
34
34
|
{ met: false, description: 'No payments captured (mock: skipped)' },
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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>;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ 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;
|
|
24
26
|
readonly setActiveProductFee: import(".").SetActiveProductFee;
|
|
25
27
|
readonly setActiveProductDiscount: import(".").SetActiveProductDiscount;
|
|
26
28
|
readonly getActiveProduct: import(".").GetActiveProduct;
|
|
@@ -149,7 +151,7 @@ export type { CheckPermission, CheckPermissionParams, CheckPermissionResponse }
|
|
|
149
151
|
export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from './actions/initiate-refund/types';
|
|
150
152
|
export type { GetCurrentCart, GetCurrentCartResponse } from './actions/get-current-cart/types';
|
|
151
153
|
export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse, } from './actions/add-product-discount/types';
|
|
152
|
-
export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
|
|
154
|
+
export type { AddProductToCart, AddProductToCartParams, AddProductToCartModifierParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
|
|
153
155
|
export type { RemoveProductFromCart, RemoveProductFromCartParams, RemoveProductFromCartResponse, } from './actions/remove-product-from-cart/types';
|
|
154
156
|
export type { UpdateCartItemQuantity, UpdateCartItemQuantityParams, UpdateCartItemQuantityResponse, } from './actions/update-cart-item-quantity/types';
|
|
155
157
|
export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse, } from './actions/add-cart-discount/types';
|
|
@@ -157,6 +159,8 @@ export type { GetContext, GetContextResponse, GetContextResponseManage, GetConte
|
|
|
157
159
|
export type { GetFinalContext, GetFinalContextResponse } from './actions/get-final-context/types';
|
|
158
160
|
export type { AddProductNote, AddProductNoteParams, AddProductNoteResponse } from './actions/add-product-note/types';
|
|
159
161
|
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';
|
|
160
164
|
export type { SetActiveProductFee, SetActiveProductFeeParams, SetActiveProductFeeResponse, } from './actions/set-active-product-fee/types';
|
|
161
165
|
export type { SetActiveProductDiscount, SetActiveProductDiscountParams, SetActiveProductDiscountResponse, } from './actions/set-active-product-discount/types';
|
|
162
166
|
export type { GetActiveProduct, GetActiveProductResponse } from './actions/get-active-product/types';
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ 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';
|
|
23
25
|
import { setActiveProductFee } from './actions/set-active-product-fee/action';
|
|
24
26
|
import { setActiveProductDiscount } from './actions/set-active-product-discount/action';
|
|
25
27
|
import { getActiveProduct } from './actions/get-active-product/action';
|
|
@@ -157,6 +159,8 @@ export const command = {
|
|
|
157
159
|
// Product Actions
|
|
158
160
|
addProductNote,
|
|
159
161
|
addProductFee,
|
|
162
|
+
getProductModifierSelections,
|
|
163
|
+
setProductModifierSelections,
|
|
160
164
|
setActiveProductFee,
|
|
161
165
|
setActiveProductDiscount,
|
|
162
166
|
getActiveProduct,
|
|
@@ -12,6 +12,8 @@ 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';
|
|
15
17
|
import { mockRemoveProductDiscount } from '../../actions/remove-product-discount/mock';
|
|
16
18
|
import { mockRemoveProductFee } from '../../actions/remove-product-fee/mock';
|
|
17
19
|
import { mockSetActiveProductFee } from '../../actions/set-active-product-fee/mock';
|
|
@@ -112,6 +114,8 @@ export const RENDER_MOCKS = {
|
|
|
112
114
|
addOrderNote: mockAddOrderNote,
|
|
113
115
|
addProductDiscount: mockAddProductDiscount,
|
|
114
116
|
addProductFee: mockAddProductFee,
|
|
117
|
+
getProductModifierSelections: mockGetProductModifierSelections,
|
|
118
|
+
setProductModifierSelections: mockSetProductModifierSelections,
|
|
115
119
|
setActiveProductFee: mockSetActiveProductFee,
|
|
116
120
|
setActiveProductDiscount: mockSetActiveProductDiscount,
|
|
117
121
|
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, 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, 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';
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -21,6 +21,8 @@ export interface RenderProviderActions {
|
|
|
21
21
|
getFinalContext: GetFinalContext;
|
|
22
22
|
addProductNote: AddProductNote;
|
|
23
23
|
addProductFee: AddProductFee;
|
|
24
|
+
getProductModifierSelections: GetProductModifierSelections;
|
|
25
|
+
setProductModifierSelections: SetProductModifierSelections;
|
|
24
26
|
setActiveProductFee: SetActiveProductFee;
|
|
25
27
|
setActiveProductDiscount: SetActiveProductDiscount;
|
|
26
28
|
getActiveProduct: GetActiveProduct;
|
|
@@ -0,0 +1,16 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,6 +17,7 @@ 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";
|
|
20
21
|
import type { CartCreatedPayload } from "./cart-created/types";
|
|
21
22
|
import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
|
|
22
23
|
import type { ProductAddedPayload } from "./product-added/types";
|
|
@@ -32,5 +33,6 @@ import type { ProductFeeAddedPayload } from "./product-fee-added/types";
|
|
|
32
33
|
import type { ProductFeeRemovedPayload } from "./product-fee-removed/types";
|
|
33
34
|
import type { ProductNoteAddedPayload } from "./product-note-added/types";
|
|
34
35
|
import type { ProductNoteRemovedPayload } from "./product-note-removed/types";
|
|
35
|
-
|
|
36
|
-
export type
|
|
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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@final-commerce/command-frame",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-staging3.2",
|
|
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.
|
|
60
|
+
"@final-commerce/common": "2.2.3-staging3.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@commitlint/cli": "^19.0.0",
|