@final-commerce/command-frame 0.1.60 → 0.1.62
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/CommonTypes.d.ts +1 -0
- package/dist/actions/add-customer-note/mock.js +1 -0
- package/dist/actions/remove-cart-fee/action.d.ts +2 -0
- package/dist/actions/remove-cart-fee/action.js +4 -0
- package/dist/actions/remove-cart-fee/mock.d.ts +2 -0
- package/dist/actions/remove-cart-fee/mock.js +35 -0
- package/dist/actions/remove-cart-fee/types.d.ts +9 -0
- package/dist/actions/remove-custom-sale/action.d.ts +2 -0
- package/dist/actions/remove-custom-sale/action.js +4 -0
- package/dist/actions/remove-custom-sale/types.d.ts +10 -0
- package/dist/actions/remove-custom-sale/types.js +1 -0
- package/dist/actions/remove-customer-note/action.d.ts +6 -0
- package/dist/actions/remove-customer-note/action.js +8 -0
- package/dist/actions/remove-customer-note/mock.d.ts +2 -0
- package/dist/actions/remove-customer-note/mock.js +13 -0
- package/dist/actions/remove-customer-note/types.d.ts +9 -0
- package/dist/actions/remove-customer-note/types.js +1 -0
- package/dist/actions/remove-non-revenue-item/action.d.ts +2 -0
- package/dist/actions/remove-non-revenue-item/action.js +4 -0
- package/dist/actions/remove-non-revenue-item/types.d.ts +10 -0
- package/dist/actions/remove-non-revenue-item/types.js +1 -0
- package/dist/actions/remove-order-note/action.d.ts +2 -0
- package/dist/actions/remove-order-note/action.js +4 -0
- package/dist/actions/remove-order-note/types.d.ts +5 -0
- package/dist/actions/remove-order-note/types.js +1 -0
- package/dist/actions/remove-product-discount/action.d.ts +2 -0
- package/dist/actions/remove-product-discount/action.js +4 -0
- package/dist/actions/remove-product-discount/types.d.ts +10 -0
- package/dist/actions/remove-product-discount/types.js +1 -0
- package/dist/actions/remove-product-fee/action.d.ts +2 -0
- package/dist/actions/remove-product-fee/action.js +4 -0
- package/dist/actions/remove-product-fee/types.d.ts +10 -0
- package/dist/actions/remove-product-fee/types.js +1 -0
- package/dist/actions/remove-product-note/action.d.ts +2 -0
- package/dist/actions/remove-product-note/action.js +4 -0
- package/dist/actions/remove-product-note/types.d.ts +10 -0
- package/dist/actions/remove-product-note/types.js +1 -0
- package/dist/index.d.ts +17 -3
- package/dist/index.js +18 -2
- package/dist/projects/render/mocks.js +11 -3
- package/dist/projects/render/types.d.ts +9 -2
- package/dist/pubsub/topics/cart/index.js +30 -0
- package/dist/pubsub/topics/cart/product-discount-added/types.d.ts +18 -0
- package/dist/pubsub/topics/cart/product-discount-added/types.js +1 -0
- package/dist/pubsub/topics/cart/product-discount-removed/types.d.ts +13 -0
- package/dist/pubsub/topics/cart/product-discount-removed/types.js +1 -0
- package/dist/pubsub/topics/cart/product-fee-added/types.d.ts +19 -0
- package/dist/pubsub/topics/cart/product-fee-added/types.js +1 -0
- package/dist/pubsub/topics/cart/product-fee-removed/types.d.ts +13 -0
- package/dist/pubsub/topics/cart/product-fee-removed/types.js +1 -0
- package/dist/pubsub/topics/cart/product-note-added/types.d.ts +14 -0
- package/dist/pubsub/topics/cart/product-note-added/types.js +1 -0
- package/dist/pubsub/topics/cart/product-note-removed/types.d.ts +13 -0
- package/dist/pubsub/topics/cart/product-note-removed/types.js +1 -0
- package/dist/pubsub/topics/cart/types.d.ts +14 -2
- package/dist/pubsub/topics/cart/types.js +6 -0
- package/package.json +21 -2
- package/dist/actions/get-active-refund/action.d.ts +0 -2
- package/dist/actions/get-active-refund/action.js +0 -4
- package/dist/actions/get-active-refund/mock.d.ts +0 -2
- package/dist/actions/get-active-refund/mock.js +0 -9
- package/dist/actions/get-active-refund/types.d.ts +0 -7
- /package/dist/actions/{get-active-refund → remove-cart-fee}/types.js +0 -0
package/dist/CommonTypes.d.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MOCK_CART, mockPublishEvent } from "../../demo/database";
|
|
2
|
+
function feeContributionToTotal(fee, subtotal) {
|
|
3
|
+
if (fee.isPercent) {
|
|
4
|
+
return subtotal * (fee.amount / 100);
|
|
5
|
+
}
|
|
6
|
+
return fee.amount;
|
|
7
|
+
}
|
|
8
|
+
export const mockRemoveCartFee = (params) => {
|
|
9
|
+
console.log("[Mock] removeCartFee called", params);
|
|
10
|
+
const { index } = params;
|
|
11
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) {
|
|
12
|
+
throw new Error("removeCartFee requires a non-negative integer index");
|
|
13
|
+
}
|
|
14
|
+
const fees = MOCK_CART.customFee;
|
|
15
|
+
if (!fees?.length) {
|
|
16
|
+
throw new Error("Cart has no fees to remove");
|
|
17
|
+
}
|
|
18
|
+
if (index >= fees.length) {
|
|
19
|
+
throw new Error(`Cart fee index ${index} is out of range (0–${fees.length - 1})`);
|
|
20
|
+
}
|
|
21
|
+
const removed = fees[index];
|
|
22
|
+
const delta = feeContributionToTotal(removed, MOCK_CART.subtotal);
|
|
23
|
+
fees.splice(index, 1);
|
|
24
|
+
if (fees.length === 0) {
|
|
25
|
+
MOCK_CART.customFee = undefined;
|
|
26
|
+
}
|
|
27
|
+
MOCK_CART.total -= delta;
|
|
28
|
+
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
29
|
+
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
30
|
+
mockPublishEvent("cart", "cart-fee-removed", { feeIndex: index });
|
|
31
|
+
return Promise.resolve({
|
|
32
|
+
success: true,
|
|
33
|
+
timestamp: new Date().toISOString()
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RemoveCartFeeParams {
|
|
2
|
+
/** Index of fee to remove from cart.customFee array */
|
|
3
|
+
index: number;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveCartFeeResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
}
|
|
9
|
+
export type RemoveCartFee = (params: RemoveCartFeeParams) => Promise<RemoveCartFeeResponse>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RemoveCustomSaleParams {
|
|
2
|
+
/** The id of the custom sale to remove */
|
|
3
|
+
id: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveCustomSaleResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type RemoveCustomSale = (params: RemoveCustomSaleParams) => Promise<RemoveCustomSaleResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove customer note action
|
|
3
|
+
* Calls the removeCustomerNote action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const removeCustomerNote = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("removeCustomerNote", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const mockRemoveCustomerNote = async (params) => {
|
|
2
|
+
console.log("[Mock] removeCustomerNote called", params);
|
|
3
|
+
const noteId = params?.noteId ?? "";
|
|
4
|
+
const timestamp = new Date().toISOString();
|
|
5
|
+
if (!noteId) {
|
|
6
|
+
return { success: false, noteId, timestamp };
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
success: true,
|
|
10
|
+
noteId,
|
|
11
|
+
timestamp
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RemoveCustomerNoteParams {
|
|
2
|
+
noteId: string;
|
|
3
|
+
}
|
|
4
|
+
export interface RemoveCustomerNoteResponse {
|
|
5
|
+
success: boolean;
|
|
6
|
+
noteId: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
}
|
|
9
|
+
export type RemoveCustomerNote = (params?: RemoveCustomerNoteParams) => Promise<RemoveCustomerNoteResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RemoveNonRevenueItemParams {
|
|
2
|
+
/** The externalId of the non-revenue item to remove */
|
|
3
|
+
externalId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveNonRevenueItemResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
externalId: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type RemoveNonRevenueItem = (params: RemoveNonRevenueItemParams) => Promise<RemoveNonRevenueItemResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RemoveProductDiscountParams {
|
|
2
|
+
/** If provided, removes discount from specific cart item. Otherwise uses active product. */
|
|
3
|
+
internalId?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveProductDiscountResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
internalId?: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type RemoveProductDiscount = (params?: RemoveProductDiscountParams) => Promise<RemoveProductDiscountResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RemoveProductFeeParams {
|
|
2
|
+
/** If provided, removes fee from specific cart item. Otherwise uses active product. */
|
|
3
|
+
internalId?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveProductFeeResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
internalId?: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type RemoveProductFee = (params?: RemoveProductFeeParams) => Promise<RemoveProductFeeResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RemoveProductNoteParams {
|
|
2
|
+
/** If provided, removes note from specific cart item. Otherwise uses active product. */
|
|
3
|
+
internalId?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RemoveProductNoteResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
internalId?: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type RemoveProductNote = (params?: RemoveProductNoteParams) => Promise<RemoveProductNoteResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare const command: {
|
|
|
39
39
|
readonly extensionPayment: import("./actions/extension-payment/types").ExtensionPayment;
|
|
40
40
|
readonly redeemPayment: import("./actions/redeem-payment/types").RedeemPayment;
|
|
41
41
|
readonly addCustomerNote: import("./actions/add-customer-note/types").AddCustomerNote;
|
|
42
|
+
readonly removeCustomerNote: import("./actions/remove-customer-note/types").RemoveCustomerNote;
|
|
42
43
|
readonly removeCustomerFromCart: import("./actions/remove-customer-from-cart/types").RemoveCustomerFromCart;
|
|
43
44
|
readonly removeCartDiscount: import("./actions/remove-cart-discount/types").RemoveCartDiscount;
|
|
44
45
|
readonly goToStationHome: import("./actions/go-to-station-home/types").GoToStationHome;
|
|
@@ -61,8 +62,14 @@ export declare const command: {
|
|
|
61
62
|
readonly setActiveSession: import("./actions/set-active-session/types").SetActiveSession;
|
|
62
63
|
readonly getActiveUser: import("./actions/get-active-user/types").GetActiveUser;
|
|
63
64
|
readonly setActiveUser: import("./actions/set-active-user/types").SetActiveUser;
|
|
64
|
-
readonly getActiveRefund: import("./actions/get-active-refund/types").GetActiveRefund;
|
|
65
65
|
readonly setActiveRefund: import("./actions/set-active-refund/types").SetActiveRefund;
|
|
66
|
+
readonly removeProductDiscount: import("./actions/remove-product-discount/types").RemoveProductDiscount;
|
|
67
|
+
readonly removeProductFee: import("./actions/remove-product-fee/types").RemoveProductFee;
|
|
68
|
+
readonly removeProductNote: import("./actions/remove-product-note/types").RemoveProductNote;
|
|
69
|
+
readonly removeCartFee: import("./actions/remove-cart-fee/types").RemoveCartFee;
|
|
70
|
+
readonly removeOrderNote: import("./actions/remove-order-note/types").RemoveOrderNote;
|
|
71
|
+
readonly removeCustomSale: import("./actions/remove-custom-sale/types").RemoveCustomSale;
|
|
72
|
+
readonly removeNonRevenueItem: import("./actions/remove-non-revenue-item/types").RemoveNonRevenueItem;
|
|
66
73
|
readonly triggerWebhook: import("./actions/trigger-webhook/types").TriggerWebhook;
|
|
67
74
|
readonly triggerZapierWebhook: import("./actions/trigger-zapier-webhook/types").TriggerZapierWebhook;
|
|
68
75
|
readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
|
|
@@ -154,6 +161,7 @@ export { EXTENSION_REFUND_REQUEST_ACTION } from "./actions/extension-refund/cons
|
|
|
154
161
|
export { installExtensionRefundListener } from "./actions/extension-refund/extension-refund-listener";
|
|
155
162
|
export type { ExtensionRefundParams, ExtensionRefundResponse } from "./actions/extension-refund/types";
|
|
156
163
|
export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse } from "./actions/add-customer-note/types";
|
|
164
|
+
export type { RemoveCustomerNote, RemoveCustomerNoteParams, RemoveCustomerNoteResponse } from "./actions/remove-customer-note/types";
|
|
157
165
|
export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from "./actions/remove-customer-from-cart/types";
|
|
158
166
|
export type { RemoveCartDiscount, RemoveCartDiscountResponse } from "./actions/remove-cart-discount/types";
|
|
159
167
|
export type { GoToStationHome, GoToStationHomeResponse } from "./actions/go-to-station-home/types";
|
|
@@ -182,8 +190,14 @@ export type { GetActiveSession, GetActiveSessionResponse } from "./actions/get-a
|
|
|
182
190
|
export type { SetActiveSession, SetActiveSessionParams, SetActiveSessionResponse } from "./actions/set-active-session/types";
|
|
183
191
|
export type { GetActiveUser, GetActiveUserResponse } from "./actions/get-active-user/types";
|
|
184
192
|
export type { SetActiveUser, SetActiveUserParams, SetActiveUserResponse } from "./actions/set-active-user/types";
|
|
185
|
-
export type { GetActiveRefund, GetActiveRefundResponse } from "./actions/get-active-refund/types";
|
|
186
193
|
export type { SetActiveRefund, SetActiveRefundParams, SetActiveRefundResponse } from "./actions/set-active-refund/types";
|
|
194
|
+
export type { RemoveProductDiscount, RemoveProductDiscountParams, RemoveProductDiscountResponse } from "./actions/remove-product-discount/types";
|
|
195
|
+
export type { RemoveProductFee, RemoveProductFeeParams, RemoveProductFeeResponse } from "./actions/remove-product-fee/types";
|
|
196
|
+
export type { RemoveProductNote, RemoveProductNoteParams, RemoveProductNoteResponse } from "./actions/remove-product-note/types";
|
|
197
|
+
export type { RemoveCartFee, RemoveCartFeeParams, RemoveCartFeeResponse } from "./actions/remove-cart-fee/types";
|
|
198
|
+
export type { RemoveOrderNote, RemoveOrderNoteResponse } from "./actions/remove-order-note/types";
|
|
199
|
+
export type { RemoveCustomSale, RemoveCustomSaleParams, RemoveCustomSaleResponse } from "./actions/remove-custom-sale/types";
|
|
200
|
+
export type { RemoveNonRevenueItem, RemoveNonRevenueItemParams, RemoveNonRevenueItemResponse } from "./actions/remove-non-revenue-item/types";
|
|
187
201
|
export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
|
|
188
202
|
export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
|
|
189
203
|
export * from "./CommonTypes";
|
|
@@ -220,7 +234,7 @@ export type { OutletActiveSetPayload, OutletActiveGetPayload, OutletActiveSetEve
|
|
|
220
234
|
export type { StationActiveSetPayload, StationActiveGetPayload, StationActiveSetEvent, StationActiveGetEvent, StationEventType, StationEventPayload } from "./pubsub/topics/station/types";
|
|
221
235
|
export type { SessionActiveSetPayload, SessionActiveGetPayload, SessionActiveSetEvent, SessionActiveGetEvent, SessionEventType, SessionEventPayload } from "./pubsub/topics/session/types";
|
|
222
236
|
export type { UserActiveSetPayload, UserActiveGetPayload, UserActiveSetEvent, UserActiveGetEvent, UsersEventType, UsersEventPayload } from "./pubsub/topics/users/types";
|
|
223
|
-
export type { CartCreatedPayload, CartCustomerAssignedPayload, ProductAddedPayload, ProductDeletedPayload, CartDiscountAddedPayload, CartDiscountRemovedPayload, CartFeeAddedPayload, CartFeeRemovedPayload, CartCreatedEvent, CartCustomerAssignedEvent, ProductAddedEvent, ProductDeletedEvent, CartDiscountAddedEvent, CartDiscountRemovedEvent, CartFeeAddedEvent, CartFeeRemovedEvent, CartEventType, CartEventPayload } from "./pubsub/topics/cart/types";
|
|
237
|
+
export type { CartCreatedPayload, CartCustomerAssignedPayload, ProductAddedPayload, ProductDeletedPayload, CartDiscountAddedPayload, CartDiscountRemovedPayload, CartFeeAddedPayload, CartFeeRemovedPayload, ProductDiscountAddedPayload, ProductDiscountRemovedPayload, ProductFeeAddedPayload, ProductFeeRemovedPayload, ProductNoteAddedPayload, ProductNoteRemovedPayload, CartCreatedEvent, CartCustomerAssignedEvent, ProductAddedEvent, ProductDeletedEvent, CartDiscountAddedEvent, CartDiscountRemovedEvent, CartFeeAddedEvent, CartFeeRemovedEvent, ProductDiscountAddedEvent, ProductDiscountRemovedEvent, ProductFeeAddedEvent, ProductFeeRemovedEvent, ProductNoteAddedEvent, ProductNoteRemovedEvent, CartEventType, CartEventPayload } from "./pubsub/topics/cart/types";
|
|
224
238
|
export type { PaymentDonePayload, PaymentErrPayload, PaymentDoneEvent, PaymentErrEvent, PaymentsEventType, PaymentsEventPayload } from "./pubsub/topics/payments/types";
|
|
225
239
|
export type { RowCreatedPayload, RowUpdatedPayload, RowDeletedPayload, RowCreatedEvent, RowUpdatedEvent, RowDeletedEvent, CustomTablesEventType, CustomTablesEventPayload } from "./pubsub/topics/custom-tables/types";
|
|
226
240
|
export type { PrintStartedPayload, PrintCompletedPayload, PrintErrorPayload, PrintStartedEvent, PrintCompletedEvent, PrintErrorEvent, PrintEventType, PrintEventPayload } from "./pubsub/topics/print/types";
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import { extensionPayment } from "./actions/extension-payment/action";
|
|
|
40
40
|
import { redeemPayment } from "./actions/redeem-payment/action";
|
|
41
41
|
// Customer Actions
|
|
42
42
|
import { addCustomerNote } from "./actions/add-customer-note/action";
|
|
43
|
+
import { removeCustomerNote } from "./actions/remove-customer-note/action";
|
|
43
44
|
import { removeCustomerFromCart } from "./actions/remove-customer-from-cart/action";
|
|
44
45
|
import { removeCartDiscount } from "./actions/remove-cart-discount/action";
|
|
45
46
|
// System Actions
|
|
@@ -63,8 +64,15 @@ import { getActiveSession } from "./actions/get-active-session/action";
|
|
|
63
64
|
import { setActiveSession } from "./actions/set-active-session/action";
|
|
64
65
|
import { getActiveUser } from "./actions/get-active-user/action";
|
|
65
66
|
import { setActiveUser } from "./actions/set-active-user/action";
|
|
66
|
-
import { getActiveRefund } from "./actions/get-active-refund/action";
|
|
67
67
|
import { setActiveRefund } from "./actions/set-active-refund/action";
|
|
68
|
+
// Remove Actions
|
|
69
|
+
import { removeProductDiscount } from "./actions/remove-product-discount/action";
|
|
70
|
+
import { removeProductFee } from "./actions/remove-product-fee/action";
|
|
71
|
+
import { removeProductNote } from "./actions/remove-product-note/action";
|
|
72
|
+
import { removeCartFee } from "./actions/remove-cart-fee/action";
|
|
73
|
+
import { removeOrderNote } from "./actions/remove-order-note/action";
|
|
74
|
+
import { removeCustomSale } from "./actions/remove-custom-sale/action";
|
|
75
|
+
import { removeNonRevenueItem } from "./actions/remove-non-revenue-item/action";
|
|
68
76
|
// Integration Actions
|
|
69
77
|
import { triggerWebhook } from "./actions/trigger-webhook/action";
|
|
70
78
|
import { triggerZapierWebhook } from "./actions/trigger-zapier-webhook/action";
|
|
@@ -154,6 +162,7 @@ export const command = {
|
|
|
154
162
|
redeemPayment,
|
|
155
163
|
// Customer Actions
|
|
156
164
|
addCustomerNote,
|
|
165
|
+
removeCustomerNote,
|
|
157
166
|
removeCustomerFromCart,
|
|
158
167
|
removeCartDiscount,
|
|
159
168
|
// System Actions
|
|
@@ -177,8 +186,15 @@ export const command = {
|
|
|
177
186
|
setActiveSession,
|
|
178
187
|
getActiveUser,
|
|
179
188
|
setActiveUser,
|
|
180
|
-
getActiveRefund,
|
|
181
189
|
setActiveRefund,
|
|
190
|
+
// Remove Actions
|
|
191
|
+
removeProductDiscount,
|
|
192
|
+
removeProductFee,
|
|
193
|
+
removeProductNote,
|
|
194
|
+
removeCartFee,
|
|
195
|
+
removeOrderNote,
|
|
196
|
+
removeCustomSale,
|
|
197
|
+
removeNonRevenueItem,
|
|
182
198
|
// Integration Actions
|
|
183
199
|
triggerWebhook,
|
|
184
200
|
triggerZapierWebhook,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { mockAddCartDiscount } from "../../actions/add-cart-discount/mock";
|
|
2
2
|
import { mockAddCartFee } from "../../actions/add-cart-fee/mock";
|
|
3
|
+
import { mockRemoveCartFee } from "../../actions/remove-cart-fee/mock";
|
|
3
4
|
import { mockAddCustomSale } from "../../actions/add-custom-sale/mock";
|
|
4
5
|
import { mockAddCustomer } from "../../actions/add-customer/mock";
|
|
5
6
|
import { mockAddCustomerNote } from "../../actions/add-customer-note/mock";
|
|
7
|
+
import { mockRemoveCustomerNote } from "../../actions/remove-customer-note/mock";
|
|
6
8
|
import { mockEditCustomer } from "../../actions/edit-customer/mock";
|
|
7
9
|
import { mockAddOrderNote } from "../../actions/add-order-note/mock";
|
|
8
10
|
import { mockAddProductDiscount } from "../../actions/add-product-discount/mock";
|
|
@@ -81,7 +83,6 @@ import { mockGetActiveSession } from "../../actions/get-active-session/mock";
|
|
|
81
83
|
import { mockSetActiveSession } from "../../actions/set-active-session/mock";
|
|
82
84
|
import { mockGetActiveUser } from "../../actions/get-active-user/mock";
|
|
83
85
|
import { mockSetActiveUser } from "../../actions/set-active-user/mock";
|
|
84
|
-
import { mockGetActiveRefund } from "../../actions/get-active-refund/mock";
|
|
85
86
|
import { mockSetActiveRefund } from "../../actions/set-active-refund/mock";
|
|
86
87
|
export const RENDER_MOCKS = {
|
|
87
88
|
addCartDiscount: mockAddCartDiscount,
|
|
@@ -90,6 +91,7 @@ export const RENDER_MOCKS = {
|
|
|
90
91
|
addCustomer: mockAddCustomer,
|
|
91
92
|
editCustomer: mockEditCustomer,
|
|
92
93
|
addCustomerNote: mockAddCustomerNote,
|
|
94
|
+
removeCustomerNote: mockRemoveCustomerNote,
|
|
93
95
|
addOrderNote: mockAddOrderNote,
|
|
94
96
|
addProductDiscount: mockAddProductDiscount,
|
|
95
97
|
addProductFee: mockAddProductFee,
|
|
@@ -167,6 +169,12 @@ export const RENDER_MOCKS = {
|
|
|
167
169
|
setActiveSession: mockSetActiveSession,
|
|
168
170
|
getActiveUser: mockGetActiveUser,
|
|
169
171
|
setActiveUser: mockSetActiveUser,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
setActiveRefund: mockSetActiveRefund,
|
|
173
|
+
removeProductDiscount: () => Promise.resolve({ success: true, timestamp: new Date().toISOString() }),
|
|
174
|
+
removeProductFee: () => Promise.resolve({ success: true, timestamp: new Date().toISOString() }),
|
|
175
|
+
removeProductNote: () => Promise.resolve({ success: true, timestamp: new Date().toISOString() }),
|
|
176
|
+
removeCartFee: mockRemoveCartFee,
|
|
177
|
+
removeOrderNote: () => Promise.resolve({ success: true, timestamp: new Date().toISOString() }),
|
|
178
|
+
removeCustomSale: params => Promise.resolve({ success: true, id: params.id, timestamp: new Date().toISOString() }),
|
|
179
|
+
removeNonRevenueItem: params => Promise.resolve({ success: true, externalId: params.externalId, timestamp: new Date().toISOString() })
|
|
172
180
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, SetActiveOutlet, GetActiveStation, SetActiveStation, GetActiveSession, SetActiveSession, GetActiveUser, SetActiveUser,
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, SetActiveOutlet, GetActiveStation, SetActiveStation, GetActiveSession, SetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem } from "../../index";
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -39,6 +39,7 @@ export interface RenderProviderActions {
|
|
|
39
39
|
redeemPayment: RedeemPayment;
|
|
40
40
|
addNonRevenueItem: AddNonRevenueItem;
|
|
41
41
|
addCustomerNote: AddCustomerNote;
|
|
42
|
+
removeCustomerNote: RemoveCustomerNote;
|
|
42
43
|
removeCustomerFromCart: RemoveCustomerFromCart;
|
|
43
44
|
removeCartDiscount: RemoveCartDiscount;
|
|
44
45
|
goToStationHome: GoToStationHome;
|
|
@@ -83,6 +84,12 @@ export interface RenderProviderActions {
|
|
|
83
84
|
setActiveSession: SetActiveSession;
|
|
84
85
|
getActiveUser: GetActiveUser;
|
|
85
86
|
setActiveUser: SetActiveUser;
|
|
86
|
-
getActiveRefund: GetActiveRefund;
|
|
87
87
|
setActiveRefund: SetActiveRefund;
|
|
88
|
+
removeProductDiscount: RemoveProductDiscount;
|
|
89
|
+
removeProductFee: RemoveProductFee;
|
|
90
|
+
removeProductNote: RemoveProductNote;
|
|
91
|
+
removeCartFee: RemoveCartFee;
|
|
92
|
+
removeOrderNote: RemoveOrderNote;
|
|
93
|
+
removeCustomSale: RemoveCustomSale;
|
|
94
|
+
removeNonRevenueItem: RemoveNonRevenueItem;
|
|
88
95
|
}
|
|
@@ -56,6 +56,36 @@ export const cartTopic = {
|
|
|
56
56
|
id: "cart-fee-removed",
|
|
57
57
|
name: "Cart Fee Removed",
|
|
58
58
|
description: "Published when a fee is removed from the cart"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "product-discount-added",
|
|
62
|
+
name: "Product Discount Added",
|
|
63
|
+
description: "Published when a discount is added to a product in the cart"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "product-discount-removed",
|
|
67
|
+
name: "Product Discount Removed",
|
|
68
|
+
description: "Published when a discount is removed from a product in the cart"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "product-fee-added",
|
|
72
|
+
name: "Product Fee Added",
|
|
73
|
+
description: "Published when a fee is added to a product in the cart"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "product-fee-removed",
|
|
77
|
+
name: "Product Fee Removed",
|
|
78
|
+
description: "Published when a fee is removed from a product in the cart"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "product-note-added",
|
|
82
|
+
name: "Product Note Added",
|
|
83
|
+
description: "Published when a note is added to a product in the cart"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "product-note-removed",
|
|
87
|
+
name: "Product Note Removed",
|
|
88
|
+
description: "Published when a note is removed from a product in the cart"
|
|
59
89
|
}
|
|
60
90
|
]
|
|
61
91
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-discount-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductDiscountAddedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
discount: {
|
|
10
|
+
amount: number;
|
|
11
|
+
isPercent: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Typed event for product-discount-added
|
|
17
|
+
*/
|
|
18
|
+
export type ProductDiscountAddedEvent = TopicEvent<ProductDiscountAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-discount-removed event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductDiscountRemovedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for product-discount-removed
|
|
12
|
+
*/
|
|
13
|
+
export type ProductDiscountRemovedEvent = TopicEvent<ProductDiscountRemovedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-fee-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductFeeAddedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
fee: {
|
|
10
|
+
amount: number;
|
|
11
|
+
isPercent: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
applyTaxes: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Typed event for product-fee-added
|
|
18
|
+
*/
|
|
19
|
+
export type ProductFeeAddedEvent = TopicEvent<ProductFeeAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-fee-removed event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductFeeRemovedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for product-fee-removed
|
|
12
|
+
*/
|
|
13
|
+
export type ProductFeeRemovedEvent = TopicEvent<ProductFeeRemovedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-note-added event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductNoteAddedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
note: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Typed event for product-note-added
|
|
13
|
+
*/
|
|
14
|
+
export type ProductNoteAddedEvent = TopicEvent<ProductNoteAddedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CFActiveProduct } from "../../../../CommonTypes";
|
|
2
|
+
import type { TopicEvent } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Payload for product-note-removed event
|
|
5
|
+
*/
|
|
6
|
+
export interface ProductNoteRemovedPayload {
|
|
7
|
+
product: CFActiveProduct;
|
|
8
|
+
internalId?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed event for product-note-removed
|
|
12
|
+
*/
|
|
13
|
+
export type ProductNoteRemovedEvent = TopicEvent<ProductNoteRemovedPayload>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,6 +11,12 @@ export * from "./cart-discount-added/types";
|
|
|
11
11
|
export * from "./cart-discount-removed/types";
|
|
12
12
|
export * from "./cart-fee-added/types";
|
|
13
13
|
export * from "./cart-fee-removed/types";
|
|
14
|
+
export * from "./product-discount-added/types";
|
|
15
|
+
export * from "./product-discount-removed/types";
|
|
16
|
+
export * from "./product-fee-added/types";
|
|
17
|
+
export * from "./product-fee-removed/types";
|
|
18
|
+
export * from "./product-note-added/types";
|
|
19
|
+
export * from "./product-note-removed/types";
|
|
14
20
|
import type { CartCreatedPayload } from "./cart-created/types";
|
|
15
21
|
import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
|
|
16
22
|
import type { ProductAddedPayload } from "./product-added/types";
|
|
@@ -20,5 +26,11 @@ import type { CartDiscountAddedPayload } from "./cart-discount-added/types";
|
|
|
20
26
|
import type { CartDiscountRemovedPayload } from "./cart-discount-removed/types";
|
|
21
27
|
import type { CartFeeAddedPayload } from "./cart-fee-added/types";
|
|
22
28
|
import type { CartFeeRemovedPayload } from "./cart-fee-removed/types";
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
import type { ProductDiscountAddedPayload } from "./product-discount-added/types";
|
|
30
|
+
import type { ProductDiscountRemovedPayload } from "./product-discount-removed/types";
|
|
31
|
+
import type { ProductFeeAddedPayload } from "./product-fee-added/types";
|
|
32
|
+
import type { ProductFeeRemovedPayload } from "./product-fee-removed/types";
|
|
33
|
+
import type { ProductNoteAddedPayload } from "./product-note-added/types";
|
|
34
|
+
import type { ProductNoteRemovedPayload } from "./product-note-removed/types";
|
|
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";
|
|
@@ -12,3 +12,9 @@ export * from "./cart-discount-added/types";
|
|
|
12
12
|
export * from "./cart-discount-removed/types";
|
|
13
13
|
export * from "./cart-fee-added/types";
|
|
14
14
|
export * from "./cart-fee-removed/types";
|
|
15
|
+
export * from "./product-discount-added/types";
|
|
16
|
+
export * from "./product-discount-removed/types";
|
|
17
|
+
export * from "./product-fee-added/types";
|
|
18
|
+
export * from "./product-fee-removed/types";
|
|
19
|
+
export * from "./product-note-added/types";
|
|
20
|
+
export * from "./product-note-removed/types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@final-commerce/command-frame",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62",
|
|
4
4
|
"description": "Commands Frame library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"test": "vitest",
|
|
18
18
|
"test:run": "vitest run",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"prepare": "npm run build",
|
|
20
|
+
"prepare": "husky && npm run build",
|
|
21
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
|
|
21
22
|
"format": "prettier --write .",
|
|
22
23
|
"format:check": "prettier --check .",
|
|
23
24
|
"publish:npm": "npm publish --registry=https://registry.npmjs.org",
|
|
@@ -41,9 +42,27 @@
|
|
|
41
42
|
"type": "git",
|
|
42
43
|
"url": "git+https://github.com/Final-Commerce/command-frame.git"
|
|
43
44
|
},
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"**/*.{ts,tsx,js,json,md}": [
|
|
47
|
+
"prettier --write"
|
|
48
|
+
],
|
|
49
|
+
"**/*.{ts,tsx}": [
|
|
50
|
+
"eslint --fix"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"jira-prepare-commit-msg": {
|
|
54
|
+
"messagePattern": "$M [$J]",
|
|
55
|
+
"jiraTicketPattern": "([A-Z]+-\\d+)",
|
|
56
|
+
"ignoredBranchesPattern": "^(main|master|develop|release-staging.*|pre-prod)$",
|
|
57
|
+
"ignoreBranchesMissingTickets": true
|
|
58
|
+
},
|
|
44
59
|
"devDependencies": {
|
|
45
60
|
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
|
46
61
|
"@typescript-eslint/parser": "^8.48.0",
|
|
62
|
+
"eslint": "^8.57.0",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"jira-prepare-commit-msg": "^1.7.2",
|
|
65
|
+
"lint-staged": "^16.2.7",
|
|
47
66
|
"prettier": "^3.7.1",
|
|
48
67
|
"typescript": "^5.0.0",
|
|
49
68
|
"vitest": "^3.0.5"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MOCK_ACTIVE_REFUND_DETAILS } from "../../demo/database";
|
|
2
|
-
export const mockGetActiveRefund = async () => {
|
|
3
|
-
console.log("[Mock] getActiveRefund called");
|
|
4
|
-
return {
|
|
5
|
-
success: true,
|
|
6
|
-
refund: MOCK_ACTIVE_REFUND_DETAILS,
|
|
7
|
-
timestamp: new Date().toISOString()
|
|
8
|
-
};
|
|
9
|
-
};
|
|
File without changes
|