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,19 +66,19 @@ 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
- declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStore>;
71
+ declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
59
72
  interface PermissionPluginOptions {
60
73
  /** Pass an existing store to share across apps. */
61
- store?: PermissionStore;
74
+ store?: PermissionStoreAPI;
62
75
  /** Initial state when the plugin creates its own store. */
63
76
  initialState?: Partial<PermissionState>;
64
77
  /** Custom directive name. Default: `permission` → `v-permission`. */
65
78
  directiveName?: string;
66
79
  }
67
80
  declare function createPermissionPlugin(options?: PermissionPluginOptions): Plugin & {
68
- store: PermissionStore;
81
+ store: PermissionStoreAPI;
69
82
  };
70
83
  interface UsePermissionResult {
71
84
  permissions: ComputedRef<PermissionCode[]>;
@@ -79,17 +92,17 @@ interface UsePermissionResult {
79
92
  setSuperAdmin: (isSuperAdmin: boolean) => void;
80
93
  hydrate: (payload: Partial<PermissionState>) => void;
81
94
  clear: () => void;
82
- store: PermissionStore;
95
+ store: PermissionStoreAPI;
83
96
  }
84
97
  /**
85
98
  * Reactive permission API for Vue 3 Composition API.
86
99
  */
87
- declare function usePermission(store?: PermissionStore): UsePermissionResult;
88
- declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
89
- declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
100
+ declare function usePermission(store?: PermissionStoreAPI): UsePermissionResult;
101
+ declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
102
+ declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
90
103
  declare module 'vue' {
91
104
  interface ComponentCustomProperties {
92
- $permission: PermissionStore;
105
+ $permission: PermissionStoreAPI;
93
106
  $can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;
94
107
  $hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;
95
108
  }
@@ -112,7 +125,7 @@ type ElWithPermission = HTMLElement & {
112
125
  * Create a `v-permission` directive bound to a specific store.
113
126
  * Prefer installing via `createPermissionPlugin()` which registers this automatically.
114
127
  */
115
- declare function createVPermission(store: PermissionStore): Directive<ElWithPermission, PermissionDirectiveValue>;
128
+ declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
116
129
 
117
130
  /**
118
131
  * Conditionally render slot content based on permission / role.
@@ -538,4 +551,4 @@ declare const snowyflake: ConfigurableSnowflake;
538
551
  declare function getAppClientId(): string;
539
552
  declare function getDeviceWorkerId(): string;
540
553
 
541
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, 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 MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, 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 ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
554
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, 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 MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, 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 ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, 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,19 +66,19 @@ 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
- declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStore>;
71
+ declare const PERMISSION_STORE_KEY: InjectionKey<PermissionStoreAPI>;
59
72
  interface PermissionPluginOptions {
60
73
  /** Pass an existing store to share across apps. */
61
- store?: PermissionStore;
74
+ store?: PermissionStoreAPI;
62
75
  /** Initial state when the plugin creates its own store. */
63
76
  initialState?: Partial<PermissionState>;
64
77
  /** Custom directive name. Default: `permission` → `v-permission`. */
65
78
  directiveName?: string;
66
79
  }
67
80
  declare function createPermissionPlugin(options?: PermissionPluginOptions): Plugin & {
68
- store: PermissionStore;
81
+ store: PermissionStoreAPI;
69
82
  };
70
83
  interface UsePermissionResult {
71
84
  permissions: ComputedRef<PermissionCode[]>;
@@ -79,17 +92,17 @@ interface UsePermissionResult {
79
92
  setSuperAdmin: (isSuperAdmin: boolean) => void;
80
93
  hydrate: (payload: Partial<PermissionState>) => void;
81
94
  clear: () => void;
82
- store: PermissionStore;
95
+ store: PermissionStoreAPI;
83
96
  }
84
97
  /**
85
98
  * Reactive permission API for Vue 3 Composition API.
86
99
  */
87
- declare function usePermission(store?: PermissionStore): UsePermissionResult;
88
- declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
89
- declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStore): ComputedRef<boolean>;
100
+ declare function usePermission(store?: PermissionStoreAPI): UsePermissionResult;
101
+ declare function useHasPermission(codes: PermissionCode | PermissionCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
102
+ declare function useHasRole(codes: RoleCode | RoleCode[], options?: CheckOptions, store?: PermissionStoreAPI): ComputedRef<boolean>;
90
103
  declare module 'vue' {
91
104
  interface ComponentCustomProperties {
92
- $permission: PermissionStore;
105
+ $permission: PermissionStoreAPI;
93
106
  $can: (codes: PermissionCode | PermissionCode[], options?: CheckOptions) => boolean;
94
107
  $hasRole: (codes: RoleCode | RoleCode[], options?: CheckOptions) => boolean;
95
108
  }
@@ -112,7 +125,7 @@ type ElWithPermission = HTMLElement & {
112
125
  * Create a `v-permission` directive bound to a specific store.
113
126
  * Prefer installing via `createPermissionPlugin()` which registers this automatically.
114
127
  */
115
- declare function createVPermission(store: PermissionStore): Directive<ElWithPermission, PermissionDirectiveValue>;
128
+ declare function createVPermission(store: PermissionStoreAPI): Directive<ElWithPermission, PermissionDirectiveValue>;
116
129
 
117
130
  /**
118
131
  * Conditionally render slot content based on permission / role.
@@ -538,4 +551,4 @@ declare const snowyflake: ConfigurableSnowflake;
538
551
  declare function getAppClientId(): string;
539
552
  declare function getDeviceWorkerId(): string;
540
553
 
541
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, 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 MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, 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 ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };
554
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, 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 MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, 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 ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, isMenuLeaf, mapAuthorizationResource, mapMenuResource, resolveMenuDepth, snowyflake, useHasPermission, useHasRole, usePermission };