@final-commerce/command-frame 0.1.46 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/actions/get-branding/action.d.ts +5 -0
- package/dist/actions/get-branding/action.js +7 -0
- package/dist/actions/get-branding/mock.d.ts +2 -0
- package/dist/actions/get-branding/mock.js +24 -0
- package/dist/actions/get-branding/types.d.ts +23 -0
- package/dist/actions/get-branding/types.js +2 -0
- package/dist/actions/get-media/action.d.ts +5 -0
- package/dist/actions/get-media/action.js +7 -0
- package/dist/actions/get-media/mock.d.ts +2 -0
- package/dist/actions/get-media/mock.js +35 -0
- package/dist/actions/get-media/types.d.ts +30 -0
- package/dist/actions/get-media/types.js +2 -0
- package/dist/actions/get-tax-tables/action.d.ts +5 -0
- package/dist/actions/get-tax-tables/action.js +7 -0
- package/dist/actions/get-tax-tables/mock.d.ts +2 -0
- package/dist/actions/get-tax-tables/mock.js +21 -0
- package/dist/actions/get-tax-tables/types.d.ts +15 -0
- package/dist/actions/get-tax-tables/types.js +2 -0
- package/dist/actions/navigate-to/action.d.ts +5 -0
- package/dist/actions/navigate-to/action.js +7 -0
- package/dist/actions/navigate-to/mock.d.ts +2 -0
- package/dist/actions/navigate-to/mock.js +7 -0
- package/dist/actions/navigate-to/types.d.ts +9 -0
- package/dist/actions/navigate-to/types.js +2 -0
- package/dist/actions/refresh-resource/action.d.ts +5 -0
- package/dist/actions/refresh-resource/action.js +7 -0
- package/dist/actions/refresh-resource/mock.d.ts +2 -0
- package/dist/actions/refresh-resource/mock.js +7 -0
- package/dist/actions/refresh-resource/types.d.ts +9 -0
- package/dist/actions/refresh-resource/types.js +2 -0
- package/dist/actions/show-notification/mock.js +2 -2
- package/dist/actions/show-notification/types.d.ts +2 -0
- package/dist/actions/upload-media/action.d.ts +5 -0
- package/dist/actions/upload-media/action.js +7 -0
- package/dist/actions/upload-media/mock.d.ts +2 -0
- package/dist/actions/upload-media/mock.js +14 -0
- package/dist/actions/upload-media/types.d.ts +20 -0
- package/dist/actions/upload-media/types.js +2 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +14 -0
- package/dist/projects/manage/mocks.js +16 -0
- package/dist/projects/manage/types.d.ts +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ const products = await client.getProducts();
|
|
|
61
61
|
For building applications that run inside the Final Commerce Management Dashboard.
|
|
62
62
|
|
|
63
63
|
- **[Manage Documentation](./src/projects/manage/README.md)**
|
|
64
|
-
- **Features:** Context
|
|
64
|
+
- **Features:** Context, catalog, entities, custom tables, secrets, and optional host-specific commands (navigation, media, tax, branding, notifications) when the dashboard implements them.
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
import { ManageClient } from '@final-commerce/command-frame';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const mockGetBranding = async () => {
|
|
2
|
+
console.log("[Mock] getBranding called");
|
|
3
|
+
return {
|
|
4
|
+
theme: "light",
|
|
5
|
+
colors: {
|
|
6
|
+
primary: "#2563eb",
|
|
7
|
+
secondary: "#64748b",
|
|
8
|
+
accent: "#0ea5e9",
|
|
9
|
+
destructive: "#dc2626",
|
|
10
|
+
sidebar: "#1e293b",
|
|
11
|
+
background: "#ffffff",
|
|
12
|
+
foreground: "#0f172a",
|
|
13
|
+
muted: "#f1f5f9",
|
|
14
|
+
border: "#e2e8f0"
|
|
15
|
+
},
|
|
16
|
+
borderRadius: "round",
|
|
17
|
+
borderRadiusValue: "0.5rem",
|
|
18
|
+
font: {
|
|
19
|
+
family: "system-ui, sans-serif"
|
|
20
|
+
},
|
|
21
|
+
logo: null,
|
|
22
|
+
timestamp: new Date().toISOString()
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type BorderRadiusPreset = "sharp" | "soft" | "round" | "pill";
|
|
2
|
+
export interface GetBrandingResponse {
|
|
3
|
+
theme: "light" | "dark";
|
|
4
|
+
colors: {
|
|
5
|
+
primary: string;
|
|
6
|
+
secondary: string;
|
|
7
|
+
accent: string;
|
|
8
|
+
destructive: string;
|
|
9
|
+
sidebar: string;
|
|
10
|
+
background: string;
|
|
11
|
+
foreground: string;
|
|
12
|
+
muted: string;
|
|
13
|
+
border: string;
|
|
14
|
+
};
|
|
15
|
+
borderRadius: BorderRadiusPreset;
|
|
16
|
+
borderRadiusValue: string;
|
|
17
|
+
font: {
|
|
18
|
+
family: string;
|
|
19
|
+
};
|
|
20
|
+
logo: string | null;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
export type GetBranding = () => Promise<GetBrandingResponse>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const now = new Date().toISOString();
|
|
2
|
+
export const mockGetMedia = async (params) => {
|
|
3
|
+
console.log("[Mock] getMedia called", params);
|
|
4
|
+
const items = [
|
|
5
|
+
{
|
|
6
|
+
_id: "mock_media_1",
|
|
7
|
+
url: "https://example.com/media/photo1.jpg",
|
|
8
|
+
filename: "photo1.jpg",
|
|
9
|
+
mimeType: "image/jpeg",
|
|
10
|
+
size: 102400,
|
|
11
|
+
folder: "images",
|
|
12
|
+
title: "Sample photo",
|
|
13
|
+
alt: "Sample",
|
|
14
|
+
width: 800,
|
|
15
|
+
height: 600,
|
|
16
|
+
createdAt: now
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_id: "mock_media_2",
|
|
20
|
+
url: "https://example.com/media/doc.pdf",
|
|
21
|
+
filename: "doc.pdf",
|
|
22
|
+
mimeType: "application/pdf",
|
|
23
|
+
size: 51200,
|
|
24
|
+
folder: "documents",
|
|
25
|
+
createdAt: now
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
return {
|
|
29
|
+
items,
|
|
30
|
+
total: items.length,
|
|
31
|
+
page: params?.page ?? 1,
|
|
32
|
+
pageSize: params?.pageSize ?? 20,
|
|
33
|
+
timestamp: new Date().toISOString()
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface GetMediaParams {
|
|
2
|
+
search?: string;
|
|
3
|
+
mimeType?: string[];
|
|
4
|
+
folder?: string;
|
|
5
|
+
page?: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
sortBy?: "createdAt" | "filename" | "size" | "title";
|
|
8
|
+
sortDir?: "asc" | "desc";
|
|
9
|
+
}
|
|
10
|
+
export interface MediaItemPayload {
|
|
11
|
+
_id: string;
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
mimeType: string;
|
|
15
|
+
size: number;
|
|
16
|
+
folder: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
alt?: string;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GetMediaResponse {
|
|
24
|
+
items: MediaItemPayload[];
|
|
25
|
+
total: number;
|
|
26
|
+
page: number;
|
|
27
|
+
pageSize: number;
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}
|
|
30
|
+
export type GetMedia = (params?: GetMediaParams) => Promise<GetMediaResponse>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const mockGetTaxTables = async () => {
|
|
2
|
+
console.log("[Mock] getTaxTables called");
|
|
3
|
+
return {
|
|
4
|
+
taxTables: [
|
|
5
|
+
{
|
|
6
|
+
_id: "mock_table_1",
|
|
7
|
+
name: "Standard",
|
|
8
|
+
rates: [
|
|
9
|
+
{ _id: "mock_rate_1", name: "GST", isCompounding: false },
|
|
10
|
+
{ _id: "mock_rate_2", name: "PST", isCompounding: true }
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
_id: "mock_table_2",
|
|
15
|
+
name: "Zero",
|
|
16
|
+
rates: [{ _id: "mock_rate_3", name: "Zero rated", isCompounding: false }]
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
timestamp: new Date().toISOString()
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TaxRatePayload {
|
|
2
|
+
_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
isCompounding: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface TaxTablePayload {
|
|
7
|
+
_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
rates: TaxRatePayload[];
|
|
10
|
+
}
|
|
11
|
+
export interface GetTaxTablesResponse {
|
|
12
|
+
taxTables: TaxTablePayload[];
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
export type GetTaxTables = () => Promise<GetTaxTablesResponse>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface NavigateToParams {
|
|
2
|
+
/** In-app path (must start with `/`). Hosts may restrict allowed prefixes. */
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
export interface NavigateToResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
}
|
|
9
|
+
export type NavigateTo = (params: NavigateToParams) => Promise<NavigateToResponse>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refresh resource action — invalidate cached list/detail data in the Manage host.
|
|
3
|
+
*/
|
|
4
|
+
import { commandFrameClient } from "../../client";
|
|
5
|
+
export const refreshResource = async (params) => {
|
|
6
|
+
return await commandFrameClient.call("refreshResource", params);
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RefreshResourceParams {
|
|
2
|
+
/** Resource key used by the host data layer (e.g. Refine resource name). */
|
|
3
|
+
resource: string;
|
|
4
|
+
}
|
|
5
|
+
export interface RefreshResourceResponse {
|
|
6
|
+
success: boolean;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
}
|
|
9
|
+
export type RefreshResource = (params: RefreshResourceParams) => Promise<RefreshResourceResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const mockShowNotification = async (params) => {
|
|
2
|
-
console.log("[Mock] showNotification called", params);
|
|
3
|
-
window.alert(`Notification: ${params?.message || "No message"}`);
|
|
2
|
+
console.log("[Mock] showNotification called", params?.message, params?.type);
|
|
3
|
+
window.alert(`Notification${params?.type ? ` (${params.type})` : ""}: ${params?.message || "No message"}`);
|
|
4
4
|
return {
|
|
5
5
|
success: true,
|
|
6
6
|
message: params?.message || "",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const mockUploadMedia = async (params) => {
|
|
2
|
+
console.log("[Mock] uploadMedia called", params.filename, params.mimeType);
|
|
3
|
+
return {
|
|
4
|
+
success: true,
|
|
5
|
+
url: `https://example.com/media/mock/${encodeURIComponent(params.filename)}`,
|
|
6
|
+
id: "mock_upload_id",
|
|
7
|
+
filename: params.filename,
|
|
8
|
+
mimeType: params.mimeType,
|
|
9
|
+
size: 1234,
|
|
10
|
+
width: null,
|
|
11
|
+
height: null,
|
|
12
|
+
timestamp: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UploadMediaParams {
|
|
2
|
+
/** Base64-encoded file content (no data URL prefix). */
|
|
3
|
+
base64: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
/** Target folder label; host default if omitted. */
|
|
7
|
+
folder?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UploadMediaResponse {
|
|
10
|
+
success: boolean;
|
|
11
|
+
url: string;
|
|
12
|
+
id?: string | null;
|
|
13
|
+
filename?: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
width?: number | null;
|
|
17
|
+
height?: number | null;
|
|
18
|
+
timestamp: string;
|
|
19
|
+
}
|
|
20
|
+
export type UploadMedia = (params: UploadMediaParams) => Promise<UploadMediaResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ export declare const command: {
|
|
|
72
72
|
readonly getSecretsKeys: import("./actions/get-secrets-keys/types").GetSecretsKeys;
|
|
73
73
|
readonly getSecretVal: import("./actions/get-secret-val/types").GetSecretVal;
|
|
74
74
|
readonly setSecretVal: import("./actions/set-secret-val/types").SetSecretVal;
|
|
75
|
+
readonly navigateTo: import("./actions/navigate-to/types").NavigateTo;
|
|
76
|
+
readonly refreshResource: import("./actions/refresh-resource/types").RefreshResource;
|
|
77
|
+
readonly getMedia: import("./actions/get-media/types").GetMedia;
|
|
78
|
+
readonly uploadMedia: import("./actions/upload-media/types").UploadMedia;
|
|
79
|
+
readonly getTaxTables: import("./actions/get-tax-tables/types").GetTaxTables;
|
|
80
|
+
readonly getBranding: import("./actions/get-branding/types").GetBranding;
|
|
75
81
|
};
|
|
76
82
|
export type { ExampleFunction, ExampleFunctionParams, ExampleFunctionResponse } from "./actions/example-function/types";
|
|
77
83
|
export type { GenerateAPIKey, GenerateAPIKeyParams, GenerateAPIKeyResponse } from "./actions/generate-api-key/types";
|
|
@@ -128,6 +134,12 @@ export type { RemoveCustomerFromCart, RemoveCustomerFromCartResponse } from "./a
|
|
|
128
134
|
export type { GoToStationHome, GoToStationHomeResponse } from "./actions/go-to-station-home/types";
|
|
129
135
|
export type { OpenCashDrawer, OpenCashDrawerResponse } from "./actions/open-cash-drawer/types";
|
|
130
136
|
export type { ShowNotification, ShowNotificationParams, ShowNotificationResponse } from "./actions/show-notification/types";
|
|
137
|
+
export type { NavigateTo, NavigateToParams, NavigateToResponse } from "./actions/navigate-to/types";
|
|
138
|
+
export type { RefreshResource, RefreshResourceParams, RefreshResourceResponse } from "./actions/refresh-resource/types";
|
|
139
|
+
export type { GetMedia, GetMediaParams, GetMediaResponse, MediaItemPayload } from "./actions/get-media/types";
|
|
140
|
+
export type { UploadMedia, UploadMediaParams, UploadMediaResponse } from "./actions/upload-media/types";
|
|
141
|
+
export type { GetTaxTables, GetTaxTablesResponse, TaxRatePayload, TaxTablePayload } from "./actions/get-tax-tables/types";
|
|
142
|
+
export type { BorderRadiusPreset, GetBranding, GetBrandingResponse } from "./actions/get-branding/types";
|
|
131
143
|
export type { ShowConfirmation, ShowConfirmationParams, ShowConfirmationResponse } from "./actions/show-confirmation/types";
|
|
132
144
|
export type { AuthenticateUser, AuthenticateUserParams, AuthenticateUserResponse } from "./actions/authenticate-user/types";
|
|
133
145
|
export type { PartialPayment, PartialPaymentParams, PartialPaymentResponse } from "./actions/partial-payment/types";
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,13 @@ import { deleteProduct } from "./actions/delete-product/action";
|
|
|
83
83
|
// Entity Actions
|
|
84
84
|
import { getOutlets } from "./actions/get-outlets/action";
|
|
85
85
|
import { getStations } from "./actions/get-stations/action";
|
|
86
|
+
// Manage extension actions (optional hosts: Deerlake, etc.)
|
|
87
|
+
import { navigateTo } from "./actions/navigate-to/action";
|
|
88
|
+
import { refreshResource } from "./actions/refresh-resource/action";
|
|
89
|
+
import { getMedia } from "./actions/get-media/action";
|
|
90
|
+
import { uploadMedia } from "./actions/upload-media/action";
|
|
91
|
+
import { getTaxTables } from "./actions/get-tax-tables/action";
|
|
92
|
+
import { getBranding } from "./actions/get-branding/action";
|
|
86
93
|
// Export actions as command object
|
|
87
94
|
export const command = {
|
|
88
95
|
exampleFunction,
|
|
@@ -170,6 +177,13 @@ export const command = {
|
|
|
170
177
|
getSecretsKeys,
|
|
171
178
|
getSecretVal,
|
|
172
179
|
setSecretVal,
|
|
180
|
+
// Manage extension actions (optional on ManageProviderActions)
|
|
181
|
+
navigateTo,
|
|
182
|
+
refreshResource,
|
|
183
|
+
getMedia,
|
|
184
|
+
uploadMedia,
|
|
185
|
+
getTaxTables,
|
|
186
|
+
getBranding,
|
|
173
187
|
};
|
|
174
188
|
export { EXTENSION_REFUND_REQUEST_ACTION } from "./actions/extension-refund/constants";
|
|
175
189
|
export { installExtensionRefundListener } from "./actions/extension-refund/extension-refund-listener";
|
|
@@ -26,6 +26,14 @@ import { mockDeleteProduct } from "../../actions/delete-product/mock";
|
|
|
26
26
|
import { mockGetOutlets } from "../../actions/get-outlets/mock";
|
|
27
27
|
import { mockGetStations } from "../../actions/get-stations/mock";
|
|
28
28
|
import { mockGetOrders } from "../../actions/get-orders/mock";
|
|
29
|
+
// Manage extension mocks
|
|
30
|
+
import { mockShowNotification } from "../../actions/show-notification/mock";
|
|
31
|
+
import { mockNavigateTo } from "../../actions/navigate-to/mock";
|
|
32
|
+
import { mockRefreshResource } from "../../actions/refresh-resource/mock";
|
|
33
|
+
import { mockGetMedia } from "../../actions/get-media/mock";
|
|
34
|
+
import { mockUploadMedia } from "../../actions/upload-media/mock";
|
|
35
|
+
import { mockGetTaxTables } from "../../actions/get-tax-tables/mock";
|
|
36
|
+
import { mockGetBranding } from "../../actions/get-branding/mock";
|
|
29
37
|
// Manage-specific mock for getFinalContext
|
|
30
38
|
const mockGetFinalContextManage = async () => {
|
|
31
39
|
console.log("[Mock] getFinalContext called (Manage)");
|
|
@@ -63,4 +71,12 @@ export const MANAGE_MOCKS = {
|
|
|
63
71
|
getOutlets: mockGetOutlets,
|
|
64
72
|
getStations: mockGetStations,
|
|
65
73
|
getOrders: mockGetOrders,
|
|
74
|
+
// Manage extension mocks
|
|
75
|
+
showNotification: mockShowNotification,
|
|
76
|
+
navigateTo: mockNavigateTo,
|
|
77
|
+
refreshResource: mockRefreshResource,
|
|
78
|
+
getMedia: mockGetMedia,
|
|
79
|
+
uploadMedia: mockUploadMedia,
|
|
80
|
+
getTaxTables: mockGetTaxTables,
|
|
81
|
+
getBranding: mockGetBranding,
|
|
66
82
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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, ShowNotification, NavigateTo, RefreshResource, GetMedia, UploadMedia, GetTaxTables, GetBranding } from "../../index";
|
|
2
2
|
export interface ManageProviderActions {
|
|
3
3
|
getContext: GetContext;
|
|
4
4
|
getFinalContext: GetFinalContext;
|
|
@@ -24,4 +24,18 @@ export interface ManageProviderActions {
|
|
|
24
24
|
getOutlets: GetOutlets;
|
|
25
25
|
getStations: GetStations;
|
|
26
26
|
getOrders: GetOrders;
|
|
27
|
+
/** Optional: toast / notification in host shell (e.g. Deerlake). */
|
|
28
|
+
showNotification?: ShowNotification;
|
|
29
|
+
/** Optional: SPA navigation (e.g. Deerlake). */
|
|
30
|
+
navigateTo?: NavigateTo;
|
|
31
|
+
/** Optional: invalidate cached data for a resource key (e.g. Deerlake). */
|
|
32
|
+
refreshResource?: RefreshResource;
|
|
33
|
+
/** Optional: list media library (e.g. Deerlake). */
|
|
34
|
+
getMedia?: GetMedia;
|
|
35
|
+
/** Optional: upload media via host (e.g. Deerlake). */
|
|
36
|
+
uploadMedia?: UploadMedia;
|
|
37
|
+
/** Optional: tax tables for company (e.g. Deerlake). */
|
|
38
|
+
getTaxTables?: GetTaxTables;
|
|
39
|
+
/** Optional: theme tokens for iframe styling (e.g. Deerlake). */
|
|
40
|
+
getBranding?: GetBranding;
|
|
27
41
|
}
|