@final-commerce/command-frame 0.0.2 → 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 +56 -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 -20
  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 +3 -0
  133. package/dist/client.js +62 -1
  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
@@ -0,0 +1,515 @@
1
+ /**
2
+ * Mock Database for Standalone/Demo Mode
3
+ * Stores mock data that mimics the Render environment
4
+ */
5
+ import { CFProductType, CFUserTypes, } from "../CommonTypes";
6
+ // Asset Imports
7
+ import logo from "./assets/logo.png";
8
+ import basilAlmondImg from "./assets/basil-almond-paste.png";
9
+ import beerImg from "./assets/beer-paste.png";
10
+ import beetImg from "./assets/beet-paste.png";
11
+ import caramelizedImg from "./assets/caramelized-paste.png";
12
+ import garlicOnionImg from "./assets/garlic-onion-paste.png";
13
+ import garlicImg from "./assets/garlic-paste.png";
14
+ import gingerLimeImg from "./assets/ginger-lime-paste.png";
15
+ import lemonImg from "./assets/lemon-paste.png";
16
+ import redPepperImg from "./assets/red-pepper-paste.png";
17
+ import roastedTomatoImg from "./assets/roasted-tomato-paste.png";
18
+ // --- COMPANY ---
19
+ export const MOCK_COMPANY = {
20
+ id: "comp_paste_demo",
21
+ name: "Paste Demo Company",
22
+ logo: logo,
23
+ settings: {
24
+ currencyPrefix: "$",
25
+ currencySuffix: "",
26
+ currencySymbol: "$",
27
+ decimalSeparator: ".",
28
+ thousandSeparator: ",",
29
+ decimals: { $numberInt: "2" }
30
+ }
31
+ };
32
+ const COMPANY_ID = MOCK_COMPANY.id;
33
+ // --- OUTLETS ---
34
+ export const MOCK_OUTLET_MAIN = {
35
+ id: "outlet_main",
36
+ _id: "outlet_main",
37
+ name: "Main Kitchen",
38
+ address: "123 Pasta Lane",
39
+ address2: "Suite 1",
40
+ city: "Rome",
41
+ state: "RM",
42
+ country: "IT",
43
+ taxId: "TAX-IT-001",
44
+ postCode: "00100",
45
+ sequenceNumber: 1,
46
+ stripeAccountId: "acct_paste_main"
47
+ };
48
+ // --- STATIONS ---
49
+ export const MOCK_STATION_1 = {
50
+ _id: "station_counter_1",
51
+ name: "Counter 1",
52
+ status: "open",
53
+ sequenceNumber: 1,
54
+ stripeTerminalId: "tm_1"
55
+ };
56
+ export const MOCK_STATION_2 = {
57
+ _id: "station_counter_2",
58
+ name: "Counter 2",
59
+ status: "open",
60
+ sequenceNumber: 2,
61
+ stripeTerminalId: "tm_2"
62
+ };
63
+ // --- USERS ---
64
+ export const MOCK_USER_MARIO = {
65
+ id: "user_mario",
66
+ firstName: "Mario",
67
+ lastName: "Demoji",
68
+ type: CFUserTypes.MANAGER,
69
+ role: {
70
+ id: "role_manager",
71
+ name: "Manager",
72
+ permissions: []
73
+ },
74
+ outlets: [MOCK_OUTLET_MAIN.id],
75
+ companies: [COMPANY_ID]
76
+ };
77
+ export const MOCK_USER_LUIGI = {
78
+ id: "user_luigi",
79
+ firstName: "Luigi",
80
+ lastName: "Demoji",
81
+ type: CFUserTypes.CASHIER,
82
+ role: {
83
+ id: "role_cashier",
84
+ name: "Cashier",
85
+ permissions: []
86
+ },
87
+ outlets: [MOCK_OUTLET_MAIN.id],
88
+ companies: [COMPANY_ID]
89
+ };
90
+ // --- CUSTOMERS ---
91
+ export const MOCK_CUSTOMER_1 = {
92
+ _id: "cust_giuseppe",
93
+ companyId: COMPANY_ID,
94
+ email: "giuseppe@example.com",
95
+ firstName: "Giuseppe",
96
+ lastName: "Verdi",
97
+ phone: "555-0101",
98
+ billing: {
99
+ firstName: "Giuseppe",
100
+ lastName: "Verdi",
101
+ address1: "Via Roma 1",
102
+ address2: "",
103
+ city: "Milano",
104
+ postCode: "20100",
105
+ country: "IT"
106
+ },
107
+ shipping: null
108
+ };
109
+ export const MOCK_CUSTOMER_2 = {
110
+ _id: "cust_sofia",
111
+ companyId: COMPANY_ID,
112
+ email: "sofia@example.com",
113
+ firstName: "Sofia",
114
+ lastName: "Loren",
115
+ phone: "555-0102",
116
+ billing: null,
117
+ shipping: null
118
+ };
119
+ export const MOCK_CUSTOMER_3 = {
120
+ _id: "cust_alessandro",
121
+ companyId: COMPANY_ID,
122
+ email: "alessandro@example.com",
123
+ firstName: "Alessandro",
124
+ lastName: "Volta",
125
+ phone: "555-0103",
126
+ billing: null,
127
+ shipping: null
128
+ };
129
+ export const MOCK_CUSTOMER_4 = {
130
+ _id: "cust_isabella",
131
+ companyId: COMPANY_ID,
132
+ email: "isabella@example.com",
133
+ firstName: "Isabella",
134
+ lastName: "Rossellini",
135
+ phone: "555-0104",
136
+ billing: null,
137
+ shipping: null
138
+ };
139
+ export const MOCK_CUSTOMER_5 = {
140
+ _id: "cust_leonardo",
141
+ companyId: COMPANY_ID,
142
+ email: "leonardo@example.com",
143
+ firstName: "Leonardo",
144
+ lastName: "Da Vinci",
145
+ phone: "555-0105",
146
+ billing: null,
147
+ shipping: null
148
+ };
149
+ // --- CATEGORIES ---
150
+ export const MOCK_CATEGORY_PASTES = {
151
+ _id: "cat_pastes",
152
+ name: "Pastes",
153
+ externalId: "ext_cat_pastes",
154
+ companyId: COMPANY_ID,
155
+ parentId: null
156
+ };
157
+ export const MOCK_CATEGORY_SPECIALTY = {
158
+ _id: "cat_specialty",
159
+ name: "Specialty",
160
+ externalId: "ext_cat_specialty",
161
+ companyId: COMPANY_ID,
162
+ parentId: "cat_pastes"
163
+ };
164
+ export const MOCK_CATEGORY_BASIC = {
165
+ _id: "cat_basic",
166
+ name: "Basic",
167
+ externalId: "ext_cat_basic",
168
+ companyId: COMPANY_ID,
169
+ parentId: "cat_pastes"
170
+ };
171
+ // --- PRODUCTS ---
172
+ const createInventory = (stock) => [{ warehouse: "main", outletId: MOCK_OUTLET_MAIN.id, stock }];
173
+ // Helper for Simple Product
174
+ const createSimpleProduct = (id, name, price, image, category, description) => {
175
+ const sku = `SKU-${id.toUpperCase()}`;
176
+ return {
177
+ _id: id,
178
+ name,
179
+ companyId: COMPANY_ID,
180
+ externalId: `ext_${id}`,
181
+ sku,
182
+ price,
183
+ minPrice: price,
184
+ maxPrice: price,
185
+ status: "active",
186
+ productType: CFProductType.SIMPLE,
187
+ taxTable: "tax_standard",
188
+ description,
189
+ images: [image],
190
+ categories: { name: category.name, externalId: category.externalId },
191
+ attributes: [],
192
+ variants: [
193
+ {
194
+ _id: `${id}_var_main`,
195
+ sku,
196
+ price,
197
+ salePrice: "0",
198
+ isOnSale: false,
199
+ manageStock: true,
200
+ externalId: `ext_${id}_var`,
201
+ attributes: [],
202
+ inventory: createInventory(100)
203
+ }
204
+ ]
205
+ };
206
+ };
207
+ // Helper for Variable Product (Size: Small, Large)
208
+ const createVariableProduct = (id, name, basePrice, largePrice, image, category, description) => {
209
+ const skuBase = `SKU-${id.toUpperCase()}`;
210
+ return {
211
+ _id: id,
212
+ name,
213
+ companyId: COMPANY_ID,
214
+ externalId: `ext_${id}`,
215
+ sku: skuBase,
216
+ price: basePrice,
217
+ minPrice: basePrice,
218
+ maxPrice: largePrice,
219
+ status: "active",
220
+ productType: CFProductType.VARIABLE,
221
+ taxTable: "tax_standard",
222
+ description,
223
+ images: [image],
224
+ categories: { name: category.name, externalId: category.externalId },
225
+ attributes: [{ name: "Size", values: ["Small", "Large"] }],
226
+ variants: [
227
+ {
228
+ _id: `${id}_var_small`,
229
+ sku: `${skuBase}-S`,
230
+ price: basePrice,
231
+ salePrice: "0",
232
+ isOnSale: false,
233
+ manageStock: true,
234
+ externalId: `ext_${id}_var_s`,
235
+ attributes: [{ name: "Size", value: "Small" }],
236
+ inventory: createInventory(50)
237
+ },
238
+ {
239
+ _id: `${id}_var_large`,
240
+ sku: `${skuBase}-L`,
241
+ price: largePrice,
242
+ salePrice: "0",
243
+ isOnSale: false,
244
+ manageStock: true,
245
+ externalId: `ext_${id}_var_l`,
246
+ attributes: [{ name: "Size", value: "Large" }],
247
+ inventory: createInventory(30)
248
+ }
249
+ ]
250
+ };
251
+ };
252
+ export const MOCK_PRODUCT_BASIL_ALMOND = createSimpleProduct("prod_basil_almond", "Basil Almond Paste", "12.00", basilAlmondImg, MOCK_CATEGORY_SPECIALTY, "A rich blend of fresh basil and roasted almonds.");
253
+ export const MOCK_PRODUCT_BEER = createVariableProduct("prod_beer", "Beer Paste", "15.00", "25.00", beerImg, MOCK_CATEGORY_SPECIALTY, "Unique paste infused with dark lager.");
254
+ export const MOCK_PRODUCT_BEET = createSimpleProduct("prod_beet", "Beet Paste", "10.00", beetImg, MOCK_CATEGORY_BASIC, "Earthy and sweet beet paste, perfect for salads.");
255
+ export const MOCK_PRODUCT_CARAMELIZED = createVariableProduct("prod_caramelized", "Caramelized Paste", "14.00", "22.00", caramelizedImg, MOCK_CATEGORY_SPECIALTY, "Slow-cooked caramelized onion paste.");
256
+ export const MOCK_PRODUCT_GARLIC_ONION = createVariableProduct("prod_garlic_onion", "Garlic Onion Paste", "11.00", "18.00", garlicOnionImg, MOCK_CATEGORY_BASIC, "Classic savory base for any dish.");
257
+ export const MOCK_PRODUCT_GARLIC = createSimpleProduct("prod_garlic", "Garlic Paste", "9.00", garlicImg, MOCK_CATEGORY_BASIC, "Pure, intense garlic paste.");
258
+ export const MOCK_PRODUCT_GINGER_LIME = createVariableProduct("prod_ginger_lime", "Ginger Lime Paste", "13.00", "20.00", gingerLimeImg, MOCK_CATEGORY_SPECIALTY, "Zesty and spicy, great for asian cuisine.");
259
+ export const MOCK_PRODUCT_LEMON = createSimpleProduct("prod_lemon", "Lemon Paste", "10.50", lemonImg, MOCK_CATEGORY_BASIC, "Bright citrus flavor concentrate.");
260
+ export const MOCK_PRODUCT_RED_PEPPER = createVariableProduct("prod_red_pepper", "Red Pepper Paste", "12.50", "19.00", redPepperImg, MOCK_CATEGORY_BASIC, "Roasted red peppers with a hint of spice.");
261
+ export const MOCK_PRODUCT_ROASTED_TOMATO = createVariableProduct("prod_roasted_tomato", "Roasted Tomato Paste", "11.50", "18.50", roastedTomatoImg, MOCK_CATEGORY_BASIC, "Deep, umami-rich tomato flavor.");
262
+ // --- ORDERS ---
263
+ // Helper to create line item
264
+ const createLineItem = (product, variantIndex = 0, quantity = 1) => {
265
+ const variant = product.variants[variantIndex];
266
+ return {
267
+ productId: product._id,
268
+ variantId: variant._id,
269
+ name: product.name,
270
+ quantity,
271
+ price: variant.price,
272
+ taxes: [],
273
+ discount: {
274
+ itemDiscount: { percentage: 0, amount: "0" },
275
+ cartDiscount: { percentage: 0, amount: "0" }
276
+ },
277
+ fee: { itemFee: { percentage: 0, amount: "0", tax: "0", taxTableId: "" } },
278
+ totalTax: "0",
279
+ total: (parseFloat(variant.price) * quantity).toFixed(2),
280
+ metadata: [],
281
+ image: product.images?.[0] || "",
282
+ sku: variant.sku,
283
+ stock: variant.inventory?.[0]?.stock || 0,
284
+ attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", ")
285
+ };
286
+ };
287
+ export const MOCK_ORDER_1 = {
288
+ _id: "order_1001",
289
+ receiptId: "1001-0001",
290
+ companyId: COMPANY_ID,
291
+ externalId: null,
292
+ status: "completed",
293
+ customer: MOCK_CUSTOMER_1,
294
+ summary: {
295
+ total: "21.00",
296
+ subTotal: "21.00",
297
+ discountTotal: "0",
298
+ shippingTotal: "0",
299
+ totalTaxes: "0",
300
+ taxes: [],
301
+ isTaxInclusive: false
302
+ },
303
+ cartDiscount: null,
304
+ cartFees: [],
305
+ paymentMethods: [
306
+ {
307
+ transactionId: "trans_cash_1",
308
+ paymentType: "cash",
309
+ amount: "21.00",
310
+ timestamp: new Date().toISOString(),
311
+ processor: "cash"
312
+ }
313
+ ],
314
+ source: "pos",
315
+ posData: {
316
+ outlet: MOCK_OUTLET_MAIN.id,
317
+ station: MOCK_STATION_1._id,
318
+ employee: MOCK_USER_LUIGI.id
319
+ },
320
+ sessionId: "sess_1",
321
+ metadata: [],
322
+ billing: MOCK_CUSTOMER_1.billing,
323
+ shipping: null,
324
+ lineItems: [
325
+ createLineItem(MOCK_PRODUCT_GARLIC, 0, 1), // 9.00
326
+ createLineItem(MOCK_PRODUCT_BASIL_ALMOND, 0, 1) // 12.00
327
+ ],
328
+ customSales: [],
329
+ balance: "0",
330
+ user: MOCK_USER_LUIGI,
331
+ outlet: MOCK_OUTLET_MAIN,
332
+ station: MOCK_STATION_1,
333
+ createdAt: new Date().toISOString()
334
+ };
335
+ export const MOCK_ORDER_2 = {
336
+ _id: "order_1002",
337
+ receiptId: "1001-0002",
338
+ companyId: COMPANY_ID,
339
+ externalId: null,
340
+ status: "completed",
341
+ customer: MOCK_CUSTOMER_2,
342
+ summary: {
343
+ total: "30.00",
344
+ subTotal: "30.00",
345
+ discountTotal: "0",
346
+ shippingTotal: "0",
347
+ totalTaxes: "0",
348
+ taxes: [],
349
+ isTaxInclusive: false
350
+ },
351
+ cartDiscount: null,
352
+ cartFees: [],
353
+ paymentMethods: [
354
+ {
355
+ transactionId: "trans_card_1",
356
+ paymentType: "credit_card",
357
+ amount: "30.00",
358
+ timestamp: new Date(Date.now() - 3600000).toISOString(),
359
+ processor: "stripe"
360
+ }
361
+ ],
362
+ source: "pos",
363
+ posData: {
364
+ outlet: MOCK_OUTLET_MAIN.id,
365
+ station: MOCK_STATION_2._id,
366
+ employee: MOCK_USER_MARIO.id
367
+ },
368
+ sessionId: "sess_2",
369
+ metadata: [],
370
+ billing: null,
371
+ shipping: null,
372
+ lineItems: [
373
+ createLineItem(MOCK_PRODUCT_BEER, 0, 2) // 15.00 * 2 = 30.00
374
+ ],
375
+ customSales: [],
376
+ balance: "0",
377
+ user: MOCK_USER_MARIO,
378
+ outlet: MOCK_OUTLET_MAIN,
379
+ station: MOCK_STATION_2,
380
+ createdAt: new Date(Date.now() - 3600000).toISOString()
381
+ };
382
+ // --- EXPORT COLLECTIONS ---
383
+ export const MOCK_USERS = [MOCK_USER_MARIO, MOCK_USER_LUIGI];
384
+ export const MOCK_STATIONS = [MOCK_STATION_1, MOCK_STATION_2];
385
+ export const MOCK_OUTLETS = [MOCK_OUTLET_MAIN];
386
+ export const MOCK_CUSTOMERS = [
387
+ MOCK_CUSTOMER_1,
388
+ MOCK_CUSTOMER_2,
389
+ MOCK_CUSTOMER_3,
390
+ MOCK_CUSTOMER_4,
391
+ MOCK_CUSTOMER_5
392
+ ];
393
+ export const MOCK_CATEGORIES = [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_BASIC];
394
+ export const MOCK_PRODUCTS = [
395
+ MOCK_PRODUCT_BASIL_ALMOND,
396
+ MOCK_PRODUCT_BEER,
397
+ MOCK_PRODUCT_BEET,
398
+ MOCK_PRODUCT_CARAMELIZED,
399
+ MOCK_PRODUCT_GARLIC_ONION,
400
+ MOCK_PRODUCT_GARLIC,
401
+ MOCK_PRODUCT_GINGER_LIME,
402
+ MOCK_PRODUCT_LEMON,
403
+ MOCK_PRODUCT_RED_PEPPER,
404
+ MOCK_PRODUCT_ROASTED_TOMATO
405
+ ];
406
+ export const MOCK_ORDERS = [MOCK_ORDER_1, MOCK_ORDER_2];
407
+ // Compatibility Exports
408
+ export const MOCK_USER = MOCK_USERS[0];
409
+ export const MOCK_STATION = MOCK_STATIONS[0];
410
+ export const MOCK_OUTLET = MOCK_OUTLETS[0];
411
+ export let MOCK_CART = {
412
+ total: 0,
413
+ subtotal: 0,
414
+ amountToBeCharged: 0,
415
+ remainingBalance: 0,
416
+ products: [],
417
+ customSales: [],
418
+ customer: null
419
+ };
420
+ // Helper to reset cart
421
+ export const resetMockCart = () => {
422
+ MOCK_CART = {
423
+ total: 0,
424
+ subtotal: 0,
425
+ amountToBeCharged: 0,
426
+ remainingBalance: 0,
427
+ products: [],
428
+ customSales: [],
429
+ customer: null
430
+ };
431
+ };
432
+ // Helper to simulate safe JSON serialization
433
+ export const safeSerialize = (data) => {
434
+ return JSON.parse(JSON.stringify(data));
435
+ };
436
+ // Helper to create order from cart
437
+ export const createOrderFromCart = (paymentType, amount, processor = "cash") => {
438
+ // Generate new Order ID
439
+ const orderId = `order_${Date.now()}`;
440
+ const receiptId = `receipt_${Date.now()}`;
441
+ // Map cart products to line items
442
+ const lineItems = MOCK_CART.products.map(p => {
443
+ // Find original product to get attributes/variants if needed
444
+ // For simplicity, we use what's in cart
445
+ return {
446
+ productId: p.id,
447
+ variantId: p.variantId,
448
+ name: p.name,
449
+ quantity: p.quantity,
450
+ price: String(p.price),
451
+ taxes: [],
452
+ discount: {
453
+ itemDiscount: { percentage: 0, amount: "0" },
454
+ cartDiscount: { percentage: 0, amount: "0" }
455
+ },
456
+ fee: { itemFee: { percentage: 0, amount: "0", tax: "0", taxTableId: "" } },
457
+ totalTax: "0",
458
+ total: (p.price * p.quantity).toFixed(2),
459
+ metadata: [],
460
+ image: p.images?.[0] || "",
461
+ sku: p.sku || "",
462
+ stock: 100, // Mock stock
463
+ attributes: p.attributes || ""
464
+ };
465
+ });
466
+ const totalStr = String(MOCK_CART.total.toFixed(2));
467
+ const newOrder = {
468
+ _id: orderId,
469
+ receiptId,
470
+ companyId: COMPANY_ID,
471
+ externalId: null,
472
+ status: "completed",
473
+ customer: MOCK_CART.customer ? MOCK_CART.customer : null,
474
+ summary: {
475
+ total: totalStr,
476
+ subTotal: totalStr,
477
+ discountTotal: "0",
478
+ shippingTotal: "0",
479
+ totalTaxes: "0",
480
+ taxes: [],
481
+ isTaxInclusive: false
482
+ },
483
+ cartDiscount: MOCK_CART.discount ? { label: MOCK_CART.discount.label || "Discount", amount: "0", percentage: MOCK_CART.discount.value } : null,
484
+ cartFees: [],
485
+ paymentMethods: [
486
+ {
487
+ transactionId: `trans_${Date.now()}`,
488
+ paymentType,
489
+ amount: String(amount),
490
+ timestamp: new Date().toISOString(),
491
+ processor
492
+ }
493
+ ],
494
+ source: "pos",
495
+ posData: {
496
+ outlet: MOCK_OUTLET_MAIN.id,
497
+ station: MOCK_STATION_1._id,
498
+ employee: MOCK_USER_LUIGI.id
499
+ },
500
+ sessionId: `session_${Date.now()}`,
501
+ metadata: [],
502
+ billing: MOCK_CART.customer?.billing || null,
503
+ shipping: MOCK_CART.customer?.shipping || null,
504
+ lineItems,
505
+ customSales: [],
506
+ balance: "0",
507
+ user: MOCK_USER_LUIGI,
508
+ outlet: MOCK_OUTLET_MAIN,
509
+ station: MOCK_STATION_1,
510
+ createdAt: new Date().toISOString()
511
+ };
512
+ MOCK_ORDERS.push(newOrder);
513
+ resetMockCart();
514
+ return newOrder;
515
+ };
@@ -0,0 +1,5 @@
1
+ import { command } from "../index";
2
+ type MockHandler = (params?: any) => Promise<any>;
3
+ export type CommandName = keyof typeof command;
4
+ export declare const MOCK_REGISTRY: Record<CommandName, MockHandler>;
5
+ export {};
@@ -0,0 +1,106 @@
1
+ import { mockAddCartDiscount } from "../actions/add-cart-discount/mock";
2
+ import { mockAddCartFee } from "../actions/add-cart-fee/mock";
3
+ import { mockAddCustomSale } from "../actions/add-custom-sale/mock";
4
+ import { mockAddCustomer } from "../actions/add-customer/mock";
5
+ import { mockAddCustomerNote } from "../actions/add-customer-note/mock";
6
+ import { mockAddOrderNote } from "../actions/add-order-note/mock";
7
+ import { mockAddProductDiscount } from "../actions/add-product-discount/mock";
8
+ import { mockAddProductFee } from "../actions/add-product-fee/mock";
9
+ import { mockAddProductNote } from "../actions/add-product-note/mock";
10
+ import { mockAddProductToCart } from "../actions/add-product-to-cart/mock";
11
+ import { mockAdjustInventory } from "../actions/adjust-inventory/mock";
12
+ import { mockAssignCustomer } from "../actions/assign-customer/mock";
13
+ import { mockAuthenticateUser } from "../actions/authenticate-user/mock";
14
+ import { mockCalculateRefundTotal } from "../actions/calculate-refund-total/mock";
15
+ import { mockCashPayment } from "../actions/cash-payment/mock";
16
+ import { mockClearCart } from "../actions/clear-cart/mock";
17
+ import { mockDeleteParkedOrder } from "../actions/delete-parked-order/mock";
18
+ import { mockExampleFunction } from "../actions/example-function/mock";
19
+ import { mockGetCategories } from "../actions/get-categories/mock";
20
+ import { mockGetContext } from "../actions/get-context/mock";
21
+ import { mockGetCurrentCart } from "../actions/get-current-cart/mock";
22
+ import { mockGetCustomers } from "../actions/get-customers/mock";
23
+ import { mockGetLineItemsByOrder } from "../actions/get-line-items-by-order/mock";
24
+ import { mockGetOrders } from "../actions/get-orders/mock";
25
+ import { mockGetProductVariants } from "../actions/get-product-variants/mock";
26
+ import { mockGetProducts } from "../actions/get-products/mock";
27
+ import { mockGetRefunds } from "../actions/get-refunds/mock";
28
+ import { mockGetRemainingRefundableQuantities } from "../actions/get-remaining-refundable-quantities/mock";
29
+ import { mockGoToPage } from "../actions/go-to-page/mock";
30
+ import { mockGoToStationHome } from "../actions/go-to-station-home/mock";
31
+ import { mockInitiateRefund } from "../actions/initiate-refund/mock";
32
+ import { mockOpenCashDrawer } from "../actions/open-cash-drawer/mock";
33
+ import { mockOpenPopup } from "../actions/open-popup/mock";
34
+ import { mockParkOrder } from "../actions/park-order/mock";
35
+ import { mockPartialPayment } from "../actions/partial-payment/mock";
36
+ import { mockProcessPartialRefund } from "../actions/process-partial-refund/mock";
37
+ import { mockRemoveCustomerFromCart } from "../actions/remove-customer-from-cart/mock";
38
+ import { mockResetRefundDetails } from "../actions/reset-refund-details/mock";
39
+ import { mockResumeParkedOrder } from "../actions/resume-parked-order/mock";
40
+ import { mockSelectAllRefundItems } from "../actions/select-all-refund-items/mock";
41
+ import { mockSetProductActive } from "../actions/set-product-active/mock";
42
+ import { mockSetRefundStockAction } from "../actions/set-refund-stock-action/mock";
43
+ import { mockShowConfirmation } from "../actions/show-confirmation/mock";
44
+ import { mockShowNotification } from "../actions/show-notification/mock";
45
+ import { mockSwitchUser } from "../actions/switch-user/mock";
46
+ import { mockTapToPayPayment } from "../actions/tap-to-pay-payment/mock";
47
+ import { mockTerminalPayment } from "../actions/terminal-payment/mock";
48
+ import { mockToggleSlideOut } from "../actions/toggle-slide-out/mock";
49
+ import { mockTriggerWebhook } from "../actions/trigger-webhook/mock";
50
+ import { mockTriggerZapierWebhook } from "../actions/trigger-zapier-webhook/mock";
51
+ import { mockUpdateCustomerFacingDisplay } from "../actions/update-customer-facing-display/mock";
52
+ import { mockVendaraPayment } from "../actions/vendara-payment/mock";
53
+ export const MOCK_REGISTRY = {
54
+ "addCartDiscount": mockAddCartDiscount,
55
+ "addCartFee": mockAddCartFee,
56
+ "addCustomSale": mockAddCustomSale,
57
+ "addCustomer": mockAddCustomer,
58
+ "addCustomerNote": mockAddCustomerNote,
59
+ "addOrderNote": mockAddOrderNote,
60
+ "addProductDiscount": mockAddProductDiscount,
61
+ "addProductFee": mockAddProductFee,
62
+ "addProductNote": mockAddProductNote,
63
+ "addProductToCart": mockAddProductToCart,
64
+ "adjustInventory": mockAdjustInventory,
65
+ "assignCustomer": mockAssignCustomer,
66
+ "authenticateUser": mockAuthenticateUser,
67
+ "calculateRefundTotal": mockCalculateRefundTotal,
68
+ "cashPayment": mockCashPayment,
69
+ "clearCart": mockClearCart,
70
+ "deleteParkedOrder": mockDeleteParkedOrder,
71
+ "exampleFunction": mockExampleFunction,
72
+ "getCategories": mockGetCategories,
73
+ "getContext": mockGetContext,
74
+ "getCurrentCart": mockGetCurrentCart,
75
+ "getCustomers": mockGetCustomers,
76
+ "getLineItemsByOrder": mockGetLineItemsByOrder,
77
+ "getOrders": mockGetOrders,
78
+ "getProductVariants": mockGetProductVariants,
79
+ "getProducts": mockGetProducts,
80
+ "getRefunds": mockGetRefunds,
81
+ "getRemainingRefundableQuantities": mockGetRemainingRefundableQuantities,
82
+ "goToPage": mockGoToPage,
83
+ "goToStationHome": mockGoToStationHome,
84
+ "initiateRefund": mockInitiateRefund,
85
+ "openCashDrawer": mockOpenCashDrawer,
86
+ "openPopup": mockOpenPopup,
87
+ "parkOrder": mockParkOrder,
88
+ "partialPayment": mockPartialPayment,
89
+ "processPartialRefund": mockProcessPartialRefund,
90
+ "removeCustomerFromCart": mockRemoveCustomerFromCart,
91
+ "resetRefundDetails": mockResetRefundDetails,
92
+ "resumeParkedOrder": mockResumeParkedOrder,
93
+ "selectAllRefundItems": mockSelectAllRefundItems,
94
+ "setProductActive": mockSetProductActive,
95
+ "setRefundStockAction": mockSetRefundStockAction,
96
+ "showConfirmation": mockShowConfirmation,
97
+ "showNotification": mockShowNotification,
98
+ "switchUser": mockSwitchUser,
99
+ "tapToPayPayment": mockTapToPayPayment,
100
+ "terminalPayment": mockTerminalPayment,
101
+ "toggleSlideOut": mockToggleSlideOut,
102
+ "triggerWebhook": mockTriggerWebhook,
103
+ "triggerZapierWebhook": mockTriggerZapierWebhook,
104
+ "updateCustomerFacingDisplay": mockUpdateCustomerFacingDisplay,
105
+ "vendaraPayment": mockVendaraPayment,
106
+ };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,7 @@ export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountRe
75
75
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
76
76
  export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
77
77
  export type { GetContext, GetContextResponse } from "./actions/get-context/types";
78
+ export type { GetFinalContext, GetFinalContextResponse } from "./actions/get-final-context/types";
78
79
  export type { AddProductNote, AddProductNoteParams, AddProductNoteResponse } from "./actions/add-product-note/types";
79
80
  export type { AddProductFee, AddProductFeeParams, AddProductFeeResponse } from "./actions/add-product-fee/types";
80
81
  export type { AdjustInventory, AdjustInventoryParams, AdjustInventoryResponse } from "./actions/adjust-inventory/types";
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CFProduct, CFCustomer } from "./CommonTypes";
1
2
  export interface ExampleFunctionParams {
2
3
  param1?: string;
3
4
  param2?: string;
@@ -18,7 +19,7 @@ export interface GetProductsParams {
18
19
  query?: Record<string, any>;
19
20
  }
20
21
  export interface GetProductsResponse {
21
- products: any[];
22
+ products: CFProduct[];
22
23
  timestamp: string;
23
24
  }
24
25
  export type GetProducts = (params?: GetProductsParams) => Promise<GetProductsResponse>;
@@ -39,7 +40,7 @@ export interface GetCustomersParams {
39
40
  query?: Record<string, any>;
40
41
  }
41
42
  export interface GetCustomersResponse {
42
- customers: any[];
43
+ customers: CFCustomer[];
43
44
  total?: number;
44
45
  timestamp: string;
45
46
  }
@@ -49,16 +50,16 @@ export interface AssignCustomerParams {
49
50
  }
50
51
  export interface AssignCustomerResponse {
51
52
  success: boolean;
52
- customer: any;
53
+ customer: CFCustomer;
53
54
  timestamp: string;
54
55
  }
55
56
  export type AssignCustomer = (params: AssignCustomerParams) => Promise<AssignCustomerResponse>;
56
57
  export interface AddCustomerParams {
57
- customer: Record<string, any>;
58
+ customer: Partial<CFCustomer>;
58
59
  }
59
60
  export interface AddCustomerResponse {
60
61
  success: boolean;
61
- customer: any;
62
+ customer: CFCustomer;
62
63
  timestamp: string;
63
64
  }
64
65
  export type AddCustomer = (params: AddCustomerParams) => Promise<AddCustomerResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",