@final-commerce/command-frame 0.2.0-beta.1 → 0.3.0-beta.3
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 +28 -26
- package/dist/CommonTypes.d.ts +79 -534
- package/dist/CommonTypes.js +5 -65
- package/dist/actions/add-customer-note/mock.js +24 -15
- package/dist/actions/add-customer-note/types.d.ts +3 -2
- package/dist/actions/add-product/mock.js +12 -6
- package/dist/actions/add-product-discount/mock.js +5 -5
- package/dist/actions/add-product-fee/mock.js +6 -6
- package/dist/actions/cash-payment/types.d.ts +0 -5
- package/dist/actions/delete-parked-order/types.d.ts +0 -3
- package/dist/actions/edit-product/mock.js +5 -3
- package/dist/actions/extension-payment/types.d.ts +4 -5
- package/dist/actions/get-context/mock.js +12 -6
- package/dist/actions/get-products/mock.js +3 -3
- package/dist/actions/get-roles/mock.js +35 -41
- package/dist/actions/get-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/action.js +4 -0
- package/dist/actions/get-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/mock.js +7 -0
- package/dist/actions/get-smart-grid-layout/types.d.ts +12 -0
- package/dist/actions/get-users/mock.js +16 -25
- package/dist/actions/initiate-refund/types.d.ts +0 -3
- package/dist/actions/integration-payment/action.d.ts +5 -0
- package/dist/actions/integration-payment/action.js +7 -0
- package/dist/actions/integration-payment/mock.d.ts +2 -0
- package/dist/actions/integration-payment/mock.js +4 -0
- package/dist/actions/integration-payment/types.d.ts +16 -0
- package/dist/actions/open-extension-overlay/action.d.ts +2 -0
- package/dist/actions/open-extension-overlay/action.js +4 -0
- package/dist/actions/open-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/open-extension-overlay/mock.js +1 -0
- package/dist/actions/open-extension-overlay/types.d.ts +9 -0
- package/dist/actions/park-order/types.d.ts +0 -3
- package/dist/actions/partial-payment/types.d.ts +0 -5
- package/dist/actions/print/mock.js +3 -6
- package/dist/actions/print/types.d.ts +1 -7
- package/dist/actions/process-partial-refund/types.d.ts +0 -3
- package/dist/actions/remove-customer-note/mock.js +14 -5
- package/dist/actions/resolve-extension-overlay/action.d.ts +2 -0
- package/dist/actions/resolve-extension-overlay/action.js +4 -0
- package/dist/actions/resolve-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/resolve-extension-overlay/mock.js +1 -0
- package/dist/actions/resolve-extension-overlay/types.d.ts +9 -0
- package/dist/actions/resume-parked-order/mock.js +1 -1
- package/dist/actions/resume-parked-order/types.d.ts +0 -3
- package/dist/actions/save-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/action.js +4 -0
- package/dist/actions/save-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/mock.js +7 -0
- package/dist/actions/save-smart-grid-layout/types.d.ts +12 -0
- package/dist/actions/set-active-product-discount/mock.js +1 -1
- package/dist/actions/set-active-product-fee/mock.js +1 -1
- package/dist/actions/tap-to-pay-payment/types.d.ts +0 -5
- package/dist/actions/terminal-payment/types.d.ts +0 -5
- package/dist/actions/vendara-payment/types.d.ts +0 -5
- package/dist/common-types/index.d.ts +0 -1
- package/dist/common-types/index.js +0 -1
- package/dist/demo/database.d.ts +21 -21
- package/dist/demo/database.js +36 -51
- package/dist/index.d.ts +124 -116
- package/dist/index.js +19 -15
- package/dist/interceptors/types.d.ts +34 -0
- package/dist/interceptors/types.js +1 -0
- package/dist/projects/render/mocks.js +10 -8
- package/dist/projects/render/types.d.ts +6 -5
- package/dist/pubsub/topics/attributes/attribute-created/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/attribute-created/types.js +1 -0
- package/dist/pubsub/topics/attributes/attribute-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/attribute-updated/types.js +1 -0
- package/dist/pubsub/topics/attributes/index.d.ts +3 -0
- package/dist/pubsub/topics/attributes/index.js +18 -0
- package/dist/pubsub/topics/attributes/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/types.js +2 -0
- package/dist/pubsub/topics/categories/category-created/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/category-created/types.js +1 -0
- package/dist/pubsub/topics/categories/category-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/category-updated/types.js +1 -0
- package/dist/pubsub/topics/categories/index.d.ts +3 -0
- package/dist/pubsub/topics/categories/index.js +18 -0
- package/dist/pubsub/topics/categories/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/types.js +2 -0
- package/dist/pubsub/topics/index.d.ts +4 -0
- package/dist/pubsub/topics/index.js +4 -0
- package/dist/pubsub/topics/orders/index.js +0 -10
- package/dist/pubsub/topics/orders/types.d.ts +2 -6
- package/dist/pubsub/topics/orders/types.js +0 -2
- package/dist/pubsub/topics/print/print-completed/types.d.ts +1 -1
- package/dist/pubsub/topics/print/print-error/types.d.ts +1 -1
- package/dist/pubsub/topics/print/print-started/types.d.ts +1 -1
- package/dist/pubsub/topics/products/product-get-active/types.d.ts +6 -2
- package/dist/pubsub/topics/transactions/index.d.ts +3 -0
- package/dist/pubsub/topics/transactions/index.js +18 -0
- package/dist/pubsub/topics/transactions/transaction-created/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/transaction-created/types.js +1 -0
- package/dist/pubsub/topics/transactions/transaction-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/transaction-updated/types.js +1 -0
- package/dist/pubsub/topics/transactions/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/types.js +2 -0
- package/dist/pubsub/topics/types.d.ts +8 -0
- package/dist/pubsub/topics/users/index.js +10 -0
- package/dist/pubsub/topics/users/types.d.ts +6 -2
- package/dist/pubsub/topics/users/types.js +2 -0
- package/dist/pubsub/topics/users/user-created/types.d.ts +6 -0
- package/dist/pubsub/topics/users/user-created/types.js +1 -0
- package/dist/pubsub/topics/users/user-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/users/user-updated/types.js +1 -0
- package/dist/pubsub/topics/variants/index.d.ts +3 -0
- package/dist/pubsub/topics/variants/index.js +18 -0
- package/dist/pubsub/topics/variants/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/types.js +2 -0
- package/dist/pubsub/topics/variants/variant-created/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/variant-created/types.js +1 -0
- package/dist/pubsub/topics/variants/variant-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/variant-updated/types.js +1 -0
- package/package.json +15 -12
- package/dist/actions/can-transition/action.d.ts +0 -2
- package/dist/actions/can-transition/action.js +0 -4
- package/dist/actions/can-transition/mock.d.ts +0 -6
- package/dist/actions/can-transition/mock.js +0 -28
- package/dist/actions/can-transition/types.d.ts +0 -11
- package/dist/actions/get-available-transitions/action.d.ts +0 -2
- package/dist/actions/get-available-transitions/action.js +0 -4
- package/dist/actions/get-available-transitions/mock.d.ts +0 -6
- package/dist/actions/get-available-transitions/mock.js +0 -26
- package/dist/actions/get-available-transitions/types.d.ts +0 -9
- package/dist/actions/trigger-webhook/action.d.ts +0 -6
- package/dist/actions/trigger-webhook/action.js +0 -8
- package/dist/actions/trigger-webhook/mock.d.ts +0 -2
- package/dist/actions/trigger-webhook/mock.js +0 -8
- package/dist/actions/trigger-webhook/types.d.ts +0 -21
- package/dist/actions/trigger-webhook/types.js +0 -2
- package/dist/actions/trigger-zapier-webhook/action.d.ts +0 -6
- package/dist/actions/trigger-zapier-webhook/action.js +0 -8
- package/dist/actions/trigger-zapier-webhook/mock.d.ts +0 -2
- package/dist/actions/trigger-zapier-webhook/mock.js +0 -8
- package/dist/actions/trigger-zapier-webhook/types.d.ts +0 -9
- package/dist/common-types/order-state.d.ts +0 -32
- package/dist/common-types/order-state.js +0 -6
- package/dist/common-types/state-fragment.d.ts +0 -77
- package/dist/common-types/state-fragment.js +0 -10
- package/dist/fragments/index.d.ts +0 -1
- package/dist/fragments/index.js +0 -1
- package/dist/fragments/preorder-no-deposit.d.ts +0 -26
- package/dist/fragments/preorder-no-deposit.js +0 -166
- package/dist/pubsub/topics/orders/state-transition-blocked/types.d.ts +0 -16
- package/dist/pubsub/topics/orders/state-transition-completed/types.d.ts +0 -15
- /package/dist/actions/{can-transition → get-smart-grid-layout}/types.js +0 -0
- /package/dist/actions/{get-available-transitions → integration-payment}/types.js +0 -0
- /package/dist/actions/{trigger-zapier-webhook → open-extension-overlay}/types.js +0 -0
- /package/dist/{pubsub/topics/orders/state-transition-blocked → actions/resolve-extension-overlay}/types.js +0 -0
- /package/dist/{pubsub/topics/orders/state-transition-completed → actions/save-smart-grid-layout}/types.js +0 -0
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { MOCK_CUSTOMERS } from "../../demo/database";
|
|
1
|
+
import { MOCK_CUSTOMERS, mockPublishEvent } from "../../demo/database";
|
|
2
|
+
function generateNoteId() {
|
|
3
|
+
return `mock_note_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
|
4
|
+
}
|
|
2
5
|
export const mockAddCustomerNote = (params) => {
|
|
3
6
|
console.log("[Mock] addCustomerNote called", params);
|
|
4
|
-
if (params?.
|
|
5
|
-
|
|
6
|
-
if (customer) {
|
|
7
|
-
if (!customer.notes) {
|
|
8
|
-
customer.notes = [];
|
|
9
|
-
}
|
|
10
|
-
customer.notes.push({
|
|
11
|
-
_id: `mock_note_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`,
|
|
12
|
-
message: params.note,
|
|
13
|
-
createdAt: new Date().toISOString()
|
|
14
|
-
});
|
|
15
|
-
}
|
|
7
|
+
if (!params?.note) {
|
|
8
|
+
throw new Error("addCustomerNote: note is required");
|
|
16
9
|
}
|
|
10
|
+
const target = params.customerId ? MOCK_CUSTOMERS.find(c => c._id === params.customerId) : MOCK_CUSTOMERS[0];
|
|
11
|
+
if (!target) {
|
|
12
|
+
throw new Error("addCustomerNote: no target customer (provide customerId or seed at least one mock customer)");
|
|
13
|
+
}
|
|
14
|
+
const noteId = generateNoteId();
|
|
15
|
+
const note = {
|
|
16
|
+
_id: noteId,
|
|
17
|
+
message: params.note,
|
|
18
|
+
createdAt: new Date().toISOString()
|
|
19
|
+
};
|
|
20
|
+
target.notes = [...(target.notes || []), note];
|
|
21
|
+
mockPublishEvent("customers", "customer-note-added", {
|
|
22
|
+
customer: target,
|
|
23
|
+
note
|
|
24
|
+
});
|
|
17
25
|
return Promise.resolve({
|
|
18
26
|
success: true,
|
|
19
|
-
customerId:
|
|
20
|
-
|
|
27
|
+
customerId: target._id,
|
|
28
|
+
noteId,
|
|
29
|
+
note: params.note,
|
|
21
30
|
timestamp: new Date().toISOString()
|
|
22
31
|
});
|
|
23
32
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export interface AddCustomerNoteParams {
|
|
2
|
-
customerId: string;
|
|
3
2
|
note: string;
|
|
3
|
+
customerId?: string;
|
|
4
4
|
}
|
|
5
5
|
export interface AddCustomerNoteResponse {
|
|
6
6
|
success: boolean;
|
|
7
7
|
customerId: string;
|
|
8
|
+
noteId: string;
|
|
8
9
|
note: string;
|
|
9
10
|
timestamp: string;
|
|
10
11
|
}
|
|
11
|
-
export type AddCustomerNote = (params
|
|
12
|
+
export type AddCustomerNote = (params: AddCustomerNoteParams) => Promise<AddCustomerNoteResponse>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { CFProductType, CurrencyCode } from "../../CommonTypes";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
2
3
|
export const mockAddProduct = async (params) => {
|
|
3
4
|
console.log("[Mock] addProduct called", params);
|
|
4
5
|
const hasVariants = params.variants && params.variants.length > 0;
|
|
6
|
+
const productId = "mock_product_" + Date.now();
|
|
5
7
|
return {
|
|
6
8
|
product: {
|
|
7
|
-
_id:
|
|
9
|
+
_id: productId,
|
|
10
|
+
externalId: `ext_${productId}`,
|
|
8
11
|
currency: CurrencyCode.USD,
|
|
9
12
|
minorUnits: 2,
|
|
10
13
|
name: params.name,
|
|
11
14
|
description: params.description,
|
|
12
|
-
categories: params.categories || [],
|
|
15
|
+
categories: (params.categories || []).map((c) => ({ name: c, externalId: c })),
|
|
13
16
|
taxTable: params.taxTable || "",
|
|
14
17
|
images: params.images || [],
|
|
15
18
|
status: params.status || "active",
|
|
@@ -20,16 +23,19 @@ export const mockAddProduct = async (params) => {
|
|
|
20
23
|
maxPrice: params.price || 0,
|
|
21
24
|
variants: hasVariants
|
|
22
25
|
? params.variants.map((v, i) => ({ ...v, _id: `mock_variant_${Date.now()}_${i}` }))
|
|
23
|
-
: [
|
|
26
|
+
: [
|
|
27
|
+
{
|
|
24
28
|
_id: `mock_variant_${Date.now()}_0`,
|
|
29
|
+
externalId: `ext_variant_${Date.now()}_0`,
|
|
25
30
|
sku: params.sku || "",
|
|
26
31
|
price: params.price || 0,
|
|
27
32
|
salePrice: 0,
|
|
28
33
|
isOnSale: false,
|
|
29
34
|
manageStock: params.manageStock || false,
|
|
30
|
-
attributes: []
|
|
31
|
-
}
|
|
35
|
+
attributes: []
|
|
36
|
+
}
|
|
37
|
+
]
|
|
32
38
|
},
|
|
33
|
-
timestamp: new Date().toISOString()
|
|
39
|
+
timestamp: new Date().toISOString()
|
|
34
40
|
};
|
|
35
41
|
};
|
|
@@ -10,11 +10,11 @@ export const mockAddProductDiscount = async (params) => {
|
|
|
10
10
|
item = MOCK_CART.products[MOCK_CART.products.length - 1];
|
|
11
11
|
}
|
|
12
12
|
if (item) {
|
|
13
|
-
item.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
item.discounts = [{
|
|
14
|
+
value: params.amount,
|
|
15
|
+
isPercent: params.isPercent || false,
|
|
16
|
+
label: params.label
|
|
17
|
+
}];
|
|
18
18
|
// Recalculate cart totals (simplified)
|
|
19
19
|
// Ideally, this should trigger a full recalculation function
|
|
20
20
|
}
|
|
@@ -10,12 +10,12 @@ export const mockAddProductFee = async (params) => {
|
|
|
10
10
|
item = MOCK_CART.products[MOCK_CART.products.length - 1];
|
|
11
11
|
}
|
|
12
12
|
if (item) {
|
|
13
|
-
item.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
item.fees = [{
|
|
14
|
+
label: params.label || "Fee",
|
|
15
|
+
amount: params.amount,
|
|
16
|
+
isPercent: params.isPercent || false,
|
|
17
|
+
applyTaxes: params.applyTaxes || false
|
|
18
|
+
}];
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { CFOrder } from "../../CommonTypes";
|
|
2
|
-
import type { CFTransitionResult } from "../../common-types/order-state";
|
|
3
2
|
export interface CashPaymentParams {
|
|
4
3
|
/** If not provided, uses the cart total. */
|
|
5
4
|
amount?: number;
|
|
6
5
|
/** Defaults to false. */
|
|
7
6
|
openChangeCalculator?: boolean;
|
|
8
|
-
/** Override the fulfillment state after full payment. Render resolves the cascade. */
|
|
9
|
-
checkoutFulfillmentTarget?: string;
|
|
10
7
|
}
|
|
11
8
|
export interface CashPaymentResponse {
|
|
12
9
|
success: boolean;
|
|
@@ -15,7 +12,5 @@ export interface CashPaymentResponse {
|
|
|
15
12
|
paymentType: string;
|
|
16
13
|
order: CFOrder | null;
|
|
17
14
|
timestamp: string;
|
|
18
|
-
/** Present when the state machine blocked or forced the transition. */
|
|
19
|
-
transitionResult?: CFTransitionResult;
|
|
20
15
|
}
|
|
21
16
|
export type CashPayment = (params?: CashPaymentParams) => Promise<CashPaymentResponse>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CFTransitionResult } from "../../common-types/order-state";
|
|
2
1
|
export interface DeleteParkedOrderParams {
|
|
3
2
|
orderId: string;
|
|
4
3
|
}
|
|
@@ -6,7 +5,5 @@ export interface DeleteParkedOrderResponse {
|
|
|
6
5
|
success: boolean;
|
|
7
6
|
orderId: string;
|
|
8
7
|
timestamp: string;
|
|
9
|
-
/** Present when the state machine blocked or forced the transition. */
|
|
10
|
-
transitionResult?: CFTransitionResult;
|
|
11
8
|
}
|
|
12
9
|
export type DeleteParkedOrder = (params?: DeleteParkedOrderParams) => Promise<DeleteParkedOrderResponse>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { CFProductType, CurrencyCode } from "../../CommonTypes";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
2
3
|
export const mockEditProduct = async (params) => {
|
|
3
4
|
console.log("[Mock] editProduct called", params);
|
|
4
5
|
return {
|
|
5
6
|
product: {
|
|
6
7
|
_id: params.productId,
|
|
8
|
+
externalId: `ext_${params.productId}`,
|
|
7
9
|
currency: CurrencyCode.USD,
|
|
8
10
|
minorUnits: 2,
|
|
9
11
|
name: params.changes.name || "Updated Product",
|
|
10
12
|
description: params.changes.description,
|
|
11
|
-
categories: params.changes.categories || [],
|
|
13
|
+
categories: (params.changes.categories || []).map((c) => ({ name: c, externalId: c })),
|
|
12
14
|
taxTable: params.changes.taxTable || "",
|
|
13
15
|
images: params.changes.images || [],
|
|
14
16
|
status: params.changes.status || "active",
|
|
15
17
|
productType: CFProductType.SIMPLE,
|
|
16
18
|
attributes: [],
|
|
17
|
-
variants: []
|
|
19
|
+
variants: []
|
|
18
20
|
},
|
|
19
|
-
timestamp: new Date().toISOString()
|
|
21
|
+
timestamp: new Date().toISOString()
|
|
20
22
|
};
|
|
21
23
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CFOrder } from "../../CommonTypes";
|
|
2
|
-
import type { CFTransitionResult } from "../../common-types/order-state";
|
|
3
2
|
/** Params for extension-initiated payments; host routes by `paymentType`. */
|
|
4
3
|
export interface ExtensionPaymentParams {
|
|
5
4
|
paymentType: string;
|
|
@@ -9,8 +8,10 @@ export interface ExtensionPaymentParams {
|
|
|
9
8
|
referenceId?: string;
|
|
10
9
|
extensionId?: string;
|
|
11
10
|
metadata?: Record<string, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
|
|
11
|
+
/** EMV tag string from an integration terminal; forwarded to the order PaymentMethod's `emv`. */
|
|
12
|
+
emvData?: string;
|
|
13
|
+
/** Processor fee for an integration payment; forwarded to the order PaymentMethod's `processorFee`. */
|
|
14
|
+
processorFee?: number;
|
|
14
15
|
}
|
|
15
16
|
export interface ExtensionPaymentResponse {
|
|
16
17
|
success: boolean;
|
|
@@ -18,7 +19,5 @@ export interface ExtensionPaymentResponse {
|
|
|
18
19
|
paymentType: string;
|
|
19
20
|
order: CFOrder | null;
|
|
20
21
|
timestamp: string;
|
|
21
|
-
/** Present when the state machine blocked or forced the transition. */
|
|
22
|
-
transitionResult?: CFTransitionResult;
|
|
23
22
|
}
|
|
24
23
|
export type ExtensionPayment = (params?: ExtensionPaymentParams) => Promise<ExtensionPaymentResponse>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MOCK_COMPANY, MOCK_OUTLET, MOCK_STATION, MOCK_USER } from "../../demo/database";
|
|
2
2
|
// Mock for Render context (POS terminal)
|
|
3
|
-
export const mockGetContext =
|
|
3
|
+
export const mockGetContext = () => {
|
|
4
4
|
console.log("[Mock] getContext called (Render)");
|
|
5
|
-
return {
|
|
5
|
+
return Promise.resolve({
|
|
6
6
|
userId: MOCK_USER.id || null,
|
|
7
7
|
companyId: MOCK_COMPANY.id || null,
|
|
8
8
|
companyName: MOCK_COMPANY.name || null,
|
|
@@ -17,17 +17,23 @@ export const mockGetContext = async () => {
|
|
|
17
17
|
buildSourceId: "mock_source_id",
|
|
18
18
|
buildIsPremium: true,
|
|
19
19
|
isOffline: false,
|
|
20
|
+
currency: "USD",
|
|
21
|
+
currencySymbol: "$",
|
|
22
|
+
currencyPrefix: "$",
|
|
23
|
+
currencySuffix: "",
|
|
24
|
+
thousandSeparator: ",",
|
|
25
|
+
decimalSeparator: ".",
|
|
20
26
|
user: null,
|
|
21
27
|
company: null,
|
|
22
28
|
station: null,
|
|
23
29
|
outlet: null,
|
|
24
30
|
timestamp: new Date().toISOString()
|
|
25
|
-
};
|
|
31
|
+
});
|
|
26
32
|
};
|
|
27
33
|
// Mock for Manage context (Hub/BuilderHub)
|
|
28
|
-
export const mockGetContextManage =
|
|
34
|
+
export const mockGetContextManage = () => {
|
|
29
35
|
console.log("[Mock] getContext called (Manage)");
|
|
30
|
-
return {
|
|
36
|
+
return Promise.resolve({
|
|
31
37
|
user: {
|
|
32
38
|
_id: MOCK_USER.id,
|
|
33
39
|
id: MOCK_USER.id,
|
|
@@ -47,5 +53,5 @@ export const mockGetContextManage = async () => {
|
|
|
47
53
|
extensionId: "mock_extension_id",
|
|
48
54
|
outlets: [MOCK_OUTLET],
|
|
49
55
|
timestamp: new Date().toISOString()
|
|
50
|
-
};
|
|
56
|
+
});
|
|
51
57
|
};
|
|
@@ -13,15 +13,15 @@ export const mockGetProducts = async (params) => {
|
|
|
13
13
|
// Handle categories filter: { $in: [...] } or direct string
|
|
14
14
|
const catFilter = query.categories;
|
|
15
15
|
if (typeof catFilter === 'string') {
|
|
16
|
-
products = products.filter(p => (p.categories || []).
|
|
16
|
+
products = products.filter(p => (p.categories || []).some(c => c.name === catFilter));
|
|
17
17
|
}
|
|
18
18
|
else if (typeof catFilter === 'object' && '$in' in catFilter) {
|
|
19
19
|
const inList = catFilter.$in;
|
|
20
|
-
products = products.filter(p => (p.categories || []).some(c => inList.includes(c)));
|
|
20
|
+
products = products.filter(p => (p.categories || []).some(c => inList.includes(c.name)));
|
|
21
21
|
}
|
|
22
22
|
else if (typeof catFilter === 'object' && '$contains' in catFilter) {
|
|
23
23
|
const containsVal = catFilter.$contains;
|
|
24
|
-
products = products.filter(p => (p.categories || []).includes(containsVal));
|
|
24
|
+
products = products.filter(p => (p.categories || []).some(c => c.name.includes(containsVal)));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return {
|
|
@@ -4,61 +4,55 @@ export const mockGetRoles = async (params) => {
|
|
|
4
4
|
roles: [
|
|
5
5
|
{
|
|
6
6
|
id: "691df9c6c478bada1fb23d0b",
|
|
7
|
-
_id: "691df9c6c478bada1fb23d0b",
|
|
8
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
9
7
|
name: "Owner",
|
|
10
8
|
permissions: [
|
|
11
|
-
{ category: "hub_access",
|
|
12
|
-
{ category: "hub_access",
|
|
13
|
-
{ category: "hub_access",
|
|
14
|
-
{ category: "hub_access",
|
|
15
|
-
{ category: "hub_access",
|
|
16
|
-
{ category: "hub_access",
|
|
17
|
-
{ category: "hub_access",
|
|
18
|
-
{ category: "hub_access",
|
|
19
|
-
{ category: "hub_access",
|
|
20
|
-
{ category: "hub_access",
|
|
21
|
-
{ category: "hub_access",
|
|
22
|
-
{ category: "hub_access",
|
|
23
|
-
{ category: "hub_access",
|
|
24
|
-
{ category: "station_access",
|
|
25
|
-
{ category: "station_access",
|
|
26
|
-
{ category: "station_access",
|
|
27
|
-
{ category: "station_access",
|
|
28
|
-
{ category: "station_access",
|
|
29
|
-
{ category: "station_access",
|
|
30
|
-
{ category: "station_access",
|
|
31
|
-
{ category: "station_access",
|
|
9
|
+
{ category: "hub_access", label: "taxes", name: "taxes", value: true },
|
|
10
|
+
{ category: "hub_access", label: "general", name: "general", value: true },
|
|
11
|
+
{ category: "hub_access", label: "reports", name: "reports", value: true },
|
|
12
|
+
{ category: "hub_access", label: "products", name: "products", value: true },
|
|
13
|
+
{ category: "hub_access", label: "users", name: "users", value: true },
|
|
14
|
+
{ category: "hub_access", label: "outlets", name: "outlets", value: true },
|
|
15
|
+
{ category: "hub_access", label: "builder", name: "builder", value: true },
|
|
16
|
+
{ category: "hub_access", label: "global_blocks", name: "global_blocks", value: true },
|
|
17
|
+
{ category: "hub_access", label: "images", name: "images", value: true },
|
|
18
|
+
{ category: "hub_access", label: "transactions", name: "transactions", value: true },
|
|
19
|
+
{ category: "hub_access", label: "payouts", name: "payouts", value: true },
|
|
20
|
+
{ category: "hub_access", label: "terminals", name: "terminals", value: true },
|
|
21
|
+
{ category: "hub_access", label: "billing", name: "billing", value: true },
|
|
22
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: true },
|
|
23
|
+
{ category: "station_access", label: "issue_refunds", name: "issue_refunds", value: true },
|
|
24
|
+
{ category: "station_access", label: "delete_customers", name: "delete_customers", value: true },
|
|
25
|
+
{ category: "station_access", label: "version_control", name: "version_control", value: true },
|
|
26
|
+
{ category: "station_access", label: "session_reports", name: "session_reports", value: true },
|
|
27
|
+
{ category: "station_access", label: "cash_drawer", name: "cash_drawer", value: true },
|
|
28
|
+
{ category: "station_access", label: "station_setting", name: "station_setting", value: true },
|
|
29
|
+
{ category: "station_access", label: "station_transactions", name: "station_transactions", value: true },
|
|
32
30
|
]
|
|
33
31
|
},
|
|
34
32
|
{
|
|
35
33
|
id: "691df9c6c478bada1fb23d0c",
|
|
36
|
-
_id: "691df9c6c478bada1fb23d0c",
|
|
37
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
38
34
|
name: "admin",
|
|
39
35
|
permissions: [
|
|
40
|
-
{ category: "hub_access",
|
|
41
|
-
{ category: "hub_access",
|
|
42
|
-
{ category: "hub_access",
|
|
43
|
-
{ category: "hub_access",
|
|
44
|
-
{ category: "hub_access",
|
|
45
|
-
{ category: "hub_access",
|
|
46
|
-
{ category: "station_access",
|
|
47
|
-
{ category: "station_access",
|
|
48
|
-
{ category: "station_access",
|
|
36
|
+
{ category: "hub_access", label: "taxes", name: "taxes", value: true },
|
|
37
|
+
{ category: "hub_access", label: "general", name: "general", value: true },
|
|
38
|
+
{ category: "hub_access", label: "reports", name: "reports", value: true },
|
|
39
|
+
{ category: "hub_access", label: "products", name: "products", value: true },
|
|
40
|
+
{ category: "hub_access", label: "users", name: "users", value: true },
|
|
41
|
+
{ category: "hub_access", label: "transactions", name: "transactions", value: true },
|
|
42
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: true },
|
|
43
|
+
{ category: "station_access", label: "issue_refunds", name: "issue_refunds", value: true },
|
|
44
|
+
{ category: "station_access", label: "delete_customers", name: "delete_customers", value: true },
|
|
49
45
|
]
|
|
50
46
|
},
|
|
51
47
|
{
|
|
52
48
|
id: "691df9c6c478bada1fb23d0d",
|
|
53
|
-
_id: "691df9c6c478bada1fb23d0d",
|
|
54
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
55
49
|
name: "cashier",
|
|
56
50
|
permissions: [
|
|
57
|
-
{ category: "station_access",
|
|
58
|
-
{ category: "station_access",
|
|
59
|
-
{ category: "station_access",
|
|
60
|
-
{ category: "station_access",
|
|
61
|
-
{ category: "station_access",
|
|
51
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: false },
|
|
52
|
+
{ category: "station_access", label: "issue_refunds", name: "issue_refunds", value: false },
|
|
53
|
+
{ category: "station_access", label: "delete_customers", name: "delete_customers", value: false },
|
|
54
|
+
{ category: "station_access", label: "session_reports", name: "session_reports", value: true },
|
|
55
|
+
{ category: "station_access", label: "cash_drawer", name: "cash_drawer", value: true },
|
|
62
56
|
]
|
|
63
57
|
}
|
|
64
58
|
],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CFSmartGridLayout } from "../../CommonTypes";
|
|
2
|
+
/** Fetch a builder SmartGrid layout by `gridId`. */
|
|
3
|
+
export interface GetSmartGridLayoutParams {
|
|
4
|
+
gridId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetSmartGridLayoutResponse {
|
|
7
|
+
success: boolean;
|
|
8
|
+
/** The stored layout, or `null` when no layout exists for the grid. */
|
|
9
|
+
layout: CFSmartGridLayout | null;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
}
|
|
12
|
+
export type GetSmartGridLayout = (params: GetSmartGridLayoutParams) => Promise<GetSmartGridLayoutResponse>;
|
|
@@ -5,7 +5,6 @@ export const mockGetUsers = async (params) => {
|
|
|
5
5
|
users: [
|
|
6
6
|
{
|
|
7
7
|
id: "691df9c2047bfc55994d703f",
|
|
8
|
-
_id: "691df9c2047bfc55994d703f",
|
|
9
8
|
firstName: "Sarah",
|
|
10
9
|
lastName: "Mitchell",
|
|
11
10
|
email: "sarah.mitchell@company.com",
|
|
@@ -13,25 +12,22 @@ export const mockGetUsers = async (params) => {
|
|
|
13
12
|
type: CFUserTypes.ORG_OWNER,
|
|
14
13
|
role: {
|
|
15
14
|
id: "691df9c6c478bada1fb23d0b",
|
|
16
|
-
_id: "691df9c6c478bada1fb23d0b",
|
|
17
15
|
name: "Owner",
|
|
18
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
19
16
|
permissions: [
|
|
20
|
-
{ category: "hub_access",
|
|
21
|
-
{ category: "hub_access",
|
|
22
|
-
{ category: "hub_access",
|
|
23
|
-
{ category: "hub_access",
|
|
24
|
-
{ category: "hub_access",
|
|
25
|
-
{ category: "hub_access",
|
|
26
|
-
{ category: "station_access",
|
|
27
|
-
{ category: "station_access",
|
|
17
|
+
{ category: "hub_access", label: "general", name: "general", value: true },
|
|
18
|
+
{ category: "hub_access", label: "products", name: "products", value: true },
|
|
19
|
+
{ category: "hub_access", label: "reports", name: "reports", value: true },
|
|
20
|
+
{ category: "hub_access", label: "users", name: "users", value: true },
|
|
21
|
+
{ category: "hub_access", label: "builder", name: "builder", value: true },
|
|
22
|
+
{ category: "hub_access", label: "billing", name: "billing", value: true },
|
|
23
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: true },
|
|
24
|
+
{ category: "station_access", label: "issue_refunds", name: "issue_refunds", value: true },
|
|
28
25
|
]
|
|
29
26
|
},
|
|
30
27
|
outlets: []
|
|
31
28
|
},
|
|
32
29
|
{
|
|
33
30
|
id: "692a1b3c4d5e6f7890abcde1",
|
|
34
|
-
_id: "692a1b3c4d5e6f7890abcde1",
|
|
35
31
|
firstName: "James",
|
|
36
32
|
lastName: "Rodriguez",
|
|
37
33
|
email: "james.rodriguez@company.com",
|
|
@@ -39,22 +35,19 @@ export const mockGetUsers = async (params) => {
|
|
|
39
35
|
type: CFUserTypes.ADMIN,
|
|
40
36
|
role: {
|
|
41
37
|
id: "691df9c6c478bada1fb23d0c",
|
|
42
|
-
_id: "691df9c6c478bada1fb23d0c",
|
|
43
38
|
name: "admin",
|
|
44
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
45
39
|
permissions: [
|
|
46
|
-
{ category: "hub_access",
|
|
47
|
-
{ category: "hub_access",
|
|
48
|
-
{ category: "hub_access",
|
|
49
|
-
{ category: "hub_access",
|
|
50
|
-
{ category: "station_access",
|
|
40
|
+
{ category: "hub_access", label: "general", name: "general", value: true },
|
|
41
|
+
{ category: "hub_access", label: "products", name: "products", value: true },
|
|
42
|
+
{ category: "hub_access", label: "reports", name: "reports", value: true },
|
|
43
|
+
{ category: "hub_access", label: "users", name: "users", value: true },
|
|
44
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: true },
|
|
51
45
|
]
|
|
52
46
|
},
|
|
53
47
|
outlets: ["outlet-main", "outlet-downtown"]
|
|
54
48
|
},
|
|
55
49
|
{
|
|
56
50
|
id: "692a1b3c4d5e6f7890abcde2",
|
|
57
|
-
_id: "692a1b3c4d5e6f7890abcde2",
|
|
58
51
|
firstName: "Lisa",
|
|
59
52
|
lastName: "Chen",
|
|
60
53
|
email: "lisa.chen@company.com",
|
|
@@ -62,13 +55,11 @@ export const mockGetUsers = async (params) => {
|
|
|
62
55
|
type: CFUserTypes.CASHIER,
|
|
63
56
|
role: {
|
|
64
57
|
id: "691df9c6c478bada1fb23d0d",
|
|
65
|
-
_id: "691df9c6c478bada1fb23d0d",
|
|
66
58
|
name: "cashier",
|
|
67
|
-
companyId: "691df9c4c478bada1fb23bff",
|
|
68
59
|
permissions: [
|
|
69
|
-
{ category: "station_access",
|
|
70
|
-
{ category: "station_access",
|
|
71
|
-
{ category: "station_access",
|
|
60
|
+
{ category: "station_access", label: "give_discounts", name: "give_discounts", value: false },
|
|
61
|
+
{ category: "station_access", label: "issue_refunds", name: "issue_refunds", value: false },
|
|
62
|
+
{ category: "station_access", label: "session_reports", name: "session_reports", value: true },
|
|
72
63
|
]
|
|
73
64
|
},
|
|
74
65
|
outlets: ["outlet-main"]
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CFTransitionResult } from "../../common-types/order-state";
|
|
2
1
|
export interface InitiateRefundParams {
|
|
3
2
|
/** The ID of the order to refund. If not provided, uses the currently active order. */
|
|
4
3
|
orderId?: string;
|
|
@@ -7,7 +6,5 @@ export interface InitiateRefundResponse {
|
|
|
7
6
|
success: boolean;
|
|
8
7
|
orderId: string;
|
|
9
8
|
timestamp: string;
|
|
10
|
-
/** Present when the state machine blocked or forced the transition. */
|
|
11
|
-
transitionResult?: CFTransitionResult;
|
|
12
9
|
}
|
|
13
10
|
export type InitiateRefund = (params?: InitiateRefundParams) => Promise<InitiateRefundResponse>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration payment — thin wrapper over {@link extensionPayment} with `paymentType: "integration"`.
|
|
3
|
+
*/
|
|
4
|
+
import { extensionPayment } from "../extension-payment/action";
|
|
5
|
+
export const integrationPayment = async (params) => {
|
|
6
|
+
return extensionPayment({ ...params, paymentType: "integration" });
|
|
7
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtensionPaymentResponse } from "../extension-payment/types";
|
|
2
|
+
/** Integration (e.g. Stripe-style terminal) payment — always uses paymentType `"integration"` on the wire. */
|
|
3
|
+
export interface IntegrationPaymentParams {
|
|
4
|
+
amount?: number;
|
|
5
|
+
processor?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
referenceId?: string;
|
|
8
|
+
extensionId?: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
/** EMV tag string from the integration terminal; forwarded to the order PaymentMethod's `emv`. */
|
|
11
|
+
emvData?: string;
|
|
12
|
+
/** Processor fee for the integration payment; forwarded to the order PaymentMethod's `processorFee`. */
|
|
13
|
+
processorFee?: number;
|
|
14
|
+
}
|
|
15
|
+
export type IntegrationPaymentResponse = ExtensionPaymentResponse;
|
|
16
|
+
export type IntegrationPayment = (params?: IntegrationPaymentParams) => Promise<IntegrationPaymentResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const mockOpenExtensionOverlay = () => Promise.resolve(true);
|