vome-core 0.0.1
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.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/src/auth/define-macro.d.ts +8 -0
- package/dist/src/auth/index.d.ts +2 -0
- package/dist/src/comm/daily-log.d.ts +8 -0
- package/dist/src/comm/env.d.ts +4 -0
- package/dist/src/comm/format-time.d.ts +10 -0
- package/dist/src/comm/merge.d.ts +2 -0
- package/dist/src/comm/scan.d.ts +4 -0
- package/dist/src/comm/startBanner.d.ts +1 -0
- package/dist/src/core/app.d.ts +37 -0
- package/dist/src/core/config.d.ts +2 -0
- package/dist/src/core/context/index.d.ts +22 -0
- package/dist/src/core/host-infra.d.ts +20 -0
- package/dist/src/core/index.d.ts +20 -0
- package/dist/src/core/plugins/async-context.d.ts +3 -0
- package/dist/src/core/plugins/error.d.ts +5 -0
- package/dist/src/core/plugins/logging.d.ts +3 -0
- package/dist/src/core/plugins/openapi.d.ts +3 -0
- package/dist/src/core/vome-config.d.ts +2 -0
- package/dist/src/ext/base-plugin.d.ts +13 -0
- package/dist/src/ext/index.d.ts +15 -0
- package/dist/src/ext/load-plugin.d.ts +12 -0
- package/dist/src/ext/micro-apps.d.ts +60 -0
- package/dist/src/ext/module-gateway.d.ts +10 -0
- package/dist/src/ext/module-registry.d.ts +45 -0
- package/dist/src/ext/path.d.ts +8 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/ioc/container.d.ts +29 -0
- package/dist/src/ioc/decorators.d.ts +35 -0
- package/dist/src/ioc/host.d.ts +2 -0
- package/dist/src/ioc/index.d.ts +6 -0
- package/dist/src/ioc/metadata.d.ts +12 -0
- package/dist/src/ioc/scope.d.ts +9 -0
- package/dist/src/logger/bootstrap.d.ts +2 -0
- package/dist/src/logger/exception.d.ts +22 -0
- package/dist/src/logger/index.d.ts +5 -0
- package/dist/src/logger/logger.d.ts +18 -0
- package/dist/src/logger/pino.d.ts +8 -0
- package/dist/src/orm/base-columns.d.ts +11 -0
- package/dist/src/orm/column-comments.d.ts +25 -0
- package/dist/src/orm/crud-config.d.ts +7 -0
- package/dist/src/orm/crud-register.d.ts +5 -0
- package/dist/src/orm/data-scope.d.ts +24 -0
- package/dist/src/orm/db-store.d.ts +12 -0
- package/dist/src/orm/entity-schema.d.ts +7 -0
- package/dist/src/orm/index.d.ts +22 -0
- package/dist/src/orm/query-builder.d.ts +12 -0
- package/dist/src/orm/query-op.d.ts +27 -0
- package/dist/src/orm/repository.d.ts +74 -0
- package/dist/src/orm/service.d.ts +71 -0
- package/dist/src/orm/tenant.d.ts +24 -0
- package/dist/src/routing/base.d.ts +27 -0
- package/dist/src/routing/context.d.ts +14 -0
- package/dist/src/routing/crud-summary.d.ts +2 -0
- package/dist/src/routing/decorators.d.ts +48 -0
- package/dist/src/routing/eps.d.ts +16 -0
- package/dist/src/routing/index.d.ts +8 -0
- package/dist/src/routing/metadata.d.ts +28 -0
- package/dist/src/routing/openapi-tags.d.ts +23 -0
- package/dist/src/routing/path-utils.d.ts +5 -0
- package/dist/src/routing/perm.d.ts +18 -0
- package/dist/src/routing/register.d.ts +7 -0
- package/dist/src/server/index.d.ts +10 -0
- package/dist/src/shared/index.d.ts +8 -0
- package/dist/src/shared/tree.d.ts +18 -0
- package/dist/typings/comm/crud.d.ts +24 -0
- package/dist/typings/comm/page.d.ts +16 -0
- package/dist/typings/comm/scan.d.ts +6 -0
- package/dist/typings/common.d.ts +6 -0
- package/dist/typings/context/data.d.ts +10 -0
- package/dist/typings/ext/module.d.ts +45 -0
- package/dist/typings/ext/plugin.d.ts +40 -0
- package/dist/typings/ioc/metadata.d.ts +31 -0
- package/dist/typings/logger/config.d.ts +6 -0
- package/dist/typings/routing/crud.d.ts +99 -0
- package/dist/typings/routing/eps.d.ts +53 -0
- package/dist/typings/routing/meta.d.ts +56 -0
- package/dist/typings/routing/register.d.ts +15 -0
- package/dist/typings/routing/scan-context.d.ts +6 -0
- package/package.json +96 -0
- package/src/admin/api/client.ts +184 -0
- package/src/admin/components/vm-aside.vue +227 -0
- package/src/admin/components/vm-auto-perm-dialog.vue +361 -0
- package/src/admin/components/vm-check-tree.vue +338 -0
- package/src/admin/components/vm-dept-tree.vue +549 -0
- package/src/admin/components/vm-empty.vue +62 -0
- package/src/admin/components/vm-eps-perm-picker.vue +114 -0
- package/src/admin/components/vm-group-cascader.vue +563 -0
- package/src/admin/components/vm-icon-picker.vue +616 -0
- package/src/admin/components/vm-markdown.vue +141 -0
- package/src/admin/components/vm-ri-icon.vue +21 -0
- package/src/admin/components/vm-role-picker.vue +314 -0
- package/src/admin/components/vm-view-path-picker.vue +56 -0
- package/src/admin/config/plugin-dev.ts +31 -0
- package/src/admin/crud/components/vm-column-custom.vue +196 -0
- package/src/admin/crud/components/vm-context-menu.vue +99 -0
- package/src/admin/crud/components/vm-date-picker.vue +74 -0
- package/src/admin/crud/components/vm-date-range.vue +291 -0
- package/src/admin/crud/components/vm-date-text.vue +41 -0
- package/src/admin/crud/components/vm-dict-tag.vue +47 -0
- package/src/admin/crud/components/vm-file-icon.vue +54 -0
- package/src/admin/crud/components/vm-multi-select.vue +181 -0
- package/src/admin/crud/components/vm-number-range.vue +200 -0
- package/src/admin/crud/components/vm-radio.vue +87 -0
- package/src/admin/crud/components/vm-select.vue +131 -0
- package/src/admin/crud/components/vm-switch.vue +128 -0
- package/src/admin/crud/components/vm-tree-select.vue +456 -0
- package/src/admin/crud/components/vm-upload-item.vue +215 -0
- package/src/admin/crud/components/vm-upload.vue +323 -0
- package/src/admin/crud/components/vm-user-select.vue +234 -0
- package/src/admin/crud/config.ts +38 -0
- package/src/admin/crud/confirm.ts +135 -0
- package/src/admin/crud/dict.ts +49 -0
- package/src/admin/crud/index.ts +79 -0
- package/src/admin/crud/key.ts +47 -0
- package/src/admin/crud/mitt.ts +27 -0
- package/src/admin/crud/plugins.ts +298 -0
- package/src/admin/crud/registry.ts +45 -0
- package/src/admin/crud/span.ts +48 -0
- package/src/admin/crud/style.ts +112 -0
- package/src/admin/crud/useCrud.ts +81 -0
- package/src/admin/crud/validate.ts +109 -0
- package/src/admin/crud/vm-add-btn.vue +68 -0
- package/src/admin/crud/vm-adv-search.vue +73 -0
- package/src/admin/crud/vm-crud.vue +517 -0
- package/src/admin/crud/vm-dialog.vue +234 -0
- package/src/admin/crud/vm-flex1.vue +14 -0
- package/src/admin/crud/vm-form.vue +239 -0
- package/src/admin/crud/vm-multi-delete-btn.vue +48 -0
- package/src/admin/crud/vm-pagination.vue +125 -0
- package/src/admin/crud/vm-refresh-btn.vue +34 -0
- package/src/admin/crud/vm-row.vue +42 -0
- package/src/admin/crud/vm-search-key.vue +76 -0
- package/src/admin/crud/vm-search.vue +367 -0
- package/src/admin/crud/vm-table.vue +852 -0
- package/src/admin/crud/vm-toolbar.vue +245 -0
- package/src/admin/crud/vm-upsert.vue +530 -0
- package/src/admin/data/remixicon-all.json +1 -0
- package/src/admin/directives/perm.ts +18 -0
- package/src/admin/env.d.ts +5 -0
- package/src/admin/hooks/useBrowser.ts +27 -0
- package/src/admin/hooks/useUpload.ts +82 -0
- package/src/admin/hooks/useVome.ts +13 -0
- package/src/admin/index.ts +59 -0
- package/src/admin/lib/browser.ts +28 -0
- package/src/admin/lib/cn.ts +7 -0
- package/src/admin/lib/dialog-float.ts +14 -0
- package/src/admin/lib/eps.ts +43 -0
- package/src/admin/lib/menu.ts +15 -0
- package/src/admin/lib/module.ts +112 -0
- package/src/admin/lib/tree.ts +2 -0
- package/src/admin/lib/upload.ts +102 -0
- package/src/admin/router/index.ts +61 -0
- package/src/admin/router/menu-routes.ts +126 -0
- package/src/admin/service/base.ts +96 -0
- package/src/admin/service/index.ts +281 -0
- package/src/admin/static/fileicon/demo.css +539 -0
- package/src/admin/static/fileicon/demo_index.html +901 -0
- package/src/admin/static/fileicon/iconfont.css +139 -0
- package/src/admin/static/fileicon/iconfont.js +1 -0
- package/src/admin/static/fileicon/iconfont.json +226 -0
- package/src/admin/static/fileicon/iconfont.ttf +0 -0
- package/src/admin/static/fileicon/iconfont.woff +0 -0
- package/src/admin/static/fileicon/iconfont.woff2 +0 -0
- package/src/admin/static/scarce//344/270/213/350/275/275/345/244/261/350/264/245.svg +1 -0
- package/src/admin/static/scarce//346/224/257/344/273/230/346/210/220/345/212/237.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/344/274/230/346/203/240/345/210/270.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/345/206/205/345/256/271.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/345/217/221/347/245/250.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/345/233/276/347/211/207.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/345/234/260/345/235/200.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/345/272/227/351/223/272.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/216/250/351/200/201.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/220/234/347/264/242/347/273/223/346/236/234.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/224/266/350/227/217.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/225/260/346/215/256.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/235/203/351/231/220.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/346/266/210/346/201/257.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/347/244/274/347/211/251.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/347/247/257/345/210/206.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/347/275/221/347/273/234.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/350/247/206/351/242/221.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/350/256/242/345/215/225.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/350/257/204/350/256/272.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/351/205/215/351/200/201.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/351/223/266/350/241/214/345/215/241.svg +1 -0
- package/src/admin/static/scarce//346/232/202/346/227/240/351/237/263/344/271/220.svg +1 -0
- package/src/admin/static/scarce//351/241/265/351/235/242/344/270/215/345/255/230/345/234/250.svg +1 -0
- package/src/admin/stores/app.ts +30 -0
- package/src/admin/stores/tags.ts +73 -0
- package/src/admin/stores/user.ts +52 -0
- package/src/admin/styles/base.css +137 -0
- package/src/admin/tsconfig.json +19 -0
- package/typings/admin/base/auth.ts +23 -0
- package/typings/admin/base/permission.ts +19 -0
- package/typings/admin/comm/cascader.ts +7 -0
- package/typings/admin/comm/check-tree.ts +7 -0
- package/typings/admin/comm/crud.ts +294 -0
- package/typings/admin/comm/eps.ts +52 -0
- package/typings/admin/comm/request.ts +12 -0
- package/typings/admin/comm/service.ts +35 -0
- package/typings/admin/comm/upload.ts +39 -0
- package/typings/admin/host.d.ts +61 -0
- package/typings/admin/vome/browser.ts +11 -0
- package/typings/admin/vome/module.ts +13 -0
- package/typings/admin/vome/tags.ts +9 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** 业务码:1000 成功 */
|
|
2
|
+
export declare const RES_CODE: {
|
|
3
|
+
readonly SUCCESS: 1000;
|
|
4
|
+
readonly ERROR: 1001;
|
|
5
|
+
};
|
|
6
|
+
export type ResCode = (typeof RES_CODE)[keyof typeof RES_CODE];
|
|
7
|
+
export type ApiSuccess<T = unknown> = {
|
|
8
|
+
code: typeof RES_CODE.SUCCESS;
|
|
9
|
+
message: string;
|
|
10
|
+
data: T;
|
|
11
|
+
};
|
|
12
|
+
export type ApiFail = {
|
|
13
|
+
code: number;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
export type ApiResult<T = unknown> = ApiSuccess<T> | ApiFail;
|
|
17
|
+
/**
|
|
18
|
+
* 控制器基类
|
|
19
|
+
*
|
|
20
|
+
* - `ok(data)` → `{ code: 1000, message: 'success', data }`
|
|
21
|
+
* - `fail(message, code?)` → `{ code, message }`
|
|
22
|
+
* - 成功响应内 Date / *Time|*Date|*At 自动格式化为 `YYYY-MM-DD HH:mm:ss`
|
|
23
|
+
*/
|
|
24
|
+
export declare class BaseController {
|
|
25
|
+
ok<T = unknown>(data?: T): ApiSuccess<T | null>;
|
|
26
|
+
fail(message?: string, code?: number): ApiFail;
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ControllerSide } from '../../typings/routing/meta';
|
|
2
|
+
import type { ControllerScanContext } from '../../typings/routing/scan-context';
|
|
3
|
+
export type { ControllerScanContext };
|
|
4
|
+
export declare function setControllerScanContext(next: ControllerScanContext | null): void;
|
|
5
|
+
export declare function getControllerScanContext(): ControllerScanContext | null;
|
|
6
|
+
/** modules/base/controller/admin/auth.ts → base */
|
|
7
|
+
export declare function parseModuleFromPath(file: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* 未写 prefix 时由文件路径生成(相对 sidePrefix)
|
|
10
|
+
* modules/base/controller/admin/auth.ts → /base/auth
|
|
11
|
+
* modules/user/controller/app/rbac.ts → /user/rbac
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseControllerAutoPrefix(file: string): string;
|
|
14
|
+
export type { ControllerSide };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { RouteMiddleware } from '../../typings/routing/crud';
|
|
3
|
+
import type { ControllerOptions } from '../../typings/routing/meta';
|
|
4
|
+
/**
|
|
5
|
+
* 注册控制器(自动进 IoC,无需 `@Provide`)。
|
|
6
|
+
*
|
|
7
|
+
* @param prefixOrOptions - `'/auth'` 显式前缀;省略则按规则:/{module}/{文件名}
|
|
8
|
+
*/
|
|
9
|
+
export declare function Controller(prefixOrOptions?: string | ControllerOptions): (target: new (...args: unknown[]) => unknown) => void;
|
|
10
|
+
/**
|
|
11
|
+
* 单路由中间件(Elysia beforeHandle)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Use(rateLimit)
|
|
16
|
+
* @Post('/once')
|
|
17
|
+
* once() {}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function Use(...middleware: RouteMiddleware[]): (target: object, propertyKey: string | symbol) => void;
|
|
21
|
+
/** 公开路由:admin 侧跳过鉴权宏 */
|
|
22
|
+
export declare function Public(): (target: object, propertyKey: string | symbol) => void;
|
|
23
|
+
/**
|
|
24
|
+
* 显式权限码(可选覆盖自动推导);超管跳过。
|
|
25
|
+
* 业务侧优先在菜单配置权限码,一般无需使用。
|
|
26
|
+
*/
|
|
27
|
+
export declare function Perms(...codes: string[]): (target: object, propertyKey: string | symbol) => void;
|
|
28
|
+
/** 跳过权限码校验(仍走登录,除非同时 @Public) */
|
|
29
|
+
export declare function IgnorePerms(): (target: object, propertyKey: string | symbol) => void;
|
|
30
|
+
export declare const Body: (schema?: unknown) => (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
31
|
+
export declare const Query: (schema?: unknown) => (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
32
|
+
export declare const Param: (schema?: unknown) => (target: object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
33
|
+
/** @example `@Get('/perms', { summary: '当前权限' })` → 侧栏显示 `perms 当前权限` */
|
|
34
|
+
export declare const Get: (path?: string, options?: {
|
|
35
|
+
summary?: string;
|
|
36
|
+
}) => (target: object, propertyKey: string | symbol) => void;
|
|
37
|
+
export declare const Post: (path?: string, options?: {
|
|
38
|
+
summary?: string;
|
|
39
|
+
}) => (target: object, propertyKey: string | symbol) => void;
|
|
40
|
+
export declare const Put: (path?: string, options?: {
|
|
41
|
+
summary?: string;
|
|
42
|
+
}) => (target: object, propertyKey: string | symbol) => void;
|
|
43
|
+
export declare const Delete: (path?: string, options?: {
|
|
44
|
+
summary?: string;
|
|
45
|
+
}) => (target: object, propertyKey: string | symbol) => void;
|
|
46
|
+
export declare const Patch: (path?: string, options?: {
|
|
47
|
+
summary?: string;
|
|
48
|
+
}) => (target: object, propertyKey: string | symbol) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EpsApiItem, EpsColumn, EpsEntity, EpsModuleMap } from '../../typings/routing/eps';
|
|
2
|
+
import { listControllers } from './metadata';
|
|
3
|
+
export type { EpsApiItem, EpsColumn, EpsEntity, EpsModuleMap };
|
|
4
|
+
/** 是否开启 EPS 下发(vome.eps === true) */
|
|
5
|
+
export declare function isEpsEnabled(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* EPS 接口元数据(按模块分组)
|
|
8
|
+
* - admin → GET /admin/base/open/eps
|
|
9
|
+
* - app → GET /app/base/open/eps
|
|
10
|
+
*/
|
|
11
|
+
export declare const Eps: {
|
|
12
|
+
controllers: typeof listControllers;
|
|
13
|
+
admin: () => EpsModuleMap;
|
|
14
|
+
app: () => EpsModuleMap;
|
|
15
|
+
enabled: typeof isEpsEnabled;
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Eps, isEpsEnabled } from './eps';
|
|
2
|
+
export type { EpsApiItem, EpsColumn, EpsEntity, EpsModuleMap } from './eps';
|
|
3
|
+
export { BaseController, RES_CODE } from './base';
|
|
4
|
+
export type { ApiFail, ApiResult, ApiSuccess, ResCode } from './base';
|
|
5
|
+
export { Controller, Get, Post, Put, Delete, Patch, Body, Query, Param, Public, Perms, IgnorePerms, Use, } from './decorators';
|
|
6
|
+
export { listControllers, type ControllerMeta, type ControllerRouteMeta, type ControllerSide, type HttpMethod, type RouteParamMeta, type RouteParamSource, } from './metadata';
|
|
7
|
+
export type { ControllerCrudOptions, CrudApi, CrudBeforeFn, InsertParamFn, QueryExtendFn, QueryExtendQb, QueryFieldRef, QueryJoin, QueryJoinType, QueryOp, QueryOpCtx, QueryWhereFn, QueryWhereResult, RouteMiddleware, } from '../../typings/routing/crud';
|
|
8
|
+
export type { CrudRegistrar } from './register';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ControllerCrudOptions, RouteMiddleware } from '../../typings/routing/crud';
|
|
3
|
+
import type { ControllerMeta, ControllerRouteMeta, ControllerSide, HttpMethod, RouteParamMeta, RouteParamSource } from '../../typings/routing/meta';
|
|
4
|
+
export type { ControllerMeta, ControllerRouteMeta, ControllerSide, HttpMethod, RouteParamMeta, RouteParamSource, };
|
|
5
|
+
export declare function registerController(meta: ControllerMeta): void;
|
|
6
|
+
export declare function listControllers(side?: ControllerSide): ControllerMeta[];
|
|
7
|
+
export declare function appendRouteParam(token: new (...args: unknown[]) => unknown, handler: string, param: RouteParamMeta): void;
|
|
8
|
+
export declare function getRouteParams(token: new (...args: unknown[]) => unknown, handler: string): RouteParamMeta[];
|
|
9
|
+
export declare function clearRouteParams(token: new (...args: unknown[]) => unknown): void;
|
|
10
|
+
export declare function markRoutePublic(token: new (...args: unknown[]) => unknown, handler: string): void;
|
|
11
|
+
export declare function isRoutePublic(token: new (...args: unknown[]) => unknown, handler: string): boolean;
|
|
12
|
+
export declare function clearRoutePublic(token: new (...args: unknown[]) => unknown): void;
|
|
13
|
+
export declare function appendRouteMiddleware(token: new (...args: unknown[]) => unknown, handler: string, middleware: RouteMiddleware[]): void;
|
|
14
|
+
export declare function getRouteMiddleware(token: new (...args: unknown[]) => unknown, handler: string): RouteMiddleware[];
|
|
15
|
+
export declare function clearRouteMiddleware(token: new (...args: unknown[]) => unknown): void;
|
|
16
|
+
export declare function setRoutePerms(token: new (...args: unknown[]) => unknown, handler: string, perms: string[]): void;
|
|
17
|
+
export declare function getRoutePerms(token: new (...args: unknown[]) => unknown, handler: string): string[] | undefined;
|
|
18
|
+
export declare function clearRoutePerms(token: new (...args: unknown[]) => unknown): void;
|
|
19
|
+
export declare function markRouteIgnorePerms(token: new (...args: unknown[]) => unknown, handler: string): void;
|
|
20
|
+
export declare function isRouteIgnorePerms(token: new (...args: unknown[]) => unknown, handler: string): boolean;
|
|
21
|
+
export declare function clearRouteIgnorePerms(token: new (...args: unknown[]) => unknown): void;
|
|
22
|
+
export declare function schemaFromParams(params: RouteParamMeta[]): {
|
|
23
|
+
body?: unknown;
|
|
24
|
+
query?: unknown;
|
|
25
|
+
params?: unknown;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** @internal 供装饰器写入 CRUD 选项时使用 */
|
|
28
|
+
export type { ControllerCrudOptions, RouteMiddleware };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ControllerSide } from './metadata';
|
|
2
|
+
/**
|
|
3
|
+
* OpenAPI 操作 tag(全局唯一)
|
|
4
|
+
* 侧栏展示名靠 x-displayName = admin | app,勿用 `/`(Scalar 会显示成整串)
|
|
5
|
+
*/
|
|
6
|
+
export declare function openApiTag(module: string, side: ControllerSide): string;
|
|
7
|
+
/**
|
|
8
|
+
* 侧栏结构:
|
|
9
|
+
* base ← x-tagGroups(一级:模块名)
|
|
10
|
+
* admin ← tag + x-displayName(二级)
|
|
11
|
+
* app
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildOpenApiTagDocs(): {
|
|
14
|
+
tags: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
'x-displayName': string;
|
|
18
|
+
}[];
|
|
19
|
+
tagGroups: {
|
|
20
|
+
name: string;
|
|
21
|
+
tags: string[];
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** 路由前缀 / 路径拼接(register / eps / decorators 共用) */
|
|
2
|
+
export declare function normalizePrefix(prefix: string): string;
|
|
3
|
+
export declare function joinPrefix(...parts: string[]): string;
|
|
4
|
+
/** 从完整路由路径拆出相对 controller prefix 的子路径 */
|
|
5
|
+
export declare function getRouteSubPath(routePath: string, controllerPrefix: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ControllerMeta, ControllerRouteMeta } from '../../typings/routing/meta';
|
|
2
|
+
/**
|
|
3
|
+
* 由模块 + Controller prefix + action 推导权限码
|
|
4
|
+
* - /menu + module base → base:menu:add
|
|
5
|
+
* - /user-role + module user → user:role:add
|
|
6
|
+
* - /base/menu(自动前缀)→ base:menu:add
|
|
7
|
+
* - /user/user-role → user:role:add
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveRoutePerm(module: string, prefix: string, action: string): string;
|
|
10
|
+
/** 路由子路径最后一段作为 action(/tree → tree) */
|
|
11
|
+
export declare function actionFromSubPath(subPath: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* admin 非公开路由的有效权限码:
|
|
14
|
+
* 显式 @Perms → 用显式;否则按约定推导;Public / IgnorePerms → 无
|
|
15
|
+
*/
|
|
16
|
+
export declare function effectivePerms(route: Pick<ControllerRouteMeta, 'public' | 'ignorePerms' | 'perms'> & {
|
|
17
|
+
path?: string;
|
|
18
|
+
}, meta: Pick<ControllerMeta, 'side' | 'module' | 'prefix'>, action?: string): string[] | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AnyElysia } from 'elysia';
|
|
2
|
+
import type { CrudRegistrar, CrudRouteOptionsInput } from '../../typings/routing/register';
|
|
3
|
+
export type { CrudRegistrar, CrudRouteOptionsInput };
|
|
4
|
+
/** @internal 宿主注册 CRUD 实现 */
|
|
5
|
+
export declare function setCrudRegistrar(fn: CrudRegistrar | undefined): void;
|
|
6
|
+
/** 扫描元数据并注册 Elysia 路由(须在 bootstrapIoc 之后调用) */
|
|
7
|
+
export declare function registerControllers(app: AnyElysia, vomeConfig: Record<string, unknown>): AnyElysia;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vome-core/server — Bun + Elysia 服务端框架入口
|
|
3
|
+
*
|
|
4
|
+
* 导入时加载宿主 `src/config`;扫描 / IoC / 路由注册在 `App.start()` 中执行。
|
|
5
|
+
* 宿主须:`import 'reflect-metadata'`,并开启 `experimentalDecorators` + `emitDecoratorMetadata`。
|
|
6
|
+
*/
|
|
7
|
+
export { App, appendInjectMeta, BaseController, Body, CommException, Context, Controller, Delete, Eps, isEpsEnabled, Get, getEnv, Inject, Ioc, isCommException, listControllers, listProviders, Logger, Param, Patch, Post, Provide, Public, Perms, IgnorePerms, Put, Query, RES_CODE, scanFiles, ScopeEnum, Use, vome, VomeConfig, DbStore, baseColumns, BASE_COLUMN_COMMENTS, entitySchemas, columnComments, getColumnComments, syncColumnCommentsToPg, Repository, getRepository, InjectRepository, BaseService, q, attachCrudRoutes, isTenantEnabled, noTenant, normalizeHost, resolveTenantScope, tableHasDepartmentId, resolveDataScope, applyDataScopeWhere, applyRowScopes, noDataScope, BasePlugin, loadPluginClass, readPluginScript, pDataPath, pPluginPath, pModulesPath, pModulePath, ModuleRegistry, loadModuleHandlers, microApps, createModuleGateway, defineAuthMacro, } from '../core';
|
|
8
|
+
export type { ApiFail, ApiResult, ApiSuccess, ClassToken, ContextData, ControllerCrudOptions, ControllerMeta, ControllerRouteMeta, ControllerSide, CrudApi, CrudBeforeFn, CrudRegistrar, CrudUpsertMode, CrudModifyType, CrudWriteOptions, CrudTrashQueryOptions, CrudDeleteOptions, PageQuery, PagePagination, PageResult, PluginManifest, PluginInfo, PluginPayload, PluginCheckResult, ModuleRouteDef, ModuleMenuDef, ModuleManifest, ModuleHandlerCtx, ModuleHandler, ModuleInstalled, EpsApiItem, EpsColumn, EpsEntity, EpsModuleMap, HttpMethod, InjectionToken, InjectMeta, InsertParamFn, ProvideOptions, ProviderToken, QueryExtendFn, QueryExtendQb, QueryFieldRef, QueryJoin, QueryJoinType, QueryOp, QueryOpCtx, QueryWhereFn, QueryWhereResult, ResCode, RouteMiddleware, RouteParamMeta, RouteParamSource, ScanOptions, } from '../core';
|
|
9
|
+
/** 与 package.json version 同步 */
|
|
10
|
+
export declare const version: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 同构共享:前后端均可引用(无 Bun / Elysia / Vue 依赖)
|
|
3
|
+
*/
|
|
4
|
+
export { merge } from '../comm/merge';
|
|
5
|
+
export { deepTree, flattenTree } from './tree';
|
|
6
|
+
export type { Loose } from '../../typings/common';
|
|
7
|
+
export type { PageQuery, PagePagination, PageResult } from '../../typings/comm/page';
|
|
8
|
+
export { RES_CODE, type ResCode, type ApiSuccess, type ApiFail, type ApiResult, } from '../routing/base';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** 扁平列表 → 树(parentId) */
|
|
2
|
+
export declare function deepTree<T extends {
|
|
3
|
+
id?: number | string;
|
|
4
|
+
parentId?: number | string | null;
|
|
5
|
+
children?: T[];
|
|
6
|
+
orderNum?: number;
|
|
7
|
+
}>(list: T[], sort?: 'asc' | 'desc'): T[];
|
|
8
|
+
/** 树 → 扁平(带 depth / hasChildren),按 expanded 展开 */
|
|
9
|
+
export declare function flattenTree<T extends {
|
|
10
|
+
id: number | string;
|
|
11
|
+
children?: T[];
|
|
12
|
+
}>(nodes: T[], expanded: Set<string | number>, depth?: number, out?: Array<T & {
|
|
13
|
+
depth: number;
|
|
14
|
+
hasChildren: boolean;
|
|
15
|
+
}>): Array<T & {
|
|
16
|
+
depth: number;
|
|
17
|
+
hasChildren: boolean;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** save:有 id 则更新;insert:只插入 */
|
|
2
|
+
export type CrudUpsertMode = 'save' | 'insert';
|
|
3
|
+
/** modifyBefore / modifyAfter 操作类型 */
|
|
4
|
+
export type CrudModifyType = 'add' | 'update' | 'delete';
|
|
5
|
+
/** add() 可选覆盖 */
|
|
6
|
+
export type CrudWriteOptions = {
|
|
7
|
+
upsert?: CrudUpsertMode;
|
|
8
|
+
};
|
|
9
|
+
/** 查询回收站范围 */
|
|
10
|
+
export type CrudTrashQueryOptions = {
|
|
11
|
+
withTrashed?: boolean;
|
|
12
|
+
onlyTrashed?: boolean;
|
|
13
|
+
softDelete?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** 删除选项 */
|
|
16
|
+
export type CrudDeleteOptions = {
|
|
17
|
+
force?: boolean;
|
|
18
|
+
softDelete?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** vome.crud 运行时配置 */
|
|
21
|
+
export type CrudConfig = {
|
|
22
|
+
upsert?: CrudUpsertMode;
|
|
23
|
+
softDelete?: boolean;
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 分页参数 */
|
|
2
|
+
export type PageQuery = {
|
|
3
|
+
/** 页码,从 1 开始,默认 1 */
|
|
4
|
+
page?: number;
|
|
5
|
+
/** 每页条数,默认 20 */
|
|
6
|
+
size?: number;
|
|
7
|
+
};
|
|
8
|
+
export type PagePagination = {
|
|
9
|
+
page: number;
|
|
10
|
+
size: number;
|
|
11
|
+
total: number;
|
|
12
|
+
};
|
|
13
|
+
export type PageResult<T = unknown> = {
|
|
14
|
+
list: T[];
|
|
15
|
+
pagination: PagePagination;
|
|
16
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type ModuleRouteDef = {
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
handler: string;
|
|
5
|
+
perms?: string;
|
|
6
|
+
summary?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ModuleMenuDef = {
|
|
9
|
+
name: string;
|
|
10
|
+
router?: string;
|
|
11
|
+
perms?: string;
|
|
12
|
+
type?: number;
|
|
13
|
+
icon?: string;
|
|
14
|
+
orderNum?: number;
|
|
15
|
+
appKey?: string;
|
|
16
|
+
isShow?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ModuleManifest = {
|
|
19
|
+
name: string;
|
|
20
|
+
key: string;
|
|
21
|
+
version: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
hook?: string;
|
|
24
|
+
config?: Record<string, unknown>;
|
|
25
|
+
singleton?: boolean;
|
|
26
|
+
author?: string;
|
|
27
|
+
logo?: string;
|
|
28
|
+
readme?: string;
|
|
29
|
+
routes?: ModuleRouteDef[];
|
|
30
|
+
menus?: ModuleMenuDef[];
|
|
31
|
+
};
|
|
32
|
+
export type ModuleHandlerCtx = {
|
|
33
|
+
body: unknown;
|
|
34
|
+
query: Record<string, string>;
|
|
35
|
+
params: Record<string, string>;
|
|
36
|
+
headers: Headers;
|
|
37
|
+
adminId?: number | string;
|
|
38
|
+
};
|
|
39
|
+
export type ModuleHandler = (ctx: ModuleHandlerCtx) => unknown | Promise<unknown>;
|
|
40
|
+
export type ModuleInstalled = ModuleManifest & {
|
|
41
|
+
path: string;
|
|
42
|
+
hasServer: boolean;
|
|
43
|
+
hasWeb: boolean;
|
|
44
|
+
hasHook: boolean;
|
|
45
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type PluginManifest = {
|
|
2
|
+
name: string;
|
|
3
|
+
key: string;
|
|
4
|
+
hook?: string;
|
|
5
|
+
singleton?: boolean;
|
|
6
|
+
version: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
author?: string;
|
|
9
|
+
logo?: string;
|
|
10
|
+
readme?: string;
|
|
11
|
+
config?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type PluginInfo = PluginManifest & {
|
|
14
|
+
config?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
export type PluginPayload = {
|
|
17
|
+
content: {
|
|
18
|
+
type: 'comm' | 'module';
|
|
19
|
+
data: string;
|
|
20
|
+
};
|
|
21
|
+
tsContent: {
|
|
22
|
+
type: 'ts';
|
|
23
|
+
data: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type PluginCheckResult = {
|
|
27
|
+
type: 0 | 1 | 2 | 3;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
export type PluginServices = {
|
|
31
|
+
cache?: {
|
|
32
|
+
get: (key: string) => Promise<unknown>;
|
|
33
|
+
set: (key: string, value: unknown) => Promise<unknown>;
|
|
34
|
+
del: (key: string) => Promise<unknown>;
|
|
35
|
+
};
|
|
36
|
+
pluginService?: {
|
|
37
|
+
getInstance: (key: string) => Promise<unknown>;
|
|
38
|
+
invoke: (key: string, method: string, ...params: unknown[]) => Promise<unknown>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** IoC 作用域 */
|
|
2
|
+
export type ScopeValue = 'singleton' | 'request' | 'prototype';
|
|
3
|
+
/** 可 new 的 Provider 类 */
|
|
4
|
+
export type ClassToken<T = unknown> = abstract new (...args: any[]) => T;
|
|
5
|
+
/**
|
|
6
|
+
* 注入标识:类 / 字符串 id / symbol
|
|
7
|
+
* 字符串 id 用于跨模块按名注入
|
|
8
|
+
*/
|
|
9
|
+
export type InjectionToken<T = unknown> = ClassToken<T> | string | symbol;
|
|
10
|
+
/** @deprecated 使用 {@link ClassToken} */
|
|
11
|
+
export type ProviderToken<T = unknown> = ClassToken<T>;
|
|
12
|
+
export type InjectMeta = {
|
|
13
|
+
propertyKey: string | symbol;
|
|
14
|
+
/** 依赖标识;与 resolve 二选一 */
|
|
15
|
+
token?: InjectionToken;
|
|
16
|
+
/** 自定义解析(如 Repository) */
|
|
17
|
+
resolve?: () => unknown;
|
|
18
|
+
};
|
|
19
|
+
export type ProviderMeta = {
|
|
20
|
+
/** 注册键(类或自定义 id) */
|
|
21
|
+
token: InjectionToken;
|
|
22
|
+
/** 实际用来 new 的类 */
|
|
23
|
+
useClass: ClassToken;
|
|
24
|
+
scope: ScopeValue;
|
|
25
|
+
};
|
|
26
|
+
export type ProvideOptions = {
|
|
27
|
+
/** 自定义标识,可用 `@Inject('id')` / `Ioc.get('id')` */
|
|
28
|
+
id?: string | symbol;
|
|
29
|
+
/** 作用域,默认 singleton */
|
|
30
|
+
scope?: ScopeValue;
|
|
31
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ClassToken } from '../ioc/metadata';
|
|
2
|
+
/** 快速 CRUD 接口名(含回收站) */
|
|
3
|
+
export type CrudApi = 'add' | 'delete' | 'update' | 'info' | 'list' | 'page' | 'restore';
|
|
4
|
+
/** 字段引用:表字段名,或带字典 / 前端行为的对象 */
|
|
5
|
+
export type QueryFieldRef = string | {
|
|
6
|
+
column: string;
|
|
7
|
+
/** 请求体参数名,默认与 column 相同 */
|
|
8
|
+
requestParam?: string;
|
|
9
|
+
/** 筛选项展示名;缺省用实体 columnComments / EPS comment */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** 业务字典 type.key;筛选项用其拉 options */
|
|
12
|
+
dict?: string;
|
|
13
|
+
/** 有 dict 时默认 true(下拉多选);false 为单选 */
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
/** true:后端仍按本字段筛选,admin 不自动构建筛控件 */
|
|
16
|
+
none?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** 区间筛选精度 / 数字类型(告诉 admin 用什么控件) */
|
|
19
|
+
export type FieldRangeType = 'int' | 'float' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
|
|
20
|
+
/** 价格 / 时间等区间;min/max 为请求体参数名 */
|
|
21
|
+
export type QueryFieldRange = {
|
|
22
|
+
column: string;
|
|
23
|
+
min: string;
|
|
24
|
+
max: string;
|
|
25
|
+
type: FieldRangeType;
|
|
26
|
+
/** true:后端支持区间,admin 不自动出控件 */
|
|
27
|
+
none?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** join 类型 */
|
|
30
|
+
export type QueryJoinType = 'join' | 'leftJoin' | 'innerJoin';
|
|
31
|
+
/**
|
|
32
|
+
* Join 配置(宿主解释为 Drizzle pgTable)
|
|
33
|
+
* `on(main)` 返回 SQL 条件,main 为主表
|
|
34
|
+
*/
|
|
35
|
+
export type QueryJoin = {
|
|
36
|
+
table: unknown;
|
|
37
|
+
type?: QueryJoinType;
|
|
38
|
+
on: (main: any) => unknown;
|
|
39
|
+
};
|
|
40
|
+
/** where / extend 上下文 */
|
|
41
|
+
export type QueryOpCtx = {
|
|
42
|
+
body: Record<string, unknown>;
|
|
43
|
+
request: Request;
|
|
44
|
+
};
|
|
45
|
+
/** where 返回:单条 SQL,或列表(undefined/false/null 自动丢弃) */
|
|
46
|
+
export type QueryWhereResult = unknown | Array<unknown | undefined | false | null>;
|
|
47
|
+
export type QueryWhereFn = (ctx: QueryOpCtx) => QueryWhereResult | Promise<QueryWhereResult>;
|
|
48
|
+
/** extend 可改的查询句柄 */
|
|
49
|
+
export type QueryExtendQb = {
|
|
50
|
+
andWhere: (condition: unknown) => void;
|
|
51
|
+
orderBy: (...orders: unknown[]) => void;
|
|
52
|
+
};
|
|
53
|
+
export type QueryExtendFn = (qb: QueryExtendQb, ctx: QueryOpCtx) => void | Promise<void>;
|
|
54
|
+
/** page / list 查询配置 */
|
|
55
|
+
export type QueryOp = {
|
|
56
|
+
keyWordLikeFields?: string[];
|
|
57
|
+
fieldEq?: QueryFieldRef[];
|
|
58
|
+
fieldLike?: QueryFieldRef[];
|
|
59
|
+
/** PG 数组列包含查询(body 单值或数组);admin 筛选用输入框 */
|
|
60
|
+
fieldArray?: QueryFieldRef[];
|
|
61
|
+
/** 数字 / 时间区间(与 fieldEq 等并存,勿再在 where 里拆参) */
|
|
62
|
+
fieldRange?: QueryFieldRange[];
|
|
63
|
+
addOrderBy?: Record<string, 'asc' | 'desc'>;
|
|
64
|
+
/** Drizzle select 对象;有 join 时建议显式配置 */
|
|
65
|
+
select?: unknown;
|
|
66
|
+
join?: QueryJoin[];
|
|
67
|
+
where?: QueryWhereFn;
|
|
68
|
+
extend?: QueryExtendFn;
|
|
69
|
+
};
|
|
70
|
+
export type InsertParamFn = (ctx: {
|
|
71
|
+
body?: unknown;
|
|
72
|
+
request?: Request;
|
|
73
|
+
}) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
74
|
+
/** 写操作前钩子(add / update / delete / restore) */
|
|
75
|
+
export type CrudBeforeFn = (ctx: {
|
|
76
|
+
body: Record<string, unknown>;
|
|
77
|
+
request: Request;
|
|
78
|
+
api: string;
|
|
79
|
+
}) => void | Promise<void>;
|
|
80
|
+
/** 控制器 / 路由中间件(Elysia onBeforeHandle) */
|
|
81
|
+
export type RouteMiddleware = (ctx: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* @Controller 快速 CRUD 选项(Drizzle 适配)
|
|
84
|
+
*/
|
|
85
|
+
export type ControllerCrudOptions = {
|
|
86
|
+
api?: CrudApi[];
|
|
87
|
+
/** Drizzle pgTable,宿主挂载 Repository */
|
|
88
|
+
entity?: unknown;
|
|
89
|
+
/** 业务 Service 类(须 @Provide,建议 extends BaseService) */
|
|
90
|
+
service?: ClassToken;
|
|
91
|
+
/** 把 Service 方法挂成 POST /methodName */
|
|
92
|
+
serviceApis?: string[];
|
|
93
|
+
/** 写操作前改 body(add/update/delete/restore) */
|
|
94
|
+
before?: CrudBeforeFn;
|
|
95
|
+
pageQueryOp?: QueryOp;
|
|
96
|
+
listQueryOp?: QueryOp;
|
|
97
|
+
insertParam?: InsertParamFn;
|
|
98
|
+
infoIgnoreProperty?: string[];
|
|
99
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { QueryFieldRange, QueryFieldRef } from './crud';
|
|
2
|
+
import type { ControllerSide } from './meta';
|
|
3
|
+
/** EPS:单条 API */
|
|
4
|
+
export type EpsApiItem = {
|
|
5
|
+
method: string;
|
|
6
|
+
path: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
dts: Record<string, unknown>;
|
|
9
|
+
tag: string;
|
|
10
|
+
prefix: string;
|
|
11
|
+
ignoreToken: boolean;
|
|
12
|
+
/** 强化:登录但免权限码 */
|
|
13
|
+
ignorePerms: boolean;
|
|
14
|
+
/** 强化:推导/显式权限码 */
|
|
15
|
+
perms: string[];
|
|
16
|
+
};
|
|
17
|
+
/** EPS:字段列 */
|
|
18
|
+
export type EpsColumn = {
|
|
19
|
+
propertyName: string;
|
|
20
|
+
type: string;
|
|
21
|
+
length?: string;
|
|
22
|
+
comment?: string;
|
|
23
|
+
nullable?: boolean;
|
|
24
|
+
defaultValue?: unknown;
|
|
25
|
+
source?: string;
|
|
26
|
+
dict?: string | string[];
|
|
27
|
+
};
|
|
28
|
+
/** EPS:单个控制器/实体描述 */
|
|
29
|
+
export type EpsEntity = {
|
|
30
|
+
module: string;
|
|
31
|
+
/** 强化:admin | app */
|
|
32
|
+
side: ControllerSide;
|
|
33
|
+
prefix: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
info: {
|
|
36
|
+
type: {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
api: EpsApiItem[];
|
|
42
|
+
columns: EpsColumn[];
|
|
43
|
+
pageQueryOp: {
|
|
44
|
+
keyWordLikeFields: string[];
|
|
45
|
+
fieldEq: Array<string | QueryFieldRef>;
|
|
46
|
+
fieldLike: Array<string | QueryFieldRef>;
|
|
47
|
+
fieldArray: Array<string | QueryFieldRef>;
|
|
48
|
+
fieldRange: QueryFieldRange[];
|
|
49
|
+
};
|
|
50
|
+
pageColumns: EpsColumn[];
|
|
51
|
+
};
|
|
52
|
+
/** EPS:按模块分组 */
|
|
53
|
+
export type EpsModuleMap = Record<string, EpsEntity[]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ControllerCrudOptions, RouteMiddleware } from './crud';
|
|
2
|
+
export type ControllerSide = 'admin' | 'app';
|
|
3
|
+
/** @Controller() 装饰器选项 */
|
|
4
|
+
export type ControllerOptions = {
|
|
5
|
+
/** 路由前缀,如 `/auth`;也可用字符串参数简写 */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
side?: ControllerSide;
|
|
8
|
+
module?: string;
|
|
9
|
+
/** EPS / OpenAPI 描述 */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** 控制器级中间件 */
|
|
12
|
+
middleware?: RouteMiddleware | RouteMiddleware[];
|
|
13
|
+
} & ControllerCrudOptions;
|
|
14
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
15
|
+
export type RouteParamSource = 'body' | 'query' | 'params';
|
|
16
|
+
/** handler 参数装饰器元数据(@Body / @Query / @Param) */
|
|
17
|
+
export type RouteParamMeta = {
|
|
18
|
+
index: number;
|
|
19
|
+
source: RouteParamSource;
|
|
20
|
+
schema?: unknown;
|
|
21
|
+
};
|
|
22
|
+
/** 路由元数据 */
|
|
23
|
+
export type ControllerRouteMeta = {
|
|
24
|
+
method: HttpMethod;
|
|
25
|
+
path: string;
|
|
26
|
+
handler: string;
|
|
27
|
+
body?: unknown;
|
|
28
|
+
query?: unknown;
|
|
29
|
+
routeParams?: unknown;
|
|
30
|
+
params?: RouteParamMeta[];
|
|
31
|
+
public?: boolean;
|
|
32
|
+
summary?: string;
|
|
33
|
+
/** 单路由中间件 */
|
|
34
|
+
middleware?: RouteMiddleware[];
|
|
35
|
+
/** 权限码(任一即可);未设且非 IgnorePerms 时由路由自动推导 */
|
|
36
|
+
perms?: string[];
|
|
37
|
+
/** 跳过权限码校验(仍可要求登录) */
|
|
38
|
+
ignorePerms?: boolean;
|
|
39
|
+
/** 框架自动 CRUD 路由 */
|
|
40
|
+
autoCrud?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** 控制器元数据 */
|
|
43
|
+
export type ControllerMeta = {
|
|
44
|
+
token: new (...args: unknown[]) => unknown;
|
|
45
|
+
module: string;
|
|
46
|
+
side: ControllerSide;
|
|
47
|
+
prefix: string;
|
|
48
|
+
/** OpenAPI / EPS 描述 */
|
|
49
|
+
description?: string;
|
|
50
|
+
file?: string;
|
|
51
|
+
routes: ControllerRouteMeta[];
|
|
52
|
+
/** 控制器级中间件(该 plugin 下全部路由) */
|
|
53
|
+
middleware?: RouteMiddleware[];
|
|
54
|
+
/** 快速 CRUD 配置 */
|
|
55
|
+
crud?: ControllerCrudOptions;
|
|
56
|
+
};
|