v0.7.14
This commit is contained in:
Vendored
+109
-30
@@ -1,33 +1,112 @@
|
||||
import React from 'react';
|
||||
import { WidgetType, WidgetContainerProps } from './button';
|
||||
|
||||
/**
|
||||
* 按一串中间件(middleware)链式转换数据;每个中间件可以是函数,也可以是要动态加载的
|
||||
* 组件名字符串(通过 core.getWidgetComponent 解析),支持嵌套数组表示的中间件组
|
||||
*/
|
||||
declare class DataConverter {
|
||||
static "__#private@#resolver": any;
|
||||
static "__#private@#newMiddleware": any;
|
||||
/**
|
||||
* @param {...(Array|[string|Function, *])} middlewares 中间件列表,每项是
|
||||
* [中间件名或函数, 传给中间件的配置],或者是这种元组的嵌套数组(会被展开)
|
||||
*/
|
||||
constructor(...middlewares: (any[] | [string | Function, any])[]);
|
||||
/**
|
||||
* 依次跑完所有中间件,把 value 转换成最终结果;单个中间件报错会被跳过,不中断整条链
|
||||
* @param {*} value 原始值
|
||||
* @param {*} [record] 关联的记录数据,中间件里可通过 this.getRecord() 取到
|
||||
* @returns {Promise<*>} 转换后的结果
|
||||
*/
|
||||
toValue: (value: any, record?: any) => Promise<any>;
|
||||
/**
|
||||
* 把 toValue 的异步转换结果渲染成 React 元素;转换完成前显示 loading,转换出错则显示错误信息
|
||||
* @param {*} value 原始值
|
||||
* @param {*} record 关联的记录数据
|
||||
* @param {*} [loading] 转换完成前显示的占位内容
|
||||
* @returns {React.ReactElement}
|
||||
*/
|
||||
toRender: (value: any, record: any, loading?: any) => React.ReactElement;
|
||||
#private;
|
||||
// ===== 用户数据结构(复用类型,JSDoc 无法跨文件引用,放 .d.ts) =====
|
||||
|
||||
interface UserRoleBinding {
|
||||
user_uuid: string
|
||||
role_uuid: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
created_user: string
|
||||
owned_user: string
|
||||
}
|
||||
|
||||
export { DataConverter as default };
|
||||
interface UserInfo {
|
||||
uuid: string
|
||||
username: string
|
||||
nickname: string
|
||||
email: string
|
||||
last_login_ip: string
|
||||
is_active: 0 | 1
|
||||
UserRole: UserRoleBinding[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
|
||||
interface MenuItem {
|
||||
/** 菜单唯一标识 */
|
||||
uuid: string
|
||||
/** 菜单显示名称 */
|
||||
name: string
|
||||
/** 图标 class 名 */
|
||||
icon: string
|
||||
/** 行为目标(组件标识 / 路由 uuid 等),含义随 widgetType 而定 */
|
||||
widget: string
|
||||
/** 行为类型 */
|
||||
widgetType: WidgetType
|
||||
/** 传给目标组件的 props 映射配置 */
|
||||
widgetProps: Record<string, unknown>
|
||||
/** 传给目标组件的 $setting 配置 */
|
||||
widgetSetting: Record<string, unknown>
|
||||
/** 弹窗容器配置 */
|
||||
widgetContainerSetting: WidgetContainerProps
|
||||
/** 子菜单 */
|
||||
children?: MenuItem[]
|
||||
}
|
||||
|
||||
interface RouteItem {
|
||||
/** 路由唯一标识 */
|
||||
uuid: string
|
||||
/** 路由名称 */
|
||||
name: string
|
||||
/** react-router path,支持动态参数(如 /page/:id) */
|
||||
uri: string
|
||||
/** 是否为布局路由(外层 layout,不直接渲染页面内容) */
|
||||
isLayout: boolean
|
||||
/** 是否需要登录才能访问 */
|
||||
isLogin: boolean
|
||||
/** 是否为手机端专属路由 */
|
||||
isPhone: boolean
|
||||
/** 路由类型 */
|
||||
type: Exclude<WidgetType, 'redirect'>
|
||||
/** 是否精确匹配路径 */
|
||||
exact: boolean
|
||||
/** widget 标识(等同于 ButtonProps.widget),经 core.getWidgetComponent 加载 */
|
||||
component: string
|
||||
/** 传给页面组件的 props 映射配置 */
|
||||
widgetProps: Record<string, unknown>
|
||||
/** 传给页面组件的 $setting 配置 */
|
||||
widgetSetting: Record<string, unknown>
|
||||
/** 弹窗容器配置 */
|
||||
widgetContainerSetting: WidgetContainerProps
|
||||
/** 附加配置(如 layout 标识等) */
|
||||
extra?: Record<string, unknown>
|
||||
}
|
||||
|
||||
// ===== http — Proxy 模式产生交叉类型,JSDoc 无法表达 =====
|
||||
|
||||
/** 每次请求自动附加的请求头 */
|
||||
interface HttpHeaders {
|
||||
/** 客户端平台标识,固定为 'web' */
|
||||
Platform: string
|
||||
/** SaaS 租户标识,单租户时为 null */
|
||||
SaaS: string | null
|
||||
/** JWT Bearer token,未登录时为 undefined */
|
||||
Authorization: string | undefined
|
||||
}
|
||||
|
||||
// ===== func — ff-worker-pipe 无类型文件,显式声明 =====
|
||||
|
||||
/**
|
||||
* 基于 Worker 的表达式执行引擎单例;
|
||||
* exec 在独立 Worker 上下文中求值一段 JS 表达式/源码
|
||||
*/
|
||||
interface WorkerPipeInstance {
|
||||
/**
|
||||
* 在 Worker 上下文中执行一段 JS 表达式
|
||||
* @param expression 要执行的表达式字符串
|
||||
* @param args 传给表达式的参数(可在表达式内作为第一个参数使用)
|
||||
* @param fns 注入到表达式执行作用域的额外可调用函数
|
||||
* @param session 会话标识;相同 session 共享 Worker 侧工作区(this)
|
||||
*/
|
||||
exec: (
|
||||
expression: string,
|
||||
args?: Record<string, unknown>,
|
||||
fns?: Record<string, Function>,
|
||||
session?: string
|
||||
) => Promise<unknown>
|
||||
/** 清除指定 session 的 Worker 侧工作区 */
|
||||
clear: (session: string) => void
|
||||
}
|
||||
|
||||
export type { HttpHeaders, MenuItem, RouteItem, UserInfo, UserRoleBinding, WorkerPipeInstance };
|
||||
|
||||
Reference in New Issue
Block a user