@final-commerce/command-frame 0.1.43 → 0.1.46
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.
- package/README.md +34 -0
- package/dist/CommonTypes.d.ts +97 -35
- package/dist/CommonTypes.js +44 -0
- package/dist/actions/add-non-revenue-item/action.d.ts +2 -0
- package/dist/actions/add-non-revenue-item/action.js +4 -0
- package/dist/actions/add-non-revenue-item/mock.d.ts +2 -0
- package/dist/actions/add-non-revenue-item/mock.js +41 -0
- package/dist/actions/add-non-revenue-item/types.d.ts +36 -0
- package/dist/actions/add-non-revenue-item/types.js +1 -0
- package/dist/actions/add-product/mock.js +7 -5
- package/dist/actions/add-product/types.d.ts +2 -2
- package/dist/actions/edit-product/mock.js +3 -1
- package/dist/actions/extension-payment/action.d.ts +5 -0
- package/dist/actions/extension-payment/action.js +7 -0
- package/dist/actions/extension-payment/mock.d.ts +2 -0
- package/dist/actions/extension-payment/mock.js +11 -0
- package/dist/actions/extension-payment/types.d.ts +19 -0
- package/dist/actions/extension-payment/types.js +1 -0
- package/dist/actions/extension-refund/constants.d.ts +2 -0
- package/dist/actions/extension-refund/constants.js +2 -0
- package/dist/actions/extension-refund/extension-refund-listener.d.ts +11 -0
- package/dist/actions/extension-refund/extension-refund-listener.js +60 -0
- package/dist/actions/extension-refund/types.d.ts +32 -0
- package/dist/actions/extension-refund/types.js +5 -0
- package/dist/actions/get-current-company-custom-extensions/mock.js +2 -2
- package/dist/actions/get-custom-extensions/mock.js +2 -2
- package/dist/actions/redeem-payment/action.d.ts +5 -0
- package/dist/actions/redeem-payment/action.js +7 -0
- package/dist/actions/redeem-payment/mock.d.ts +2 -0
- package/dist/actions/redeem-payment/mock.js +4 -0
- package/dist/actions/redeem-payment/types.d.ts +12 -0
- package/dist/actions/redeem-payment/types.js +1 -0
- package/dist/actions/resume-parked-order/mock.js +3 -3
- package/dist/common-types/custom-extensions.d.ts +1 -1
- package/dist/demo/database.d.ts +1 -1
- package/dist/demo/database.js +68 -60
- package/dist/demo/mocks/custom-tables.js +3 -3
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/projects/render/mocks.js +6 -0
- package/dist/projects/render/types.d.ts +4 -1
- package/package.json +5 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-initiated refund request for extension-controlled payments (e.g. redeem / gift card).
|
|
3
|
+
* The host (Render) postMessages the iframe; the extension performs the provider refund and replies.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parameters sent from host to extension for a refund.
|
|
7
|
+
*
|
|
8
|
+
* **`amount` uses major currency units** (e.g. dollars), consistent with the string amount
|
|
9
|
+
* passed through `sendRefundPaymentRequest` in Render (parsed with `parseFloat` / `+amount`).
|
|
10
|
+
*/
|
|
11
|
+
export interface ExtensionRefundParams {
|
|
12
|
+
/** e.g. `"redeem"` — matches order paymentMethods[].paymentType */
|
|
13
|
+
paymentType: string;
|
|
14
|
+
processor?: string;
|
|
15
|
+
/** Major currency units (same as refund flow amount string, not cents). */
|
|
16
|
+
amount: number;
|
|
17
|
+
/** Local sale transaction id (Mongo-style id from paymentMethods[].transactionId). */
|
|
18
|
+
saleId: string;
|
|
19
|
+
orderId?: string;
|
|
20
|
+
referenceId?: string;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Business result from the extension after attempting the refund.
|
|
25
|
+
* Transport success/failure uses {@link import("../../client").PostMessageResponse}.
|
|
26
|
+
*/
|
|
27
|
+
export interface ExtensionRefundResponse {
|
|
28
|
+
success: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
/** Provider/extension reference for the refund transaction, stored in local DB paymentData when present. */
|
|
31
|
+
extensionTransactionId?: string;
|
|
32
|
+
}
|
|
@@ -14,7 +14,7 @@ export const mockGetCurrentCompanyCustomExtensions = async (params) => {
|
|
|
14
14
|
"https://example.com/images/loyalty-1.png",
|
|
15
15
|
"https://example.com/images/loyalty-2.png"
|
|
16
16
|
],
|
|
17
|
-
price:
|
|
17
|
+
price: 2999,
|
|
18
18
|
website: "https://loyalty-extension.example.com",
|
|
19
19
|
isDeleted: false,
|
|
20
20
|
createdAt: "2024-01-01T10:00:00.000Z",
|
|
@@ -29,7 +29,7 @@ export const mockGetCurrentCompanyCustomExtensions = async (params) => {
|
|
|
29
29
|
short_description: "Real-time inventory insights",
|
|
30
30
|
long_description: "Get detailed insights into your inventory with real-time tracking, low stock alerts, and comprehensive reporting.",
|
|
31
31
|
main_image: "https://example.com/images/inventory-extension.png",
|
|
32
|
-
price:
|
|
32
|
+
price: 4999,
|
|
33
33
|
isDeleted: false,
|
|
34
34
|
createdAt: "2024-01-05T08:00:00.000Z",
|
|
35
35
|
updatedAt: "2024-01-05T08:00:00.000Z",
|
|
@@ -14,7 +14,7 @@ export const mockGetCustomExtensions = async () => {
|
|
|
14
14
|
"https://example.com/images/loyalty-1.png",
|
|
15
15
|
"https://example.com/images/loyalty-2.png"
|
|
16
16
|
],
|
|
17
|
-
price:
|
|
17
|
+
price: 2999,
|
|
18
18
|
website: "https://loyalty-extension.example.com",
|
|
19
19
|
isDeleted: false,
|
|
20
20
|
createdAt: "2024-01-01T10:00:00.000Z",
|
|
@@ -29,7 +29,7 @@ export const mockGetCustomExtensions = async () => {
|
|
|
29
29
|
short_description: "Real-time inventory insights",
|
|
30
30
|
long_description: "Get detailed insights into your inventory with real-time tracking, low stock alerts, and comprehensive reporting.",
|
|
31
31
|
main_image: "https://example.com/images/inventory-extension.png",
|
|
32
|
-
price:
|
|
32
|
+
price: 4999,
|
|
33
33
|
isDeleted: false,
|
|
34
34
|
createdAt: "2024-01-05T08:00:00.000Z",
|
|
35
35
|
updatedAt: "2024-01-05T08:00:00.000Z",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redeem payment — thin wrapper over {@link extensionPayment} with `paymentType: "redeem"`.
|
|
3
|
+
*/
|
|
4
|
+
import { extensionPayment } from "../extension-payment/action";
|
|
5
|
+
export const redeemPayment = async (params) => {
|
|
6
|
+
return extensionPayment({ ...params, paymentType: "redeem" });
|
|
7
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExtensionPaymentResponse } from "../extension-payment/types";
|
|
2
|
+
/** Redeem (e.g. gift card) — always uses paymentType `"redeem"` on the wire. */
|
|
3
|
+
export interface RedeemPaymentParams {
|
|
4
|
+
amount?: number;
|
|
5
|
+
processor?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
referenceId?: string;
|
|
8
|
+
extensionId?: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export type RedeemPaymentResponse = ExtensionPaymentResponse;
|
|
12
|
+
export type RedeemPayment = (params?: RedeemPaymentParams) => Promise<RedeemPaymentResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -30,7 +30,7 @@ export const mockResumeParkedOrder = async (params) => {
|
|
|
30
30
|
id: li.productId,
|
|
31
31
|
name: li.name,
|
|
32
32
|
quantity: li.quantity,
|
|
33
|
-
price:
|
|
33
|
+
price: li.price,
|
|
34
34
|
internalId: li.internalId || li.productId,
|
|
35
35
|
variantId: li.variantId,
|
|
36
36
|
sku: li.sku,
|
|
@@ -39,8 +39,8 @@ export const mockResumeParkedOrder = async (params) => {
|
|
|
39
39
|
taxTableId: "",
|
|
40
40
|
attributes: li.attributes
|
|
41
41
|
}));
|
|
42
|
-
MOCK_CART.subtotal =
|
|
43
|
-
MOCK_CART.total =
|
|
42
|
+
MOCK_CART.subtotal = orderToResume.summary.subTotal;
|
|
43
|
+
MOCK_CART.total = orderToResume.summary.total;
|
|
44
44
|
MOCK_CART.amountToBeCharged = MOCK_CART.total;
|
|
45
45
|
MOCK_CART.remainingBalance = MOCK_CART.total;
|
|
46
46
|
// Remove from parked
|
package/dist/demo/database.d.ts
CHANGED
|
@@ -53,4 +53,4 @@ export declare const safeSerialize: <T>(data: T) => T;
|
|
|
53
53
|
type MockEventCallback = (event: any) => void;
|
|
54
54
|
export declare const mockPublishEvent: (topic: string, eventType: string, data: any) => void;
|
|
55
55
|
export declare const mockSubscribeToTopic: (topic: string, callback: MockEventCallback) => void;
|
|
56
|
-
export declare const createOrderFromCart: (paymentType: string, amount: number
|
|
56
|
+
export declare const createOrderFromCart: (paymentType: string, amount: number, processor?: string) => CFActiveOrder;
|
package/dist/demo/database.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Mock Database for Standalone/Demo Mode
|
|
3
3
|
* Stores mock data that mimics the Render environment
|
|
4
4
|
*/
|
|
5
|
-
import { CFProductType, CFUserTypes, } from "../CommonTypes";
|
|
5
|
+
import { CFProductType, CFUserTypes, CurrencyCode, } from "../CommonTypes";
|
|
6
6
|
export * from './mocks';
|
|
7
7
|
// Asset Imports - Using Remote URLs to avoid build complexity with asset copying
|
|
8
8
|
const ASSETS_BASE_URL = "https://raw.githubusercontent.com/Final-Commerce/command-frame/refs/heads/main/src/demo/assets";
|
|
@@ -195,6 +195,8 @@ const createSimpleProduct = (id, name, price, image, categories, description) =>
|
|
|
195
195
|
companyId: COMPANY_ID,
|
|
196
196
|
externalId: `ext_${id}`,
|
|
197
197
|
sku,
|
|
198
|
+
currency: CurrencyCode.USD,
|
|
199
|
+
minorUnits: 2,
|
|
198
200
|
minPrice: price,
|
|
199
201
|
maxPrice: price,
|
|
200
202
|
status: "active",
|
|
@@ -202,7 +204,6 @@ const createSimpleProduct = (id, name, price, image, categories, description) =>
|
|
|
202
204
|
taxTable: "tax_standard",
|
|
203
205
|
description,
|
|
204
206
|
images: [image],
|
|
205
|
-
// Render stores product categories as an array of category IDs
|
|
206
207
|
categories: categories.map(c => c._id),
|
|
207
208
|
attributes: [],
|
|
208
209
|
variants: [
|
|
@@ -210,7 +211,7 @@ const createSimpleProduct = (id, name, price, image, categories, description) =>
|
|
|
210
211
|
_id: `${id}_var_main`,
|
|
211
212
|
sku,
|
|
212
213
|
price,
|
|
213
|
-
salePrice:
|
|
214
|
+
salePrice: 0,
|
|
214
215
|
isOnSale: false,
|
|
215
216
|
manageStock: true,
|
|
216
217
|
externalId: `ext_${id}_var`,
|
|
@@ -229,6 +230,8 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, categorie
|
|
|
229
230
|
companyId: COMPANY_ID,
|
|
230
231
|
externalId: `ext_${id}`,
|
|
231
232
|
sku: skuBase,
|
|
233
|
+
currency: CurrencyCode.USD,
|
|
234
|
+
minorUnits: 2,
|
|
232
235
|
minPrice: basePrice,
|
|
233
236
|
maxPrice: largePrice,
|
|
234
237
|
status: "active",
|
|
@@ -236,7 +239,6 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, categorie
|
|
|
236
239
|
taxTable: "tax_standard",
|
|
237
240
|
description,
|
|
238
241
|
images: [image],
|
|
239
|
-
// Render stores product categories as an array of category IDs
|
|
240
242
|
categories: categories.map(c => c._id),
|
|
241
243
|
attributes: [{ name: "Size", values: ["Small", "Large"] }],
|
|
242
244
|
variants: [
|
|
@@ -244,7 +246,7 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, categorie
|
|
|
244
246
|
_id: `${id}_var_small`,
|
|
245
247
|
sku: `${skuBase}-S`,
|
|
246
248
|
price: basePrice,
|
|
247
|
-
salePrice:
|
|
249
|
+
salePrice: 0,
|
|
248
250
|
isOnSale: false,
|
|
249
251
|
manageStock: true,
|
|
250
252
|
externalId: `ext_${id}_var_s`,
|
|
@@ -255,7 +257,7 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, categorie
|
|
|
255
257
|
_id: `${id}_var_large`,
|
|
256
258
|
sku: `${skuBase}-L`,
|
|
257
259
|
price: largePrice,
|
|
258
|
-
salePrice:
|
|
260
|
+
salePrice: 0,
|
|
259
261
|
isOnSale: false,
|
|
260
262
|
manageStock: true,
|
|
261
263
|
externalId: `ext_${id}_var_l`,
|
|
@@ -265,23 +267,23 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, categorie
|
|
|
265
267
|
]
|
|
266
268
|
};
|
|
267
269
|
};
|
|
268
|
-
export const MOCK_PRODUCT_BASIL_ALMOND = createSimpleProduct("prod_basil_almond", "Basil Almond Paste",
|
|
269
|
-
export const MOCK_PRODUCT_BEER = createVariableProduct("prod_beer", "Beer Paste",
|
|
270
|
-
export const MOCK_PRODUCT_BEET = createSimpleProduct("prod_beet", "Beet Paste",
|
|
271
|
-
export const MOCK_PRODUCT_CARAMELIZED = createVariableProduct("prod_caramelized", "Caramelized Paste",
|
|
272
|
-
export const MOCK_PRODUCT_GARLIC_ONION = createVariableProduct("prod_garlic_onion", "Garlic Onion Paste",
|
|
273
|
-
export const MOCK_PRODUCT_GARLIC = createSimpleProduct("prod_garlic", "Garlic Paste",
|
|
274
|
-
export const MOCK_PRODUCT_GINGER_LIME = createVariableProduct("prod_ginger_lime", "Ginger Lime Paste",
|
|
275
|
-
export const MOCK_PRODUCT_LEMON = createSimpleProduct("prod_lemon", "Lemon Paste",
|
|
276
|
-
export const MOCK_PRODUCT_RED_PEPPER = createVariableProduct("prod_red_pepper", "Red Pepper Paste",
|
|
277
|
-
export const MOCK_PRODUCT_ROASTED_TOMATO = createVariableProduct("prod_roasted_tomato", "Roasted Tomato Paste",
|
|
278
|
-
export const MOCK_PRODUCT_MINT_LEMON = createSimpleProduct("prod_mint_lemon", "Mint Lemon Paste",
|
|
270
|
+
export const MOCK_PRODUCT_BASIL_ALMOND = createSimpleProduct("prod_basil_almond", "Basil Almond Paste", 1200, basilAlmondImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "A rich blend of fresh basil and roasted almonds.");
|
|
271
|
+
export const MOCK_PRODUCT_BEER = createVariableProduct("prod_beer", "Beer Paste", 1500, 2500, beerImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY], "Unique paste infused with dark lager.");
|
|
272
|
+
export const MOCK_PRODUCT_BEET = createSimpleProduct("prod_beet", "Beet Paste", 1000, beetImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Earthy and sweet beet paste, perfect for salads.");
|
|
273
|
+
export const MOCK_PRODUCT_CARAMELIZED = createVariableProduct("prod_caramelized", "Caramelized Paste", 1400, 2200, caramelizedImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Slow-cooked caramelized onion paste.");
|
|
274
|
+
export const MOCK_PRODUCT_GARLIC_ONION = createVariableProduct("prod_garlic_onion", "Garlic Onion Paste", 1100, 1800, garlicOnionImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Classic savory base for any dish.");
|
|
275
|
+
export const MOCK_PRODUCT_GARLIC = createSimpleProduct("prod_garlic", "Garlic Paste", 900, garlicImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Pure, intense garlic paste.");
|
|
276
|
+
export const MOCK_PRODUCT_GINGER_LIME = createVariableProduct("prod_ginger_lime", "Ginger Lime Paste", 1300, 2000, gingerLimeImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Zesty and spicy, great for asian cuisine.");
|
|
277
|
+
export const MOCK_PRODUCT_LEMON = createSimpleProduct("prod_lemon", "Lemon Paste", 1050, lemonImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Bright citrus flavor concentrate.");
|
|
278
|
+
export const MOCK_PRODUCT_RED_PEPPER = createVariableProduct("prod_red_pepper", "Red Pepper Paste", 1250, 1900, redPepperImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Roasted red peppers with a hint of spice.");
|
|
279
|
+
export const MOCK_PRODUCT_ROASTED_TOMATO = createVariableProduct("prod_roasted_tomato", "Roasted Tomato Paste", 1150, 1850, roastedTomatoImg, [MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_VEGAN], "Deep, umami-rich tomato flavor.");
|
|
280
|
+
export const MOCK_PRODUCT_MINT_LEMON = createSimpleProduct("prod_mint_lemon", "Mint Lemon Paste", 1200, lemonImg, // Reusing lemon image for now
|
|
279
281
|
[MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Refreshing mint and lemon blend.");
|
|
280
|
-
export const MOCK_PRODUCT_CHILI_GARLIC = createVariableProduct("prod_chili_garlic", "Chili Garlic Paste",
|
|
282
|
+
export const MOCK_PRODUCT_CHILI_GARLIC = createVariableProduct("prod_chili_garlic", "Chili Garlic Paste", 1050, 1650, redPepperImg, // Reusing red pepper image
|
|
281
283
|
[MOCK_CATEGORY_PASTES, MOCK_CATEGORY_BASIC, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Spicy garlic paste with chili flakes.");
|
|
282
|
-
export const MOCK_PRODUCT_HABANERO = createSimpleProduct("prod_habanero", "Habanero Paste",
|
|
284
|
+
export const MOCK_PRODUCT_HABANERO = createSimpleProduct("prod_habanero", "Habanero Paste", 1400, redPepperImg, // Reusing red pepper image
|
|
283
285
|
[MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPICY, MOCK_CATEGORY_VEGAN], "Extremely spicy habanero concentrate.");
|
|
284
|
-
export const MOCK_PRODUCT_BLACK_GARLIC = createSimpleProduct("prod_black_garlic", "Black Garlic Paste",
|
|
286
|
+
export const MOCK_PRODUCT_BLACK_GARLIC = createSimpleProduct("prod_black_garlic", "Black Garlic Paste", 1800, garlicImg, // Reusing garlic image
|
|
285
287
|
[MOCK_CATEGORY_PASTES, MOCK_CATEGORY_SPECIALTY, MOCK_CATEGORY_VEGAN], "Fermented black garlic paste, sweet and savory.");
|
|
286
288
|
// --- ORDERS ---
|
|
287
289
|
// Helper to create line item
|
|
@@ -295,12 +297,12 @@ const createLineItem = (product, variantIndex = 0, quantity = 1) => {
|
|
|
295
297
|
price: variant.price,
|
|
296
298
|
taxes: [],
|
|
297
299
|
discount: {
|
|
298
|
-
itemDiscount: { percentage: 0, amount:
|
|
299
|
-
cartDiscount: { percentage: 0, amount:
|
|
300
|
+
itemDiscount: { percentage: 0, amount: 0 },
|
|
301
|
+
cartDiscount: { percentage: 0, amount: 0 }
|
|
300
302
|
},
|
|
301
|
-
fee: { itemFee: { percentage: 0, amount:
|
|
302
|
-
totalTax:
|
|
303
|
-
total:
|
|
303
|
+
fee: { itemFee: { percentage: 0, amount: 0, tax: 0, taxTableId: "" } },
|
|
304
|
+
totalTax: 0,
|
|
305
|
+
total: variant.price * quantity,
|
|
304
306
|
metadata: [],
|
|
305
307
|
image: product.images?.[0] || "",
|
|
306
308
|
sku: variant.sku,
|
|
@@ -310,17 +312,19 @@ const createLineItem = (product, variantIndex = 0, quantity = 1) => {
|
|
|
310
312
|
};
|
|
311
313
|
export const MOCK_ORDER_1 = {
|
|
312
314
|
_id: "order_1001",
|
|
315
|
+
currency: CurrencyCode.USD,
|
|
316
|
+
minorUnits: 2,
|
|
313
317
|
receiptId: "1001-0001",
|
|
314
318
|
companyId: COMPANY_ID,
|
|
315
319
|
externalId: null,
|
|
316
320
|
status: "completed",
|
|
317
321
|
customer: MOCK_CUSTOMER_1,
|
|
318
322
|
summary: {
|
|
319
|
-
total:
|
|
320
|
-
subTotal:
|
|
321
|
-
discountTotal:
|
|
322
|
-
shippingTotal:
|
|
323
|
-
totalTaxes:
|
|
323
|
+
total: 2100,
|
|
324
|
+
subTotal: 2100,
|
|
325
|
+
discountTotal: 0,
|
|
326
|
+
shippingTotal: 0,
|
|
327
|
+
totalTaxes: 0,
|
|
324
328
|
taxes: [],
|
|
325
329
|
isTaxInclusive: false
|
|
326
330
|
},
|
|
@@ -330,7 +334,7 @@ export const MOCK_ORDER_1 = {
|
|
|
330
334
|
{
|
|
331
335
|
transactionId: "trans_cash_1",
|
|
332
336
|
paymentType: "cash",
|
|
333
|
-
amount:
|
|
337
|
+
amount: 2100,
|
|
334
338
|
timestamp: new Date().toISOString(),
|
|
335
339
|
processor: "cash"
|
|
336
340
|
}
|
|
@@ -346,11 +350,11 @@ export const MOCK_ORDER_1 = {
|
|
|
346
350
|
billing: MOCK_CUSTOMER_1.billing || null,
|
|
347
351
|
shipping: null,
|
|
348
352
|
lineItems: [
|
|
349
|
-
createLineItem(MOCK_PRODUCT_GARLIC, 0, 1),
|
|
350
|
-
createLineItem(MOCK_PRODUCT_BASIL_ALMOND, 0, 1)
|
|
353
|
+
createLineItem(MOCK_PRODUCT_GARLIC, 0, 1),
|
|
354
|
+
createLineItem(MOCK_PRODUCT_BASIL_ALMOND, 0, 1)
|
|
351
355
|
],
|
|
352
356
|
customSales: [],
|
|
353
|
-
balance:
|
|
357
|
+
balance: 0,
|
|
354
358
|
user: MOCK_USER_LUIGI,
|
|
355
359
|
outlet: MOCK_OUTLET_MAIN,
|
|
356
360
|
station: MOCK_STATION_1,
|
|
@@ -358,17 +362,19 @@ export const MOCK_ORDER_1 = {
|
|
|
358
362
|
};
|
|
359
363
|
export const MOCK_ORDER_2 = {
|
|
360
364
|
_id: "order_1002",
|
|
365
|
+
currency: CurrencyCode.USD,
|
|
366
|
+
minorUnits: 2,
|
|
361
367
|
receiptId: "1001-0002",
|
|
362
368
|
companyId: COMPANY_ID,
|
|
363
369
|
externalId: null,
|
|
364
370
|
status: "completed",
|
|
365
371
|
customer: MOCK_CUSTOMER_2,
|
|
366
372
|
summary: {
|
|
367
|
-
total:
|
|
368
|
-
subTotal:
|
|
369
|
-
discountTotal:
|
|
370
|
-
shippingTotal:
|
|
371
|
-
totalTaxes:
|
|
373
|
+
total: 3000,
|
|
374
|
+
subTotal: 3000,
|
|
375
|
+
discountTotal: 0,
|
|
376
|
+
shippingTotal: 0,
|
|
377
|
+
totalTaxes: 0,
|
|
372
378
|
taxes: [],
|
|
373
379
|
isTaxInclusive: false
|
|
374
380
|
},
|
|
@@ -378,7 +384,7 @@ export const MOCK_ORDER_2 = {
|
|
|
378
384
|
{
|
|
379
385
|
transactionId: "trans_card_1",
|
|
380
386
|
paymentType: "credit_card",
|
|
381
|
-
amount:
|
|
387
|
+
amount: 3000,
|
|
382
388
|
timestamp: new Date(Date.now() - 3600000).toISOString(),
|
|
383
389
|
processor: "stripe"
|
|
384
390
|
}
|
|
@@ -394,10 +400,10 @@ export const MOCK_ORDER_2 = {
|
|
|
394
400
|
billing: null,
|
|
395
401
|
shipping: null,
|
|
396
402
|
lineItems: [
|
|
397
|
-
createLineItem(MOCK_PRODUCT_BEER, 0, 2)
|
|
403
|
+
createLineItem(MOCK_PRODUCT_BEER, 0, 2)
|
|
398
404
|
],
|
|
399
405
|
customSales: [],
|
|
400
|
-
balance:
|
|
406
|
+
balance: 0,
|
|
401
407
|
user: MOCK_USER_MARIO,
|
|
402
408
|
outlet: MOCK_OUTLET_MAIN,
|
|
403
409
|
station: MOCK_STATION_2,
|
|
@@ -450,6 +456,7 @@ export let MOCK_CART = {
|
|
|
450
456
|
remainingBalance: 0,
|
|
451
457
|
products: [],
|
|
452
458
|
customSales: [],
|
|
459
|
+
nonRevenueItems: [],
|
|
453
460
|
customer: null
|
|
454
461
|
};
|
|
455
462
|
// Helper to reset cart
|
|
@@ -461,6 +468,7 @@ export const resetMockCart = () => {
|
|
|
461
468
|
remainingBalance: 0,
|
|
462
469
|
products: [],
|
|
463
470
|
customSales: [],
|
|
471
|
+
nonRevenueItems: [],
|
|
464
472
|
customer: null
|
|
465
473
|
};
|
|
466
474
|
};
|
|
@@ -499,53 +507,53 @@ export const createOrderFromCart = (paymentType, amount, processor = "cash") =>
|
|
|
499
507
|
const receiptId = `receipt_${Date.now()}`;
|
|
500
508
|
// Map cart products to line items
|
|
501
509
|
const lineItems = MOCK_CART.products.map(p => {
|
|
502
|
-
// Find original product to get attributes/variants if needed
|
|
503
|
-
// For simplicity, we use what's in cart
|
|
504
510
|
return {
|
|
505
511
|
productId: p.id,
|
|
506
512
|
variantId: p.variantId,
|
|
507
513
|
name: p.name,
|
|
508
514
|
quantity: p.quantity,
|
|
509
|
-
price:
|
|
515
|
+
price: p.price,
|
|
510
516
|
taxes: [],
|
|
511
517
|
discount: {
|
|
512
|
-
itemDiscount: { percentage: 0, amount:
|
|
513
|
-
cartDiscount: { percentage: 0, amount:
|
|
518
|
+
itemDiscount: { percentage: 0, amount: 0, const: "0" },
|
|
519
|
+
cartDiscount: { percentage: 0, amount: 0, const: "0" }
|
|
514
520
|
},
|
|
515
|
-
fee: { itemFee: { percentage: 0, amount:
|
|
516
|
-
totalTax:
|
|
517
|
-
total:
|
|
521
|
+
fee: { itemFee: { percentage: 0, amount: 0, tax: 0, taxTableId: "" } },
|
|
522
|
+
totalTax: 0,
|
|
523
|
+
total: p.price * p.quantity,
|
|
518
524
|
metadata: [],
|
|
519
525
|
image: p.images?.[0] || "",
|
|
520
526
|
sku: p.sku || "",
|
|
521
|
-
stock: 100,
|
|
527
|
+
stock: 100,
|
|
522
528
|
attributes: p.attributes || ""
|
|
523
529
|
};
|
|
524
530
|
});
|
|
525
|
-
const
|
|
531
|
+
const totalNum = MOCK_CART.total;
|
|
526
532
|
const newOrder = {
|
|
527
533
|
_id: orderId,
|
|
534
|
+
currency: CurrencyCode.USD,
|
|
535
|
+
minorUnits: 2,
|
|
528
536
|
receiptId,
|
|
529
537
|
companyId: COMPANY_ID,
|
|
530
538
|
externalId: null,
|
|
531
539
|
status: "completed",
|
|
532
540
|
customer: MOCK_CART.customer ? MOCK_CART.customer : null,
|
|
533
541
|
summary: {
|
|
534
|
-
total:
|
|
535
|
-
subTotal:
|
|
536
|
-
discountTotal:
|
|
537
|
-
shippingTotal:
|
|
538
|
-
totalTaxes:
|
|
542
|
+
total: totalNum,
|
|
543
|
+
subTotal: totalNum,
|
|
544
|
+
discountTotal: 0,
|
|
545
|
+
shippingTotal: 0,
|
|
546
|
+
totalTaxes: 0,
|
|
539
547
|
taxes: [],
|
|
540
548
|
isTaxInclusive: false
|
|
541
549
|
},
|
|
542
|
-
cartDiscount: MOCK_CART.discount ? { label: MOCK_CART.discount.label || "Discount", amount:
|
|
550
|
+
cartDiscount: MOCK_CART.discount ? { label: MOCK_CART.discount.label || "Discount", amount: 0, percentage: MOCK_CART.discount.value } : null,
|
|
543
551
|
cartFees: [],
|
|
544
552
|
paymentMethods: [
|
|
545
553
|
{
|
|
546
554
|
transactionId: `trans_${Date.now()}`,
|
|
547
555
|
paymentType,
|
|
548
|
-
amount
|
|
556
|
+
amount,
|
|
549
557
|
timestamp: new Date().toISOString(),
|
|
550
558
|
processor
|
|
551
559
|
}
|
|
@@ -562,7 +570,7 @@ export const createOrderFromCart = (paymentType, amount, processor = "cash") =>
|
|
|
562
570
|
shipping: MOCK_CART.customer?.shipping || null,
|
|
563
571
|
lineItems,
|
|
564
572
|
customSales: [],
|
|
565
|
-
balance:
|
|
573
|
+
balance: 0,
|
|
566
574
|
user: MOCK_USER_LUIGI,
|
|
567
575
|
outlet: MOCK_OUTLET_MAIN,
|
|
568
576
|
station: MOCK_STATION_1,
|
|
@@ -235,7 +235,7 @@ export const MOCK_CUSTOM_EXTENSIONS = [
|
|
|
235
235
|
"https://example.com/images/loyalty-1.png",
|
|
236
236
|
"https://example.com/images/loyalty-2.png"
|
|
237
237
|
],
|
|
238
|
-
price:
|
|
238
|
+
price: 2999,
|
|
239
239
|
website: "https://loyalty-extension.example.com",
|
|
240
240
|
isDeleted: false,
|
|
241
241
|
createdAt: "2024-01-01T10:00:00.000Z",
|
|
@@ -250,7 +250,7 @@ export const MOCK_CUSTOM_EXTENSIONS = [
|
|
|
250
250
|
short_description: "Real-time inventory insights",
|
|
251
251
|
long_description: "Get detailed insights into your inventory with real-time tracking, low stock alerts, and comprehensive reporting.",
|
|
252
252
|
main_image: "https://example.com/images/inventory-extension.png",
|
|
253
|
-
price:
|
|
253
|
+
price: 4999,
|
|
254
254
|
isDeleted: false,
|
|
255
255
|
createdAt: "2024-01-05T08:00:00.000Z",
|
|
256
256
|
updatedAt: "2024-01-05T08:00:00.000Z",
|
|
@@ -264,7 +264,7 @@ export const MOCK_CUSTOM_EXTENSIONS = [
|
|
|
264
264
|
short_description: "Automated email marketing",
|
|
265
265
|
long_description: "Create and manage email campaigns, automate customer communications, and track engagement metrics.",
|
|
266
266
|
main_image: "https://example.com/images/email-extension.png",
|
|
267
|
-
price:
|
|
267
|
+
price: 3999,
|
|
268
268
|
isDeleted: false,
|
|
269
269
|
createdAt: "2024-01-08T12:00:00.000Z",
|
|
270
270
|
updatedAt: "2024-01-08T12:00:00.000Z",
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const command: {
|
|
|
3
3
|
readonly generateAPIKey: import("./actions/generate-api-key/types").GenerateAPIKey;
|
|
4
4
|
readonly getProducts: import("./actions/get-products/types").GetProducts;
|
|
5
5
|
readonly addCustomSale: import("./actions/add-custom-sale/types").AddCustomSale;
|
|
6
|
+
readonly addNonRevenueItem: import("./actions/add-non-revenue-item/types").AddNonRevenueItem;
|
|
6
7
|
readonly getCustomers: import("./actions/get-customers/types").GetCustomers;
|
|
7
8
|
readonly assignCustomer: import("./actions/assign-customer/types").AssignCustomer;
|
|
8
9
|
readonly addCustomer: import("./actions/add-customer/types").AddCustomer;
|
|
@@ -30,6 +31,8 @@ export declare const command: {
|
|
|
30
31
|
readonly tapToPayPayment: import("./actions/tap-to-pay-payment/types").TapToPayPayment;
|
|
31
32
|
readonly terminalPayment: import("./actions/terminal-payment/types").TerminalPayment;
|
|
32
33
|
readonly vendaraPayment: import("./actions/vendara-payment/types").VendaraPayment;
|
|
34
|
+
readonly extensionPayment: import("./actions/extension-payment/types").ExtensionPayment;
|
|
35
|
+
readonly redeemPayment: import("./actions/redeem-payment/types").RedeemPayment;
|
|
33
36
|
readonly addCustomerNote: import("./actions/add-customer-note/types").AddCustomerNote;
|
|
34
37
|
readonly removeCustomerFromCart: import("./actions/remove-customer-from-cart/types").RemoveCustomerFromCart;
|
|
35
38
|
readonly goToStationHome: import("./actions/go-to-station-home/types").GoToStationHome;
|
|
@@ -74,6 +77,7 @@ export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse }
|
|
|
74
77
|
export type { GenerateAPIKey, GenerateAPIKeyParams, GenerateAPIKeyResponse } from "./actions/generate-api-key/types";
|
|
75
78
|
export type { GetProducts, GetProductsParams, GetProductsResponse } from "./actions/get-products/types";
|
|
76
79
|
export type { AddCustomSale, AddCustomSaleParams, AddCustomSaleResponse } from "./actions/add-custom-sale/types";
|
|
80
|
+
export type { AddNonRevenueItem, AddNonRevenueItemParams, AddNonRevenueItemResponse } from "./actions/add-non-revenue-item/types";
|
|
77
81
|
export type { GetCustomers, GetCustomersParams, GetCustomersResponse } from "./actions/get-customers/types";
|
|
78
82
|
export type { AssignCustomer, AssignCustomerParams, AssignCustomerResponse } from "./actions/assign-customer/types";
|
|
79
83
|
export type { AddCustomer, AddCustomerParams, AddCustomerResponse } from "./actions/add-customer/types";
|
|
@@ -114,6 +118,11 @@ export type { CashPayment, CashPaymentParams, CashPaymentResponse } from "./acti
|
|
|
114
118
|
export type { TapToPayPayment, TapToPayPaymentParams, TapToPayPaymentResponse } from "./actions/tap-to-pay-payment/types";
|
|
115
119
|
export type { TerminalPayment, TerminalPaymentParams, TerminalPaymentResponse } from "./actions/terminal-payment/types";
|
|
116
120
|
export type { VendaraPayment, VendaraPaymentParams, VendaraPaymentResponse } from "./actions/vendara-payment/types";
|
|
121
|
+
export type { ExtensionPayment, ExtensionPaymentParams, ExtensionPaymentResponse } from "./actions/extension-payment/types";
|
|
122
|
+
export type { RedeemPayment, RedeemPaymentParams, RedeemPaymentResponse } from "./actions/redeem-payment/types";
|
|
123
|
+
export { EXTENSION_REFUND_REQUEST_ACTION } from "./actions/extension-refund/constants";
|
|
124
|
+
export { installExtensionRefundListener } from "./actions/extension-refund/extension-refund-listener";
|
|
125
|
+
export type { ExtensionRefundParams, ExtensionRefundResponse } from "./actions/extension-refund/types";
|
|
117
126
|
export type { AddCustomerNote, AddCustomerNoteParams, AddCustomerNoteResponse } from "./actions/add-customer-note/types";
|
|
118
127
|
export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from "./actions/remove-customer-from-cart/types";
|
|
119
128
|
export type { GoToStationHome, GoToStationHomeResponse } from "./actions/go-to-station-home/types";
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { exampleFunction } from "./actions/example-function/action";
|
|
3
3
|
import { getProducts } from "./actions/get-products/action";
|
|
4
4
|
import { addCustomSale } from "./actions/add-custom-sale/action";
|
|
5
|
+
import { addNonRevenueItem } from "./actions/add-non-revenue-item/action";
|
|
5
6
|
import { getCustomers } from "./actions/get-customers/action";
|
|
6
7
|
import { assignCustomer } from "./actions/assign-customer/action";
|
|
7
8
|
import { addCustomer } from "./actions/add-customer/action";
|
|
@@ -30,6 +31,8 @@ import { cashPayment } from "./actions/cash-payment/action";
|
|
|
30
31
|
import { tapToPayPayment } from "./actions/tap-to-pay-payment/action";
|
|
31
32
|
import { terminalPayment } from "./actions/terminal-payment/action";
|
|
32
33
|
import { vendaraPayment } from "./actions/vendara-payment/action";
|
|
34
|
+
import { extensionPayment } from "./actions/extension-payment/action";
|
|
35
|
+
import { redeemPayment } from "./actions/redeem-payment/action";
|
|
33
36
|
// Customer Actions
|
|
34
37
|
import { addCustomerNote } from "./actions/add-customer-note/action";
|
|
35
38
|
import { removeCustomerFromCart } from "./actions/remove-customer-from-cart/action";
|
|
@@ -86,6 +89,7 @@ export const command = {
|
|
|
86
89
|
generateAPIKey,
|
|
87
90
|
getProducts,
|
|
88
91
|
addCustomSale,
|
|
92
|
+
addNonRevenueItem,
|
|
89
93
|
getCustomers,
|
|
90
94
|
assignCustomer,
|
|
91
95
|
addCustomer,
|
|
@@ -115,6 +119,8 @@ export const command = {
|
|
|
115
119
|
tapToPayPayment,
|
|
116
120
|
terminalPayment,
|
|
117
121
|
vendaraPayment,
|
|
122
|
+
extensionPayment,
|
|
123
|
+
redeemPayment,
|
|
118
124
|
// Customer Actions
|
|
119
125
|
addCustomerNote,
|
|
120
126
|
removeCustomerFromCart,
|
|
@@ -165,6 +171,8 @@ export const command = {
|
|
|
165
171
|
getSecretVal,
|
|
166
172
|
setSecretVal,
|
|
167
173
|
};
|
|
174
|
+
export { EXTENSION_REFUND_REQUEST_ACTION } from "./actions/extension-refund/constants";
|
|
175
|
+
export { installExtensionRefundListener } from "./actions/extension-refund/extension-refund-listener";
|
|
168
176
|
// Export Common Types
|
|
169
177
|
export * from "./CommonTypes";
|
|
170
178
|
// Export Provider
|
|
@@ -45,6 +45,9 @@ import { mockTerminalPayment } from "../../actions/terminal-payment/mock";
|
|
|
45
45
|
import { mockTriggerWebhook } from "../../actions/trigger-webhook/mock";
|
|
46
46
|
import { mockTriggerZapierWebhook } from "../../actions/trigger-zapier-webhook/mock";
|
|
47
47
|
import { mockVendaraPayment } from "../../actions/vendara-payment/mock";
|
|
48
|
+
import { mockExtensionPayment } from "../../actions/extension-payment/mock";
|
|
49
|
+
import { mockRedeemPayment } from "../../actions/redeem-payment/mock";
|
|
50
|
+
import { mockAddNonRevenueItem } from "../../actions/add-non-revenue-item/mock";
|
|
48
51
|
import { mockGetFinalContext } from "../../actions/get-final-context/mock";
|
|
49
52
|
import { mockPrint } from "../../actions/print/mock";
|
|
50
53
|
import { mockSetActiveOrder } from "../../actions/set-active-order/mock";
|
|
@@ -109,6 +112,9 @@ export const RENDER_MOCKS = {
|
|
|
109
112
|
triggerWebhook: mockTriggerWebhook,
|
|
110
113
|
triggerZapierWebhook: mockTriggerZapierWebhook,
|
|
111
114
|
vendaraPayment: mockVendaraPayment,
|
|
115
|
+
extensionPayment: mockExtensionPayment,
|
|
116
|
+
redeemPayment: mockRedeemPayment,
|
|
117
|
+
addNonRevenueItem: mockAddNonRevenueItem,
|
|
112
118
|
getFinalContext: mockGetFinalContext,
|
|
113
119
|
print: mockPrint,
|
|
114
120
|
setActiveOrder: mockSetActiveOrder,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles } from "../../index";
|
|
1
|
+
import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, RemoveProductFromCart, UpdateCartItemQuantity, AddCartDiscount, GetContext, GetFinalContext, AddProductNote, AddProductFee, AdjustInventory, AddOrderNote, AddCartFee, ClearCart, ParkOrder, ResumeParkedOrder, DeleteParkedOrder, InitiateRefund, CashPayment, TapToPayPayment, TerminalPayment, VendaraPayment, ExtensionPayment, RedeemPayment, AddNonRevenueItem, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart, Print, SetActiveOrder, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomTableFields, GetSecretsKeys, GetSecretVal, SetSecretVal, GetUsers, GetRoles } from "../../index";
|
|
2
2
|
export interface RenderProviderActions {
|
|
3
3
|
exampleFunction: ExampleFunction;
|
|
4
4
|
getProducts: GetProducts;
|
|
@@ -30,6 +30,9 @@ export interface RenderProviderActions {
|
|
|
30
30
|
tapToPayPayment: TapToPayPayment;
|
|
31
31
|
terminalPayment: TerminalPayment;
|
|
32
32
|
vendaraPayment: VendaraPayment;
|
|
33
|
+
extensionPayment: ExtensionPayment;
|
|
34
|
+
redeemPayment: RedeemPayment;
|
|
35
|
+
addNonRevenueItem: AddNonRevenueItem;
|
|
33
36
|
addCustomerNote: AddCustomerNote;
|
|
34
37
|
removeCustomerFromCart: RemoveCustomerFromCart;
|
|
35
38
|
goToStationHome: GoToStationHome;
|