@final-commerce/command-frame 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/print/action.d.ts +6 -0
- package/dist/actions/print/action.js +8 -0
- package/dist/actions/print/mock.d.ts +2 -0
- package/dist/actions/print/mock.js +26 -0
- package/dist/actions/print/types.d.ts +44 -0
- package/dist/actions/print/types.js +1 -0
- package/dist/actions/set-active-order/action.d.ts +6 -0
- package/dist/actions/set-active-order/action.js +8 -0
- package/dist/actions/set-active-order/mock.d.ts +2 -0
- package/dist/actions/set-active-order/mock.js +19 -0
- package/dist/actions/set-active-order/types.d.ts +10 -0
- package/dist/actions/set-active-order/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -1
- package/dist/projects/render/mocks.js +4 -0
- package/dist/projects/render/types.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const mockPrint = async (params) => {
|
|
2
|
+
console.log("[Mock] print called", params);
|
|
3
|
+
if (!params) {
|
|
4
|
+
throw new Error("Print parameters are required");
|
|
5
|
+
}
|
|
6
|
+
// Mock implementation - just log what would be printed
|
|
7
|
+
switch (params.type) {
|
|
8
|
+
case "image":
|
|
9
|
+
console.log("[Mock] Would print image:", params.data.image?.substring(0, 50) + "...");
|
|
10
|
+
break;
|
|
11
|
+
case "html":
|
|
12
|
+
console.log("[Mock] Would print HTML:", params.data.html?.substring(0, 100) + "...");
|
|
13
|
+
break;
|
|
14
|
+
case "selector":
|
|
15
|
+
console.log("[Mock] Would print element with selector:", params.data.selector);
|
|
16
|
+
break;
|
|
17
|
+
case "receipt":
|
|
18
|
+
console.log("[Mock] Would print receipt for order:", params.data.order);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
type: params.type
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CFActiveOrder } from "../../CommonTypes";
|
|
2
|
+
export type PrintType = "image" | "html" | "selector" | "receipt";
|
|
3
|
+
export type PrintParams = {
|
|
4
|
+
type: "image";
|
|
5
|
+
data: {
|
|
6
|
+
image: string;
|
|
7
|
+
};
|
|
8
|
+
options?: PrintOptions;
|
|
9
|
+
} | {
|
|
10
|
+
type: "html";
|
|
11
|
+
data: {
|
|
12
|
+
html: string;
|
|
13
|
+
};
|
|
14
|
+
options?: PrintOptions;
|
|
15
|
+
} | {
|
|
16
|
+
type: "selector";
|
|
17
|
+
data: {
|
|
18
|
+
selector: string;
|
|
19
|
+
};
|
|
20
|
+
options?: PrintOptions;
|
|
21
|
+
} | {
|
|
22
|
+
type: "receipt";
|
|
23
|
+
data: {
|
|
24
|
+
order?: Omit<CFActiveOrder, "_id">;
|
|
25
|
+
globalBlockId?: string;
|
|
26
|
+
};
|
|
27
|
+
options?: PrintOptions;
|
|
28
|
+
};
|
|
29
|
+
export interface PrintOptions {
|
|
30
|
+
margins?: {
|
|
31
|
+
top?: number;
|
|
32
|
+
right?: number;
|
|
33
|
+
bottom?: number;
|
|
34
|
+
left?: number;
|
|
35
|
+
};
|
|
36
|
+
paperSize?: string;
|
|
37
|
+
width?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PrintResponse {
|
|
40
|
+
success: boolean;
|
|
41
|
+
timestamp: string;
|
|
42
|
+
type: PrintType;
|
|
43
|
+
}
|
|
44
|
+
export type Print = (params?: PrintParams) => Promise<PrintResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set active order action
|
|
3
|
+
* Calls the setActiveOrder action on the parent window
|
|
4
|
+
*/
|
|
5
|
+
import { commandFrameClient } from "../../client";
|
|
6
|
+
export const setActiveOrder = async (params) => {
|
|
7
|
+
return await commandFrameClient.call("setActiveOrder", params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const mockSetActiveOrder = async (params) => {
|
|
2
|
+
console.log("[Mock] setActiveOrder called", params);
|
|
3
|
+
if (!params?.orderId) {
|
|
4
|
+
throw new Error("Order ID is required");
|
|
5
|
+
}
|
|
6
|
+
// Mock order response
|
|
7
|
+
return {
|
|
8
|
+
success: true,
|
|
9
|
+
order: {
|
|
10
|
+
_id: params.orderId,
|
|
11
|
+
id: params.orderId,
|
|
12
|
+
status: "completed",
|
|
13
|
+
companyId: "mock-company",
|
|
14
|
+
createdAt: new Date().toISOString(),
|
|
15
|
+
updatedAt: new Date().toISOString()
|
|
16
|
+
},
|
|
17
|
+
timestamp: new Date().toISOString()
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CFOrder } from "../../CommonTypes";
|
|
2
|
+
export interface SetActiveOrderParams {
|
|
3
|
+
orderId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SetActiveOrderResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
order: CFOrder;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export type SetActiveOrder = (params?: SetActiveOrderParams) => Promise<SetActiveOrderResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare const command: {
|
|
|
38
38
|
readonly authenticateUser: import("./actions/authenticate-user/types").AuthenticateUser;
|
|
39
39
|
readonly partialPayment: import("./actions/partial-payment/types").PartialPayment;
|
|
40
40
|
readonly switchUser: import("./actions/switch-user/types").SwitchUser;
|
|
41
|
+
readonly print: import("./actions/print/types").Print;
|
|
42
|
+
readonly setActiveOrder: import("./actions/set-active-order/types").SetActiveOrder;
|
|
41
43
|
readonly triggerWebhook: import("./actions/trigger-webhook/types").TriggerWebhook;
|
|
42
44
|
readonly triggerZapierWebhook: import("./actions/trigger-zapier-webhook/types").TriggerZapierWebhook;
|
|
43
45
|
readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
|
|
@@ -96,6 +98,8 @@ export type { ShowConfirmation, ShowConfirmationParams, ShowConfirmationResponse
|
|
|
96
98
|
export type { AuthenticateUser, AuthenticateUserParams, AuthenticateUserResponse } from "./actions/authenticate-user/types";
|
|
97
99
|
export type { PartialPayment, PartialPaymentParams, PartialPaymentResponse } from "./actions/partial-payment/types";
|
|
98
100
|
export type { SwitchUser, SwitchUserParams, SwitchUserResponse } from "./actions/switch-user/types";
|
|
101
|
+
export type { Print, PrintParams, PrintResponse } from "./actions/print/types";
|
|
102
|
+
export type { SetActiveOrder, SetActiveOrderParams, SetActiveOrderResponse } from "./actions/set-active-order/types";
|
|
99
103
|
export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
|
|
100
104
|
export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
|
|
101
105
|
export * from "./CommonTypes";
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@ import { showConfirmation } from "./actions/show-confirmation/action";
|
|
|
41
41
|
import { authenticateUser } from "./actions/authenticate-user/action";
|
|
42
42
|
import { partialPayment } from "./actions/partial-payment/action";
|
|
43
43
|
import { switchUser } from "./actions/switch-user/action";
|
|
44
|
+
import { print } from "./actions/print/action";
|
|
45
|
+
import { setActiveOrder } from "./actions/set-active-order/action";
|
|
44
46
|
// Integration Actions
|
|
45
47
|
import { triggerWebhook } from "./actions/trigger-webhook/action";
|
|
46
48
|
import { triggerZapierWebhook } from "./actions/trigger-zapier-webhook/action";
|
|
@@ -101,6 +103,8 @@ export const command = {
|
|
|
101
103
|
authenticateUser,
|
|
102
104
|
partialPayment,
|
|
103
105
|
switchUser,
|
|
106
|
+
print,
|
|
107
|
+
setActiveOrder,
|
|
104
108
|
// Integration Actions
|
|
105
109
|
triggerWebhook,
|
|
106
110
|
triggerZapierWebhook,
|
|
@@ -114,7 +118,7 @@ export const command = {
|
|
|
114
118
|
processPartialRefund,
|
|
115
119
|
// Custom Tables Actions
|
|
116
120
|
getCustomTables,
|
|
117
|
-
getCustomTableFields
|
|
121
|
+
getCustomTableFields
|
|
118
122
|
};
|
|
119
123
|
// Export Common Types
|
|
120
124
|
export * from "./CommonTypes";
|
|
@@ -46,6 +46,8 @@ import { mockTriggerWebhook } from "../../actions/trigger-webhook/mock";
|
|
|
46
46
|
import { mockTriggerZapierWebhook } from "../../actions/trigger-zapier-webhook/mock";
|
|
47
47
|
import { mockVendaraPayment } from "../../actions/vendara-payment/mock";
|
|
48
48
|
import { mockGetFinalContext } from "../../actions/get-final-context/mock";
|
|
49
|
+
import { mockPrint } from "../../actions/print/mock";
|
|
50
|
+
import { mockSetActiveOrder } from "../../actions/set-active-order/mock";
|
|
49
51
|
export const RENDER_MOCKS = {
|
|
50
52
|
addCartDiscount: mockAddCartDiscount,
|
|
51
53
|
addCartFee: mockAddCartFee,
|
|
@@ -95,4 +97,6 @@ export const RENDER_MOCKS = {
|
|
|
95
97
|
triggerZapierWebhook: mockTriggerZapierWebhook,
|
|
96
98
|
vendaraPayment: mockVendaraPayment,
|
|
97
99
|
getFinalContext: mockGetFinalContext,
|
|
100
|
+
print: mockPrint,
|
|
101
|
+
setActiveOrder: mockSetActiveOrder
|
|
98
102
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart } from "../../index";
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder } from "../../index";
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -48,4 +48,6 @@ export interface RenderProviderActions {
|
|
|
48
48
|
getRemainingRefundableQuantities: GetRemainingRefundableQuantities;
|
|
49
49
|
processPartialRefund: ProcessPartialRefund;
|
|
50
50
|
getCurrentCart: GetCurrentCart;
|
|
51
|
+
print: Print;
|
|
52
|
+
setActiveOrder: SetActiveOrder;
|
|
51
53
|
}
|