@final-commerce/command-frame 0.4.2-preprod.1 → 0.5.0-preprod.2

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 (62) hide show
  1. package/README.md +4 -55
  2. package/dist/CommonTypes.d.ts +1 -1
  3. package/dist/actions/add-product-fee/types.d.ts +1 -2
  4. package/dist/actions/adjust-inventory/mock.js +25 -21
  5. package/dist/actions/adjust-inventory/types.d.ts +1 -1
  6. package/dist/actions/authenticate-user/mock.js +4 -0
  7. package/dist/actions/authenticate-user/types.d.ts +13 -0
  8. package/dist/actions/cash-payment/mock.js +6 -2
  9. package/dist/actions/cash-payment/types.d.ts +5 -4
  10. package/dist/actions/delete-parked-order/types.d.ts +0 -3
  11. package/dist/actions/extension-payment/mock.js +5 -1
  12. package/dist/actions/extension-payment/types.d.ts +10 -5
  13. package/dist/actions/get-custom-table-data/types.d.ts +2 -4
  14. package/dist/actions/get-final-context/mock.js +1 -1
  15. package/dist/actions/get-remaining-refundable-quantities/mock.js +2 -0
  16. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +13 -0
  17. package/dist/actions/initiate-refund/types.d.ts +0 -3
  18. package/dist/actions/integration-payment/types.d.ts +5 -5
  19. package/dist/actions/park-order/types.d.ts +0 -3
  20. package/dist/actions/partial-payment/types.d.ts +0 -5
  21. package/dist/actions/print/mock.js +2 -0
  22. package/dist/actions/print/types.d.ts +7 -0
  23. package/dist/actions/process-partial-refund/types.d.ts +0 -3
  24. package/dist/actions/redeem-payment/types.d.ts +2 -2
  25. package/dist/actions/resume-parked-order/types.d.ts +0 -3
  26. package/dist/actions/tap-to-pay-payment/mock.js +5 -1
  27. package/dist/actions/tap-to-pay-payment/types.d.ts +9 -4
  28. package/dist/actions/terminal-payment/mock.js +5 -1
  29. package/dist/actions/terminal-payment/types.d.ts +11 -6
  30. package/dist/actions/upsert-custom-table-data/types.d.ts +11 -1
  31. package/dist/actions/void-order/types.d.ts +0 -3
  32. package/dist/index.d.ts +0 -8
  33. package/dist/index.js +0 -6
  34. package/dist/projects/render/mocks.js +0 -6
  35. package/dist/projects/render/types.d.ts +1 -6
  36. package/package.json +1 -1
  37. package/dist/actions/open-extension-overlay/action.d.ts +0 -2
  38. package/dist/actions/open-extension-overlay/action.js +0 -4
  39. package/dist/actions/open-extension-overlay/mock.d.ts +0 -2
  40. package/dist/actions/open-extension-overlay/mock.js +0 -1
  41. package/dist/actions/open-extension-overlay/types.d.ts +0 -9
  42. package/dist/actions/open-extension-overlay/types.js +0 -1
  43. package/dist/actions/resolve-extension-overlay/action.d.ts +0 -2
  44. package/dist/actions/resolve-extension-overlay/action.js +0 -4
  45. package/dist/actions/resolve-extension-overlay/mock.d.ts +0 -2
  46. package/dist/actions/resolve-extension-overlay/mock.js +0 -1
  47. package/dist/actions/resolve-extension-overlay/types.d.ts +0 -9
  48. package/dist/actions/resolve-extension-overlay/types.js +0 -1
  49. package/dist/actions/vendara-payment/action.d.ts +0 -6
  50. package/dist/actions/vendara-payment/action.js +0 -8
  51. package/dist/actions/vendara-payment/mock.d.ts +0 -2
  52. package/dist/actions/vendara-payment/mock.js +0 -11
  53. package/dist/actions/vendara-payment/types.d.ts +0 -26
  54. package/dist/actions/vendara-payment/types.js +0 -1
  55. package/dist/hooks/index.d.ts +0 -17
  56. package/dist/hooks/index.js +0 -39
  57. package/dist/hooks/types.d.ts +0 -15
  58. package/dist/hooks/types.js +0 -1
  59. package/dist/interceptors/index.d.ts +0 -21
  60. package/dist/interceptors/index.js +0 -53
  61. package/dist/interceptors/types.d.ts +0 -26
  62. package/dist/interceptors/types.js +0 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ A TypeScript library for type-safe communication between iframes and their paren
4
4
 
5
5
  ## Overview
6
6
 
7
- Command Frame provides a structured way to build integrations that run inside Final Commerce applications (like Render POS or Manage Dashboard). It handles the underlying `postMessage` communication while enforcing strict type safety for both the host application (Provider) and the embedded app (Client).
7
+ Command Frame provides a structured way to build integrations that run inside Final Commerce applications (the kaching POS runtime or the Manage Dashboard). It handles the underlying `postMessage` communication while enforcing strict type safety for both the host application (Provider) and the embedded app (Client).
8
8
 
9
9
  `RenderClient` and `ManageClient` extend `CommandFrameClient`: dynamic methods such as `getProducts()` map to `postMessage` actions named after the method (camelCase), with typed params and responses per project.
10
10
 
@@ -14,8 +14,6 @@ The library provides three main capabilities:
14
14
  | ------------------- | ------------------------------------------------------------------------- | ----------------------------------------- |
15
15
  | **Commands** | Call host functions from the iframe (e.g. get products, open cash drawer) | Request/response per call |
16
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
- | **Interceptors** | Gate POS flows (approve / modify / block) at named points | Blocking; host waits for your response |
19
17
  | **Refund commands** | Refund payments to gift cards or redeem tenders via `redeemRefund`, or mixed-destination legs on `processPartialRefund`; query engine capacity with `getRefundPlan`; pre-gate UI with `checkPermission` (`issue_refunds` is enforced runtime-side) | Request/response per call |
20
18
 
21
19
  Domain models (orders, cart, customers, products, and related types) are documented in **[Types reference](./src/types/README.md)**.
@@ -65,7 +63,7 @@ true` → `amount` is `0–100`), and quantities.
65
63
 
66
64
  ### Render (POS System)
67
65
 
68
- For building applications that run inside the Render Point of Sale interface.
66
+ For building applications that run inside the Final Commerce POS (the kaching runtime).
69
67
 
70
68
  - **[Render Documentation](./src/projects/render/README.md)**
71
69
  - **Features:** Order management, Product catalog, Customer management, Payments, Hardware integration (Cash drawer, Printer), Custom tables, Secrets storage.
@@ -93,10 +91,10 @@ const context = await client.getContext();
93
91
 
94
92
  ## Pub/Sub
95
93
 
96
- The pub/sub system allows iframe extensions to subscribe to topics and receive real-time events published by the host (Render). Subscriptions are **page-scoped** -- they fire only while the iframe is mounted on the current page.
94
+ The pub/sub system allows iframe extensions to subscribe to topics and receive real-time events published by the POS host (kaching). Subscriptions are **page-scoped** -- they fire only while the iframe is mounted on the current page.
97
95
 
98
96
  - **[Pub/Sub Documentation](./src/pubsub/README.md)**
99
- - **Topics:** Cart (16), Customers (8), Orders (5), Payments (2), Products (4), Refunds (4), Print (3), Custom Tables (3), Outlet (2), Station (2), Session (2), Users (2).
97
+ - **Topics:** Cart (16), Customers (8), Orders (7), Payments (2), Products (4), Refunds (4), Print (3), Custom Tables (3), Outlet (2), Station (2), Session (2), Users (4), Variants (2), Transactions (2), Categories (2), Attributes (2), Split Payments (1).
100
98
 
101
99
  ```typescript
102
100
  import { topics } from '@final-commerce/command-frame';
@@ -109,55 +107,6 @@ const subscriptionId = topics.subscribe('cart', (event) => {
109
107
  topics.unsubscribe('cart', subscriptionId);
110
108
  ```
111
109
 
112
- ## Hooks
113
-
114
- Hooks are **session-scoped** event callbacks that run in the host (Render) context and persist across all page navigations -- even when the extension iframe is no longer on the current page. Use hooks for business logic that must run on every event (e.g. logging to custom tables, triggering webhooks).
115
-
116
- - **[Hooks Documentation](./src/hooks/README.md)**
117
- - The callback is serialized and sent to the host; it must be **self-contained** (no closures, no imports).
118
- - A stable `hookId` is required for deduplication (safe on iframe reload).
119
-
120
- ```typescript
121
- import { hooks } from '@final-commerce/command-frame';
122
-
123
- hooks.register(
124
- 'cart',
125
- async (event, hostCommands) => {
126
- await hostCommands.upsertCustomTableData({
127
- tableName: 'cart-events-log',
128
- data: { eventType: event.type, payload: event.data, timestamp: event.timestamp },
129
- });
130
- },
131
- { hookId: 'my-extension:cart-log' },
132
- );
133
-
134
- // Unregister when no longer needed
135
- hooks.unregister('my-extension:cart-log');
136
- ```
137
-
138
- ## Interceptors
139
-
140
- Interceptors let an extension **gate a POS flow** (approve / modify / block) at a named point — the host waits for your interceptor and acts on what it returns. Unlike hooks, interceptors are **blocking**.
141
-
142
- - **[Interceptors Documentation](./src/interceptors/README.md)**
143
- - The callback is serialized and reconstructed on the host; it must be **self-contained** (no closures, no imports).
144
- - A stable `interceptorId` is required for deduplication (safe on iframe reload).
145
-
146
- ```typescript
147
- import { interceptors } from '@final-commerce/command-frame';
148
-
149
- interceptors.register(
150
- 'refund_start',
151
- async (payload, cmds) => {
152
- if (payload.paymentTypes.includes('redeem')) {
153
- return cmds.openExtensionOverlay({ point: 'refund_start', payload });
154
- }
155
- return true; // nothing for us to do
156
- },
157
- { interceptorId: 'my-extension:refund-guard' },
158
- );
159
- ```
160
-
161
110
  ## Refunding redeem / extension payments
162
111
 
163
112
  When staff refund an order that was paid with `paymentType: "redeem"` (via `redeemPayment` or `extensionPayment`), use the **`redeemRefund`** command to refund the amount onto a gift card or redeem tender.
@@ -96,7 +96,7 @@ export interface CFActiveRefundDetails {
96
96
  refundProcessingStatus?: CFRefundProcessingStatus | null;
97
97
  sessionRefundedTotal?: number;
98
98
  }
99
- export type CFProjectName = "Render" | "Manage";
99
+ export type CFProjectName = "kaching" | "Manage";
100
100
  export interface CFContextRender {
101
101
  userId: string | null;
102
102
  companyId: string | null;
@@ -5,9 +5,8 @@ export interface AddProductFeeParams {
5
5
  isPercent?: boolean;
6
6
  /** Defaults to "Fee". */
7
7
  label?: string;
8
- /** Defaults to `false`. */
8
+ /** Defaults to `false`. When true, the fee inherits the target cart line's own tax table (a caller-supplied tax table is not honored). */
9
9
  applyTaxes?: boolean;
10
- taxTableId?: string;
11
10
  /** The unique identifier for a specific line item in the cart. */
12
11
  internalId?: string;
13
12
  }
@@ -2,29 +2,33 @@ import { MOCK_PRODUCTS } from "../../demo/database";
2
2
  export const mockAdjustInventory = async (params) => {
3
3
  console.log("[Mock] adjustInventory called", params);
4
4
  let newStock = 0;
5
- if (params && params.productId) {
6
- const product = MOCK_PRODUCTS.find(p => p._id === params.productId);
7
- if (product) {
8
- // Find variant
9
- const variant = params.variantId
10
- ? product.variants.find(v => v._id === params.variantId)
11
- : product.variants[0];
12
- if (variant && variant.inventory && variant.inventory.length > 0) {
13
- const currentStock = variant.inventory[0].stock || 0;
14
- const changeAmount = Number(params.amount);
15
- if (params.stockType === 'add') {
16
- newStock = currentStock + changeAmount;
17
- }
18
- else if (params.stockType === 'subtract') {
19
- newStock = currentStock - changeAmount;
20
- }
21
- else {
22
- newStock = changeAmount;
23
- }
24
- // Update mock DB
25
- variant.inventory[0].stock = newStock;
5
+ // Real handler keys off variantId (falling back to the active product's
6
+ // variant); mirror that here by finding the owning product for the variant.
7
+ if (params && params.variantId) {
8
+ const variantId = params.variantId;
9
+ let variant;
10
+ for (const product of MOCK_PRODUCTS) {
11
+ const match = product.variants.find(v => v._id === variantId);
12
+ if (match) {
13
+ variant = match;
14
+ break;
26
15
  }
27
16
  }
17
+ if (variant && variant.inventory && variant.inventory.length > 0) {
18
+ const currentStock = variant.inventory[0].stock || 0;
19
+ const changeAmount = Number(params.amount);
20
+ if (params.stockType === 'add') {
21
+ newStock = currentStock + changeAmount;
22
+ }
23
+ else if (params.stockType === 'subtract') {
24
+ newStock = currentStock - changeAmount;
25
+ }
26
+ else {
27
+ newStock = changeAmount;
28
+ }
29
+ // Update mock DB
30
+ variant.inventory[0].stock = newStock;
31
+ }
28
32
  }
29
33
  return {
30
34
  success: true,
@@ -3,8 +3,8 @@ export interface AdjustInventoryParams {
3
3
  amount: string;
4
4
  /** 'add' (increase), 'subtract' (decrease), or 'set' (recount). */
5
5
  stockType: 'add' | 'subtract' | 'set';
6
+ /** Variant to adjust. Omit to use the active product's selected variant. */
6
7
  variantId?: string;
7
- productId?: string;
8
8
  }
9
9
  export interface AdjustInventoryResponse {
10
10
  success: boolean;
@@ -1,5 +1,9 @@
1
1
  export const mockAuthenticateUser = async (params) => {
2
2
  console.log("[Mock] authenticateUser called", params);
3
+ // Headless path requires both userId and pin together (mirrors the handler guard).
4
+ if ((params?.userId || params?.pin) && !(params?.userId && params?.pin)) {
5
+ throw new Error("userId and pin must be provided together");
6
+ }
3
7
  return {
4
8
  success: true,
5
9
  roleIds: params?.roleIds || [],
@@ -1,5 +1,18 @@
1
1
  export interface AuthenticateUserParams {
2
+ /** Role IDs authorized for the gated action. The authenticating user must hold one of these. */
2
3
  roleIds: string[];
4
+ /**
5
+ * Headless validation: the id of the user whose PIN to verify. Provide together
6
+ * with `pin` to validate the credentials in-process and return success/failure
7
+ * WITHOUT showing kaching's PIN modal (the flow owns its own PIN UI). When
8
+ * omitted, the modal flow is used. Must be paired with `pin`.
9
+ */
10
+ userId?: string;
11
+ /**
12
+ * Headless validation: the PIN to check against `userId`'s stored pincode.
13
+ * Must be paired with `userId`. The user must also hold one of `roleIds`.
14
+ */
15
+ pin?: string;
3
16
  }
4
17
  export interface AuthenticateUserResponse {
5
18
  success: boolean;
@@ -11,7 +11,9 @@ export const mockCashPayment = async (params) => {
11
11
  cashRounding: 0,
12
12
  paymentType: "cash",
13
13
  order: null,
14
- timestamp: new Date().toISOString()
14
+ timestamp: new Date().toISOString(),
15
+ saleFinalized: false,
16
+ remainingBalance: 0
15
17
  };
16
18
  };
17
19
  // Contract: `amount` is required, integer MINOR currency units — same
@@ -55,6 +57,8 @@ export const mockCashPayment = async (params) => {
55
57
  cashRounding: 0,
56
58
  paymentType: "cash",
57
59
  order,
58
- timestamp: new Date().toISOString()
60
+ timestamp: new Date().toISOString(),
61
+ saleFinalized: true,
62
+ remainingBalance: 0
59
63
  };
60
64
  };
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface CashPaymentParams {
4
3
  /**
5
4
  * The amount to pay with this tender, in integer MINOR currency units
@@ -29,7 +28,7 @@ export interface CashPaymentParams {
29
28
  * POS still opens its legacy change-calculator modal.
30
29
  */
31
30
  openChangeCalculator?: boolean;
32
- /** Override the fulfillment state after full payment. Render resolves the cascade. */
31
+ /** Override the fulfillment state after full payment. kaching resolves the cascade. */
33
32
  checkoutFulfillmentTarget?: string;
34
33
  }
35
34
  export interface CashPaymentResponse {
@@ -56,7 +55,9 @@ export interface CashPaymentResponse {
56
55
  paymentType: string;
57
56
  order: CFOrder | null;
58
57
  timestamp: string;
59
- /** Present when the state machine blocked or forced the transition. */
60
- transitionResult?: CFTransitionResult;
58
+ /** True when this tender settled the cart's remaining balance (the sale completed). */
59
+ saleFinalized: boolean;
60
+ /** Balance still due after this tender, in integer MINOR currency units (0 once the sale is finalized). */
61
+ remainingBalance: number;
61
62
  }
62
63
  export type CashPayment = (params: CashPaymentParams) => Promise<CashPaymentResponse>;
@@ -1,4 +1,3 @@
1
- import type { CFTransitionResult } from "../../common-types/order-state";
2
1
  export interface DeleteParkedOrderParams {
3
2
  orderId: string;
4
3
  }
@@ -6,7 +5,5 @@ export interface DeleteParkedOrderResponse {
6
5
  success: boolean;
7
6
  orderId: string;
8
7
  timestamp: string;
9
- /** Present when the state machine blocked or forced the transition. */
10
- transitionResult?: CFTransitionResult;
11
8
  }
12
9
  export type DeleteParkedOrder = (params?: DeleteParkedOrderParams) => Promise<DeleteParkedOrderResponse>;
@@ -6,6 +6,10 @@ export const mockExtensionPayment = async (params) => {
6
6
  amount: params?.amount ?? null,
7
7
  paymentType,
8
8
  order: MOCK_ORDERS[0],
9
- timestamp: new Date().toISOString()
9
+ timestamp: new Date().toISOString(),
10
+ change: 0,
11
+ cashRounding: 0,
12
+ saleFinalized: true,
13
+ remainingBalance: 0
10
14
  };
11
15
  };
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  /** Params for extension-initiated payments; host routes by `paymentType`. */
4
3
  export interface ExtensionPaymentParams {
5
4
  paymentType: string;
@@ -15,8 +14,8 @@ export interface ExtensionPaymentParams {
15
14
  referenceId?: string;
16
15
  extensionId?: string;
17
16
  metadata?: Record<string, unknown>;
18
- /** Override the fulfillment landing on full payment. Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
19
- targetFulfillmentState?: string;
17
+ /** Override the fulfillment state the order lands in on full payment (validated against the fulfillment state machine; invalid values throw). Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
18
+ checkoutFulfillmentTarget?: string;
20
19
  /** EMV data when the underlying payment carries one (typed as `IntegrationEmvData` by the integration wrapper). */
21
20
  emvData?: unknown;
22
21
  /** Processor fee in integer MINOR currency units; recorded on the order's paymentMethod.processorFee. */
@@ -28,7 +27,13 @@ export interface ExtensionPaymentResponse {
28
27
  paymentType: string;
29
28
  order: CFOrder | null;
30
29
  timestamp: string;
31
- /** Present when the state machine blocked or forced the transition. */
32
- transitionResult?: CFTransitionResult;
30
+ /** Change due back to the customer in integer MINOR currency units (0 for non-cash tenders). */
31
+ change: number;
32
+ /** Signed cash-rounding delta applied to the charge, in integer MINOR currency units (positive = rounded up); 0 when the company has no cash-rounding setting. */
33
+ cashRounding: number;
34
+ /** True when this tender settled the cart's remaining balance (the sale completed). */
35
+ saleFinalized: boolean;
36
+ /** Balance still due after this tender, in integer MINOR currency units (0 once the sale is finalized). */
37
+ remainingBalance: number;
33
38
  }
34
39
  export type ExtensionPayment = (params?: ExtensionPaymentParams) => Promise<ExtensionPaymentResponse>;
@@ -4,10 +4,8 @@ export interface GetCustomTableDataResponse<T = any> {
4
4
  timestamp: string;
5
5
  }
6
6
  export interface GetCustomTableDataParams {
7
- /** Table name (kebab-case). Required if tableId is not provided. */
8
- tableName?: string;
9
- /** Table ID. Required if tableName is not provided. */
10
- tableId?: string;
7
+ /** Table name (kebab-case). Required — the handler throws if it is absent. */
8
+ tableName: string;
11
9
  /** Optional query filter */
12
10
  query?: any;
13
11
  /** Pagination offset */
@@ -1,6 +1,6 @@
1
1
  export const mockGetFinalContext = async () => {
2
2
  console.log("[Mock] getFinalContext called");
3
3
  return {
4
- projectName: "Render"
4
+ projectName: "kaching"
5
5
  };
6
6
  };
@@ -4,6 +4,8 @@ export const mockGetRemainingRefundableQuantities = async (_params) => {
4
4
  success: true,
5
5
  lineItems: {},
6
6
  customSales: {},
7
+ cartFees: {},
8
+ tips: {},
7
9
  timestamp: new Date().toISOString()
8
10
  };
9
11
  };
@@ -5,6 +5,19 @@ export interface GetRemainingRefundableQuantitiesResponse {
5
5
  success: boolean;
6
6
  lineItems: Record<string, number>;
7
7
  customSales: Record<string, number>;
8
+ /**
9
+ * Remaining refundable cart fees, keyed by `order.cartFees[].id` —
10
+ * the same key `processPartialRefund` takes for `type: 'fee'` items.
11
+ * 0/1 semantics: `1` = still refundable, `0` = already refunded.
12
+ */
13
+ cartFees: Record<string, number>;
14
+ /**
15
+ * Remaining refundable tips, keyed by the paying method's
16
+ * `transactionId` — the same key `processPartialRefund` takes for
17
+ * `type: 'tip'` items. Only payment methods that carry a tip appear.
18
+ * 0/1 semantics: `1` = still refundable, `0` = already refunded.
19
+ */
20
+ tips: Record<string, number>;
8
21
  timestamp: string;
9
22
  }
10
23
  export type GetRemainingRefundableQuantities = (params?: GetRemainingRefundableQuantitiesParams) => Promise<GetRemainingRefundableQuantitiesResponse>;
@@ -1,4 +1,3 @@
1
- import type { CFTransitionResult } from "../../common-types/order-state";
2
1
  export interface InitiateRefundParams {
3
2
  /** The ID of the order to refund. If not provided, uses the currently active order. */
4
3
  orderId?: string;
@@ -7,7 +6,5 @@ export interface InitiateRefundResponse {
7
6
  success: boolean;
8
7
  orderId: string;
9
8
  timestamp: string;
10
- /** Present when the state machine blocked or forced the transition. */
11
- transitionResult?: CFTransitionResult;
12
9
  }
13
10
  export type InitiateRefund = (params?: InitiateRefundParams) => Promise<InitiateRefundResponse>;
@@ -2,7 +2,7 @@ import type { ExtensionPaymentResponse } from "../extension-payment/types";
2
2
  /**
3
3
  * Card display fields for an integration payment.
4
4
  *
5
- * Render JSON-serializes this object onto the order's `paymentMethod.emv` field;
5
+ * kaching JSON-serializes this object onto the order's `paymentMethod.emv` field;
6
6
  * the transactions list, split-payment refund modal, and receipt mapper parse it
7
7
  * back. Field names are translated to the platform's canonical EMV keys ("Brand",
8
8
  * "Cardholder Name", "Card Number", etc.) on the host before serialization — your
@@ -24,13 +24,13 @@ export interface IntegrationEmvData {
24
24
  expiryDate?: string;
25
25
  /** Issuer / bank name. → "Issuer" */
26
26
  issuer?: string;
27
- /** Last 4 digits of the card. Render masks to "**** **** **** XXXX" before display. → "Card Number" */
27
+ /** Last 4 digits of the card. kaching masks to "**** **** **** XXXX" before display. → "Card Number" */
28
28
  cardNumberLast4?: string;
29
29
  }
30
30
  /**
31
31
  * Integration payment (e.g. Stripe-like) — always uses paymentType `"integration"` on the wire.
32
32
  * The extension processes the payment with its own provider, then reports the result here so
33
- * Render can record the transaction + order.
33
+ * kaching can record the transaction + order.
34
34
  *
35
35
  * Required fields (compile-time enforced by TS, runtime-enforced by the host handler):
36
36
  * - `amount` — integer MINOR currency units of the captured amount (e.g. 1575 = $15.75)
@@ -51,8 +51,8 @@ export interface IntegrationPaymentParams {
51
51
  metadata?: Record<string, unknown>;
52
52
  /** Provider fee in integer MINOR currency units — stored on paymentMethod.processorFee. */
53
53
  processorFee?: number;
54
- /** Override the fulfillment landing on full payment. Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
55
- targetFulfillmentState?: string;
54
+ /** Override the fulfillment state the order lands in on full payment (validated against the fulfillment state machine; invalid values throw). Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
55
+ checkoutFulfillmentTarget?: string;
56
56
  }
57
57
  export type IntegrationPaymentResponse = ExtensionPaymentResponse;
58
58
  export type IntegrationPayment = (params: IntegrationPaymentParams) => Promise<IntegrationPaymentResponse>;
@@ -1,10 +1,7 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface ParkOrderResponse {
4
3
  success: boolean;
5
4
  order: CFOrder;
6
5
  timestamp: string;
7
- /** Present when the state machine blocked or forced the transition. */
8
- transitionResult?: CFTransitionResult;
9
6
  }
10
7
  export type ParkOrder = () => Promise<ParkOrderResponse>;
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface PartialPaymentParams {
4
3
  /** The payment amount in integer MINOR currency units (required if openUI is false). If isPercent is true, this is a percentage (0-100) instead. */
5
4
  amount?: number;
@@ -7,8 +6,6 @@ export interface PartialPaymentParams {
7
6
  isPercent?: boolean;
8
7
  /** If true, opens the split payment UI. */
9
8
  openUI?: boolean;
10
- /** Override the fulfillment landing on full payment. Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
11
- targetFulfillmentState?: string;
12
9
  }
13
10
  export interface PartialPaymentResponse {
14
11
  success: boolean;
@@ -17,7 +14,5 @@ export interface PartialPaymentResponse {
17
14
  openUI: boolean;
18
15
  order: CFOrder | null;
19
16
  timestamp: string;
20
- /** Present when the state machine blocked or forced the transition. */
21
- transitionResult?: CFTransitionResult;
22
17
  }
23
18
  export type PartialPayment = (params?: PartialPaymentParams) => Promise<PartialPaymentResponse>;
@@ -9,9 +9,11 @@ export const mockPrint = (params) => {
9
9
  console.log("[Mock] Would print image:", params.data.image?.substring(0, 50) + "...");
10
10
  break;
11
11
  case "html":
12
+ console.warn("[Mock] print type 'html' is DEPRECATED — rasterize and use type: 'image'.");
12
13
  console.log("[Mock] Would print HTML:", params.data.html?.substring(0, 100) + "...");
13
14
  break;
14
15
  case "receipt":
16
+ console.warn("[Mock] print type 'receipt' is DEPRECATED — rasterize and use type: 'image'.");
15
17
  console.log("[Mock] Would print receipt for order:", params.data.order);
16
18
  break;
17
19
  }
@@ -7,12 +7,18 @@ export type PrintParams = {
7
7
  };
8
8
  options?: PrintOptions;
9
9
  } | {
10
+ /** @deprecated Rasterize your HTML and use `type: "image"`. The native path posts raw HTML to the shell (no html2canvas/sanitization) and PrintOptions may be dropped. */
10
11
  type: "html";
11
12
  data: {
12
13
  html: string;
13
14
  };
14
15
  options?: PrintOptions;
15
16
  } | {
17
+ /**
18
+ * @deprecated Compose + rasterize your receipt and use `type: "image"`.
19
+ * The station requires `order` (no active-order fallback), ignores
20
+ * `globalBlockId`, and drops ALL PrintOptions (including tag routing).
21
+ */
16
22
  type: "receipt";
17
23
  data: {
18
24
  order?: Omit<CFActiveOrder, "_id">;
@@ -27,6 +33,7 @@ export interface PrintOptions {
27
33
  bottom?: number;
28
34
  left?: number;
29
35
  };
36
+ /** @deprecated Not consumed by the runtime — paper size comes from the station's per-printer settings. */
30
37
  paperSize?: string;
31
38
  width?: string;
32
39
  /**
@@ -1,4 +1,3 @@
1
- import type { CFTransitionResult } from "../../common-types/order-state";
2
1
  export interface ProcessPartialRefundParams {
3
2
  /**
4
3
  * Optional refund reason.
@@ -114,7 +113,5 @@ export interface ProcessPartialRefundResponse {
114
113
  success: boolean;
115
114
  refundId: string;
116
115
  timestamp: string;
117
- /** Present when the state machine blocked or forced the transition. */
118
- transitionResult?: CFTransitionResult;
119
116
  }
120
117
  export type ProcessPartialRefund = (params?: ProcessPartialRefundParams) => Promise<ProcessPartialRefundResponse>;
@@ -12,8 +12,8 @@ export interface RedeemPaymentParams {
12
12
  processor?: string;
13
13
  referenceId?: string;
14
14
  metadata?: Record<string, unknown>;
15
- /** Override the fulfillment landing on full payment. Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
16
- targetFulfillmentState?: string;
15
+ /** Override the fulfillment state the order lands in on full payment (validated against the fulfillment state machine; invalid values throw). Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
16
+ checkoutFulfillmentTarget?: string;
17
17
  }
18
18
  export type RedeemPaymentResponse = ExtensionPaymentResponse;
19
19
  export type RedeemPayment = (params: RedeemPaymentParams) => Promise<RedeemPaymentResponse>;
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface ResumeParkedOrderParams {
4
3
  orderId: string;
5
4
  }
@@ -7,7 +6,5 @@ export interface ResumeParkedOrderResponse {
7
6
  success: boolean;
8
7
  order: CFOrder;
9
8
  timestamp: string;
10
- /** Present when the state machine blocked or forced the transition. */
11
- transitionResult?: CFTransitionResult;
12
9
  }
13
10
  export type ResumeParkedOrder = (params?: ResumeParkedOrderParams) => Promise<ResumeParkedOrderResponse>;
@@ -10,6 +10,10 @@ export const mockTapToPayPayment = async (params) => {
10
10
  amount: due,
11
11
  paymentType: "tapToPay",
12
12
  order,
13
- timestamp: new Date().toISOString()
13
+ timestamp: new Date().toISOString(),
14
+ change: 0,
15
+ cashRounding: 0,
16
+ saleFinalized: true,
17
+ remainingBalance: 0
14
18
  };
15
19
  };
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface TapToPayPaymentParams {
4
3
  /**
5
4
  * The amount to pay with this tender, in integer MINOR currency units
@@ -11,7 +10,7 @@ export interface TapToPayPaymentParams {
11
10
  * - more than balance → error
12
11
  */
13
12
  amount: number;
14
- /** Override the fulfillment state after full payment. Render resolves the cascade. */
13
+ /** Override the fulfillment state after full payment. kaching resolves the cascade. */
15
14
  checkoutFulfillmentTarget?: string;
16
15
  }
17
16
  export interface TapToPayPaymentResponse {
@@ -20,7 +19,13 @@ export interface TapToPayPaymentResponse {
20
19
  paymentType: string;
21
20
  order: CFOrder | null;
22
21
  timestamp: string;
23
- /** Present when the state machine blocked or forced the transition. */
24
- transitionResult?: CFTransitionResult;
22
+ /** Change due back to the customer in integer MINOR currency units (0 for non-cash tenders). */
23
+ change: number;
24
+ /** Signed cash-rounding delta applied to the charge, in integer MINOR currency units (positive = rounded up); 0 when the company has no cash-rounding setting. */
25
+ cashRounding: number;
26
+ /** True when this tender settled the cart's remaining balance (the sale completed). */
27
+ saleFinalized: boolean;
28
+ /** Balance still due after this tender, in integer MINOR currency units (0 once the sale is finalized). */
29
+ remainingBalance: number;
25
30
  }
26
31
  export type TapToPayPayment = (params?: TapToPayPaymentParams) => Promise<TapToPayPaymentResponse>;
@@ -11,6 +11,10 @@ export const mockTerminalPayment = async (params) => {
11
11
  amount: due,
12
12
  paymentType: "terminal",
13
13
  order,
14
- timestamp: new Date().toISOString()
14
+ timestamp: new Date().toISOString(),
15
+ change: 0,
16
+ cashRounding: 0,
17
+ saleFinalized: true,
18
+ remainingBalance: 0
15
19
  };
16
20
  };
@@ -1,5 +1,4 @@
1
1
  import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
2
  export interface TerminalPaymentParams {
4
3
  /**
5
4
  * The amount to pay with this tender, in integer MINOR currency units
@@ -11,10 +10,10 @@ export interface TerminalPaymentParams {
11
10
  * - more than balance → error
12
11
  */
13
12
  amount: number;
14
- /** "Bluetooth" or "Cloud". Defaults to "Cloud". */
13
+ /** "Bluetooth" or "Cloud". Only "Cloud" routes to the cloud processor; omitted or "Bluetooth" uses the native card reader. */
15
14
  paymentType?: "Bluetooth" | "Cloud";
16
- /** Override the fulfillment landing on full payment. Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
17
- targetFulfillmentState?: string;
15
+ /** Override the fulfillment state the order lands in on full payment (validated against the fulfillment state machine; invalid values throw). Omitted: preserve advanced fulfillment, auto-fulfill from draft/pending/on_hold. */
16
+ checkoutFulfillmentTarget?: string;
18
17
  }
19
18
  export interface TerminalPaymentResponse {
20
19
  success: boolean;
@@ -22,7 +21,13 @@ export interface TerminalPaymentResponse {
22
21
  paymentType: string;
23
22
  order: CFOrder | null;
24
23
  timestamp: string;
25
- /** Present when the state machine blocked or forced the transition. */
26
- transitionResult?: CFTransitionResult;
24
+ /** Change due back to the customer in integer MINOR currency units (0 for non-cash tenders). */
25
+ change: number;
26
+ /** Signed cash-rounding delta applied to the charge, in integer MINOR currency units (positive = rounded up); 0 when the company has no cash-rounding setting. */
27
+ cashRounding: number;
28
+ /** True when this tender settled the cart's remaining balance (the sale completed). */
29
+ saleFinalized: boolean;
30
+ /** Balance still due after this tender, in integer MINOR currency units (0 once the sale is finalized). */
31
+ remainingBalance: number;
27
32
  }
28
33
  export type TerminalPayment = (params?: TerminalPaymentParams) => Promise<TerminalPaymentResponse>;
@@ -1,6 +1,16 @@
1
+ /** The persisted custom-table row: your `data` fields plus the platform-generated identity. */
2
+ export type UpsertedCustomTableRow<T = any> = T & {
3
+ /** Generated row id (present on both insert and update). */
4
+ _id: string;
5
+ /** ISO timestamp; present on insert. */
6
+ createdAt?: string;
7
+ /** ISO timestamp; set on every upsert. */
8
+ updatedAt?: string;
9
+ };
1
10
  export interface UpsertCustomTableDataResponse<T = any> {
2
11
  success: boolean;
3
- data: T;
12
+ /** The PERSISTED row (with the generated `_id`/timestamps), not a bare echo of the input. */
13
+ data: UpsertedCustomTableRow<T>;
4
14
  timestamp: string;
5
15
  }
6
16
  export interface UpsertCustomTableDataParams<T = any> {
@@ -1,4 +1,3 @@
1
- import type { CFTransitionResult } from '../../common-types/order-state';
2
1
  export type VoidOrderOutcome = 'voided' | 'refunded';
3
2
  export interface VoidOrderParams {
4
3
  /** Order to void; defaults to the active order. */
@@ -21,7 +20,5 @@ export interface VoidOrderResponse {
21
20
  */
22
21
  outcome: VoidOrderOutcome;
23
22
  timestamp: string;
24
- /** Present when the state machine blocked or forced the transition. */
25
- transitionResult?: CFTransitionResult;
26
23
  }
27
24
  export type VoidOrder = (params?: VoidOrderParams) => Promise<VoidOrderResponse>;
package/dist/index.d.ts CHANGED
@@ -38,7 +38,6 @@ export declare const command: {
38
38
  readonly getCashRoundingAmount: import(".").GetCashRoundingAmount;
39
39
  readonly tapToPayPayment: import(".").TapToPayPayment;
40
40
  readonly terminalPayment: import(".").TerminalPayment;
41
- readonly vendaraPayment: import(".").VendaraPayment;
42
41
  readonly extensionPayment: import(".").ExtensionPayment;
43
42
  readonly redeemPayment: import(".").RedeemPayment;
44
43
  readonly integrationPayment: import(".").IntegrationPayment;
@@ -145,8 +144,6 @@ export type { RedeemRefund, RedeemRefundParams, RedeemRefundResponse } from './a
145
144
  export type { GetRefundPlan, GetRefundPlanParams, GetRefundPlanResponse, RefundPlanSource, } from './actions/get-refund-plan/types';
146
145
  export type { CheckPermission, CheckPermissionParams, CheckPermissionResponse, } from './actions/check-permission/types';
147
146
  export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from './actions/initiate-refund/types';
148
- export type { OpenExtensionOverlay, OpenExtensionOverlayParams, OpenExtensionOverlayResponse, } from './actions/open-extension-overlay/types';
149
- export type { ResolveExtensionOverlay, ResolveExtensionOverlayParams, ResolveExtensionOverlayResponse, } from './actions/resolve-extension-overlay/types';
150
147
  export type { GetCurrentCart, GetCurrentCartResponse } from './actions/get-current-cart/types';
151
148
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse, } from './actions/add-product-discount/types';
152
149
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
@@ -173,7 +170,6 @@ export type { CashPayment, CashPaymentParams, CashPaymentResponse } from './acti
173
170
  export type { GetCashRoundingAmount, GetCashRoundingAmountParams, GetCashRoundingAmountResponse, } from './actions/get-cash-rounding-amount/types';
174
171
  export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse, } from './actions/tap-to-pay-payment/types';
175
172
  export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from './actions/terminal-payment/types';
176
- export type { VendaraPayment, VendaraPaymentParams, VendaraPaymentResponse } from './actions/vendara-payment/types';
177
173
  export type { ExtensionPayment, ExtensionPaymentParams, ExtensionPaymentResponse, } from './actions/extension-payment/types';
178
174
  export type { RedeemPayment, RedeemPaymentParams, RedeemPaymentResponse } from './actions/redeem-payment/types';
179
175
  export type { IntegrationPayment, IntegrationPaymentParams, IntegrationPaymentResponse, IntegrationEmvData, } from './actions/integration-payment/types';
@@ -226,10 +222,6 @@ export type { PostMessageRequest, PostMessageResponse } from './client';
226
222
  export { topics } from './pubsub/topics';
227
223
  export type { TopicDefinition, TopicEvent, TopicEventType, TopicSubscriptionCallback, TopicSubscription, HookCallback, HookOptions, HookRegistration, } from './pubsub/types';
228
224
  export type { TopicEventPayloadMap } from './pubsub/topics/types';
229
- export { hooks } from './hooks';
230
- export type { HookFunction, HookRegisterOptions } from './hooks';
231
- export { interceptors } from './interceptors';
232
- export type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorReturn, InterceptorOverlayContext, InterceptorHostCommands, } from './interceptors';
233
225
  export { customersTopic } from './pubsub/topics/customers';
234
226
  export { ordersTopic } from './pubsub/topics/orders';
235
227
  export { refundsTopic } from './pubsub/topics/refunds';
package/dist/index.js CHANGED
@@ -38,7 +38,6 @@ import { cashPayment } from './actions/cash-payment/action';
38
38
  import { getCashRoundingAmount } from './actions/get-cash-rounding-amount/action';
39
39
  import { tapToPayPayment } from './actions/tap-to-pay-payment/action';
40
40
  import { terminalPayment } from './actions/terminal-payment/action';
41
- import { vendaraPayment } from './actions/vendara-payment/action';
42
41
  import { extensionPayment } from './actions/extension-payment/action';
43
42
  import { redeemPayment } from './actions/redeem-payment/action';
44
43
  import { integrationPayment } from './actions/integration-payment/action';
@@ -172,7 +171,6 @@ export const command = {
172
171
  getCashRoundingAmount,
173
172
  tapToPayPayment,
174
173
  terminalPayment,
175
- vendaraPayment,
176
174
  extensionPayment,
177
175
  redeemPayment,
178
176
  integrationPayment,
@@ -277,10 +275,6 @@ export * from './projects/manage';
277
275
  export { commandFrameClient, CommandFrameClient } from './client';
278
276
  // Export Pub/Sub
279
277
  export { topics } from './pubsub/topics';
280
- // Export Hooks (extension iframe API for session-scoped event callbacks)
281
- export { hooks } from './hooks';
282
- // Export Interceptors (extension iframe API for gating host flows)
283
- export { interceptors } from './interceptors';
284
278
  // Export Pub/Sub Topics
285
279
  export { customersTopic } from './pubsub/topics/customers';
286
280
  export { ordersTopic } from './pubsub/topics/orders';
@@ -44,8 +44,6 @@ import { mockGetTaxTables } from '../../actions/get-tax-tables/mock';
44
44
  import { mockGetRemainingRefundableQuantities } from '../../actions/get-remaining-refundable-quantities/mock';
45
45
  import { mockGoToStationHome } from '../../actions/go-to-station-home/mock';
46
46
  import { mockInitiateRefund } from '../../actions/initiate-refund/mock';
47
- import { mockOpenExtensionOverlay } from '../../actions/open-extension-overlay/mock';
48
- import { mockResolveExtensionOverlay } from '../../actions/resolve-extension-overlay/mock';
49
47
  import { mockOpenCashDrawer } from '../../actions/open-cash-drawer/mock';
50
48
  import { mockParkOrder } from '../../actions/park-order/mock';
51
49
  import { mockPartialPayment } from '../../actions/partial-payment/mock';
@@ -63,7 +61,6 @@ import { mockShowNotification } from '../../actions/show-notification/mock';
63
61
  import { mockSwitchUser } from '../../actions/switch-user/mock';
64
62
  import { mockTapToPayPayment } from '../../actions/tap-to-pay-payment/mock';
65
63
  import { mockTerminalPayment } from '../../actions/terminal-payment/mock';
66
- import { mockVendaraPayment } from '../../actions/vendara-payment/mock';
67
64
  import { mockExtensionPayment } from '../../actions/extension-payment/mock';
68
65
  import { mockRedeemPayment } from '../../actions/redeem-payment/mock';
69
66
  import { mockIntegrationPayment } from '../../actions/integration-payment/mock';
@@ -141,8 +138,6 @@ export const RENDER_MOCKS = {
141
138
  getRemainingRefundableQuantities: mockGetRemainingRefundableQuantities,
142
139
  goToStationHome: mockGoToStationHome,
143
140
  initiateRefund: mockInitiateRefund,
144
- openExtensionOverlay: mockOpenExtensionOverlay,
145
- resolveExtensionOverlay: mockResolveExtensionOverlay,
146
141
  openCashDrawer: mockOpenCashDrawer,
147
142
  parkOrder: mockParkOrder,
148
143
  partialPayment: mockPartialPayment,
@@ -161,7 +156,6 @@ export const RENDER_MOCKS = {
161
156
  switchUser: mockSwitchUser,
162
157
  tapToPayPayment: mockTapToPayPayment,
163
158
  terminalPayment: mockTerminalPayment,
164
- vendaraPayment: mockVendaraPayment,
165
159
  extensionPayment: mockExtensionPayment,
166
160
  redeemPayment: mockRedeemPayment,
167
161
  integrationPayment: mockIntegrationPayment,
@@ -1,6 +1,4 @@
1
- import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms } from '../../index';
2
- import type { OpenExtensionOverlay } from '../../actions/open-extension-overlay/types';
3
- import type { ResolveExtensionOverlay } from '../../actions/resolve-extension-overlay/types';
1
+ import type { ExampleFunction, GetProducts, AddCustomSale, EditCustomSale, GetCustomers, AssignCustomer, AddCustomer, EditCustomer, GetCategories, GetOrders, GetRefunds, GetTaxTables, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, SetActiveProductFee, SetActiveProductDiscount, GetActiveProduct, SetActiveProduct, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, VoidOrder, InitiateRefund, CashPayment, GetCashRoundingAmount, TapToPayPayment, TerminalPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, RedeemRefund, GetRefundPlan, CheckPermission, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles, RemoveCartDiscount, GetActiveOrder, GetActiveCustomer, SetActiveCustomer, GetActiveOutlet, GetActiveStation, GetActiveSession, GetActiveUser, SetActiveUser, SetActiveRefund, RemoveProductDiscount, RemoveProductFee, RemoveProductNote, RemoveCartFee, RemoveOrderNote, RemoveCustomSale, RemoveNonRevenueItem, CanTransition, GetAvailableTransitions, ApplyTransition, IntegrationPayment, GetSmartGridLayout, SaveSmartGridLayout, SendEmail, SendSms } from '../../index';
4
2
  export interface RenderProviderActions {
5
3
  exampleFunction: ExampleFunction;
6
4
  getProducts: GetProducts;
@@ -36,13 +34,10 @@ export interface RenderProviderActions {
36
34
  deleteParkedOrder: DeleteParkedOrder;
37
35
  voidOrder: VoidOrder;
38
36
  initiateRefund: InitiateRefund;
39
- openExtensionOverlay: OpenExtensionOverlay;
40
- resolveExtensionOverlay: ResolveExtensionOverlay;
41
37
  cashPayment: CashPayment;
42
38
  getCashRoundingAmount: GetCashRoundingAmount;
43
39
  tapToPayPayment: TapToPayPayment;
44
40
  terminalPayment: TerminalPayment;
45
- vendaraPayment: VendaraPayment;
46
41
  extensionPayment: ExtensionPayment;
47
42
  redeemPayment: RedeemPayment;
48
43
  integrationPayment: IntegrationPayment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.4.2-preprod.1",
3
+ "version": "0.5.0-preprod.2",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import type { OpenExtensionOverlay } from "./types";
2
- export declare const openExtensionOverlay: OpenExtensionOverlay;
@@ -1,4 +0,0 @@
1
- import { commandFrameClient } from "../../client";
2
- export const openExtensionOverlay = async (params) => {
3
- return await commandFrameClient.call("openExtensionOverlay", params);
4
- };
@@ -1,2 +0,0 @@
1
- import type { OpenExtensionOverlay } from "./types";
2
- export declare const mockOpenExtensionOverlay: OpenExtensionOverlay;
@@ -1 +0,0 @@
1
- export const mockOpenExtensionOverlay = async (_params) => true;
@@ -1,9 +0,0 @@
1
- import type { InterceptorPoint, InterceptorReturn } from "../../interceptors/types";
2
- export interface OpenExtensionOverlayParams {
3
- point: InterceptorPoint;
4
- payload?: any;
5
- /** Owning extension id. Injected by the host for interceptor-originated calls; optional for direct calls. */
6
- extensionId?: string;
7
- }
8
- export type OpenExtensionOverlayResponse = InterceptorReturn;
9
- export type OpenExtensionOverlay = (params: OpenExtensionOverlayParams) => Promise<OpenExtensionOverlayResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { ResolveExtensionOverlay } from "./types";
2
- export declare const resolveExtensionOverlay: ResolveExtensionOverlay;
@@ -1,4 +0,0 @@
1
- import { commandFrameClient } from "../../client";
2
- export const resolveExtensionOverlay = async (params) => {
3
- return await commandFrameClient.call("resolveExtensionOverlay", params);
4
- };
@@ -1,2 +0,0 @@
1
- import type { ResolveExtensionOverlay } from "./types";
2
- export declare const mockResolveExtensionOverlay: ResolveExtensionOverlay;
@@ -1 +0,0 @@
1
- export const mockResolveExtensionOverlay = async (_params) => ({ success: true });
@@ -1,9 +0,0 @@
1
- import type { InterceptorReturn } from "../../interceptors/types";
2
- export interface ResolveExtensionOverlayParams {
3
- overlayId: string;
4
- result: InterceptorReturn;
5
- }
6
- export interface ResolveExtensionOverlayResponse {
7
- success: boolean;
8
- }
9
- export type ResolveExtensionOverlay = (params: ResolveExtensionOverlayParams) => Promise<ResolveExtensionOverlayResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Vendara payment action
3
- * Calls the vendaraPayment action on the parent window
4
- */
5
- import type { VendaraPayment } from "./types";
6
- export declare const vendaraPayment: VendaraPayment;
@@ -1,8 +0,0 @@
1
- /**
2
- * Vendara payment action
3
- * Calls the vendaraPayment action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const vendaraPayment = async (params) => {
7
- return await commandFrameClient.call("vendaraPayment", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { VendaraPayment } from "./types";
2
- export declare const mockVendaraPayment: VendaraPayment;
@@ -1,11 +0,0 @@
1
- import { MOCK_ORDERS } from "../../demo/database";
2
- export const mockVendaraPayment = async (params) => {
3
- console.log("[Mock] vendaraPayment called", params);
4
- return {
5
- success: true,
6
- amount: params?.amount || null,
7
- paymentType: "vendara",
8
- order: MOCK_ORDERS[0],
9
- timestamp: new Date().toISOString()
10
- };
11
- };
@@ -1,26 +0,0 @@
1
- import { CFOrder } from "../../CommonTypes";
2
- import type { CFTransitionResult } from "../../common-types/order-state";
3
- export interface VendaraPaymentParams {
4
- /**
5
- * The amount to pay with this tender, in integer MINOR currency units
6
- * (e.g. 1575 = $15.75). Required. Semantics against the cart's balance due:
7
- * - missing → error
8
- * - less than balance → partial payment (the POS enters a fixed
9
- * split-payment leg for this amount)
10
- * - equal to balance → full payment
11
- * - more than balance → error
12
- */
13
- amount: number;
14
- /** Override the fulfillment state after full payment. Render resolves the cascade. */
15
- checkoutFulfillmentTarget?: string;
16
- }
17
- export interface VendaraPaymentResponse {
18
- success: boolean;
19
- amount: number | null;
20
- paymentType: string;
21
- order: CFOrder | null;
22
- timestamp: string;
23
- /** Present when the state machine blocked or forced the transition. */
24
- transitionResult?: CFTransitionResult;
25
- }
26
- export type VendaraPayment = (params?: VendaraPaymentParams) => Promise<VendaraPaymentResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import type { HookFunction, HookRegisterOptions } from "./types";
2
- /**
3
- * Register a session-scoped hook. The callback is serialized and sent to the host (Render);
4
- * once registered, it runs in the host context even when the extension iframe is not on the current page.
5
- * The callback must be self-contained (only use event, hostCommands, callCommand).
6
- * Uses options.hookId as a stable dedup key: re-registering with the same hookId replaces the previous hook.
7
- */
8
- declare function register(topic: string, callback: HookFunction, options: HookRegisterOptions): string;
9
- /**
10
- * Unregister a hook by ID. Sends a message to the host to remove the hook.
11
- */
12
- declare function unregister(hookId: string): void;
13
- export declare const hooks: {
14
- register: typeof register;
15
- unregister: typeof unregister;
16
- };
17
- export type { HookFunction, HookRegisterOptions } from "./types";
@@ -1,39 +0,0 @@
1
- const DEFAULT_ORIGIN = "*";
2
- function getOrigin() {
3
- return typeof window !== "undefined" ? window.__COMMAND_FRAME_ORIGIN__ ?? DEFAULT_ORIGIN : DEFAULT_ORIGIN;
4
- }
5
- /**
6
- * Register a session-scoped hook. The callback is serialized and sent to the host (Render);
7
- * once registered, it runs in the host context even when the extension iframe is not on the current page.
8
- * The callback must be self-contained (only use event, hostCommands, callCommand).
9
- * Uses options.hookId as a stable dedup key: re-registering with the same hookId replaces the previous hook.
10
- */
11
- function register(topic, callback, options) {
12
- const hookId = options.hookId;
13
- const functionBody = callback.toString();
14
- if (typeof window !== "undefined" && window.top && window.top !== window) {
15
- window.top.postMessage({
16
- type: "hook-register",
17
- topic,
18
- functionBody,
19
- eventTypes: options.eventTypes,
20
- hookId
21
- }, getOrigin());
22
- }
23
- return hookId;
24
- }
25
- /**
26
- * Unregister a hook by ID. Sends a message to the host to remove the hook.
27
- */
28
- function unregister(hookId) {
29
- if (typeof window !== "undefined" && window.top && window.top !== window) {
30
- window.top.postMessage({
31
- type: "hook-unregister",
32
- hookId
33
- }, getOrigin());
34
- }
35
- }
36
- export const hooks = {
37
- register,
38
- unregister
39
- };
@@ -1,15 +0,0 @@
1
- import type { TopicEvent } from "../pubsub/types";
2
- /**
3
- * Function signature for extension hook callbacks.
4
- * The function is serialized and sent to the host; it receives event and hostCommands when executed.
5
- */
6
- export type HookFunction = (event: TopicEvent, hostCommands: Record<string, (params?: any) => Promise<any>>, callCommand: (action: string, params?: any) => Promise<any>) => void | Promise<void>;
7
- /**
8
- * Options when registering a hook from the extension iframe.
9
- */
10
- export interface HookRegisterOptions {
11
- /** Stable identifier for this hook. Used to deduplicate on reload. Must be unique per hook. */
12
- hookId: string;
13
- /** Only fire for these event types; omit to receive all events for the topic */
14
- eventTypes?: string[];
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorOverlayContext } from "./types";
2
- /** Register a session-scoped interceptor for a named point. Callback is serialized to the host. */
3
- declare function register(point: InterceptorPoint, callback: InterceptorFunction, options: InterceptorRegisterOptions): string;
4
- declare function unregister(interceptorId: string): void;
5
- /** Register a handler invoked when this iframe is opened as an overlay by the host. */
6
- declare function onOverlay(handler: (ctx: InterceptorOverlayContext) => void): void;
7
- /** Continue the gated flow, merging `data` into the flow payload. */
8
- declare function resolve(data: Record<string, any>): Promise<void>;
9
- /** Continue the gated flow with no data. */
10
- declare function proceed(): Promise<void>;
11
- /** Stop the gated flow. */
12
- declare function cancel(): Promise<void>;
13
- export declare const interceptors: {
14
- register: typeof register;
15
- unregister: typeof unregister;
16
- onOverlay: typeof onOverlay;
17
- resolve: typeof resolve;
18
- proceed: typeof proceed;
19
- cancel: typeof cancel;
20
- };
21
- export type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorReturn, InterceptorOverlayContext, InterceptorHostCommands } from "./types";
@@ -1,53 +0,0 @@
1
- import { commandFrameClient } from "../client";
2
- const DEFAULT_ORIGIN = "*";
3
- function getOrigin() {
4
- return typeof window !== "undefined" ? window.__COMMAND_FRAME_ORIGIN__ ?? DEFAULT_ORIGIN : DEFAULT_ORIGIN;
5
- }
6
- let overlayId = null;
7
- let overlayContext = null;
8
- let overlayHandler = null;
9
- if (typeof window !== "undefined") {
10
- window.addEventListener("message", (event) => {
11
- const data = event.data;
12
- if (data && data.type === "interceptor-overlay-init" && typeof data.overlayId === "string") {
13
- overlayId = data.overlayId;
14
- overlayContext = { point: data.point, payload: data.payload };
15
- if (overlayHandler)
16
- overlayHandler(overlayContext);
17
- }
18
- });
19
- }
20
- /** Register a session-scoped interceptor for a named point. Callback is serialized to the host. */
21
- function register(point, callback, options) {
22
- const interceptorId = options.interceptorId;
23
- const functionBody = callback.toString();
24
- if (typeof window !== "undefined" && window.top && window.top !== window) {
25
- window.top.postMessage({ type: "interceptor-register", point, functionBody, interceptorId, timeoutMs: options.timeoutMs }, getOrigin());
26
- }
27
- return interceptorId;
28
- }
29
- function unregister(interceptorId) {
30
- if (typeof window !== "undefined" && window.top && window.top !== window) {
31
- window.top.postMessage({ type: "interceptor-unregister", interceptorId }, getOrigin());
32
- }
33
- }
34
- /** Register a handler invoked when this iframe is opened as an overlay by the host. */
35
- function onOverlay(handler) {
36
- overlayHandler = handler;
37
- if (overlayContext)
38
- handler(overlayContext);
39
- }
40
- async function report(result) {
41
- if (!overlayId) {
42
- console.warn("[interceptors] report called outside an overlay context — ignored");
43
- return;
44
- }
45
- await commandFrameClient.call("resolveExtensionOverlay", { overlayId, result });
46
- }
47
- /** Continue the gated flow, merging `data` into the flow payload. */
48
- function resolve(data) { return report(data); }
49
- /** Continue the gated flow with no data. */
50
- function proceed() { return report(true); }
51
- /** Stop the gated flow. */
52
- function cancel() { return report(false); }
53
- export const interceptors = { register, unregister, onOverlay, resolve, proceed, cancel };
@@ -1,26 +0,0 @@
1
- /**
2
- * Interceptors let an installed extension gate a host flow at a named point.
3
- * Registration mirrors hooks: the callback is serialized and reconstructed on the host,
4
- * so it must be self-contained (use only its payload arg and the injected host commands).
5
- */
6
- export type InterceptorPoint = "refund_start";
7
- /** false = stop the flow; true = continue, no data; object = continue and merge into the flow payload. */
8
- export type InterceptorReturn<T extends Record<string, any> = Record<string, any>> = boolean | T;
9
- export interface InterceptorHostCommands {
10
- openExtensionOverlay: (params: {
11
- point: InterceptorPoint;
12
- payload?: any;
13
- }) => Promise<InterceptorReturn>;
14
- [command: string]: (params?: any) => Promise<any>;
15
- }
16
- export type InterceptorFunction = (payload: any, cmds: InterceptorHostCommands, callCommand: (action: string, params?: any) => Promise<any>) => InterceptorReturn | Promise<InterceptorReturn>;
17
- export interface InterceptorRegisterOptions {
18
- /** Stable id; re-registering with the same id replaces the previous one. */
19
- interceptorId: string;
20
- /** Per-interceptor timeout override (ms). */
21
- timeoutMs?: number;
22
- }
23
- export interface InterceptorOverlayContext {
24
- point: InterceptorPoint;
25
- payload: any;
26
- }
@@ -1 +0,0 @@
1
- export {};