com-angel-authorization 1.0.10 → 1.0.14
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/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +27 -9
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +19 -6
- package/dist/react/index.d.ts +19 -6
- package/dist/react/index.js +27 -9
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +27 -13
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +25 -12
- package/dist/vue/index.d.ts +25 -12
- package/dist/vue/index.js +27 -13
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -26,12 +26,25 @@ interface PermissionChecker {
|
|
|
26
26
|
can(codes: PermissionCode | PermissionCode[], options?: CheckOptions): boolean;
|
|
27
27
|
getState(): PermissionState;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 权限 store 的公共接口(不含 class private 字段)。
|
|
31
|
+
* 用于跨入口(主包 / react / vue)传参,避免重复打包后的名义类型冲突。
|
|
32
|
+
*/
|
|
33
|
+
interface PermissionStoreAPI extends PermissionChecker {
|
|
34
|
+
setState(next: Partial<PermissionState>): void;
|
|
35
|
+
setPermissions(permissions: PermissionCode[]): void;
|
|
36
|
+
setRoles(roles: RoleCode[]): void;
|
|
37
|
+
setSuperAdmin(isSuperAdmin: boolean): void;
|
|
38
|
+
hydrate(payload: Partial<PermissionState>): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
subscribe(listener: PermissionListener): () => void;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* Mutable permission store shared by React / Vue adapters.
|
|
32
45
|
* Framework-agnostic — safe to use in Node, browser, or any UI lib.
|
|
33
46
|
*/
|
|
34
|
-
declare class PermissionStore implements
|
|
47
|
+
declare class PermissionStore implements PermissionStoreAPI {
|
|
35
48
|
private state;
|
|
36
49
|
private permissionSet;
|
|
37
50
|
private roleSet;
|
|
@@ -53,16 +66,16 @@ declare class PermissionStore implements PermissionChecker {
|
|
|
53
66
|
subscribe(listener: PermissionListener): () => void;
|
|
54
67
|
private emit;
|
|
55
68
|
}
|
|
56
|
-
declare function createPermissionStore(initial?: Partial<PermissionState>):
|
|
69
|
+
declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
|
|
57
70
|
|
|
58
71
|
interface PermissionProviderProps {
|
|
59
72
|
children: ReactNode;
|
|
60
73
|
/** Pass an existing store to share across trees, or omit to create one. */
|
|
61
|
-
store?:
|
|
74
|
+
store?: PermissionStoreAPI;
|
|
62
75
|
/** Initial state when the provider creates its own store. */
|
|
63
76
|
initialState?: Partial<PermissionState>;
|
|
64
77
|
}
|
|
65
|
-
declare function PermissionProvider({ children, store: externalStore, initialState, }: PermissionProviderProps): react.FunctionComponentElement<react.ProviderProps<
|
|
78
|
+
declare function PermissionProvider({ children, store: externalStore, initialState, }: PermissionProviderProps): react.FunctionComponentElement<react.ProviderProps<PermissionStoreAPI | null>>;
|
|
66
79
|
interface UsePermissionResult {
|
|
67
80
|
permissions: PermissionCode[];
|
|
68
81
|
roles: RoleCode[];
|
|
@@ -75,7 +88,7 @@ interface UsePermissionResult {
|
|
|
75
88
|
setSuperAdmin: (isSuperAdmin: boolean) => void;
|
|
76
89
|
hydrate: (payload: Partial<PermissionState>) => void;
|
|
77
90
|
clear: () => void;
|
|
78
|
-
store:
|
|
91
|
+
store: PermissionStoreAPI;
|
|
79
92
|
}
|
|
80
93
|
declare function usePermission(): UsePermissionResult;
|
|
81
94
|
/** Returns whether the current user has the given permission(s). */
|
|
@@ -386,4 +399,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
386
399
|
declare function getAppClientId(): string;
|
|
387
400
|
declare function getDeviceWorkerId(): string;
|
|
388
401
|
|
|
389
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
402
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, type PermissionStoreAPI, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -26,12 +26,25 @@ interface PermissionChecker {
|
|
|
26
26
|
can(codes: PermissionCode | PermissionCode[], options?: CheckOptions): boolean;
|
|
27
27
|
getState(): PermissionState;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 权限 store 的公共接口(不含 class private 字段)。
|
|
31
|
+
* 用于跨入口(主包 / react / vue)传参,避免重复打包后的名义类型冲突。
|
|
32
|
+
*/
|
|
33
|
+
interface PermissionStoreAPI extends PermissionChecker {
|
|
34
|
+
setState(next: Partial<PermissionState>): void;
|
|
35
|
+
setPermissions(permissions: PermissionCode[]): void;
|
|
36
|
+
setRoles(roles: RoleCode[]): void;
|
|
37
|
+
setSuperAdmin(isSuperAdmin: boolean): void;
|
|
38
|
+
hydrate(payload: Partial<PermissionState>): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
subscribe(listener: PermissionListener): () => void;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* Mutable permission store shared by React / Vue adapters.
|
|
32
45
|
* Framework-agnostic — safe to use in Node, browser, or any UI lib.
|
|
33
46
|
*/
|
|
34
|
-
declare class PermissionStore implements
|
|
47
|
+
declare class PermissionStore implements PermissionStoreAPI {
|
|
35
48
|
private state;
|
|
36
49
|
private permissionSet;
|
|
37
50
|
private roleSet;
|
|
@@ -53,16 +66,16 @@ declare class PermissionStore implements PermissionChecker {
|
|
|
53
66
|
subscribe(listener: PermissionListener): () => void;
|
|
54
67
|
private emit;
|
|
55
68
|
}
|
|
56
|
-
declare function createPermissionStore(initial?: Partial<PermissionState>):
|
|
69
|
+
declare function createPermissionStore(initial?: Partial<PermissionState>): PermissionStoreAPI;
|
|
57
70
|
|
|
58
71
|
interface PermissionProviderProps {
|
|
59
72
|
children: ReactNode;
|
|
60
73
|
/** Pass an existing store to share across trees, or omit to create one. */
|
|
61
|
-
store?:
|
|
74
|
+
store?: PermissionStoreAPI;
|
|
62
75
|
/** Initial state when the provider creates its own store. */
|
|
63
76
|
initialState?: Partial<PermissionState>;
|
|
64
77
|
}
|
|
65
|
-
declare function PermissionProvider({ children, store: externalStore, initialState, }: PermissionProviderProps): react.FunctionComponentElement<react.ProviderProps<
|
|
78
|
+
declare function PermissionProvider({ children, store: externalStore, initialState, }: PermissionProviderProps): react.FunctionComponentElement<react.ProviderProps<PermissionStoreAPI | null>>;
|
|
66
79
|
interface UsePermissionResult {
|
|
67
80
|
permissions: PermissionCode[];
|
|
68
81
|
roles: RoleCode[];
|
|
@@ -75,7 +88,7 @@ interface UsePermissionResult {
|
|
|
75
88
|
setSuperAdmin: (isSuperAdmin: boolean) => void;
|
|
76
89
|
hydrate: (payload: Partial<PermissionState>) => void;
|
|
77
90
|
clear: () => void;
|
|
78
|
-
store:
|
|
91
|
+
store: PermissionStoreAPI;
|
|
79
92
|
}
|
|
80
93
|
declare function usePermission(): UsePermissionResult;
|
|
81
94
|
/** Returns whether the current user has the given permission(s). */
|
|
@@ -386,4 +399,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
386
399
|
declare function getAppClientId(): string;
|
|
387
400
|
declare function getDeviceWorkerId(): string;
|
|
388
401
|
|
|
389
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
402
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LEAF_NO, MENU_LEAF_YES, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, type PermissionStoreAPI, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_MENU_DEPTH, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.js
CHANGED
|
@@ -1563,10 +1563,6 @@ function MenuManager({
|
|
|
1563
1563
|
}
|
|
1564
1564
|
)
|
|
1565
1565
|
] }),
|
|
1566
|
-
/* @__PURE__ */ jsxs2("div", { style: styles2.field, children: [
|
|
1567
|
-
/* @__PURE__ */ jsx3("span", { style: styles2.label, children: "\u83DC\u5355\u5C42\u7EA7\uFF08depth\uFF09" }),
|
|
1568
|
-
/* @__PURE__ */ jsx3("input", { style: styles2.input, value: form.depth, readOnly: true })
|
|
1569
|
-
] }),
|
|
1570
1566
|
/* @__PURE__ */ jsxs2("fieldset", { style: styles2.fieldset, children: [
|
|
1571
1567
|
/* @__PURE__ */ jsx3("legend", { style: styles2.label, children: "\u83DC\u5355\u7C7B\u578B" }),
|
|
1572
1568
|
/* @__PURE__ */ jsx3("div", { style: styles2.radioGroup, children: MENU_TYPE_OPTIONS.map((opt) => /* @__PURE__ */ jsxs2("label", { style: styles2.radioItem, children: [
|
|
@@ -1575,6 +1571,7 @@ function MenuManager({
|
|
|
1575
1571
|
{
|
|
1576
1572
|
type: "radio",
|
|
1577
1573
|
name: "menu-type",
|
|
1574
|
+
style: styles2.control,
|
|
1578
1575
|
checked: form.type === opt.value,
|
|
1579
1576
|
onChange: () => setForm((prev) => ({
|
|
1580
1577
|
...prev,
|
|
@@ -1617,6 +1614,7 @@ function MenuManager({
|
|
|
1617
1614
|
"input",
|
|
1618
1615
|
{
|
|
1619
1616
|
type: "checkbox",
|
|
1617
|
+
style: styles2.control,
|
|
1620
1618
|
checked: form.permissionPointIds.includes(p.resourceId),
|
|
1621
1619
|
onChange: () => togglePermission(p.resourceId)
|
|
1622
1620
|
}
|
|
@@ -1635,6 +1633,7 @@ function MenuManager({
|
|
|
1635
1633
|
{
|
|
1636
1634
|
type: "radio",
|
|
1637
1635
|
name: "menu-status",
|
|
1636
|
+
style: styles2.control,
|
|
1638
1637
|
checked: form.status === opt.value,
|
|
1639
1638
|
onChange: () => setForm((prev) => ({ ...prev, status: opt.value }))
|
|
1640
1639
|
}
|
|
@@ -1890,7 +1889,9 @@ var styles2 = {
|
|
|
1890
1889
|
border: "none",
|
|
1891
1890
|
display: "flex",
|
|
1892
1891
|
flexDirection: "column",
|
|
1893
|
-
gap: 8
|
|
1892
|
+
gap: 8,
|
|
1893
|
+
backgroundColor: "transparent",
|
|
1894
|
+
color: "#101828"
|
|
1894
1895
|
},
|
|
1895
1896
|
label: { fontSize: 13, color: "#344054", fontWeight: 500 },
|
|
1896
1897
|
input: {
|
|
@@ -1904,14 +1905,29 @@ var styles2 = {
|
|
|
1904
1905
|
boxSizing: "border-box",
|
|
1905
1906
|
width: "100%"
|
|
1906
1907
|
},
|
|
1907
|
-
|
|
1908
|
+
control: {
|
|
1909
|
+
width: 16,
|
|
1910
|
+
height: 16,
|
|
1911
|
+
margin: 0,
|
|
1912
|
+
flexShrink: 0,
|
|
1913
|
+
accentColor: "#049BAD",
|
|
1914
|
+
backgroundColor: "#ffffff",
|
|
1915
|
+
colorScheme: "light"
|
|
1916
|
+
},
|
|
1917
|
+
radioGroup: {
|
|
1918
|
+
display: "flex",
|
|
1919
|
+
flexWrap: "wrap",
|
|
1920
|
+
gap: 16,
|
|
1921
|
+
backgroundColor: "transparent"
|
|
1922
|
+
},
|
|
1908
1923
|
radioItem: {
|
|
1909
1924
|
display: "flex",
|
|
1910
1925
|
alignItems: "center",
|
|
1911
1926
|
gap: 6,
|
|
1912
1927
|
fontSize: 14,
|
|
1913
1928
|
color: "#344054",
|
|
1914
|
-
cursor: "pointer"
|
|
1929
|
+
cursor: "pointer",
|
|
1930
|
+
backgroundColor: "transparent"
|
|
1915
1931
|
},
|
|
1916
1932
|
multiSelect: {
|
|
1917
1933
|
maxHeight: 160,
|
|
@@ -1919,7 +1935,8 @@ var styles2 = {
|
|
|
1919
1935
|
border: "1px solid #eaecf0",
|
|
1920
1936
|
borderRadius: 8,
|
|
1921
1937
|
padding: 8,
|
|
1922
|
-
|
|
1938
|
+
backgroundColor: "#ffffff",
|
|
1939
|
+
color: "#101828"
|
|
1923
1940
|
},
|
|
1924
1941
|
checkItem: {
|
|
1925
1942
|
display: "flex",
|
|
@@ -1928,7 +1945,8 @@ var styles2 = {
|
|
|
1928
1945
|
padding: "6px 4px",
|
|
1929
1946
|
fontSize: 13,
|
|
1930
1947
|
color: "#344054",
|
|
1931
|
-
cursor: "pointer"
|
|
1948
|
+
cursor: "pointer",
|
|
1949
|
+
backgroundColor: "transparent"
|
|
1932
1950
|
},
|
|
1933
1951
|
hint: { fontSize: 13, color: "#98a2b3", padding: 8 },
|
|
1934
1952
|
dialogFooter: {
|