@final-commerce/command-frame 0.0.1

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 (217) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +418 -0
  3. package/dist/actions/add-cart-discount/action.d.ts +6 -0
  4. package/dist/actions/add-cart-discount/action.js +8 -0
  5. package/dist/actions/add-cart-discount/types.d.ts +13 -0
  6. package/dist/actions/add-cart-discount/types.js +1 -0
  7. package/dist/actions/add-cart-fee/action.d.ts +6 -0
  8. package/dist/actions/add-cart-fee/action.js +8 -0
  9. package/dist/actions/add-cart-fee/types.d.ts +16 -0
  10. package/dist/actions/add-cart-fee/types.js +1 -0
  11. package/dist/actions/add-custom-sale/action.d.ts +6 -0
  12. package/dist/actions/add-custom-sale/action.js +8 -0
  13. package/dist/actions/add-custom-sale/types.d.ts +13 -0
  14. package/dist/actions/add-custom-sale/types.js +1 -0
  15. package/dist/actions/add-customer/action.d.ts +6 -0
  16. package/dist/actions/add-customer/action.js +8 -0
  17. package/dist/actions/add-customer/types.d.ts +9 -0
  18. package/dist/actions/add-customer/types.js +1 -0
  19. package/dist/actions/add-customer-note/action.d.ts +6 -0
  20. package/dist/actions/add-customer-note/action.js +8 -0
  21. package/dist/actions/add-customer-note/types.d.ts +11 -0
  22. package/dist/actions/add-customer-note/types.js +1 -0
  23. package/dist/actions/add-order-note/action.d.ts +6 -0
  24. package/dist/actions/add-order-note/action.js +8 -0
  25. package/dist/actions/add-order-note/types.d.ts +9 -0
  26. package/dist/actions/add-order-note/types.js +1 -0
  27. package/dist/actions/add-product-discount/action.d.ts +6 -0
  28. package/dist/actions/add-product-discount/action.js +8 -0
  29. package/dist/actions/add-product-discount/types.d.ts +13 -0
  30. package/dist/actions/add-product-discount/types.js +1 -0
  31. package/dist/actions/add-product-fee/action.d.ts +6 -0
  32. package/dist/actions/add-product-fee/action.js +8 -0
  33. package/dist/actions/add-product-fee/types.d.ts +16 -0
  34. package/dist/actions/add-product-fee/types.js +1 -0
  35. package/dist/actions/add-product-note/action.d.ts +6 -0
  36. package/dist/actions/add-product-note/action.js +8 -0
  37. package/dist/actions/add-product-note/types.d.ts +9 -0
  38. package/dist/actions/add-product-note/types.js +1 -0
  39. package/dist/actions/add-product-to-cart/action.d.ts +6 -0
  40. package/dist/actions/add-product-to-cart/action.js +8 -0
  41. package/dist/actions/add-product-to-cart/types.d.ts +12 -0
  42. package/dist/actions/add-product-to-cart/types.js +1 -0
  43. package/dist/actions/adjust-inventory/action.d.ts +6 -0
  44. package/dist/actions/adjust-inventory/action.js +8 -0
  45. package/dist/actions/adjust-inventory/types.d.ts +12 -0
  46. package/dist/actions/adjust-inventory/types.js +1 -0
  47. package/dist/actions/assign-customer/action.d.ts +6 -0
  48. package/dist/actions/assign-customer/action.js +8 -0
  49. package/dist/actions/assign-customer/types.d.ts +9 -0
  50. package/dist/actions/assign-customer/types.js +1 -0
  51. package/dist/actions/authenticate-user/action.d.ts +6 -0
  52. package/dist/actions/authenticate-user/action.js +8 -0
  53. package/dist/actions/authenticate-user/types.d.ts +9 -0
  54. package/dist/actions/authenticate-user/types.js +1 -0
  55. package/dist/actions/calculate-refund-total/action.d.ts +6 -0
  56. package/dist/actions/calculate-refund-total/action.js +8 -0
  57. package/dist/actions/calculate-refund-total/types.d.ts +12 -0
  58. package/dist/actions/calculate-refund-total/types.js +1 -0
  59. package/dist/actions/cash-payment/action.d.ts +6 -0
  60. package/dist/actions/cash-payment/action.js +8 -0
  61. package/dist/actions/cash-payment/types.d.ts +13 -0
  62. package/dist/actions/cash-payment/types.js +1 -0
  63. package/dist/actions/clear-cart/action.d.ts +6 -0
  64. package/dist/actions/clear-cart/action.js +8 -0
  65. package/dist/actions/clear-cart/types.d.ts +5 -0
  66. package/dist/actions/clear-cart/types.js +1 -0
  67. package/dist/actions/delete-parked-order/action.d.ts +6 -0
  68. package/dist/actions/delete-parked-order/action.js +8 -0
  69. package/dist/actions/delete-parked-order/types.d.ts +9 -0
  70. package/dist/actions/delete-parked-order/types.js +1 -0
  71. package/dist/actions/example-function/action.d.ts +6 -0
  72. package/dist/actions/example-function/action.js +8 -0
  73. package/dist/actions/example-function/types.d.ts +16 -0
  74. package/dist/actions/example-function/types.js +1 -0
  75. package/dist/actions/get-categories/action.d.ts +6 -0
  76. package/dist/actions/get-categories/action.js +8 -0
  77. package/dist/actions/get-categories/types.d.ts +16 -0
  78. package/dist/actions/get-categories/types.js +1 -0
  79. package/dist/actions/get-context/action.d.ts +6 -0
  80. package/dist/actions/get-context/action.js +8 -0
  81. package/dist/actions/get-context/types.d.ts +17 -0
  82. package/dist/actions/get-context/types.js +1 -0
  83. package/dist/actions/get-current-cart/action.d.ts +6 -0
  84. package/dist/actions/get-current-cart/action.js +8 -0
  85. package/dist/actions/get-current-cart/types.d.ts +6 -0
  86. package/dist/actions/get-current-cart/types.js +1 -0
  87. package/dist/actions/get-customers/action.d.ts +6 -0
  88. package/dist/actions/get-customers/action.js +8 -0
  89. package/dist/actions/get-customers/types.d.ts +31 -0
  90. package/dist/actions/get-customers/types.js +1 -0
  91. package/dist/actions/get-line-items-by-order/action.d.ts +6 -0
  92. package/dist/actions/get-line-items-by-order/action.js +8 -0
  93. package/dist/actions/get-line-items-by-order/types.d.ts +13 -0
  94. package/dist/actions/get-line-items-by-order/types.js +1 -0
  95. package/dist/actions/get-orders/action.d.ts +6 -0
  96. package/dist/actions/get-orders/action.js +8 -0
  97. package/dist/actions/get-orders/types.d.ts +17 -0
  98. package/dist/actions/get-orders/types.js +1 -0
  99. package/dist/actions/get-product-variants/action.d.ts +6 -0
  100. package/dist/actions/get-product-variants/action.js +8 -0
  101. package/dist/actions/get-product-variants/types.d.ts +9 -0
  102. package/dist/actions/get-product-variants/types.js +1 -0
  103. package/dist/actions/get-products/action.d.ts +6 -0
  104. package/dist/actions/get-products/action.js +8 -0
  105. package/dist/actions/get-products/types.d.ts +28 -0
  106. package/dist/actions/get-products/types.js +1 -0
  107. package/dist/actions/get-refunds/action.d.ts +6 -0
  108. package/dist/actions/get-refunds/action.js +8 -0
  109. package/dist/actions/get-refunds/types.d.ts +16 -0
  110. package/dist/actions/get-refunds/types.js +1 -0
  111. package/dist/actions/get-remaining-refundable-quantities/action.d.ts +6 -0
  112. package/dist/actions/get-remaining-refundable-quantities/action.js +8 -0
  113. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +7 -0
  114. package/dist/actions/get-remaining-refundable-quantities/types.js +1 -0
  115. package/dist/actions/go-to-page/action.d.ts +6 -0
  116. package/dist/actions/go-to-page/action.js +8 -0
  117. package/dist/actions/go-to-page/types.d.ts +9 -0
  118. package/dist/actions/go-to-page/types.js +1 -0
  119. package/dist/actions/go-to-station-home/action.d.ts +6 -0
  120. package/dist/actions/go-to-station-home/action.js +8 -0
  121. package/dist/actions/go-to-station-home/types.d.ts +5 -0
  122. package/dist/actions/go-to-station-home/types.js +1 -0
  123. package/dist/actions/initiate-refund/action.d.ts +6 -0
  124. package/dist/actions/initiate-refund/action.js +8 -0
  125. package/dist/actions/initiate-refund/types.d.ts +9 -0
  126. package/dist/actions/initiate-refund/types.js +1 -0
  127. package/dist/actions/open-cash-drawer/action.d.ts +6 -0
  128. package/dist/actions/open-cash-drawer/action.js +8 -0
  129. package/dist/actions/open-cash-drawer/types.d.ts +5 -0
  130. package/dist/actions/open-cash-drawer/types.js +1 -0
  131. package/dist/actions/open-popup/action.d.ts +6 -0
  132. package/dist/actions/open-popup/action.js +8 -0
  133. package/dist/actions/open-popup/types.d.ts +9 -0
  134. package/dist/actions/open-popup/types.js +1 -0
  135. package/dist/actions/park-order/action.d.ts +6 -0
  136. package/dist/actions/park-order/action.js +8 -0
  137. package/dist/actions/park-order/types.d.ts +6 -0
  138. package/dist/actions/park-order/types.js +1 -0
  139. package/dist/actions/partial-payment/action.d.ts +6 -0
  140. package/dist/actions/partial-payment/action.js +8 -0
  141. package/dist/actions/partial-payment/types.d.ts +14 -0
  142. package/dist/actions/partial-payment/types.js +1 -0
  143. package/dist/actions/process-partial-refund/action.d.ts +6 -0
  144. package/dist/actions/process-partial-refund/action.js +8 -0
  145. package/dist/actions/process-partial-refund/types.d.ts +9 -0
  146. package/dist/actions/process-partial-refund/types.js +1 -0
  147. package/dist/actions/remove-customer-from-cart/action.d.ts +6 -0
  148. package/dist/actions/remove-customer-from-cart/action.js +8 -0
  149. package/dist/actions/remove-customer-from-cart/types.d.ts +5 -0
  150. package/dist/actions/remove-customer-from-cart/types.js +1 -0
  151. package/dist/actions/reset-refund-details/action.d.ts +6 -0
  152. package/dist/actions/reset-refund-details/action.js +8 -0
  153. package/dist/actions/reset-refund-details/types.d.ts +5 -0
  154. package/dist/actions/reset-refund-details/types.js +1 -0
  155. package/dist/actions/resume-parked-order/action.d.ts +6 -0
  156. package/dist/actions/resume-parked-order/action.js +8 -0
  157. package/dist/actions/resume-parked-order/types.d.ts +9 -0
  158. package/dist/actions/resume-parked-order/types.js +1 -0
  159. package/dist/actions/select-all-refund-items/action.d.ts +6 -0
  160. package/dist/actions/select-all-refund-items/action.js +8 -0
  161. package/dist/actions/select-all-refund-items/types.d.ts +6 -0
  162. package/dist/actions/select-all-refund-items/types.js +1 -0
  163. package/dist/actions/set-product-active/action.d.ts +6 -0
  164. package/dist/actions/set-product-active/action.js +8 -0
  165. package/dist/actions/set-product-active/types.d.ts +9 -0
  166. package/dist/actions/set-product-active/types.js +1 -0
  167. package/dist/actions/set-refund-stock-action/action.d.ts +6 -0
  168. package/dist/actions/set-refund-stock-action/action.js +8 -0
  169. package/dist/actions/set-refund-stock-action/types.d.ts +11 -0
  170. package/dist/actions/set-refund-stock-action/types.js +1 -0
  171. package/dist/actions/show-confirmation/action.d.ts +6 -0
  172. package/dist/actions/show-confirmation/action.js +8 -0
  173. package/dist/actions/show-confirmation/types.d.ts +9 -0
  174. package/dist/actions/show-confirmation/types.js +1 -0
  175. package/dist/actions/show-notification/action.d.ts +6 -0
  176. package/dist/actions/show-notification/action.js +8 -0
  177. package/dist/actions/show-notification/types.d.ts +9 -0
  178. package/dist/actions/show-notification/types.js +1 -0
  179. package/dist/actions/switch-user/action.d.ts +6 -0
  180. package/dist/actions/switch-user/action.js +8 -0
  181. package/dist/actions/switch-user/types.d.ts +13 -0
  182. package/dist/actions/switch-user/types.js +1 -0
  183. package/dist/actions/tap-to-pay-payment/action.d.ts +6 -0
  184. package/dist/actions/tap-to-pay-payment/action.js +8 -0
  185. package/dist/actions/tap-to-pay-payment/types.d.ts +11 -0
  186. package/dist/actions/tap-to-pay-payment/types.js +1 -0
  187. package/dist/actions/terminal-payment/action.d.ts +6 -0
  188. package/dist/actions/terminal-payment/action.js +8 -0
  189. package/dist/actions/terminal-payment/types.d.ts +11 -0
  190. package/dist/actions/terminal-payment/types.js +1 -0
  191. package/dist/actions/toggle-slide-out/action.d.ts +6 -0
  192. package/dist/actions/toggle-slide-out/action.js +8 -0
  193. package/dist/actions/toggle-slide-out/types.d.ts +9 -0
  194. package/dist/actions/toggle-slide-out/types.js +1 -0
  195. package/dist/actions/trigger-webhook/action.d.ts +6 -0
  196. package/dist/actions/trigger-webhook/action.js +8 -0
  197. package/dist/actions/trigger-webhook/types.d.ts +16 -0
  198. package/dist/actions/trigger-webhook/types.js +1 -0
  199. package/dist/actions/trigger-zapier-webhook/action.d.ts +6 -0
  200. package/dist/actions/trigger-zapier-webhook/action.js +8 -0
  201. package/dist/actions/trigger-zapier-webhook/types.d.ts +9 -0
  202. package/dist/actions/trigger-zapier-webhook/types.js +1 -0
  203. package/dist/actions/update-customer-facing-display/action.d.ts +6 -0
  204. package/dist/actions/update-customer-facing-display/action.js +8 -0
  205. package/dist/actions/update-customer-facing-display/types.d.ts +9 -0
  206. package/dist/actions/update-customer-facing-display/types.js +1 -0
  207. package/dist/actions/vendara-payment/action.d.ts +6 -0
  208. package/dist/actions/vendara-payment/action.js +8 -0
  209. package/dist/actions/vendara-payment/types.d.ts +11 -0
  210. package/dist/actions/vendara-payment/types.js +1 -0
  211. package/dist/client.d.ts +33 -0
  212. package/dist/client.js +145 -0
  213. package/dist/index.d.ts +108 -0
  214. package/dist/index.js +121 -0
  215. package/dist/types.d.ts +64 -0
  216. package/dist/types.js +1 -0
  217. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Final Commerce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,418 @@
1
+ # @final-commerce/command-frame
2
+
3
+ A TypeScript library for communication between iframes and their parent windows using postMessage with type safety and error handling.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @final-commerce/command-frame
9
+ ```
10
+
11
+ This package is available on the public NPM registry.
12
+
13
+ ## Table of Contents
14
+
15
+ - [API Overview](#api-overview)
16
+ - [Quick Start](#quick-start)
17
+ - [Actions Documentation](#actions-documentation)
18
+ - [Examples](#examples)
19
+ - [Debugging](#debugging)
20
+ - [Type Safety](#type-safety)
21
+ - [License](#license)
22
+
23
+ ## API Overview
24
+
25
+ The library provides a `command` namespace object containing all available actions. Each action is a typed function that communicates with the parent window via postMessage.
26
+
27
+ ### Available Actions
28
+
29
+ #### Data Retrieval
30
+ - **[getCustomers](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-customers/README.md)** - Retrieve a list of customers from the parent application
31
+ - **[getProducts](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-products/README.md)** - Retrieve a list of products from the parent application
32
+ - **[getCategories](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-categories/README.md)** - Retrieve a list of categories from the parent application
33
+ - **[getProductVariants](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-product-variants/README.md)** - Retrieve all variants for a specific product
34
+ - **[getContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-context/README.md)** - Get current environment/context information (user, company, device, station, outlet, build)
35
+
36
+ #### Product Actions
37
+ - **[setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)** - Set a product variant as the active product
38
+ - **[addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)** - Add a discount to the currently active product
39
+ - **[addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)** - Add the currently active product to the cart
40
+ - **[addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)** - Add a note to the currently active product
41
+ - **[addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)** - Add a fee to the currently active product
42
+ - **[adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)** - Adjust inventory/stock level for the currently active product
43
+
44
+ #### Order Actions
45
+ - **[addCustomSale](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-custom-sale/README.md)** - Add a custom sale item to the cart
46
+ - **[addCartDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-discount/README.md)** - Add a discount to the entire cart
47
+ - **[addOrderNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-order-note/README.md)** - Add a note to the current order/cart
48
+ - **[addCartFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-fee/README.md)** - Add a fee to the entire cart
49
+ - **[clearCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/clear-cart/README.md)** - Clear all items from the current cart
50
+ - **[parkOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/park-order/README.md)** - Park (save) the current order for later retrieval
51
+ - **[resumeParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/resume-parked-order/README.md)** - Resume a previously parked order
52
+ - **[deleteParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/delete-parked-order/README.md)** - Delete a parked order
53
+ - **[reorderActiveOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reorder-active-order/README.md)** - Reorder items from the currently active order into the cart
54
+ - **[initiateRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/initiate-refund/README.md)** - Open the refund UI for an order
55
+ - **[cashPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/cash-payment/README.md)** - Initiate a cash payment
56
+ - **[tapToPayPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/tap-to-pay-payment/README.md)** - Initiate a tap-to-pay payment
57
+ - **[terminalPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/terminal-payment/README.md)** - Initiate a terminal payment
58
+ - **[vendaraPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/vendara-payment/README.md)** - Initiate a Vendara payment
59
+ - **[partialPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/partial-payment/README.md)** - Initiate a partial/split payment
60
+
61
+ #### Customer Actions
62
+ - **[addCustomer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-customer/README.md)** - Add a new customer to the local database
63
+ - **[assignCustomer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/assign-customer/README.md)** - Assign an existing customer to the current session/cart
64
+ - **[addCustomerNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-customer-note/README.md)** - Add a note to a customer's record
65
+ - **[removeCustomerFromCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/remove-customer-from-cart/README.md)** - Remove the currently assigned customer from the cart
66
+
67
+ #### System Actions
68
+ - **[goToStationHome](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/go-to-station-home/README.md)** - Navigate to the station home page
69
+ - **[goToPage](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/go-to-page/README.md)** - Navigate to a specific page
70
+ - **[openCashDrawer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/open-cash-drawer/README.md)** - Open the cash drawer
71
+ - **[openPopup](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/open-popup/README.md)** - Open a popup/modal by ID
72
+ - **[showNotification](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/show-notification/README.md)** - Show a notification message
73
+ - **[toggleSlideOut](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/toggle-slide-out/README.md)** - Toggle a slide-out panel
74
+ - **[showConfirmation](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/show-confirmation/README.md)** - Show a confirmation dialog
75
+ - **[authenticateUser](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/authenticate-user/README.md)** - Trigger user authentication for specific roles
76
+ - **[updateCustomerFacingDisplay](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/update-customer-facing-display/README.md)** - Update the customer-facing display to show a specific page
77
+ - **[switchUser](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/switch-user/README.md)** - Switch the current user to a different user
78
+
79
+ #### Integration Actions
80
+ - **[triggerWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-webhook/README.md)** - Trigger a webhook with the specified configuration
81
+ - **[triggerZapierWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-zapier-webhook/README.md)** - Trigger a Zapier webhook with the current context data
82
+
83
+ #### Reference
84
+ - **[exampleFunction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/example-function/README.md)** - Example/template function (for reference only)
85
+
86
+ For detailed documentation on each action, including parameter descriptions, response structures, and usage examples, see the [Actions Documentation](#actions-documentation) section below.
87
+
88
+ ## Quick Start
89
+
90
+ ```typescript
91
+ import { command } from '@final-commerce/command-frame';
92
+
93
+ // Get products from parent window
94
+ const products = await command.getProducts();
95
+
96
+ // Get customers from parent window
97
+ const customers = await command.getCustomers();
98
+
99
+ // Get categories from parent window
100
+ const categories = await command.getCategories();
101
+
102
+ // Get variants for a product
103
+ const variants = await command.getProductVariants({
104
+ productId: '691df9c6c478bada1fb23d31'
105
+ });
106
+
107
+ // Set a variant as active, add discount, then add to cart
108
+ await command.setProductActive({
109
+ variantId: '691df9c6c478bada1fb23d55'
110
+ });
111
+
112
+ await command.addProductDiscount({
113
+ amount: 10,
114
+ isPercent: false,
115
+ label: 'Discount'
116
+ });
117
+
118
+ await command.addProductToCart({
119
+ quantity: 1
120
+ });
121
+
122
+ // Add cart discount
123
+ await command.addCartDiscount({
124
+ amount: 10,
125
+ isPercent: false,
126
+ label: 'Cart Discount'
127
+ });
128
+
129
+ // Get current context/environment
130
+ const context = await command.getContext();
131
+ console.log('Current user:', context.userId);
132
+ console.log('Current company:', context.companyName);
133
+ console.log('Current build:', context.buildName);
134
+ ```
135
+
136
+ For complete usage examples and detailed parameter descriptions, see the documentation for each action in the [Actions Documentation](#actions-documentation) section.
137
+
138
+ ## Actions Documentation
139
+
140
+ Each action has detailed documentation with complete parameter descriptions, response structures, and multiple usage examples:
141
+
142
+ ### [getCustomers](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-customers/README.md)
143
+
144
+ Retrieves a list of customers from the parent application's local database. Supports MongoDB query syntax for filtering, text search across name/email/phone fields, and pagination.
145
+
146
+ ### [getProducts](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-products/README.md)
147
+
148
+ Retrieves a list of products from the parent application's local database. Supports filtering by name, SKU, status, product type, categories, tags, and more.
149
+
150
+ ### [addCustomer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-customer/README.md)
151
+
152
+ Adds a new customer to the local database in the parent application. Supports full customer structure including addresses, metadata, notes, and tags.
153
+
154
+ ### [assignCustomer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/assign-customer/README.md)
155
+
156
+ Assigns an existing customer to the current active session/cart. The customer must exist in the local database.
157
+
158
+ ### [getCategories](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-categories/README.md)
159
+
160
+ Retrieves a list of categories from the parent application's local database. Supports filtering by name, parent ID, and external ID.
161
+
162
+ ### [getProductVariants](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-product-variants/README.md)
163
+
164
+ Retrieves all variants for a specific product from the parent application's local database. Useful for displaying variant options or selecting a specific variant.
165
+
166
+ ### [addCustomSale](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-custom-sale/README.md)
167
+
168
+ Adds a custom sale item to the cart in the parent window. Useful for adding non-product items like service fees, discounts, or custom charges.
169
+
170
+ ### [setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)
171
+
172
+ Sets a product variant as the active product in the parent application. Required before adding discounts or adding products to cart.
173
+
174
+ ### [addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)
175
+
176
+ Adds a discount to the currently active product. Supports both fixed amount and percentage discounts. The product must be set as active first.
177
+
178
+ ### [addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)
179
+
180
+ Adds the currently active product to the cart. Supports specifying quantity. The product must be set as active first.
181
+
182
+ ### [addCartDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-discount/README.md)
183
+
184
+ Adds a discount to the entire cart. Supports both fixed amount and percentage discounts. Applies to the cart subtotal and affects all items.
185
+
186
+ ### [getContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-context/README.md)
187
+
188
+ Retrieves the current environment/context information from the parent application. Returns user, company, device, station, outlet, and build information including IDs, names, and other relevant details.
189
+
190
+ ### Product Actions
191
+
192
+ ### [addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)
193
+
194
+ Adds a note to the currently active product in the cart. Requires a product to be set as active first.
195
+
196
+ ### [addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)
197
+
198
+ Adds a fee to the currently active product. Supports both fixed amount and percentage-based fees. Requires a product to be set as active first.
199
+
200
+ ### [adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)
201
+
202
+ Adjusts the inventory/stock level for the currently active product. Supports adding, subtracting, or setting stock to a specific value.
203
+
204
+ ### Order Actions
205
+
206
+ ### [addOrderNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-order-note/README.md)
207
+
208
+ Adds a note to the current order/cart.
209
+
210
+ ### [addCartFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-fee/README.md)
211
+
212
+ Adds a fee to the entire cart. Supports both fixed amount and percentage-based fees.
213
+
214
+ ### [clearCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/clear-cart/README.md)
215
+
216
+ Clears all items from the current cart and resets cart-related state.
217
+
218
+ ### [parkOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/park-order/README.md)
219
+
220
+ Parks (saves) the current order for later retrieval. The cart is cleared after parking.
221
+
222
+ ### [resumeParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/resume-parked-order/README.md)
223
+
224
+ Resumes a previously parked order by loading it back into the cart.
225
+
226
+ ### [deleteParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/delete-parked-order/README.md)
227
+
228
+ Deletes a parked order from the system.
229
+
230
+ ### [reorderActiveOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reorder-active-order/README.md)
231
+
232
+ Reorders the items from the currently active order into the cart. Products that are out of stock will not be added.
233
+
234
+ ### [initiateRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/initiate-refund/README.md)
235
+
236
+ Opens the refund UI for the specified order or the currently active order.
237
+
238
+ ### [cashPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/cash-payment/README.md)
239
+
240
+ Initiates a cash payment for the current cart. Opens the cash payment UI if change calculation is enabled.
241
+
242
+ ### [tapToPayPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/tap-to-pay-payment/README.md)
243
+
244
+ Initiates a tap-to-pay payment for the current cart. May request tip if tip functionality is enabled.
245
+
246
+ ### [terminalPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/terminal-payment/README.md)
247
+
248
+ Initiates a terminal payment for the current cart. May request tip if tip functionality is enabled.
249
+
250
+ ### [vendaraPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/vendara-payment/README.md)
251
+
252
+ Initiates a Vendara payment for the current cart. May request tip if tip functionality is enabled.
253
+
254
+ ### [partialPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/partial-payment/README.md)
255
+
256
+ Initiates a partial/split payment for the current cart. Can open the split payment UI or process a payment with a specified amount.
257
+
258
+ ### Customer Actions
259
+
260
+ ### [addCustomerNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-customer-note/README.md)
261
+
262
+ Adds a note to a customer's record. Requires the customer ID.
263
+
264
+ ### [removeCustomerFromCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/remove-customer-from-cart/README.md)
265
+
266
+ Removes the currently assigned customer from the cart.
267
+
268
+ ### System Actions
269
+
270
+ ### [goToStationHome](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/go-to-station-home/README.md)
271
+
272
+ Navigates to the station home page.
273
+
274
+ ### [goToPage](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/go-to-page/README.md)
275
+
276
+ Navigates to a specific page in the application by page ID.
277
+
278
+ ### [openCashDrawer](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/open-cash-drawer/README.md)
279
+
280
+ Opens the cash drawer (if connected to a compatible device).
281
+
282
+ ### [openPopup](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/open-popup/README.md)
283
+
284
+ Opens a popup/modal by ID. If the popup is already open, calling this will close it (toggle behavior).
285
+
286
+ ### [showNotification](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/show-notification/README.md)
287
+
288
+ Shows a notification message to the user.
289
+
290
+ ### [toggleSlideOut](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/toggle-slide-out/README.md)
291
+
292
+ Toggles (opens/closes) a slide-out panel by ID.
293
+
294
+ ### [showConfirmation](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/show-confirmation/README.md)
295
+
296
+ Shows a confirmation dialog to the user. The actual promise resolution (accept/decline) is handled by the parent application's handler system.
297
+
298
+ ### [authenticateUser](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/authenticate-user/README.md)
299
+
300
+ Triggers user authentication for specific roles. Shows an authentication dialog in the parent application.
301
+
302
+ ### [updateCustomerFacingDisplay](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/update-customer-facing-display/README.md)
303
+
304
+ Updates the customer-facing display to show a specific page by page ID.
305
+
306
+ ### [switchUser](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/switch-user/README.md)
307
+
308
+ Switches the current user to a different user. Supports three modes: dialog (select from all users), role (select from users with specific roles), or specific (switch to a specific user).
309
+
310
+ ### Integration Actions
311
+
312
+ ### [triggerWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-webhook/README.md)
313
+
314
+ Triggers a webhook with the specified configuration. Supports custom data, authentication, and various payload types.
315
+
316
+ ### [triggerZapierWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-zapier-webhook/README.md)
317
+
318
+ Triggers a Zapier webhook with the current context data (cart, customer, order, etc.).
319
+
320
+ ### Reference
321
+
322
+ ### [exampleFunction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/example-function/README.md)
323
+
324
+ An example/template function for reference. See the documentation for the structure to follow when creating new actions.
325
+
326
+ ## Examples
327
+
328
+ See the [example/](https://github.com/Final-Commerce/command-frame/tree/main/example) folder for a working React + Vite demo application that demonstrates how to use this library in a real-world scenario.
329
+
330
+ To run the example:
331
+
332
+ ```bash
333
+ cd example
334
+ npm install
335
+ npm run dev
336
+ ```
337
+
338
+ ## Debugging
339
+
340
+ Enable debug logging by setting the debug flag before importing:
341
+
342
+ ```typescript
343
+ (window as any).__POSTMESSAGE_DEBUG__ = true;
344
+ import { command } from '@final-commerce/command-frame';
345
+ ```
346
+
347
+ This will log all postMessage communication to the console, including:
348
+ - Request details (action name, parameters, request ID)
349
+ - Response details (success status, data, errors)
350
+ - Timing information
351
+ - Origin validation
352
+
353
+ ## Type Safety
354
+
355
+ All actions are fully typed with TypeScript. Import types for use in your code:
356
+
357
+ ```typescript
358
+ import type {
359
+ // Data Retrieval
360
+ GetCustomersParams, GetCustomersResponse, GetCustomers,
361
+ GetProductsParams, GetProductsResponse, GetProducts,
362
+ GetCategoriesParams, GetCategoriesResponse, GetCategories,
363
+ GetProductVariantsParams, GetProductVariantsResponse, GetProductVariants,
364
+ GetContext, GetContextResponse,
365
+ // Product Actions
366
+ SetProductActiveParams, SetProductActiveResponse, SetProductActive,
367
+ AddProductDiscountParams, AddProductDiscountResponse, AddProductDiscount,
368
+ AddProductToCartParams, AddProductToCartResponse, AddProductToCart,
369
+ AddProductNoteParams, AddProductNoteResponse, AddProductNote,
370
+ AddProductFeeParams, AddProductFeeResponse, AddProductFee,
371
+ AdjustInventoryParams, AdjustInventoryResponse, AdjustInventory,
372
+ // Order Actions
373
+ AddCustomSaleParams, AddCustomSaleResponse, AddCustomSale,
374
+ AddCartDiscountParams, AddCartDiscountResponse, AddCartDiscount,
375
+ AddOrderNoteParams, AddOrderNoteResponse, AddOrderNote,
376
+ AddCartFeeParams, AddCartFeeResponse, AddCartFee,
377
+ ClearCartResponse, ClearCart,
378
+ ParkOrderResponse, ParkOrder,
379
+ ResumeParkedOrderParams, ResumeParkedOrderResponse, ResumeParkedOrder,
380
+ DeleteParkedOrderParams, DeleteParkedOrderResponse, DeleteParkedOrder,
381
+ ReorderActiveOrderResponse, ReorderActiveOrder,
382
+ InitiateRefundParams, InitiateRefundResponse, InitiateRefund,
383
+ CashPaymentParams, CashPaymentResponse, CashPayment,
384
+ TapToPayPaymentParams, TapToPayPaymentResponse, TapToPayPayment,
385
+ TerminalPaymentParams, TerminalPaymentResponse, TerminalPayment,
386
+ VendaraPaymentParams, VendaraPaymentResponse, VendaraPayment,
387
+ PartialPaymentParams, PartialPaymentResponse, PartialPayment,
388
+ // Customer Actions
389
+ AddCustomerParams, AddCustomerResponse, AddCustomer,
390
+ AssignCustomerParams, AssignCustomerResponse, AssignCustomer,
391
+ AddCustomerNoteParams, AddCustomerNoteResponse, AddCustomerNote,
392
+ RemoveCustomerFromCartResponse, RemoveCustomerFromCart,
393
+ // System Actions
394
+ GoToStationHomeResponse, GoToStationHome,
395
+ GoToPageParams, GoToPageResponse, GoToPage,
396
+ OpenCashDrawerResponse, OpenCashDrawer,
397
+ OpenPopupParams, OpenPopupResponse, OpenPopup,
398
+ ShowNotificationParams, ShowNotificationResponse, ShowNotification,
399
+ ToggleSlideOutParams, ToggleSlideOutResponse, ToggleSlideOut,
400
+ ShowConfirmationParams, ShowConfirmationResponse, ShowConfirmation,
401
+ AuthenticateUserParams, AuthenticateUserResponse, AuthenticateUser,
402
+ UpdateCustomerFacingDisplayParams, UpdateCustomerFacingDisplayResponse, UpdateCustomerFacingDisplay,
403
+ SwitchUserParams, SwitchUserResponse, SwitchUser,
404
+ // Integration Actions
405
+ TriggerWebhookParams, TriggerWebhookResponse, TriggerWebhook,
406
+ TriggerZapierWebhookParams, TriggerZapierWebhookResponse, TriggerZapierWebhook,
407
+ // Reference
408
+ ExampleFunctionParams, ExampleFunctionResponse, ExampleFunction
409
+ } from '@final-commerce/command-frame';
410
+ ```
411
+
412
+ **Note:** Entity data (customers, products) is returned as `any[]` or `any` to allow flexibility between different database implementations (MongoDB/mongoose vs LokiJS/IndexedDB). For detailed entity structures, refer to the action-specific documentation in the [Actions Documentation](#actions-documentation) section.
413
+
414
+ ## License
415
+
416
+ MIT
417
+
418
+ See [LICENSE](LICENSE) file for details.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add cart discount action
3
+ * Calls the addCartDiscount action on the parent window
4
+ */
5
+ import type { AddCartDiscount } from "./types";
6
+ export declare const addCartDiscount: AddCartDiscount;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add cart discount action
3
+ * Calls the addCartDiscount action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addCartDiscount = async (params) => {
7
+ return await commandFrameClient.call("addCartDiscount", params);
8
+ };
@@ -0,0 +1,13 @@
1
+ export interface AddCartDiscountParams {
2
+ amount: number;
3
+ isPercent?: boolean;
4
+ label?: string;
5
+ }
6
+ export interface AddCartDiscountResponse {
7
+ success: boolean;
8
+ amount: number;
9
+ isPercent: boolean;
10
+ label: string;
11
+ timestamp: string;
12
+ }
13
+ export type AddCartDiscount = (params?: AddCartDiscountParams) => Promise<AddCartDiscountResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add cart fee action
3
+ * Calls the addCartFee action on the parent window
4
+ */
5
+ import type { AddCartFee } from "./types";
6
+ export declare const addCartFee: AddCartFee;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add cart fee action
3
+ * Calls the addCartFee action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addCartFee = async (params) => {
7
+ return await commandFrameClient.call("addCartFee", params);
8
+ };
@@ -0,0 +1,16 @@
1
+ export interface AddCartFeeParams {
2
+ amount: number;
3
+ isPercent?: boolean;
4
+ label?: string;
5
+ applyTaxes?: boolean;
6
+ taxTableId?: string;
7
+ }
8
+ export interface AddCartFeeResponse {
9
+ success: boolean;
10
+ amount: number;
11
+ isPercent: boolean;
12
+ label: string;
13
+ applyTaxes: boolean;
14
+ timestamp: string;
15
+ }
16
+ export type AddCartFee = (params?: AddCartFeeParams) => Promise<AddCartFeeResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add custom sale action
3
+ * Calls the addCustomSale action on the parent window
4
+ */
5
+ import type { AddCustomSale } from "./types";
6
+ export declare const addCustomSale: AddCustomSale;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add custom sale action
3
+ * Calls the addCustomSale action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addCustomSale = async (params) => {
7
+ return await commandFrameClient.call("addCustomSale", params);
8
+ };
@@ -0,0 +1,13 @@
1
+ export interface AddCustomSaleParams {
2
+ label: string;
3
+ price: number | string;
4
+ applyTaxes?: boolean;
5
+ }
6
+ export interface AddCustomSaleResponse {
7
+ success: boolean;
8
+ label: string;
9
+ price: number;
10
+ applyTaxes: boolean;
11
+ timestamp: string;
12
+ }
13
+ export type AddCustomSale = (params?: AddCustomSaleParams) => Promise<AddCustomSaleResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add customer action
3
+ * Calls the addCustomer action on the parent window
4
+ */
5
+ import type { AddCustomer } from "./types";
6
+ export declare const addCustomer: AddCustomer;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add customer action
3
+ * Calls the addCustomer action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addCustomer = async (params) => {
7
+ return await commandFrameClient.call("addCustomer", params);
8
+ };
@@ -0,0 +1,9 @@
1
+ export interface AddCustomerParams {
2
+ customer: Record<string, any>;
3
+ }
4
+ export interface AddCustomerResponse {
5
+ success: boolean;
6
+ customer: any;
7
+ timestamp: string;
8
+ }
9
+ export type AddCustomer = (params: AddCustomerParams) => Promise<AddCustomerResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add customer note action
3
+ * Calls the addCustomerNote action on the parent window
4
+ */
5
+ import type { AddCustomerNote } from "./types";
6
+ export declare const addCustomerNote: AddCustomerNote;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add customer note action
3
+ * Calls the addCustomerNote action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addCustomerNote = async (params) => {
7
+ return await commandFrameClient.call("addCustomerNote", params);
8
+ };
@@ -0,0 +1,11 @@
1
+ export interface AddCustomerNoteParams {
2
+ customerId: string;
3
+ note: string;
4
+ }
5
+ export interface AddCustomerNoteResponse {
6
+ success: boolean;
7
+ customerId: string;
8
+ note: string;
9
+ timestamp: string;
10
+ }
11
+ export type AddCustomerNote = (params?: AddCustomerNoteParams) => Promise<AddCustomerNoteResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Add order note action
3
+ * Calls the addOrderNote action on the parent window
4
+ */
5
+ import type { AddOrderNote } from "./types";
6
+ export declare const addOrderNote: AddOrderNote;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Add order note action
3
+ * Calls the addOrderNote action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const addOrderNote = async (params) => {
7
+ return await commandFrameClient.call("addOrderNote", params);
8
+ };
@@ -0,0 +1,9 @@
1
+ export interface AddOrderNoteParams {
2
+ note: string;
3
+ }
4
+ export interface AddOrderNoteResponse {
5
+ success: boolean;
6
+ note: string;
7
+ timestamp: string;
8
+ }
9
+ export type AddOrderNote = (params?: AddOrderNoteParams) => Promise<AddOrderNoteResponse>;
@@ -0,0 +1 @@
1
+ export {};