com-angel-authorization 1.0.11 → 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.
@@ -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 PermissionChecker {
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>): PermissionStore;
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?: PermissionStore;
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<PermissionStore | null>>;
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: PermissionStore;
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 };
@@ -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 PermissionChecker {
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>): PermissionStore;
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?: PermissionStore;
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<PermissionStore | null>>;
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: PermissionStore;
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 };