@final-commerce/command-frame 0.0.1 → 0.0.4
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 +62 -7
- package/dist/CommonTypes.d.ts +469 -0
- package/dist/CommonTypes.js +21 -0
- package/dist/actions/add-cart-discount/mock.d.ts +2 -0
- package/dist/actions/add-cart-discount/mock.js +27 -0
- package/dist/actions/add-cart-fee/mock.d.ts +2 -0
- package/dist/actions/add-cart-fee/mock.js +31 -0
- package/dist/actions/add-custom-sale/mock.d.ts +2 -0
- package/dist/actions/add-custom-sale/mock.js +12 -0
- package/dist/actions/add-customer/mock.d.ts +2 -0
- package/dist/actions/add-customer/mock.js +23 -0
- package/dist/actions/add-customer/types.d.ts +3 -2
- package/dist/actions/add-customer-note/mock.d.ts +2 -0
- package/dist/actions/add-customer-note/mock.js +9 -0
- package/dist/actions/add-order-note/mock.d.ts +2 -0
- package/dist/actions/add-order-note/mock.js +8 -0
- package/dist/actions/add-product-discount/mock.d.ts +2 -0
- package/dist/actions/add-product-discount/mock.js +10 -0
- package/dist/actions/add-product-fee/mock.d.ts +2 -0
- package/dist/actions/add-product-fee/mock.js +11 -0
- package/dist/actions/add-product-note/mock.d.ts +2 -0
- package/dist/actions/add-product-note/mock.js +8 -0
- package/dist/actions/add-product-to-cart/mock.d.ts +2 -0
- package/dist/actions/add-product-to-cart/mock.js +56 -0
- package/dist/actions/add-product-to-cart/types.d.ts +2 -0
- package/dist/actions/adjust-inventory/mock.d.ts +2 -0
- package/dist/actions/adjust-inventory/mock.js +18 -0
- package/dist/actions/assign-customer/mock.d.ts +2 -0
- package/dist/actions/assign-customer/mock.js +14 -0
- package/dist/actions/assign-customer/types.d.ts +2 -1
- package/dist/actions/authenticate-user/mock.d.ts +2 -0
- package/dist/actions/authenticate-user/mock.js +8 -0
- package/dist/actions/calculate-refund-total/mock.d.ts +2 -0
- package/dist/actions/calculate-refund-total/mock.js +14 -0
- package/dist/actions/calculate-refund-total/types.d.ts +3 -2
- package/dist/actions/cash-payment/mock.d.ts +2 -0
- package/dist/actions/cash-payment/mock.js +14 -0
- package/dist/actions/cash-payment/types.d.ts +2 -1
- package/dist/actions/clear-cart/mock.d.ts +2 -0
- package/dist/actions/clear-cart/mock.js +9 -0
- package/dist/actions/delete-parked-order/mock.d.ts +2 -0
- package/dist/actions/delete-parked-order/mock.js +8 -0
- package/dist/actions/example-function/mock.d.ts +2 -0
- package/dist/actions/example-function/mock.js +13 -0
- package/dist/actions/get-categories/mock.d.ts +2 -0
- package/dist/actions/get-categories/mock.js +20 -0
- package/dist/actions/get-categories/types.d.ts +2 -1
- package/dist/actions/get-context/mock.d.ts +2 -0
- package/dist/actions/get-context/mock.js +24 -0
- package/dist/actions/get-context/types.d.ts +2 -16
- package/dist/actions/get-current-cart/mock.d.ts +2 -0
- package/dist/actions/get-current-cart/mock.js +9 -0
- package/dist/actions/get-current-cart/types.d.ts +2 -1
- package/dist/actions/get-customers/mock.d.ts +2 -0
- package/dist/actions/get-customers/mock.js +17 -0
- package/dist/actions/get-customers/types.d.ts +2 -1
- package/dist/actions/get-final-context/action.d.ts +6 -0
- package/dist/actions/get-final-context/action.js +8 -0
- package/dist/actions/get-final-context/types.d.ts +4 -0
- package/dist/actions/get-final-context/types.js +1 -0
- package/dist/actions/get-line-items-by-order/mock.d.ts +2 -0
- package/dist/actions/get-line-items-by-order/mock.js +12 -0
- package/dist/actions/get-line-items-by-order/types.d.ts +3 -2
- package/dist/actions/get-orders/mock.d.ts +2 -0
- package/dist/actions/get-orders/mock.js +104 -0
- package/dist/actions/get-orders/types.d.ts +2 -1
- package/dist/actions/get-product-variants/mock.d.ts +2 -0
- package/dist/actions/get-product-variants/mock.js +14 -0
- package/dist/actions/get-product-variants/types.d.ts +2 -1
- package/dist/actions/get-products/mock.d.ts +2 -0
- package/dist/actions/get-products/mock.js +31 -0
- package/dist/actions/get-products/types.d.ts +2 -1
- package/dist/actions/get-refunds/mock.d.ts +2 -0
- package/dist/actions/get-refunds/mock.js +9 -0
- package/dist/actions/get-refunds/types.d.ts +2 -1
- package/dist/actions/get-remaining-refundable-quantities/mock.d.ts +2 -0
- package/dist/actions/get-remaining-refundable-quantities/mock.js +9 -0
- package/dist/actions/go-to-page/mock.d.ts +2 -0
- package/dist/actions/go-to-page/mock.js +8 -0
- package/dist/actions/go-to-station-home/mock.d.ts +2 -0
- package/dist/actions/go-to-station-home/mock.js +7 -0
- package/dist/actions/initiate-refund/mock.d.ts +2 -0
- package/dist/actions/initiate-refund/mock.js +8 -0
- package/dist/actions/open-cash-drawer/mock.d.ts +2 -0
- package/dist/actions/open-cash-drawer/mock.js +7 -0
- package/dist/actions/open-popup/mock.d.ts +2 -0
- package/dist/actions/open-popup/mock.js +8 -0
- package/dist/actions/park-order/mock.d.ts +2 -0
- package/dist/actions/park-order/mock.js +9 -0
- package/dist/actions/park-order/types.d.ts +2 -1
- package/dist/actions/partial-payment/mock.d.ts +2 -0
- package/dist/actions/partial-payment/mock.js +12 -0
- package/dist/actions/partial-payment/types.d.ts +2 -1
- package/dist/actions/process-partial-refund/mock.d.ts +2 -0
- package/dist/actions/process-partial-refund/mock.js +8 -0
- package/dist/actions/remove-customer-from-cart/mock.d.ts +2 -0
- package/dist/actions/remove-customer-from-cart/mock.js +9 -0
- package/dist/actions/reset-refund-details/mock.d.ts +2 -0
- package/dist/actions/reset-refund-details/mock.js +7 -0
- package/dist/actions/resume-parked-order/mock.d.ts +2 -0
- package/dist/actions/resume-parked-order/mock.js +9 -0
- package/dist/actions/resume-parked-order/types.d.ts +2 -1
- package/dist/actions/select-all-refund-items/mock.d.ts +2 -0
- package/dist/actions/select-all-refund-items/mock.js +8 -0
- package/dist/actions/set-product-active/mock.d.ts +2 -0
- package/dist/actions/set-product-active/mock.js +8 -0
- package/dist/actions/set-refund-stock-action/mock.d.ts +2 -0
- package/dist/actions/set-refund-stock-action/mock.js +9 -0
- package/dist/actions/show-confirmation/mock.d.ts +2 -0
- package/dist/actions/show-confirmation/mock.js +9 -0
- package/dist/actions/show-notification/mock.d.ts +2 -0
- package/dist/actions/show-notification/mock.js +8 -0
- package/dist/actions/switch-user/mock.d.ts +2 -0
- package/dist/actions/switch-user/mock.js +10 -0
- package/dist/actions/tap-to-pay-payment/mock.d.ts +2 -0
- package/dist/actions/tap-to-pay-payment/mock.js +11 -0
- package/dist/actions/tap-to-pay-payment/types.d.ts +2 -1
- package/dist/actions/terminal-payment/mock.d.ts +2 -0
- package/dist/actions/terminal-payment/mock.js +14 -0
- package/dist/actions/terminal-payment/types.d.ts +2 -1
- package/dist/actions/toggle-slide-out/mock.d.ts +2 -0
- package/dist/actions/toggle-slide-out/mock.js +8 -0
- package/dist/actions/trigger-webhook/mock.d.ts +2 -0
- package/dist/actions/trigger-webhook/mock.js +8 -0
- package/dist/actions/trigger-zapier-webhook/mock.d.ts +2 -0
- package/dist/actions/trigger-zapier-webhook/mock.js +8 -0
- package/dist/actions/update-customer-facing-display/mock.d.ts +2 -0
- package/dist/actions/update-customer-facing-display/mock.js +8 -0
- package/dist/actions/vendara-payment/mock.d.ts +2 -0
- package/dist/actions/vendara-payment/mock.js +11 -0
- package/dist/actions/vendara-payment/types.d.ts +2 -1
- package/dist/client.d.ts +4 -1
- package/dist/client.js +63 -2
- package/dist/demo/database.d.ts +45 -0
- package/dist/demo/database.js +515 -0
- package/dist/demo/registry.d.ts +5 -0
- package/dist/demo/registry.js +106 -0
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const mockAddCustomSale = async (params) => {
|
|
2
|
+
console.log("[Mock] addCustomSale called", params);
|
|
3
|
+
if (!params)
|
|
4
|
+
throw new Error("Params required");
|
|
5
|
+
return {
|
|
6
|
+
success: true,
|
|
7
|
+
label: params.label,
|
|
8
|
+
price: Number(params.price),
|
|
9
|
+
applyTaxes: params.applyTaxes ?? false,
|
|
10
|
+
timestamp: new Date().toISOString()
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MOCK_CUSTOMERS } from "../../demo/database";
|
|
2
|
+
export const mockAddCustomer = async (params) => {
|
|
3
|
+
console.log("[Mock] addCustomer called", params);
|
|
4
|
+
if (!params?.customer)
|
|
5
|
+
throw new Error("Customer data required");
|
|
6
|
+
const newCustomer = {
|
|
7
|
+
_id: "new_mock_cust_" + Date.now(),
|
|
8
|
+
companyId: "mock_company_id",
|
|
9
|
+
email: params.customer.email || "",
|
|
10
|
+
firstName: params.customer.firstName || "",
|
|
11
|
+
lastName: params.customer.lastName || "",
|
|
12
|
+
phone: params.customer.phone,
|
|
13
|
+
billing: null,
|
|
14
|
+
shipping: null,
|
|
15
|
+
...params.customer
|
|
16
|
+
};
|
|
17
|
+
MOCK_CUSTOMERS.push(newCustomer);
|
|
18
|
+
return {
|
|
19
|
+
success: true,
|
|
20
|
+
customer: newCustomer,
|
|
21
|
+
timestamp: new Date().toISOString()
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CFCustomer } from "../../CommonTypes";
|
|
1
2
|
export interface AddCustomerParams {
|
|
2
|
-
customer:
|
|
3
|
+
customer: Partial<CFCustomer>;
|
|
3
4
|
}
|
|
4
5
|
export interface AddCustomerResponse {
|
|
5
6
|
success: boolean;
|
|
6
|
-
customer:
|
|
7
|
+
customer: CFCustomer;
|
|
7
8
|
timestamp: string;
|
|
8
9
|
}
|
|
9
10
|
export type AddCustomer = (params: AddCustomerParams) => Promise<AddCustomerResponse>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const mockAddProductDiscount = async (params) => {
|
|
2
|
+
console.log("[Mock] addProductDiscount called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
amount: params?.amount || 0,
|
|
6
|
+
isPercent: params?.isPercent || false,
|
|
7
|
+
label: params?.label || "",
|
|
8
|
+
timestamp: new Date().toISOString()
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const mockAddProductFee = async (params) => {
|
|
2
|
+
console.log("[Mock] addProductFee called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
amount: params?.amount || 0,
|
|
6
|
+
isPercent: params?.isPercent || false,
|
|
7
|
+
label: params?.label || "",
|
|
8
|
+
applyTaxes: params?.applyTaxes || false,
|
|
9
|
+
timestamp: new Date().toISOString()
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MOCK_CART, MOCK_PRODUCTS } from "../../demo/database";
|
|
2
|
+
export const mockAddProductToCart = async (params) => {
|
|
3
|
+
console.log("[Mock] addProductToCart called", params);
|
|
4
|
+
const productId = params?.productId;
|
|
5
|
+
const variantId = params?.variantId;
|
|
6
|
+
const quantity = params?.quantity || 1;
|
|
7
|
+
let product = MOCK_PRODUCTS[0]; // Default fallback
|
|
8
|
+
if (productId) {
|
|
9
|
+
const found = MOCK_PRODUCTS.find(p => p._id === productId);
|
|
10
|
+
if (found) {
|
|
11
|
+
product = found;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.warn(`[Mock] Product with ID ${productId} not found, using default.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Determine variant
|
|
18
|
+
let variant = product.variants[0];
|
|
19
|
+
if (variantId) {
|
|
20
|
+
const foundVariant = product.variants.find(v => v._id === variantId);
|
|
21
|
+
if (foundVariant) {
|
|
22
|
+
variant = foundVariant;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Add to MOCK_CART
|
|
26
|
+
const activeProduct = {
|
|
27
|
+
...product,
|
|
28
|
+
id: product._id,
|
|
29
|
+
internalId: product._id + "_" + Date.now(), // unique ID for cart item
|
|
30
|
+
variantId: variant._id,
|
|
31
|
+
quantity: quantity,
|
|
32
|
+
price: Number(variant.price),
|
|
33
|
+
taxTableId: product.taxTable,
|
|
34
|
+
stock: variant.inventory?.[0]?.stock || 0,
|
|
35
|
+
images: product.images || [],
|
|
36
|
+
localQuantity: quantity,
|
|
37
|
+
sku: variant.sku,
|
|
38
|
+
attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", ")
|
|
39
|
+
};
|
|
40
|
+
MOCK_CART.products.push(activeProduct);
|
|
41
|
+
// Recalculate totals
|
|
42
|
+
const lineTotal = activeProduct.price * quantity;
|
|
43
|
+
MOCK_CART.subtotal += lineTotal;
|
|
44
|
+
// Simple total calculation (ignoring taxes/fees for mock simplicity unless needed)
|
|
45
|
+
MOCK_CART.total += lineTotal;
|
|
46
|
+
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
47
|
+
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
productId: activeProduct.id,
|
|
51
|
+
variantId: activeProduct.variantId,
|
|
52
|
+
name: activeProduct.name,
|
|
53
|
+
quantity: quantity,
|
|
54
|
+
timestamp: new Date().toISOString()
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const mockAdjustInventory = async (params) => {
|
|
2
|
+
console.log("[Mock] adjustInventory called", params);
|
|
3
|
+
// Simulate updating inventory
|
|
4
|
+
let newStock = 100;
|
|
5
|
+
if (params?.stockType === 'add')
|
|
6
|
+
newStock += Number(params.amount);
|
|
7
|
+
if (params?.stockType === 'subtract')
|
|
8
|
+
newStock -= Number(params.amount);
|
|
9
|
+
if (params?.stockType === 'set')
|
|
10
|
+
newStock = Number(params.amount);
|
|
11
|
+
return {
|
|
12
|
+
success: true,
|
|
13
|
+
amount: params?.amount || "0",
|
|
14
|
+
stockType: params?.stockType || "set",
|
|
15
|
+
newStock,
|
|
16
|
+
timestamp: new Date().toISOString()
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MOCK_CUSTOMERS, MOCK_CART } from "../../demo/database";
|
|
2
|
+
export const mockAssignCustomer = async (params) => {
|
|
3
|
+
console.log("[Mock] assignCustomer called", params);
|
|
4
|
+
const customer = MOCK_CUSTOMERS.find(c => c._id === params.customerId);
|
|
5
|
+
if (!customer) {
|
|
6
|
+
throw new Error("Customer not found in mock DB");
|
|
7
|
+
}
|
|
8
|
+
MOCK_CART.customer = customer;
|
|
9
|
+
return {
|
|
10
|
+
success: true,
|
|
11
|
+
customer,
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CFCustomer } from "../../CommonTypes";
|
|
1
2
|
export interface AssignCustomerParams {
|
|
2
3
|
customerId: string;
|
|
3
4
|
}
|
|
4
5
|
export interface AssignCustomerResponse {
|
|
5
6
|
success: boolean;
|
|
6
|
-
customer:
|
|
7
|
+
customer: CFCustomer;
|
|
7
8
|
timestamp: string;
|
|
8
9
|
}
|
|
9
10
|
export type AssignCustomer = (params: AssignCustomerParams) => Promise<AssignCustomerResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const mockCalculateRefundTotal = async () => {
|
|
2
|
+
console.log("[Mock] calculateRefundTotal called");
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
summary: {
|
|
6
|
+
subtotal: "0.00",
|
|
7
|
+
tax: "0.00",
|
|
8
|
+
total: "0.00"
|
|
9
|
+
},
|
|
10
|
+
refundedLineItems: [],
|
|
11
|
+
refundedCustomSales: [],
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFRefundedLineItem, CFRefundedCustomSale } from "../../CommonTypes";
|
|
1
2
|
export interface CalculateRefundTotalResponse {
|
|
2
3
|
success: boolean;
|
|
3
4
|
summary: {
|
|
@@ -5,8 +6,8 @@ export interface CalculateRefundTotalResponse {
|
|
|
5
6
|
tax: string;
|
|
6
7
|
total: string;
|
|
7
8
|
};
|
|
8
|
-
refundedLineItems:
|
|
9
|
-
refundedCustomSales:
|
|
9
|
+
refundedLineItems: CFRefundedLineItem[];
|
|
10
|
+
refundedCustomSales: CFRefundedCustomSale[];
|
|
10
11
|
timestamp: string;
|
|
11
12
|
}
|
|
12
13
|
export type CalculateRefundTotal = () => Promise<CalculateRefundTotalResponse>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createOrderFromCart } from "../../demo/database";
|
|
2
|
+
export const mockCashPayment = async (params) => {
|
|
3
|
+
console.log("[Mock] cashPayment called", params);
|
|
4
|
+
const amount = params?.amount || 0;
|
|
5
|
+
const order = createOrderFromCart("cash", amount, "cash");
|
|
6
|
+
return {
|
|
7
|
+
success: true,
|
|
8
|
+
amount,
|
|
9
|
+
openChangeCalculator: params?.openChangeCalculator || false,
|
|
10
|
+
paymentType: "cash",
|
|
11
|
+
order,
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
1
2
|
export interface CashPaymentParams {
|
|
2
3
|
amount?: number;
|
|
3
4
|
openChangeCalculator?: boolean;
|
|
@@ -7,7 +8,7 @@ export interface CashPaymentResponse {
|
|
|
7
8
|
amount: number;
|
|
8
9
|
openChangeCalculator: boolean;
|
|
9
10
|
paymentType: string;
|
|
10
|
-
order:
|
|
11
|
+
order: CFOrder | null;
|
|
11
12
|
timestamp: string;
|
|
12
13
|
}
|
|
13
14
|
export type CashPayment = (params?: CashPaymentParams) => Promise<CashPaymentResponse>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const mockExampleFunction = async (params) => {
|
|
2
|
+
console.log("[Mock] exampleFunction called", params);
|
|
3
|
+
return {
|
|
4
|
+
receivedParams: params || {},
|
|
5
|
+
responsePayload: {
|
|
6
|
+
field1: "mock1",
|
|
7
|
+
field2: "mock2",
|
|
8
|
+
field3: "mock3"
|
|
9
|
+
},
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
processed: true
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MOCK_CATEGORIES, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetCategories = async (params) => {
|
|
3
|
+
console.log("[Mock] getCategories called", params);
|
|
4
|
+
// Simple filter simulation
|
|
5
|
+
let categories = MOCK_CATEGORIES;
|
|
6
|
+
const query = params?.query || {};
|
|
7
|
+
if (query.name) {
|
|
8
|
+
const nameFilter = typeof query.name === 'string' ? query.name : '';
|
|
9
|
+
if (nameFilter) {
|
|
10
|
+
categories = categories.filter(c => c.name.toLowerCase().includes(nameFilter.toLowerCase()));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (query.parentId !== undefined) {
|
|
14
|
+
categories = categories.filter(c => c.parentId === query.parentId);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
categories: safeSerialize(categories),
|
|
18
|
+
timestamp: new Date().toISOString()
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFCategory } from "../../CommonTypes";
|
|
1
2
|
export interface GetCategoriesParams {
|
|
2
3
|
query?: {
|
|
3
4
|
name?: string | {
|
|
@@ -10,7 +11,7 @@ export interface GetCategoriesParams {
|
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
export interface GetCategoriesResponse {
|
|
13
|
-
categories:
|
|
14
|
+
categories: CFCategory[];
|
|
14
15
|
timestamp: string;
|
|
15
16
|
}
|
|
16
17
|
export type GetCategories = (params?: GetCategoriesParams) => Promise<GetCategoriesResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MOCK_COMPANY, MOCK_OUTLET, MOCK_STATION, MOCK_USER } from "../../demo/database";
|
|
2
|
+
export const mockGetContext = async () => {
|
|
3
|
+
console.log("[Mock] getContext called");
|
|
4
|
+
return {
|
|
5
|
+
userId: MOCK_USER.id,
|
|
6
|
+
companyId: MOCK_COMPANY.id || null,
|
|
7
|
+
companyName: MOCK_COMPANY.name || null,
|
|
8
|
+
deviceId: "mock_device_id",
|
|
9
|
+
stationId: MOCK_STATION._id,
|
|
10
|
+
stationName: MOCK_STATION.name,
|
|
11
|
+
outletId: MOCK_OUTLET.id,
|
|
12
|
+
outletName: MOCK_OUTLET.name || null,
|
|
13
|
+
buildId: "mock_build_id",
|
|
14
|
+
buildName: "Mock Build",
|
|
15
|
+
buildVersion: "1.0.0-mock",
|
|
16
|
+
buildSourceId: "mock_source_id",
|
|
17
|
+
buildIsPremium: true,
|
|
18
|
+
user: null,
|
|
19
|
+
company: null,
|
|
20
|
+
station: null,
|
|
21
|
+
outlet: null,
|
|
22
|
+
timestamp: new Date().toISOString()
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
companyId: string | null;
|
|
4
|
-
companyName: string | null;
|
|
5
|
-
deviceId: string | null;
|
|
6
|
-
stationId: string | null;
|
|
7
|
-
stationName: string | null;
|
|
8
|
-
outletId: string | null;
|
|
9
|
-
outletName: string | null;
|
|
10
|
-
buildId: string | null;
|
|
11
|
-
buildName: string | null;
|
|
12
|
-
buildVersion: string | null;
|
|
13
|
-
buildSourceId: string | null;
|
|
14
|
-
buildIsPremium: boolean;
|
|
15
|
-
timestamp: string;
|
|
16
|
-
}
|
|
1
|
+
import { CFContext } from "../../CommonTypes";
|
|
2
|
+
export type GetContextResponse = CFContext;
|
|
17
3
|
export type GetContext = () => Promise<GetContextResponse>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MOCK_CART, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetCurrentCart = async () => {
|
|
3
|
+
console.log("[Mock] getCurrentCart called");
|
|
4
|
+
return {
|
|
5
|
+
success: true,
|
|
6
|
+
cart: safeSerialize(MOCK_CART),
|
|
7
|
+
timestamp: new Date().toISOString()
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MOCK_CUSTOMERS, safeSerialize } from "../../demo/database";
|
|
2
|
+
export const mockGetCustomers = async (params) => {
|
|
3
|
+
console.log("[Mock] getCustomers called", params);
|
|
4
|
+
let customers = MOCK_CUSTOMERS;
|
|
5
|
+
const query = params?.query || {};
|
|
6
|
+
if (query.searchValue) {
|
|
7
|
+
const search = String(query.searchValue).toLowerCase();
|
|
8
|
+
customers = customers.filter(c => c.firstName.toLowerCase().includes(search) ||
|
|
9
|
+
c.lastName.toLowerCase().includes(search) ||
|
|
10
|
+
c.email.toLowerCase().includes(search));
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
customers: safeSerialize(customers),
|
|
14
|
+
total: customers.length,
|
|
15
|
+
timestamp: new Date().toISOString()
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CFCustomer } from "../../CommonTypes";
|
|
1
2
|
export interface GetCustomersParams {
|
|
2
3
|
query?: {
|
|
3
4
|
email?: string | {
|
|
@@ -24,7 +25,7 @@ export interface GetCustomersParams {
|
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
export interface GetCustomersResponse {
|
|
27
|
-
customers:
|
|
28
|
+
customers: CFCustomer[];
|
|
28
29
|
total?: number;
|
|
29
30
|
timestamp: string;
|
|
30
31
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get final context action
|
|
3
|
+
* Calls the getFinalContext action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const getFinalContext = async () => {
|
|
7
|
+
return await commandFrameClient.call("getFinalContext", undefined);
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const mockGetLineItemsByOrder = async (params) => {
|
|
2
|
+
console.log("[Mock] getLineItemsByOrder called", params);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
orderId: params?.orderId || "mock_order_id",
|
|
6
|
+
lineItems: [],
|
|
7
|
+
customSales: [],
|
|
8
|
+
remainingQuantities: {},
|
|
9
|
+
remainingCustomSalesQuantities: {},
|
|
10
|
+
timestamp: new Date().toISOString()
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { CFLineItem, CFCustomSale } from "../../CommonTypes";
|
|
1
2
|
export interface GetLineItemsByOrderParams {
|
|
2
3
|
orderId?: string;
|
|
3
4
|
}
|
|
4
5
|
export interface GetLineItemsByOrderResponse {
|
|
5
6
|
success: boolean;
|
|
6
7
|
orderId: string;
|
|
7
|
-
lineItems:
|
|
8
|
-
customSales:
|
|
8
|
+
lineItems: CFLineItem[];
|
|
9
|
+
customSales: CFCustomSale[];
|
|
9
10
|
remainingQuantities: Record<string, number>;
|
|
10
11
|
remainingCustomSalesQuantities: Record<string, number>;
|
|
11
12
|
timestamp: string;
|