@final-commerce/command-frame 0.2.0-beta.1 → 0.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -26
- package/dist/CommonTypes.d.ts +79 -534
- package/dist/CommonTypes.js +5 -65
- package/dist/actions/add-customer-note/mock.js +24 -15
- package/dist/actions/add-customer-note/types.d.ts +3 -2
- package/dist/actions/add-product/mock.js +12 -6
- package/dist/actions/add-product-discount/mock.js +5 -5
- package/dist/actions/add-product-fee/mock.js +6 -6
- package/dist/actions/cash-payment/types.d.ts +0 -5
- package/dist/actions/delete-parked-order/types.d.ts +0 -3
- package/dist/actions/edit-product/mock.js +5 -3
- package/dist/actions/extension-payment/types.d.ts +4 -5
- package/dist/actions/get-context/mock.js +12 -6
- package/dist/actions/get-products/mock.js +3 -3
- package/dist/actions/get-roles/mock.js +35 -41
- package/dist/actions/get-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/action.js +4 -0
- package/dist/actions/get-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/get-smart-grid-layout/mock.js +7 -0
- package/dist/actions/get-smart-grid-layout/types.d.ts +12 -0
- package/dist/actions/get-users/mock.js +16 -25
- package/dist/actions/initiate-refund/types.d.ts +0 -3
- package/dist/actions/integration-payment/action.d.ts +5 -0
- package/dist/actions/integration-payment/action.js +7 -0
- package/dist/actions/integration-payment/mock.d.ts +2 -0
- package/dist/actions/integration-payment/mock.js +4 -0
- package/dist/actions/integration-payment/types.d.ts +16 -0
- package/dist/actions/open-extension-overlay/action.d.ts +2 -0
- package/dist/actions/open-extension-overlay/action.js +4 -0
- package/dist/actions/open-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/open-extension-overlay/mock.js +1 -0
- package/dist/actions/open-extension-overlay/types.d.ts +9 -0
- package/dist/actions/park-order/types.d.ts +0 -3
- package/dist/actions/partial-payment/types.d.ts +0 -5
- package/dist/actions/print/mock.js +3 -6
- package/dist/actions/print/types.d.ts +1 -7
- package/dist/actions/process-partial-refund/types.d.ts +0 -3
- package/dist/actions/remove-customer-note/mock.js +14 -5
- package/dist/actions/resolve-extension-overlay/action.d.ts +2 -0
- package/dist/actions/resolve-extension-overlay/action.js +4 -0
- package/dist/actions/resolve-extension-overlay/mock.d.ts +2 -0
- package/dist/actions/resolve-extension-overlay/mock.js +1 -0
- package/dist/actions/resolve-extension-overlay/types.d.ts +9 -0
- package/dist/actions/resume-parked-order/mock.js +1 -1
- package/dist/actions/resume-parked-order/types.d.ts +0 -3
- package/dist/actions/save-smart-grid-layout/action.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/action.js +4 -0
- package/dist/actions/save-smart-grid-layout/mock.d.ts +2 -0
- package/dist/actions/save-smart-grid-layout/mock.js +7 -0
- package/dist/actions/save-smart-grid-layout/types.d.ts +12 -0
- package/dist/actions/set-active-product-discount/mock.js +1 -1
- package/dist/actions/set-active-product-fee/mock.js +1 -1
- package/dist/actions/tap-to-pay-payment/types.d.ts +0 -5
- package/dist/actions/terminal-payment/types.d.ts +0 -5
- package/dist/actions/vendara-payment/types.d.ts +0 -5
- package/dist/common-types/index.d.ts +0 -1
- package/dist/common-types/index.js +0 -1
- package/dist/demo/database.d.ts +21 -21
- package/dist/demo/database.js +36 -51
- package/dist/index.d.ts +124 -116
- package/dist/index.js +19 -15
- package/dist/interceptors/types.d.ts +34 -0
- package/dist/interceptors/types.js +1 -0
- package/dist/projects/render/mocks.js +10 -8
- package/dist/projects/render/types.d.ts +6 -5
- package/dist/pubsub/topics/attributes/attribute-created/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/attribute-created/types.js +1 -0
- package/dist/pubsub/topics/attributes/attribute-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/attribute-updated/types.js +1 -0
- package/dist/pubsub/topics/attributes/index.d.ts +3 -0
- package/dist/pubsub/topics/attributes/index.js +18 -0
- package/dist/pubsub/topics/attributes/types.d.ts +6 -0
- package/dist/pubsub/topics/attributes/types.js +2 -0
- package/dist/pubsub/topics/categories/category-created/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/category-created/types.js +1 -0
- package/dist/pubsub/topics/categories/category-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/category-updated/types.js +1 -0
- package/dist/pubsub/topics/categories/index.d.ts +3 -0
- package/dist/pubsub/topics/categories/index.js +18 -0
- package/dist/pubsub/topics/categories/types.d.ts +6 -0
- package/dist/pubsub/topics/categories/types.js +2 -0
- package/dist/pubsub/topics/index.d.ts +4 -0
- package/dist/pubsub/topics/index.js +4 -0
- package/dist/pubsub/topics/orders/index.js +0 -10
- package/dist/pubsub/topics/orders/types.d.ts +2 -6
- package/dist/pubsub/topics/orders/types.js +0 -2
- package/dist/pubsub/topics/print/print-completed/types.d.ts +1 -1
- package/dist/pubsub/topics/print/print-error/types.d.ts +1 -1
- package/dist/pubsub/topics/print/print-started/types.d.ts +1 -1
- package/dist/pubsub/topics/products/product-get-active/types.d.ts +6 -2
- package/dist/pubsub/topics/transactions/index.d.ts +3 -0
- package/dist/pubsub/topics/transactions/index.js +18 -0
- package/dist/pubsub/topics/transactions/transaction-created/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/transaction-created/types.js +1 -0
- package/dist/pubsub/topics/transactions/transaction-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/transaction-updated/types.js +1 -0
- package/dist/pubsub/topics/transactions/types.d.ts +6 -0
- package/dist/pubsub/topics/transactions/types.js +2 -0
- package/dist/pubsub/topics/types.d.ts +8 -0
- package/dist/pubsub/topics/users/index.js +10 -0
- package/dist/pubsub/topics/users/types.d.ts +6 -2
- package/dist/pubsub/topics/users/types.js +2 -0
- package/dist/pubsub/topics/users/user-created/types.d.ts +6 -0
- package/dist/pubsub/topics/users/user-created/types.js +1 -0
- package/dist/pubsub/topics/users/user-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/users/user-updated/types.js +1 -0
- package/dist/pubsub/topics/variants/index.d.ts +3 -0
- package/dist/pubsub/topics/variants/index.js +18 -0
- package/dist/pubsub/topics/variants/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/types.js +2 -0
- package/dist/pubsub/topics/variants/variant-created/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/variant-created/types.js +1 -0
- package/dist/pubsub/topics/variants/variant-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/variants/variant-updated/types.js +1 -0
- package/package.json +15 -12
- package/dist/actions/can-transition/action.d.ts +0 -2
- package/dist/actions/can-transition/action.js +0 -4
- package/dist/actions/can-transition/mock.d.ts +0 -6
- package/dist/actions/can-transition/mock.js +0 -28
- package/dist/actions/can-transition/types.d.ts +0 -11
- package/dist/actions/get-available-transitions/action.d.ts +0 -2
- package/dist/actions/get-available-transitions/action.js +0 -4
- package/dist/actions/get-available-transitions/mock.d.ts +0 -6
- package/dist/actions/get-available-transitions/mock.js +0 -26
- package/dist/actions/get-available-transitions/types.d.ts +0 -9
- package/dist/actions/trigger-webhook/action.d.ts +0 -6
- package/dist/actions/trigger-webhook/action.js +0 -8
- package/dist/actions/trigger-webhook/mock.d.ts +0 -2
- package/dist/actions/trigger-webhook/mock.js +0 -8
- package/dist/actions/trigger-webhook/types.d.ts +0 -21
- package/dist/actions/trigger-webhook/types.js +0 -2
- package/dist/actions/trigger-zapier-webhook/action.d.ts +0 -6
- package/dist/actions/trigger-zapier-webhook/action.js +0 -8
- package/dist/actions/trigger-zapier-webhook/mock.d.ts +0 -2
- package/dist/actions/trigger-zapier-webhook/mock.js +0 -8
- package/dist/actions/trigger-zapier-webhook/types.d.ts +0 -9
- package/dist/common-types/order-state.d.ts +0 -32
- package/dist/common-types/order-state.js +0 -6
- package/dist/common-types/state-fragment.d.ts +0 -77
- package/dist/common-types/state-fragment.js +0 -10
- package/dist/fragments/index.d.ts +0 -1
- package/dist/fragments/index.js +0 -1
- package/dist/fragments/preorder-no-deposit.d.ts +0 -26
- package/dist/fragments/preorder-no-deposit.js +0 -166
- package/dist/pubsub/topics/orders/state-transition-blocked/types.d.ts +0 -16
- package/dist/pubsub/topics/orders/state-transition-completed/types.d.ts +0 -15
- /package/dist/actions/{can-transition → get-smart-grid-layout}/types.js +0 -0
- /package/dist/actions/{get-available-transitions → integration-payment}/types.js +0 -0
- /package/dist/actions/{trigger-zapier-webhook → open-extension-overlay}/types.js +0 -0
- /package/dist/{pubsub/topics/orders/state-transition-blocked → actions/resolve-extension-overlay}/types.js +0 -0
- /package/dist/{pubsub/topics/orders/state-transition-completed → actions/save-smart-grid-layout}/types.js +0 -0
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
|
|
14
|
-
|
|
15
|
-
| **Commands**
|
|
16
|
-
| **Pub/Sub**
|
|
17
|
-
| **Hooks**
|
|
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
|
|
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
|
|
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
|
|
85
|
+
import { topics } from '@final-commerce/command-frame';
|
|
86
86
|
|
|
87
|
-
const subscriptionId = topics.subscribe(
|
|
88
|
-
console.log(
|
|
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(
|
|
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
|
|
105
|
-
|
|
106
|
-
hooks.register(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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(
|
|
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 {
|
|
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
|
|
139
|
+
return ok
|
|
140
|
+
? { success: true, extensionTransactionId: ok.providerRefundId }
|
|
141
|
+
: { success: false, error: 'Refund declined' };
|
|
140
142
|
});
|
|
141
143
|
|
|
142
144
|
// on teardown (optional)
|