@final-commerce/command-frame 0.1.17 → 0.1.19
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/actions/remove-product-from-cart/action.d.ts +6 -0
- package/dist/actions/remove-product-from-cart/action.js +8 -0
- package/dist/actions/remove-product-from-cart/mock.d.ts +2 -0
- package/dist/actions/remove-product-from-cart/mock.js +32 -0
- package/dist/actions/remove-product-from-cart/types.d.ts +11 -0
- package/dist/actions/remove-product-from-cart/types.js +2 -0
- package/dist/actions/update-cart-item-quantity/action.d.ts +6 -0
- package/dist/actions/update-cart-item-quantity/action.js +8 -0
- package/dist/actions/update-cart-item-quantity/mock.d.ts +2 -0
- package/dist/actions/update-cart-item-quantity/mock.js +60 -0
- package/dist/actions/update-cart-item-quantity/types.d.ts +15 -0
- package/dist/actions/update-cart-item-quantity/types.js +2 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +10 -5
- package/dist/projects/render/mocks.js +4 -0
- package/dist/projects/render/types.d.ts +3 -1
- package/dist/pubsub/topics/cart/index.js +13 -8
- package/dist/pubsub/topics/cart/product-updated/types.d.ts +14 -0
- package/dist/pubsub/topics/cart/product-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/dist/pubsub/topics/customers/index.js +6 -6
- package/dist/pubsub/topics/orders/index.js +2 -2
- package/dist/pubsub/topics/payments/index.js +2 -2
- package/dist/pubsub/topics/products/index.js +2 -2
- package/dist/pubsub/topics/refunds/index.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove product from cart action
|
|
3
|
+
* Calls the removeProductFromCart action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const removeProductFromCart = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("removeProductFromCart", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MOCK_CART, mockPublishEvent } from "../../demo/database";
|
|
2
|
+
export const mockRemoveProductFromCart = async (params) => {
|
|
3
|
+
console.log("[Mock] removeProductFromCart called", params);
|
|
4
|
+
if (!params?.internalId) {
|
|
5
|
+
throw new Error('internalId is required');
|
|
6
|
+
}
|
|
7
|
+
const { internalId } = params;
|
|
8
|
+
// Find the product in the cart
|
|
9
|
+
const productIndex = MOCK_CART.products.findIndex(p => p.internalId === internalId);
|
|
10
|
+
if (productIndex === -1) {
|
|
11
|
+
throw new Error(`Cart item with internalId ${internalId} not found`);
|
|
12
|
+
}
|
|
13
|
+
const product = MOCK_CART.products[productIndex];
|
|
14
|
+
// Remove from cart
|
|
15
|
+
MOCK_CART.products.splice(productIndex, 1);
|
|
16
|
+
// Recalculate totals
|
|
17
|
+
const lineTotal = product.price * product.quantity;
|
|
18
|
+
MOCK_CART.subtotal -= lineTotal;
|
|
19
|
+
MOCK_CART.total -= lineTotal;
|
|
20
|
+
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
21
|
+
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
22
|
+
// Publish product-deleted event
|
|
23
|
+
mockPublishEvent('cart', 'product-deleted', {
|
|
24
|
+
product: product,
|
|
25
|
+
internalId: internalId
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
internalId: internalId,
|
|
30
|
+
timestamp: new Date().toISOString()
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RemoveProductFromCartParams {
|
|
2
|
+
/** The unique identifier for the specific cart item to remove. */
|
|
3
|
+
internalId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveProductFromCartResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
/** The unique identifier of the removed cart item. */
|
|
8
|
+
internalId: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
}
|
|
11
|
+
export type RemoveProductFromCart = (params?: RemoveProductFromCartParams) => Promise<RemoveProductFromCartResponse>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update cart item quantity action
|
|
3
|
+
* Calls the updateCartItemQuantity action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const updateCartItemQuantity = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("updateCartItemQuantity", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MOCK_CART, mockPublishEvent } from "../../demo/database";
|
|
2
|
+
export const mockUpdateCartItemQuantity = async (params) => {
|
|
3
|
+
console.log("[Mock] updateCartItemQuantity called", params);
|
|
4
|
+
if (!params?.internalId) {
|
|
5
|
+
throw new Error('internalId is required');
|
|
6
|
+
}
|
|
7
|
+
if (params.quantity === undefined || params.quantity === null) {
|
|
8
|
+
throw new Error('quantity is required');
|
|
9
|
+
}
|
|
10
|
+
const { internalId, quantity } = params;
|
|
11
|
+
// Find the product in the cart
|
|
12
|
+
const productIndex = MOCK_CART.products.findIndex(p => p.internalId === internalId);
|
|
13
|
+
if (productIndex === -1) {
|
|
14
|
+
throw new Error(`Cart item with internalId ${internalId} not found`);
|
|
15
|
+
}
|
|
16
|
+
const product = MOCK_CART.products[productIndex];
|
|
17
|
+
const previousQuantity = product.quantity;
|
|
18
|
+
// If quantity is 0, remove the item
|
|
19
|
+
if (quantity === 0) {
|
|
20
|
+
MOCK_CART.products.splice(productIndex, 1);
|
|
21
|
+
// Recalculate totals
|
|
22
|
+
const lineTotal = product.price * previousQuantity;
|
|
23
|
+
MOCK_CART.subtotal -= lineTotal;
|
|
24
|
+
MOCK_CART.total -= lineTotal;
|
|
25
|
+
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
26
|
+
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
27
|
+
// Publish product-deleted event
|
|
28
|
+
mockPublishEvent('cart', 'product-deleted', {
|
|
29
|
+
product: product,
|
|
30
|
+
internalId: internalId
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
internalId: internalId,
|
|
35
|
+
quantity: 0,
|
|
36
|
+
timestamp: new Date().toISOString()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Update quantity
|
|
40
|
+
const quantityDelta = quantity - previousQuantity;
|
|
41
|
+
product.quantity = quantity;
|
|
42
|
+
// Recalculate totals
|
|
43
|
+
const lineTotalDelta = product.price * quantityDelta;
|
|
44
|
+
MOCK_CART.subtotal += lineTotalDelta;
|
|
45
|
+
MOCK_CART.total += lineTotalDelta;
|
|
46
|
+
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
47
|
+
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
48
|
+
// Publish product-updated event
|
|
49
|
+
mockPublishEvent('cart', 'product-updated', {
|
|
50
|
+
product: product,
|
|
51
|
+
previousQuantity: previousQuantity,
|
|
52
|
+
newQuantity: quantity
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
internalId: internalId,
|
|
57
|
+
quantity: quantity,
|
|
58
|
+
timestamp: new Date().toISOString()
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface UpdateCartItemQuantityParams {
|
|
2
|
+
/** The unique identifier for the specific cart item to update. */
|
|
3
|
+
internalId: string;
|
|
4
|
+
/** The new quantity. If set to 0, the item will be removed from the cart. */
|
|
5
|
+
quantity: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateCartItemQuantityResponse {
|
|
8
|
+
success: boolean;
|
|
9
|
+
/** The unique identifier of the updated cart item. */
|
|
10
|
+
internalId: string;
|
|
11
|
+
/** The new quantity after the update. */
|
|
12
|
+
quantity: number;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
export type UpdateCartItemQuantity = (params?: UpdateCartItemQuantityParams) => Promise<UpdateCartItemQuantityResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare const command: {
|
|
|
10
10
|
readonly getRefunds: import("./actions/get-refunds/types").GetRefunds;
|
|
11
11
|
readonly addProductDiscount: import("./actions/add-product-discount/types").AddProductDiscount;
|
|
12
12
|
readonly addProductToCart: import("./actions/add-product-to-cart/types").AddProductToCart;
|
|
13
|
+
readonly removeProductFromCart: import("./actions/remove-product-from-cart/types").RemoveProductFromCart;
|
|
14
|
+
readonly updateCartItemQuantity: import("./actions/update-cart-item-quantity/types").UpdateCartItemQuantity;
|
|
13
15
|
readonly addCartDiscount: import("./actions/add-cart-discount/types").AddCartDiscount;
|
|
14
16
|
readonly getContext: import("./actions/get-context/types").GetContext;
|
|
15
17
|
readonly getFinalContext: import("./actions/get-final-context/types").GetFinalContext;
|
|
@@ -18,11 +20,11 @@ export declare const command: {
|
|
|
18
20
|
readonly adjustInventory: import("./actions/adjust-inventory/types").AdjustInventory;
|
|
19
21
|
readonly addOrderNote: import("./actions/add-order-note/types").AddOrderNote;
|
|
20
22
|
readonly addCartFee: import("./actions/add-cart-fee/types").AddCartFee;
|
|
23
|
+
readonly getCurrentCart: import("./actions/get-current-cart/types").GetCurrentCart;
|
|
21
24
|
readonly clearCart: import("./actions/clear-cart/types").ClearCart;
|
|
22
25
|
readonly parkOrder: import("./actions/park-order/types").ParkOrder;
|
|
23
26
|
readonly resumeParkedOrder: import("./actions/resume-parked-order/types").ResumeParkedOrder;
|
|
24
27
|
readonly deleteParkedOrder: import("./actions/delete-parked-order/types").DeleteParkedOrder;
|
|
25
|
-
readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
|
|
26
28
|
readonly cashPayment: import("./actions/cash-payment/types").CashPayment;
|
|
27
29
|
readonly tapToPayPayment: import("./actions/tap-to-pay-payment/types").TapToPayPayment;
|
|
28
30
|
readonly terminalPayment: import("./actions/terminal-payment/types").TerminalPayment;
|
|
@@ -38,13 +40,13 @@ export declare const command: {
|
|
|
38
40
|
readonly switchUser: import("./actions/switch-user/types").SwitchUser;
|
|
39
41
|
readonly triggerWebhook: import("./actions/trigger-webhook/types").TriggerWebhook;
|
|
40
42
|
readonly triggerZapierWebhook: import("./actions/trigger-zapier-webhook/types").TriggerZapierWebhook;
|
|
43
|
+
readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
|
|
41
44
|
readonly setRefundStockAction: import("./actions/set-refund-stock-action/types").SetRefundStockAction;
|
|
42
45
|
readonly selectAllRefundItems: import("./actions/select-all-refund-items/types").SelectAllRefundItems;
|
|
43
46
|
readonly resetRefundDetails: import("./actions/reset-refund-details/types").ResetRefundDetails;
|
|
44
47
|
readonly calculateRefundTotal: import("./actions/calculate-refund-total/types").CalculateRefundTotal;
|
|
45
48
|
readonly getRemainingRefundableQuantities: import("./actions/get-remaining-refundable-quantities/types").GetRemainingRefundableQuantities;
|
|
46
49
|
readonly processPartialRefund: import("./actions/process-partial-refund/types").ProcessPartialRefund;
|
|
47
|
-
readonly getCurrentCart: import("./actions/get-current-cart/types").GetCurrentCart;
|
|
48
50
|
};
|
|
49
51
|
export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from "./actions/example-function/types";
|
|
50
52
|
export type { GetProducts, GetProductsParams, GetProductsResponse } from "./actions/get-products/types";
|
|
@@ -61,9 +63,12 @@ export type { ResetRefundDetails, ResetRefundDetailsResponse } from "./actions/r
|
|
|
61
63
|
export type { CalculateRefundTotal, CalculateRefundTotalParams, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
|
|
62
64
|
export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
|
|
63
65
|
export type { ProcessPartialRefund, ProcessPartialRefundParams, ProcessPartialRefundResponse } from "./actions/process-partial-refund/types";
|
|
66
|
+
export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from "./actions/initiate-refund/types";
|
|
64
67
|
export type { GetCurrentCart, GetCurrentCartResponse } from "./actions/get-current-cart/types";
|
|
65
68
|
export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse } from "./actions/add-product-discount/types";
|
|
66
69
|
export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
|
|
70
|
+
export type { RemoveProductFromCart, RemoveProductFromCartParams, RemoveProductFromCartResponse } from "./actions/remove-product-from-cart/types";
|
|
71
|
+
export type { UpdateCartItemQuantity, UpdateCartItemQuantityParams, UpdateCartItemQuantityResponse } from "./actions/update-cart-item-quantity/types";
|
|
67
72
|
export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
|
|
68
73
|
export type { GetContext, GetContextResponse } from "./actions/get-context/types";
|
|
69
74
|
export type { GetFinalContext, GetFinalContextResponse } from "./actions/get-final-context/types";
|
|
@@ -76,7 +81,6 @@ export type { ClearCart, ClearCartResponse } from "./actions/clear-cart/types";
|
|
|
76
81
|
export type { ParkOrder, ParkOrderResponse } from "./actions/park-order/types";
|
|
77
82
|
export type { ResumeParkedOrder, ResumeParkedOrderParams, ResumeParkedOrderResponse } from "./actions/resume-parked-order/types";
|
|
78
83
|
export type { DeleteParkedOrder, DeleteParkedOrderParams, DeleteParkedOrderResponse } from "./actions/delete-parked-order/types";
|
|
79
|
-
export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from "./actions/initiate-refund/types";
|
|
80
84
|
export type { CashPayment, CashPaymentParams, CashPaymentResponse } from "./actions/cash-payment/types";
|
|
81
85
|
export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse } from "./actions/tap-to-pay-payment/types";
|
|
82
86
|
export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from "./actions/terminal-payment/types";
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,13 @@ import { assignCustomer } from "./actions/assign-customer/action";
|
|
|
7
7
|
import { addCustomer } from "./actions/add-customer/action";
|
|
8
8
|
import { getCategories } from "./actions/get-categories/action";
|
|
9
9
|
import { getOrders } from "./actions/get-orders/action";
|
|
10
|
-
import { getRefunds } from "./actions/get-refunds/action";
|
|
11
10
|
import { addCartDiscount } from "./actions/add-cart-discount/action";
|
|
12
11
|
import { getContext } from "./actions/get-context/action";
|
|
13
12
|
import { getFinalContext } from "./actions/get-final-context/action";
|
|
14
13
|
import { addProductDiscount } from "./actions/add-product-discount/action";
|
|
15
14
|
import { addProductToCart } from "./actions/add-product-to-cart/action";
|
|
15
|
+
import { removeProductFromCart } from "./actions/remove-product-from-cart/action";
|
|
16
|
+
import { updateCartItemQuantity } from "./actions/update-cart-item-quantity/action";
|
|
16
17
|
// Product Actions
|
|
17
18
|
import { addProductNote } from "./actions/add-product-note/action";
|
|
18
19
|
import { addProductFee } from "./actions/add-product-fee/action";
|
|
@@ -20,11 +21,11 @@ import { adjustInventory } from "./actions/adjust-inventory/action";
|
|
|
20
21
|
// Order Actions
|
|
21
22
|
import { addOrderNote } from "./actions/add-order-note/action";
|
|
22
23
|
import { addCartFee } from "./actions/add-cart-fee/action";
|
|
24
|
+
import { getCurrentCart } from "./actions/get-current-cart/action";
|
|
23
25
|
import { clearCart } from "./actions/clear-cart/action";
|
|
24
26
|
import { parkOrder } from "./actions/park-order/action";
|
|
25
27
|
import { resumeParkedOrder } from "./actions/resume-parked-order/action";
|
|
26
28
|
import { deleteParkedOrder } from "./actions/delete-parked-order/action";
|
|
27
|
-
import { initiateRefund } from "./actions/initiate-refund/action";
|
|
28
29
|
import { cashPayment } from "./actions/cash-payment/action";
|
|
29
30
|
import { tapToPayPayment } from "./actions/tap-to-pay-payment/action";
|
|
30
31
|
import { terminalPayment } from "./actions/terminal-payment/action";
|
|
@@ -43,13 +44,15 @@ import { switchUser } from "./actions/switch-user/action";
|
|
|
43
44
|
// Integration Actions
|
|
44
45
|
import { triggerWebhook } from "./actions/trigger-webhook/action";
|
|
45
46
|
import { triggerZapierWebhook } from "./actions/trigger-zapier-webhook/action";
|
|
47
|
+
// Refund Actions
|
|
48
|
+
import { getRefunds } from "./actions/get-refunds/action";
|
|
49
|
+
import { initiateRefund } from "./actions/initiate-refund/action";
|
|
46
50
|
import { setRefundStockAction } from "./actions/set-refund-stock-action/action";
|
|
47
51
|
import { selectAllRefundItems } from "./actions/select-all-refund-items/action";
|
|
48
52
|
import { resetRefundDetails } from "./actions/reset-refund-details/action";
|
|
49
53
|
import { calculateRefundTotal } from "./actions/calculate-refund-total/action";
|
|
50
54
|
import { getRemainingRefundableQuantities } from "./actions/get-remaining-refundable-quantities/action";
|
|
51
55
|
import { processPartialRefund } from "./actions/process-partial-refund/action";
|
|
52
|
-
import { getCurrentCart } from "./actions/get-current-cart/action";
|
|
53
56
|
// Export actions as command object
|
|
54
57
|
export const command = {
|
|
55
58
|
exampleFunction,
|
|
@@ -63,6 +66,8 @@ export const command = {
|
|
|
63
66
|
getRefunds,
|
|
64
67
|
addProductDiscount,
|
|
65
68
|
addProductToCart,
|
|
69
|
+
removeProductFromCart,
|
|
70
|
+
updateCartItemQuantity,
|
|
66
71
|
addCartDiscount,
|
|
67
72
|
getContext,
|
|
68
73
|
getFinalContext,
|
|
@@ -73,11 +78,11 @@ export const command = {
|
|
|
73
78
|
// Order Actions
|
|
74
79
|
addOrderNote,
|
|
75
80
|
addCartFee,
|
|
81
|
+
getCurrentCart,
|
|
76
82
|
clearCart,
|
|
77
83
|
parkOrder,
|
|
78
84
|
resumeParkedOrder,
|
|
79
85
|
deleteParkedOrder,
|
|
80
|
-
initiateRefund,
|
|
81
86
|
cashPayment,
|
|
82
87
|
tapToPayPayment,
|
|
83
88
|
terminalPayment,
|
|
@@ -97,13 +102,13 @@ export const command = {
|
|
|
97
102
|
triggerWebhook,
|
|
98
103
|
triggerZapierWebhook,
|
|
99
104
|
// Refund Actions
|
|
105
|
+
initiateRefund,
|
|
100
106
|
setRefundStockAction,
|
|
101
107
|
selectAllRefundItems,
|
|
102
108
|
resetRefundDetails,
|
|
103
109
|
calculateRefundTotal,
|
|
104
110
|
getRemainingRefundableQuantities,
|
|
105
111
|
processPartialRefund,
|
|
106
|
-
getCurrentCart
|
|
107
112
|
};
|
|
108
113
|
// Export Common Types
|
|
109
114
|
export * from "./CommonTypes";
|
|
@@ -8,6 +8,8 @@ import { mockAddProductDiscount } from "../../actions/add-product-discount/mock"
|
|
|
8
8
|
import { mockAddProductFee } from "../../actions/add-product-fee/mock";
|
|
9
9
|
import { mockAddProductNote } from "../../actions/add-product-note/mock";
|
|
10
10
|
import { mockAddProductToCart } from "../../actions/add-product-to-cart/mock";
|
|
11
|
+
import { mockRemoveProductFromCart } from "../../actions/remove-product-from-cart/mock";
|
|
12
|
+
import { mockUpdateCartItemQuantity } from "../../actions/update-cart-item-quantity/mock";
|
|
11
13
|
import { mockAdjustInventory } from "../../actions/adjust-inventory/mock";
|
|
12
14
|
import { mockAssignCustomer } from "../../actions/assign-customer/mock";
|
|
13
15
|
import { mockAuthenticateUser } from "../../actions/authenticate-user/mock";
|
|
@@ -55,6 +57,8 @@ export const RENDER_MOCKS = {
|
|
|
55
57
|
addProductFee: mockAddProductFee,
|
|
56
58
|
addProductNote: mockAddProductNote,
|
|
57
59
|
addProductToCart: mockAddProductToCart,
|
|
60
|
+
removeProductFromCart: mockRemoveProductFromCart,
|
|
61
|
+
updateCartItemQuantity: mockUpdateCartItemQuantity,
|
|
58
62
|
adjustInventory: mockAdjustInventory,
|
|
59
63
|
assignCustomer: mockAssignCustomer,
|
|
60
64
|
authenticateUser: mockAuthenticateUser,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart } from "../../index";
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart } from "../../index";
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -11,6 +11,8 @@ export interface RenderProviderActions {
|
|
|
11
11
|
getRefunds: GetRefunds;
|
|
12
12
|
addProductDiscount: AddProductDiscount;
|
|
13
13
|
addProductToCart: AddProductToCart;
|
|
14
|
+
removeProductFromCart: RemoveProductFromCart;
|
|
15
|
+
updateCartItemQuantity: UpdateCartItemQuantity;
|
|
14
16
|
addCartDiscount: AddCartDiscount;
|
|
15
17
|
getContext: GetContext;
|
|
16
18
|
getFinalContext: GetFinalContext;
|
|
@@ -10,42 +10,47 @@ export const cartTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "cart-created",
|
|
12
12
|
name: "Cart Created",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a new cart is created"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "customer-assigned",
|
|
17
17
|
name: "Customer Assigned",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when a customer is assigned to the cart"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
id: "product-added",
|
|
22
22
|
name: "Product Added",
|
|
23
|
-
description: "
|
|
23
|
+
description: "Published when a product is added to the cart"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
id: "product-deleted",
|
|
27
27
|
name: "Product Deleted",
|
|
28
|
-
description: "
|
|
28
|
+
description: "Published when a product is removed from the cart"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "product-updated",
|
|
32
|
+
name: "Product Updated",
|
|
33
|
+
description: "Published when a product's quantity is updated in the cart"
|
|
29
34
|
},
|
|
30
35
|
{
|
|
31
36
|
id: "cart-discount-added",
|
|
32
37
|
name: "Cart Discount Added",
|
|
33
|
-
description: "
|
|
38
|
+
description: "Published when a discount is added to the cart"
|
|
34
39
|
},
|
|
35
40
|
{
|
|
36
41
|
id: "cart-discount-removed",
|
|
37
42
|
name: "Cart Discount Removed",
|
|
38
|
-
description: "
|
|
43
|
+
description: "Published when a discount is removed from the cart"
|
|
39
44
|
},
|
|
40
45
|
{
|
|
41
46
|
id: "cart-fee-added",
|
|
42
47
|
name: "Cart Fee Added",
|
|
43
|
-
description: "
|
|
48
|
+
description: "Published when a fee is added to the cart"
|
|
44
49
|
},
|
|
45
50
|
{
|
|
46
51
|
id: "cart-fee-removed",
|
|
47
52
|
name: "Cart Fee Removed",
|
|
48
|
-
description: "
|
|
53
|
+
description: "Published when a fee is removed from the cart"
|
|
49
54
|
}
|
|
50
55
|
]
|
|
51
56
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for cart product-updated event
|
|
5
|
+
*/
|
|
6
|
+
export interface CartProductUpdatedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
previousQuantity: number;
|
|
9
|
+
newQuantity: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Typed event for cart product-updated
|
|
13
|
+
*/
|
|
14
|
+
export type CartProductUpdatedEvent = TopicEvent<CartProductUpdatedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export * from "./cart-created/types";
|
|
|
6
6
|
export * from "./customer-assigned/types";
|
|
7
7
|
export * from "./product-added/types";
|
|
8
8
|
export * from "./product-deleted/types";
|
|
9
|
+
export * from "./product-updated/types";
|
|
9
10
|
export * from "./cart-discount-added/types";
|
|
10
11
|
export * from "./cart-discount-removed/types";
|
|
11
12
|
export * from "./cart-fee-added/types";
|
|
@@ -14,9 +15,10 @@ import type { CartCreatedPayload } from "./cart-created/types";
|
|
|
14
15
|
import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
|
|
15
16
|
import type { ProductAddedPayload } from "./product-added/types";
|
|
16
17
|
import type { ProductDeletedPayload } from "./product-deleted/types";
|
|
18
|
+
import type { CartProductUpdatedPayload } from "./product-updated/types";
|
|
17
19
|
import type { CartDiscountAddedPayload } from "./cart-discount-added/types";
|
|
18
20
|
import type { CartDiscountRemovedPayload } from "./cart-discount-removed/types";
|
|
19
21
|
import type { CartFeeAddedPayload } from "./cart-fee-added/types";
|
|
20
22
|
import type { CartFeeRemovedPayload } from "./cart-fee-removed/types";
|
|
21
|
-
export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload;
|
|
22
|
-
export type CartEventType = "cart-created" | "customer-assigned" | "product-added" | "product-deleted" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed";
|
|
23
|
+
export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartProductUpdatedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload;
|
|
24
|
+
export type CartEventType = "cart-created" | "customer-assigned" | "product-added" | "product-deleted" | "product-updated" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed";
|
|
@@ -7,6 +7,7 @@ export * from "./cart-created/types";
|
|
|
7
7
|
export * from "./customer-assigned/types";
|
|
8
8
|
export * from "./product-added/types";
|
|
9
9
|
export * from "./product-deleted/types";
|
|
10
|
+
export * from "./product-updated/types";
|
|
10
11
|
export * from "./cart-discount-added/types";
|
|
11
12
|
export * from "./cart-discount-removed/types";
|
|
12
13
|
export * from "./cart-fee-added/types";
|
|
@@ -10,32 +10,32 @@ export const customersTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "customer-created",
|
|
12
12
|
name: "Customer Created",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a new customer is created"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "customer-updated",
|
|
17
17
|
name: "Customer Updated",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when a customer is updated"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
id: "customer-note-added",
|
|
22
22
|
name: "Customer Note Added",
|
|
23
|
-
description: "
|
|
23
|
+
description: "Published when a note is added to a customer"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
id: "customer-note-deleted",
|
|
27
27
|
name: "Customer Note Deleted",
|
|
28
|
-
description: "
|
|
28
|
+
description: "Published when a note is deleted from a customer"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
id: "customer-assigned",
|
|
32
32
|
name: "Customer Assigned",
|
|
33
|
-
description: "
|
|
33
|
+
description: "Published when a customer is assigned to the cart"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
id: "customer-unassigned",
|
|
37
37
|
name: "Customer Unassigned",
|
|
38
|
-
description: "
|
|
38
|
+
description: "Published when a customer is unassigned from the cart"
|
|
39
39
|
}
|
|
40
40
|
]
|
|
41
41
|
};
|
|
@@ -10,12 +10,12 @@ export const ordersTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "order-created",
|
|
12
12
|
name: "Order Created",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a new order is created"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "order-updated",
|
|
17
17
|
name: "Order Updated",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when an order is updated"
|
|
19
19
|
}
|
|
20
20
|
]
|
|
21
21
|
};
|
|
@@ -10,12 +10,12 @@ export const paymentsTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "payment-done",
|
|
12
12
|
name: "Payment Done",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a payment is successfully completed"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "payment-err",
|
|
17
17
|
name: "Payment Error",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when a payment error occurs"
|
|
19
19
|
}
|
|
20
20
|
]
|
|
21
21
|
};
|
|
@@ -10,12 +10,12 @@ export const productsTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "product-created",
|
|
12
12
|
name: "Product Created",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a new product is synced/created"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "product-updated",
|
|
17
17
|
name: "Product Updated",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when a product is synced/updated"
|
|
19
19
|
}
|
|
20
20
|
]
|
|
21
21
|
};
|
|
@@ -10,12 +10,12 @@ export const refundsTopic = {
|
|
|
10
10
|
{
|
|
11
11
|
id: "refund-created",
|
|
12
12
|
name: "Refund Created",
|
|
13
|
-
description: "
|
|
13
|
+
description: "Published when a new refund is created"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "refund-updated",
|
|
17
17
|
name: "Refund Updated",
|
|
18
|
-
description: "
|
|
18
|
+
description: "Published when a refund is updated"
|
|
19
19
|
}
|
|
20
20
|
]
|
|
21
21
|
};
|