@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.
Files changed (151) hide show
  1. package/README.md +28 -26
  2. package/dist/CommonTypes.d.ts +79 -534
  3. package/dist/CommonTypes.js +5 -65
  4. package/dist/actions/add-customer-note/mock.js +24 -15
  5. package/dist/actions/add-customer-note/types.d.ts +3 -2
  6. package/dist/actions/add-product/mock.js +12 -6
  7. package/dist/actions/add-product-discount/mock.js +5 -5
  8. package/dist/actions/add-product-fee/mock.js +6 -6
  9. package/dist/actions/cash-payment/types.d.ts +0 -5
  10. package/dist/actions/delete-parked-order/types.d.ts +0 -3
  11. package/dist/actions/edit-product/mock.js +5 -3
  12. package/dist/actions/extension-payment/types.d.ts +4 -5
  13. package/dist/actions/get-context/mock.js +12 -6
  14. package/dist/actions/get-products/mock.js +3 -3
  15. package/dist/actions/get-roles/mock.js +35 -41
  16. package/dist/actions/get-smart-grid-layout/action.d.ts +2 -0
  17. package/dist/actions/get-smart-grid-layout/action.js +4 -0
  18. package/dist/actions/get-smart-grid-layout/mock.d.ts +2 -0
  19. package/dist/actions/get-smart-grid-layout/mock.js +7 -0
  20. package/dist/actions/get-smart-grid-layout/types.d.ts +12 -0
  21. package/dist/actions/get-users/mock.js +16 -25
  22. package/dist/actions/initiate-refund/types.d.ts +0 -3
  23. package/dist/actions/integration-payment/action.d.ts +5 -0
  24. package/dist/actions/integration-payment/action.js +7 -0
  25. package/dist/actions/integration-payment/mock.d.ts +2 -0
  26. package/dist/actions/integration-payment/mock.js +4 -0
  27. package/dist/actions/integration-payment/types.d.ts +16 -0
  28. package/dist/actions/open-extension-overlay/action.d.ts +2 -0
  29. package/dist/actions/open-extension-overlay/action.js +4 -0
  30. package/dist/actions/open-extension-overlay/mock.d.ts +2 -0
  31. package/dist/actions/open-extension-overlay/mock.js +1 -0
  32. package/dist/actions/open-extension-overlay/types.d.ts +9 -0
  33. package/dist/actions/park-order/types.d.ts +0 -3
  34. package/dist/actions/partial-payment/types.d.ts +0 -5
  35. package/dist/actions/print/mock.js +3 -6
  36. package/dist/actions/print/types.d.ts +1 -7
  37. package/dist/actions/process-partial-refund/types.d.ts +0 -3
  38. package/dist/actions/remove-customer-note/mock.js +14 -5
  39. package/dist/actions/resolve-extension-overlay/action.d.ts +2 -0
  40. package/dist/actions/resolve-extension-overlay/action.js +4 -0
  41. package/dist/actions/resolve-extension-overlay/mock.d.ts +2 -0
  42. package/dist/actions/resolve-extension-overlay/mock.js +1 -0
  43. package/dist/actions/resolve-extension-overlay/types.d.ts +9 -0
  44. package/dist/actions/resume-parked-order/mock.js +1 -1
  45. package/dist/actions/resume-parked-order/types.d.ts +0 -3
  46. package/dist/actions/save-smart-grid-layout/action.d.ts +2 -0
  47. package/dist/actions/save-smart-grid-layout/action.js +4 -0
  48. package/dist/actions/save-smart-grid-layout/mock.d.ts +2 -0
  49. package/dist/actions/save-smart-grid-layout/mock.js +7 -0
  50. package/dist/actions/save-smart-grid-layout/types.d.ts +12 -0
  51. package/dist/actions/set-active-product-discount/mock.js +1 -1
  52. package/dist/actions/set-active-product-fee/mock.js +1 -1
  53. package/dist/actions/tap-to-pay-payment/types.d.ts +0 -5
  54. package/dist/actions/terminal-payment/types.d.ts +0 -5
  55. package/dist/actions/vendara-payment/types.d.ts +0 -5
  56. package/dist/common-types/index.d.ts +0 -1
  57. package/dist/common-types/index.js +0 -1
  58. package/dist/demo/database.d.ts +21 -21
  59. package/dist/demo/database.js +36 -51
  60. package/dist/index.d.ts +124 -116
  61. package/dist/index.js +19 -15
  62. package/dist/interceptors/types.d.ts +34 -0
  63. package/dist/interceptors/types.js +1 -0
  64. package/dist/projects/render/mocks.js +10 -8
  65. package/dist/projects/render/types.d.ts +6 -5
  66. package/dist/pubsub/topics/attributes/attribute-created/types.d.ts +6 -0
  67. package/dist/pubsub/topics/attributes/attribute-created/types.js +1 -0
  68. package/dist/pubsub/topics/attributes/attribute-updated/types.d.ts +6 -0
  69. package/dist/pubsub/topics/attributes/attribute-updated/types.js +1 -0
  70. package/dist/pubsub/topics/attributes/index.d.ts +3 -0
  71. package/dist/pubsub/topics/attributes/index.js +18 -0
  72. package/dist/pubsub/topics/attributes/types.d.ts +6 -0
  73. package/dist/pubsub/topics/attributes/types.js +2 -0
  74. package/dist/pubsub/topics/categories/category-created/types.d.ts +6 -0
  75. package/dist/pubsub/topics/categories/category-created/types.js +1 -0
  76. package/dist/pubsub/topics/categories/category-updated/types.d.ts +6 -0
  77. package/dist/pubsub/topics/categories/category-updated/types.js +1 -0
  78. package/dist/pubsub/topics/categories/index.d.ts +3 -0
  79. package/dist/pubsub/topics/categories/index.js +18 -0
  80. package/dist/pubsub/topics/categories/types.d.ts +6 -0
  81. package/dist/pubsub/topics/categories/types.js +2 -0
  82. package/dist/pubsub/topics/index.d.ts +4 -0
  83. package/dist/pubsub/topics/index.js +4 -0
  84. package/dist/pubsub/topics/orders/index.js +0 -10
  85. package/dist/pubsub/topics/orders/types.d.ts +2 -6
  86. package/dist/pubsub/topics/orders/types.js +0 -2
  87. package/dist/pubsub/topics/print/print-completed/types.d.ts +1 -1
  88. package/dist/pubsub/topics/print/print-error/types.d.ts +1 -1
  89. package/dist/pubsub/topics/print/print-started/types.d.ts +1 -1
  90. package/dist/pubsub/topics/products/product-get-active/types.d.ts +6 -2
  91. package/dist/pubsub/topics/transactions/index.d.ts +3 -0
  92. package/dist/pubsub/topics/transactions/index.js +18 -0
  93. package/dist/pubsub/topics/transactions/transaction-created/types.d.ts +6 -0
  94. package/dist/pubsub/topics/transactions/transaction-created/types.js +1 -0
  95. package/dist/pubsub/topics/transactions/transaction-updated/types.d.ts +6 -0
  96. package/dist/pubsub/topics/transactions/transaction-updated/types.js +1 -0
  97. package/dist/pubsub/topics/transactions/types.d.ts +6 -0
  98. package/dist/pubsub/topics/transactions/types.js +2 -0
  99. package/dist/pubsub/topics/types.d.ts +8 -0
  100. package/dist/pubsub/topics/users/index.js +10 -0
  101. package/dist/pubsub/topics/users/types.d.ts +6 -2
  102. package/dist/pubsub/topics/users/types.js +2 -0
  103. package/dist/pubsub/topics/users/user-created/types.d.ts +6 -0
  104. package/dist/pubsub/topics/users/user-created/types.js +1 -0
  105. package/dist/pubsub/topics/users/user-updated/types.d.ts +6 -0
  106. package/dist/pubsub/topics/users/user-updated/types.js +1 -0
  107. package/dist/pubsub/topics/variants/index.d.ts +3 -0
  108. package/dist/pubsub/topics/variants/index.js +18 -0
  109. package/dist/pubsub/topics/variants/types.d.ts +6 -0
  110. package/dist/pubsub/topics/variants/types.js +2 -0
  111. package/dist/pubsub/topics/variants/variant-created/types.d.ts +6 -0
  112. package/dist/pubsub/topics/variants/variant-created/types.js +1 -0
  113. package/dist/pubsub/topics/variants/variant-updated/types.d.ts +6 -0
  114. package/dist/pubsub/topics/variants/variant-updated/types.js +1 -0
  115. package/package.json +15 -12
  116. package/dist/actions/can-transition/action.d.ts +0 -2
  117. package/dist/actions/can-transition/action.js +0 -4
  118. package/dist/actions/can-transition/mock.d.ts +0 -6
  119. package/dist/actions/can-transition/mock.js +0 -28
  120. package/dist/actions/can-transition/types.d.ts +0 -11
  121. package/dist/actions/get-available-transitions/action.d.ts +0 -2
  122. package/dist/actions/get-available-transitions/action.js +0 -4
  123. package/dist/actions/get-available-transitions/mock.d.ts +0 -6
  124. package/dist/actions/get-available-transitions/mock.js +0 -26
  125. package/dist/actions/get-available-transitions/types.d.ts +0 -9
  126. package/dist/actions/trigger-webhook/action.d.ts +0 -6
  127. package/dist/actions/trigger-webhook/action.js +0 -8
  128. package/dist/actions/trigger-webhook/mock.d.ts +0 -2
  129. package/dist/actions/trigger-webhook/mock.js +0 -8
  130. package/dist/actions/trigger-webhook/types.d.ts +0 -21
  131. package/dist/actions/trigger-webhook/types.js +0 -2
  132. package/dist/actions/trigger-zapier-webhook/action.d.ts +0 -6
  133. package/dist/actions/trigger-zapier-webhook/action.js +0 -8
  134. package/dist/actions/trigger-zapier-webhook/mock.d.ts +0 -2
  135. package/dist/actions/trigger-zapier-webhook/mock.js +0 -8
  136. package/dist/actions/trigger-zapier-webhook/types.d.ts +0 -9
  137. package/dist/common-types/order-state.d.ts +0 -32
  138. package/dist/common-types/order-state.js +0 -6
  139. package/dist/common-types/state-fragment.d.ts +0 -77
  140. package/dist/common-types/state-fragment.js +0 -10
  141. package/dist/fragments/index.d.ts +0 -1
  142. package/dist/fragments/index.js +0 -1
  143. package/dist/fragments/preorder-no-deposit.d.ts +0 -26
  144. package/dist/fragments/preorder-no-deposit.js +0 -166
  145. package/dist/pubsub/topics/orders/state-transition-blocked/types.d.ts +0 -16
  146. package/dist/pubsub/topics/orders/state-transition-completed/types.d.ts +0 -15
  147. /package/dist/actions/{can-transition → get-smart-grid-layout}/types.js +0 -0
  148. /package/dist/actions/{get-available-transitions → integration-payment}/types.js +0 -0
  149. /package/dist/actions/{trigger-zapier-webhook → open-extension-overlay}/types.js +0 -0
  150. /package/dist/{pubsub/topics/orders/state-transition-blocked → actions/resolve-extension-overlay}/types.js +0 -0
  151. /package/dist/{pubsub/topics/orders/state-transition-completed → actions/save-smart-grid-layout}/types.js +0 -0
package/README.md CHANGED
@@ -10,11 +10,11 @@ Command Frame provides a structured way to build integrations that run inside Fi
10
10
 
11
11
  The library provides three main capabilities:
12
12
 
13
- | Capability | Purpose | Scope |
14
- | ------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------- |
15
- | **Commands** | Call host functions from the iframe (e.g. get products, open cash drawer) | Request/response per call |
16
- | **Pub/Sub** | Subscribe to real-time events from the host (e.g. cart changes, payments) | Page-scoped (while iframe is mounted) |
17
- | **Hooks** | Register business-logic callbacks that persist across all pages | Session-scoped (survives page navigation) |
13
+ | Capability | Purpose | Scope |
14
+ |-----------|---------|-------|
15
+ | **Commands** | Call host functions from the iframe (e.g. get products, open cash drawer) | Request/response per call |
16
+ | **Pub/Sub** | Subscribe to real-time events from the host (e.g. cart changes, payments) | Page-scoped (while iframe is mounted) |
17
+ | **Hooks** | Register business-logic callbacks that persist across all pages | Session-scoped (survives page navigation) |
18
18
  | **Host → iframe refunds** | Render asks the extension to reverse redeem / gift-card payments before completing a POS refund | Parent `postMessage` + `requestId` (see below) |
19
19
 
20
20
  Domain models (orders, cart, customers, products, and related types) are documented in **[Types reference](./src/types/README.md)**.
@@ -54,7 +54,7 @@ For building applications that run inside the Render Point of Sale interface.
54
54
  - **Features:** Order management, Product catalog, Customer management, Payments, Hardware integration (Cash drawer, Printer), Custom tables, Secrets storage.
55
55
 
56
56
  ```typescript
57
- import { RenderClient } from "@final-commerce/command-frame";
57
+ import { RenderClient } from '@final-commerce/command-frame';
58
58
 
59
59
  const client = new RenderClient();
60
60
  const products = await client.getProducts();
@@ -68,7 +68,7 @@ For building applications that run inside the Final Commerce Management Dashboar
68
68
  - **Features:** Context, catalog, entities, custom tables, secrets, and optional host-specific commands (navigation, media, tax, branding, notifications) when the dashboard implements them.
69
69
 
70
70
  ```typescript
71
- import { ManageClient } from "@final-commerce/command-frame";
71
+ import { ManageClient } from '@final-commerce/command-frame';
72
72
 
73
73
  const client = new ManageClient();
74
74
  const context = await client.getContext();
@@ -82,14 +82,14 @@ The pub/sub system allows iframe extensions to subscribe to topics and receive r
82
82
  - **Topics:** Cart (16), Customers (8), Orders (4), Payments (2), Products (4), Refunds (4), Print (3), Custom Tables (3), Outlet (2), Station (2), Session (2), Users (2).
83
83
 
84
84
  ```typescript
85
- import { topics } from "@final-commerce/command-frame";
85
+ import { topics } from '@final-commerce/command-frame';
86
86
 
87
- const subscriptionId = topics.subscribe("cart", event => {
88
- console.log("Cart event:", event.type, event.data);
87
+ const subscriptionId = topics.subscribe('cart', (event) => {
88
+ console.log('Cart event:', event.type, event.data);
89
89
  });
90
90
 
91
91
  // Unsubscribe when done
92
- topics.unsubscribe("cart", subscriptionId);
92
+ topics.unsubscribe('cart', subscriptionId);
93
93
  ```
94
94
 
95
95
  ## Hooks
@@ -101,21 +101,17 @@ Hooks are **session-scoped** event callbacks that run in the host (Render) conte
101
101
  - A stable `hookId` is required for deduplication (safe on iframe reload).
102
102
 
103
103
  ```typescript
104
- import { hooks } from "@final-commerce/command-frame";
105
-
106
- hooks.register(
107
- "cart",
108
- async (event, hostCommands) => {
109
- await hostCommands.upsertCustomTableData({
110
- tableName: "cart-events-log",
111
- data: { eventType: event.type, payload: event.data, timestamp: event.timestamp }
112
- });
113
- },
114
- { hookId: "my-extension:cart-log" }
115
- );
104
+ import { hooks } from '@final-commerce/command-frame';
105
+
106
+ hooks.register('cart', async (event, hostCommands) => {
107
+ await hostCommands.upsertCustomTableData({
108
+ tableName: 'cart-events-log',
109
+ data: { eventType: event.type, payload: event.data, timestamp: event.timestamp },
110
+ });
111
+ }, { hookId: 'my-extension:cart-log' });
116
112
 
117
113
  // Unregister when no longer needed
118
- hooks.unregister("my-extension:cart-log");
114
+ hooks.unregister('my-extension:cart-log');
119
115
  ```
120
116
 
121
117
  ## Host-initiated extension refunds (redeem / gift card)
@@ -131,12 +127,18 @@ hooks.unregister("my-extension:cart-log");
131
127
  Exported APIs: `installExtensionRefundListener`, `EXTENSION_REFUND_REQUEST_ACTION`, types **`ExtensionRefundParams`** / **`ExtensionRefundResponse`**.
132
128
 
133
129
  ```typescript
134
- import { installExtensionRefundListener, type ExtensionRefundParams, type ExtensionRefundResponse } from "@final-commerce/command-frame";
130
+ import {
131
+ installExtensionRefundListener,
132
+ type ExtensionRefundParams,
133
+ type ExtensionRefundResponse
134
+ } from '@final-commerce/command-frame';
135
135
 
136
136
  const unsubscribe = installExtensionRefundListener(async (params: ExtensionRefundParams): Promise<ExtensionRefundResponse> => {
137
137
  // params.paymentType === "redeem", params.amount in major currency units, params.saleId, params.processor, etc.
138
138
  const ok = await myGiftCardProvider.refund(params);
139
- return ok ? { success: true, extensionTransactionId: ok.providerRefundId } : { success: false, error: "Refund declined" };
139
+ return ok
140
+ ? { success: true, extensionTransactionId: ok.providerRefundId }
141
+ : { success: false, error: 'Refund declined' };
140
142
  });
141
143
 
142
144
  // on teardown (optional)