@final-commerce/command-frame 0.1.7 → 0.1.10

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 (39) hide show
  1. package/README.md +28 -29
  2. package/dist/CommonTypes.d.ts +0 -1
  3. package/dist/actions/add-custom-sale/mock.js +3 -0
  4. package/dist/actions/add-custom-sale/types.d.ts +1 -0
  5. package/dist/actions/add-product-discount/mock.js +1 -0
  6. package/dist/actions/add-product-discount/types.d.ts +2 -0
  7. package/dist/actions/add-product-fee/mock.js +1 -0
  8. package/dist/actions/add-product-fee/types.d.ts +2 -0
  9. package/dist/actions/add-product-note/mock.js +1 -0
  10. package/dist/actions/add-product-note/types.d.ts +2 -0
  11. package/dist/actions/add-product-to-cart/mock.js +20 -16
  12. package/dist/actions/add-product-to-cart/types.d.ts +6 -1
  13. package/dist/actions/adjust-inventory/types.d.ts +1 -0
  14. package/dist/actions/calculate-refund-total/mock.js +2 -2
  15. package/dist/actions/calculate-refund-total/types.d.ts +4 -1
  16. package/dist/actions/get-final-context/mock.d.ts +2 -0
  17. package/dist/actions/get-final-context/mock.js +6 -0
  18. package/dist/actions/get-products/types.d.ts +2 -0
  19. package/dist/actions/get-remaining-refundable-quantities/mock.js +2 -2
  20. package/dist/actions/get-remaining-refundable-quantities/types.d.ts +4 -1
  21. package/dist/actions/process-partial-refund/mock.js +1 -1
  22. package/dist/actions/process-partial-refund/types.d.ts +6 -0
  23. package/dist/actions/select-all-refund-items/mock.js +2 -2
  24. package/dist/actions/select-all-refund-items/types.d.ts +4 -1
  25. package/dist/actions/set-refund-stock-action/mock.js +1 -0
  26. package/dist/actions/set-refund-stock-action/types.d.ts +2 -0
  27. package/dist/actions/trigger-webhook/types.d.ts +3 -2
  28. package/dist/actions/trigger-webhook/types.js +1 -0
  29. package/dist/demo/database.js +0 -2
  30. package/dist/demo/registry.js +2 -2
  31. package/dist/index.d.ts +5 -6
  32. package/dist/index.js +2 -2
  33. package/package.json +1 -1
  34. package/dist/actions/set-product-active/action.d.ts +0 -6
  35. package/dist/actions/set-product-active/action.js +0 -8
  36. package/dist/actions/set-product-active/mock.d.ts +0 -2
  37. package/dist/actions/set-product-active/mock.js +0 -8
  38. package/dist/actions/set-product-active/types.d.ts +0 -9
  39. package/dist/actions/set-product-active/types.js +0 -1
package/README.md CHANGED
@@ -38,12 +38,11 @@ The library provides a `command` namespace object containing all available comma
38
38
  - **[getFinalContext](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/get-final-context/README.md)** - Get final context information (project name)
39
39
 
40
40
  #### Product Actions
41
- - **[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
42
- - **[addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)** - Add a discount to the currently active product
43
- - **[addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)** - Add the currently active product to the cart
44
- - **[addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)** - Add a note to the currently active product
45
- - **[addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)** - Add a fee to the currently active product
46
- - **[adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)** - Adjust inventory/stock level for the currently active product
41
+ - **[addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)** - Add a product to the cart with optional discounts, fees, and notes
42
+ - **[addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)** - Add a discount to a specific product in the cart (using `cartItemId`)
43
+ - **[addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)** - Add a note to a specific product in the cart (using `cartItemId`)
44
+ - **[addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)** - Add a fee to a specific product in the cart (using `cartItemId`)
45
+ - **[adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)** - Adjust inventory/stock level for a specific product variant
47
46
 
48
47
  #### Order Actions
49
48
  - **[addCustomSale](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-custom-sale/README.md)** - Add a custom sale item to the cart
@@ -116,19 +115,24 @@ const variants = await command.getProductVariants({
116
115
  productId: '691df9c6c478bada1fb23d31'
117
116
  });
118
117
 
119
- // Set a variant as active, add discount, then add to cart
120
- await command.setProductActive({
121
- variantId: '691df9c6c478bada1fb23d55'
118
+ // Add product to cart with optional discounts and fees
119
+ const addedProduct = await command.addProductToCart({
120
+ variantId: '691df9c6c478bada1fb23d55',
121
+ quantity: 1,
122
+ discounts: [{
123
+ amount: 10,
124
+ isPercent: false,
125
+ label: 'Discount'
126
+ }],
127
+ notes: 'No onions'
122
128
  });
123
129
 
130
+ // Add a discount to the specific item just added (if you didn't add it during creation)
124
131
  await command.addProductDiscount({
125
- amount: 10,
126
- isPercent: false,
127
- label: 'Discount'
128
- });
129
-
130
- await command.addProductToCart({
131
- quantity: 1
132
+ cartItemId: addedProduct.internalId,
133
+ amount: 5,
134
+ isPercent: true,
135
+ label: 'Extra 5% Off'
132
136
  });
133
137
 
134
138
  // Add cart discount
@@ -188,17 +192,13 @@ Retrieves the current cart object with all its contents including products, cust
188
192
 
189
193
  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.
190
194
 
191
- ### [setProductActive](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/set-product-active/README.md)
195
+ ### [addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)
192
196
 
193
- Sets a product variant as the active product in the parent application. Required before adding discounts or adding products to cart.
197
+ Adds a product to the cart. Supports specifying quantity, applying discounts, fees, and notes in a single atomic operation.
194
198
 
195
199
  ### [addProductDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-discount/README.md)
196
200
 
197
- Adds a discount to the currently active product. Supports both fixed amount and percentage discounts. The product must be set as active first.
198
-
199
- ### [addProductToCart](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-to-cart/README.md)
200
-
201
- Adds the currently active product to the cart. Supports specifying quantity. The product must be set as active first.
201
+ Adds a discount to a specific product in the cart (identified by `cartItemId`). Supports both fixed amount and percentage discounts.
202
202
 
203
203
  ### [addCartDiscount](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-cart-discount/README.md)
204
204
 
@@ -212,15 +212,15 @@ Retrieves the current environment/context information from the parent applicatio
212
212
 
213
213
  ### [addProductNote](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-note/README.md)
214
214
 
215
- Adds a note to the currently active product in the cart. Requires a product to be set as active first.
215
+ Adds a note to a specific product in the cart (identified by `cartItemId`).
216
216
 
217
217
  ### [addProductFee](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/add-product-fee/README.md)
218
218
 
219
- Adds a fee to the currently active product. Supports both fixed amount and percentage-based fees. Requires a product to be set as active first.
219
+ Adds a fee to a specific product in the cart (identified by `cartItemId`). Supports both fixed amount and percentage-based fees.
220
220
 
221
221
  ### [adjustInventory](https://github.com/Final-Commerce/command-frame/blob/main/src/actions/adjust-inventory/README.md)
222
222
 
223
- Adjusts the inventory/stock level for the currently active product. Supports adding, subtracting, or setting stock to a specific value.
223
+ Adjusts the inventory/stock level for a specific product variant. Supports adding, subtracting, or setting stock to a specific value.
224
224
 
225
225
  ### Order Actions
226
226
 
@@ -461,7 +461,6 @@ import type {
461
461
  GetFinalContext, GetFinalContextResponse,
462
462
  GetCurrentCart, GetCurrentCartResponse,
463
463
  // Product Actions
464
- SetProductActiveParams, SetProductActiveResponse, SetProductActive,
465
464
  AddProductDiscountParams, AddProductDiscountResponse, AddProductDiscount,
466
465
  AddProductToCartParams, AddProductToCartResponse, AddProductToCart,
467
466
  AddProductNoteParams, AddProductNoteResponse, AddProductNote,
@@ -500,12 +499,12 @@ import type {
500
499
  SwitchUserParams, SwitchUserResponse, SwitchUser,
501
500
  // Refund Actions
502
501
  GetLineItemsByOrderParams, GetLineItemsByOrderResponse, GetLineItemsByOrder,
503
- SelectAllRefundItemsResponse, SelectAllRefundItems,
502
+ SelectAllRefundItemsParams, SelectAllRefundItemsResponse, SelectAllRefundItems,
504
503
  ResetRefundDetailsResponse, ResetRefundDetails,
505
504
  SetRefundStockActionParams, SetRefundStockActionResponse, SetRefundStockAction,
506
505
  CalculateRefundTotalResponse, CalculateRefundTotal,
507
506
  ProcessPartialRefundParams, ProcessPartialRefundResponse, ProcessPartialRefund,
508
- GetRemainingRefundableQuantitiesResponse, GetRemainingRefundableQuantities,
507
+ GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse, GetRemainingRefundableQuantities,
509
508
  // Integration Actions
510
509
  TriggerWebhookParams, TriggerWebhookResponse, TriggerWebhook,
511
510
  TriggerZapierWebhookParams, TriggerZapierWebhookResponse, TriggerZapierWebhook,
@@ -125,7 +125,6 @@ export interface CFProduct {
125
125
  variants: CFProductVariant[];
126
126
  minPrice?: string;
127
127
  maxPrice?: string;
128
- price?: string;
129
128
  status?: string;
130
129
  isDeleted?: boolean;
131
130
  }
@@ -2,8 +2,11 @@ export const mockAddCustomSale = async (params) => {
2
2
  console.log("[Mock] addCustomSale called", params);
3
3
  if (!params)
4
4
  throw new Error("Params required");
5
+ // Simple mock ID generation
6
+ const mockId = 'sale_' + Math.random().toString(36).substr(2, 9);
5
7
  return {
6
8
  success: true,
9
+ customSaleId: mockId,
7
10
  label: params.label,
8
11
  price: Number(params.price),
9
12
  applyTaxes: params.applyTaxes ?? false,
@@ -5,6 +5,7 @@ export interface AddCustomSaleParams {
5
5
  }
6
6
  export interface AddCustomSaleResponse {
7
7
  success: boolean;
8
+ customSaleId: string;
8
9
  label: string;
9
10
  price: number;
10
11
  applyTaxes: boolean;
@@ -5,6 +5,7 @@ export const mockAddProductDiscount = async (params) => {
5
5
  amount: params?.amount || 0,
6
6
  isPercent: params?.isPercent || false,
7
7
  label: params?.label || "",
8
+ cartItemId: params?.cartItemId,
8
9
  timestamp: new Date().toISOString()
9
10
  };
10
11
  };
@@ -2,12 +2,14 @@ export interface AddProductDiscountParams {
2
2
  amount: number;
3
3
  isPercent?: boolean;
4
4
  label?: string;
5
+ cartItemId?: string;
5
6
  }
6
7
  export interface AddProductDiscountResponse {
7
8
  success: boolean;
8
9
  amount: number;
9
10
  isPercent: boolean;
10
11
  label: string;
12
+ cartItemId?: string;
11
13
  timestamp: string;
12
14
  }
13
15
  export type AddProductDiscount = (params?: AddProductDiscountParams) => Promise<AddProductDiscountResponse>;
@@ -6,6 +6,7 @@ export const mockAddProductFee = async (params) => {
6
6
  isPercent: params?.isPercent || false,
7
7
  label: params?.label || "",
8
8
  applyTaxes: params?.applyTaxes || false,
9
+ cartItemId: params?.cartItemId,
9
10
  timestamp: new Date().toISOString()
10
11
  };
11
12
  };
@@ -4,6 +4,7 @@ export interface AddProductFeeParams {
4
4
  label?: string;
5
5
  applyTaxes?: boolean;
6
6
  taxTableId?: string;
7
+ cartItemId?: string;
7
8
  }
8
9
  export interface AddProductFeeResponse {
9
10
  success: boolean;
@@ -11,6 +12,7 @@ export interface AddProductFeeResponse {
11
12
  isPercent: boolean;
12
13
  label: string;
13
14
  applyTaxes: boolean;
15
+ cartItemId?: string;
14
16
  timestamp: string;
15
17
  }
16
18
  export type AddProductFee = (params?: AddProductFeeParams) => Promise<AddProductFeeResponse>;
@@ -3,6 +3,7 @@ export const mockAddProductNote = async (params) => {
3
3
  return {
4
4
  success: true,
5
5
  note: params?.note || "",
6
+ cartItemId: params?.cartItemId,
6
7
  timestamp: new Date().toISOString()
7
8
  };
8
9
  };
@@ -1,9 +1,11 @@
1
1
  export interface AddProductNoteParams {
2
2
  note: string;
3
+ cartItemId?: string;
3
4
  }
4
5
  export interface AddProductNoteResponse {
5
6
  success: boolean;
6
7
  note: string;
8
+ cartItemId?: string;
7
9
  timestamp: string;
8
10
  }
9
11
  export type AddProductNote = (params?: AddProductNoteParams) => Promise<AddProductNoteResponse>;
@@ -1,32 +1,33 @@
1
1
  import { MOCK_CART, MOCK_PRODUCTS } from "../../demo/database";
2
2
  export const mockAddProductToCart = async (params) => {
3
3
  console.log("[Mock] addProductToCart called", params);
4
- const productId = params?.productId;
5
4
  const variantId = params?.variantId;
6
5
  const quantity = params?.quantity || 1;
7
6
  let product = MOCK_PRODUCTS[0]; // Default fallback
8
- if (productId) {
9
- const found = MOCK_PRODUCTS.find(p => p._id === productId);
10
- if (found) {
11
- product = found;
12
- }
13
- else {
14
- console.warn(`[Mock] Product with ID ${productId} not found, using default.`);
15
- }
16
- }
17
- // Determine variant
18
7
  let variant = product.variants[0];
8
+ // Determine variant and product from variantId
19
9
  if (variantId) {
20
- const foundVariant = product.variants.find(v => v._id === variantId);
21
- if (foundVariant) {
22
- variant = foundVariant;
10
+ // Search through all products to find the one containing this variant
11
+ for (const p of MOCK_PRODUCTS) {
12
+ const foundVariant = p.variants.find(v => v._id === variantId);
13
+ if (foundVariant) {
14
+ product = p;
15
+ variant = foundVariant;
16
+ break;
17
+ }
23
18
  }
24
19
  }
25
20
  // Add to MOCK_CART
21
+ const internalId = product._id + "_" + Date.now();
22
+ // Process optional fields for mock
23
+ let note = undefined;
24
+ if (params?.notes) {
25
+ note = Array.isArray(params.notes) ? params.notes.join(", ") : params.notes;
26
+ }
26
27
  const activeProduct = {
27
28
  ...product,
28
29
  id: product._id,
29
- internalId: product._id + "_" + Date.now(), // unique ID for cart item
30
+ internalId: internalId, // unique ID for cart item
30
31
  variantId: variant._id,
31
32
  quantity: quantity,
32
33
  price: Number(variant.price),
@@ -35,7 +36,9 @@ export const mockAddProductToCart = async (params) => {
35
36
  images: product.images || [],
36
37
  localQuantity: quantity,
37
38
  sku: variant.sku,
38
- attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", ")
39
+ attributes: variant.attributes.map(a => `${a.name}: ${a.value}`).join(", "),
40
+ note: note
41
+ // discount/fee could be added here to mock object if CFActiveProduct supports it
39
42
  };
40
43
  MOCK_CART.products.push(activeProduct);
41
44
  // Recalculate totals
@@ -49,6 +52,7 @@ export const mockAddProductToCart = async (params) => {
49
52
  success: true,
50
53
  productId: activeProduct.id,
51
54
  variantId: activeProduct.variantId,
55
+ internalId: activeProduct.internalId,
52
56
  name: activeProduct.name,
53
57
  quantity: quantity,
54
58
  timestamp: new Date().toISOString()
@@ -1,12 +1,17 @@
1
+ import type { AddProductDiscountParams } from "../add-product-discount/types";
2
+ import type { AddProductFeeParams } from "../add-product-fee/types";
1
3
  export interface AddProductToCartParams {
2
- productId?: string;
3
4
  variantId?: string;
4
5
  quantity?: number;
6
+ discounts?: AddProductDiscountParams[];
7
+ fees?: AddProductFeeParams[];
8
+ notes?: string | string[];
5
9
  }
6
10
  export interface AddProductToCartResponse {
7
11
  success: boolean;
8
12
  productId: string;
9
13
  variantId: string;
14
+ internalId: string;
10
15
  name: string;
11
16
  quantity: number;
12
17
  timestamp: string;
@@ -1,6 +1,7 @@
1
1
  export interface AdjustInventoryParams {
2
2
  amount: string;
3
3
  stockType: 'add' | 'subtract' | 'set';
4
+ variantId?: string;
4
5
  }
5
6
  export interface AdjustInventoryResponse {
6
7
  success: boolean;
@@ -1,5 +1,5 @@
1
- export const mockCalculateRefundTotal = async () => {
2
- console.log("[Mock] calculateRefundTotal called");
1
+ export const mockCalculateRefundTotal = async (_params) => {
2
+ console.log("[Mock] calculateRefundTotal called", _params);
3
3
  return {
4
4
  success: true,
5
5
  summary: {
@@ -1,4 +1,7 @@
1
1
  import { CFRefundedLineItem, CFRefundedCustomSale } from "../../CommonTypes";
2
+ export interface CalculateRefundTotalParams {
3
+ orderId?: string;
4
+ }
2
5
  export interface CalculateRefundTotalResponse {
3
6
  success: boolean;
4
7
  summary: {
@@ -10,4 +13,4 @@ export interface CalculateRefundTotalResponse {
10
13
  refundedCustomSales: CFRefundedCustomSale[];
11
14
  timestamp: string;
12
15
  }
13
- export type CalculateRefundTotal = () => Promise<CalculateRefundTotalResponse>;
16
+ export type CalculateRefundTotal = (params?: CalculateRefundTotalParams) => Promise<CalculateRefundTotalResponse>;
@@ -0,0 +1,2 @@
1
+ import { GetFinalContext } from "./types";
2
+ export declare const mockGetFinalContext: GetFinalContext;
@@ -0,0 +1,6 @@
1
+ export const mockGetFinalContext = async () => {
2
+ console.log("[Mock] getFinalContext called");
3
+ return {
4
+ projectName: "Mock Project"
5
+ };
6
+ };
@@ -21,6 +21,8 @@ export interface GetProductsParams {
21
21
  externalId?: string;
22
22
  [key: string]: any;
23
23
  };
24
+ offset?: number;
25
+ limit?: number;
24
26
  }
25
27
  export interface GetProductsResponse {
26
28
  products: CFProduct[];
@@ -1,5 +1,5 @@
1
- export const mockGetRemainingRefundableQuantities = async () => {
2
- console.log("[Mock] getRemainingRefundableQuantities called");
1
+ export const mockGetRemainingRefundableQuantities = async (_params) => {
2
+ console.log("[Mock] getRemainingRefundableQuantities called", _params);
3
3
  return {
4
4
  success: true,
5
5
  lineItems: {},
@@ -1,7 +1,10 @@
1
+ export interface GetRemainingRefundableQuantitiesParams {
2
+ orderId?: string;
3
+ }
1
4
  export interface GetRemainingRefundableQuantitiesResponse {
2
5
  success: boolean;
3
6
  lineItems: Record<string, number>;
4
7
  customSales: Record<string, number>;
5
8
  timestamp: string;
6
9
  }
7
- export type GetRemainingRefundableQuantities = () => Promise<GetRemainingRefundableQuantitiesResponse>;
10
+ export type GetRemainingRefundableQuantities = (params?: GetRemainingRefundableQuantitiesParams) => Promise<GetRemainingRefundableQuantitiesResponse>;
@@ -2,7 +2,7 @@ export const mockProcessPartialRefund = async (params) => {
2
2
  console.log("[Mock] processPartialRefund called", params);
3
3
  return {
4
4
  success: true,
5
- refundId: "mock_refund_id",
5
+ refundId: 'mock_refund_' + Date.now(),
6
6
  timestamp: new Date().toISOString()
7
7
  };
8
8
  };
@@ -1,5 +1,11 @@
1
1
  export interface ProcessPartialRefundParams {
2
2
  reason?: string;
3
+ orderId?: string;
4
+ items?: {
5
+ itemKey: string;
6
+ quantity: number;
7
+ type?: 'product' | 'customSale' | 'fee' | 'tip';
8
+ }[];
3
9
  }
4
10
  export interface ProcessPartialRefundResponse {
5
11
  success: boolean;
@@ -1,5 +1,5 @@
1
- export const mockSelectAllRefundItems = async () => {
2
- console.log("[Mock] selectAllRefundItems called");
1
+ export const mockSelectAllRefundItems = async (_params) => {
2
+ console.log("[Mock] selectAllRefundItems called", _params);
3
3
  return {
4
4
  success: true,
5
5
  selectedItemsCount: 5,
@@ -1,6 +1,9 @@
1
+ export interface SelectAllRefundItemsParams {
2
+ orderId?: string;
3
+ }
1
4
  export interface SelectAllRefundItemsResponse {
2
5
  success: boolean;
3
6
  selectedItemsCount: number;
4
7
  timestamp: string;
5
8
  }
6
- export type SelectAllRefundItems = () => Promise<SelectAllRefundItemsResponse>;
9
+ export type SelectAllRefundItems = (params?: SelectAllRefundItemsParams) => Promise<SelectAllRefundItemsResponse>;
@@ -2,6 +2,7 @@ export const mockSetRefundStockAction = async (params) => {
2
2
  console.log("[Mock] setRefundStockAction called", params);
3
3
  return {
4
4
  success: true,
5
+ orderId: params?.orderId,
5
6
  itemKey: params?.itemKey || "",
6
7
  action: params?.action || "RESTOCK",
7
8
  timestamp: new Date().toISOString()
@@ -1,9 +1,11 @@
1
1
  export interface SetRefundStockActionParams {
2
+ orderId?: string;
2
3
  itemKey: string;
3
4
  action: 'RESTOCK' | 'REFUND_DAMAGE';
4
5
  }
5
6
  export interface SetRefundStockActionResponse {
6
7
  success: boolean;
8
+ orderId?: string;
7
9
  itemKey: string;
8
10
  action: string;
9
11
  timestamp: string;
@@ -1,12 +1,13 @@
1
+ export type TriggerWebhookPresetType = 'product' | 'cart' | 'order' | 'customer';
1
2
  export interface TriggerWebhookParams {
2
3
  webhookUrl: string;
3
4
  publicKey?: string;
4
5
  presetData?: boolean;
5
- presetType?: string;
6
+ presetType?: TriggerWebhookPresetType;
6
7
  isCustomHook?: boolean;
7
8
  customHookData?: string;
8
9
  payloadType?: string;
9
- dynamicDataFields?: any[];
10
+ dynamicDataFields?: unknown[];
10
11
  }
11
12
  export interface TriggerWebhookResponse {
12
13
  success: boolean;
@@ -1 +1,2 @@
1
+ // Trigger Webhook Types
1
2
  export {};
@@ -180,7 +180,6 @@ const createSimpleProduct = (id, name, price, image, category, description) => {
180
180
  companyId: COMPANY_ID,
181
181
  externalId: `ext_${id}`,
182
182
  sku,
183
- price,
184
183
  minPrice: price,
185
184
  maxPrice: price,
186
185
  status: "active",
@@ -214,7 +213,6 @@ const createVariableProduct = (id, name, basePrice, largePrice, image, category,
214
213
  companyId: COMPANY_ID,
215
214
  externalId: `ext_${id}`,
216
215
  sku: skuBase,
217
- price: basePrice,
218
216
  minPrice: basePrice,
219
217
  maxPrice: largePrice,
220
218
  status: "active",
@@ -38,7 +38,6 @@ import { mockRemoveCustomerFromCart } from "../actions/remove-customer-from-cart
38
38
  import { mockResetRefundDetails } from "../actions/reset-refund-details/mock";
39
39
  import { mockResumeParkedOrder } from "../actions/resume-parked-order/mock";
40
40
  import { mockSelectAllRefundItems } from "../actions/select-all-refund-items/mock";
41
- import { mockSetProductActive } from "../actions/set-product-active/mock";
42
41
  import { mockSetRefundStockAction } from "../actions/set-refund-stock-action/mock";
43
42
  import { mockShowConfirmation } from "../actions/show-confirmation/mock";
44
43
  import { mockShowNotification } from "../actions/show-notification/mock";
@@ -50,6 +49,7 @@ import { mockTriggerWebhook } from "../actions/trigger-webhook/mock";
50
49
  import { mockTriggerZapierWebhook } from "../actions/trigger-zapier-webhook/mock";
51
50
  import { mockUpdateCustomerFacingDisplay } from "../actions/update-customer-facing-display/mock";
52
51
  import { mockVendaraPayment } from "../actions/vendara-payment/mock";
52
+ import { mockGetFinalContext } from "../actions/get-final-context/mock";
53
53
  export const MOCK_REGISTRY = {
54
54
  "addCartDiscount": mockAddCartDiscount,
55
55
  "addCartFee": mockAddCartFee,
@@ -91,7 +91,6 @@ export const MOCK_REGISTRY = {
91
91
  "resetRefundDetails": mockResetRefundDetails,
92
92
  "resumeParkedOrder": mockResumeParkedOrder,
93
93
  "selectAllRefundItems": mockSelectAllRefundItems,
94
- "setProductActive": mockSetProductActive,
95
94
  "setRefundStockAction": mockSetRefundStockAction,
96
95
  "showConfirmation": mockShowConfirmation,
97
96
  "showNotification": mockShowNotification,
@@ -103,4 +102,5 @@ export const MOCK_REGISTRY = {
103
102
  "triggerZapierWebhook": mockTriggerZapierWebhook,
104
103
  "updateCustomerFacingDisplay": mockUpdateCustomerFacingDisplay,
105
104
  "vendaraPayment": mockVendaraPayment,
105
+ "getFinalContext": mockGetFinalContext,
106
106
  };
package/dist/index.d.ts CHANGED
@@ -9,11 +9,11 @@ export declare const command: {
9
9
  readonly getProductVariants: import("./actions/get-product-variants/types").GetProductVariants;
10
10
  readonly getOrders: import("./actions/get-orders/types").GetOrders;
11
11
  readonly getRefunds: import("./actions/get-refunds/types").GetRefunds;
12
- readonly setProductActive: import("./actions/set-product-active/types").SetProductActive;
13
12
  readonly addProductDiscount: import("./actions/add-product-discount/types").AddProductDiscount;
14
13
  readonly addProductToCart: import("./actions/add-product-to-cart/types").AddProductToCart;
15
14
  readonly addCartDiscount: import("./actions/add-cart-discount/types").AddCartDiscount;
16
15
  readonly getContext: import("./actions/get-context/types").GetContext;
16
+ readonly getFinalContext: import("./actions/get-final-context/types").GetFinalContext;
17
17
  readonly addProductNote: import("./actions/add-product-note/types").AddProductNote;
18
18
  readonly addProductFee: import("./actions/add-product-fee/types").AddProductFee;
19
19
  readonly adjustInventory: import("./actions/adjust-inventory/types").AdjustInventory;
@@ -64,13 +64,12 @@ export type { GetOrders, GetOrdersParams, GetOrdersResponse } from "./actions/ge
64
64
  export type { GetRefunds, GetRefundsParams, GetRefundsResponse } from "./actions/get-refunds/types";
65
65
  export type { GetLineItemsByOrder, GetLineItemsByOrderParams, GetLineItemsByOrderResponse } from "./actions/get-line-items-by-order/types";
66
66
  export type { SetRefundStockAction, SetRefundStockActionParams, SetRefundStockActionResponse } from "./actions/set-refund-stock-action/types";
67
- export type { SelectAllRefundItems, SelectAllRefundItemsResponse } from "./actions/select-all-refund-items/types";
67
+ export type { SelectAllRefundItems, SelectAllRefundItemsParams, SelectAllRefundItemsResponse } from "./actions/select-all-refund-items/types";
68
68
  export type { ResetRefundDetails, ResetRefundDetailsResponse } from "./actions/reset-refund-details/types";
69
- export type { CalculateRefundTotal, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
70
- export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
69
+ export type { CalculateRefundTotal, CalculateRefundTotalParams, CalculateRefundTotalResponse } from "./actions/calculate-refund-total/types";
70
+ export type { GetRemainingRefundableQuantities, GetRemainingRefundableQuantitiesParams, GetRemainingRefundableQuantitiesResponse } from "./actions/get-remaining-refundable-quantities/types";
71
71
  export type { ProcessPartialRefund, ProcessPartialRefundParams, ProcessPartialRefundResponse } from "./actions/process-partial-refund/types";
72
72
  export type { GetCurrentCart, GetCurrentCartResponse } from "./actions/get-current-cart/types";
73
- export type { SetProductActive, SetProductActiveParams, SetProductActiveResponse } from "./actions/set-product-active/types";
74
73
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse } from "./actions/add-product-discount/types";
75
74
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
76
75
  export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
@@ -103,7 +102,7 @@ export type { AuthenticateUser, AuthenticateUserParams, AuthenticateUserResponse
103
102
  export type { UpdateCustomerFacingDisplay, UpdateCustomerFacingDisplayParams, UpdateCustomerFacingDisplayResponse } from "./actions/update-customer-facing-display/types";
104
103
  export type { PartialPayment, PartialPaymentParams, PartialPaymentResponse } from "./actions/partial-payment/types";
105
104
  export type { SwitchUser, SwitchUserParams, SwitchUserResponse } from "./actions/switch-user/types";
106
- export type { TriggerWebhook, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
105
+ export type { TriggerWebhook, TriggerWebhookPresetType, TriggerWebhookParams, TriggerWebhookResponse } from "./actions/trigger-webhook/types";
107
106
  export type { TriggerZapierWebhook, TriggerZapierWebhookParams, TriggerZapierWebhookResponse } from "./actions/trigger-zapier-webhook/types";
108
107
  export * from "./CommonTypes";
109
108
  export { commandFrameClient, CommandFrameClient } from "./client";
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@ import { getProductVariants } from "./actions/get-product-variants/action";
10
10
  import { getOrders } from "./actions/get-orders/action";
11
11
  import { getRefunds } from "./actions/get-refunds/action";
12
12
  import { addCartDiscount } from "./actions/add-cart-discount/action";
13
- import { setProductActive } from "./actions/set-product-active/action";
14
13
  import { getContext } from "./actions/get-context/action";
14
+ import { getFinalContext } from "./actions/get-final-context/action";
15
15
  import { addProductDiscount } from "./actions/add-product-discount/action";
16
16
  import { addProductToCart } from "./actions/add-product-to-cart/action";
17
17
  // Product Actions
@@ -68,11 +68,11 @@ export const command = {
68
68
  getProductVariants,
69
69
  getOrders,
70
70
  getRefunds,
71
- setProductActive,
72
71
  addProductDiscount,
73
72
  addProductToCart,
74
73
  addCartDiscount,
75
74
  getContext,
75
+ getFinalContext,
76
76
  // Product Actions
77
77
  addProductNote,
78
78
  addProductFee,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +0,0 @@
1
- /**
2
- * Set product active action
3
- * Calls the setProductActive action on the parent window
4
- */
5
- import type { SetProductActive } from "./types";
6
- export declare const setProductActive: SetProductActive;
@@ -1,8 +0,0 @@
1
- /**
2
- * Set product active action
3
- * Calls the setProductActive action on the parent window
4
- */
5
- import { commandFrameClient } from "../../client";
6
- export const setProductActive = async (params) => {
7
- return await commandFrameClient.call("setProductActive", params);
8
- };
@@ -1,2 +0,0 @@
1
- import { SetProductActive } from "./types";
2
- export declare const mockSetProductActive: SetProductActive;
@@ -1,8 +0,0 @@
1
- export const mockSetProductActive = async (params) => {
2
- console.log("[Mock] setProductActive called", params);
3
- return {
4
- success: true,
5
- variantId: params?.variantId || "",
6
- timestamp: new Date().toISOString()
7
- };
8
- };
@@ -1,9 +0,0 @@
1
- export interface SetProductActiveParams {
2
- variantId: string;
3
- }
4
- export interface SetProductActiveResponse {
5
- success: boolean;
6
- variantId: string;
7
- timestamp: string;
8
- }
9
- export type SetProductActive = (params?: SetProductActiveParams) => Promise<SetProductActiveResponse>;
@@ -1 +0,0 @@
1
- export {};