@final-commerce/command-frame 0.0.1 → 0.0.4

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 (140) hide show
  1. package/README.md +62 -7
  2. package/dist/CommonTypes.d.ts +469 -0
  3. package/dist/CommonTypes.js +21 -0
  4. package/dist/actions/add-cart-discount/mock.d.ts +2 -0
  5. package/dist/actions/add-cart-discount/mock.js +27 -0
  6. package/dist/actions/add-cart-fee/mock.d.ts +2 -0
  7. package/dist/actions/add-cart-fee/mock.js +31 -0
  8. package/dist/actions/add-custom-sale/mock.d.ts +2 -0
  9. package/dist/actions/add-custom-sale/mock.js +12 -0
  10. package/dist/actions/add-customer/mock.d.ts +2 -0
  11. package/dist/actions/add-customer/mock.js +23 -0
  12. package/dist/actions/add-customer/types.d.ts +3 -2
  13. package/dist/actions/add-customer-note/mock.d.ts +2 -0
  14. package/dist/actions/add-customer-note/mock.js +9 -0
  15. package/dist/actions/add-order-note/mock.d.ts +2 -0
  16. package/dist/actions/add-order-note/mock.js +8 -0
  17. package/dist/actions/add-product-discount/mock.d.ts +2 -0
  18. package/dist/actions/add-product-discount/mock.js +10 -0
  19. package/dist/actions/add-product-fee/mock.d.ts +2 -0
  20. package/dist/actions/add-product-fee/mock.js +11 -0
  21. package/dist/actions/add-product-note/mock.d.ts +2 -0
  22. package/dist/actions/add-product-note/mock.js +8 -0
  23. package/dist/actions/add-product-to-cart/mock.d.ts +2 -0
  24. package/dist/actions/add-product-to-cart/mock.js +56 -0
  25. package/dist/actions/add-product-to-cart/types.d.ts +2 -0
  26. package/dist/actions/adjust-inventory/mock.d.ts +2 -0
  27. package/dist/actions/adjust-inventory/mock.js +18 -0
  28. package/dist/actions/assign-customer/mock.d.ts +2 -0
  29. package/dist/actions/assign-customer/mock.js +14 -0
  30. package/dist/actions/assign-customer/types.d.ts +2 -1
  31. package/dist/actions/authenticate-user/mock.d.ts +2 -0
  32. package/dist/actions/authenticate-user/mock.js +8 -0
  33. package/dist/actions/calculate-refund-total/mock.d.ts +2 -0
  34. package/dist/actions/calculate-refund-total/mock.js +14 -0
  35. package/dist/actions/calculate-refund-total/types.d.ts +3 -2
  36. package/dist/actions/cash-payment/mock.d.ts +2 -0
  37. package/dist/actions/cash-payment/mock.js +14 -0
  38. package/dist/actions/cash-payment/types.d.ts +2 -1
  39. package/dist/actions/clear-cart/mock.d.ts +2 -0
  40. package/dist/actions/clear-cart/mock.js +9 -0
  41. package/dist/actions/delete-parked-order/mock.d.ts +2 -0
  42. package/dist/actions/delete-parked-order/mock.js +8 -0
  43. package/dist/actions/example-function/mock.d.ts +2 -0
  44. package/dist/actions/example-function/mock.js +13 -0
  45. package/dist/actions/get-categories/mock.d.ts +2 -0
  46. package/dist/actions/get-categories/mock.js +20 -0
  47. package/dist/actions/get-categories/types.d.ts +2 -1
  48. package/dist/actions/get-context/mock.d.ts +2 -0
  49. package/dist/actions/get-context/mock.js +24 -0
  50. package/dist/actions/get-context/types.d.ts +2 -16
  51. package/dist/actions/get-current-cart/mock.d.ts +2 -0
  52. package/dist/actions/get-current-cart/mock.js +9 -0
  53. package/dist/actions/get-current-cart/types.d.ts +2 -1
  54. package/dist/actions/get-customers/mock.d.ts +2 -0
  55. package/dist/actions/get-customers/mock.js +17 -0
  56. package/dist/actions/get-customers/types.d.ts +2 -1
  57. package/dist/actions/get-final-context/action.d.ts +6 -0
  58. package/dist/actions/get-final-context/action.js +8 -0
  59. package/dist/actions/get-final-context/types.d.ts +4 -0
  60. package/dist/actions/get-final-context/types.js +1 -0
  61. package/dist/actions/get-line-items-by-order/mock.d.ts +2 -0
  62. package/dist/actions/get-line-items-by-order/mock.js +12 -0
  63. package/dist/actions/get-line-items-by-order/types.d.ts +3 -2
  64. package/dist/actions/get-orders/mock.d.ts +2 -0
  65. package/dist/actions/get-orders/mock.js +104 -0
  66. package/dist/actions/get-orders/types.d.ts +2 -1
  67. package/dist/actions/get-product-variants/mock.d.ts +2 -0
  68. package/dist/actions/get-product-variants/mock.js +14 -0
  69. package/dist/actions/get-product-variants/types.d.ts +2 -1
  70. package/dist/actions/get-products/mock.d.ts +2 -0
  71. package/dist/actions/get-products/mock.js +31 -0
  72. package/dist/actions/get-products/types.d.ts +2 -1
  73. package/dist/actions/get-refunds/mock.d.ts +2 -0
  74. package/dist/actions/get-refunds/mock.js +9 -0
  75. package/dist/actions/get-refunds/types.d.ts +2 -1
  76. package/dist/actions/get-remaining-refundable-quantities/mock.d.ts +2 -0
  77. package/dist/actions/get-remaining-refundable-quantities/mock.js +9 -0
  78. package/dist/actions/go-to-page/mock.d.ts +2 -0
  79. package/dist/actions/go-to-page/mock.js +8 -0
  80. package/dist/actions/go-to-station-home/mock.d.ts +2 -0
  81. package/dist/actions/go-to-station-home/mock.js +7 -0
  82. package/dist/actions/initiate-refund/mock.d.ts +2 -0
  83. package/dist/actions/initiate-refund/mock.js +8 -0
  84. package/dist/actions/open-cash-drawer/mock.d.ts +2 -0
  85. package/dist/actions/open-cash-drawer/mock.js +7 -0
  86. package/dist/actions/open-popup/mock.d.ts +2 -0
  87. package/dist/actions/open-popup/mock.js +8 -0
  88. package/dist/actions/park-order/mock.d.ts +2 -0
  89. package/dist/actions/park-order/mock.js +9 -0
  90. package/dist/actions/park-order/types.d.ts +2 -1
  91. package/dist/actions/partial-payment/mock.d.ts +2 -0
  92. package/dist/actions/partial-payment/mock.js +12 -0
  93. package/dist/actions/partial-payment/types.d.ts +2 -1
  94. package/dist/actions/process-partial-refund/mock.d.ts +2 -0
  95. package/dist/actions/process-partial-refund/mock.js +8 -0
  96. package/dist/actions/remove-customer-from-cart/mock.d.ts +2 -0
  97. package/dist/actions/remove-customer-from-cart/mock.js +9 -0
  98. package/dist/actions/reset-refund-details/mock.d.ts +2 -0
  99. package/dist/actions/reset-refund-details/mock.js +7 -0
  100. package/dist/actions/resume-parked-order/mock.d.ts +2 -0
  101. package/dist/actions/resume-parked-order/mock.js +9 -0
  102. package/dist/actions/resume-parked-order/types.d.ts +2 -1
  103. package/dist/actions/select-all-refund-items/mock.d.ts +2 -0
  104. package/dist/actions/select-all-refund-items/mock.js +8 -0
  105. package/dist/actions/set-product-active/mock.d.ts +2 -0
  106. package/dist/actions/set-product-active/mock.js +8 -0
  107. package/dist/actions/set-refund-stock-action/mock.d.ts +2 -0
  108. package/dist/actions/set-refund-stock-action/mock.js +9 -0
  109. package/dist/actions/show-confirmation/mock.d.ts +2 -0
  110. package/dist/actions/show-confirmation/mock.js +9 -0
  111. package/dist/actions/show-notification/mock.d.ts +2 -0
  112. package/dist/actions/show-notification/mock.js +8 -0
  113. package/dist/actions/switch-user/mock.d.ts +2 -0
  114. package/dist/actions/switch-user/mock.js +10 -0
  115. package/dist/actions/tap-to-pay-payment/mock.d.ts +2 -0
  116. package/dist/actions/tap-to-pay-payment/mock.js +11 -0
  117. package/dist/actions/tap-to-pay-payment/types.d.ts +2 -1
  118. package/dist/actions/terminal-payment/mock.d.ts +2 -0
  119. package/dist/actions/terminal-payment/mock.js +14 -0
  120. package/dist/actions/terminal-payment/types.d.ts +2 -1
  121. package/dist/actions/toggle-slide-out/mock.d.ts +2 -0
  122. package/dist/actions/toggle-slide-out/mock.js +8 -0
  123. package/dist/actions/trigger-webhook/mock.d.ts +2 -0
  124. package/dist/actions/trigger-webhook/mock.js +8 -0
  125. package/dist/actions/trigger-zapier-webhook/mock.d.ts +2 -0
  126. package/dist/actions/trigger-zapier-webhook/mock.js +8 -0
  127. package/dist/actions/update-customer-facing-display/mock.d.ts +2 -0
  128. package/dist/actions/update-customer-facing-display/mock.js +8 -0
  129. package/dist/actions/vendara-payment/mock.d.ts +2 -0
  130. package/dist/actions/vendara-payment/mock.js +11 -0
  131. package/dist/actions/vendara-payment/types.d.ts +2 -1
  132. package/dist/client.d.ts +4 -1
  133. package/dist/client.js +63 -2
  134. package/dist/demo/database.d.ts +45 -0
  135. package/dist/demo/database.js +515 -0
  136. package/dist/demo/registry.d.ts +5 -0
  137. package/dist/demo/registry.js +106 -0
  138. package/dist/index.d.ts +1 -0
  139. package/dist/types.d.ts +6 -5
  140. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @final-commerce/command-frame
2
2
 
3
- A TypeScript library for communication between iframes and their parent windows using postMessage with type safety and error handling.
3
+ A TypeScript library for communication between iframes and their parent windows using postMessage with type safety and error handling. test.
4
4
 
5
5
  ## Installation
6
6
 
@@ -31,7 +31,10 @@ The library provides a `command` namespace object containing all available actio
31
31
  - **[getProducts](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-products/README.md)** - Retrieve a list of products from the parent application
32
32
  - **[getCategories](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-categories/README.md)** - Retrieve a list of categories from the parent application
33
33
  - **[getProductVariants](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-product-variants/README.md)** - Retrieve all variants for a specific product
34
+ - **[getOrders](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-orders/README.md)** - Retrieve a list of orders from the system with optional filtering, sorting, and pagination
35
+ - **[getCurrentCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-current-cart/README.md)** - Retrieve the current cart object with all its contents
34
36
  - **[getContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-context/README.md)** - Get current environment/context information (user, company, device, station, outlet, build)
37
+ - **[getFinalContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-final-context/README.md)** - Get final context information (project name)
35
38
 
36
39
  #### Product Actions
37
40
  - **[setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)** - Set a product variant as the active product
@@ -50,7 +53,6 @@ The library provides a `command` namespace object containing all available actio
50
53
  - **[parkOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/park-order/README.md)** - Park (save) the current order for later retrieval
51
54
  - **[resumeParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/resume-parked-order/README.md)** - Resume a previously parked order
52
55
  - **[deleteParkedOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/delete-parked-order/README.md)** - Delete a parked order
53
- - **[reorderActiveOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reorder-active-order/README.md)** - Reorder items from the currently active order into the cart
54
56
  - **[initiateRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/initiate-refund/README.md)** - Open the refund UI for an order
55
57
  - **[cashPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/cash-payment/README.md)** - Initiate a cash payment
56
58
  - **[tapToPayPayment](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/tap-to-pay-payment/README.md)** - Initiate a tap-to-pay payment
@@ -76,6 +78,15 @@ The library provides a `command` namespace object containing all available actio
76
78
  - **[updateCustomerFacingDisplay](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/update-customer-facing-display/README.md)** - Update the customer-facing display to show a specific page
77
79
  - **[switchUser](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/switch-user/README.md)** - Switch the current user to a different user
78
80
 
81
+ #### Refund Actions
82
+ - **[getLineItemsByOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-line-items-by-order/README.md)** - Retrieve line items and custom sales from an order for refund purposes
83
+ - **[selectAllRefundItems](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/select-all-refund-items/README.md)** - Select all remaining refundable items for a full refund
84
+ - **[resetRefundDetails](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reset-refund-details/README.md)** - Clear all refund selections
85
+ - **[setRefundStockAction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-refund-stock-action/README.md)** - Set stock handling option (restock/damage) for a refunded item
86
+ - **[calculateRefundTotal](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/calculate-refund-total/README.md)** - Calculate refund total based on current selections
87
+ - **[processPartialRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/process-partial-refund/README.md)** - Process a partial refund based on current selections
88
+ - **[getRemainingRefundableQuantities](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-remaining-refundable-quantities/README.md)** - Get remaining refundable quantities for items in the active order
89
+
79
90
  #### Integration Actions
80
91
  - **[triggerWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-webhook/README.md)** - Trigger a webhook with the specified configuration
81
92
  - **[triggerZapierWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-zapier-webhook/README.md)** - Trigger a Zapier webhook with the current context data
@@ -163,6 +174,14 @@ Retrieves a list of categories from the parent application's local database. Sup
163
174
 
164
175
  Retrieves all variants for a specific product from the parent application's local database. Useful for displaying variant options or selecting a specific variant.
165
176
 
177
+ ### [getOrders](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-orders/README.md)
178
+
179
+ Retrieves a list of orders from the system with optional filtering, sorting, and pagination. Supports filtering by status, customer ID, session ID, and text search.
180
+
181
+ ### [getCurrentCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-current-cart/README.md)
182
+
183
+ Retrieves the current cart object with all its contents including products, custom sales, discounts, fees, totals, and customer information.
184
+
166
185
  ### [addCustomSale](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-custom-sale/README.md)
167
186
 
168
187
  Adds a custom sale item to the cart in the parent window. Useful for adding non-product items like service fees, discounts, or custom charges.
@@ -227,10 +246,6 @@ Resumes a previously parked order by loading it back into the cart.
227
246
 
228
247
  Deletes a parked order from the system.
229
248
 
230
- ### [reorderActiveOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reorder-active-order/README.md)
231
-
232
- Reorders the items from the currently active order into the cart. Products that are out of stock will not be added.
233
-
234
249
  ### [initiateRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/initiate-refund/README.md)
235
250
 
236
251
  Opens the refund UI for the specified order or the currently active order.
@@ -307,6 +322,36 @@ Updates the customer-facing display to show a specific page by page ID.
307
322
 
308
323
  Switches the current user to a different user. Supports three modes: dialog (select from all users), role (select from users with specific roles), or specific (switch to a specific user).
309
324
 
325
+ ### Refund Actions
326
+
327
+ ### [getLineItemsByOrder](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-line-items-by-order/README.md)
328
+
329
+ Retrieves line items and custom sales from an order, along with calculated remaining refundable quantities for each item.
330
+
331
+ ### [selectAllRefundItems](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/select-all-refund-items/README.md)
332
+
333
+ Selects all remaining refundable items (line items, custom sales, cart fees, and tips) for a full refund.
334
+
335
+ ### [resetRefundDetails](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/reset-refund-details/README.md)
336
+
337
+ Clears all refund selections (quantities, custom sales, cart fees, tips, and stock actions).
338
+
339
+ ### [setRefundStockAction](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-refund-stock-action/README.md)
340
+
341
+ Sets the stock handling option for a refunded line item (restock or mark as damaged).
342
+
343
+ ### [calculateRefundTotal](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/calculate-refund-total/README.md)
344
+
345
+ Calculates and returns a preview of the refund total based on current refund selections, without processing the refund.
346
+
347
+ ### [processPartialRefund](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/process-partial-refund/README.md)
348
+
349
+ Processes a partial refund based on the current refund selections in the refund details state.
350
+
351
+ ### [getRemainingRefundableQuantities](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-remaining-refundable-quantities/README.md)
352
+
353
+ Gets the remaining refundable quantities for all line items and custom sales in the active order.
354
+
310
355
  ### Integration Actions
311
356
 
312
357
  ### [triggerWebhook](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/trigger-webhook/README.md)
@@ -361,7 +406,10 @@ import type {
361
406
  GetProductsParams, GetProductsResponse, GetProducts,
362
407
  GetCategoriesParams, GetCategoriesResponse, GetCategories,
363
408
  GetProductVariantsParams, GetProductVariantsResponse, GetProductVariants,
409
+ GetOrdersParams, GetOrdersResponse, GetOrders,
364
410
  GetContext, GetContextResponse,
411
+ GetFinalContext, GetFinalContextResponse,
412
+ GetCurrentCart, GetCurrentCartResponse,
365
413
  // Product Actions
366
414
  SetProductActiveParams, SetProductActiveResponse, SetProductActive,
367
415
  AddProductDiscountParams, AddProductDiscountResponse, AddProductDiscount,
@@ -378,7 +426,6 @@ import type {
378
426
  ParkOrderResponse, ParkOrder,
379
427
  ResumeParkedOrderParams, ResumeParkedOrderResponse, ResumeParkedOrder,
380
428
  DeleteParkedOrderParams, DeleteParkedOrderResponse, DeleteParkedOrder,
381
- ReorderActiveOrderResponse, ReorderActiveOrder,
382
429
  InitiateRefundParams, InitiateRefundResponse, InitiateRefund,
383
430
  CashPaymentParams, CashPaymentResponse, CashPayment,
384
431
  TapToPayPaymentParams, TapToPayPaymentResponse, TapToPayPayment,
@@ -401,6 +448,14 @@ import type {
401
448
  AuthenticateUserParams, AuthenticateUserResponse, AuthenticateUser,
402
449
  UpdateCustomerFacingDisplayParams, UpdateCustomerFacingDisplayResponse, UpdateCustomerFacingDisplay,
403
450
  SwitchUserParams, SwitchUserResponse, SwitchUser,
451
+ // Refund Actions
452
+ GetLineItemsByOrderParams, GetLineItemsByOrderResponse, GetLineItemsByOrder,
453
+ SelectAllRefundItemsResponse, SelectAllRefundItems,
454
+ ResetRefundDetailsResponse, ResetRefundDetails,
455
+ SetRefundStockActionParams, SetRefundStockActionResponse, SetRefundStockAction,
456
+ CalculateRefundTotalResponse, CalculateRefundTotal,
457
+ ProcessPartialRefundParams, ProcessPartialRefundResponse, ProcessPartialRefund,
458
+ GetRemainingRefundableQuantitiesResponse, GetRemainingRefundableQuantities,
404
459
  // Integration Actions
405
460
  TriggerWebhookParams, TriggerWebhookResponse, TriggerWebhook,
406
461
  TriggerZapierWebhookParams, TriggerZapierWebhookResponse, TriggerZapierWebhook,
@@ -0,0 +1,469 @@
1
+ export declare enum CFProductType {
2
+ SIMPLE = "simple",
3
+ VARIABLE = "variable"
4
+ }
5
+ export declare enum CFUserTypes {
6
+ OWNER = "owner",
7
+ ORG_USER = "organization_user",
8
+ ORG_OWNER = "organization_owner",
9
+ FINAL_USER = "final_user",
10
+ FINAL_OWNER = "final_owner",
11
+ EMPLOYEE = "employee",
12
+ SUPER_ADMIN = "super_admin",
13
+ MANAGER = "manager",
14
+ ADMIN = "admin",
15
+ ASSISTANT_MANAGER = "assistant",
16
+ CASHIER = "cashier",
17
+ RESELLER = "reseller"
18
+ }
19
+ export interface CFActiveEntity {
20
+ }
21
+ export interface CFDiscount {
22
+ value: number;
23
+ label?: string;
24
+ isPercent?: boolean;
25
+ }
26
+ export interface CFCustomFee {
27
+ label: string;
28
+ amount: number;
29
+ isPercent: boolean;
30
+ applyTaxes: boolean;
31
+ taxTableId?: string;
32
+ }
33
+ export interface CFAddress {
34
+ firstName: string;
35
+ lastName: string;
36
+ company?: string | null;
37
+ city: string;
38
+ postCode: string;
39
+ province?: string;
40
+ state?: string;
41
+ country?: string;
42
+ address1: string;
43
+ address2: string;
44
+ }
45
+ export interface CFMetadataItem {
46
+ key: string;
47
+ value: string;
48
+ }
49
+ export interface CFTax {
50
+ id: string;
51
+ name: string;
52
+ percentage: number;
53
+ amount: string;
54
+ taxTableName: string;
55
+ taxTableId: string;
56
+ }
57
+ export interface CFInventory {
58
+ warehouse: string;
59
+ outletId: string;
60
+ stock?: number | null;
61
+ }
62
+ export interface CFCustomerNote {
63
+ createdAt: string;
64
+ message: string;
65
+ }
66
+ export interface CFOrderNote {
67
+ externalId?: string;
68
+ author?: string;
69
+ note?: string;
70
+ customerNote?: boolean;
71
+ addedByUser?: string;
72
+ dateCreated?: string;
73
+ }
74
+ export interface CFCategory {
75
+ _id: string;
76
+ companyId: string;
77
+ externalId: string;
78
+ name: string;
79
+ parentId: null | string;
80
+ __v?: number;
81
+ }
82
+ export interface CFProductVariant {
83
+ sku: string;
84
+ price: string;
85
+ salePrice: string;
86
+ isOnSale: boolean;
87
+ barcode?: string;
88
+ costPrice?: string;
89
+ manageStock: boolean;
90
+ externalId: string;
91
+ inventory?: CFInventory[];
92
+ allowBackorder?: boolean;
93
+ images?: string[];
94
+ attributes: {
95
+ name: string;
96
+ value?: string;
97
+ }[];
98
+ metadata?: {
99
+ key: string;
100
+ value: string;
101
+ }[];
102
+ _id: string;
103
+ }
104
+ export interface CFProduct {
105
+ _id: string;
106
+ companyId?: string;
107
+ externalId: string;
108
+ taxTable: string;
109
+ name: string;
110
+ description?: string;
111
+ shortDescription?: string;
112
+ images?: string[];
113
+ categories: {
114
+ name: string;
115
+ externalId: string;
116
+ };
117
+ attributes: {
118
+ name: string;
119
+ values: string[];
120
+ }[];
121
+ tags?: string[];
122
+ supplier?: string;
123
+ sku?: string;
124
+ productType: CFProductType;
125
+ variants: CFProductVariant[];
126
+ minPrice?: string;
127
+ maxPrice?: string;
128
+ price?: string;
129
+ status?: string;
130
+ isDeleted?: boolean;
131
+ }
132
+ export interface CFActiveProduct extends CFActiveEntity {
133
+ id: string;
134
+ internalId: string;
135
+ externalId: string;
136
+ productExternalId: string;
137
+ variantId: string;
138
+ name: string;
139
+ sku: string;
140
+ price: number;
141
+ images: string[];
142
+ taxTableId: string;
143
+ quantity: number;
144
+ note?: string;
145
+ discount?: CFDiscount;
146
+ description?: string;
147
+ longDescription?: string;
148
+ shortDescription?: string;
149
+ barcodeId?: string;
150
+ stock: number;
151
+ allowBackOrder?: boolean;
152
+ fee?: CFCustomFee;
153
+ isUnlimited?: boolean;
154
+ attributes?: string;
155
+ localQuantity?: number;
156
+ }
157
+ export interface CFCustomer {
158
+ _id: string;
159
+ companyId: any;
160
+ externalId?: string;
161
+ email: string;
162
+ firstName: string;
163
+ lastName: string;
164
+ fromOliver?: boolean;
165
+ phone?: string;
166
+ tags?: string[];
167
+ metadata?: Record<string, string>[];
168
+ notes?: CFCustomerNote[];
169
+ billing: CFAddress | null;
170
+ shipping: CFAddress | null;
171
+ }
172
+ export interface CFActiveCustomer extends CFCustomer {
173
+ id?: string;
174
+ }
175
+ export interface CFTip {
176
+ amount: string;
177
+ percentage: number;
178
+ }
179
+ export interface CFSummary {
180
+ discountTotal: string;
181
+ shippingTotal?: string | null;
182
+ total: string;
183
+ totalTaxes: string;
184
+ subTotal: string;
185
+ taxes: CFTax[];
186
+ tip?: CFTip | null;
187
+ isTaxInclusive: boolean;
188
+ }
189
+ export interface CFCartDiscountItem {
190
+ label: string;
191
+ amount: string;
192
+ percentage: number;
193
+ }
194
+ export interface CFCartFeeItem {
195
+ id: string;
196
+ label: string;
197
+ amount: string;
198
+ percentage: number;
199
+ taxTableId?: string;
200
+ tax?: string;
201
+ taxName: string;
202
+ }
203
+ export interface CFTipPayment {
204
+ amount: string;
205
+ tipTo: string;
206
+ percentage: number;
207
+ }
208
+ export interface CFRefundedTipPayment {
209
+ amount: string;
210
+ percentage: number;
211
+ transactionId: string;
212
+ tipTo: string;
213
+ }
214
+ export interface CFPaymentMethod {
215
+ transactionId: string;
216
+ paymentType: string;
217
+ amount: string;
218
+ timestamp: string;
219
+ processor: string;
220
+ saleId?: string;
221
+ change?: string | null;
222
+ tip?: CFTipPayment | null;
223
+ cashRounding?: number;
224
+ emv?: string | null;
225
+ }
226
+ export interface CFPosDataItem {
227
+ outlet: string;
228
+ station: string;
229
+ employee: string | {
230
+ _id?: string;
231
+ firstName: string;
232
+ lastName: string;
233
+ };
234
+ }
235
+ export interface CFDiscountDetail {
236
+ percentage: number;
237
+ amount: string;
238
+ }
239
+ export interface CFFeeDetail {
240
+ percentage: number;
241
+ amount: string;
242
+ tax: string;
243
+ taxTableId: string;
244
+ }
245
+ export interface CFDiscountLineItem {
246
+ itemDiscount: CFDiscountDetail;
247
+ cartDiscount: CFDiscountDetail;
248
+ }
249
+ export interface CFFeeLineItem {
250
+ itemFee: CFFeeDetail;
251
+ cartFee?: CFFeeDetail;
252
+ }
253
+ export interface CFLineItem {
254
+ productId: string;
255
+ variantExternalId?: string;
256
+ productExternalId?: string;
257
+ internalId?: string;
258
+ name: string;
259
+ quantity: number;
260
+ price: string;
261
+ taxes: CFTax[];
262
+ discount: CFDiscountLineItem;
263
+ fee: CFFeeLineItem;
264
+ totalTax: string;
265
+ total: string;
266
+ metadata: CFMetadataItem[];
267
+ image: string;
268
+ sku: string;
269
+ stock: number;
270
+ note?: string;
271
+ description?: string;
272
+ variantId: string;
273
+ images?: string[];
274
+ attributes?: string;
275
+ }
276
+ export interface CFCustomSale {
277
+ customSaleId: string;
278
+ name: string;
279
+ price: string;
280
+ quantity: number;
281
+ applyTaxes: boolean;
282
+ total: string;
283
+ totalTax: string;
284
+ taxes: CFTax[];
285
+ discount: {
286
+ cartDiscount: CFDiscountDetail;
287
+ };
288
+ fee: {
289
+ cartFee: {
290
+ amount: string;
291
+ label: string;
292
+ percentage: number;
293
+ tax: string;
294
+ taxTableId: string;
295
+ };
296
+ };
297
+ }
298
+ export interface CFRefundedLineItem {
299
+ productId: string;
300
+ variantId: string;
301
+ variantExternalId?: string;
302
+ productExternalId?: string;
303
+ internalId?: string;
304
+ name: string;
305
+ quantity: number;
306
+ price: string;
307
+ taxes: CFTax[];
308
+ discount: CFDiscountLineItem;
309
+ totalTax: string;
310
+ total: string;
311
+ image: string;
312
+ sku: string;
313
+ note?: string;
314
+ description?: string;
315
+ images?: string[];
316
+ fee: CFFeeLineItem;
317
+ }
318
+ export interface CFRefundedCustomSale extends CFCustomSale {
319
+ }
320
+ export interface CFRefundItem {
321
+ lineItems: CFRefundedLineItem[];
322
+ customSales: CFRefundedCustomSale[];
323
+ cartFees: CFCartFeeItem[];
324
+ tips: CFRefundedTipPayment[];
325
+ refundedBy: string;
326
+ timestamp: string | undefined;
327
+ summary?: CFSummary;
328
+ refundPayment: CFPaymentMethod[];
329
+ balance?: string;
330
+ receiptId?: string;
331
+ currency?: string;
332
+ }
333
+ export interface CFOrder {
334
+ _id: string;
335
+ receiptId?: string;
336
+ companyId: string;
337
+ externalId: string | null;
338
+ status: string;
339
+ customer: Partial<CFActiveCustomer | null>;
340
+ customerNote?: string;
341
+ summary: CFSummary;
342
+ cartDiscount: CFCartDiscountItem | null;
343
+ cartFees: CFCartFeeItem[] | null;
344
+ updatedAt?: string;
345
+ createdAt?: string;
346
+ paymentMethods: CFPaymentMethod[];
347
+ source: string;
348
+ posData: CFPosDataItem | null;
349
+ sessionId: string;
350
+ metadata: CFMetadataItem[];
351
+ notes?: CFOrderNote[] | null;
352
+ billing: CFAddress | null;
353
+ shipping: CFAddress | null;
354
+ lineItems: CFLineItem[];
355
+ customSales: CFCustomSale[];
356
+ refund?: CFRefundItem[];
357
+ balance: string;
358
+ signature?: string | null;
359
+ }
360
+ export interface CFActiveUserRole {
361
+ id?: string;
362
+ name: string;
363
+ permissions: {
364
+ category: string;
365
+ label: string;
366
+ name: string;
367
+ value: boolean;
368
+ }[];
369
+ }
370
+ export interface CFActiveUser extends CFActiveEntity {
371
+ firstName?: string;
372
+ lastName?: string;
373
+ role: CFActiveUserRole;
374
+ id: string;
375
+ outlets?: string[];
376
+ type?: CFUserTypes;
377
+ companies?: any;
378
+ }
379
+ export interface CFActiveOutlet extends CFActiveEntity {
380
+ address: string;
381
+ address2: string;
382
+ city: string;
383
+ state: string;
384
+ country?: string;
385
+ taxId: string;
386
+ postCode?: string;
387
+ name?: string;
388
+ stripe?: {
389
+ locationId: string;
390
+ };
391
+ id: string;
392
+ sequenceNumber: number;
393
+ _id?: string;
394
+ stripeAccountId: string;
395
+ }
396
+ export interface CFActiveStation {
397
+ _id: string;
398
+ sequenceNumber?: number;
399
+ name: string;
400
+ status: string;
401
+ buildSrcId?: string;
402
+ buildVersion?: string;
403
+ publishBuildId?: string;
404
+ createdAt?: string;
405
+ updatedAt?: string;
406
+ stripeTerminalId?: string;
407
+ }
408
+ export interface CFActiveOrder extends CFOrder {
409
+ id?: string;
410
+ internalId?: string;
411
+ user?: CFActiveUser;
412
+ outlet?: CFActiveOutlet;
413
+ isDeleted?: boolean;
414
+ newOrder?: boolean;
415
+ currency?: string;
416
+ station?: CFActiveStation;
417
+ }
418
+ export interface CFActiveCustomSales {
419
+ id: string;
420
+ name: string;
421
+ applyTaxes: boolean;
422
+ taxTableId?: string;
423
+ quantity: number;
424
+ price: number;
425
+ discount?: any;
426
+ fee?: any;
427
+ }
428
+ export interface CFActiveCart extends CFActiveEntity {
429
+ tax?: number;
430
+ total: number;
431
+ subtotal: number;
432
+ discount?: CFDiscount;
433
+ customFee?: CFCustomFee[];
434
+ products: CFActiveProduct[];
435
+ customSales?: CFActiveCustomSales[];
436
+ remainingBalance?: number;
437
+ amountToBeCharged: number;
438
+ customer?: Partial<CFCustomer | null> | null;
439
+ orderNotes?: string;
440
+ cartTotal?: number;
441
+ orderTotal?: number;
442
+ orderId?: string;
443
+ }
444
+ export interface CFActiveCompany extends CFActiveEntity {
445
+ id?: string;
446
+ name?: string;
447
+ logo?: string;
448
+ settings?: any;
449
+ }
450
+ export interface CFContext {
451
+ userId: string | null;
452
+ companyId: string | null;
453
+ companyName: string | null;
454
+ deviceId: string | null;
455
+ stationId: string | null;
456
+ stationName: string | null;
457
+ outletId: string | null;
458
+ outletName: string | null;
459
+ buildId: string | null;
460
+ buildName: string | null;
461
+ buildVersion: string | null;
462
+ buildSourceId: string | null;
463
+ buildIsPremium: boolean;
464
+ user: Record<string, any> | null;
465
+ company: Omit<Record<string, any>, 'settings'> | null;
466
+ station: Record<string, any> | null;
467
+ outlet: Record<string, any> | null;
468
+ timestamp: string;
469
+ }
@@ -0,0 +1,21 @@
1
+ // Enums
2
+ export var CFProductType;
3
+ (function (CFProductType) {
4
+ CFProductType["SIMPLE"] = "simple";
5
+ CFProductType["VARIABLE"] = "variable";
6
+ })(CFProductType || (CFProductType = {}));
7
+ export var CFUserTypes;
8
+ (function (CFUserTypes) {
9
+ CFUserTypes["OWNER"] = "owner";
10
+ CFUserTypes["ORG_USER"] = "organization_user";
11
+ CFUserTypes["ORG_OWNER"] = "organization_owner";
12
+ CFUserTypes["FINAL_USER"] = "final_user";
13
+ CFUserTypes["FINAL_OWNER"] = "final_owner";
14
+ CFUserTypes["EMPLOYEE"] = "employee";
15
+ CFUserTypes["SUPER_ADMIN"] = "super_admin";
16
+ CFUserTypes["MANAGER"] = "manager";
17
+ CFUserTypes["ADMIN"] = "admin";
18
+ CFUserTypes["ASSISTANT_MANAGER"] = "assistant";
19
+ CFUserTypes["CASHIER"] = "cashier";
20
+ CFUserTypes["RESELLER"] = "reseller";
21
+ })(CFUserTypes || (CFUserTypes = {}));
@@ -0,0 +1,2 @@
1
+ import { AddCartDiscount } from "./types";
2
+ export declare const mockAddCartDiscount: AddCartDiscount;
@@ -0,0 +1,27 @@
1
+ import { MOCK_CART } from "../../demo/database";
2
+ export const mockAddCartDiscount = async (params) => {
3
+ console.log("[Mock] addCartDiscount called", params);
4
+ if (params) {
5
+ MOCK_CART.discount = {
6
+ value: params.amount,
7
+ isPercent: params.isPercent,
8
+ label: params.label
9
+ };
10
+ // Simple mock calc (not real logic)
11
+ if (params.isPercent) {
12
+ MOCK_CART.total = MOCK_CART.subtotal * (1 - params.amount / 100);
13
+ }
14
+ else {
15
+ MOCK_CART.total = MOCK_CART.subtotal - params.amount;
16
+ }
17
+ MOCK_CART.amountToBeCharged = MOCK_CART.total;
18
+ MOCK_CART.remainingBalance = MOCK_CART.total;
19
+ }
20
+ return {
21
+ success: true,
22
+ amount: params?.amount || 0,
23
+ isPercent: params?.isPercent || false,
24
+ label: params?.label || "",
25
+ timestamp: new Date().toISOString()
26
+ };
27
+ };
@@ -0,0 +1,2 @@
1
+ import { AddCartFee } from "./types";
2
+ export declare const mockAddCartFee: AddCartFee;
@@ -0,0 +1,31 @@
1
+ import { MOCK_CART } from "../../demo/database";
2
+ export const mockAddCartFee = async (params) => {
3
+ console.log("[Mock] addCartFee called", params);
4
+ if (params) {
5
+ if (!MOCK_CART.customFee)
6
+ MOCK_CART.customFee = [];
7
+ MOCK_CART.customFee.push({
8
+ label: params.label || "Fee",
9
+ amount: params.amount,
10
+ isPercent: params.isPercent || false,
11
+ applyTaxes: params.applyTaxes || false,
12
+ taxTableId: params.taxTableId
13
+ });
14
+ // Simple calc
15
+ let feeAmount = params.amount;
16
+ if (params.isPercent) {
17
+ feeAmount = MOCK_CART.subtotal * (params.amount / 100);
18
+ }
19
+ MOCK_CART.total += feeAmount;
20
+ MOCK_CART.amountToBeCharged = MOCK_CART.total;
21
+ MOCK_CART.remainingBalance = MOCK_CART.total;
22
+ }
23
+ return {
24
+ success: true,
25
+ amount: params?.amount || 0,
26
+ isPercent: params?.isPercent || false,
27
+ label: params?.label || "",
28
+ applyTaxes: params?.applyTaxes || false,
29
+ timestamp: new Date().toISOString()
30
+ };
31
+ };