@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
@@ -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;
@@ -82,6 +81,7 @@ export declare const command: {
82
81
  readonly processPartialRefund: import(".").ProcessPartialRefund;
83
82
  readonly redeemRefund: import(".").RedeemRefund;
84
83
  readonly getRefundPlan: import(".").GetRefundPlan;
84
+ readonly checkPermission: import(".").CheckPermission;
85
85
  readonly addProduct: import(".").AddProduct;
86
86
  readonly editProduct: import(".").EditProduct;
87
87
  readonly editProductVariants: import(".").EditProductVariants;
@@ -142,9 +142,8 @@ export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantities
142
142
  export type { ProcessPartialRefund, ProcessPartialRefundParams, ProcessPartialRefundResponse, } from './actions/process-partial-refund/types';
143
143
  export type { RedeemRefund, RedeemRefundParams, RedeemRefundResponse } from './actions/redeem-refund/types';
144
144
  export type { GetRefundPlan, GetRefundPlanParams, GetRefundPlanResponse, RefundPlanSource, } from './actions/get-refund-plan/types';
145
+ export type { CheckPermission, CheckPermissionParams, CheckPermissionResponse, } from './actions/check-permission/types';
145
146
  export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } from './actions/initiate-refund/types';
146
- export type { OpenExtensionOverlay, OpenExtensionOverlayParams, OpenExtensionOverlayResponse, } from './actions/open-extension-overlay/types';
147
- export type { ResolveExtensionOverlay, ResolveExtensionOverlayParams, ResolveExtensionOverlayResponse, } from './actions/resolve-extension-overlay/types';
148
147
  export type { GetCurrentCart, GetCurrentCartResponse } from './actions/get-current-cart/types';
149
148
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse, } from './actions/add-product-discount/types';
150
149
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse, } from './actions/add-product-to-cart/types';
@@ -171,7 +170,6 @@ export type { CashPayment, CashPaymentParams, CashPaymentResponse } from './acti
171
170
  export type { GetCashRoundingAmount, GetCashRoundingAmountParams, GetCashRoundingAmountResponse, } from './actions/get-cash-rounding-amount/types';
172
171
  export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse, } from './actions/tap-to-pay-payment/types';
173
172
  export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from './actions/terminal-payment/types';
174
- export type { VendaraPayment, VendaraPaymentParams, VendaraPaymentResponse } from './actions/vendara-payment/types';
175
173
  export type { ExtensionPayment, ExtensionPaymentParams, ExtensionPaymentResponse, } from './actions/extension-payment/types';
176
174
  export type { RedeemPayment, RedeemPaymentParams, RedeemPaymentResponse } from './actions/redeem-payment/types';
177
175
  export type { IntegrationPayment, IntegrationPaymentParams, IntegrationPaymentResponse, IntegrationEmvData, } from './actions/integration-payment/types';
@@ -224,10 +222,6 @@ export type { PostMessageRequest, PostMessageResponse } from './client';
224
222
  export { topics } from './pubsub/topics';
225
223
  export type { TopicDefinition, TopicEvent, TopicEventType, TopicSubscriptionCallback, TopicSubscription, HookCallback, HookOptions, HookRegistration, } from './pubsub/types';
226
224
  export type { TopicEventPayloadMap } from './pubsub/topics/types';
227
- export { hooks } from './hooks';
228
- export type { HookFunction, HookRegisterOptions } from './hooks';
229
- export { interceptors } from './interceptors';
230
- export type { InterceptorFunction, InterceptorPoint, InterceptorRegisterOptions, InterceptorReturn, InterceptorOverlayContext, InterceptorHostCommands, } from './interceptors';
231
225
  export { customersTopic } from './pubsub/topics/customers';
232
226
  export { ordersTopic } from './pubsub/topics/orders';
233
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';
@@ -89,6 +88,7 @@ import { getRemainingRefundableQuantities } from './actions/get-remaining-refund
89
88
  import { processPartialRefund } from './actions/process-partial-refund/action';
90
89
  import { redeemRefund } from './actions/redeem-refund/action';
91
90
  import { getRefundPlan } from './actions/get-refund-plan/action';
91
+ import { checkPermission } from './actions/check-permission/action';
92
92
  // Custom Tables Actions
93
93
  import { getCustomTables } from './actions/get-custom-tables/action';
94
94
  import { getCustomTableFields } from './actions/get-custom-table-fields/action';
@@ -171,7 +171,6 @@ export const command = {
171
171
  getCashRoundingAmount,
172
172
  tapToPayPayment,
173
173
  terminalPayment,
174
- vendaraPayment,
175
174
  extensionPayment,
176
175
  redeemPayment,
177
176
  integrationPayment,
@@ -221,6 +220,7 @@ export const command = {
221
220
  processPartialRefund,
222
221
  redeemRefund,
223
222
  getRefundPlan,
223
+ checkPermission,
224
224
  // Product CRUD Actions
225
225
  addProduct,
226
226
  editProduct,
@@ -275,10 +275,6 @@ export * from './projects/manage';
275
275
  export { commandFrameClient, CommandFrameClient } from './client';
276
276
  // Export Pub/Sub
277
277
  export { topics } from './pubsub/topics';
278
- // Export Hooks (extension iframe API for session-scoped event callbacks)
279
- export { hooks } from './hooks';
280
- // Export Interceptors (extension iframe API for gating host flows)
281
- export { interceptors } from './interceptors';
282
278
  // Export Pub/Sub Topics
283
279
  export { customersTopic } from './pubsub/topics/customers';
284
280
  export { ordersTopic } from './pubsub/topics/orders';
@@ -44,14 +44,13 @@ 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';
52
50
  import { mockProcessPartialRefund } from '../../actions/process-partial-refund/mock';
53
51
  import { mockRedeemRefund } from '../../actions/redeem-refund/mock';
54
52
  import { mockGetRefundPlan } from '../../actions/get-refund-plan/mock';
53
+ import { mockCheckPermission } from '../../actions/check-permission/mock';
55
54
  import { mockRemoveCustomerFromCart } from '../../actions/remove-customer-from-cart/mock';
56
55
  import { mockResetRefundDetails } from '../../actions/reset-refund-details/mock';
57
56
  import { mockResumeParkedOrder } from '../../actions/resume-parked-order/mock';
@@ -62,7 +61,6 @@ import { mockShowNotification } from '../../actions/show-notification/mock';
62
61
  import { mockSwitchUser } from '../../actions/switch-user/mock';
63
62
  import { mockTapToPayPayment } from '../../actions/tap-to-pay-payment/mock';
64
63
  import { mockTerminalPayment } from '../../actions/terminal-payment/mock';
65
- import { mockVendaraPayment } from '../../actions/vendara-payment/mock';
66
64
  import { mockExtensionPayment } from '../../actions/extension-payment/mock';
67
65
  import { mockRedeemPayment } from '../../actions/redeem-payment/mock';
68
66
  import { mockIntegrationPayment } from '../../actions/integration-payment/mock';
@@ -140,14 +138,13 @@ export const RENDER_MOCKS = {
140
138
  getRemainingRefundableQuantities: mockGetRemainingRefundableQuantities,
141
139
  goToStationHome: mockGoToStationHome,
142
140
  initiateRefund: mockInitiateRefund,
143
- openExtensionOverlay: mockOpenExtensionOverlay,
144
- resolveExtensionOverlay: mockResolveExtensionOverlay,
145
141
  openCashDrawer: mockOpenCashDrawer,
146
142
  parkOrder: mockParkOrder,
147
143
  partialPayment: mockPartialPayment,
148
144
  processPartialRefund: mockProcessPartialRefund,
149
145
  redeemRefund: mockRedeemRefund,
150
146
  getRefundPlan: mockGetRefundPlan,
147
+ checkPermission: mockCheckPermission,
151
148
  removeCustomerFromCart: mockRemoveCustomerFromCart,
152
149
  removeCartDiscount: mockRemoveCartDiscount,
153
150
  resetRefundDetails: mockResetRefundDetails,
@@ -159,7 +156,6 @@ export const RENDER_MOCKS = {
159
156
  switchUser: mockSwitchUser,
160
157
  tapToPayPayment: mockTapToPayPayment,
161
158
  terminalPayment: mockTerminalPayment,
162
- vendaraPayment: mockVendaraPayment,
163
159
  extensionPayment: mockExtensionPayment,
164
160
  redeemPayment: mockRedeemPayment,
165
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, 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;
@@ -66,6 +61,7 @@ export interface RenderProviderActions {
66
61
  processPartialRefund: ProcessPartialRefund;
67
62
  redeemRefund: RedeemRefund;
68
63
  getRefundPlan: GetRefundPlan;
64
+ checkPermission: CheckPermission;
69
65
  getCurrentCart: GetCurrentCart;
70
66
  print: Print;
71
67
  setActiveOrder: SetActiveOrder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.4.1-preprod.2",
3
+ "version": "0.5.0-preprod.1",
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 {};