@mercurjs/dashboard-sdk 2.3.2-canary.0 → 2.3.2-canary.2
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/index.cjs +31 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -1
- package/dist/types-CTuDKgPc.d.cts +142 -0
- package/dist/types-CTuDKgPc.d.ts +142 -0
- package/dist/vite.cjs +24 -3
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +24 -3
- package/package.json +1 -1
- package/dist/types-zgnwn8ra.d.cts +0 -74
- package/dist/types-zgnwn8ra.d.ts +0 -74
package/dist/index.cjs
CHANGED
|
@@ -20,9 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
OPERATION_IMPLICATIONS: () => OPERATION_IMPLICATIONS,
|
|
24
|
+
buildPermission: () => buildPermission,
|
|
23
25
|
defineCustomFieldsConfig: () => defineCustomFieldsConfig,
|
|
24
26
|
defineNavigationConfig: () => defineNavigationConfig,
|
|
25
|
-
defineWidgetConfig: () => defineWidgetConfig
|
|
27
|
+
defineWidgetConfig: () => defineWidgetConfig,
|
|
28
|
+
parsePermission: () => parsePermission
|
|
26
29
|
});
|
|
27
30
|
module.exports = __toCommonJS(index_exports);
|
|
28
31
|
|
|
@@ -42,9 +45,35 @@ function defineNavigationConfig(config) {
|
|
|
42
45
|
function defineCustomFieldsConfig(config) {
|
|
43
46
|
return createConfigHelper(config);
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
// src/permissions.ts
|
|
50
|
+
var OPERATION_IMPLICATIONS = {
|
|
51
|
+
read: ["read"],
|
|
52
|
+
create: ["create"],
|
|
53
|
+
update: ["update"],
|
|
54
|
+
delete: ["delete"],
|
|
55
|
+
"*": ["read", "create", "update", "delete", "*"]
|
|
56
|
+
};
|
|
57
|
+
function parsePermission(permission) {
|
|
58
|
+
const parts = permission.split(":");
|
|
59
|
+
if (parts.length !== 2) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const [resource, operation] = parts;
|
|
63
|
+
return {
|
|
64
|
+
resource,
|
|
65
|
+
operation
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function buildPermission(resource, operation) {
|
|
69
|
+
return `${resource}:${operation}`;
|
|
70
|
+
}
|
|
45
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
72
|
0 && (module.exports = {
|
|
73
|
+
OPERATION_IMPLICATIONS,
|
|
74
|
+
buildPermission,
|
|
47
75
|
defineCustomFieldsConfig,
|
|
48
76
|
defineNavigationConfig,
|
|
49
|
-
defineWidgetConfig
|
|
77
|
+
defineWidgetConfig,
|
|
78
|
+
parsePermission
|
|
50
79
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BuiltMercurConfig, M as MercurConfig, R as RouteConfig } from './types-
|
|
1
|
+
export { B as BuiltMercurConfig, M as MercurConfig, O as OPERATION_IMPLICATIONS, P as Permission, a as PermissionOperation, b as PermissionRequirement, c as PermissionResource, d as PermissionsContextValue, e as PermissionsRequirementsContextValue, R as RouteConfig, f as RouteHandle, U as UserPolicy, g as buildPermission, p as parsePermission } from './types-CTuDKgPc.cjs';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BuiltMercurConfig, M as MercurConfig, R as RouteConfig } from './types-
|
|
1
|
+
export { B as BuiltMercurConfig, M as MercurConfig, O as OPERATION_IMPLICATIONS, P as Permission, a as PermissionOperation, b as PermissionRequirement, c as PermissionResource, d as PermissionsContextValue, e as PermissionsRequirementsContextValue, R as RouteConfig, f as RouteHandle, U as UserPolicy, g as buildPermission, p as parsePermission } from './types-CTuDKgPc.js';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,34 @@ function defineNavigationConfig(config) {
|
|
|
16
16
|
function defineCustomFieldsConfig(config) {
|
|
17
17
|
return createConfigHelper(config);
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
// src/permissions.ts
|
|
21
|
+
var OPERATION_IMPLICATIONS = {
|
|
22
|
+
read: ["read"],
|
|
23
|
+
create: ["create"],
|
|
24
|
+
update: ["update"],
|
|
25
|
+
delete: ["delete"],
|
|
26
|
+
"*": ["read", "create", "update", "delete", "*"]
|
|
27
|
+
};
|
|
28
|
+
function parsePermission(permission) {
|
|
29
|
+
const parts = permission.split(":");
|
|
30
|
+
if (parts.length !== 2) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const [resource, operation] = parts;
|
|
34
|
+
return {
|
|
35
|
+
resource,
|
|
36
|
+
operation
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function buildPermission(resource, operation) {
|
|
40
|
+
return `${resource}:${operation}`;
|
|
41
|
+
}
|
|
19
42
|
export {
|
|
43
|
+
OPERATION_IMPLICATIONS,
|
|
44
|
+
buildPermission,
|
|
20
45
|
defineCustomFieldsConfig,
|
|
21
46
|
defineNavigationConfig,
|
|
22
|
-
defineWidgetConfig
|
|
47
|
+
defineWidgetConfig,
|
|
48
|
+
parsePermission
|
|
23
49
|
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Permission strings follow the pattern `{resource}:{operation}`, e.g.
|
|
5
|
+
* `customer:read`, `product:create`, `order:*`.
|
|
6
|
+
*
|
|
7
|
+
* The resource list mirrors the policies registered server-side — Medusa's own
|
|
8
|
+
* catalog plus Mercur's (`packages/core/src/policies`). A name that is not
|
|
9
|
+
* registered there is not a type error, it simply never matches a granted
|
|
10
|
+
* policy, so the two are kept in sync by a test in `packages/admin`.
|
|
11
|
+
*/
|
|
12
|
+
type PermissionResource = "api_key" | "campaign" | "commission_line" | "commission_rate" | "commission_rule" | "currency" | "customer" | "customer_address" | "customer_group" | "file" | "fulfillment" | "fulfillment_provider" | "fulfillment_set" | "inventory_item" | "inventory_level" | "invite" | "member_invite" | "notification" | "offer" | "order" | "order_change" | "order_claim" | "order_claim_item" | "order_exchange" | "order_group" | "order_item" | "payment" | "payment_collection" | "payment_method" | "payment_session" | "payout" | "payout_account" | "price" | "price_list" | "price_preference" | "product" | "product_attribute" | "product_attribute_value" | "product_category" | "product_change" | "product_collection" | "product_option" | "product_option_value" | "product_tag" | "product_type" | "product_variant" | "promotion" | "rbac_policy" | "rbac_role" | "refund_reason" | "region" | "reservation_item" | "return" | "return_reason" | "review" | "sales_channel" | "seller" | "seller_member" | "service_zone" | "shipping_option" | "shipping_option_type" | "shipping_profile" | "stock_location" | "store" | "store_locale" | "tax_provider" | "tax_rate" | "tax_region" | "translation" | "translation_setting" | "user" | "workflow_execution";
|
|
13
|
+
type PermissionOperation = "read" | "create" | "update" | "delete" | "*";
|
|
14
|
+
type Permission = `${PermissionResource}:${PermissionOperation}`;
|
|
15
|
+
interface UserPolicy {
|
|
16
|
+
permissions: Permission[];
|
|
17
|
+
}
|
|
18
|
+
interface PermissionRequirement {
|
|
19
|
+
permissions: Permission[];
|
|
20
|
+
/** If true, ALL permissions are required. Defaults to ANY. */
|
|
21
|
+
requireAll?: boolean;
|
|
22
|
+
/** Optional label describing where the requirement came from. */
|
|
23
|
+
source?: string;
|
|
24
|
+
}
|
|
25
|
+
interface PermissionsContextValue {
|
|
26
|
+
policy: UserPolicy | null;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
/** Whether RBAC is active. When `false`, every check resolves to `true`. */
|
|
29
|
+
isRbacEnabled: boolean;
|
|
30
|
+
hasPermission: (permission: Permission) => boolean;
|
|
31
|
+
hasAnyPermission: (permissions: Permission[]) => boolean;
|
|
32
|
+
hasAllPermissions: (permissions: Permission[]) => boolean;
|
|
33
|
+
can: (resource: PermissionResource, operation: PermissionOperation) => boolean;
|
|
34
|
+
}
|
|
35
|
+
interface PermissionsRequirementsContextValue {
|
|
36
|
+
requiredPermissions: PermissionRequirement[];
|
|
37
|
+
registerRequiredPermissions: (id: string, requirement: PermissionRequirement) => void;
|
|
38
|
+
unregisterRequiredPermissions: (id: string) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Operations implied by a granted operation. Only the wildcard fans out.
|
|
42
|
+
* Note that `update` does not imply `read` — grants must be explicit.
|
|
43
|
+
*/
|
|
44
|
+
declare const OPERATION_IMPLICATIONS: Record<PermissionOperation, PermissionOperation[]>;
|
|
45
|
+
declare function parsePermission(permission: string): {
|
|
46
|
+
resource: PermissionResource;
|
|
47
|
+
operation: PermissionOperation;
|
|
48
|
+
} | null;
|
|
49
|
+
declare function buildPermission(resource: PermissionResource, operation: PermissionOperation): Permission;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for the Mercur dashboard plugin.
|
|
53
|
+
*
|
|
54
|
+
* Passed to `mercurDashboardPlugin()` in `vite.config.ts` to configure
|
|
55
|
+
* the vendor or admin dashboard at build time.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* mercurDashboardPlugin({
|
|
60
|
+
* medusaConfigPath: '../../packages/api/medusa-config.ts',
|
|
61
|
+
* enableSellerRegistration: true,
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
interface MercurConfig {
|
|
66
|
+
/** Path to the MedusaJS config file, resolved relative to the project root. */
|
|
67
|
+
medusaConfigPath: string;
|
|
68
|
+
/**
|
|
69
|
+
* Backend URL for API requests.
|
|
70
|
+
* @default "http://localhost:9000"
|
|
71
|
+
*/
|
|
72
|
+
backendUrl?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Absolute base URL for the vendor dashboard, including any path prefix
|
|
75
|
+
* (for example `https://vendors.example.com/seller`).
|
|
76
|
+
*
|
|
77
|
+
* The plugin does not read `.env` files on its own. Load env in your
|
|
78
|
+
* app's `vite.config.ts` and pass the value here when you need
|
|
79
|
+
* cross-origin links such as seller invite URLs.
|
|
80
|
+
*
|
|
81
|
+
* If omitted, the plugin falls back to vendor module dev server
|
|
82
|
+
* detection in development and to the configured vendor path in
|
|
83
|
+
* production.
|
|
84
|
+
*/
|
|
85
|
+
vendorUrl?: string;
|
|
86
|
+
/** Dashboard display name. */
|
|
87
|
+
name?: string;
|
|
88
|
+
/** Path to a logo asset for the dashboard. */
|
|
89
|
+
logo?: string;
|
|
90
|
+
/** Internationalization settings. */
|
|
91
|
+
i18n?: {
|
|
92
|
+
/** The default language code (e.g. `"en"`). */
|
|
93
|
+
defaultLanguage: string;
|
|
94
|
+
};
|
|
95
|
+
/** Whether to allow new sellers to register from the login screen. */
|
|
96
|
+
enableSellerRegistration?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum allowed size for image uploads, in bytes.
|
|
99
|
+
* Used by dashboard upload components to reject oversized files
|
|
100
|
+
* before they are sent to the backend.
|
|
101
|
+
* @default 2_097_152 // 2 MB
|
|
102
|
+
*/
|
|
103
|
+
imageLimit?: number;
|
|
104
|
+
}
|
|
105
|
+
interface BuiltMercurConfig extends MercurConfig {
|
|
106
|
+
backendUrl: string;
|
|
107
|
+
base?: string;
|
|
108
|
+
root: string;
|
|
109
|
+
srcDir: string;
|
|
110
|
+
pluginExtensions: string[];
|
|
111
|
+
imageLimit: number;
|
|
112
|
+
}
|
|
113
|
+
type RouteConfig = {
|
|
114
|
+
label: string;
|
|
115
|
+
icon?: ComponentType;
|
|
116
|
+
rank?: number;
|
|
117
|
+
nested?: string;
|
|
118
|
+
translationNs?: string;
|
|
119
|
+
public?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Permissions the actor must hold for this route's sidebar entry to be
|
|
122
|
+
* shown. Enforcement of the route itself comes from `handle.permissions`
|
|
123
|
+
* — this only controls navigation visibility.
|
|
124
|
+
*/
|
|
125
|
+
permissions?: Permission[];
|
|
126
|
+
/** If true, ALL `permissions` are required. Defaults to ANY. */
|
|
127
|
+
requireAll?: boolean;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The value of a route module's `export const handle`. Read by react-router's
|
|
131
|
+
* `useMatches()`; `permissions` is enforced by `RoutePermissionGuard`.
|
|
132
|
+
*/
|
|
133
|
+
type RouteHandle = {
|
|
134
|
+
permissions?: Permission | Permission[];
|
|
135
|
+
/** If true (default at the route level), ALL permissions are required. */
|
|
136
|
+
requireAll?: boolean;
|
|
137
|
+
/** Where to send the actor on denial. Renders Access Denied when unset. */
|
|
138
|
+
redirectTo?: string;
|
|
139
|
+
breadcrumb?: (match: never) => ReactNode;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { type BuiltMercurConfig as B, type MercurConfig as M, OPERATION_IMPLICATIONS as O, type Permission as P, type RouteConfig as R, type UserPolicy as U, type PermissionOperation as a, type PermissionRequirement as b, type PermissionResource as c, type PermissionsContextValue as d, type PermissionsRequirementsContextValue as e, type RouteHandle as f, buildPermission as g, parsePermission as p };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Permission strings follow the pattern `{resource}:{operation}`, e.g.
|
|
5
|
+
* `customer:read`, `product:create`, `order:*`.
|
|
6
|
+
*
|
|
7
|
+
* The resource list mirrors the policies registered server-side — Medusa's own
|
|
8
|
+
* catalog plus Mercur's (`packages/core/src/policies`). A name that is not
|
|
9
|
+
* registered there is not a type error, it simply never matches a granted
|
|
10
|
+
* policy, so the two are kept in sync by a test in `packages/admin`.
|
|
11
|
+
*/
|
|
12
|
+
type PermissionResource = "api_key" | "campaign" | "commission_line" | "commission_rate" | "commission_rule" | "currency" | "customer" | "customer_address" | "customer_group" | "file" | "fulfillment" | "fulfillment_provider" | "fulfillment_set" | "inventory_item" | "inventory_level" | "invite" | "member_invite" | "notification" | "offer" | "order" | "order_change" | "order_claim" | "order_claim_item" | "order_exchange" | "order_group" | "order_item" | "payment" | "payment_collection" | "payment_method" | "payment_session" | "payout" | "payout_account" | "price" | "price_list" | "price_preference" | "product" | "product_attribute" | "product_attribute_value" | "product_category" | "product_change" | "product_collection" | "product_option" | "product_option_value" | "product_tag" | "product_type" | "product_variant" | "promotion" | "rbac_policy" | "rbac_role" | "refund_reason" | "region" | "reservation_item" | "return" | "return_reason" | "review" | "sales_channel" | "seller" | "seller_member" | "service_zone" | "shipping_option" | "shipping_option_type" | "shipping_profile" | "stock_location" | "store" | "store_locale" | "tax_provider" | "tax_rate" | "tax_region" | "translation" | "translation_setting" | "user" | "workflow_execution";
|
|
13
|
+
type PermissionOperation = "read" | "create" | "update" | "delete" | "*";
|
|
14
|
+
type Permission = `${PermissionResource}:${PermissionOperation}`;
|
|
15
|
+
interface UserPolicy {
|
|
16
|
+
permissions: Permission[];
|
|
17
|
+
}
|
|
18
|
+
interface PermissionRequirement {
|
|
19
|
+
permissions: Permission[];
|
|
20
|
+
/** If true, ALL permissions are required. Defaults to ANY. */
|
|
21
|
+
requireAll?: boolean;
|
|
22
|
+
/** Optional label describing where the requirement came from. */
|
|
23
|
+
source?: string;
|
|
24
|
+
}
|
|
25
|
+
interface PermissionsContextValue {
|
|
26
|
+
policy: UserPolicy | null;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
/** Whether RBAC is active. When `false`, every check resolves to `true`. */
|
|
29
|
+
isRbacEnabled: boolean;
|
|
30
|
+
hasPermission: (permission: Permission) => boolean;
|
|
31
|
+
hasAnyPermission: (permissions: Permission[]) => boolean;
|
|
32
|
+
hasAllPermissions: (permissions: Permission[]) => boolean;
|
|
33
|
+
can: (resource: PermissionResource, operation: PermissionOperation) => boolean;
|
|
34
|
+
}
|
|
35
|
+
interface PermissionsRequirementsContextValue {
|
|
36
|
+
requiredPermissions: PermissionRequirement[];
|
|
37
|
+
registerRequiredPermissions: (id: string, requirement: PermissionRequirement) => void;
|
|
38
|
+
unregisterRequiredPermissions: (id: string) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Operations implied by a granted operation. Only the wildcard fans out.
|
|
42
|
+
* Note that `update` does not imply `read` — grants must be explicit.
|
|
43
|
+
*/
|
|
44
|
+
declare const OPERATION_IMPLICATIONS: Record<PermissionOperation, PermissionOperation[]>;
|
|
45
|
+
declare function parsePermission(permission: string): {
|
|
46
|
+
resource: PermissionResource;
|
|
47
|
+
operation: PermissionOperation;
|
|
48
|
+
} | null;
|
|
49
|
+
declare function buildPermission(resource: PermissionResource, operation: PermissionOperation): Permission;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for the Mercur dashboard plugin.
|
|
53
|
+
*
|
|
54
|
+
* Passed to `mercurDashboardPlugin()` in `vite.config.ts` to configure
|
|
55
|
+
* the vendor or admin dashboard at build time.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* mercurDashboardPlugin({
|
|
60
|
+
* medusaConfigPath: '../../packages/api/medusa-config.ts',
|
|
61
|
+
* enableSellerRegistration: true,
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
interface MercurConfig {
|
|
66
|
+
/** Path to the MedusaJS config file, resolved relative to the project root. */
|
|
67
|
+
medusaConfigPath: string;
|
|
68
|
+
/**
|
|
69
|
+
* Backend URL for API requests.
|
|
70
|
+
* @default "http://localhost:9000"
|
|
71
|
+
*/
|
|
72
|
+
backendUrl?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Absolute base URL for the vendor dashboard, including any path prefix
|
|
75
|
+
* (for example `https://vendors.example.com/seller`).
|
|
76
|
+
*
|
|
77
|
+
* The plugin does not read `.env` files on its own. Load env in your
|
|
78
|
+
* app's `vite.config.ts` and pass the value here when you need
|
|
79
|
+
* cross-origin links such as seller invite URLs.
|
|
80
|
+
*
|
|
81
|
+
* If omitted, the plugin falls back to vendor module dev server
|
|
82
|
+
* detection in development and to the configured vendor path in
|
|
83
|
+
* production.
|
|
84
|
+
*/
|
|
85
|
+
vendorUrl?: string;
|
|
86
|
+
/** Dashboard display name. */
|
|
87
|
+
name?: string;
|
|
88
|
+
/** Path to a logo asset for the dashboard. */
|
|
89
|
+
logo?: string;
|
|
90
|
+
/** Internationalization settings. */
|
|
91
|
+
i18n?: {
|
|
92
|
+
/** The default language code (e.g. `"en"`). */
|
|
93
|
+
defaultLanguage: string;
|
|
94
|
+
};
|
|
95
|
+
/** Whether to allow new sellers to register from the login screen. */
|
|
96
|
+
enableSellerRegistration?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Maximum allowed size for image uploads, in bytes.
|
|
99
|
+
* Used by dashboard upload components to reject oversized files
|
|
100
|
+
* before they are sent to the backend.
|
|
101
|
+
* @default 2_097_152 // 2 MB
|
|
102
|
+
*/
|
|
103
|
+
imageLimit?: number;
|
|
104
|
+
}
|
|
105
|
+
interface BuiltMercurConfig extends MercurConfig {
|
|
106
|
+
backendUrl: string;
|
|
107
|
+
base?: string;
|
|
108
|
+
root: string;
|
|
109
|
+
srcDir: string;
|
|
110
|
+
pluginExtensions: string[];
|
|
111
|
+
imageLimit: number;
|
|
112
|
+
}
|
|
113
|
+
type RouteConfig = {
|
|
114
|
+
label: string;
|
|
115
|
+
icon?: ComponentType;
|
|
116
|
+
rank?: number;
|
|
117
|
+
nested?: string;
|
|
118
|
+
translationNs?: string;
|
|
119
|
+
public?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Permissions the actor must hold for this route's sidebar entry to be
|
|
122
|
+
* shown. Enforcement of the route itself comes from `handle.permissions`
|
|
123
|
+
* — this only controls navigation visibility.
|
|
124
|
+
*/
|
|
125
|
+
permissions?: Permission[];
|
|
126
|
+
/** If true, ALL `permissions` are required. Defaults to ANY. */
|
|
127
|
+
requireAll?: boolean;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The value of a route module's `export const handle`. Read by react-router's
|
|
131
|
+
* `useMatches()`; `permissions` is enforced by `RoutePermissionGuard`.
|
|
132
|
+
*/
|
|
133
|
+
type RouteHandle = {
|
|
134
|
+
permissions?: Permission | Permission[];
|
|
135
|
+
/** If true (default at the route level), ALL permissions are required. */
|
|
136
|
+
requireAll?: boolean;
|
|
137
|
+
/** Where to send the actor on denial. Renders Access Denied when unset. */
|
|
138
|
+
redirectTo?: string;
|
|
139
|
+
breadcrumb?: (match: never) => ReactNode;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { type BuiltMercurConfig as B, type MercurConfig as M, OPERATION_IMPLICATIONS as O, type Permission as P, type RouteConfig as R, type UserPolicy as U, type PermissionOperation as a, type PermissionRequirement as b, type PermissionResource as c, type PermissionsContextValue as d, type PermissionsRequirementsContextValue as e, type RouteHandle as f, buildPermission as g, parsePermission as p };
|
package/dist/vite.cjs
CHANGED
|
@@ -478,7 +478,24 @@ function processConfigProperties(properties) {
|
|
|
478
478
|
if (rank && (0, import_types.isObjectProperty)(rank) && (0, import_types.isNumericLiteral)(rank.value)) {
|
|
479
479
|
rankValue = rank.value.value;
|
|
480
480
|
}
|
|
481
|
-
|
|
481
|
+
const requireAll = properties.find(
|
|
482
|
+
(prop) => (0, import_types.isObjectProperty)(prop) && (0, import_types.isIdentifier)(prop.key, { name: "requireAll" })
|
|
483
|
+
);
|
|
484
|
+
let requireAllValue;
|
|
485
|
+
if (requireAll && (0, import_types.isObjectProperty)(requireAll) && (0, import_types.isBooleanLiteral)(requireAll.value)) {
|
|
486
|
+
requireAllValue = requireAll.value.value;
|
|
487
|
+
}
|
|
488
|
+
return {
|
|
489
|
+
label: hasLabel,
|
|
490
|
+
icon: hasIcon,
|
|
491
|
+
rank: rankValue,
|
|
492
|
+
nested: nestedValue,
|
|
493
|
+
translationNs: translationNsValue,
|
|
494
|
+
// Referenced by identifier at runtime rather than extracted here, so
|
|
495
|
+
// the array may be computed instead of a string-literal list.
|
|
496
|
+
permissions: hasProperty("permissions"),
|
|
497
|
+
requireAll: requireAllValue
|
|
498
|
+
};
|
|
482
499
|
}
|
|
483
500
|
function getRouteConfig(file) {
|
|
484
501
|
try {
|
|
@@ -522,7 +539,9 @@ function generateMenuItem(config, file, routesDir, index) {
|
|
|
522
539
|
path: getRoute2(file, routesDir),
|
|
523
540
|
rank: config.rank,
|
|
524
541
|
nested: config.nested,
|
|
525
|
-
translationNs: config.translationNs ? `${configName}.translationNs` : void 0
|
|
542
|
+
translationNs: config.translationNs ? `${configName}.translationNs` : void 0,
|
|
543
|
+
permissions: config.permissions ? `${configName}.permissions` : void 0,
|
|
544
|
+
requireAll: config.requireAll
|
|
526
545
|
};
|
|
527
546
|
}
|
|
528
547
|
function formatMenuItem(menuItem) {
|
|
@@ -532,7 +551,9 @@ function formatMenuItem(menuItem) {
|
|
|
532
551
|
` path: "${menuItem.path}"`,
|
|
533
552
|
` rank: ${menuItem.rank !== void 0 ? menuItem.rank : "undefined"}`,
|
|
534
553
|
` nested: ${menuItem.nested ? `"${menuItem.nested}"` : "undefined"}`,
|
|
535
|
-
` translationNs: ${menuItem.translationNs || "undefined"}
|
|
554
|
+
` translationNs: ${menuItem.translationNs || "undefined"}`,
|
|
555
|
+
` permissions: ${menuItem.permissions || "undefined"}`,
|
|
556
|
+
` requireAll: ${menuItem.requireAll !== void 0 ? menuItem.requireAll : "undefined"}`
|
|
536
557
|
];
|
|
537
558
|
return ` {
|
|
538
559
|
${parts.join(",\n")}
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -458,7 +458,24 @@ function processConfigProperties(properties) {
|
|
|
458
458
|
if (rank && isObjectProperty(rank) && isNumericLiteral(rank.value)) {
|
|
459
459
|
rankValue = rank.value.value;
|
|
460
460
|
}
|
|
461
|
-
|
|
461
|
+
const requireAll = properties.find(
|
|
462
|
+
(prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "requireAll" })
|
|
463
|
+
);
|
|
464
|
+
let requireAllValue;
|
|
465
|
+
if (requireAll && isObjectProperty(requireAll) && isBooleanLiteral(requireAll.value)) {
|
|
466
|
+
requireAllValue = requireAll.value.value;
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
label: hasLabel,
|
|
470
|
+
icon: hasIcon,
|
|
471
|
+
rank: rankValue,
|
|
472
|
+
nested: nestedValue,
|
|
473
|
+
translationNs: translationNsValue,
|
|
474
|
+
// Referenced by identifier at runtime rather than extracted here, so
|
|
475
|
+
// the array may be computed instead of a string-literal list.
|
|
476
|
+
permissions: hasProperty("permissions"),
|
|
477
|
+
requireAll: requireAllValue
|
|
478
|
+
};
|
|
462
479
|
}
|
|
463
480
|
function getRouteConfig(file) {
|
|
464
481
|
try {
|
|
@@ -502,7 +519,9 @@ function generateMenuItem(config, file, routesDir, index) {
|
|
|
502
519
|
path: getRoute2(file, routesDir),
|
|
503
520
|
rank: config.rank,
|
|
504
521
|
nested: config.nested,
|
|
505
|
-
translationNs: config.translationNs ? `${configName}.translationNs` : void 0
|
|
522
|
+
translationNs: config.translationNs ? `${configName}.translationNs` : void 0,
|
|
523
|
+
permissions: config.permissions ? `${configName}.permissions` : void 0,
|
|
524
|
+
requireAll: config.requireAll
|
|
506
525
|
};
|
|
507
526
|
}
|
|
508
527
|
function formatMenuItem(menuItem) {
|
|
@@ -512,7 +531,9 @@ function formatMenuItem(menuItem) {
|
|
|
512
531
|
` path: "${menuItem.path}"`,
|
|
513
532
|
` rank: ${menuItem.rank !== void 0 ? menuItem.rank : "undefined"}`,
|
|
514
533
|
` nested: ${menuItem.nested ? `"${menuItem.nested}"` : "undefined"}`,
|
|
515
|
-
` translationNs: ${menuItem.translationNs || "undefined"}
|
|
534
|
+
` translationNs: ${menuItem.translationNs || "undefined"}`,
|
|
535
|
+
` permissions: ${menuItem.permissions || "undefined"}`,
|
|
536
|
+
` requireAll: ${menuItem.requireAll !== void 0 ? menuItem.requireAll : "undefined"}`
|
|
516
537
|
];
|
|
517
538
|
return ` {
|
|
518
539
|
${parts.join(",\n")}
|
package/package.json
CHANGED
|
@@ -1,74 +0,0 @@
|
|
|
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 };
|
package/dist/types-zgnwn8ra.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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 };
|