@final-commerce/command-frame 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CommonTypes.d.ts +28 -1
- package/dist/actions/generate-api-key/action.d.ts +2 -0
- package/dist/actions/generate-api-key/action.js +5 -0
- package/dist/actions/generate-api-key/mock.d.ts +2 -0
- package/dist/actions/generate-api-key/mock.js +6 -0
- package/dist/actions/generate-api-key/types.d.ts +7 -0
- package/dist/actions/generate-api-key/types.js +1 -0
- package/dist/actions/get-context/mock.d.ts +2 -1
- package/dist/actions/get-context/mock.js +28 -2
- package/dist/actions/get-context/types.d.ts +4 -2
- package/dist/actions/get-final-context/action.d.ts +1 -0
- package/dist/actions/get-final-context/action.js +3 -1
- package/dist/actions/get-final-context/mock.js +1 -1
- package/dist/actions/get-final-context/types.d.ts +2 -1
- package/dist/client.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/projects/manage/mocks.js +12 -4
- package/dist/projects/manage/types.d.ts +2 -1
- package/package.json +1 -1
package/dist/CommonTypes.d.ts
CHANGED
|
@@ -372,6 +372,7 @@ export interface CFActiveUser extends CFActiveEntity {
|
|
|
372
372
|
lastName?: string;
|
|
373
373
|
role: CFActiveUserRole;
|
|
374
374
|
id: string;
|
|
375
|
+
_id?: string;
|
|
375
376
|
outlets?: string[];
|
|
376
377
|
type?: CFUserTypes;
|
|
377
378
|
companies?: any;
|
|
@@ -447,7 +448,8 @@ export interface CFActiveCompany extends CFActiveEntity {
|
|
|
447
448
|
logo?: string;
|
|
448
449
|
settings?: any;
|
|
449
450
|
}
|
|
450
|
-
export
|
|
451
|
+
export type CFProjectName = "Render" | "Manage";
|
|
452
|
+
export interface CFContextRender {
|
|
451
453
|
userId: string | null;
|
|
452
454
|
companyId: string | null;
|
|
453
455
|
companyName: string | null;
|
|
@@ -467,3 +469,28 @@ export interface CFContext {
|
|
|
467
469
|
outlet: Record<string, any> | null;
|
|
468
470
|
timestamp: string;
|
|
469
471
|
}
|
|
472
|
+
export interface CFOutletInfo {
|
|
473
|
+
_id?: string;
|
|
474
|
+
id?: string;
|
|
475
|
+
name: string;
|
|
476
|
+
address?: string | {
|
|
477
|
+
address1?: string;
|
|
478
|
+
address2?: string;
|
|
479
|
+
city?: string;
|
|
480
|
+
country?: string;
|
|
481
|
+
state?: string;
|
|
482
|
+
postCode?: string;
|
|
483
|
+
};
|
|
484
|
+
city?: string;
|
|
485
|
+
state?: string;
|
|
486
|
+
country?: string;
|
|
487
|
+
}
|
|
488
|
+
export interface CFContextManage {
|
|
489
|
+
user: any;
|
|
490
|
+
company: any;
|
|
491
|
+
menuItem?: any;
|
|
492
|
+
extensionId: string;
|
|
493
|
+
outlets?: any[];
|
|
494
|
+
timestamp: string;
|
|
495
|
+
}
|
|
496
|
+
export type CFContext = CFContextRender;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MOCK_COMPANY, MOCK_OUTLET, MOCK_STATION, MOCK_USER } from "../../demo/database";
|
|
2
|
+
// Mock for Render context (POS terminal)
|
|
2
3
|
export const mockGetContext = async () => {
|
|
3
|
-
console.log("[Mock] getContext called");
|
|
4
|
+
console.log("[Mock] getContext called (Render)");
|
|
4
5
|
return {
|
|
5
|
-
userId: MOCK_USER.id,
|
|
6
|
+
userId: MOCK_USER.id || null,
|
|
6
7
|
companyId: MOCK_COMPANY.id || null,
|
|
7
8
|
companyName: MOCK_COMPANY.name || null,
|
|
8
9
|
deviceId: "mock_device_id",
|
|
@@ -22,3 +23,28 @@ export const mockGetContext = async () => {
|
|
|
22
23
|
timestamp: new Date().toISOString()
|
|
23
24
|
};
|
|
24
25
|
};
|
|
26
|
+
// Mock for Manage context (Hub/BuilderHub)
|
|
27
|
+
export const mockGetContextManage = async () => {
|
|
28
|
+
console.log("[Mock] getContext called (Manage)");
|
|
29
|
+
return {
|
|
30
|
+
user: {
|
|
31
|
+
_id: MOCK_USER.id,
|
|
32
|
+
id: MOCK_USER.id,
|
|
33
|
+
firstName: MOCK_USER.firstName,
|
|
34
|
+
lastName: MOCK_USER.lastName
|
|
35
|
+
},
|
|
36
|
+
company: {
|
|
37
|
+
_id: MOCK_COMPANY.id,
|
|
38
|
+
name: MOCK_COMPANY.name || "Demo Company",
|
|
39
|
+
logo: MOCK_COMPANY.logo
|
|
40
|
+
},
|
|
41
|
+
menuItem: {
|
|
42
|
+
_id: "mock_menu_item_id",
|
|
43
|
+
text: "Demo Menu Item",
|
|
44
|
+
iframeUrl: "https://example.com/iframe"
|
|
45
|
+
},
|
|
46
|
+
extensionId: "mock_extension_id",
|
|
47
|
+
outlets: [MOCK_OUTLET],
|
|
48
|
+
timestamp: new Date().toISOString()
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
1
|
+
import { CFContextRender, CFContextManage } from "../../CommonTypes";
|
|
2
|
+
export type GetContextResponseRender = CFContextRender;
|
|
3
|
+
export type GetContextResponseManage = CFContextManage;
|
|
4
|
+
export type GetContextResponse = CFContextRender | CFContextManage;
|
|
3
5
|
export type GetContext = () => Promise<GetContextResponse>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get final context action
|
|
3
3
|
* Calls the getFinalContext action on the parent window
|
|
4
|
+
* Uses a 5-second timeout since this should respond quickly
|
|
4
5
|
*/
|
|
5
6
|
import { commandFrameClient } from "../../client";
|
|
7
|
+
const GET_FINAL_CONTEXT_TIMEOUT = 5000; // 5 seconds
|
|
6
8
|
export const getFinalContext = async () => {
|
|
7
|
-
return await commandFrameClient.call("getFinalContext", undefined);
|
|
9
|
+
return await commandFrameClient.call("getFinalContext", undefined, GET_FINAL_CONTEXT_TIMEOUT);
|
|
8
10
|
};
|
package/dist/client.js
CHANGED
|
@@ -26,6 +26,8 @@ export class CommandFrameClient {
|
|
|
26
26
|
// Auto-detect mock mode on initialization
|
|
27
27
|
this.detectContext().then((context) => {
|
|
28
28
|
if (!context) {
|
|
29
|
+
// If context detection fails, we switch to mock mode
|
|
30
|
+
// BUT only if we aren't already forcing mock mode (which happens above if no parent)
|
|
29
31
|
if (this.isDebugEnabled()) {
|
|
30
32
|
console.warn("[ActionsClient] Environment detection failed (timeout or error). Switching to Mock Mode.");
|
|
31
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const command: {
|
|
2
2
|
readonly exampleFunction: import("./actions/example-function/types").ExampleFunction;
|
|
3
|
+
readonly generateAPIKey: import("./actions/generate-api-key/types").GenerateAPIKey;
|
|
3
4
|
readonly getProducts: import("./actions/get-products/types").GetProducts;
|
|
4
5
|
readonly addCustomSale: import("./actions/add-custom-sale/types").AddCustomSale;
|
|
5
6
|
readonly getCustomers: import("./actions/get-customers/types").GetCustomers;
|
|
@@ -59,6 +60,7 @@ export declare const command: {
|
|
|
59
60
|
readonly getCustomExtensionCustomTables: import("./actions/get-custom-extension-custom-tables/types").GetCustomExtensionCustomTables;
|
|
60
61
|
};
|
|
61
62
|
export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from "./actions/example-function/types";
|
|
63
|
+
export type { GenerateAPIKey, GenerateAPIKeyParams, GenerateAPIKeyResponse } from "./actions/generate-api-key/types";
|
|
62
64
|
export type { GetProducts, GetProductsParams, GetProductsResponse } from "./actions/get-products/types";
|
|
63
65
|
export type { AddCustomSale, AddCustomSaleParams, AddCustomSaleResponse } from "./actions/add-custom-sale/types";
|
|
64
66
|
export type { GetCustomers, GetCustomersParams, GetCustomersResponse } from "./actions/get-customers/types";
|
|
@@ -80,7 +82,7 @@ export type { AddProductToCart, AddProductToCartParams, AddProductToCartResponse
|
|
|
80
82
|
export type { RemoveProductFromCart, RemoveProductFromCartParams, RemoveProductFromCartResponse } from "./actions/remove-product-from-cart/types";
|
|
81
83
|
export type { UpdateCartItemQuantity, UpdateCartItemQuantityParams, UpdateCartItemQuantityResponse } from "./actions/update-cart-item-quantity/types";
|
|
82
84
|
export type { AddCartDiscount, AddCartDiscountParams, AddCartDiscountResponse } from "./actions/add-cart-discount/types";
|
|
83
|
-
export type { GetContext, GetContextResponse } from "./actions/get-context/types";
|
|
85
|
+
export type { GetContext, GetContextResponse, GetContextResponseManage, GetContextResponseRender } from "./actions/get-context/types";
|
|
84
86
|
export type { GetFinalContext, GetFinalContextResponse } from "./actions/get-final-context/types";
|
|
85
87
|
export type { AddProductNote, AddProductNoteParams, AddProductNoteResponse } from "./actions/add-product-note/types";
|
|
86
88
|
export type { AddProductFee, AddProductFeeParams, AddProductFeeResponse } from "./actions/add-product-fee/types";
|
package/dist/index.js
CHANGED
|
@@ -65,9 +65,11 @@ import { deleteCustomTableData } from "./actions/delete-custom-table-data/action
|
|
|
65
65
|
import { getCustomExtensions } from "./actions/get-custom-extensions/action";
|
|
66
66
|
import { getCurrentCompanyCustomExtensions } from "./actions/get-current-company-custom-extensions/action";
|
|
67
67
|
import { getCustomExtensionCustomTables } from "./actions/get-custom-extension-custom-tables/action";
|
|
68
|
+
import { generateAPIKey } from "./actions/generate-api-key/action";
|
|
68
69
|
// Export actions as command object
|
|
69
70
|
export const command = {
|
|
70
71
|
exampleFunction,
|
|
72
|
+
generateAPIKey,
|
|
71
73
|
getProducts,
|
|
72
74
|
addCustomSale,
|
|
73
75
|
getCustomers,
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mockGetContextManage } from "../../actions/get-context/mock";
|
|
2
|
+
import { mockGenerateAPIKey } from "../../actions/generate-api-key/mock";
|
|
3
|
+
// Manage-specific mock for getFinalContext
|
|
4
|
+
const mockGetFinalContextManage = async () => {
|
|
5
|
+
console.log("[Mock] getFinalContext called (Manage)");
|
|
6
|
+
return {
|
|
7
|
+
projectName: "Manage"
|
|
8
|
+
};
|
|
9
|
+
};
|
|
3
10
|
export const MANAGE_MOCKS = {
|
|
4
|
-
getContext:
|
|
5
|
-
getFinalContext:
|
|
11
|
+
getContext: mockGetContextManage,
|
|
12
|
+
getFinalContext: mockGetFinalContextManage,
|
|
13
|
+
generateAPIKey: mockGenerateAPIKey
|
|
6
14
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { GetContext, GetFinalContext } from "../../index";
|
|
1
|
+
import type { GetContext, GetFinalContext, GenerateAPIKey } from "../../index";
|
|
2
2
|
export interface ManageProviderActions {
|
|
3
3
|
getContext: GetContext;
|
|
4
4
|
getFinalContext: GetFinalContext;
|
|
5
|
+
generateAPIKey: GenerateAPIKey;
|
|
5
6
|
}
|