com-angel-authorization 1.0.5 → 1.0.6

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.
@@ -181,11 +181,16 @@ type ListPaginationResult = {
181
181
  hasPreviousPage: boolean;
182
182
  hasNextPage: boolean;
183
183
  };
184
- /** 权限点状态:1 启用,0 禁用 */
184
+ /** 通用状态:权限点 1 启用 / 0 禁用;菜单 1 显示 / 0 隐藏 */
185
185
  type ResourceStatus = 0 | 1;
186
+ /** 权限点类型 */
187
+ type ApiResourceType = 'api';
188
+ /** 菜单资源类型 */
189
+ type MenuResourceType = 'page' | 'menu' | 'button';
190
+ type ResourceType = ApiResourceType | MenuResourceType;
186
191
  type AuthorizationResource = {
187
192
  resourceId: string;
188
- type: 'api';
193
+ type: ApiResourceType;
189
194
  name: string;
190
195
  identification: string;
191
196
  status: ResourceStatus;
@@ -201,10 +206,10 @@ type AuthorizationResourceFormValues = {
201
206
  };
202
207
  type CreateAuthorizationResourceBody = AuthorizationResourceFormValues & {
203
208
  resourceId: string;
204
- type: 'api';
209
+ type: ApiResourceType;
205
210
  };
206
211
  type UpdateAuthorizationResourceBody = Partial<AuthorizationResourceFormValues> & {
207
- type?: 'api';
212
+ type?: ApiResourceType;
208
213
  };
209
214
  type FetchAuthorizationResourcesParams = {
210
215
  pagination?: ListPaginationParams;
@@ -215,17 +220,65 @@ type AuthorizationResourceListResult = {
215
220
  hasPreviousPage: boolean;
216
221
  hasNextPage: boolean;
217
222
  };
218
- declare const RESOURCE_TYPE_API: "api";
223
+ type MenuResource = {
224
+ resourceId: string;
225
+ parentId: string;
226
+ type: MenuResourceType;
227
+ name: string;
228
+ identification: string;
229
+ permissionPointIds: string[];
230
+ /** 关联权限点名称(列表展示用,后端可能返回) */
231
+ permissionPointNames?: string[];
232
+ status: ResourceStatus;
233
+ };
234
+ type MenuResourceFormValues = {
235
+ parentId: string;
236
+ type: MenuResourceType;
237
+ name: string;
238
+ identification: string;
239
+ permissionPointIds: string[];
240
+ status: ResourceStatus;
241
+ };
242
+ type CreateMenuResourceBody = MenuResourceFormValues & {
243
+ resourceId: string;
244
+ };
245
+ type UpdateMenuResourceBody = Partial<MenuResourceFormValues>;
246
+ type FetchMenuResourcesParams = {
247
+ pagination?: ListPaginationParams;
248
+ };
249
+ type MenuResourceListResult = {
250
+ records: MenuResource[];
251
+ pageToken: string;
252
+ hasPreviousPage: boolean;
253
+ hasNextPage: boolean;
254
+ };
255
+ declare const RESOURCE_TYPE_API: ApiResourceType;
256
+ declare const MENU_TYPE_PAGE: MenuResourceType;
257
+ declare const MENU_TYPE_MENU: MenuResourceType;
258
+ declare const MENU_TYPE_BUTTON: MenuResourceType;
259
+ /** 菜单列表查询 type 参数 */
260
+ declare const MENU_LIST_TYPE_PARAM = "page,menu,button";
261
+ declare const ROOT_PARENT_ID = "0";
219
262
  declare const RESOURCE_STATUS_ENABLED: ResourceStatus;
220
263
  declare const RESOURCE_STATUS_DISABLED: ResourceStatus;
221
264
  declare const RESOURCE_STATUS_OPTIONS: {
222
265
  label: string;
223
266
  value: ResourceStatus;
224
267
  }[];
268
+ /** 菜单可见性 */
269
+ declare const MENU_VISIBILITY_OPTIONS: {
270
+ label: string;
271
+ value: ResourceStatus;
272
+ }[];
225
273
  declare const RESOURCE_PRIVATE_OPTIONS: {
226
274
  label: string;
227
275
  value: boolean;
228
276
  }[];
277
+ declare const MENU_TYPE_OPTIONS: {
278
+ label: string;
279
+ value: MenuResourceType;
280
+ }[];
281
+ declare const MENU_TYPE_LABEL: Record<MenuResourceType, string>;
229
282
 
230
283
  type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
231
284
  type ResourceRequestOptions = {
@@ -244,10 +297,22 @@ type AuthorizationResourceApi = {
244
297
  update: (resourceId: string, values: AuthorizationResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
245
298
  remove: (resourceId: string, signal?: AbortSignal) => Promise<unknown>;
246
299
  };
300
+ type MenuResourceApi = {
301
+ list: (params?: FetchMenuResourcesParams, signal?: AbortSignal) => Promise<MenuResourceListResult>;
302
+ /** 拉取权限点(type=api),供菜单表单多选 */
303
+ listPermissionPoints: (params?: FetchAuthorizationResourcesParams, signal?: AbortSignal) => Promise<AuthorizationResourceListResult>;
304
+ create: (values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
305
+ update: (resourceId: string, values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
306
+ remove: (resourceId: string, signal?: AbortSignal) => Promise<unknown>;
307
+ };
247
308
  declare function mapAuthorizationResource(item: unknown): AuthorizationResource | null;
309
+ declare function mapMenuResource(item: unknown): MenuResource | null;
248
310
  declare function buildCreateBody(values: AuthorizationResourceFormValues, resourceId?: string): CreateAuthorizationResourceBody;
249
311
  declare function buildUpdateBody(values: AuthorizationResourceFormValues): UpdateAuthorizationResourceBody;
312
+ declare function buildCreateMenuBody(values: MenuResourceFormValues, resourceId?: string): CreateMenuResourceBody;
313
+ declare function buildUpdateMenuBody(values: MenuResourceFormValues): UpdateMenuResourceBody;
250
314
  declare function createAuthorizationResourceApi(request: ResourceHttpRequest): AuthorizationResourceApi;
315
+ declare function createMenuResourceApi(request: ResourceHttpRequest): MenuResourceApi;
251
316
  type CreateDefaultResourceRequestOptions = {
252
317
  /** API 前缀,如 `/api` 或完整域名 */
253
318
  baseUrl?: string;
@@ -301,6 +366,42 @@ declare const ResourceManager: vue.DefineComponent<vue.ExtractPropTypes<{
301
366
  pageSize: string;
302
367
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
303
368
 
369
+ /**
370
+ * 菜单管理页面(Vue 3)
371
+ */
372
+ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
373
+ api: {
374
+ type: PropType<MenuResourceApi>;
375
+ required: true;
376
+ };
377
+ title: {
378
+ type: StringConstructor;
379
+ default: string;
380
+ };
381
+ pageSize: {
382
+ type: StringConstructor;
383
+ default: string;
384
+ };
385
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
386
+ [key: string]: any;
387
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
388
+ api: {
389
+ type: PropType<MenuResourceApi>;
390
+ required: true;
391
+ };
392
+ title: {
393
+ type: StringConstructor;
394
+ default: string;
395
+ };
396
+ pageSize: {
397
+ type: StringConstructor;
398
+ default: string;
399
+ };
400
+ }>> & Readonly<{}>, {
401
+ title: string;
402
+ pageSize: string;
403
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
404
+
304
405
  interface SnowyflakeOptions {
305
406
  epoch?: bigint;
306
407
  workerId?: bigint;
@@ -331,4 +432,4 @@ declare const snowyflake: ConfigurableSnowflake;
331
432
  declare function getAppClientId(): string;
332
433
  declare function getDeviceWorkerId(): string;
333
434
 
334
- export { type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type FetchAuthorizationResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, type MatchMode, 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, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type RoleCode, type UpdateAuthorizationResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildUpdateBody, createAuthorizationResourceApi, createDefaultResourceRequest, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, snowyflake, useHasPermission, useHasRole, usePermission };
435
+ 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_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_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
@@ -181,11 +181,16 @@ type ListPaginationResult = {
181
181
  hasPreviousPage: boolean;
182
182
  hasNextPage: boolean;
183
183
  };
184
- /** 权限点状态:1 启用,0 禁用 */
184
+ /** 通用状态:权限点 1 启用 / 0 禁用;菜单 1 显示 / 0 隐藏 */
185
185
  type ResourceStatus = 0 | 1;
186
+ /** 权限点类型 */
187
+ type ApiResourceType = 'api';
188
+ /** 菜单资源类型 */
189
+ type MenuResourceType = 'page' | 'menu' | 'button';
190
+ type ResourceType = ApiResourceType | MenuResourceType;
186
191
  type AuthorizationResource = {
187
192
  resourceId: string;
188
- type: 'api';
193
+ type: ApiResourceType;
189
194
  name: string;
190
195
  identification: string;
191
196
  status: ResourceStatus;
@@ -201,10 +206,10 @@ type AuthorizationResourceFormValues = {
201
206
  };
202
207
  type CreateAuthorizationResourceBody = AuthorizationResourceFormValues & {
203
208
  resourceId: string;
204
- type: 'api';
209
+ type: ApiResourceType;
205
210
  };
206
211
  type UpdateAuthorizationResourceBody = Partial<AuthorizationResourceFormValues> & {
207
- type?: 'api';
212
+ type?: ApiResourceType;
208
213
  };
209
214
  type FetchAuthorizationResourcesParams = {
210
215
  pagination?: ListPaginationParams;
@@ -215,17 +220,65 @@ type AuthorizationResourceListResult = {
215
220
  hasPreviousPage: boolean;
216
221
  hasNextPage: boolean;
217
222
  };
218
- declare const RESOURCE_TYPE_API: "api";
223
+ type MenuResource = {
224
+ resourceId: string;
225
+ parentId: string;
226
+ type: MenuResourceType;
227
+ name: string;
228
+ identification: string;
229
+ permissionPointIds: string[];
230
+ /** 关联权限点名称(列表展示用,后端可能返回) */
231
+ permissionPointNames?: string[];
232
+ status: ResourceStatus;
233
+ };
234
+ type MenuResourceFormValues = {
235
+ parentId: string;
236
+ type: MenuResourceType;
237
+ name: string;
238
+ identification: string;
239
+ permissionPointIds: string[];
240
+ status: ResourceStatus;
241
+ };
242
+ type CreateMenuResourceBody = MenuResourceFormValues & {
243
+ resourceId: string;
244
+ };
245
+ type UpdateMenuResourceBody = Partial<MenuResourceFormValues>;
246
+ type FetchMenuResourcesParams = {
247
+ pagination?: ListPaginationParams;
248
+ };
249
+ type MenuResourceListResult = {
250
+ records: MenuResource[];
251
+ pageToken: string;
252
+ hasPreviousPage: boolean;
253
+ hasNextPage: boolean;
254
+ };
255
+ declare const RESOURCE_TYPE_API: ApiResourceType;
256
+ declare const MENU_TYPE_PAGE: MenuResourceType;
257
+ declare const MENU_TYPE_MENU: MenuResourceType;
258
+ declare const MENU_TYPE_BUTTON: MenuResourceType;
259
+ /** 菜单列表查询 type 参数 */
260
+ declare const MENU_LIST_TYPE_PARAM = "page,menu,button";
261
+ declare const ROOT_PARENT_ID = "0";
219
262
  declare const RESOURCE_STATUS_ENABLED: ResourceStatus;
220
263
  declare const RESOURCE_STATUS_DISABLED: ResourceStatus;
221
264
  declare const RESOURCE_STATUS_OPTIONS: {
222
265
  label: string;
223
266
  value: ResourceStatus;
224
267
  }[];
268
+ /** 菜单可见性 */
269
+ declare const MENU_VISIBILITY_OPTIONS: {
270
+ label: string;
271
+ value: ResourceStatus;
272
+ }[];
225
273
  declare const RESOURCE_PRIVATE_OPTIONS: {
226
274
  label: string;
227
275
  value: boolean;
228
276
  }[];
277
+ declare const MENU_TYPE_OPTIONS: {
278
+ label: string;
279
+ value: MenuResourceType;
280
+ }[];
281
+ declare const MENU_TYPE_LABEL: Record<MenuResourceType, string>;
229
282
 
230
283
  type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
231
284
  type ResourceRequestOptions = {
@@ -244,10 +297,22 @@ type AuthorizationResourceApi = {
244
297
  update: (resourceId: string, values: AuthorizationResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
245
298
  remove: (resourceId: string, signal?: AbortSignal) => Promise<unknown>;
246
299
  };
300
+ type MenuResourceApi = {
301
+ list: (params?: FetchMenuResourcesParams, signal?: AbortSignal) => Promise<MenuResourceListResult>;
302
+ /** 拉取权限点(type=api),供菜单表单多选 */
303
+ listPermissionPoints: (params?: FetchAuthorizationResourcesParams, signal?: AbortSignal) => Promise<AuthorizationResourceListResult>;
304
+ create: (values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
305
+ update: (resourceId: string, values: MenuResourceFormValues, signal?: AbortSignal) => Promise<unknown>;
306
+ remove: (resourceId: string, signal?: AbortSignal) => Promise<unknown>;
307
+ };
247
308
  declare function mapAuthorizationResource(item: unknown): AuthorizationResource | null;
309
+ declare function mapMenuResource(item: unknown): MenuResource | null;
248
310
  declare function buildCreateBody(values: AuthorizationResourceFormValues, resourceId?: string): CreateAuthorizationResourceBody;
249
311
  declare function buildUpdateBody(values: AuthorizationResourceFormValues): UpdateAuthorizationResourceBody;
312
+ declare function buildCreateMenuBody(values: MenuResourceFormValues, resourceId?: string): CreateMenuResourceBody;
313
+ declare function buildUpdateMenuBody(values: MenuResourceFormValues): UpdateMenuResourceBody;
250
314
  declare function createAuthorizationResourceApi(request: ResourceHttpRequest): AuthorizationResourceApi;
315
+ declare function createMenuResourceApi(request: ResourceHttpRequest): MenuResourceApi;
251
316
  type CreateDefaultResourceRequestOptions = {
252
317
  /** API 前缀,如 `/api` 或完整域名 */
253
318
  baseUrl?: string;
@@ -301,6 +366,42 @@ declare const ResourceManager: vue.DefineComponent<vue.ExtractPropTypes<{
301
366
  pageSize: string;
302
367
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
303
368
 
369
+ /**
370
+ * 菜单管理页面(Vue 3)
371
+ */
372
+ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
373
+ api: {
374
+ type: PropType<MenuResourceApi>;
375
+ required: true;
376
+ };
377
+ title: {
378
+ type: StringConstructor;
379
+ default: string;
380
+ };
381
+ pageSize: {
382
+ type: StringConstructor;
383
+ default: string;
384
+ };
385
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
386
+ [key: string]: any;
387
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
388
+ api: {
389
+ type: PropType<MenuResourceApi>;
390
+ required: true;
391
+ };
392
+ title: {
393
+ type: StringConstructor;
394
+ default: string;
395
+ };
396
+ pageSize: {
397
+ type: StringConstructor;
398
+ default: string;
399
+ };
400
+ }>> & Readonly<{}>, {
401
+ title: string;
402
+ pageSize: string;
403
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
404
+
304
405
  interface SnowyflakeOptions {
305
406
  epoch?: bigint;
306
407
  workerId?: bigint;
@@ -331,4 +432,4 @@ declare const snowyflake: ConfigurableSnowflake;
331
432
  declare function getAppClientId(): string;
332
433
  declare function getDeviceWorkerId(): string;
333
434
 
334
- export { type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type FetchAuthorizationResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, type MatchMode, 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, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type RoleCode, type UpdateAuthorizationResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildUpdateBody, createAuthorizationResourceApi, createDefaultResourceRequest, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, snowyflake, useHasPermission, useHasRole, usePermission };
435
+ 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_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_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };