@final-commerce/command-frame 0.1.61 → 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.
@@ -104,6 +104,7 @@ export interface CFInventory {
104
104
  _id?: string;
105
105
  }
106
106
  export interface CFCustomerNote {
107
+ _id?: string;
107
108
  createdAt: string;
108
109
  message: string;
109
110
  }
@@ -8,6 +8,7 @@ export const mockAddCustomerNote = async (params) => {
8
8
  customer.notes = [];
9
9
  }
10
10
  customer.notes.push({
11
+ _id: `mock_note_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`,
11
12
  message: params.note,
12
13
  createdAt: new Date().toISOString()
13
14
  });
@@ -0,0 +1,2 @@
1
+ import type { RemoveCartFee } from "./types";
2
+ export declare const mockRemoveCartFee: RemoveCartFee;
@@ -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,6 @@
1
+ /**
2
+ * Remove customer note action
3
+ * Calls the removeCustomerNote action on the parent window
4
+ */
5
+ import type { RemoveCustomerNote } from "./types";
6
+ export declare const removeCustomerNote: RemoveCustomerNote;
@@ -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,2 @@
1
+ import { RemoveCustomerNote } from "./types";
2
+ export declare const mockRemoveCustomerNote: RemoveCustomerNote;
@@ -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 {};
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;
@@ -160,6 +161,7 @@ export { EXTENSION_REFUND_REQUEST_ACTION } from "./actions/extension-refund/cons
160
161
  export { installExtensionRefundListener } from "./actions/extension-refund/extension-refund-listener";
161
162
  export type { ExtensionRefundParams, ExtensionRefundResponse } from "./actions/extension-refund/types";
162
163
  export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse } from "./actions/add-customer-note/types";
164
+ export type { RemoveCustomerNote, RemoveCustomerNoteParams, RemoveCustomerNoteResponse } from "./actions/remove-customer-note/types";
163
165
  export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from "./actions/remove-customer-from-cart/types";
164
166
  export type { RemoveCartDiscount, RemoveCartDiscountResponse } from "./actions/remove-cart-discount/types";
165
167
  export type { GoToStationHome, GoToStationHomeResponse } from "./actions/go-to-station-home/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
@@ -161,6 +162,7 @@ export const command = {
161
162
  redeemPayment,
162
163
  // Customer Actions
163
164
  addCustomerNote,
165
+ removeCustomerNote,
164
166
  removeCustomerFromCart,
165
167
  removeCartDiscount,
166
168
  // System Actions
@@ -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";
@@ -89,6 +91,7 @@ export const RENDER_MOCKS = {
89
91
  addCustomer: mockAddCustomer,
90
92
  editCustomer: mockEditCustomer,
91
93
  addCustomerNote: mockAddCustomerNote,
94
+ removeCustomerNote: mockRemoveCustomerNote,
92
95
  addOrderNote: mockAddOrderNote,
93
96
  addProductDiscount: mockAddProductDiscount,
94
97
  addProductFee: mockAddProductFee,
@@ -167,11 +170,11 @@ export const RENDER_MOCKS = {
167
170
  getActiveUser: mockGetActiveUser,
168
171
  setActiveUser: mockSetActiveUser,
169
172
  setActiveRefund: mockSetActiveRefund,
170
- removeProductDiscount: async () => ({ success: true, timestamp: new Date().toISOString() }),
171
- removeProductFee: async () => ({ success: true, timestamp: new Date().toISOString() }),
172
- removeProductNote: async () => ({ success: true, timestamp: new Date().toISOString() }),
173
- removeCartFee: async () => ({ success: true, timestamp: new Date().toISOString() }),
174
- removeOrderNote: async () => ({ success: true, timestamp: new Date().toISOString() }),
175
- removeCustomSale: async (params) => ({ success: true, id: params.id, timestamp: new Date().toISOString() }),
176
- removeNonRevenueItem: async (params) => ({ success: true, externalId: params.externalId, timestamp: new Date().toISOString() })
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() })
177
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, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem } from "../../index";
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.61",
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"