@final-commerce/command-frame 0.1.16 → 0.1.18

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.
Files changed (48) hide show
  1. package/README.md +42 -449
  2. package/dist/actions/add-cart-discount/mock.js +5 -1
  3. package/dist/actions/add-product-to-cart/mock.js +3 -1
  4. package/dist/actions/assign-customer/mock.js +3 -1
  5. package/dist/actions/cash-payment/mock.js +3 -1
  6. package/dist/actions/clear-cart/mock.js +3 -1
  7. package/dist/client.d.ts +4 -1
  8. package/dist/client.js +24 -4
  9. package/dist/demo/database.d.ts +4 -0
  10. package/dist/demo/database.js +26 -0
  11. package/dist/index.d.ts +7 -3
  12. package/dist/index.js +12 -5
  13. package/dist/projects/manage/client.d.ts +13 -0
  14. package/dist/projects/manage/client.js +13 -0
  15. package/dist/projects/manage/index.d.ts +4 -0
  16. package/dist/projects/manage/index.js +4 -0
  17. package/dist/projects/manage/mocks.d.ts +2 -0
  18. package/dist/projects/manage/mocks.js +6 -0
  19. package/dist/projects/manage/provider.d.ts +8 -0
  20. package/dist/projects/manage/provider.js +6 -0
  21. package/dist/projects/manage/types.d.ts +5 -0
  22. package/dist/projects/manage/types.js +1 -0
  23. package/dist/projects/render/client.d.ts +13 -0
  24. package/dist/projects/render/client.js +13 -0
  25. package/dist/projects/render/index.d.ts +4 -0
  26. package/dist/projects/render/index.js +4 -0
  27. package/dist/projects/render/mocks.d.ts +2 -0
  28. package/dist/projects/render/mocks.js +94 -0
  29. package/dist/projects/render/provider.d.ts +8 -0
  30. package/dist/projects/render/provider.js +6 -0
  31. package/dist/projects/render/types.d.ts +49 -0
  32. package/dist/projects/render/types.js +1 -0
  33. package/dist/provider.d.ts +19 -0
  34. package/dist/provider.js +178 -0
  35. package/dist/pubsub/subscriber.d.ts +4 -0
  36. package/dist/pubsub/subscriber.js +53 -5
  37. package/dist/pubsub/topics/cart/index.js +8 -8
  38. package/dist/pubsub/topics/customers/index.js +6 -6
  39. package/dist/pubsub/topics/orders/index.js +2 -2
  40. package/dist/pubsub/topics/payments/index.js +2 -2
  41. package/dist/pubsub/topics/products/index.js +2 -2
  42. package/dist/pubsub/topics/refunds/index.js +2 -2
  43. package/dist/pubsub/topics/types.d.ts +14 -0
  44. package/dist/pubsub/topics/types.js +1 -0
  45. package/dist/pubsub/types.d.ts +9 -0
  46. package/package.json +1 -1
  47. package/dist/demo/registry.d.ts +0 -5
  48. package/dist/demo/registry.js +0 -94
package/dist/client.js CHANGED
@@ -2,7 +2,6 @@
2
2
  * Command Frame Client for iframe communication
3
3
  * Allows the iframe to call functions on the parent window via postMessage
4
4
  */
5
- import { MOCK_REGISTRY } from "./demo/registry";
6
5
  export class CommandFrameClient {
7
6
  constructor(options = {}) {
8
7
  this.pendingRequests = new Map();
@@ -12,11 +11,20 @@ export class CommandFrameClient {
12
11
  this.useGlobalDebug = options.debug === undefined;
13
12
  // Default to provided mockMode or false. Detection happens via getFinalContext.
14
13
  this.mockMode = options.mockMode ?? false;
14
+ this.mockRegistry = options.mockRegistry || {};
15
+ // If running standalone (no parent window), force Mock Mode immediately
16
+ // This prevents the 2s delay and ensures immediate response in dev/standalone mode
17
+ if (typeof window !== 'undefined' && (!window.parent || window.parent === window)) {
18
+ if (this.isDebugEnabled()) {
19
+ console.log("[ActionsClient] Standalone mode detected. Enabling Mock Mode immediately.");
20
+ }
21
+ this.mockMode = true;
22
+ }
15
23
  if (typeof window !== 'undefined') {
16
24
  window.addEventListener("message", this.handleMessage.bind(this));
17
25
  }
18
26
  // Auto-detect mock mode on initialization
19
- this.getFinalContext().then((context) => {
27
+ this.detectContext().then((context) => {
20
28
  if (!context) {
21
29
  if (this.isDebugEnabled()) {
22
30
  console.warn("[ActionsClient] Environment detection failed (timeout or error). Switching to Mock Mode.");
@@ -31,6 +39,18 @@ export class CommandFrameClient {
31
39
  mockMode: this.mockMode
32
40
  });
33
41
  }
42
+ // Return a Proxy to enable dynamic method calls
43
+ // This allows client.getProducts() to map to client.call('getProducts')
44
+ return new Proxy(this, {
45
+ get: (target, prop) => {
46
+ // If the property exists on the instance, return it
47
+ if (prop in target) {
48
+ return target[prop];
49
+ }
50
+ // Otherwise, assume it's an action name and return a wrapper function
51
+ return (params) => target.call(prop, params);
52
+ }
53
+ });
34
54
  }
35
55
  isDebugEnabled() {
36
56
  if (!this.useGlobalDebug) {
@@ -44,7 +64,7 @@ export class CommandFrameClient {
44
64
  if (this.isDebugEnabled()) {
45
65
  console.log("[ActionsClient] Mock Call", { action, params });
46
66
  }
47
- const mockHandler = MOCK_REGISTRY[action];
67
+ const mockHandler = this.mockRegistry[action];
48
68
  if (mockHandler) {
49
69
  // Simulate async delay
50
70
  await new Promise(resolve => setTimeout(resolve, 100));
@@ -111,7 +131,7 @@ export class CommandFrameClient {
111
131
  });
112
132
  }
113
133
  // Private check to determine environment
114
- getFinalContext() {
134
+ detectContext() {
115
135
  return new Promise((resolve) => {
116
136
  if (typeof window === 'undefined' || !window.parent || window.parent === window)
117
137
  return resolve(null);
@@ -49,4 +49,8 @@ export declare const MOCK_OUTLET: CFActiveOutlet;
49
49
  export declare let MOCK_CART: CFActiveCart;
50
50
  export declare const resetMockCart: () => void;
51
51
  export declare const safeSerialize: <T>(data: T) => T;
52
+ type MockEventCallback = (event: any) => void;
53
+ export declare const mockPublishEvent: (topic: string, eventType: string, data: any) => void;
54
+ export declare const mockSubscribeToTopic: (topic: string, callback: MockEventCallback) => void;
52
55
  export declare const createOrderFromCart: (paymentType: string, amount: number | string, processor?: string) => CFActiveOrder;
56
+ export {};
@@ -467,6 +467,30 @@ export const resetMockCart = () => {
467
467
  export const safeSerialize = (data) => {
468
468
  return JSON.parse(JSON.stringify(data));
469
469
  };
470
+ const mockTopicSubscribers = {};
471
+ export const mockPublishEvent = (topic, eventType, data) => {
472
+ const subscribers = mockTopicSubscribers[topic] || [];
473
+ const event = {
474
+ topic,
475
+ type: eventType,
476
+ data,
477
+ timestamp: new Date().toISOString()
478
+ };
479
+ subscribers.forEach(callback => {
480
+ try {
481
+ callback(event);
482
+ }
483
+ catch (error) {
484
+ console.error(`[Mock] Error in topic callback for ${topic}:`, error);
485
+ }
486
+ });
487
+ };
488
+ export const mockSubscribeToTopic = (topic, callback) => {
489
+ if (!mockTopicSubscribers[topic]) {
490
+ mockTopicSubscribers[topic] = [];
491
+ }
492
+ mockTopicSubscribers[topic].push(callback);
493
+ };
470
494
  // Helper to create order from cart
471
495
  export const createOrderFromCart = (paymentType, amount, processor = "cash") => {
472
496
  // Generate new Order ID
@@ -545,5 +569,7 @@ export const createOrderFromCart = (paymentType, amount, processor = "cash") =>
545
569
  };
546
570
  MOCK_ORDERS.push(newOrder);
547
571
  resetMockCart();
572
+ // Publish cart-created event after cart is reset (simulates new empty cart)
573
+ mockPublishEvent('cart', 'cart-created', {});
548
574
  return newOrder;
549
575
  };
package/dist/index.d.ts CHANGED
@@ -18,11 +18,11 @@ export declare const command: {
18
18
  readonly adjustInventory: import("./actions/adjust-inventory/types").AdjustInventory;
19
19
  readonly addOrderNote: import("./actions/add-order-note/types").AddOrderNote;
20
20
  readonly addCartFee: import("./actions/add-cart-fee/types").AddCartFee;
21
+ readonly getCurrentCart: import("./actions/get-current-cart/types").GetCurrentCart;
21
22
  readonly clearCart: import("./actions/clear-cart/types").ClearCart;
22
23
  readonly parkOrder: import("./actions/park-order/types").ParkOrder;
23
24
  readonly resumeParkedOrder: import("./actions/resume-parked-order/types").ResumeParkedOrder;
24
25
  readonly deleteParkedOrder: import("./actions/delete-parked-order/types").DeleteParkedOrder;
25
- readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
26
26
  readonly cashPayment: import("./actions/cash-payment/types").CashPayment;
27
27
  readonly tapToPayPayment: import("./actions/tap-to-pay-payment/types").TapToPayPayment;
28
28
  readonly terminalPayment: import("./actions/terminal-payment/types").TerminalPayment;
@@ -38,13 +38,13 @@ export declare const command: {
38
38
  readonly switchUser: import("./actions/switch-user/types").SwitchUser;
39
39
  readonly triggerWebhook: import("./actions/trigger-webhook/types").TriggerWebhook;
40
40
  readonly triggerZapierWebhook: import("./actions/trigger-zapier-webhook/types").TriggerZapierWebhook;
41
+ readonly initiateRefund: import("./actions/initiate-refund/types").InitiateRefund;
41
42
  readonly setRefundStockAction: import("./actions/set-refund-stock-action/types").SetRefundStockAction;
42
43
  readonly selectAllRefundItems: import("./actions/select-all-refund-items/types").SelectAllRefundItems;
43
44
  readonly resetRefundDetails: import("./actions/reset-refund-details/types").ResetRefundDetails;
44
45
  readonly calculateRefundTotal: import("./actions/calculate-refund-total/types").CalculateRefundTotal;
45
46
  readonly getRemainingRefundableQuantities: import("./actions/get-remaining-refundable-quantities/types").GetRemainingRefundableQuantities;
46
47
  readonly processPartialRefund: import("./actions/process-partial-refund/types").ProcessPartialRefund;
47
- readonly getCurrentCart: import("./actions/get-current-cart/types").GetCurrentCart;
48
48
  };
49
49
  export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from "./actions/example-function/types";
50
50
  export type { GetProducts, GetProductsParams, GetProductsResponse } from "./actions/get-products/types";
@@ -61,6 +61,7 @@ export type { ResetRefundDetails, ResetRefundDetailsResponse } from "./actions/r
61
61
  export type { CalculateRefundTotal, CalculateRefundTotalParams, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
62
62
  export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
63
63
  export type { ProcessPartialRefund, ProcessPartialRefundParams, ProcessPartialRefundResponse } from "./actions/process-partial-refund/types";
64
+ export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from "./actions/initiate-refund/types";
64
65
  export type { GetCurrentCart, GetCurrentCartResponse } from "./actions/get-current-cart/types";
65
66
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse } from "./actions/add-product-discount/types";
66
67
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
@@ -76,7 +77,6 @@ export type { ClearCart, ClearCartResponse } from "./actions/clear-cart/types";
76
77
  export type { ParkOrder, ParkOrderResponse } from "./actions/park-order/types";
77
78
  export type { ResumeParkedOrder, ResumeParkedOrderParams, ResumeParkedOrderResponse } from "./actions/resume-parked-order/types";
78
79
  export type { DeleteParkedOrder, DeleteParkedOrderParams, DeleteParkedOrderResponse } from "./actions/delete-parked-order/types";
79
- export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from "./actions/initiate-refund/types";
80
80
  export type { CashPayment, CashPaymentParams, CashPaymentResponse } from "./actions/cash-payment/types";
81
81
  export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse } from "./actions/tap-to-pay-payment/types";
82
82
  export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from "./actions/terminal-payment/types";
@@ -93,6 +93,10 @@ export type { SwitchUser, SwitchUserParams, SwitchUserResponse } from "./actions
93
93
  export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
94
94
  export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
95
95
  export * from "./CommonTypes";
96
+ export { CommandFrameProvider } from "./provider";
97
+ export type { ActionHandler, ActionHandlers } from "./provider";
98
+ export * from "./projects/render";
99
+ export * from "./projects/manage";
96
100
  export { commandFrameClient, CommandFrameClient } from "./client";
97
101
  export type { PostMessageRequest, PostMessageResponse } from "./client";
98
102
  export { topics } from "./pubsub/topic";
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ import { assignCustomer } from "./actions/assign-customer/action";
7
7
  import { addCustomer } from "./actions/add-customer/action";
8
8
  import { getCategories } from "./actions/get-categories/action";
9
9
  import { getOrders } from "./actions/get-orders/action";
10
- import { getRefunds } from "./actions/get-refunds/action";
11
10
  import { addCartDiscount } from "./actions/add-cart-discount/action";
12
11
  import { getContext } from "./actions/get-context/action";
13
12
  import { getFinalContext } from "./actions/get-final-context/action";
@@ -20,11 +19,11 @@ import { adjustInventory } from "./actions/adjust-inventory/action";
20
19
  // Order Actions
21
20
  import { addOrderNote } from "./actions/add-order-note/action";
22
21
  import { addCartFee } from "./actions/add-cart-fee/action";
22
+ import { getCurrentCart } from "./actions/get-current-cart/action";
23
23
  import { clearCart } from "./actions/clear-cart/action";
24
24
  import { parkOrder } from "./actions/park-order/action";
25
25
  import { resumeParkedOrder } from "./actions/resume-parked-order/action";
26
26
  import { deleteParkedOrder } from "./actions/delete-parked-order/action";
27
- import { initiateRefund } from "./actions/initiate-refund/action";
28
27
  import { cashPayment } from "./actions/cash-payment/action";
29
28
  import { tapToPayPayment } from "./actions/tap-to-pay-payment/action";
30
29
  import { terminalPayment } from "./actions/terminal-payment/action";
@@ -43,13 +42,15 @@ import { switchUser } from "./actions/switch-user/action";
43
42
  // Integration Actions
44
43
  import { triggerWebhook } from "./actions/trigger-webhook/action";
45
44
  import { triggerZapierWebhook } from "./actions/trigger-zapier-webhook/action";
45
+ // Refund Actions
46
+ import { getRefunds } from "./actions/get-refunds/action";
47
+ import { initiateRefund } from "./actions/initiate-refund/action";
46
48
  import { setRefundStockAction } from "./actions/set-refund-stock-action/action";
47
49
  import { selectAllRefundItems } from "./actions/select-all-refund-items/action";
48
50
  import { resetRefundDetails } from "./actions/reset-refund-details/action";
49
51
  import { calculateRefundTotal } from "./actions/calculate-refund-total/action";
50
52
  import { getRemainingRefundableQuantities } from "./actions/get-remaining-refundable-quantities/action";
51
53
  import { processPartialRefund } from "./actions/process-partial-refund/action";
52
- import { getCurrentCart } from "./actions/get-current-cart/action";
53
54
  // Export actions as command object
54
55
  export const command = {
55
56
  exampleFunction,
@@ -73,11 +74,11 @@ export const command = {
73
74
  // Order Actions
74
75
  addOrderNote,
75
76
  addCartFee,
77
+ getCurrentCart,
76
78
  clearCart,
77
79
  parkOrder,
78
80
  resumeParkedOrder,
79
81
  deleteParkedOrder,
80
- initiateRefund,
81
82
  cashPayment,
82
83
  tapToPayPayment,
83
84
  terminalPayment,
@@ -97,16 +98,22 @@ export const command = {
97
98
  triggerWebhook,
98
99
  triggerZapierWebhook,
99
100
  // Refund Actions
101
+ initiateRefund,
100
102
  setRefundStockAction,
101
103
  selectAllRefundItems,
102
104
  resetRefundDetails,
103
105
  calculateRefundTotal,
104
106
  getRemainingRefundableQuantities,
105
107
  processPartialRefund,
106
- getCurrentCart
107
108
  };
108
109
  // Export Common Types
109
110
  export * from "./CommonTypes";
111
+ // Export Provider
112
+ export { CommandFrameProvider } from "./provider";
113
+ // Export Render Project
114
+ export * from "./projects/render";
115
+ // Export Manage Project
116
+ export * from "./projects/manage";
110
117
  // Export client
111
118
  export { commandFrameClient, CommandFrameClient } from "./client";
112
119
  // Export Pub/Sub
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { ManageProviderActions } from "./types";
3
+ export interface ManageClient extends ManageProviderActions {
4
+ }
5
+ export declare class ManageClient extends CommandFrameClient {
6
+ constructor(options?: {
7
+ timeout?: number;
8
+ origin?: string;
9
+ debug?: boolean;
10
+ mockMode?: boolean;
11
+ });
12
+ }
13
+ export declare const manageClient: ManageClient;
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { MANAGE_MOCKS } from "./mocks";
3
+ export class ManageClient extends CommandFrameClient {
4
+ constructor(options = {}) {
5
+ super({
6
+ ...options,
7
+ mockRegistry: MANAGE_MOCKS
8
+ });
9
+ }
10
+ }
11
+ export const manageClient = new ManageClient({
12
+ debug: typeof window !== "undefined" && window.__POSTMESSAGE_DEBUG__ === true
13
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,2 @@
1
+ import { ManageProviderActions } from "./types";
2
+ export declare const MANAGE_MOCKS: ManageProviderActions;
@@ -0,0 +1,6 @@
1
+ import { mockGetContext } from "../../actions/get-context/mock";
2
+ import { mockGetFinalContext } from "../../actions/get-final-context/mock";
3
+ export const MANAGE_MOCKS = {
4
+ getContext: mockGetContext,
5
+ getFinalContext: mockGetFinalContext
6
+ };
@@ -0,0 +1,8 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ import { ManageProviderActions } from "./types";
3
+ export declare class ManageCommandFrameProvider extends CommandFrameProvider<ManageProviderActions> {
4
+ constructor(actions: ManageProviderActions, options?: {
5
+ origin?: string;
6
+ debug?: boolean;
7
+ });
8
+ }
@@ -0,0 +1,6 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ export class ManageCommandFrameProvider extends CommandFrameProvider {
3
+ constructor(actions, options) {
4
+ super(actions, options);
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { GetContext, GetFinalContext } from "../../index";
2
+ export interface ManageProviderActions {
3
+ getContext: GetContext;
4
+ getFinalContext: GetFinalContext;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { RenderProviderActions } from "./types";
3
+ export interface RenderClient extends RenderProviderActions {
4
+ }
5
+ export declare class RenderClient extends CommandFrameClient {
6
+ constructor(options?: {
7
+ timeout?: number;
8
+ origin?: string;
9
+ debug?: boolean;
10
+ mockMode?: boolean;
11
+ });
12
+ }
13
+ export declare const renderClient: RenderClient;
@@ -0,0 +1,13 @@
1
+ import { CommandFrameClient } from "../../client";
2
+ import { RENDER_MOCKS } from "./mocks";
3
+ export class RenderClient extends CommandFrameClient {
4
+ constructor(options = {}) {
5
+ super({
6
+ ...options,
7
+ mockRegistry: RENDER_MOCKS
8
+ });
9
+ }
10
+ }
11
+ export const renderClient = new RenderClient({
12
+ debug: typeof window !== "undefined" && window.__POSTMESSAGE_DEBUG__ === true
13
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./mocks";
3
+ export * from "./provider";
4
+ export * from "./client";
@@ -0,0 +1,2 @@
1
+ import { RenderProviderActions } from "./types";
2
+ export declare const RENDER_MOCKS: RenderProviderActions;
@@ -0,0 +1,94 @@
1
+ import { mockAddCartDiscount } from "../../actions/add-cart-discount/mock";
2
+ import { mockAddCartFee } from "../../actions/add-cart-fee/mock";
3
+ import { mockAddCustomSale } from "../../actions/add-custom-sale/mock";
4
+ import { mockAddCustomer } from "../../actions/add-customer/mock";
5
+ import { mockAddCustomerNote } from "../../actions/add-customer-note/mock";
6
+ import { mockAddOrderNote } from "../../actions/add-order-note/mock";
7
+ import { mockAddProductDiscount } from "../../actions/add-product-discount/mock";
8
+ import { mockAddProductFee } from "../../actions/add-product-fee/mock";
9
+ import { mockAddProductNote } from "../../actions/add-product-note/mock";
10
+ import { mockAddProductToCart } from "../../actions/add-product-to-cart/mock";
11
+ import { mockAdjustInventory } from "../../actions/adjust-inventory/mock";
12
+ import { mockAssignCustomer } from "../../actions/assign-customer/mock";
13
+ import { mockAuthenticateUser } from "../../actions/authenticate-user/mock";
14
+ import { mockCalculateRefundTotal } from "../../actions/calculate-refund-total/mock";
15
+ import { mockCashPayment } from "../../actions/cash-payment/mock";
16
+ import { mockClearCart } from "../../actions/clear-cart/mock";
17
+ import { mockDeleteParkedOrder } from "../../actions/delete-parked-order/mock";
18
+ import { mockExampleFunction } from "../../actions/example-function/mock";
19
+ import { mockGetCategories } from "../../actions/get-categories/mock";
20
+ import { mockGetContext } from "../../actions/get-context/mock";
21
+ import { mockGetCurrentCart } from "../../actions/get-current-cart/mock";
22
+ import { mockGetCustomers } from "../../actions/get-customers/mock";
23
+ import { mockGetOrders } from "../../actions/get-orders/mock";
24
+ import { mockGetProducts } from "../../actions/get-products/mock";
25
+ import { mockGetRefunds } from "../../actions/get-refunds/mock";
26
+ import { mockGetRemainingRefundableQuantities } from "../../actions/get-remaining-refundable-quantities/mock";
27
+ import { mockGoToStationHome } from "../../actions/go-to-station-home/mock";
28
+ import { mockInitiateRefund } from "../../actions/initiate-refund/mock";
29
+ import { mockOpenCashDrawer } from "../../actions/open-cash-drawer/mock";
30
+ import { mockParkOrder } from "../../actions/park-order/mock";
31
+ import { mockPartialPayment } from "../../actions/partial-payment/mock";
32
+ import { mockProcessPartialRefund } from "../../actions/process-partial-refund/mock";
33
+ import { mockRemoveCustomerFromCart } from "../../actions/remove-customer-from-cart/mock";
34
+ import { mockResetRefundDetails } from "../../actions/reset-refund-details/mock";
35
+ import { mockResumeParkedOrder } from "../../actions/resume-parked-order/mock";
36
+ import { mockSelectAllRefundItems } from "../../actions/select-all-refund-items/mock";
37
+ import { mockSetRefundStockAction } from "../../actions/set-refund-stock-action/mock";
38
+ import { mockShowConfirmation } from "../../actions/show-confirmation/mock";
39
+ import { mockShowNotification } from "../../actions/show-notification/mock";
40
+ import { mockSwitchUser } from "../../actions/switch-user/mock";
41
+ import { mockTapToPayPayment } from "../../actions/tap-to-pay-payment/mock";
42
+ import { mockTerminalPayment } from "../../actions/terminal-payment/mock";
43
+ import { mockTriggerWebhook } from "../../actions/trigger-webhook/mock";
44
+ import { mockTriggerZapierWebhook } from "../../actions/trigger-zapier-webhook/mock";
45
+ import { mockVendaraPayment } from "../../actions/vendara-payment/mock";
46
+ import { mockGetFinalContext } from "../../actions/get-final-context/mock";
47
+ export const RENDER_MOCKS = {
48
+ addCartDiscount: mockAddCartDiscount,
49
+ addCartFee: mockAddCartFee,
50
+ addCustomSale: mockAddCustomSale,
51
+ addCustomer: mockAddCustomer,
52
+ addCustomerNote: mockAddCustomerNote,
53
+ addOrderNote: mockAddOrderNote,
54
+ addProductDiscount: mockAddProductDiscount,
55
+ addProductFee: mockAddProductFee,
56
+ addProductNote: mockAddProductNote,
57
+ addProductToCart: mockAddProductToCart,
58
+ adjustInventory: mockAdjustInventory,
59
+ assignCustomer: mockAssignCustomer,
60
+ authenticateUser: mockAuthenticateUser,
61
+ calculateRefundTotal: mockCalculateRefundTotal,
62
+ cashPayment: mockCashPayment,
63
+ clearCart: mockClearCart,
64
+ deleteParkedOrder: mockDeleteParkedOrder,
65
+ exampleFunction: mockExampleFunction,
66
+ getCategories: mockGetCategories,
67
+ getContext: mockGetContext,
68
+ getCurrentCart: mockGetCurrentCart,
69
+ getCustomers: mockGetCustomers,
70
+ getOrders: mockGetOrders,
71
+ getProducts: mockGetProducts,
72
+ getRefunds: mockGetRefunds,
73
+ getRemainingRefundableQuantities: mockGetRemainingRefundableQuantities,
74
+ goToStationHome: mockGoToStationHome,
75
+ initiateRefund: mockInitiateRefund,
76
+ openCashDrawer: mockOpenCashDrawer,
77
+ parkOrder: mockParkOrder,
78
+ partialPayment: mockPartialPayment,
79
+ processPartialRefund: mockProcessPartialRefund,
80
+ removeCustomerFromCart: mockRemoveCustomerFromCart,
81
+ resetRefundDetails: mockResetRefundDetails,
82
+ resumeParkedOrder: mockResumeParkedOrder,
83
+ selectAllRefundItems: mockSelectAllRefundItems,
84
+ setRefundStockAction: mockSetRefundStockAction,
85
+ showConfirmation: mockShowConfirmation,
86
+ showNotification: mockShowNotification,
87
+ switchUser: mockSwitchUser,
88
+ tapToPayPayment: mockTapToPayPayment,
89
+ terminalPayment: mockTerminalPayment,
90
+ triggerWebhook: mockTriggerWebhook,
91
+ triggerZapierWebhook: mockTriggerZapierWebhook,
92
+ vendaraPayment: mockVendaraPayment,
93
+ getFinalContext: mockGetFinalContext,
94
+ };
@@ -0,0 +1,8 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ import { RenderProviderActions } from "./types";
3
+ export declare class RenderCommandFrameProvider extends CommandFrameProvider<RenderProviderActions> {
4
+ constructor(actions: RenderProviderActions, options?: {
5
+ origin?: string;
6
+ debug?: boolean;
7
+ });
8
+ }
@@ -0,0 +1,6 @@
1
+ import { CommandFrameProvider } from "../../provider";
2
+ export class RenderCommandFrameProvider extends CommandFrameProvider {
3
+ constructor(actions, options) {
4
+ super(actions, options);
5
+ }
6
+ }
@@ -0,0 +1,49 @@
1
+ import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, 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";
2
+ export interface RenderProviderActions {
3
+ exampleFunction: ExampleFunction;
4
+ getProducts: GetProducts;
5
+ addCustomSale: AddCustomSale;
6
+ getCustomers: GetCustomers;
7
+ assignCustomer: AssignCustomer;
8
+ addCustomer: AddCustomer;
9
+ getCategories: GetCategories;
10
+ getOrders: GetOrders;
11
+ getRefunds: GetRefunds;
12
+ addProductDiscount: AddProductDiscount;
13
+ addProductToCart: AddProductToCart;
14
+ addCartDiscount: AddCartDiscount;
15
+ getContext: GetContext;
16
+ getFinalContext: GetFinalContext;
17
+ addProductNote: AddProductNote;
18
+ addProductFee: AddProductFee;
19
+ adjustInventory: AdjustInventory;
20
+ addOrderNote: AddOrderNote;
21
+ addCartFee: AddCartFee;
22
+ clearCart: ClearCart;
23
+ parkOrder: ParkOrder;
24
+ resumeParkedOrder: ResumeParkedOrder;
25
+ deleteParkedOrder: DeleteParkedOrder;
26
+ initiateRefund: InitiateRefund;
27
+ cashPayment: CashPayment;
28
+ tapToPayPayment: TapToPayPayment;
29
+ terminalPayment: TerminalPayment;
30
+ vendaraPayment: VendaraPayment;
31
+ addCustomerNote: AddCustomerNote;
32
+ removeCustomerFromCart: RemoveCustomerFromCart;
33
+ goToStationHome: GoToStationHome;
34
+ openCashDrawer: OpenCashDrawer;
35
+ showNotification: ShowNotification;
36
+ showConfirmation: ShowConfirmation;
37
+ authenticateUser: AuthenticateUser;
38
+ partialPayment: PartialPayment;
39
+ switchUser: SwitchUser;
40
+ triggerWebhook: TriggerWebhook;
41
+ triggerZapierWebhook: TriggerZapierWebhook;
42
+ setRefundStockAction: SetRefundStockAction;
43
+ selectAllRefundItems: SelectAllRefundItems;
44
+ resetRefundDetails: ResetRefundDetails;
45
+ calculateRefundTotal: CalculateRefundTotal;
46
+ getRemainingRefundableQuantities: GetRemainingRefundableQuantities;
47
+ processPartialRefund: ProcessPartialRefund;
48
+ getCurrentCart: GetCurrentCart;
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ export type ActionHandler<TParams = any, TResponse = any> = (params: TParams) => Promise<TResponse> | TResponse;
2
+ export type ActionHandlers = Map<string, ActionHandler>;
3
+ export declare class CommandFrameProvider<TActions extends object = any> {
4
+ private handlers;
5
+ private origin;
6
+ private debug;
7
+ private destroyed;
8
+ private boundHandleMessage;
9
+ constructor(actions?: TActions, options?: {
10
+ origin?: string;
11
+ debug?: boolean;
12
+ });
13
+ register<TParams = any, TResponse = any>(action: string, handler: ActionHandler<TParams, TResponse>): void;
14
+ unregister(action: string): void;
15
+ private handleMessage;
16
+ private sendResponse;
17
+ destroy(): void;
18
+ isDestroyed(): boolean;
19
+ }