@geelato/gl-types 1.0.0

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.
@@ -0,0 +1,8 @@
1
+ export * from './types/plugin'
2
+ export * from './types/schema/action'
3
+ export * from './types/schema/method'
4
+ export * from './types/schema/componentMeta'
5
+ export * from './types/schema/componentInstance'
6
+ export * from './types/schema/componentMaterial'
7
+ export * from './types/schema/schema'
8
+ export * from './types/ide/ide'
@@ -0,0 +1,70 @@
1
+ export interface IPanel {
2
+ // 唯一标识
3
+ name: string;
4
+ // 显示名称
5
+ title: string;
6
+ // 面板图标
7
+ iconType: string;
8
+ // 面板对应的全局注册组件名
9
+ componentName: string;
10
+ // 面板的顺序,默认为0,值超小的排在前面,值大的排在后面
11
+ index?: number;
12
+ // 面板打开的位置,默认为"sidebar"
13
+ target?: "sidebar" | "blank";
14
+ }
15
+
16
+ export interface IPanelOptions {
17
+ title: string;
18
+ name: string;
19
+ iconType: string;
20
+ componentName: string;
21
+ showSetterPanels?: string[];
22
+ }
23
+
24
+ /**
25
+ * 插件接口
26
+ * 在IDE中,插件是用于扩展IDE功能的模块,可以包含sidebar、stage、setter等面板,以及页面类型与设置面板的映射
27
+ */
28
+ export interface IIdePlugin {
29
+ // 插件的名称(唯一标识)
30
+ name: string;
31
+ // 插件的版本
32
+ version: string;
33
+ // 插件的描述
34
+ description?: string;
35
+ // 插件的作者
36
+ author?: string;
37
+ // 插件的类型
38
+ // type?: string
39
+ // 插件的sidebar面板
40
+ sidebar: Array<IPanel>;
41
+ // 插件的stage面板
42
+ stage: Array<IPanel>;
43
+ // 插件的setter面板
44
+ setter: Array<IPanel>;
45
+ // 页面类型与设置面板的映射,即选择什么页面类型时,相应的面板会被激活。key为pageType如flowPage
46
+ pageTypeSetterPanelNameMap: Record<string, string[]>;
47
+
48
+ // 获取面板
49
+ getPanels(panelType: string): Array<Panel> | undefined;
50
+
51
+ // 添加页面类型与设置面板的映射
52
+ pushPageTypeAndSetterPanelNames(pageType: string, panelNames: string[]): void;
53
+
54
+ // 获取页面类型对应的设置面板名称
55
+ getSetterPanelNamesByPageType(pageType: string): string[];
56
+ }
57
+
58
+ /**
59
+ * ide.html中,打开idePlugin.html时,会传递一些参数给插件
60
+ */
61
+ export interface IPluginSetupOptions {
62
+ // 插件中,作为展示的主组件名称
63
+ name: string;
64
+ // 当前应用的id
65
+ appId: string;
66
+ // 当前应用的名称
67
+ appName: string;
68
+ // 当前的租户编号
69
+ tenantCode: string;
70
+ }
@@ -0,0 +1,48 @@
1
+ import type { App } from 'vue'
2
+ import type { AxiosStatic, AxiosInstance } from 'axios'
3
+
4
+ export interface Item {
5
+ name: string;
6
+ }
7
+
8
+ export type ItemStatus = 'uninstalled' | 'installed'
9
+
10
+
11
+ export interface IPlugin extends Item{
12
+ /**
13
+ * 获取插件名称,唯一标识
14
+ */
15
+ name: string
16
+
17
+ /**
18
+ * 插件的版本
19
+ */
20
+ version: string
21
+
22
+ /**
23
+ * 插件的加载地址,如果为空,表示采用默认的服务端加载地址
24
+ */
25
+ url?: string
26
+
27
+ getI18nMessages(): I18nMessages
28
+
29
+ install(app: App, options: PluginOptions): void
30
+
31
+ uninstall(): void
32
+ }
33
+
34
+ export interface PluginOptions {
35
+ axios: AxiosStatic | AxiosInstance
36
+ ctx?: Record<string, any>
37
+ router?: any
38
+ pinia?: any
39
+
40
+ [key: string]: any
41
+ }
42
+
43
+
44
+ export type I18nMessages = {
45
+ 'zh-CN': Record<string, any>
46
+ 'en-US': Record<string, any>
47
+ [key: string]: any
48
+ }
@@ -0,0 +1,33 @@
1
+ import {IComponentInstance } from './componentInstance'
2
+
3
+ export interface IAction {
4
+ id?: string;
5
+ eventName: string;
6
+ name: string;
7
+ title: string;
8
+ body?: string;
9
+ __commandBlock?: IComponentInstance;
10
+ }
11
+
12
+ // 动作、方法调用参数元数据定义
13
+ export interface IParamMeta {
14
+ // 字段名
15
+ title: string;
16
+ // dataIndex
17
+ name: string;
18
+ // 是否必需
19
+ required: boolean;
20
+ // 类型
21
+ type: string;
22
+ // 需要求和的字段名称
23
+ description?: string;
24
+ // 详细介绍的文章id
25
+ docId?: string;
26
+ }
27
+
28
+ export interface IActionMeta {
29
+ name: string; // 必填,类型为 string
30
+ title: string; // 必填,类型为 string
31
+ description?: string; // 可选,类型为 string
32
+ params?: IParamMeta[]; // 可选,类型为 ParamMeta[]
33
+ }
@@ -0,0 +1,145 @@
1
+ import {IAction } from './action'
2
+
3
+ export interface I18nItem {
4
+ [key: string]: any
5
+ 'zh-CN': string
6
+ 'en-US': string
7
+ }
8
+
9
+ export interface FieldRule<FieldValue = any> {
10
+ type?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'email' | 'url' | 'ip';
11
+ required?: boolean;
12
+ message?: string;
13
+ length?: number;
14
+ maxLength?: number;
15
+ minLength?: number;
16
+ match?: RegExp;
17
+ uppercase?: boolean;
18
+ lowercase?: boolean;
19
+ min?: number;
20
+ max?: number;
21
+ equal?: number;
22
+ positive?: boolean;
23
+ negative?: boolean;
24
+ true?: boolean;
25
+ false?: boolean;
26
+ includes?: any[];
27
+ deepEqual?: any;
28
+ empty?: boolean;
29
+ hasKeys?: string[];
30
+ validator?: (value: FieldValue | undefined, callback: (error?: string) => void) => void;
31
+ }
32
+
33
+ /**
34
+ * 绑定字段
35
+ */
36
+ export interface IBindField {
37
+ appCode: string;
38
+ entityName: string;
39
+ fieldName: string;
40
+ }
41
+
42
+ /**
43
+ * 绑定实体
44
+ */
45
+ export interface IBindEntity {
46
+ appCode: string;
47
+ entityName: string;
48
+ }
49
+
50
+ export interface IComponentInstanceProps {
51
+ // 标题,如用于formItem的标题
52
+ label?: string;
53
+ // 绑定字段,对于输入组件,需要用到该属性
54
+ bindField?: IBindField;
55
+
56
+ // 组件个性化属性
57
+ [key: string]: any;
58
+
59
+ // 占位符
60
+ placeholder?: string;
61
+ // 描述
62
+ description?: string;
63
+ // 默认值表达式,在值为null或undefined时生效。注:应叫_defaultValue,名称上合理
64
+ _valueExpression?: any;
65
+ // 是否禁用
66
+ disabled?: boolean;
67
+ // 只读
68
+ readonly?: boolean;
69
+ // 是否渲染
70
+ unRender?: boolean;
71
+ // 是否隐藏(渲染但不可见)
72
+ _hidden?: boolean;
73
+ // 验证规则,适用于表单项组件,如AInput
74
+ rules?: FieldRule<any> | FieldRule<any>[];
75
+ }
76
+
77
+ /**
78
+ * "__"开头的属性用于以下场景:
79
+ * 1、动态产生用于内部计算使用
80
+ * 2、作为源代码属性且不需要在发布运行版本中出现
81
+ * 在保存为release版本时,"__"开头的属性会被删除掉,以减小文件的大小
82
+ * source版本,仍保存该属性信息
83
+ */
84
+ export interface IComponentInstance {
85
+ id: string;
86
+ // 创建id时的id前缀
87
+ __idPrefix?: string;
88
+ title?: string;
89
+ // 子标题,用于在设置面板中展示,特别是用于脚本编排组件中,子标题用于展示该脚本块实例的概要意图用途
90
+ __subTitle?: string
91
+ // 备注信息,用于在设置面板中展示,特别是用于脚本编排组件中,描述信息用于展示该脚本块实例的详细用途
92
+ __remark?: string;
93
+ componentName: string;
94
+ // 如dataEntry,可以用来区分是否为表单输入项,在渲染时展示label
95
+ group?: string;
96
+ // 组件的值绑定属性名,默认为modelValue,特殊的,如tabs为activeKey
97
+ vModelName?: string;
98
+ // 组件属性
99
+ props: IComponentInstanceProps;
100
+ // 属性值表达式,通过变量绑定、函数计算等,动态计算属性的值
101
+ propsExpressions?: IComponentInstanceProps;
102
+ slots: { [key: string]: any; propsTarget?: string; propsName?: string };
103
+ // 插槽值表达式,通过变量绑定、函数计算等,动态计算属性的值
104
+ slotsExpressions?: IComponentInstanceProps;
105
+ children: IComponentInstance[];
106
+ actions: IAction[];
107
+ // 额外,如用于GlCard
108
+ extra?: IComponentInstance;
109
+ style?: Object;
110
+ propsWrapper?: string;
111
+ // 多语言,表单配置中默认的为zh-CN,这里只需配置en-US,如果需要繁体,则可配置增加zh-TW或zh-HK
112
+ i18n?: I18nItem[];
113
+ // 运行时的值,如对于input等表单组件,可用于v-model绑定值
114
+ value?: undefined | string | number | boolean | object | Array<any>;
115
+ // 禁用拖放 默认为false,不禁止
116
+ // 如在渲染工作流画布的场景中,禁止工作流画布可拖动,可设置为true
117
+ disabledDnd?: boolean;
118
+ // 如在渲染工作流画布的场景中,禁止选择该组件,如点击选择无效,避免子组件冒泡触发
119
+ disabledSelect?: boolean;
120
+ // 映射引用的组件id,这个属性用于图元映射到组件实例的场景,如设计页面是一个工作流程图,图元的id映射到组件refId
121
+ refId?: string;
122
+ // 用于组件映射到外部的组件或外部的图元素等。如组件实例为GlPage时,可以在此存储当前页面对应的graph对象
123
+ refObject?: Object;
124
+ // 是否禁用,默认为启用,用于设计时
125
+ _disabled?: boolean;
126
+ // 是否为模板实例
127
+ __isTemplateInst?: boolean;
128
+ // 是否为组件的内置组件
129
+ __isInnerComponent?: boolean;
130
+ // 运行时产生,用于指令块组件
131
+ // 是否为被调用的指令块
132
+ __isInvokeBlock?: boolean;
133
+ // 作为被调用的指令块占位符
134
+ __invokeBlockPlaceholder?: string;
135
+ // 字段验证之后的错误信息
136
+ __validateError?: any;
137
+ // 拖动标识,通过监控该标识的变化,可以判断整个页面是否有变化
138
+ __dragFlag?: string;
139
+ // 脚本块
140
+ __commandBlock?: IComponentInstance;
141
+ // 组件是否启用权限控制,用于在渲染时,确定是否需要检查权限,perms为空、为r为0或空、w为0或空都表示不需要检查
142
+ perms?: { r?: number; w?: number };
143
+ // 组件的权限控制配置,用于设计时配置
144
+ __perms?: { r: { id: string; name: string; enabled: number }; w: { id: string; name: string; enabled: number } };
145
+ }
@@ -0,0 +1,44 @@
1
+ import { IComponentInstance } from './componentInstance'
2
+ import { IComponentMeta } from './componentMeta'
3
+
4
+ export interface IComponentMaterial {
5
+ /**
6
+ * 物料全局id,material开头,16位
7
+ */
8
+ gid: string;
9
+
10
+ /**
11
+ * 组件名称,必填
12
+ */
13
+ componentName: string;
14
+
15
+ /**
16
+ * 图标类型,未设置时,默认取componentName对应组件元数据的值
17
+ */
18
+ iconType?: string;
19
+
20
+ /**
21
+ * 分组,未设置时,默认取componentName对应组件元数据的值
22
+ */
23
+ group?: string;
24
+
25
+ /**
26
+ * 标题,未设置时,默认取componentName对应组件元数据的值
27
+ */
28
+ title?: string;
29
+
30
+ /**
31
+ * 使用方,默认为空数组
32
+ */
33
+ useBy: string[];
34
+
35
+ /**
36
+ * 该物料的组件实例示例
37
+ */
38
+ instance: IComponentInstance | {};
39
+
40
+ /**
41
+ * 该物料的组件元数据定义
42
+ */
43
+ meta: IComponentMeta;
44
+ }
@@ -0,0 +1,219 @@
1
+ import { IActionMeta, IParamMeta } from './action'
2
+ import { IReturnInfoMeta } from './method'
3
+ /**
4
+ * 记录组件中哪些信息需要进行多语言配置
5
+ * 同时定义多语言信息
6
+ */
7
+ export interface IComponentI18nMeta {
8
+ props?: Record<string, string>
9
+ }
10
+
11
+ /**
12
+ * 组件的内置组件在整个组件实例配置文件中的位置定义
13
+ */
14
+ export interface IInnerComponentPosition {
15
+ title: string
16
+ // 访问的属性路径如 x?.y?.z
17
+ propPath: string
18
+ // 通过一个函数来获取,输入为基于path获取的节点数据,用于处理复杂的内置组件场景,如果配置了该pathFn,则以此为准
19
+ // (data)=>{return []}
20
+ // propPathFn?: Function = undefined
21
+ // 如果没有组件时,该内置组件是否被忽略,如在列表的数据列中,有些列可能会有组件,有些列则没有,若没有可以忽略,而不报错。
22
+ ignoreWhenNoComponent?: boolean
23
+ }
24
+
25
+ export interface IStyleSetterMeta{
26
+
27
+ }
28
+
29
+ export interface ISetterComponentPropsMeta {
30
+ // 配置的数据内容
31
+ dataItems?: Array<any>
32
+ [key: string]: any;
33
+ }
34
+
35
+ export interface IPropertySetterMeta {
36
+ // 属性名
37
+ name: String
38
+
39
+ // 属性标题
40
+ title: String
41
+
42
+ // 分组,用于在设置面板中分组展示,包括:base 基础 | view 外观 | 数据 data
43
+ group: String
44
+
45
+ // 类型默认为normal, props 普通 | slots 插槽 | children 子组件 | innerHTML | JsonArray | JsonObject
46
+ type?: String
47
+
48
+ // 占位符
49
+ placeholder?: String
50
+
51
+ // 配置器组件名称
52
+ setterComponentName: string
53
+
54
+ // 配置器组件属性
55
+ setterComponentProps: ISetterComponentPropsMeta
56
+
57
+ // 配置器组件样式
58
+ setterComponentStyle?: IStyleSetterMeta
59
+
60
+ // 配置器组件容器样式
61
+ setterContainerStyle?: IStyleSetterMeta
62
+
63
+ // 启用配置器级件容器默认的内边距,默认不需要启用,若启用,则配置器组件容器内边距为8px
64
+ enableSetterContainerPadding?: boolean
65
+
66
+ // 配置器组件默认值
67
+ setterDefaultValue?: any
68
+
69
+ setterComponentDefaultValue?: any
70
+
71
+ // 是否在设置面板中展示,不显示时,常与默认值配合使用
72
+ show?: Boolean
73
+
74
+ // 展示模式 tile | collapse
75
+ displayMode?: String
76
+
77
+ // 绑定的值字段名称, 如 value、checked、modelValue
78
+ setterComponentVModelName?: String
79
+
80
+ // 样式
81
+ style?: IStyleSetterMeta
82
+
83
+ // 是否可以展开 TODO
84
+ expanded?: Boolean
85
+
86
+ // 配置的数据内容
87
+ dataItems?: Array<any>
88
+
89
+ // 属性描述,用于在配置属性时,可以了解该属性的详细信息
90
+ description?: String
91
+
92
+ // 子属性,适用于Json结构配置的组件,如echarts中的组件
93
+ properties?: Array<IPropertySetterMeta>
94
+
95
+ // 默认值,可用于压缩配置文件时,检查是否等于默认值,若等于默认值,则可以删除该配置的属性
96
+ defaultValue?: any
97
+
98
+ // 在属性设置器中,若该属性为数组对象属性时,指定数组中对象的某一属性作为标题
99
+ titleField?: String
100
+
101
+ // 子标题,与titleField配合使用
102
+ subTitleField?: String
103
+
104
+ // 配置了子标题字段,但获取不到子标题时告警
105
+ alarmIfNoSubTitle?: string;
106
+
107
+ // type为slots时有值
108
+ slotComponentName?: String
109
+
110
+ // 将配置该的结果绑定到槽渲染组件的v-model中还是v-bind中,默认为v-model
111
+ slotComponentBindTarget?: String
112
+
113
+ // 绑定的名称xxxName,结合slotComponentBindTarget使用,如v-bind:xxxName,v-model:xxxName
114
+ slotComponentBindName?: String
115
+
116
+ subComponentName?: String;
117
+
118
+ subComponentCount?: Number
119
+
120
+ // 是否启用值表达式,用于结合上下文的信息、相关逻辑计算得出value
121
+ enableValueExpress?: Boolean
122
+
123
+ // 是否为变量属性,脚本编排中使用
124
+ isBlockVarProp?:boolean
125
+
126
+ // 属性表达式,用于在配置属性时,在配置组件属性时,可以基于该属性表达式的值,来控制组件的属性值
127
+ // 如:{
128
+ // "show": "$.aProp.value === '1'"
129
+ // }
130
+ // 其中$.aProp.value 表示获取aProp的value值,如果aProp的值为1,则show为true,否则为false
131
+ // 用应场景,如A属性选择了M类型时,B属性可以显示,否则隐藏等
132
+ propsExpressions?:Record<string,any>
133
+
134
+ // 规则,用于在配置属性时,可以控制属性是否为必填
135
+ // {
136
+ // "type": "boolean",
137
+ // "required": true,
138
+ // "ruleName": "required",
139
+ // "message": "必填"
140
+ // },
141
+ // {
142
+ // "type": "string",
143
+ // "_RuleExpression": "1=1",
144
+ // "ruleName": "_RuleExpression"
145
+ // }
146
+ rules?:Array<any>
147
+
148
+ }
149
+
150
+
151
+
152
+ export interface IMethodMeta {
153
+ // 是否为异步的方法,异步方法返回类型为Promise<any>
154
+ async?: boolean;
155
+ name: string; // "fetchSuccess"
156
+ title: string; // "成功加载完数据"
157
+ description?: string; // 从服务端成功加数据(0到多条)后触发。
158
+ params?: IParamMeta[];
159
+ defaultValue?: any; // 默认值在接口中通常不指定具体类型,除非有必要
160
+ returnInfo?: IReturnInfoMeta;
161
+ // 是否动态参数,可用于控制配置页面,展示可添加参数的功能
162
+ isDynamicParams?: boolean;
163
+ }
164
+
165
+ export type TechType = 'h5pc' | 'h5mobile' | 'mpWechat' | 'mpAlipay' | 'mpBaidu';
166
+
167
+ export interface IComponentMeta {
168
+ // 组件英文名称,注册到全局环境的名称GlButton
169
+ componentName: string;
170
+ // 组件中文名称
171
+ title: string;
172
+ // 组件类型,h5pc、h5mobile、mpWechat、mpAlipay、mpBaidu...,默认为h5pc
173
+ type?: TechType;
174
+ // 是否在组件选择栏中显示
175
+ show?: boolean;
176
+ // 组件的值绑定属性名,默认为modelValue,特殊的,如tabs为activeKey
177
+ vModelName?: string;
178
+ // 在舞台中是以块状还是行内样式进行展示
179
+ displayOnStage?: string;
180
+ // 在属性配置面板中,是以哪种模式来展示属性,值为:Tile|Collapse
181
+ displayMode: string;
182
+ // 组件图标
183
+ iconType: string;
184
+ // 组件分组,用于在组件选择栏目中进行区分,如form、base
185
+ group: string;
186
+ // 使用于哪些类型的页面,如Page、Dbm...,以便于在编辑相应的页面时从sidebar中过滤掉不合适的组件
187
+ useBy: string[];
188
+ // 属性数组
189
+ properties: IPropertySetterMeta[];
190
+ // 记录需要进行多语言翻译的字段
191
+ i18n?: IComponentI18nMeta;
192
+ // 事件动作
193
+ actions?: IActionMeta[];
194
+ // 组件方法,对应组件defineExpose的内容
195
+ methods?: IMethodMeta[];
196
+ // 引用的组件名称,如AButton
197
+ propsWrapper?: string;
198
+ // 别名简称,用于在生成id时作为前缀
199
+ alias?: string;
200
+ // 为作命令块组件时,在设计器中,展示的描述该命令块的。
201
+ // 如:打开第三方网页,地址为:{url}。其中url为属性properties中的其中一直属性,在展示时动态渲染
202
+ // 如果blockContent的默认以 @language开始,即格式为 @language:xxx 则需进行格式化显示
203
+ blockContent?: string;
204
+ // 块内容的语言,如javascript,默认为空,表示普通的文本
205
+ blockContentLanguage?: string;
206
+ // 块中表示变量名的属性,如:varsName,以便于配置时,可以依据该属性名,获取在真实的变量名
207
+ blockVarNameProps?: string[];
208
+ // 用于设计时,标识是否弃用true,默认为启用即false。弃用时,在sidebar中不可以选择,但在已应用的页面中还可以使用
209
+ deprecated?: boolean;
210
+ /**
211
+ * 该组件内置的组件说明
212
+ *
213
+ */
214
+ innerComponents?: IInnerComponentPosition[];
215
+ /**
216
+ * 组件的描述
217
+ */
218
+ description?: string;
219
+ }
@@ -0,0 +1,46 @@
1
+ import { IParamMeta } from './action';
2
+
3
+ /**
4
+ * 方法参数元数据
5
+ */
6
+ export interface IMethodParamMeta {
7
+ name: string;
8
+ title: string;
9
+ // 默认值
10
+ defaultValue?: any;
11
+ type: string;
12
+ description: string;
13
+ }
14
+
15
+ export interface IReturnInfoMeta {
16
+ // 如string | number | string[] 等
17
+ returnType: string;
18
+ // 对返回的内容进行补充描述
19
+ description: string;
20
+ // 内部的文档指引中的文档id
21
+ docId?: string;
22
+ }
23
+
24
+ export interface IMethodSetterMeta {
25
+ // 方法名
26
+ name: string;
27
+ title: string;
28
+ description?: string;
29
+ params: IMethodParamMeta[];
30
+ returnInfo: IReturnInfoMeta;
31
+ }
32
+
33
+ export interface IMethodDefinition {
34
+ // 是否为异步的方法,异步方法返回类型为Promise<any>
35
+ async?: boolean;
36
+ name: string;
37
+ title: string;
38
+ description?: string;
39
+ params?: IParamMeta[];
40
+ defaultValue?: any;
41
+ returnInfo?: IReturnInfoMeta;
42
+ // 是否动态参数,可用于控制配置页面,展示可添加参数的功能
43
+ isDynamicParams?: boolean;
44
+ }
45
+
46
+ export type ValueTypes = 'String' | 'Boolean' | 'Expression' | 'Number' | 'Array' | 'Object' | 'Dict';
@@ -0,0 +1,11 @@
1
+ import {IComponentMeta } from './componentMeta'
2
+ import {IComponentInstance } from './componentInstance'
3
+ import { Item } from '../plugin'
4
+ export interface ISchema extends Item{
5
+ /**
6
+ * 一般取和插件一致的名称
7
+ */
8
+ name: string
9
+ componentMetas: IComponentMeta[]
10
+ customInstances: IComponentInstance[]
11
+ }
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './types/plugin'
2
+ export * from './types/schema/action'
3
+ export * from './types/schema/method'
4
+ export * from './types/schema/componentMeta'
5
+ export * from './types/schema/componentInstance'
6
+ export * from './types/schema/componentMaterial'
7
+ export * from './types/schema/schema'
8
+ export * from './types/ide/ide'
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@geelato/gl-types",
3
+ "version": "1.0.0",
4
+ "types": "dist/index.d.ts",
5
+ "main": "dist/index.d.ts",
6
+ "publishConfig": {
7
+ "registry": "https://registry.npmjs.org/",
8
+ "access": "public"
9
+ },
10
+ "dependencies": {
11
+ "axios": "1.8.3",
12
+ "pinia": "3.0.1",
13
+ "vue": "3.5.13"
14
+ },
15
+ "devDependencies": {
16
+ "@types/node": "22.13.9",
17
+ "chokidar": "^4.0.3",
18
+ "dts-bundle-generator": "9.5.1",
19
+ "ts-node": "10.9.2"
20
+ },
21
+ "scripts": {
22
+ "build": "node scripts/build.js",
23
+ "watch": "node scripts/watch.js",
24
+ "dev": "node scripts/watch.js",
25
+ "type-check": "tsc --noEmit",
26
+ "test-types": "tsc --noEmit dist/__tests__/type-test.ts",
27
+ "test": "tsc --noEmit && echo '✅ 类型检查通过'"
28
+ }
29
+ }
@@ -0,0 +1,70 @@
1
+ export interface IPanel {
2
+ // 唯一标识
3
+ name: string;
4
+ // 显示名称
5
+ title: string;
6
+ // 面板图标
7
+ iconType: string;
8
+ // 面板对应的全局注册组件名
9
+ componentName: string;
10
+ // 面板的顺序,默认为0,值超小的排在前面,值大的排在后面
11
+ index?: number;
12
+ // 面板打开的位置,默认为"sidebar"
13
+ target?: "sidebar" | "blank";
14
+ }
15
+
16
+ export interface IPanelOptions {
17
+ title: string;
18
+ name: string;
19
+ iconType: string;
20
+ componentName: string;
21
+ showSetterPanels?: string[];
22
+ }
23
+
24
+ /**
25
+ * 插件接口
26
+ * 在IDE中,插件是用于扩展IDE功能的模块,可以包含sidebar、stage、setter等面板,以及页面类型与设置面板的映射
27
+ */
28
+ export interface IIdePlugin {
29
+ // 插件的名称(唯一标识)
30
+ name: string;
31
+ // 插件的版本
32
+ version: string;
33
+ // 插件的描述
34
+ description?: string;
35
+ // 插件的作者
36
+ author?: string;
37
+ // 插件的类型
38
+ // type?: string
39
+ // 插件的sidebar面板
40
+ sidebar: Array<IPanel>;
41
+ // 插件的stage面板
42
+ stage: Array<IPanel>;
43
+ // 插件的setter面板
44
+ setter: Array<IPanel>;
45
+ // 页面类型与设置面板的映射,即选择什么页面类型时,相应的面板会被激活。key为pageType如flowPage
46
+ pageTypeSetterPanelNameMap: Record<string, string[]>;
47
+
48
+ // 获取面板
49
+ getPanels(panelType: string): Array<Panel> | undefined;
50
+
51
+ // 添加页面类型与设置面板的映射
52
+ pushPageTypeAndSetterPanelNames(pageType: string, panelNames: string[]): void;
53
+
54
+ // 获取页面类型对应的设置面板名称
55
+ getSetterPanelNamesByPageType(pageType: string): string[];
56
+ }
57
+
58
+ /**
59
+ * ide.html中,打开idePlugin.html时,会传递一些参数给插件
60
+ */
61
+ export interface IPluginSetupOptions {
62
+ // 插件中,作为展示的主组件名称
63
+ name: string;
64
+ // 当前应用的id
65
+ appId: string;
66
+ // 当前应用的名称
67
+ appName: string;
68
+ // 当前的租户编号
69
+ tenantCode: string;
70
+ }
@@ -0,0 +1,48 @@
1
+ import type { App } from 'vue'
2
+ import type { AxiosStatic, AxiosInstance } from 'axios'
3
+
4
+ export interface Item {
5
+ name: string;
6
+ }
7
+
8
+ export type ItemStatus = 'uninstalled' | 'installed'
9
+
10
+
11
+ export interface IPlugin extends Item{
12
+ /**
13
+ * 获取插件名称,唯一标识
14
+ */
15
+ name: string
16
+
17
+ /**
18
+ * 插件的版本
19
+ */
20
+ version: string
21
+
22
+ /**
23
+ * 插件的加载地址,如果为空,表示采用默认的服务端加载地址
24
+ */
25
+ url?: string
26
+
27
+ getI18nMessages(): I18nMessages
28
+
29
+ install(app: App, options: PluginOptions): void
30
+
31
+ uninstall(): void
32
+ }
33
+
34
+ export interface PluginOptions {
35
+ axios: AxiosStatic | AxiosInstance
36
+ ctx?: Record<string, any>
37
+ router?: any
38
+ pinia?: any
39
+
40
+ [key: string]: any
41
+ }
42
+
43
+
44
+ export type I18nMessages = {
45
+ 'zh-CN': Record<string, any>
46
+ 'en-US': Record<string, any>
47
+ [key: string]: any
48
+ }
@@ -0,0 +1,33 @@
1
+ import {IComponentInstance } from './componentInstance'
2
+
3
+ export interface IAction {
4
+ id?: string;
5
+ eventName: string;
6
+ name: string;
7
+ title: string;
8
+ body?: string;
9
+ __commandBlock?: IComponentInstance;
10
+ }
11
+
12
+ // 动作、方法调用参数元数据定义
13
+ export interface IParamMeta {
14
+ // 字段名
15
+ title: string;
16
+ // dataIndex
17
+ name: string;
18
+ // 是否必需
19
+ required: boolean;
20
+ // 类型
21
+ type: string;
22
+ // 需要求和的字段名称
23
+ description?: string;
24
+ // 详细介绍的文章id
25
+ docId?: string;
26
+ }
27
+
28
+ export interface IActionMeta {
29
+ name: string; // 必填,类型为 string
30
+ title: string; // 必填,类型为 string
31
+ description?: string; // 可选,类型为 string
32
+ params?: IParamMeta[]; // 可选,类型为 ParamMeta[]
33
+ }
@@ -0,0 +1,145 @@
1
+ import {IAction } from './action'
2
+
3
+ export interface I18nItem {
4
+ [key: string]: any
5
+ 'zh-CN': string
6
+ 'en-US': string
7
+ }
8
+
9
+ export interface FieldRule<FieldValue = any> {
10
+ type?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'email' | 'url' | 'ip';
11
+ required?: boolean;
12
+ message?: string;
13
+ length?: number;
14
+ maxLength?: number;
15
+ minLength?: number;
16
+ match?: RegExp;
17
+ uppercase?: boolean;
18
+ lowercase?: boolean;
19
+ min?: number;
20
+ max?: number;
21
+ equal?: number;
22
+ positive?: boolean;
23
+ negative?: boolean;
24
+ true?: boolean;
25
+ false?: boolean;
26
+ includes?: any[];
27
+ deepEqual?: any;
28
+ empty?: boolean;
29
+ hasKeys?: string[];
30
+ validator?: (value: FieldValue | undefined, callback: (error?: string) => void) => void;
31
+ }
32
+
33
+ /**
34
+ * 绑定字段
35
+ */
36
+ export interface IBindField {
37
+ appCode: string;
38
+ entityName: string;
39
+ fieldName: string;
40
+ }
41
+
42
+ /**
43
+ * 绑定实体
44
+ */
45
+ export interface IBindEntity {
46
+ appCode: string;
47
+ entityName: string;
48
+ }
49
+
50
+ export interface IComponentInstanceProps {
51
+ // 标题,如用于formItem的标题
52
+ label?: string;
53
+ // 绑定字段,对于输入组件,需要用到该属性
54
+ bindField?: IBindField;
55
+
56
+ // 组件个性化属性
57
+ [key: string]: any;
58
+
59
+ // 占位符
60
+ placeholder?: string;
61
+ // 描述
62
+ description?: string;
63
+ // 默认值表达式,在值为null或undefined时生效。注:应叫_defaultValue,名称上合理
64
+ _valueExpression?: any;
65
+ // 是否禁用
66
+ disabled?: boolean;
67
+ // 只读
68
+ readonly?: boolean;
69
+ // 是否渲染
70
+ unRender?: boolean;
71
+ // 是否隐藏(渲染但不可见)
72
+ _hidden?: boolean;
73
+ // 验证规则,适用于表单项组件,如AInput
74
+ rules?: FieldRule<any> | FieldRule<any>[];
75
+ }
76
+
77
+ /**
78
+ * "__"开头的属性用于以下场景:
79
+ * 1、动态产生用于内部计算使用
80
+ * 2、作为源代码属性且不需要在发布运行版本中出现
81
+ * 在保存为release版本时,"__"开头的属性会被删除掉,以减小文件的大小
82
+ * source版本,仍保存该属性信息
83
+ */
84
+ export interface IComponentInstance {
85
+ id: string;
86
+ // 创建id时的id前缀
87
+ __idPrefix?: string;
88
+ title?: string;
89
+ // 子标题,用于在设置面板中展示,特别是用于脚本编排组件中,子标题用于展示该脚本块实例的概要意图用途
90
+ __subTitle?: string
91
+ // 备注信息,用于在设置面板中展示,特别是用于脚本编排组件中,描述信息用于展示该脚本块实例的详细用途
92
+ __remark?: string;
93
+ componentName: string;
94
+ // 如dataEntry,可以用来区分是否为表单输入项,在渲染时展示label
95
+ group?: string;
96
+ // 组件的值绑定属性名,默认为modelValue,特殊的,如tabs为activeKey
97
+ vModelName?: string;
98
+ // 组件属性
99
+ props: IComponentInstanceProps;
100
+ // 属性值表达式,通过变量绑定、函数计算等,动态计算属性的值
101
+ propsExpressions?: IComponentInstanceProps;
102
+ slots: { [key: string]: any; propsTarget?: string; propsName?: string };
103
+ // 插槽值表达式,通过变量绑定、函数计算等,动态计算属性的值
104
+ slotsExpressions?: IComponentInstanceProps;
105
+ children: IComponentInstance[];
106
+ actions: IAction[];
107
+ // 额外,如用于GlCard
108
+ extra?: IComponentInstance;
109
+ style?: Object;
110
+ propsWrapper?: string;
111
+ // 多语言,表单配置中默认的为zh-CN,这里只需配置en-US,如果需要繁体,则可配置增加zh-TW或zh-HK
112
+ i18n?: I18nItem[];
113
+ // 运行时的值,如对于input等表单组件,可用于v-model绑定值
114
+ value?: undefined | string | number | boolean | object | Array<any>;
115
+ // 禁用拖放 默认为false,不禁止
116
+ // 如在渲染工作流画布的场景中,禁止工作流画布可拖动,可设置为true
117
+ disabledDnd?: boolean;
118
+ // 如在渲染工作流画布的场景中,禁止选择该组件,如点击选择无效,避免子组件冒泡触发
119
+ disabledSelect?: boolean;
120
+ // 映射引用的组件id,这个属性用于图元映射到组件实例的场景,如设计页面是一个工作流程图,图元的id映射到组件refId
121
+ refId?: string;
122
+ // 用于组件映射到外部的组件或外部的图元素等。如组件实例为GlPage时,可以在此存储当前页面对应的graph对象
123
+ refObject?: Object;
124
+ // 是否禁用,默认为启用,用于设计时
125
+ _disabled?: boolean;
126
+ // 是否为模板实例
127
+ __isTemplateInst?: boolean;
128
+ // 是否为组件的内置组件
129
+ __isInnerComponent?: boolean;
130
+ // 运行时产生,用于指令块组件
131
+ // 是否为被调用的指令块
132
+ __isInvokeBlock?: boolean;
133
+ // 作为被调用的指令块占位符
134
+ __invokeBlockPlaceholder?: string;
135
+ // 字段验证之后的错误信息
136
+ __validateError?: any;
137
+ // 拖动标识,通过监控该标识的变化,可以判断整个页面是否有变化
138
+ __dragFlag?: string;
139
+ // 脚本块
140
+ __commandBlock?: IComponentInstance;
141
+ // 组件是否启用权限控制,用于在渲染时,确定是否需要检查权限,perms为空、为r为0或空、w为0或空都表示不需要检查
142
+ perms?: { r?: number; w?: number };
143
+ // 组件的权限控制配置,用于设计时配置
144
+ __perms?: { r: { id: string; name: string; enabled: number }; w: { id: string; name: string; enabled: number } };
145
+ }
@@ -0,0 +1,44 @@
1
+ import { IComponentInstance } from './componentInstance'
2
+ import { IComponentMeta } from './componentMeta'
3
+
4
+ export interface IComponentMaterial {
5
+ /**
6
+ * 物料全局id,material开头,16位
7
+ */
8
+ gid: string;
9
+
10
+ /**
11
+ * 组件名称,必填
12
+ */
13
+ componentName: string;
14
+
15
+ /**
16
+ * 图标类型,未设置时,默认取componentName对应组件元数据的值
17
+ */
18
+ iconType?: string;
19
+
20
+ /**
21
+ * 分组,未设置时,默认取componentName对应组件元数据的值
22
+ */
23
+ group?: string;
24
+
25
+ /**
26
+ * 标题,未设置时,默认取componentName对应组件元数据的值
27
+ */
28
+ title?: string;
29
+
30
+ /**
31
+ * 使用方,默认为空数组
32
+ */
33
+ useBy: string[];
34
+
35
+ /**
36
+ * 该物料的组件实例示例
37
+ */
38
+ instance: IComponentInstance | {};
39
+
40
+ /**
41
+ * 该物料的组件元数据定义
42
+ */
43
+ meta: IComponentMeta;
44
+ }
@@ -0,0 +1,219 @@
1
+ import { IActionMeta, IParamMeta } from './action'
2
+ import { IReturnInfoMeta } from './method'
3
+ /**
4
+ * 记录组件中哪些信息需要进行多语言配置
5
+ * 同时定义多语言信息
6
+ */
7
+ export interface IComponentI18nMeta {
8
+ props?: Record<string, string>
9
+ }
10
+
11
+ /**
12
+ * 组件的内置组件在整个组件实例配置文件中的位置定义
13
+ */
14
+ export interface IInnerComponentPosition {
15
+ title: string
16
+ // 访问的属性路径如 x?.y?.z
17
+ propPath: string
18
+ // 通过一个函数来获取,输入为基于path获取的节点数据,用于处理复杂的内置组件场景,如果配置了该pathFn,则以此为准
19
+ // (data)=>{return []}
20
+ // propPathFn?: Function = undefined
21
+ // 如果没有组件时,该内置组件是否被忽略,如在列表的数据列中,有些列可能会有组件,有些列则没有,若没有可以忽略,而不报错。
22
+ ignoreWhenNoComponent?: boolean
23
+ }
24
+
25
+ export interface IStyleSetterMeta{
26
+
27
+ }
28
+
29
+ export interface ISetterComponentPropsMeta {
30
+ // 配置的数据内容
31
+ dataItems?: Array<any>
32
+ [key: string]: any;
33
+ }
34
+
35
+ export interface IPropertySetterMeta {
36
+ // 属性名
37
+ name: String
38
+
39
+ // 属性标题
40
+ title: String
41
+
42
+ // 分组,用于在设置面板中分组展示,包括:base 基础 | view 外观 | 数据 data
43
+ group: String
44
+
45
+ // 类型默认为normal, props 普通 | slots 插槽 | children 子组件 | innerHTML | JsonArray | JsonObject
46
+ type?: String
47
+
48
+ // 占位符
49
+ placeholder?: String
50
+
51
+ // 配置器组件名称
52
+ setterComponentName: string
53
+
54
+ // 配置器组件属性
55
+ setterComponentProps: ISetterComponentPropsMeta
56
+
57
+ // 配置器组件样式
58
+ setterComponentStyle?: IStyleSetterMeta
59
+
60
+ // 配置器组件容器样式
61
+ setterContainerStyle?: IStyleSetterMeta
62
+
63
+ // 启用配置器级件容器默认的内边距,默认不需要启用,若启用,则配置器组件容器内边距为8px
64
+ enableSetterContainerPadding?: boolean
65
+
66
+ // 配置器组件默认值
67
+ setterDefaultValue?: any
68
+
69
+ setterComponentDefaultValue?: any
70
+
71
+ // 是否在设置面板中展示,不显示时,常与默认值配合使用
72
+ show?: Boolean
73
+
74
+ // 展示模式 tile | collapse
75
+ displayMode?: String
76
+
77
+ // 绑定的值字段名称, 如 value、checked、modelValue
78
+ setterComponentVModelName?: String
79
+
80
+ // 样式
81
+ style?: IStyleSetterMeta
82
+
83
+ // 是否可以展开 TODO
84
+ expanded?: Boolean
85
+
86
+ // 配置的数据内容
87
+ dataItems?: Array<any>
88
+
89
+ // 属性描述,用于在配置属性时,可以了解该属性的详细信息
90
+ description?: String
91
+
92
+ // 子属性,适用于Json结构配置的组件,如echarts中的组件
93
+ properties?: Array<IPropertySetterMeta>
94
+
95
+ // 默认值,可用于压缩配置文件时,检查是否等于默认值,若等于默认值,则可以删除该配置的属性
96
+ defaultValue?: any
97
+
98
+ // 在属性设置器中,若该属性为数组对象属性时,指定数组中对象的某一属性作为标题
99
+ titleField?: String
100
+
101
+ // 子标题,与titleField配合使用
102
+ subTitleField?: String
103
+
104
+ // 配置了子标题字段,但获取不到子标题时告警
105
+ alarmIfNoSubTitle?: string;
106
+
107
+ // type为slots时有值
108
+ slotComponentName?: String
109
+
110
+ // 将配置该的结果绑定到槽渲染组件的v-model中还是v-bind中,默认为v-model
111
+ slotComponentBindTarget?: String
112
+
113
+ // 绑定的名称xxxName,结合slotComponentBindTarget使用,如v-bind:xxxName,v-model:xxxName
114
+ slotComponentBindName?: String
115
+
116
+ subComponentName?: String;
117
+
118
+ subComponentCount?: Number
119
+
120
+ // 是否启用值表达式,用于结合上下文的信息、相关逻辑计算得出value
121
+ enableValueExpress?: Boolean
122
+
123
+ // 是否为变量属性,脚本编排中使用
124
+ isBlockVarProp?:boolean
125
+
126
+ // 属性表达式,用于在配置属性时,在配置组件属性时,可以基于该属性表达式的值,来控制组件的属性值
127
+ // 如:{
128
+ // "show": "$.aProp.value === '1'"
129
+ // }
130
+ // 其中$.aProp.value 表示获取aProp的value值,如果aProp的值为1,则show为true,否则为false
131
+ // 用应场景,如A属性选择了M类型时,B属性可以显示,否则隐藏等
132
+ propsExpressions?:Record<string,any>
133
+
134
+ // 规则,用于在配置属性时,可以控制属性是否为必填
135
+ // {
136
+ // "type": "boolean",
137
+ // "required": true,
138
+ // "ruleName": "required",
139
+ // "message": "必填"
140
+ // },
141
+ // {
142
+ // "type": "string",
143
+ // "_RuleExpression": "1=1",
144
+ // "ruleName": "_RuleExpression"
145
+ // }
146
+ rules?:Array<any>
147
+
148
+ }
149
+
150
+
151
+
152
+ export interface IMethodMeta {
153
+ // 是否为异步的方法,异步方法返回类型为Promise<any>
154
+ async?: boolean;
155
+ name: string; // "fetchSuccess"
156
+ title: string; // "成功加载完数据"
157
+ description?: string; // 从服务端成功加数据(0到多条)后触发。
158
+ params?: IParamMeta[];
159
+ defaultValue?: any; // 默认值在接口中通常不指定具体类型,除非有必要
160
+ returnInfo?: IReturnInfoMeta;
161
+ // 是否动态参数,可用于控制配置页面,展示可添加参数的功能
162
+ isDynamicParams?: boolean;
163
+ }
164
+
165
+ export type TechType = 'h5pc' | 'h5mobile' | 'mpWechat' | 'mpAlipay' | 'mpBaidu';
166
+
167
+ export interface IComponentMeta {
168
+ // 组件英文名称,注册到全局环境的名称GlButton
169
+ componentName: string;
170
+ // 组件中文名称
171
+ title: string;
172
+ // 组件类型,h5pc、h5mobile、mpWechat、mpAlipay、mpBaidu...,默认为h5pc
173
+ type?: TechType;
174
+ // 是否在组件选择栏中显示
175
+ show?: boolean;
176
+ // 组件的值绑定属性名,默认为modelValue,特殊的,如tabs为activeKey
177
+ vModelName?: string;
178
+ // 在舞台中是以块状还是行内样式进行展示
179
+ displayOnStage?: string;
180
+ // 在属性配置面板中,是以哪种模式来展示属性,值为:Tile|Collapse
181
+ displayMode: string;
182
+ // 组件图标
183
+ iconType: string;
184
+ // 组件分组,用于在组件选择栏目中进行区分,如form、base
185
+ group: string;
186
+ // 使用于哪些类型的页面,如Page、Dbm...,以便于在编辑相应的页面时从sidebar中过滤掉不合适的组件
187
+ useBy: string[];
188
+ // 属性数组
189
+ properties: IPropertySetterMeta[];
190
+ // 记录需要进行多语言翻译的字段
191
+ i18n?: IComponentI18nMeta;
192
+ // 事件动作
193
+ actions?: IActionMeta[];
194
+ // 组件方法,对应组件defineExpose的内容
195
+ methods?: IMethodMeta[];
196
+ // 引用的组件名称,如AButton
197
+ propsWrapper?: string;
198
+ // 别名简称,用于在生成id时作为前缀
199
+ alias?: string;
200
+ // 为作命令块组件时,在设计器中,展示的描述该命令块的。
201
+ // 如:打开第三方网页,地址为:{url}。其中url为属性properties中的其中一直属性,在展示时动态渲染
202
+ // 如果blockContent的默认以 @language开始,即格式为 @language:xxx 则需进行格式化显示
203
+ blockContent?: string;
204
+ // 块内容的语言,如javascript,默认为空,表示普通的文本
205
+ blockContentLanguage?: string;
206
+ // 块中表示变量名的属性,如:varsName,以便于配置时,可以依据该属性名,获取在真实的变量名
207
+ blockVarNameProps?: string[];
208
+ // 用于设计时,标识是否弃用true,默认为启用即false。弃用时,在sidebar中不可以选择,但在已应用的页面中还可以使用
209
+ deprecated?: boolean;
210
+ /**
211
+ * 该组件内置的组件说明
212
+ *
213
+ */
214
+ innerComponents?: IInnerComponentPosition[];
215
+ /**
216
+ * 组件的描述
217
+ */
218
+ description?: string;
219
+ }
@@ -0,0 +1,46 @@
1
+ import { IParamMeta } from './action';
2
+
3
+ /**
4
+ * 方法参数元数据
5
+ */
6
+ export interface IMethodParamMeta {
7
+ name: string;
8
+ title: string;
9
+ // 默认值
10
+ defaultValue?: any;
11
+ type: string;
12
+ description: string;
13
+ }
14
+
15
+ export interface IReturnInfoMeta {
16
+ // 如string | number | string[] 等
17
+ returnType: string;
18
+ // 对返回的内容进行补充描述
19
+ description: string;
20
+ // 内部的文档指引中的文档id
21
+ docId?: string;
22
+ }
23
+
24
+ export interface IMethodSetterMeta {
25
+ // 方法名
26
+ name: string;
27
+ title: string;
28
+ description?: string;
29
+ params: IMethodParamMeta[];
30
+ returnInfo: IReturnInfoMeta;
31
+ }
32
+
33
+ export interface IMethodDefinition {
34
+ // 是否为异步的方法,异步方法返回类型为Promise<any>
35
+ async?: boolean;
36
+ name: string;
37
+ title: string;
38
+ description?: string;
39
+ params?: IParamMeta[];
40
+ defaultValue?: any;
41
+ returnInfo?: IReturnInfoMeta;
42
+ // 是否动态参数,可用于控制配置页面,展示可添加参数的功能
43
+ isDynamicParams?: boolean;
44
+ }
45
+
46
+ export type ValueTypes = 'String' | 'Boolean' | 'Expression' | 'Number' | 'Array' | 'Object' | 'Dict';
@@ -0,0 +1,11 @@
1
+ import {IComponentMeta } from './componentMeta'
2
+ import {IComponentInstance } from './componentInstance'
3
+ import { Item } from '../plugin'
4
+ export interface ISchema extends Item{
5
+ /**
6
+ * 一般取和插件一致的名称
7
+ */
8
+ name: string
9
+ componentMetas: IComponentMeta[]
10
+ customInstances: IComponentInstance[]
11
+ }