@final-commerce/command-frame 0.1.18 → 0.1.20

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 (69) hide show
  1. package/dist/CommonTypes.d.ts +1 -0
  2. package/dist/CommonTypes.js +1 -0
  3. package/dist/actions/delete-custom-table-data/action.d.ts +6 -0
  4. package/dist/actions/delete-custom-table-data/action.js +8 -0
  5. package/dist/actions/delete-custom-table-data/types.d.ts +9 -0
  6. package/dist/actions/delete-custom-table-data/types.js +1 -0
  7. package/dist/actions/get-custom-table-data/action.d.ts +6 -0
  8. package/dist/actions/get-custom-table-data/action.js +8 -0
  9. package/dist/actions/get-custom-table-data/types.d.ts +12 -0
  10. package/dist/actions/get-custom-table-data/types.js +1 -0
  11. package/dist/actions/get-custom-table-fields/action.d.ts +6 -0
  12. package/dist/actions/get-custom-table-fields/action.js +8 -0
  13. package/dist/actions/get-custom-table-fields/types.d.ts +10 -0
  14. package/dist/actions/get-custom-table-fields/types.js +1 -0
  15. package/dist/actions/get-custom-tables/action.d.ts +6 -0
  16. package/dist/actions/get-custom-tables/action.js +8 -0
  17. package/dist/actions/get-custom-tables/types.d.ts +7 -0
  18. package/dist/actions/get-custom-tables/types.js +1 -0
  19. package/dist/actions/remove-product-from-cart/action.d.ts +6 -0
  20. package/dist/actions/remove-product-from-cart/action.js +8 -0
  21. package/dist/actions/remove-product-from-cart/mock.d.ts +2 -0
  22. package/dist/actions/remove-product-from-cart/mock.js +32 -0
  23. package/dist/actions/remove-product-from-cart/types.d.ts +11 -0
  24. package/dist/actions/remove-product-from-cart/types.js +2 -0
  25. package/dist/actions/update-cart-item-quantity/action.d.ts +6 -0
  26. package/dist/actions/update-cart-item-quantity/action.js +8 -0
  27. package/dist/actions/update-cart-item-quantity/mock.d.ts +2 -0
  28. package/dist/actions/update-cart-item-quantity/mock.js +60 -0
  29. package/dist/actions/update-cart-item-quantity/types.d.ts +15 -0
  30. package/dist/actions/update-cart-item-quantity/types.js +2 -0
  31. package/dist/actions/upsert-custom-table-data/action.d.ts +6 -0
  32. package/dist/actions/upsert-custom-table-data/action.js +8 -0
  33. package/dist/actions/upsert-custom-table-data/types.d.ts +10 -0
  34. package/dist/actions/upsert-custom-table-data/types.js +1 -0
  35. package/dist/common-types/custom-tables.d.ts +26 -0
  36. package/dist/common-types/custom-tables.js +8 -0
  37. package/dist/common-types/index.d.ts +1 -0
  38. package/dist/common-types/index.js +1 -0
  39. package/dist/demo/database.d.ts +1 -1
  40. package/dist/demo/database.js +1 -0
  41. package/dist/demo/mocks/custom-tables.d.ts +3 -0
  42. package/dist/demo/mocks/custom-tables.js +46 -0
  43. package/dist/demo/mocks/index.d.ts +1 -0
  44. package/dist/demo/mocks/index.js +1 -0
  45. package/dist/index.d.ts +14 -1
  46. package/dist/index.js +12 -1
  47. package/dist/projects/render/mocks.js +4 -0
  48. package/dist/projects/render/types.d.ts +3 -1
  49. package/dist/pubsub/topics/cart/index.js +5 -0
  50. package/dist/pubsub/topics/cart/product-updated/types.d.ts +14 -0
  51. package/dist/pubsub/topics/cart/product-updated/types.js +1 -0
  52. package/dist/pubsub/topics/cart/types.d.ts +4 -2
  53. package/dist/pubsub/topics/cart/types.js +1 -0
  54. package/dist/pubsub/topics/custom-tables/index.d.ts +7 -0
  55. package/dist/pubsub/topics/custom-tables/index.js +28 -0
  56. package/dist/pubsub/topics/custom-tables/row-created/types.d.ts +12 -0
  57. package/dist/pubsub/topics/custom-tables/row-created/types.js +1 -0
  58. package/dist/pubsub/topics/custom-tables/row-deleted/types.d.ts +12 -0
  59. package/dist/pubsub/topics/custom-tables/row-deleted/types.js +1 -0
  60. package/dist/pubsub/topics/custom-tables/row-updated/types.d.ts +12 -0
  61. package/dist/pubsub/topics/custom-tables/row-updated/types.js +1 -0
  62. package/dist/pubsub/topics/custom-tables/types.d.ts +12 -0
  63. package/dist/pubsub/topics/custom-tables/types.js +8 -0
  64. package/dist/pubsub/topics/index.d.ts +1 -0
  65. package/dist/pubsub/topics/index.js +1 -0
  66. package/dist/pubsub/topics/types.d.ts +2 -0
  67. package/package.json +1 -1
  68. package/dist/pubsub/topic.d.ts +0 -36
  69. package/dist/pubsub/topic.js +0 -52
@@ -1,3 +1,4 @@
1
+ export * from "./common-types";
1
2
  export declare enum CFProductType {
2
3
  SIMPLE = "simple",
3
4
  VARIABLE = "variable"
@@ -1,3 +1,4 @@
1
+ export * from "./common-types";
1
2
  // Enums
2
3
  export var CFProductType;
3
4
  (function (CFProductType) {
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import type { DeleteCustomTableData } from "./types";
6
+ export declare const deleteCustomTableData: DeleteCustomTableData;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const deleteCustomTableData = async (params) => {
7
+ return await commandFrameClient.call("deleteCustomTableData", params);
8
+ };
@@ -0,0 +1,9 @@
1
+ export interface DeleteCustomTableDataResponse {
2
+ success: boolean;
3
+ timestamp: string;
4
+ }
5
+ export interface DeleteCustomTableDataParams {
6
+ tableName: string;
7
+ rowId: string;
8
+ }
9
+ export type DeleteCustomTableData = (params?: DeleteCustomTableDataParams) => Promise<DeleteCustomTableDataResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import type { GetCustomTableData } from "./types";
6
+ export declare const getCustomTableData: GetCustomTableData;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const getCustomTableData = async (params) => {
7
+ return await commandFrameClient.call("getCustomTableData", params);
8
+ };
@@ -0,0 +1,12 @@
1
+ export interface GetCustomTableDataResponse<T = any> {
2
+ success: boolean;
3
+ data: T[];
4
+ timestamp: string;
5
+ }
6
+ export interface GetCustomTableDataParams {
7
+ tableName: string;
8
+ query?: any;
9
+ offset?: number;
10
+ limit?: number;
11
+ }
12
+ export type GetCustomTableData = <T = any>(params?: GetCustomTableDataParams) => Promise<GetCustomTableDataResponse<T>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get custom table fields action
3
+ * Calls the getCustomTableFields action on the parent window
4
+ */
5
+ import type { GetCustomTableFields } from "./types";
6
+ export declare const getCustomTableFields: GetCustomTableFields;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get custom table fields action
3
+ * Calls the getCustomTableFields action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const getCustomTableFields = async (params) => {
7
+ return await commandFrameClient.call("getCustomTableFields", params);
8
+ };
@@ -0,0 +1,10 @@
1
+ import { CFCustomTableField } from "../../CommonTypes";
2
+ export interface GetCustomTableFieldsParams {
3
+ tableId: string;
4
+ }
5
+ export interface GetCustomTableFieldsResponse {
6
+ success: boolean;
7
+ fields: CFCustomTableField[];
8
+ timestamp: string;
9
+ }
10
+ export type GetCustomTableFields = (params: GetCustomTableFieldsParams) => Promise<GetCustomTableFieldsResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import type { GetCustomTables } from "./types";
6
+ export declare const getCustomTables: GetCustomTables;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const getCustomTables = async () => {
7
+ return await commandFrameClient.call("getCustomTables");
8
+ };
@@ -0,0 +1,7 @@
1
+ import { CFCustomTable } from "../../CommonTypes";
2
+ export interface GetCustomTablesResponse {
3
+ success: boolean;
4
+ customTables: CFCustomTable[];
5
+ timestamp: string;
6
+ }
7
+ export type GetCustomTables = () => Promise<GetCustomTablesResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Remove product from cart action
3
+ * Calls the removeProductFromCart action on the parent window
4
+ */
5
+ import type { RemoveProductFromCart } from "./types";
6
+ export declare const removeProductFromCart: RemoveProductFromCart;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Remove product from cart action
3
+ * Calls the removeProductFromCart action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const removeProductFromCart = async (params) => {
7
+ return await commandFrameClient.call("removeProductFromCart", params);
8
+ };
@@ -0,0 +1,2 @@
1
+ import { RemoveProductFromCart } from "./types";
2
+ export declare const mockRemoveProductFromCart: RemoveProductFromCart;
@@ -0,0 +1,32 @@
1
+ import { MOCK_CART, mockPublishEvent } from "../../demo/database";
2
+ export const mockRemoveProductFromCart = async (params) => {
3
+ console.log("[Mock] removeProductFromCart called", params);
4
+ if (!params?.internalId) {
5
+ throw new Error('internalId is required');
6
+ }
7
+ const { internalId } = params;
8
+ // Find the product in the cart
9
+ const productIndex = MOCK_CART.products.findIndex(p => p.internalId === internalId);
10
+ if (productIndex === -1) {
11
+ throw new Error(`Cart item with internalId ${internalId} not found`);
12
+ }
13
+ const product = MOCK_CART.products[productIndex];
14
+ // Remove from cart
15
+ MOCK_CART.products.splice(productIndex, 1);
16
+ // Recalculate totals
17
+ const lineTotal = product.price * product.quantity;
18
+ MOCK_CART.subtotal -= lineTotal;
19
+ MOCK_CART.total -= lineTotal;
20
+ MOCK_CART.amountToBeCharged = MOCK_CART.total;
21
+ MOCK_CART.remainingBalance = MOCK_CART.total;
22
+ // Publish product-deleted event
23
+ mockPublishEvent('cart', 'product-deleted', {
24
+ product: product,
25
+ internalId: internalId
26
+ });
27
+ return {
28
+ success: true,
29
+ internalId: internalId,
30
+ timestamp: new Date().toISOString()
31
+ };
32
+ };
@@ -0,0 +1,11 @@
1
+ export interface RemoveProductFromCartParams {
2
+ /** The unique identifier for the specific cart item to remove. */
3
+ internalId: string;
4
+ }
5
+ export interface RemoveProductFromCartResponse {
6
+ success: boolean;
7
+ /** The unique identifier of the removed cart item. */
8
+ internalId: string;
9
+ timestamp: string;
10
+ }
11
+ export type RemoveProductFromCart = (params?: RemoveProductFromCartParams) => Promise<RemoveProductFromCartResponse>;
@@ -0,0 +1,2 @@
1
+ // Remove Product From Cart Types
2
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Update cart item quantity action
3
+ * Calls the updateCartItemQuantity action on the parent window
4
+ */
5
+ import type { UpdateCartItemQuantity } from "./types";
6
+ export declare const updateCartItemQuantity: UpdateCartItemQuantity;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Update cart item quantity action
3
+ * Calls the updateCartItemQuantity action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const updateCartItemQuantity = async (params) => {
7
+ return await commandFrameClient.call("updateCartItemQuantity", params);
8
+ };
@@ -0,0 +1,2 @@
1
+ import { UpdateCartItemQuantity } from "./types";
2
+ export declare const mockUpdateCartItemQuantity: UpdateCartItemQuantity;
@@ -0,0 +1,60 @@
1
+ import { MOCK_CART, mockPublishEvent } from "../../demo/database";
2
+ export const mockUpdateCartItemQuantity = async (params) => {
3
+ console.log("[Mock] updateCartItemQuantity called", params);
4
+ if (!params?.internalId) {
5
+ throw new Error('internalId is required');
6
+ }
7
+ if (params.quantity === undefined || params.quantity === null) {
8
+ throw new Error('quantity is required');
9
+ }
10
+ const { internalId, quantity } = params;
11
+ // Find the product in the cart
12
+ const productIndex = MOCK_CART.products.findIndex(p => p.internalId === internalId);
13
+ if (productIndex === -1) {
14
+ throw new Error(`Cart item with internalId ${internalId} not found`);
15
+ }
16
+ const product = MOCK_CART.products[productIndex];
17
+ const previousQuantity = product.quantity;
18
+ // If quantity is 0, remove the item
19
+ if (quantity === 0) {
20
+ MOCK_CART.products.splice(productIndex, 1);
21
+ // Recalculate totals
22
+ const lineTotal = product.price * previousQuantity;
23
+ MOCK_CART.subtotal -= lineTotal;
24
+ MOCK_CART.total -= lineTotal;
25
+ MOCK_CART.amountToBeCharged = MOCK_CART.total;
26
+ MOCK_CART.remainingBalance = MOCK_CART.total;
27
+ // Publish product-deleted event
28
+ mockPublishEvent('cart', 'product-deleted', {
29
+ product: product,
30
+ internalId: internalId
31
+ });
32
+ return {
33
+ success: true,
34
+ internalId: internalId,
35
+ quantity: 0,
36
+ timestamp: new Date().toISOString()
37
+ };
38
+ }
39
+ // Update quantity
40
+ const quantityDelta = quantity - previousQuantity;
41
+ product.quantity = quantity;
42
+ // Recalculate totals
43
+ const lineTotalDelta = product.price * quantityDelta;
44
+ MOCK_CART.subtotal += lineTotalDelta;
45
+ MOCK_CART.total += lineTotalDelta;
46
+ MOCK_CART.amountToBeCharged = MOCK_CART.total;
47
+ MOCK_CART.remainingBalance = MOCK_CART.total;
48
+ // Publish product-updated event
49
+ mockPublishEvent('cart', 'product-updated', {
50
+ product: product,
51
+ previousQuantity: previousQuantity,
52
+ newQuantity: quantity
53
+ });
54
+ return {
55
+ success: true,
56
+ internalId: internalId,
57
+ quantity: quantity,
58
+ timestamp: new Date().toISOString()
59
+ };
60
+ };
@@ -0,0 +1,15 @@
1
+ export interface UpdateCartItemQuantityParams {
2
+ /** The unique identifier for the specific cart item to update. */
3
+ internalId: string;
4
+ /** The new quantity. If set to 0, the item will be removed from the cart. */
5
+ quantity: number;
6
+ }
7
+ export interface UpdateCartItemQuantityResponse {
8
+ success: boolean;
9
+ /** The unique identifier of the updated cart item. */
10
+ internalId: string;
11
+ /** The new quantity after the update. */
12
+ quantity: number;
13
+ timestamp: string;
14
+ }
15
+ export type UpdateCartItemQuantity = (params?: UpdateCartItemQuantityParams) => Promise<UpdateCartItemQuantityResponse>;
@@ -0,0 +1,2 @@
1
+ // Update Cart Item Quantity Types
2
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import type { UpsertCustomTableData } from "./types";
6
+ export declare const upsertCustomTableData: UpsertCustomTableData;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get custom tables action
3
+ * Calls the getCustomTables action on the parent window
4
+ */
5
+ import { commandFrameClient } from "../../client";
6
+ export const upsertCustomTableData = async (params) => {
7
+ return await commandFrameClient.call("upsertCustomTableData", params);
8
+ };
@@ -0,0 +1,10 @@
1
+ export interface UpsertCustomTableDataResponse<T = any> {
2
+ success: boolean;
3
+ data: T;
4
+ timestamp: string;
5
+ }
6
+ export interface UpsertCustomTableDataParams<T = any> {
7
+ tableName: string;
8
+ data: T;
9
+ }
10
+ export type UpsertCustomTableData = <T = any>(params?: UpsertCustomTableDataParams<T>) => Promise<UpsertCustomTableDataResponse<T>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ export type CFCustomTable = {
2
+ _id: string;
3
+ name: string;
4
+ description?: string;
5
+ metadata?: Array<{
6
+ key: string;
7
+ value: any;
8
+ }>;
9
+ };
10
+ export declare enum AttributeType {
11
+ STRING = "string",
12
+ NUMBER = "number",
13
+ BOOLEAN = "boolean",
14
+ DATE = "date",
15
+ JSON_STRING = "json-string"
16
+ }
17
+ export type CFCustomTableField = {
18
+ _id: string;
19
+ tableId: string;
20
+ name: string;
21
+ type: AttributeType;
22
+ required?: boolean;
23
+ defaultValue?: any;
24
+ referenceLinkedCollection?: string;
25
+ referenceLinkedField?: string;
26
+ };
@@ -0,0 +1,8 @@
1
+ export var AttributeType;
2
+ (function (AttributeType) {
3
+ AttributeType["STRING"] = "string";
4
+ AttributeType["NUMBER"] = "number";
5
+ AttributeType["BOOLEAN"] = "boolean";
6
+ AttributeType["DATE"] = "date";
7
+ AttributeType["JSON_STRING"] = "json-string";
8
+ })(AttributeType || (AttributeType = {}));
@@ -0,0 +1 @@
1
+ export * from "./custom-tables";
@@ -0,0 +1 @@
1
+ export * from "./custom-tables";
@@ -3,6 +3,7 @@
3
3
  * Stores mock data that mimics the Render environment
4
4
  */
5
5
  import { CFActiveCompany, CFActiveUser, CFActiveStation, CFActiveOutlet, CFActiveOrder, CFCustomer, CFProduct, CFActiveCart, CFCategory } from "../CommonTypes";
6
+ export * from './mocks';
6
7
  export declare const MOCK_COMPANY: CFActiveCompany;
7
8
  export declare const MOCK_OUTLET_MAIN: CFActiveOutlet;
8
9
  export declare const MOCK_STATION_1: CFActiveStation;
@@ -53,4 +54,3 @@ type MockEventCallback = (event: any) => void;
53
54
  export declare const mockPublishEvent: (topic: string, eventType: string, data: any) => void;
54
55
  export declare const mockSubscribeToTopic: (topic: string, callback: MockEventCallback) => void;
55
56
  export declare const createOrderFromCart: (paymentType: string, amount: number | string, processor?: string) => CFActiveOrder;
56
- export {};
@@ -3,6 +3,7 @@
3
3
  * Stores mock data that mimics the Render environment
4
4
  */
5
5
  import { CFProductType, CFUserTypes, } from "../CommonTypes";
6
+ export * from './mocks';
6
7
  // Asset Imports - Using Remote URLs to avoid build complexity with asset copying
7
8
  const ASSETS_BASE_URL = "https://raw.githubusercontent.com/Final-Commerce/command-frame/refs/heads/main/src/demo/assets";
8
9
  const logo = `${ASSETS_BASE_URL}/logo.png`;
@@ -0,0 +1,3 @@
1
+ import { CFCustomTable, CFCustomTableField } from "../../CommonTypes";
2
+ export declare const MOCK_CUSTOM_TABLES: CFCustomTable[];
3
+ export declare const MOCK_CUSTOM_TABLE_FIELDS: CFCustomTableField[];
@@ -0,0 +1,46 @@
1
+ import { AttributeType } from "../../CommonTypes";
2
+ export const MOCK_CUSTOM_TABLES = [
3
+ {
4
+ _id: "custom_table_1",
5
+ name: "Custom Table 1",
6
+ description: "Custom Table 1 Description",
7
+ metadata: [
8
+ {
9
+ key: "value",
10
+ value: "value"
11
+ }
12
+ ]
13
+ }
14
+ ];
15
+ export const MOCK_CUSTOM_TABLE_FIELDS = [
16
+ {
17
+ _id: "field_1",
18
+ tableId: "custom_table_1",
19
+ name: "customerId",
20
+ type: AttributeType.STRING,
21
+ required: true
22
+ },
23
+ {
24
+ _id: "field_2",
25
+ tableId: "custom_table_1",
26
+ name: "points",
27
+ type: AttributeType.NUMBER,
28
+ required: true,
29
+ defaultValue: 0
30
+ },
31
+ {
32
+ _id: "field_3",
33
+ tableId: "custom_table_1",
34
+ name: "isActive",
35
+ type: AttributeType.BOOLEAN,
36
+ required: false,
37
+ defaultValue: true
38
+ },
39
+ {
40
+ _id: "field_4",
41
+ tableId: "custom_table_1",
42
+ name: "lastUpdated",
43
+ type: AttributeType.DATE,
44
+ required: false
45
+ }
46
+ ];
@@ -0,0 +1 @@
1
+ export * from "./custom-tables";
@@ -0,0 +1 @@
1
+ export * from "./custom-tables";
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare const command: {
10
10
  readonly getRefunds: import("./actions/get-refunds/types").GetRefunds;
11
11
  readonly addProductDiscount: import("./actions/add-product-discount/types").AddProductDiscount;
12
12
  readonly addProductToCart: import("./actions/add-product-to-cart/types").AddProductToCart;
13
+ readonly removeProductFromCart: import("./actions/remove-product-from-cart/types").RemoveProductFromCart;
14
+ readonly updateCartItemQuantity: import("./actions/update-cart-item-quantity/types").UpdateCartItemQuantity;
13
15
  readonly addCartDiscount: import("./actions/add-cart-discount/types").AddCartDiscount;
14
16
  readonly getContext: import("./actions/get-context/types").GetContext;
15
17
  readonly getFinalContext: import("./actions/get-final-context/types").GetFinalContext;
@@ -45,6 +47,8 @@ export declare const command: {
45
47
  readonly calculateRefundTotal: import("./actions/calculate-refund-total/types").CalculateRefundTotal;
46
48
  readonly getRemainingRefundableQuantities: import("./actions/get-remaining-refundable-quantities/types").GetRemainingRefundableQuantities;
47
49
  readonly processPartialRefund: import("./actions/process-partial-refund/types").ProcessPartialRefund;
50
+ readonly getCustomTables: import("./actions/get-custom-tables/types").GetCustomTables;
51
+ readonly getCustomTableFields: import("./actions/get-custom-table-fields/types").GetCustomTableFields;
48
52
  };
49
53
  export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from "./actions/example-function/types";
50
54
  export type { GetProducts, GetProductsParams, GetProductsResponse } from "./actions/get-products/types";
@@ -65,6 +69,8 @@ export type { InitiateRefund, InitiateRefundParams, InitiateRefundResponse } fro
65
69
  export type { GetCurrentCart, GetCurrentCartResponse } from "./actions/get-current-cart/types";
66
70
  export type { AddProductDiscount, AddProductDiscountParams, AddProductDiscountResponse } from "./actions/add-product-discount/types";
67
71
  export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse } from "./actions/add-product-to-cart/types";
72
+ export type { RemoveProductFromCart, RemoveProductFromCartParams, RemoveProductFromCartResponse } from "./actions/remove-product-from-cart/types";
73
+ export type { UpdateCartItemQuantity, UpdateCartItemQuantityParams, UpdateCartItemQuantityResponse } from "./actions/update-cart-item-quantity/types";
68
74
  export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
69
75
  export type { GetContext, GetContextResponse } from "./actions/get-context/types";
70
76
  export type { GetFinalContext, GetFinalContextResponse } from "./actions/get-final-context/types";
@@ -99,7 +105,7 @@ export * from "./projects/render";
99
105
  export * from "./projects/manage";
100
106
  export { commandFrameClient, CommandFrameClient } from "./client";
101
107
  export type { PostMessageRequest, PostMessageResponse } from "./client";
102
- export { topics } from "./pubsub/topic";
108
+ export { topics } from "./pubsub/topics";
103
109
  export type { TopicDefinition, TopicEvent, TopicEventType, TopicSubscriptionCallback, TopicSubscription } from "./pubsub/types";
104
110
  export { customersTopic } from "./pubsub/topics/customers";
105
111
  export { ordersTopic } from "./pubsub/topics/orders";
@@ -107,9 +113,16 @@ export { refundsTopic } from "./pubsub/topics/refunds";
107
113
  export { productsTopic } from "./pubsub/topics/products";
108
114
  export { cartTopic } from "./pubsub/topics/cart";
109
115
  export { paymentsTopic } from "./pubsub/topics/payments";
116
+ export { customTablesTopic } from "./pubsub/topics/custom-tables";
110
117
  export type { CustomerCreatedPayload, CustomerUpdatedPayload, CustomerNoteAddedPayload, CustomerNoteDeletedPayload, CustomerAssignedPayload, CustomerUnassignedPayload, CustomerCreatedEvent, CustomerUpdatedEvent, CustomerNoteAddedEvent, CustomerNoteDeletedEvent, CustomerAssignedEvent, CustomerUnassignedEvent, CustomersEventType, CustomersEventPayload } from "./pubsub/topics/customers/types";
111
118
  export type { OrderCreatedPayload, OrderUpdatedPayload, OrderCreatedEvent, OrderUpdatedEvent, OrdersEventType, OrdersEventPayload } from "./pubsub/topics/orders/types";
112
119
  export type { RefundCreatedPayload, RefundUpdatedPayload, RefundCreatedEvent, RefundUpdatedEvent, RefundsEventType, RefundsEventPayload } from "./pubsub/topics/refunds/types";
113
120
  export type { ProductCreatedPayload, ProductUpdatedPayload, ProductCreatedEvent, ProductUpdatedEvent, ProductsEventType, ProductsEventPayload } from "./pubsub/topics/products/types";
114
121
  export type { CartCreatedPayload, CartCustomerAssignedPayload, ProductAddedPayload, ProductDeletedPayload, CartDiscountAddedPayload, CartDiscountRemovedPayload, CartFeeAddedPayload, CartFeeRemovedPayload, CartCreatedEvent, CartCustomerAssignedEvent, ProductAddedEvent, ProductDeletedEvent, CartDiscountAddedEvent, CartDiscountRemovedEvent, CartFeeAddedEvent, CartFeeRemovedEvent, CartEventType, CartEventPayload } from "./pubsub/topics/cart/types";
115
122
  export type { PaymentDonePayload, PaymentErrPayload, PaymentDoneEvent, PaymentErrEvent, PaymentsEventType, PaymentsEventPayload } from "./pubsub/topics/payments/types";
123
+ export type { RowCreatedPayload, RowUpdatedPayload, RowDeletedPayload, RowCreatedEvent, RowUpdatedEvent, RowDeletedEvent, CustomTablesEventType, CustomTablesEventPayload } from "./pubsub/topics/custom-tables/types";
124
+ export type { GetCustomTables, GetCustomTablesResponse } from "./actions/get-custom-tables/types";
125
+ export type { GetCustomTableFields, GetCustomTableFieldsParams, GetCustomTableFieldsResponse } from "./actions/get-custom-table-fields/types";
126
+ export type { GetCustomTableData, GetCustomTableDataParams, GetCustomTableDataResponse } from "./actions/get-custom-table-data/types";
127
+ export type { UpsertCustomTableData, UpsertCustomTableDataParams, UpsertCustomTableDataResponse } from "./actions/upsert-custom-table-data/types";
128
+ export type { DeleteCustomTableData, DeleteCustomTableDataParams, DeleteCustomTableDataResponse } from "./actions/delete-custom-table-data/types";
package/dist/index.js CHANGED
@@ -12,6 +12,8 @@ import { getContext } from "./actions/get-context/action";
12
12
  import { getFinalContext } from "./actions/get-final-context/action";
13
13
  import { addProductDiscount } from "./actions/add-product-discount/action";
14
14
  import { addProductToCart } from "./actions/add-product-to-cart/action";
15
+ import { removeProductFromCart } from "./actions/remove-product-from-cart/action";
16
+ import { updateCartItemQuantity } from "./actions/update-cart-item-quantity/action";
15
17
  // Product Actions
16
18
  import { addProductNote } from "./actions/add-product-note/action";
17
19
  import { addProductFee } from "./actions/add-product-fee/action";
@@ -51,6 +53,9 @@ import { resetRefundDetails } from "./actions/reset-refund-details/action";
51
53
  import { calculateRefundTotal } from "./actions/calculate-refund-total/action";
52
54
  import { getRemainingRefundableQuantities } from "./actions/get-remaining-refundable-quantities/action";
53
55
  import { processPartialRefund } from "./actions/process-partial-refund/action";
56
+ // Custom Tables Actions
57
+ import { getCustomTables } from "./actions/get-custom-tables/action";
58
+ import { getCustomTableFields } from "./actions/get-custom-table-fields/action";
54
59
  // Export actions as command object
55
60
  export const command = {
56
61
  exampleFunction,
@@ -64,6 +69,8 @@ export const command = {
64
69
  getRefunds,
65
70
  addProductDiscount,
66
71
  addProductToCart,
72
+ removeProductFromCart,
73
+ updateCartItemQuantity,
67
74
  addCartDiscount,
68
75
  getContext,
69
76
  getFinalContext,
@@ -105,6 +112,9 @@ export const command = {
105
112
  calculateRefundTotal,
106
113
  getRemainingRefundableQuantities,
107
114
  processPartialRefund,
115
+ // Custom Tables Actions
116
+ getCustomTables,
117
+ getCustomTableFields,
108
118
  };
109
119
  // Export Common Types
110
120
  export * from "./CommonTypes";
@@ -117,7 +127,7 @@ export * from "./projects/manage";
117
127
  // Export client
118
128
  export { commandFrameClient, CommandFrameClient } from "./client";
119
129
  // Export Pub/Sub
120
- export { topics } from "./pubsub/topic";
130
+ export { topics } from "./pubsub/topics";
121
131
  // Export Pub/Sub Topics
122
132
  export { customersTopic } from "./pubsub/topics/customers";
123
133
  export { ordersTopic } from "./pubsub/topics/orders";
@@ -125,3 +135,4 @@ export { refundsTopic } from "./pubsub/topics/refunds";
125
135
  export { productsTopic } from "./pubsub/topics/products";
126
136
  export { cartTopic } from "./pubsub/topics/cart";
127
137
  export { paymentsTopic } from "./pubsub/topics/payments";
138
+ export { customTablesTopic } from "./pubsub/topics/custom-tables";
@@ -8,6 +8,8 @@ import { mockAddProductDiscount } from "../../actions/add-product-discount/mock"
8
8
  import { mockAddProductFee } from "../../actions/add-product-fee/mock";
9
9
  import { mockAddProductNote } from "../../actions/add-product-note/mock";
10
10
  import { mockAddProductToCart } from "../../actions/add-product-to-cart/mock";
11
+ import { mockRemoveProductFromCart } from "../../actions/remove-product-from-cart/mock";
12
+ import { mockUpdateCartItemQuantity } from "../../actions/update-cart-item-quantity/mock";
11
13
  import { mockAdjustInventory } from "../../actions/adjust-inventory/mock";
12
14
  import { mockAssignCustomer } from "../../actions/assign-customer/mock";
13
15
  import { mockAuthenticateUser } from "../../actions/authenticate-user/mock";
@@ -55,6 +57,8 @@ export const RENDER_MOCKS = {
55
57
  addProductFee: mockAddProductFee,
56
58
  addProductNote: mockAddProductNote,
57
59
  addProductToCart: mockAddProductToCart,
60
+ removeProductFromCart: mockRemoveProductFromCart,
61
+ updateCartItemQuantity: mockUpdateCartItemQuantity,
58
62
  adjustInventory: mockAdjustInventory,
59
63
  assignCustomer: mockAssignCustomer,
60
64
  authenticateUser: mockAuthenticateUser,
@@ -1,4 +1,4 @@
1
- import type { ExampleFunction, GetProducts, AddCustomSale, GetCustomers, AssignCustomer, AddCustomer, GetCategories, GetOrders, GetRefunds, AddProductDiscount, AddProductToCart, 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 } 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, AddCustomerNote, RemoveCustomerFromCart, GoToStationHome, OpenCashDrawer, ShowNotification, ShowConfirmation, AuthenticateUser, PartialPayment, SwitchUser, TriggerWebhook, TriggerZapierWebhook, SetRefundStockAction, SelectAllRefundItems, ResetRefundDetails, CalculateRefundTotal, GetRemainingRefundableQuantities, ProcessPartialRefund, GetCurrentCart } from "../../index";
2
2
  export interface RenderProviderActions {
3
3
  exampleFunction: ExampleFunction;
4
4
  getProducts: GetProducts;
@@ -11,6 +11,8 @@ export interface RenderProviderActions {
11
11
  getRefunds: GetRefunds;
12
12
  addProductDiscount: AddProductDiscount;
13
13
  addProductToCart: AddProductToCart;
14
+ removeProductFromCart: RemoveProductFromCart;
15
+ updateCartItemQuantity: UpdateCartItemQuantity;
14
16
  addCartDiscount: AddCartDiscount;
15
17
  getContext: GetContext;
16
18
  getFinalContext: GetFinalContext;
@@ -27,6 +27,11 @@ export const cartTopic = {
27
27
  name: "Product Deleted",
28
28
  description: "Published when a product is removed from the cart"
29
29
  },
30
+ {
31
+ id: "product-updated",
32
+ name: "Product Updated",
33
+ description: "Published when a product's quantity is updated in the cart"
34
+ },
30
35
  {
31
36
  id: "cart-discount-added",
32
37
  name: "Cart Discount Added",
@@ -0,0 +1,14 @@
1
+ import type { CFActiveProduct } from "../../../../CommonTypes";
2
+ import type { TopicEvent } from "../../../types";
3
+ /**
4
+ * Payload for cart product-updated event
5
+ */
6
+ export interface CartProductUpdatedPayload {
7
+ product: CFActiveProduct;
8
+ previousQuantity: number;
9
+ newQuantity: number;
10
+ }
11
+ /**
12
+ * Typed event for cart product-updated
13
+ */
14
+ export type CartProductUpdatedEvent = TopicEvent<CartProductUpdatedPayload>;
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,7 @@ export * from "./cart-created/types";
6
6
  export * from "./customer-assigned/types";
7
7
  export * from "./product-added/types";
8
8
  export * from "./product-deleted/types";
9
+ export * from "./product-updated/types";
9
10
  export * from "./cart-discount-added/types";
10
11
  export * from "./cart-discount-removed/types";
11
12
  export * from "./cart-fee-added/types";
@@ -14,9 +15,10 @@ import type { CartCreatedPayload } from "./cart-created/types";
14
15
  import type { CartCustomerAssignedPayload } from "./customer-assigned/types";
15
16
  import type { ProductAddedPayload } from "./product-added/types";
16
17
  import type { ProductDeletedPayload } from "./product-deleted/types";
18
+ import type { CartProductUpdatedPayload } from "./product-updated/types";
17
19
  import type { CartDiscountAddedPayload } from "./cart-discount-added/types";
18
20
  import type { CartDiscountRemovedPayload } from "./cart-discount-removed/types";
19
21
  import type { CartFeeAddedPayload } from "./cart-fee-added/types";
20
22
  import type { CartFeeRemovedPayload } from "./cart-fee-removed/types";
21
- export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload;
22
- export type CartEventType = "cart-created" | "customer-assigned" | "product-added" | "product-deleted" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed";
23
+ export type CartEventPayload = CartCreatedPayload | CartCustomerAssignedPayload | ProductAddedPayload | ProductDeletedPayload | CartProductUpdatedPayload | CartDiscountAddedPayload | CartDiscountRemovedPayload | CartFeeAddedPayload | CartFeeRemovedPayload;
24
+ export type CartEventType = "cart-created" | "customer-assigned" | "product-added" | "product-deleted" | "product-updated" | "cart-discount-added" | "cart-discount-removed" | "cart-fee-added" | "cart-fee-removed";
@@ -7,6 +7,7 @@ export * from "./cart-created/types";
7
7
  export * from "./customer-assigned/types";
8
8
  export * from "./product-added/types";
9
9
  export * from "./product-deleted/types";
10
+ export * from "./product-updated/types";
10
11
  export * from "./cart-discount-added/types";
11
12
  export * from "./cart-discount-removed/types";
12
13
  export * from "./cart-fee-added/types";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Custom Tables Topic Definition
3
+ * Defines the custom tables topic and its available event types
4
+ */
5
+ import type { TopicDefinition } from "../../types";
6
+ export declare const customTablesTopic: TopicDefinition;
7
+ export * from "./types";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Custom Tables Topic Definition
3
+ * Defines the custom tables topic and its available event types
4
+ */
5
+ export const customTablesTopic = {
6
+ id: "custom-tables",
7
+ name: "Custom Tables",
8
+ description: "Topic for custom table-related events",
9
+ eventTypes: [
10
+ {
11
+ id: "row-created",
12
+ name: "Row Created",
13
+ description: "Fired when a new row is created in a custom table"
14
+ },
15
+ {
16
+ id: "row-updated",
17
+ name: "Row Updated",
18
+ description: "Fired when a row is updated in a custom table"
19
+ },
20
+ {
21
+ id: "row-deleted",
22
+ name: "Row Deleted",
23
+ description: "Fired when a row is deleted from a custom table"
24
+ }
25
+ ]
26
+ };
27
+ // Re-export types
28
+ export * from "./types";
@@ -0,0 +1,12 @@
1
+ import type { TopicEvent } from "../../../types";
2
+ /**
3
+ * Payload for customer-created event
4
+ */
5
+ export interface RowCreatedPayload {
6
+ tableName: string;
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * Typed event for customer-created
11
+ */
12
+ export type RowCreatedEvent = TopicEvent<RowCreatedPayload>;
@@ -0,0 +1,12 @@
1
+ import type { TopicEvent } from "../../../types";
2
+ /**
3
+ * Payload for row-deleted event
4
+ */
5
+ export interface RowDeletedPayload {
6
+ tableName: string;
7
+ rowId: string;
8
+ }
9
+ /**
10
+ * Typed event for customer-created
11
+ */
12
+ export type RowDeletedEvent = TopicEvent<RowDeletedPayload>;
@@ -0,0 +1,12 @@
1
+ import type { TopicEvent } from "../../../types";
2
+ /**
3
+ * Payload for row-updated event
4
+ */
5
+ export interface RowUpdatedPayload {
6
+ tableName: string;
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * Typed event for customer-created
11
+ */
12
+ export type RowUpdatedEvent = TopicEvent<RowUpdatedPayload>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Custom Tables Topic Types
3
+ * Aggregated types for all custom table-related events
4
+ */
5
+ export * from "./row-created/types";
6
+ export * from "./row-updated/types";
7
+ export * from "./row-deleted/types";
8
+ import type { RowCreatedPayload } from "./row-created/types";
9
+ import type { RowUpdatedPayload } from "./row-updated/types";
10
+ import type { RowDeletedPayload } from "./row-deleted/types";
11
+ export type CustomTablesEventPayload = RowCreatedPayload | RowUpdatedPayload | RowDeletedPayload;
12
+ export type CustomTablesEventType = "row-created" | "row-updated" | "row-deleted";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Custom Tables Topic Types
3
+ * Aggregated types for all custom table-related events
4
+ */
5
+ // Re-export all event types
6
+ export * from "./row-created/types";
7
+ export * from "./row-updated/types";
8
+ export * from "./row-deleted/types";
@@ -8,3 +8,4 @@ export * from "./refunds";
8
8
  export * from "./products";
9
9
  export * from "./cart";
10
10
  export * from "./payments";
11
+ export * from "./custom-tables";
@@ -8,3 +8,4 @@ export * from "./refunds";
8
8
  export * from "./products";
9
9
  export * from "./cart";
10
10
  export * from "./payments";
11
+ export * from "./custom-tables";
@@ -4,6 +4,7 @@ import { RefundsEventType, RefundsEventPayload } from "./refunds/types";
4
4
  import { ProductsEventType, ProductsEventPayload } from "./products/types";
5
5
  import { CartEventType, CartEventPayload } from "./cart/types";
6
6
  import { PaymentsEventType, PaymentsEventPayload } from "./payments/types";
7
+ import { CustomTablesEventPayload, CustomTablesEventType } from "./custom-tables/types";
7
8
  export interface TopicEventPayloadMap {
8
9
  customers: Record<CustomersEventType, CustomersEventPayload>;
9
10
  orders: Record<OrdersEventType, OrdersEventPayload>;
@@ -11,4 +12,5 @@ export interface TopicEventPayloadMap {
11
12
  products: Record<ProductsEventType, ProductsEventPayload>;
12
13
  cart: Record<CartEventType, CartEventPayload>;
13
14
  payments: Record<PaymentsEventType, PaymentsEventPayload>;
15
+ customTables: Record<CustomTablesEventType, CustomTablesEventPayload>;
14
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,36 +0,0 @@
1
- /**
2
- * Pub/Sub module for Command Frame
3
- * Provides topic subscription functionality for iframe apps
4
- */
5
- export * from "./types";
6
- export { TopicSubscriber } from "./subscriber";
7
- import { TopicSubscriber } from "./subscriber";
8
- /**
9
- * Get or create the singleton TopicSubscriber instance
10
- */
11
- export declare function getTopicSubscriber(options?: {
12
- origin?: string;
13
- debug?: boolean;
14
- }): TopicSubscriber;
15
- /**
16
- * Topics API for iframe apps
17
- */
18
- declare const topicsApi: {
19
- /**
20
- * Subscribe to a topic
21
- */
22
- subscribe: <T = any>(topic: string, callback: (event: import("./types").TopicEvent<T>) => void) => string;
23
- /**
24
- * Unsubscribe from a topic
25
- */
26
- unsubscribe: (topic: string, subscriptionId: string) => boolean;
27
- /**
28
- * Unsubscribe all callbacks for a topic
29
- */
30
- unsubscribeAll: (topic: string) => number;
31
- /**
32
- * Get available topics
33
- */
34
- getTopics: () => Promise<import("./types").TopicDefinition[]>;
35
- };
36
- export { topicsApi as topics };
@@ -1,52 +0,0 @@
1
- /**
2
- * Pub/Sub module for Command Frame
3
- * Provides topic subscription functionality for iframe apps
4
- */
5
- export * from "./types";
6
- export { TopicSubscriber } from "./subscriber";
7
- // Singleton instance
8
- import { TopicSubscriber } from "./subscriber";
9
- let subscriberInstance = null;
10
- /**
11
- * Get or create the singleton TopicSubscriber instance
12
- */
13
- export function getTopicSubscriber(options) {
14
- if (!subscriberInstance) {
15
- subscriberInstance = new TopicSubscriber(options);
16
- }
17
- return subscriberInstance;
18
- }
19
- /**
20
- * Topics API for iframe apps
21
- */
22
- const topicsApi = {
23
- /**
24
- * Subscribe to a topic
25
- */
26
- subscribe: (topic, callback) => {
27
- const subscriber = getTopicSubscriber();
28
- return subscriber.subscribe(topic, callback);
29
- },
30
- /**
31
- * Unsubscribe from a topic
32
- */
33
- unsubscribe: (topic, subscriptionId) => {
34
- const subscriber = getTopicSubscriber();
35
- return subscriber.unsubscribe(topic, subscriptionId);
36
- },
37
- /**
38
- * Unsubscribe all callbacks for a topic
39
- */
40
- unsubscribeAll: (topic) => {
41
- const subscriber = getTopicSubscriber();
42
- return subscriber.unsubscribeAll(topic);
43
- },
44
- /**
45
- * Get available topics
46
- */
47
- getTopics: async () => {
48
- const subscriber = getTopicSubscriber();
49
- return await subscriber.getTopics();
50
- }
51
- };
52
- export { topicsApi as topics };