@final-commerce/command-frame 0.4.1-preprod.2 → 0.5.0-preprod.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 (66) hide show
  1. package/README.md +5 -56
  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/check-permission/action.d.ts +6 -0
  11. package/dist/actions/check-permission/action.js +8 -0
  12. package/dist/actions/check-permission/mock.d.ts +8 -0
  13. package/dist/actions/check-permission/mock.js +18 -0
  14. package/dist/actions/check-permission/types.d.ts +17 -0
  15. package/dist/actions/check-permission/types.js +9 -0
  16. package/dist/actions/delete-parked-order/types.d.ts +0 -3
  17. package/dist/actions/extension-payment/mock.js +5 -1
  18. package/dist/actions/extension-payment/types.d.ts +10 -5
  19. package/dist/actions/get-custom-table-data/types.d.ts +2 -4
  20. package/dist/actions/get-final-context/mock.js +1 -1
  21. package/dist/actions/initiate-refund/types.d.ts +0 -3
  22. package/dist/actions/integration-payment/types.d.ts +5 -5
  23. package/dist/actions/park-order/types.d.ts +0 -3
  24. package/dist/actions/partial-payment/types.d.ts +0 -5
  25. package/dist/actions/print/mock.js +2 -0
  26. package/dist/actions/print/types.d.ts +7 -0
  27. package/dist/actions/process-partial-refund/types.d.ts +0 -3
  28. package/dist/actions/redeem-payment/types.d.ts +2 -2
  29. package/dist/actions/resume-parked-order/types.d.ts +0 -3
  30. package/dist/actions/tap-to-pay-payment/mock.js +5 -1
  31. package/dist/actions/tap-to-pay-payment/types.d.ts +9 -4
  32. package/dist/actions/terminal-payment/mock.js +5 -1
  33. package/dist/actions/terminal-payment/types.d.ts +11 -6
  34. package/dist/actions/upsert-custom-table-data/types.d.ts +11 -1
  35. package/dist/actions/void-order/types.d.ts +0 -3
  36. package/dist/index.d.ts +2 -8
  37. package/dist/index.js +2 -6
  38. package/dist/projects/render/mocks.js +2 -6
  39. package/dist/projects/render/types.d.ts +2 -6
  40. package/package.json +1 -1
  41. package/dist/actions/open-extension-overlay/action.d.ts +0 -2
  42. package/dist/actions/open-extension-overlay/action.js +0 -4
  43. package/dist/actions/open-extension-overlay/mock.d.ts +0 -2
  44. package/dist/actions/open-extension-overlay/mock.js +0 -1
  45. package/dist/actions/open-extension-overlay/types.d.ts +0 -9
  46. package/dist/actions/open-extension-overlay/types.js +0 -1
  47. package/dist/actions/resolve-extension-overlay/action.d.ts +0 -2
  48. package/dist/actions/resolve-extension-overlay/action.js +0 -4
  49. package/dist/actions/resolve-extension-overlay/mock.d.ts +0 -2
  50. package/dist/actions/resolve-extension-overlay/mock.js +0 -1
  51. package/dist/actions/resolve-extension-overlay/types.d.ts +0 -9
  52. package/dist/actions/resolve-extension-overlay/types.js +0 -1
  53. package/dist/actions/vendara-payment/action.d.ts +0 -6
  54. package/dist/actions/vendara-payment/action.js +0 -8
  55. package/dist/actions/vendara-payment/mock.d.ts +0 -2
  56. package/dist/actions/vendara-payment/mock.js +0 -11
  57. package/dist/actions/vendara-payment/types.d.ts +0 -26
  58. package/dist/actions/vendara-payment/types.js +0 -1
  59. package/dist/hooks/index.d.ts +0 -17
  60. package/dist/hooks/index.js +0 -39
  61. package/dist/hooks/types.d.ts +0 -15
  62. package/dist/hooks/types.js +0 -1
  63. package/dist/interceptors/index.d.ts +0 -21
  64. package/dist/interceptors/index.js +0 -53
  65. package/dist/interceptors/types.d.ts +0 -26
  66. 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,9 +14,7 @@ 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
- | **Refund commands** | Refund payments to gift cards or redeem tenders via `redeemRefund`, or mixed-destination legs on `processPartialRefund`; query engine capacity with `getRefundPlan` | Request/response per call |
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)**.
22
20
 
@@ -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>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Check permission action
3
+ * Calls the checkPermission action on the parent window
4
+ */
5
+ import type { CheckPermission } from './types';
6
+ export declare const checkPermission: CheckPermission;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Check permission action
3
+ * Calls the checkPermission action on the parent window
4
+ */
5
+ import { commandFrameClient } from '../../client';
6
+ export const checkPermission = async (params) => {
7
+ return await commandFrameClient.call('checkPermission', params);
8
+ };
@@ -0,0 +1,8 @@
1
+ import { CheckPermission } from './types';
2
+ /**
3
+ * Standalone mock: `allowed: true` for every permission EXCEPT the magic name
4
+ * `'mock_denied'`, which returns `allowed: false` — so flows can exercise both
5
+ * UI branches outside the iframe. The runtime answers from the hydrated
6
+ * active user's role instead.
7
+ */
8
+ export declare const mockCheckPermission: CheckPermission;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Standalone mock: `allowed: true` for every permission EXCEPT the magic name
3
+ * `'mock_denied'`, which returns `allowed: false` — so flows can exercise both
4
+ * UI branches outside the iframe. The runtime answers from the hydrated
5
+ * active user's role instead.
6
+ */
7
+ export const mockCheckPermission = async (params) => {
8
+ console.log('[Mock] checkPermission called', params);
9
+ if (!params?.permission) {
10
+ throw new Error('permission is required');
11
+ }
12
+ return {
13
+ success: true,
14
+ permission: params.permission,
15
+ allowed: params.permission !== 'mock_denied',
16
+ timestamp: new Date().toISOString(),
17
+ };
18
+ };
@@ -0,0 +1,17 @@
1
+ export interface CheckPermissionParams {
2
+ /** Permission name, e.g. 'issue_refunds'. */
3
+ permission: string;
4
+ }
5
+ export interface CheckPermissionResponse {
6
+ success: boolean;
7
+ /** Echo of the permission that was checked. */
8
+ permission: string;
9
+ /**
10
+ * True when the active user holds the permission — either explicitly on
11
+ * their role, or implicitly because their user type does not carry a role
12
+ * (company owner, final/org staff).
13
+ */
14
+ allowed: boolean;
15
+ timestamp: string;
16
+ }
17
+ export type CheckPermission = (params: CheckPermissionParams) => Promise<CheckPermissionResponse>;
@@ -0,0 +1,9 @@
1
+ // Check Permission Types
2
+ //
3
+ // READ-ONLY query: does the ACTIVE user hold a named permission? Truth source
4
+ // is the runtime's hydrated active user (role + permissions from the synced
5
+ // `users`/`roles` collections). Use it to PRE-GATE UI (hide/disable a Refund
6
+ // button, show "You are not allowed to initiate refunds") — it is not the
7
+ // security boundary: mutating refund commands enforce `issue_refunds`
8
+ // runtime-side regardless (`REFUND_PERMISSION_DENIED: ` prefix).
9
+ export {};
@@ -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
  };
@@ -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>;