@mercurjs/dashboard-sdk 2.2.0-canary.40 → 2.2.0-canary.41
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/chunk-3RG5ZIWI.js +10 -0
- package/dist/index.cjs +16 -917
- package/dist/index.d.cts +159 -80
- package/dist/index.d.ts +173 -0
- package/dist/index.js +23 -0
- package/dist/types-zgnwn8ra.d.cts +74 -0
- package/dist/types-zgnwn8ra.d.ts +74 -0
- package/dist/vite.cjs +1201 -0
- package/dist/vite.d.cts +14 -0
- package/dist/vite.d.ts +14 -0
- package/dist/vite.js +1180 -0
- package/package.json +13 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,94 +1,173 @@
|
|
|
1
|
-
|
|
1
|
+
export { B as BuiltMercurConfig, M as MercurConfig, R as RouteConfig } from './types-zgnwn8ra.cjs';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Open registry interfaces. Each panel package ships a generated
|
|
6
|
+
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
7
|
+
* (declaration merging), and a developer augments them by hand to register a
|
|
8
|
+
* zone their own page renders. The helper unions read off the interface keys.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
11
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
12
|
+
* interface WidgetZoneRegistry {
|
|
13
|
+
* "erp.dashboard.before": true
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
17
16
|
*/
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
SettingsSidebar?: string;
|
|
50
|
-
TopbarActions?: string;
|
|
51
|
-
StoreSetup?: string;
|
|
52
|
-
};
|
|
53
|
-
/** Internationalization settings. */
|
|
54
|
-
i18n?: {
|
|
55
|
-
/** The default language code (e.g. `"en"`). */
|
|
56
|
-
defaultLanguage: string;
|
|
57
|
-
};
|
|
58
|
-
/** Whether to allow new sellers to register from the login screen. */
|
|
59
|
-
enableSellerRegistration?: boolean;
|
|
17
|
+
interface WidgetZoneRegistry {
|
|
18
|
+
}
|
|
19
|
+
interface NavItemRegistry {
|
|
20
|
+
}
|
|
21
|
+
interface NavParentRegistry {
|
|
22
|
+
}
|
|
23
|
+
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
24
|
+
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
25
|
+
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* A widget is a React component attached to a named zone on a page. The
|
|
28
|
+
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
29
|
+
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
30
|
+
* order.
|
|
31
|
+
*/
|
|
32
|
+
interface WidgetConfig {
|
|
33
|
+
zone: WidgetZoneId | WidgetZoneId[];
|
|
34
|
+
/** Stable id; derived from the file path at build time when omitted. */
|
|
35
|
+
id?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Override for a single built-in navigation item. */
|
|
38
|
+
interface NavItemOverride {
|
|
39
|
+
id: NavItemId;
|
|
40
|
+
/** Order within the item's parent (or among top-level items). */
|
|
41
|
+
rank?: number;
|
|
42
|
+
/** Remove from the sidebar (route may still be reachable directly). */
|
|
43
|
+
hidden?: boolean;
|
|
44
|
+
/** i18n key or literal replacing the item's label. */
|
|
45
|
+
label?: string;
|
|
46
|
+
/** Icon component replacing the item's icon. */
|
|
47
|
+
icon?: ComponentType;
|
|
60
48
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* before they are sent to the backend.
|
|
64
|
-
* @default 2_097_152 // 2 MB
|
|
49
|
+
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
50
|
+
* children; `null` promotes a nested item to the top level.
|
|
65
51
|
*/
|
|
66
|
-
|
|
52
|
+
nested?: NavParentId | null;
|
|
67
53
|
}
|
|
68
|
-
interface
|
|
69
|
-
|
|
70
|
-
base?: string;
|
|
71
|
-
root: string;
|
|
72
|
-
srcDir: string;
|
|
73
|
-
pluginExtensions: string[];
|
|
74
|
-
imageLimit: number;
|
|
54
|
+
interface NavigationConfig {
|
|
55
|
+
items: NavItemOverride[];
|
|
75
56
|
}
|
|
76
|
-
type RouteConfig = {
|
|
77
|
-
label: string;
|
|
78
|
-
icon?: ComponentType;
|
|
79
|
-
rank?: number;
|
|
80
|
-
nested?: string;
|
|
81
|
-
translationNs?: string;
|
|
82
|
-
public?: boolean;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
declare function mercurDashboardPlugin(pluginConfig: MercurConfig): Vite.Plugin;
|
|
86
57
|
|
|
87
58
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
59
|
+
* Minimal structural stand-in for a Zod schema, so the SDK stays free of a zod
|
|
60
|
+
* dependency. `createFormHelper` (in `@mercurjs/dashboard-shared`) produces real
|
|
61
|
+
* zod schemas that satisfy this shape.
|
|
91
62
|
*/
|
|
92
|
-
|
|
63
|
+
type FieldValidation = {
|
|
64
|
+
safeParse?: (value: unknown) => unknown;
|
|
65
|
+
parse?: (value: unknown) => unknown;
|
|
66
|
+
def?: {
|
|
67
|
+
type?: string;
|
|
68
|
+
};
|
|
69
|
+
_def?: unknown;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Per-model registry seeded by each panel's generated `extension-targets.d.ts`
|
|
73
|
+
* and extendable by hand. Shapes the typed form/display zones per model.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
77
|
+
* interface CustomFieldsRegistry {
|
|
78
|
+
* product: {
|
|
79
|
+
* formZones: "create" | "edit" | "organize" | "attributes"
|
|
80
|
+
* formTabs: { create: "general" | "organize"; edit: never }
|
|
81
|
+
* displayZones: "general" | "organize"
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
interface CustomFieldsRegistry {
|
|
87
|
+
}
|
|
88
|
+
type DefaultModelShape = {
|
|
89
|
+
formZones: string;
|
|
90
|
+
formTabs: Record<string, string>;
|
|
91
|
+
displayZones: string;
|
|
92
|
+
displayFieldIds: string;
|
|
93
|
+
};
|
|
94
|
+
type CustomFieldModel = keyof CustomFieldsRegistry extends never ? string : keyof CustomFieldsRegistry;
|
|
95
|
+
type ModelShape<TModel> = TModel extends keyof CustomFieldsRegistry ? CustomFieldsRegistry[TModel] & DefaultModelShape : DefaultModelShape;
|
|
96
|
+
type CustomFormField<TData = unknown> = {
|
|
97
|
+
/** Zod schema — drives the input type and validation. */
|
|
98
|
+
validation: FieldValidation;
|
|
99
|
+
/** Static default or a resolver from the loaded entity. */
|
|
100
|
+
defaultValue?: ((data: TData) => unknown) | unknown;
|
|
101
|
+
label?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
placeholder?: string;
|
|
104
|
+
/** Custom render component; falls back to a default input for the type. */
|
|
105
|
+
component?: ComponentType;
|
|
106
|
+
};
|
|
107
|
+
type CustomFormZone<TModel> = ModelShape<TModel>["formZones"];
|
|
108
|
+
/**
|
|
109
|
+
* Valid tab ids for a model's form zone. Narrows to the scanned union when the
|
|
110
|
+
* zone has tabbed forms; falls back to `string` for zones without tabs (e.g.
|
|
111
|
+
* onboarding steps) and for unknown models.
|
|
112
|
+
*/
|
|
113
|
+
type CustomFormTab<TModel, TZone> = TZone extends keyof ModelShape<TModel>["formTabs"] ? ModelShape<TModel>["formTabs"][TZone] : string;
|
|
114
|
+
type CustomFormEntry<TModel> = CustomFormZone<TModel> extends infer TZone ? TZone extends CustomFormZone<TModel> ? {
|
|
115
|
+
zone: TZone;
|
|
116
|
+
/** TabbedForm tab id, or onboarding wizard step id for `zone: "onboarding"`. */
|
|
117
|
+
tab?: CustomFormTab<TModel, TZone>;
|
|
118
|
+
fields: Record<string, CustomFormField>;
|
|
119
|
+
} : never : never;
|
|
120
|
+
/**
|
|
121
|
+
* ADD (unknown id + component), REPLACE (built-in id + component), or REMOVE
|
|
122
|
+
* (built-in id + `component: null`) a section field. Built-in ids autocomplete
|
|
123
|
+
* from the model's generated `displayFieldIds`; any other string adds a new row.
|
|
124
|
+
*/
|
|
125
|
+
type CustomDisplayField<TModel = unknown> = {
|
|
126
|
+
id: ModelShape<TModel>["displayFieldIds"] | (string & {});
|
|
127
|
+
component: ComponentType<{
|
|
128
|
+
data?: unknown;
|
|
129
|
+
}> | null;
|
|
130
|
+
};
|
|
131
|
+
/** Same `{ rank?, component }` shape as list bulk actions. */
|
|
132
|
+
type SectionAction = {
|
|
133
|
+
rank?: number;
|
|
134
|
+
component: ComponentType<{
|
|
135
|
+
data?: unknown;
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
type CustomDisplayEntry<TModel> = {
|
|
139
|
+
zone: ModelShape<TModel>["displayZones"];
|
|
140
|
+
fields?: CustomDisplayField<TModel>[];
|
|
141
|
+
actions?: SectionAction[];
|
|
142
|
+
};
|
|
143
|
+
type CustomColumn = {
|
|
144
|
+
id: string;
|
|
145
|
+
header?: string;
|
|
146
|
+
component?: ComponentType<{
|
|
147
|
+
row?: unknown;
|
|
148
|
+
value?: unknown;
|
|
149
|
+
}>;
|
|
150
|
+
};
|
|
151
|
+
type CustomListExtension = {
|
|
152
|
+
columns?: CustomColumn[];
|
|
153
|
+
bulkActions?: SectionAction[];
|
|
154
|
+
filters?: unknown[];
|
|
155
|
+
viewDefaults?: {
|
|
156
|
+
columnVisibility?: Record<string, boolean>;
|
|
157
|
+
columnOrder?: string[];
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel> {
|
|
161
|
+
model: TModel;
|
|
162
|
+
/** Module link(s) fetched alongside the entity (e.g. `brand`). */
|
|
163
|
+
link?: string | string[];
|
|
164
|
+
list?: CustomListExtension;
|
|
165
|
+
forms?: CustomFormEntry<TModel>[];
|
|
166
|
+
displays?: CustomDisplayEntry<TModel>[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
170
|
+
declare function defineNavigationConfig(config: NavigationConfig): NavigationConfig;
|
|
171
|
+
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
93
172
|
|
|
94
|
-
export { type
|
|
173
|
+
export { type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type FieldValidation, type NavItemId, type NavItemOverride, type NavItemRegistry, type NavParentId, type NavParentRegistry, type NavigationConfig, type SectionAction, type WidgetConfig, type WidgetZoneId, type WidgetZoneRegistry, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export { B as BuiltMercurConfig, M as MercurConfig, R as RouteConfig } from './types-zgnwn8ra.js';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Open registry interfaces. Each panel package ships a generated
|
|
6
|
+
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
7
|
+
* (declaration merging), and a developer augments them by hand to register a
|
|
8
|
+
* zone their own page renders. The helper unions read off the interface keys.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
12
|
+
* interface WidgetZoneRegistry {
|
|
13
|
+
* "erp.dashboard.before": true
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
interface WidgetZoneRegistry {
|
|
18
|
+
}
|
|
19
|
+
interface NavItemRegistry {
|
|
20
|
+
}
|
|
21
|
+
interface NavParentRegistry {
|
|
22
|
+
}
|
|
23
|
+
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
24
|
+
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
25
|
+
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* A widget is a React component attached to a named zone on a page. The
|
|
28
|
+
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
29
|
+
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
30
|
+
* order.
|
|
31
|
+
*/
|
|
32
|
+
interface WidgetConfig {
|
|
33
|
+
zone: WidgetZoneId | WidgetZoneId[];
|
|
34
|
+
/** Stable id; derived from the file path at build time when omitted. */
|
|
35
|
+
id?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Override for a single built-in navigation item. */
|
|
38
|
+
interface NavItemOverride {
|
|
39
|
+
id: NavItemId;
|
|
40
|
+
/** Order within the item's parent (or among top-level items). */
|
|
41
|
+
rank?: number;
|
|
42
|
+
/** Remove from the sidebar (route may still be reachable directly). */
|
|
43
|
+
hidden?: boolean;
|
|
44
|
+
/** i18n key or literal replacing the item's label. */
|
|
45
|
+
label?: string;
|
|
46
|
+
/** Icon component replacing the item's icon. */
|
|
47
|
+
icon?: ComponentType;
|
|
48
|
+
/**
|
|
49
|
+
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
50
|
+
* children; `null` promotes a nested item to the top level.
|
|
51
|
+
*/
|
|
52
|
+
nested?: NavParentId | null;
|
|
53
|
+
}
|
|
54
|
+
interface NavigationConfig {
|
|
55
|
+
items: NavItemOverride[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Minimal structural stand-in for a Zod schema, so the SDK stays free of a zod
|
|
60
|
+
* dependency. `createFormHelper` (in `@mercurjs/dashboard-shared`) produces real
|
|
61
|
+
* zod schemas that satisfy this shape.
|
|
62
|
+
*/
|
|
63
|
+
type FieldValidation = {
|
|
64
|
+
safeParse?: (value: unknown) => unknown;
|
|
65
|
+
parse?: (value: unknown) => unknown;
|
|
66
|
+
def?: {
|
|
67
|
+
type?: string;
|
|
68
|
+
};
|
|
69
|
+
_def?: unknown;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Per-model registry seeded by each panel's generated `extension-targets.d.ts`
|
|
73
|
+
* and extendable by hand. Shapes the typed form/display zones per model.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
77
|
+
* interface CustomFieldsRegistry {
|
|
78
|
+
* product: {
|
|
79
|
+
* formZones: "create" | "edit" | "organize" | "attributes"
|
|
80
|
+
* formTabs: { create: "general" | "organize"; edit: never }
|
|
81
|
+
* displayZones: "general" | "organize"
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
interface CustomFieldsRegistry {
|
|
87
|
+
}
|
|
88
|
+
type DefaultModelShape = {
|
|
89
|
+
formZones: string;
|
|
90
|
+
formTabs: Record<string, string>;
|
|
91
|
+
displayZones: string;
|
|
92
|
+
displayFieldIds: string;
|
|
93
|
+
};
|
|
94
|
+
type CustomFieldModel = keyof CustomFieldsRegistry extends never ? string : keyof CustomFieldsRegistry;
|
|
95
|
+
type ModelShape<TModel> = TModel extends keyof CustomFieldsRegistry ? CustomFieldsRegistry[TModel] & DefaultModelShape : DefaultModelShape;
|
|
96
|
+
type CustomFormField<TData = unknown> = {
|
|
97
|
+
/** Zod schema — drives the input type and validation. */
|
|
98
|
+
validation: FieldValidation;
|
|
99
|
+
/** Static default or a resolver from the loaded entity. */
|
|
100
|
+
defaultValue?: ((data: TData) => unknown) | unknown;
|
|
101
|
+
label?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
placeholder?: string;
|
|
104
|
+
/** Custom render component; falls back to a default input for the type. */
|
|
105
|
+
component?: ComponentType;
|
|
106
|
+
};
|
|
107
|
+
type CustomFormZone<TModel> = ModelShape<TModel>["formZones"];
|
|
108
|
+
/**
|
|
109
|
+
* Valid tab ids for a model's form zone. Narrows to the scanned union when the
|
|
110
|
+
* zone has tabbed forms; falls back to `string` for zones without tabs (e.g.
|
|
111
|
+
* onboarding steps) and for unknown models.
|
|
112
|
+
*/
|
|
113
|
+
type CustomFormTab<TModel, TZone> = TZone extends keyof ModelShape<TModel>["formTabs"] ? ModelShape<TModel>["formTabs"][TZone] : string;
|
|
114
|
+
type CustomFormEntry<TModel> = CustomFormZone<TModel> extends infer TZone ? TZone extends CustomFormZone<TModel> ? {
|
|
115
|
+
zone: TZone;
|
|
116
|
+
/** TabbedForm tab id, or onboarding wizard step id for `zone: "onboarding"`. */
|
|
117
|
+
tab?: CustomFormTab<TModel, TZone>;
|
|
118
|
+
fields: Record<string, CustomFormField>;
|
|
119
|
+
} : never : never;
|
|
120
|
+
/**
|
|
121
|
+
* ADD (unknown id + component), REPLACE (built-in id + component), or REMOVE
|
|
122
|
+
* (built-in id + `component: null`) a section field. Built-in ids autocomplete
|
|
123
|
+
* from the model's generated `displayFieldIds`; any other string adds a new row.
|
|
124
|
+
*/
|
|
125
|
+
type CustomDisplayField<TModel = unknown> = {
|
|
126
|
+
id: ModelShape<TModel>["displayFieldIds"] | (string & {});
|
|
127
|
+
component: ComponentType<{
|
|
128
|
+
data?: unknown;
|
|
129
|
+
}> | null;
|
|
130
|
+
};
|
|
131
|
+
/** Same `{ rank?, component }` shape as list bulk actions. */
|
|
132
|
+
type SectionAction = {
|
|
133
|
+
rank?: number;
|
|
134
|
+
component: ComponentType<{
|
|
135
|
+
data?: unknown;
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
type CustomDisplayEntry<TModel> = {
|
|
139
|
+
zone: ModelShape<TModel>["displayZones"];
|
|
140
|
+
fields?: CustomDisplayField<TModel>[];
|
|
141
|
+
actions?: SectionAction[];
|
|
142
|
+
};
|
|
143
|
+
type CustomColumn = {
|
|
144
|
+
id: string;
|
|
145
|
+
header?: string;
|
|
146
|
+
component?: ComponentType<{
|
|
147
|
+
row?: unknown;
|
|
148
|
+
value?: unknown;
|
|
149
|
+
}>;
|
|
150
|
+
};
|
|
151
|
+
type CustomListExtension = {
|
|
152
|
+
columns?: CustomColumn[];
|
|
153
|
+
bulkActions?: SectionAction[];
|
|
154
|
+
filters?: unknown[];
|
|
155
|
+
viewDefaults?: {
|
|
156
|
+
columnVisibility?: Record<string, boolean>;
|
|
157
|
+
columnOrder?: string[];
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel> {
|
|
161
|
+
model: TModel;
|
|
162
|
+
/** Module link(s) fetched alongside the entity (e.g. `brand`). */
|
|
163
|
+
link?: string | string[];
|
|
164
|
+
list?: CustomListExtension;
|
|
165
|
+
forms?: CustomFormEntry<TModel>[];
|
|
166
|
+
displays?: CustomDisplayEntry<TModel>[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
170
|
+
declare function defineNavigationConfig(config: NavigationConfig): NavigationConfig;
|
|
171
|
+
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
172
|
+
|
|
173
|
+
export { type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type FieldValidation, type NavItemId, type NavItemOverride, type NavItemRegistry, type NavParentId, type NavParentRegistry, type NavigationConfig, type SectionAction, type WidgetConfig, type WidgetZoneId, type WidgetZoneRegistry, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./chunk-3RG5ZIWI.js";
|
|
2
|
+
|
|
3
|
+
// src/config/utils.ts
|
|
4
|
+
function createConfigHelper(config) {
|
|
5
|
+
return {
|
|
6
|
+
...config,
|
|
7
|
+
$$typeof: /* @__PURE__ */ Symbol.for("react.memo")
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function defineWidgetConfig(config) {
|
|
11
|
+
return createConfigHelper(config);
|
|
12
|
+
}
|
|
13
|
+
function defineNavigationConfig(config) {
|
|
14
|
+
return createConfigHelper(config);
|
|
15
|
+
}
|
|
16
|
+
function defineCustomFieldsConfig(config) {
|
|
17
|
+
return createConfigHelper(config);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
defineCustomFieldsConfig,
|
|
21
|
+
defineNavigationConfig,
|
|
22
|
+
defineWidgetConfig
|
|
23
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the Mercur dashboard plugin.
|
|
5
|
+
*
|
|
6
|
+
* Passed to `mercurDashboardPlugin()` in `vite.config.ts` to configure
|
|
7
|
+
* the vendor or admin dashboard at build time.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* mercurDashboardPlugin({
|
|
12
|
+
* medusaConfigPath: '../../packages/api/medusa-config.ts',
|
|
13
|
+
* enableSellerRegistration: true,
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
interface MercurConfig {
|
|
18
|
+
/** Path to the MedusaJS config file, resolved relative to the project root. */
|
|
19
|
+
medusaConfigPath: string;
|
|
20
|
+
/**
|
|
21
|
+
* Backend URL for API requests.
|
|
22
|
+
* @default "http://localhost:9000"
|
|
23
|
+
*/
|
|
24
|
+
backendUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Absolute base URL for the vendor dashboard, including any path prefix
|
|
27
|
+
* (for example `https://vendors.example.com/seller`).
|
|
28
|
+
*
|
|
29
|
+
* The plugin does not read `.env` files on its own. Load env in your
|
|
30
|
+
* app's `vite.config.ts` and pass the value here when you need
|
|
31
|
+
* cross-origin links such as seller invite URLs.
|
|
32
|
+
*
|
|
33
|
+
* If omitted, the plugin falls back to vendor module dev server
|
|
34
|
+
* detection in development and to the configured vendor path in
|
|
35
|
+
* production.
|
|
36
|
+
*/
|
|
37
|
+
vendorUrl?: string;
|
|
38
|
+
/** Dashboard display name. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Path to a logo asset for the dashboard. */
|
|
41
|
+
logo?: string;
|
|
42
|
+
/** Internationalization settings. */
|
|
43
|
+
i18n?: {
|
|
44
|
+
/** The default language code (e.g. `"en"`). */
|
|
45
|
+
defaultLanguage: string;
|
|
46
|
+
};
|
|
47
|
+
/** Whether to allow new sellers to register from the login screen. */
|
|
48
|
+
enableSellerRegistration?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum allowed size for image uploads, in bytes.
|
|
51
|
+
* Used by dashboard upload components to reject oversized files
|
|
52
|
+
* before they are sent to the backend.
|
|
53
|
+
* @default 2_097_152 // 2 MB
|
|
54
|
+
*/
|
|
55
|
+
imageLimit?: number;
|
|
56
|
+
}
|
|
57
|
+
interface BuiltMercurConfig extends MercurConfig {
|
|
58
|
+
backendUrl: string;
|
|
59
|
+
base?: string;
|
|
60
|
+
root: string;
|
|
61
|
+
srcDir: string;
|
|
62
|
+
pluginExtensions: string[];
|
|
63
|
+
imageLimit: number;
|
|
64
|
+
}
|
|
65
|
+
type RouteConfig = {
|
|
66
|
+
label: string;
|
|
67
|
+
icon?: ComponentType;
|
|
68
|
+
rank?: number;
|
|
69
|
+
nested?: string;
|
|
70
|
+
translationNs?: string;
|
|
71
|
+
public?: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type { BuiltMercurConfig as B, MercurConfig as M, RouteConfig as R };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the Mercur dashboard plugin.
|
|
5
|
+
*
|
|
6
|
+
* Passed to `mercurDashboardPlugin()` in `vite.config.ts` to configure
|
|
7
|
+
* the vendor or admin dashboard at build time.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* mercurDashboardPlugin({
|
|
12
|
+
* medusaConfigPath: '../../packages/api/medusa-config.ts',
|
|
13
|
+
* enableSellerRegistration: true,
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
interface MercurConfig {
|
|
18
|
+
/** Path to the MedusaJS config file, resolved relative to the project root. */
|
|
19
|
+
medusaConfigPath: string;
|
|
20
|
+
/**
|
|
21
|
+
* Backend URL for API requests.
|
|
22
|
+
* @default "http://localhost:9000"
|
|
23
|
+
*/
|
|
24
|
+
backendUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Absolute base URL for the vendor dashboard, including any path prefix
|
|
27
|
+
* (for example `https://vendors.example.com/seller`).
|
|
28
|
+
*
|
|
29
|
+
* The plugin does not read `.env` files on its own. Load env in your
|
|
30
|
+
* app's `vite.config.ts` and pass the value here when you need
|
|
31
|
+
* cross-origin links such as seller invite URLs.
|
|
32
|
+
*
|
|
33
|
+
* If omitted, the plugin falls back to vendor module dev server
|
|
34
|
+
* detection in development and to the configured vendor path in
|
|
35
|
+
* production.
|
|
36
|
+
*/
|
|
37
|
+
vendorUrl?: string;
|
|
38
|
+
/** Dashboard display name. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Path to a logo asset for the dashboard. */
|
|
41
|
+
logo?: string;
|
|
42
|
+
/** Internationalization settings. */
|
|
43
|
+
i18n?: {
|
|
44
|
+
/** The default language code (e.g. `"en"`). */
|
|
45
|
+
defaultLanguage: string;
|
|
46
|
+
};
|
|
47
|
+
/** Whether to allow new sellers to register from the login screen. */
|
|
48
|
+
enableSellerRegistration?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum allowed size for image uploads, in bytes.
|
|
51
|
+
* Used by dashboard upload components to reject oversized files
|
|
52
|
+
* before they are sent to the backend.
|
|
53
|
+
* @default 2_097_152 // 2 MB
|
|
54
|
+
*/
|
|
55
|
+
imageLimit?: number;
|
|
56
|
+
}
|
|
57
|
+
interface BuiltMercurConfig extends MercurConfig {
|
|
58
|
+
backendUrl: string;
|
|
59
|
+
base?: string;
|
|
60
|
+
root: string;
|
|
61
|
+
srcDir: string;
|
|
62
|
+
pluginExtensions: string[];
|
|
63
|
+
imageLimit: number;
|
|
64
|
+
}
|
|
65
|
+
type RouteConfig = {
|
|
66
|
+
label: string;
|
|
67
|
+
icon?: ComponentType;
|
|
68
|
+
rank?: number;
|
|
69
|
+
nested?: string;
|
|
70
|
+
translationNs?: string;
|
|
71
|
+
public?: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type { BuiltMercurConfig as B, MercurConfig as M, RouteConfig as R };
|