@final-commerce/command-frame 0.1.36 → 0.1.37

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 (41) hide show
  1. package/dist/actions/add-product/action.d.ts +2 -0
  2. package/dist/actions/add-product/action.js +4 -0
  3. package/dist/actions/add-product/mock.d.ts +2 -0
  4. package/dist/actions/add-product/mock.js +33 -0
  5. package/dist/actions/add-product/types.d.ts +21 -0
  6. package/dist/actions/add-product/types.js +1 -0
  7. package/dist/actions/delete-product/action.d.ts +2 -0
  8. package/dist/actions/delete-product/action.js +4 -0
  9. package/dist/actions/delete-product/mock.d.ts +2 -0
  10. package/dist/actions/delete-product/mock.js +7 -0
  11. package/dist/actions/delete-product/types.d.ts +8 -0
  12. package/dist/actions/delete-product/types.js +1 -0
  13. package/dist/actions/edit-product/action.d.ts +2 -0
  14. package/dist/actions/edit-product/action.js +4 -0
  15. package/dist/actions/edit-product/mock.d.ts +2 -0
  16. package/dist/actions/edit-product/mock.js +19 -0
  17. package/dist/actions/edit-product/types.d.ts +17 -0
  18. package/dist/actions/edit-product/types.js +1 -0
  19. package/dist/actions/edit-product-variants/action.d.ts +2 -0
  20. package/dist/actions/edit-product-variants/action.js +4 -0
  21. package/dist/actions/edit-product-variants/mock.d.ts +2 -0
  22. package/dist/actions/edit-product-variants/mock.js +7 -0
  23. package/dist/actions/edit-product-variants/types.d.ts +15 -0
  24. package/dist/actions/edit-product-variants/types.js +1 -0
  25. package/dist/actions/get-outlets/action.d.ts +2 -0
  26. package/dist/actions/get-outlets/action.js +4 -0
  27. package/dist/actions/get-outlets/mock.d.ts +2 -0
  28. package/dist/actions/get-outlets/mock.js +24 -0
  29. package/dist/actions/get-outlets/types.d.ts +6 -0
  30. package/dist/actions/get-outlets/types.js +1 -0
  31. package/dist/actions/get-stations/action.d.ts +2 -0
  32. package/dist/actions/get-stations/action.js +4 -0
  33. package/dist/actions/get-stations/mock.d.ts +2 -0
  34. package/dist/actions/get-stations/mock.js +20 -0
  35. package/dist/actions/get-stations/types.d.ts +9 -0
  36. package/dist/actions/get-stations/types.js +1 -0
  37. package/dist/index.d.ts +12 -0
  38. package/dist/index.js +16 -0
  39. package/dist/projects/manage/mocks.js +21 -1
  40. package/dist/projects/manage/types.d.ts +9 -3
  41. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import type { AddProduct } from "./types";
2
+ export declare const addProduct: AddProduct;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const addProduct = async (params) => {
3
+ return await commandFrameClient.call("addProduct", params);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { AddProduct } from "./types";
2
+ export declare const mockAddProduct: AddProduct;
@@ -0,0 +1,33 @@
1
+ import { CFProductType } from "../../CommonTypes";
2
+ export const mockAddProduct = async (params) => {
3
+ console.log("[Mock] addProduct called", params);
4
+ const hasVariants = params.variants && params.variants.length > 0;
5
+ return {
6
+ product: {
7
+ _id: "mock_product_" + Date.now(),
8
+ name: params.name,
9
+ description: params.description,
10
+ categories: params.categories || [],
11
+ taxTable: params.taxTable || "",
12
+ images: params.images || [],
13
+ status: params.status || "active",
14
+ sku: params.sku,
15
+ productType: hasVariants ? CFProductType.VARIABLE : CFProductType.SIMPLE,
16
+ attributes: [],
17
+ minPrice: params.price || "0",
18
+ maxPrice: params.price || "0",
19
+ variants: hasVariants
20
+ ? params.variants.map((v, i) => ({ ...v, _id: `mock_variant_${Date.now()}_${i}` }))
21
+ : [{
22
+ _id: `mock_variant_${Date.now()}_0`,
23
+ sku: params.sku || "",
24
+ price: params.price || "0",
25
+ salePrice: "0",
26
+ isOnSale: false,
27
+ manageStock: params.manageStock || false,
28
+ attributes: [],
29
+ }],
30
+ },
31
+ timestamp: new Date().toISOString(),
32
+ };
33
+ };
@@ -0,0 +1,21 @@
1
+ import { CFProduct, CFProductVariant } from "../../CommonTypes";
2
+ export interface AddProductParams {
3
+ name: string;
4
+ description?: string;
5
+ categories?: string[];
6
+ taxTable?: string;
7
+ images?: string[];
8
+ status?: 'active' | 'inactive';
9
+ /** For simple products: set price directly */
10
+ price?: string;
11
+ sku?: string;
12
+ costPrice?: string;
13
+ manageStock?: boolean;
14
+ /** For variable products: provide variants array */
15
+ variants?: Omit<CFProductVariant, '_id'>[];
16
+ }
17
+ export interface AddProductResponse {
18
+ product: CFProduct;
19
+ timestamp: string;
20
+ }
21
+ export type AddProduct = (params: AddProductParams) => Promise<AddProductResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { DeleteProduct } from "./types";
2
+ export declare const deleteProduct: DeleteProduct;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const deleteProduct = async (params) => {
3
+ return await commandFrameClient.call("deleteProduct", params);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { DeleteProduct } from "./types";
2
+ export declare const mockDeleteProduct: DeleteProduct;
@@ -0,0 +1,7 @@
1
+ export const mockDeleteProduct = async (params) => {
2
+ console.log("[Mock] deleteProduct called", params);
3
+ return {
4
+ success: true,
5
+ timestamp: new Date().toISOString(),
6
+ };
7
+ };
@@ -0,0 +1,8 @@
1
+ export interface DeleteProductParams {
2
+ productId: string;
3
+ }
4
+ export interface DeleteProductResponse {
5
+ success: boolean;
6
+ timestamp: string;
7
+ }
8
+ export type DeleteProduct = (params: DeleteProductParams) => Promise<DeleteProductResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { EditProduct } from "./types";
2
+ export declare const editProduct: EditProduct;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const editProduct = async (params) => {
3
+ return await commandFrameClient.call("editProduct", params);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { EditProduct } from "./types";
2
+ export declare const mockEditProduct: EditProduct;
@@ -0,0 +1,19 @@
1
+ import { CFProductType } from "../../CommonTypes";
2
+ export const mockEditProduct = async (params) => {
3
+ console.log("[Mock] editProduct called", params);
4
+ return {
5
+ product: {
6
+ _id: params.productId,
7
+ name: params.changes.name || "Updated Product",
8
+ description: params.changes.description,
9
+ categories: params.changes.categories || [],
10
+ taxTable: params.changes.taxTable || "",
11
+ images: params.changes.images || [],
12
+ status: params.changes.status || "active",
13
+ productType: CFProductType.SIMPLE,
14
+ attributes: [],
15
+ variants: [],
16
+ },
17
+ timestamp: new Date().toISOString(),
18
+ };
19
+ };
@@ -0,0 +1,17 @@
1
+ import { CFProduct } from "../../CommonTypes";
2
+ export interface EditProductParams {
3
+ productId: string;
4
+ changes: {
5
+ name?: string;
6
+ description?: string;
7
+ categories?: string[];
8
+ taxTable?: string | null;
9
+ images?: string[];
10
+ status?: 'active' | 'inactive';
11
+ };
12
+ }
13
+ export interface EditProductResponse {
14
+ product: CFProduct;
15
+ timestamp: string;
16
+ }
17
+ export type EditProduct = (params: EditProductParams) => Promise<EditProductResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { EditProductVariants } from "./types";
2
+ export declare const editProductVariants: EditProductVariants;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const editProductVariants = async (params) => {
3
+ return await commandFrameClient.call("editProductVariants", params);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { EditProductVariants } from "./types";
2
+ export declare const mockEditProductVariants: EditProductVariants;
@@ -0,0 +1,7 @@
1
+ export const mockEditProductVariants = async (params) => {
2
+ console.log("[Mock] editProductVariants called", params);
3
+ return {
4
+ success: true,
5
+ timestamp: new Date().toISOString(),
6
+ };
7
+ };
@@ -0,0 +1,15 @@
1
+ import { CFProductVariant } from "../../CommonTypes";
2
+ export interface EditProductVariantsParams {
3
+ productId: string;
4
+ additions?: Omit<CFProductVariant, '_id'>[];
5
+ changes?: Array<{
6
+ _id: string;
7
+ changes: Partial<CFProductVariant>;
8
+ }>;
9
+ deletions?: string[];
10
+ }
11
+ export interface EditProductVariantsResponse {
12
+ success: boolean;
13
+ timestamp: string;
14
+ }
15
+ export type EditProductVariants = (params: EditProductVariantsParams) => Promise<EditProductVariantsResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { GetOutlets } from "./types";
2
+ export declare const getOutlets: GetOutlets;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const getOutlets = async () => {
3
+ return await commandFrameClient.call("getOutlets");
4
+ };
@@ -0,0 +1,2 @@
1
+ import { GetOutlets } from "./types";
2
+ export declare const mockGetOutlets: GetOutlets;
@@ -0,0 +1,24 @@
1
+ export const mockGetOutlets = async () => {
2
+ console.log("[Mock] getOutlets called");
3
+ return {
4
+ outlets: [
5
+ {
6
+ _id: "mock_outlet_001",
7
+ name: "Main Store",
8
+ address: "123 Commerce St",
9
+ city: "New York",
10
+ state: "NY",
11
+ country: "US",
12
+ },
13
+ {
14
+ _id: "mock_outlet_002",
15
+ name: "Downtown Branch",
16
+ address: "456 Market Ave",
17
+ city: "San Francisco",
18
+ state: "CA",
19
+ country: "US",
20
+ },
21
+ ],
22
+ timestamp: new Date().toISOString(),
23
+ };
24
+ };
@@ -0,0 +1,6 @@
1
+ import { CFOutletInfo } from "../../CommonTypes";
2
+ export interface GetOutletsResponse {
3
+ outlets: CFOutletInfo[];
4
+ timestamp: string;
5
+ }
6
+ export type GetOutlets = () => Promise<GetOutletsResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { GetStations } from "./types";
2
+ export declare const getStations: GetStations;
@@ -0,0 +1,4 @@
1
+ import { commandFrameClient } from "../../client";
2
+ export const getStations = async (params) => {
3
+ return await commandFrameClient.call("getStations", params);
4
+ };
@@ -0,0 +1,2 @@
1
+ import { GetStations } from "./types";
2
+ export declare const mockGetStations: GetStations;
@@ -0,0 +1,20 @@
1
+ export const mockGetStations = async (params) => {
2
+ console.log("[Mock] getStations called", params);
3
+ return {
4
+ stations: [
5
+ {
6
+ _id: "mock_station_001",
7
+ name: "POS Terminal 1",
8
+ status: "active",
9
+ sequenceNumber: 1,
10
+ },
11
+ {
12
+ _id: "mock_station_002",
13
+ name: "POS Terminal 2",
14
+ status: "active",
15
+ sequenceNumber: 2,
16
+ },
17
+ ],
18
+ timestamp: new Date().toISOString(),
19
+ };
20
+ };
@@ -0,0 +1,9 @@
1
+ import { CFActiveStation } from "../../CommonTypes";
2
+ export interface GetStationsParams {
3
+ outletId?: string;
4
+ }
5
+ export interface GetStationsResponse {
6
+ stations: CFActiveStation[];
7
+ timestamp: string;
8
+ }
9
+ export type GetStations = (params?: GetStationsParams) => Promise<GetStationsResponse>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -50,6 +50,12 @@ export declare const command: {
50
50
  readonly calculateRefundTotal: import("./actions/calculate-refund-total/types").CalculateRefundTotal;
51
51
  readonly getRemainingRefundableQuantities: import("./actions/get-remaining-refundable-quantities/types").GetRemainingRefundableQuantities;
52
52
  readonly processPartialRefund: import("./actions/process-partial-refund/types").ProcessPartialRefund;
53
+ readonly addProduct: import("./actions/add-product/types").AddProduct;
54
+ readonly editProduct: import("./actions/edit-product/types").EditProduct;
55
+ readonly editProductVariants: import("./actions/edit-product-variants/types").EditProductVariants;
56
+ readonly deleteProduct: import("./actions/delete-product/types").DeleteProduct;
57
+ readonly getOutlets: import("./actions/get-outlets/types").GetOutlets;
58
+ readonly getStations: import("./actions/get-stations/types").GetStations;
53
59
  readonly getCustomTables: import("./actions/get-custom-tables/types").GetCustomTables;
54
60
  readonly getCustomTableFields: import("./actions/get-custom-table-fields/types").GetCustomTableFields;
55
61
  readonly getCustomTableData: import("./actions/get-custom-table-data/types").GetCustomTableData;
@@ -72,6 +78,12 @@ export type { GetCustomers, GetCustomersParams, GetCustomersResponse } from "./a
72
78
  export type { AssignCustomer, AssignCustomerParams, AssignCustomerResponse } from "./actions/assign-customer/types";
73
79
  export type { AddCustomer, AddCustomerParams, AddCustomerResponse } from "./actions/add-customer/types";
74
80
  export type { GetCategories, GetCategoriesParams, GetCategoriesResponse } from "./actions/get-categories/types";
81
+ export type { AddProduct, AddProductParams, AddProductResponse } from "./actions/add-product/types";
82
+ export type { EditProduct, EditProductParams, EditProductResponse } from "./actions/edit-product/types";
83
+ export type { EditProductVariants, EditProductVariantsParams, EditProductVariantsResponse } from "./actions/edit-product-variants/types";
84
+ export type { DeleteProduct, DeleteProductParams, DeleteProductResponse } from "./actions/delete-product/types";
85
+ export type { GetOutlets, GetOutletsResponse } from "./actions/get-outlets/types";
86
+ export type { GetStations, GetStationsParams, GetStationsResponse } from "./actions/get-stations/types";
75
87
  export type { GetOrders, GetOrdersParams, GetOrdersResponse } from "./actions/get-orders/types";
76
88
  export type { GetRefunds, GetRefundsParams, GetRefundsResponse } from "./actions/get-refunds/types";
77
89
  export type { SetRefundStockAction, SetRefundStockActionParams, SetRefundStockActionResponse } from "./actions/set-refund-stock-action/types";
package/dist/index.js CHANGED
@@ -72,6 +72,14 @@ import { getSecretsKeys } from "./actions/get-secrets-keys/action";
72
72
  import { getSecretVal } from "./actions/get-secret-val/action";
73
73
  import { setSecretVal } from "./actions/set-secret-val/action";
74
74
  import { generateAPIKey } from "./actions/generate-api-key/action";
75
+ // Product CRUD Actions
76
+ import { addProduct } from "./actions/add-product/action";
77
+ import { editProduct } from "./actions/edit-product/action";
78
+ import { editProductVariants } from "./actions/edit-product-variants/action";
79
+ import { deleteProduct } from "./actions/delete-product/action";
80
+ // Entity Actions
81
+ import { getOutlets } from "./actions/get-outlets/action";
82
+ import { getStations } from "./actions/get-stations/action";
75
83
  // Export actions as command object
76
84
  export const command = {
77
85
  exampleFunction,
@@ -131,6 +139,14 @@ export const command = {
131
139
  calculateRefundTotal,
132
140
  getRemainingRefundableQuantities,
133
141
  processPartialRefund,
142
+ // Product CRUD Actions
143
+ addProduct,
144
+ editProduct,
145
+ editProductVariants,
146
+ deleteProduct,
147
+ // Entity Actions
148
+ getOutlets,
149
+ getStations,
134
150
  // Custom Tables Actions
135
151
  getCustomTables,
136
152
  getCustomTableFields,
@@ -16,6 +16,16 @@ import { mockGetCustomExtensionCustomTables } from "../../actions/get-custom-ext
16
16
  import { mockGetUsers } from "../../actions/get-users/mock";
17
17
  import { mockGetRoles } from "../../actions/get-roles/mock";
18
18
  import { mockGetCustomers } from "../../actions/get-customers/mock";
19
+ // Catalog Mocks
20
+ import { mockGetProducts } from "../../actions/get-products/mock";
21
+ import { mockGetCategories } from "../../actions/get-categories/mock";
22
+ import { mockEditProduct } from "../../actions/edit-product/mock";
23
+ import { mockEditProductVariants } from "../../actions/edit-product-variants/mock";
24
+ import { mockDeleteProduct } from "../../actions/delete-product/mock";
25
+ // Entity Mocks
26
+ import { mockGetOutlets } from "../../actions/get-outlets/mock";
27
+ import { mockGetStations } from "../../actions/get-stations/mock";
28
+ import { mockGetOrders } from "../../actions/get-orders/mock";
19
29
  // Manage-specific mock for getFinalContext
20
30
  const mockGetFinalContextManage = async () => {
21
31
  console.log("[Mock] getFinalContext called (Manage)");
@@ -42,5 +52,15 @@ export const MANAGE_MOCKS = {
42
52
  // Company Data Actions
43
53
  getUsers: mockGetUsers,
44
54
  getRoles: mockGetRoles,
45
- getCustomers: mockGetCustomers
55
+ getCustomers: mockGetCustomers,
56
+ // Catalog Actions
57
+ getProducts: mockGetProducts,
58
+ getCategories: mockGetCategories,
59
+ editProduct: mockEditProduct,
60
+ editProductVariants: mockEditProductVariants,
61
+ deleteProduct: mockDeleteProduct,
62
+ // Entity Actions
63
+ getOutlets: mockGetOutlets,
64
+ getStations: mockGetStations,
65
+ getOrders: mockGetOrders,
46
66
  };
@@ -1,6 +1,4 @@
1
- import type { GetContext, GetFinalContext, GetSecretsKeys, GetSecretVal, SetSecretVal, GenerateAPIKey, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomers } from "../../index";
2
- import type { GetUsers } from "../../actions/get-users/types";
3
- import type { GetRoles } from "../../actions/get-roles/types";
1
+ import type { GetContext, GetFinalContext, GetSecretsKeys, GetSecretVal, SetSecretVal, GenerateAPIKey, GetCustomTables, GetCustomTableData, UpsertCustomTableData, DeleteCustomTableData, GetCustomExtensions, GetCurrentCompanyCustomExtensions, GetCustomExtensionCustomTables, GetCustomers, GetProducts, GetCategories, EditProduct, EditProductVariants, DeleteProduct, GetOutlets, GetStations, GetOrders, GetUsers, GetRoles } from "../../index";
4
2
  export interface ManageProviderActions {
5
3
  getContext: GetContext;
6
4
  getFinalContext: GetFinalContext;
@@ -18,4 +16,12 @@ export interface ManageProviderActions {
18
16
  getUsers: GetUsers;
19
17
  getRoles: GetRoles;
20
18
  getCustomers: GetCustomers;
19
+ getProducts: GetProducts;
20
+ getCategories: GetCategories;
21
+ editProduct: EditProduct;
22
+ editProductVariants: EditProductVariants;
23
+ deleteProduct: DeleteProduct;
24
+ getOutlets: GetOutlets;
25
+ getStations: GetStations;
26
+ getOrders: GetOrders;
21
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-commerce/command-frame",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Commands Frame library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",