@oinone/kunlun-meta 6.2.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.
Files changed (145) hide show
  1. package/dist/oinone-kunlun-meta.esm.js +496 -0
  2. package/dist/types/index.d.ts +1 -0
  3. package/dist/types/src/element/ActionElement.d.ts +15 -0
  4. package/dist/types/src/element/ApiElement.d.ts +21 -0
  5. package/dist/types/src/element/ClearElement.d.ts +9 -0
  6. package/dist/types/src/element/ConfigElement.d.ts +6 -0
  7. package/dist/types/src/element/ContextElement.d.ts +9 -0
  8. package/dist/types/src/element/CustomElement.d.ts +7 -0
  9. package/dist/types/src/element/FieldElement.d.ts +25 -0
  10. package/dist/types/src/element/IBaseElement.d.ts +5 -0
  11. package/dist/types/src/element/PropElement.d.ts +6 -0
  12. package/dist/types/src/element/RequestElement.d.ts +9 -0
  13. package/dist/types/src/element/ResponseElement.d.ts +9 -0
  14. package/dist/types/src/element/SubscribeElement.d.ts +9 -0
  15. package/dist/types/src/element/ValidationElement.d.ts +12 -0
  16. package/dist/types/src/element/ViewElement.d.ts +15 -0
  17. package/dist/types/src/element/WidgetElement.d.ts +23 -0
  18. package/dist/types/src/element/index.d.ts +14 -0
  19. package/dist/types/src/global-config/index.d.ts +2 -0
  20. package/dist/types/src/global-config/runtime-config.d.ts +14 -0
  21. package/dist/types/src/global-config/type.d.ts +26 -0
  22. package/dist/types/src/index.d.ts +5 -0
  23. package/dist/types/src/metadata/constant/config.d.ts +1 -0
  24. package/dist/types/src/metadata/constant/index.d.ts +2 -0
  25. package/dist/types/src/metadata/constant/module-name.d.ts +20 -0
  26. package/dist/types/src/metadata/fragment/action.d.ts +6 -0
  27. package/dist/types/src/metadata/fragment/field.d.ts +2 -0
  28. package/dist/types/src/metadata/fragment/func.d.ts +2 -0
  29. package/dist/types/src/metadata/fragment/index.d.ts +13 -0
  30. package/dist/types/src/metadata/fragment/menu.d.ts +2 -0
  31. package/dist/types/src/metadata/fragment/model.d.ts +2 -0
  32. package/dist/types/src/metadata/fragment/page.d.ts +2 -0
  33. package/dist/types/src/metadata/index.d.ts +4 -0
  34. package/dist/types/src/metadata/runtime-fragment/action.d.ts +8 -0
  35. package/dist/types/src/metadata/runtime-fragment/function.d.ts +3 -0
  36. package/dist/types/src/metadata/runtime-fragment/index.d.ts +20 -0
  37. package/dist/types/src/metadata/runtime-fragment/model.d.ts +2 -0
  38. package/dist/types/src/metadata/runtime-fragment/module.d.ts +2 -0
  39. package/dist/types/src/metadata/runtime-fragment/view.d.ts +6 -0
  40. package/dist/types/src/metadata/types/dsl-node.d.ts +12 -0
  41. package/dist/types/src/metadata/types/enumeration.d.ts +18 -0
  42. package/dist/types/src/metadata/types/index.d.ts +8 -0
  43. package/dist/types/src/metadata/types/layout.d.ts +4 -0
  44. package/dist/types/src/metadata/types/model.d.ts +573 -0
  45. package/dist/types/src/metadata/types/tag.d.ts +23 -0
  46. package/dist/types/src/metadata/types/user.d.ts +22 -0
  47. package/dist/types/src/metadata/types/value.d.ts +3 -0
  48. package/dist/types/src/metadata/types/view.d.ts +170 -0
  49. package/dist/types/src/plugin-loader/factory/PluginLoaderFactory.d.ts +4 -0
  50. package/dist/types/src/plugin-loader/factory/index.d.ts +1 -0
  51. package/dist/types/src/plugin-loader/index.d.ts +5 -0
  52. package/dist/types/src/plugin-loader/loader/CJSPluginLoader.d.ts +7 -0
  53. package/dist/types/src/plugin-loader/loader/CSSPluginLoader.d.ts +7 -0
  54. package/dist/types/src/plugin-loader/loader/ESMPluginLoader.d.ts +7 -0
  55. package/dist/types/src/plugin-loader/loader/IIFEPluginLoader.d.ts +7 -0
  56. package/dist/types/src/plugin-loader/loader/LoadedEvent.d.ts +4 -0
  57. package/dist/types/src/plugin-loader/loader/PluginLoader.d.ts +5 -0
  58. package/dist/types/src/plugin-loader/loader/RemotePluginLoader.d.ts +5 -0
  59. package/dist/types/src/plugin-loader/loader/UMDPluginLoader.d.ts +6 -0
  60. package/dist/types/src/plugin-loader/loader/index.d.ts +1 -0
  61. package/dist/types/src/plugin-loader/typing/index.d.ts +2 -0
  62. package/dist/types/src/plugin-loader/typing/load-option.d.ts +48 -0
  63. package/dist/types/src/plugin-loader/typing/loader-config.d.ts +38 -0
  64. package/dist/types/src/plugin-loader/util/PluginLoadHelper.d.ts +7 -0
  65. package/dist/types/src/plugin-loader/util/index.d.ts +1 -0
  66. package/dist/types/src/util/element.d.ts +16 -0
  67. package/dist/types/src/util/field.d.ts +7 -0
  68. package/dist/types/src/util/helper.d.ts +2 -0
  69. package/dist/types/src/util/index.d.ts +6 -0
  70. package/dist/types/src/util/ke-common.d.ts +6 -0
  71. package/dist/types/src/util/lang.d.ts +4 -0
  72. package/dist/types/src/util/validation-utils.d.ts +3 -0
  73. package/index.ts +1 -0
  74. package/package.json +17 -0
  75. package/rollup.config.js +4 -0
  76. package/src/element/ActionElement.ts +20 -0
  77. package/src/element/ApiElement.ts +22 -0
  78. package/src/element/ClearElement.ts +10 -0
  79. package/src/element/ConfigElement.ts +7 -0
  80. package/src/element/ContextElement.ts +10 -0
  81. package/src/element/CustomElement.ts +22 -0
  82. package/src/element/FieldElement.ts +41 -0
  83. package/src/element/IBaseElement.ts +5 -0
  84. package/src/element/PropElement.ts +7 -0
  85. package/src/element/RequestElement.ts +10 -0
  86. package/src/element/ResponseElement.ts +10 -0
  87. package/src/element/SubscribeElement.ts +10 -0
  88. package/src/element/ValidationElement.ts +17 -0
  89. package/src/element/ViewElement.ts +23 -0
  90. package/src/element/WidgetElement.ts +33 -0
  91. package/src/element/index.ts +14 -0
  92. package/src/global-config/index.ts +2 -0
  93. package/src/global-config/runtime-config.ts +83 -0
  94. package/src/global-config/type.ts +48 -0
  95. package/src/index.ts +5 -0
  96. package/src/metadata/constant/config.ts +1 -0
  97. package/src/metadata/constant/index.ts +2 -0
  98. package/src/metadata/constant/module-name.ts +21 -0
  99. package/src/metadata/fragment/action.ts +119 -0
  100. package/src/metadata/fragment/field.ts +42 -0
  101. package/src/metadata/fragment/func.ts +21 -0
  102. package/src/metadata/fragment/index.ts +20 -0
  103. package/src/metadata/fragment/menu.ts +35 -0
  104. package/src/metadata/fragment/model.ts +76 -0
  105. package/src/metadata/fragment/page.ts +17 -0
  106. package/src/metadata/index.ts +4 -0
  107. package/src/metadata/runtime-fragment/action.ts +159 -0
  108. package/src/metadata/runtime-fragment/function.ts +25 -0
  109. package/src/metadata/runtime-fragment/index.ts +36 -0
  110. package/src/metadata/runtime-fragment/model.ts +18 -0
  111. package/src/metadata/runtime-fragment/module.ts +11 -0
  112. package/src/metadata/runtime-fragment/view.ts +44 -0
  113. package/src/metadata/types/dsl-node.ts +14 -0
  114. package/src/metadata/types/enumeration.ts +19 -0
  115. package/src/metadata/types/index.ts +8 -0
  116. package/src/metadata/types/layout.ts +4 -0
  117. package/src/metadata/types/model.ts +823 -0
  118. package/src/metadata/types/tag.ts +24 -0
  119. package/src/metadata/types/user.ts +27 -0
  120. package/src/metadata/types/value.ts +3 -0
  121. package/src/metadata/types/view.ts +194 -0
  122. package/src/plugin-loader/factory/PluginLoaderFactory.ts +23 -0
  123. package/src/plugin-loader/factory/index.ts +1 -0
  124. package/src/plugin-loader/index.ts +33 -0
  125. package/src/plugin-loader/loader/CJSPluginLoader.ts +18 -0
  126. package/src/plugin-loader/loader/CSSPluginLoader.ts +29 -0
  127. package/src/plugin-loader/loader/ESMPluginLoader.ts +53 -0
  128. package/src/plugin-loader/loader/IIFEPluginLoader.ts +18 -0
  129. package/src/plugin-loader/loader/LoadedEvent.ts +24 -0
  130. package/src/plugin-loader/loader/PluginLoader.ts +12 -0
  131. package/src/plugin-loader/loader/RemotePluginLoader.ts +54 -0
  132. package/src/plugin-loader/loader/UMDPluginLoader.ts +50 -0
  133. package/src/plugin-loader/loader/index.ts +1 -0
  134. package/src/plugin-loader/typing/index.ts +2 -0
  135. package/src/plugin-loader/typing/load-option.ts +51 -0
  136. package/src/plugin-loader/typing/loader-config.ts +38 -0
  137. package/src/plugin-loader/util/PluginLoadHelper.ts +70 -0
  138. package/src/plugin-loader/util/index.ts +1 -0
  139. package/src/util/element.ts +154 -0
  140. package/src/util/field.ts +63 -0
  141. package/src/util/helper.ts +6 -0
  142. package/src/util/index.ts +6 -0
  143. package/src/util/ke-common.ts +25 -0
  144. package/src/util/lang.ts +8 -0
  145. package/src/util/validation-utils.ts +17 -0
@@ -0,0 +1,823 @@
1
+ import { BIGINT, EntityId } from './value';
2
+ import { IView, SystemSource, ViewActionTarget, ViewType } from './view';
3
+
4
+ export type ModelId = EntityId;
5
+
6
+ export interface IModel {
7
+ id: ModelId;
8
+ pk: string[];
9
+ model: string;
10
+ name: string;
11
+ type: ModelType;
12
+ module?: string;
13
+ moduleName: string;
14
+ modelFields: IModelField[];
15
+ displayName?: string;
16
+ labelFields?: string[];
17
+ label?: string;
18
+ progressField?: string;
19
+ masterFieldStr?: string;
20
+ progressFieldStr?: string;
21
+ viewActionList?: IViewAction[];
22
+ serverActionList?: IServerAction[];
23
+ urlActionList?: IURLAction[];
24
+ clientActionList?: IClientAction[];
25
+ functions?: IModelFunc[];
26
+ modelActions?: (IClientAction | IURLAction | IServerAction | IViewAction)[];
27
+ viewList?: IView[];
28
+ uniqueList?: { fieldList: IModelField[]; fields: string }[];
29
+ uniques?: string[];
30
+ indexes?: string[];
31
+ indexList?: { fieldList: IModelField[]; fields: string[] }[];
32
+ ordering?: string;
33
+ attributes?: {
34
+ requiredCondition?: string;
35
+ invisibleCondition?: string;
36
+ readonlyCondition?: string;
37
+ layoutGrid: number;
38
+ layoutGroup: string;
39
+ };
40
+ }
41
+
42
+ export enum ModelType {
43
+ STORE = 'STORE',
44
+ TRANSIENT = 'TRANSIENT',
45
+ ABSTRACT = 'ABSTRACT',
46
+ PROXY = 'PROXY',
47
+ CLIENT = 'CLIENT'
48
+ }
49
+
50
+ // 标准字段类型,注意不要改值,跟后端对应的
51
+ export enum ModelFieldType {
52
+ // region string
53
+ String = 'STRING',
54
+ Text = 'TEXT',
55
+ HTML = 'HTML',
56
+ Phone = 'PHONE',
57
+ Email = 'EMAIL',
58
+ // endregion
59
+
60
+ // region number
61
+ Integer = 'INTEGER',
62
+ Long = 'LONG',
63
+ Float = 'FLOAT',
64
+ Currency = 'MONEY',
65
+ // endregion
66
+
67
+ // region date
68
+ DateTime = 'DATETIME',
69
+ Date = 'DATE',
70
+ Time = 'TIME',
71
+ Year = 'YEAR',
72
+ // endregion
73
+
74
+ // region others
75
+ Boolean = 'BOOLEAN',
76
+ Enum = 'ENUM',
77
+ Map = 'MAP',
78
+ Related = 'RELATED',
79
+ // endregion
80
+
81
+ // region relation
82
+ OneToOne = 'O2O',
83
+ OneToMany = 'O2M',
84
+ ManyToOne = 'M2O',
85
+ ManyToMany = 'M2M',
86
+ // endregion
87
+
88
+ OBJ = 'OBJ',
89
+
90
+ /**
91
+ * @deprecated 已废弃
92
+ */
93
+ ID = 'ID',
94
+ /**
95
+ * @deprecated 已废弃
96
+ */
97
+ Null = 'NULL',
98
+ /**
99
+ * @deprecated 已废弃
100
+ */
101
+ UID = 'UID',
102
+ /**
103
+ * @deprecated 已废弃
104
+ */
105
+ MultiEnum = 'MULTI_ENUM' // 新增枚举多选字段
106
+ }
107
+
108
+ export const ModelFieldTypeDisplayName = {
109
+ ID: 'ID',
110
+ NULL: '空',
111
+ INTEGER: '整数',
112
+ LONG: '长整型',
113
+ FLOAT: '浮点数',
114
+ BOOLEAN: '布尔型',
115
+ STRING: '文本',
116
+ TEXT: '多行文本',
117
+ DATETIME: '时间日期',
118
+ DATE: '日期',
119
+ TIME: '时间',
120
+ YEAR: '年份',
121
+ HTML: '富文本',
122
+ MONEY: '金额',
123
+ ENUM: '数据字典',
124
+ MULTI_ENUM: '多枚举', // 新增枚举多选字段
125
+ O2O: '一对一',
126
+ O2M: '一对多',
127
+ M2O: '多对一',
128
+ M2M: '多对多',
129
+ RELATED: '引用类型',
130
+ MAP: '键值对',
131
+ UID: '用户ID',
132
+ PHONE: '手机',
133
+ EMAIL: '邮箱'
134
+ };
135
+
136
+ export const ModelFieldTypeOptions: { label: string; value: string }[] = [
137
+ {
138
+ label: ModelFieldTypeDisplayName.STRING,
139
+ value: ModelFieldType.String
140
+ },
141
+ {
142
+ label: ModelFieldTypeDisplayName.TEXT,
143
+ value: ModelFieldType.Text
144
+ },
145
+ {
146
+ label: ModelFieldTypeDisplayName.HTML,
147
+ value: ModelFieldType.HTML
148
+ },
149
+ {
150
+ label: ModelFieldTypeDisplayName.PHONE,
151
+ value: ModelFieldType.Phone
152
+ },
153
+ {
154
+ label: ModelFieldTypeDisplayName.EMAIL,
155
+ value: ModelFieldType.Email
156
+ },
157
+ {
158
+ label: ModelFieldTypeDisplayName.INTEGER,
159
+ value: ModelFieldType.Integer
160
+ },
161
+ {
162
+ label: ModelFieldTypeDisplayName.LONG,
163
+ value: ModelFieldType.Long
164
+ },
165
+ {
166
+ label: ModelFieldTypeDisplayName.FLOAT,
167
+ value: ModelFieldType.Float
168
+ },
169
+ {
170
+ label: ModelFieldTypeDisplayName.MONEY,
171
+ value: ModelFieldType.Currency
172
+ },
173
+ {
174
+ label: ModelFieldTypeDisplayName.DATETIME,
175
+ value: ModelFieldType.DateTime
176
+ },
177
+ {
178
+ label: ModelFieldTypeDisplayName.DATE,
179
+ value: ModelFieldType.Date
180
+ },
181
+ {
182
+ label: ModelFieldTypeDisplayName.TIME,
183
+ value: ModelFieldType.Time
184
+ },
185
+ {
186
+ label: ModelFieldTypeDisplayName.YEAR,
187
+ value: ModelFieldType.Year
188
+ },
189
+ {
190
+ label: ModelFieldTypeDisplayName.BOOLEAN,
191
+ value: ModelFieldType.Boolean
192
+ },
193
+ {
194
+ label: ModelFieldTypeDisplayName.ENUM,
195
+ value: ModelFieldType.Enum
196
+ },
197
+ {
198
+ label: ModelFieldTypeDisplayName.MAP,
199
+ value: ModelFieldType.Map
200
+ },
201
+ // {
202
+ // label: ModelFieldTypeDisplayName.O2O,
203
+ // value: ModelFieldType.OneToOne
204
+ // },
205
+ {
206
+ label: ModelFieldTypeDisplayName.O2M,
207
+ value: ModelFieldType.OneToMany
208
+ },
209
+ {
210
+ label: ModelFieldTypeDisplayName.M2O,
211
+ value: ModelFieldType.ManyToOne
212
+ },
213
+ {
214
+ label: ModelFieldTypeDisplayName.M2M,
215
+ value: ModelFieldType.ManyToMany
216
+ }
217
+ ];
218
+
219
+ export enum ModelFieldSerializeType {
220
+ NON = 'NON',
221
+ JSON = 'JSON',
222
+ COMMA = 'COMMA',
223
+ BIT = 'BIT',
224
+ DOT = 'DOT'
225
+ }
226
+
227
+ export interface IModelField {
228
+ id: string;
229
+ data?: string; // 兼容v3新版字段
230
+ name: string; // 绑定模型的属性名,对应FieldElement.data
231
+ viewIndex: string; // 只做前端唯一识别用, 对应FieldElement.name,这里暂时不用name或者viewName是为了好全局搜索替换
232
+ limit: number; // 分页数量? 该字段为关联关系数量限制,对于xxx2many的字段,允许选择的数量限制。
233
+ load: string;
234
+ loadType: LoadType;
235
+ loadApi: string;
236
+ ttype: ModelFieldType;
237
+ model: string;
238
+ modelId: ModelId;
239
+ displayName?: string;
240
+ max?: string;
241
+ min?: string;
242
+ sys?: boolean;
243
+ systemSource?: SystemSource; // 系统来源
244
+ size?: number; // 数值字段的长度
245
+ decimal?: number; // 数值字段的精度
246
+ options?: IModelFieldOption[]; // 枚举返回数据字段
247
+ index?: boolean; // 是否索引字段
248
+ unique?: boolean; // 是否唯一索引字段
249
+ translate?: boolean; // 是否需要翻译
250
+
251
+ // 临时
252
+ label?: string;
253
+
254
+ /**
255
+ * 关联的对方模型,原来的 relation
256
+ */
257
+ references?: string;
258
+ /**
259
+ * m2m 关联关系的模型
260
+ */
261
+ through?: string;
262
+ /**
263
+ * 关系字段,自身模型的关联字段
264
+ */
265
+ relationFields?: string[];
266
+ /**
267
+ * 关联字段,关联模型的关联字段
268
+ */
269
+ referenceFields?: string[];
270
+ /**
271
+ * 中间模型里当前模型的关联字段
272
+ */
273
+ throughRelationFields?: string[];
274
+ /**
275
+ * 中间模型里关联模型的关联字段
276
+ */
277
+ throughReferenceFields?: string[];
278
+ invisible?: boolean | string; // 默认是否可见
279
+ priority?: BIGINT; // 字段排序
280
+ compute?: string; // 计算
281
+ relatedTtype?: ModelFieldType;
282
+ widget?: string;
283
+ field?: string;
284
+
285
+ sortable?: boolean; // 这个字段是xml里面配置的,不是后端模型字段里面的
286
+
287
+ hint?: string; // 这个字段是xml里面配置的,不是后端模型字段里面的
288
+ patternType?: string; // 正则校验类型,这个字段是xml里面配置的,不是后端模型字段里面的
289
+ pattern?: string; // 正则校验
290
+ validation?: string; // 表达式校验
291
+ tips?: string; // 校验失败的提示消息
292
+ independentlyEditable?: boolean; // 是否开启行内编辑
293
+
294
+ // relation?: string;
295
+ // relationField?: string;
296
+ related: string[];
297
+ store?: boolean; // 是否需要存储
298
+ relationStore?: boolean;
299
+ // 存储序列化函数编码
300
+ storeSerialize?: ModelFieldSerializeType; // NON JSON COMMA DOT
301
+ domain?: string;
302
+ isUnique?: boolean; // 是否全局唯一,默认值false(TODO 前端稍后再处理)
303
+ required?: boolean | string; // 是否必填,默认值false
304
+ requiredTips?: string; // 必填的校验文案
305
+ domainSize?: string; // 后端给的备选项一页的数量
306
+ readonly?: boolean; // 是否只读(新增的时候可编辑,修改的时候不可编辑),默认值false
307
+ multi: boolean; // 字段返回值是否为数组
308
+ format: string;
309
+ defaultValue: string;
310
+ attributes?: {
311
+ requiredCondition?: string;
312
+ invisibleCondition?: string;
313
+ readonlyCondition?: string;
314
+ layoutGrid: number;
315
+ layoutGroup: string;
316
+ layoutTab: string;
317
+ layoutTabs: string;
318
+ };
319
+ // 不取名为children是因为有地方需要mixin服务端的children字段,但是相同名称的children数据类型不一样,导致不能合并代码报错,所以取了一个不冲突的字段名
320
+ modelFields: IModelField[];
321
+ }
322
+
323
+ export enum EnumOptionState {
324
+ ACTIVE = 'ACTIVE',
325
+ INACTIVE = 'INACTIVE'
326
+ }
327
+
328
+ export interface IModelFieldOption {
329
+ name: string;
330
+ value: string;
331
+ state: EnumOptionState;
332
+ displayName?: string;
333
+ color?: string;
334
+ backgroundColor?: string;
335
+ icon?: string;
336
+ label?: string;
337
+ invisible?: boolean;
338
+ isDefault?: boolean;
339
+ hint?: string;
340
+ thumbnail?: string;
341
+ }
342
+
343
+ export function isRelationTtype(ttype: ModelFieldType): boolean {
344
+ return [
345
+ ModelFieldType.OneToOne,
346
+ ModelFieldType.OneToMany,
347
+ ModelFieldType.ManyToOne,
348
+ ModelFieldType.ManyToMany
349
+ ].includes(ttype);
350
+ }
351
+
352
+ export function isToOneTtype(ttype: ModelFieldType): boolean {
353
+ return [ModelFieldType.OneToOne, ModelFieldType.ManyToOne].includes(ttype);
354
+ }
355
+
356
+ export function isToManyTtype(ttype: ModelFieldType): boolean {
357
+ return [ModelFieldType.ManyToMany, ModelFieldType.OneToMany].includes(ttype);
358
+ }
359
+
360
+ export function isRelatedTtype(ttype: ModelFieldType): boolean {
361
+ return ttype === ModelFieldType.Related;
362
+ }
363
+
364
+ export interface IModule {
365
+ id: string;
366
+ name: string;
367
+ module: string;
368
+ displayName?: string;
369
+ logo: string;
370
+ homePage: IViewAction;
371
+ allMenus: IMenu[];
372
+ priority: number;
373
+ application: boolean;
374
+ like: boolean;
375
+ urlHomePage?: IURLAction;
376
+ }
377
+
378
+ export interface IMenu {
379
+ id: string;
380
+ name: string;
381
+ displayName: string;
382
+ parentName: string;
383
+ icon?: string;
384
+ parent?: IMenu;
385
+ priority: number;
386
+ moduleDefinition: {
387
+ id: string;
388
+ name: string;
389
+ displayName: string;
390
+ };
391
+ actionType?: ActionType;
392
+ viewAction?: IViewAction;
393
+ serverAction?: IServerAction;
394
+ urlAction?: IURLAction;
395
+ children?: Array<IMenu>;
396
+ mapping?: Record<string, unknown>;
397
+ context?: Record<string, unknown>;
398
+ }
399
+
400
+ /**
401
+ * 请求类型
402
+ */
403
+ export enum ApiProtocol {
404
+ GRAPHQL = 'graphql',
405
+ RESTFUL = 'restful'
406
+ }
407
+
408
+ /**
409
+ * 内容数据的类型
410
+ */
411
+ export enum DataType {
412
+ // 基础类型 string int 等
413
+ PRIMITIVE = 'primitive',
414
+ // 单体复杂对象
415
+ OBJECT = 'object',
416
+ // 列表
417
+ LIST = 'list'
418
+ }
419
+
420
+ /**
421
+ * 加载的函数类型
422
+ */
423
+ export enum LoadType {
424
+ // 客户端函数
425
+ CLIENT = 'client',
426
+ // 服务端函数
427
+ SERVER = 'server'
428
+ }
429
+
430
+ /**
431
+ * 校验类型
432
+ */
433
+ export enum ValidationScope {
434
+ // 客户端校验
435
+ CLIENT = 'client',
436
+ // 服务端校验
437
+ SERVER = 'server',
438
+ // 客户端校验 + 服务端校验
439
+ BOTH = 'both'
440
+ }
441
+
442
+ /**
443
+ * 查询类型
444
+ * 不使用queryPage接口,直传当前选中行数据(对象object或者列表list,默认是domain)
445
+ * 默认值:DOMAIN
446
+ */
447
+ export enum QueryType {
448
+ // 使用queryPage接口的查询条件
449
+ DOMAIN = 'domain',
450
+ // 取mapping标签内定义的对象数据
451
+ OBJECT = 'object',
452
+ // 当前选中行数据
453
+ LIST = 'list'
454
+ }
455
+
456
+ interface IModelFuncArg {
457
+ name: string;
458
+ ttype: ModelFieldType;
459
+ }
460
+
461
+ export interface IModelFunc {
462
+ method: string;
463
+ name: string;
464
+ fun: string;
465
+ argumentList: IModelFuncArg[];
466
+ type: 'CREATE' | 'DELETE' | 'UPDATE' | 'QUERY'[];
467
+ }
468
+
469
+ export enum ActionType {
470
+ // 下面三种与服务端是对应的
471
+ Server = 'SERVER',
472
+ View = 'VIEW',
473
+ URL = 'URL',
474
+ Client = 'CLIENT',
475
+
476
+ // 前端造出来的
477
+ Model = 'model',
478
+ Composition = 'COMPOSITION',
479
+
480
+ // 项目化动态注册的自定义动作
481
+ Custom = 'custom'
482
+ }
483
+
484
+ export enum ActionContextType {
485
+ Single = 'SINGLE',
486
+ Batch = 'BATCH',
487
+ SingleAndBatch = 'SINGLE_AND_BATCH',
488
+ ContextFree = 'CONTEXT_FREE'
489
+ }
490
+
491
+ export type ActionId = EntityId;
492
+
493
+ export interface IBaseAbstractAction {
494
+ title?: string;
495
+ displayName?: string;
496
+ label?: string;
497
+ model?: string;
498
+ /**
499
+ * @deprecated
500
+ */
501
+ rule?: string; // 过滤规则
502
+ invisible?: string; // 按钮显隐规则
503
+ }
504
+
505
+ export interface IBaseAction extends IBaseAbstractAction {
506
+ id: ActionId;
507
+ name: string;
508
+ model: string;
509
+ modelDefinition?: IModel;
510
+ bindingType: string[]; // action绑定在源模型上的哪些视图上
511
+ bindingViewName?: string; // action 仅显示在指定视图上
512
+ actionType: ActionType;
513
+ contextType: ActionContextType;
514
+ usageDesc?: string; // 说明
515
+ groups?: any[]; // 群组
516
+ builtIn?: boolean; // 是否为内置的
517
+ skipCheck?: boolean; // FIXME: 是否跳过动作策略筛选,为了解决在现有过滤规则的前提下,一些通用的客户端动作被动作策略拦住,等动作筛选系统搞出来可以干掉
518
+ config?: Record<string, unknown>;
519
+ confirm?: string;
520
+ priority?: number;
521
+ sessionPath?: string;
522
+ }
523
+
524
+ export interface ViewActionPage {
525
+ layoutTemplate: string; // 页面布局模板
526
+ name: string;
527
+ model: string;
528
+ id: EntityId;
529
+ active: boolean;
530
+ viewList: IView[];
531
+ }
532
+
533
+ export interface IViewAction extends IBaseAction {
534
+ actionType: ActionType.View;
535
+ target: ViewActionTarget; // 目标窗口
536
+ resModel: string;
537
+ resModelDefinition?: IModel;
538
+ resViewName: string;
539
+ bindingViewName?: string; // 绑定的xmlname
540
+ queryType?: QueryType;
541
+ apiProtocol?: ApiProtocol;
542
+ viewMode?: string; // 打开目标模型后,可支持切换的视图类型,用逗号 split 之后是 ViewType
543
+ viewType: ViewType; // 打开目标模型后,默认打开的视图类型
544
+ dataType?: DataType; // 打开目标模型的视图分类
545
+ domain?: string; // 打开目标模型的列表类视图时附带的查询条件
546
+ filter?: string; // 打开目标模型的列表类视图时附带的查询条件, 用户不可见
547
+ load?: string;
548
+ loadFunction?: IModelFunc;
549
+ context?: Record<string, unknown>; // 上下文变量
550
+ moduleName: string; // module 前端用短标识
551
+ page?: ViewActionPage;
552
+ resView?: IView;
553
+ module: string;
554
+ resModule?: string;
555
+ resModuleName?: string;
556
+ resModuleDefinition?: IModule;
557
+
558
+ moduleDefinition?: IModule;
559
+ maskDefinition?: {
560
+ name: string;
561
+ template: string;
562
+ };
563
+ theme?: string;
564
+ }
565
+
566
+ export interface ISharedViewAction extends IViewAction {
567
+ sharedCode: string;
568
+ authorizationCode: string;
569
+ sharedParameters: string;
570
+ browserTitle?: string;
571
+ language?: string;
572
+ languageIsoCode?: string;
573
+ }
574
+
575
+ export interface IServerAction extends IBaseAction {
576
+ actionType: ActionType.Server;
577
+ functionDefinition: IModelFunc;
578
+ function: IModelFunc;
579
+ module: string;
580
+ }
581
+
582
+ export enum ActionFunctionType {
583
+ JAVA = 'JAVA',
584
+ JS = 'JS',
585
+ GROOVY = 'GROOVY'
586
+ }
587
+
588
+ interface IServerActionFunction {
589
+ name: string; // 函数名称
590
+ namespace: string; // 函数体
591
+ funName: string; // 函数方法
592
+ argNames: string; // 函数参数名列表
593
+ argTypes: string; // 方法参数类型,','分割
594
+ returnType: string; // 返回值类型
595
+ type: ActionFunctionType; // 代码的编程语言类型
596
+ imports?: string; // 上下文引用
597
+ context?: string; // 上下文变量
598
+ codes: string; // 函数代码内容
599
+ isExported: boolean; // 是否发布服务
600
+ exportGroup: string; // 服务发布组
601
+ exportVersion: string; // 服务发布版本
602
+ }
603
+
604
+ export interface IURLAction extends IBaseAction {
605
+ url: string;
606
+ compute?: string;
607
+ target: ViewActionTarget;
608
+ confirm?: string;
609
+ module: string;
610
+ context: Record<string, unknown>;
611
+ }
612
+
613
+ // 以下部分,后端暂无定义,前端自己使用,暂时只给前端用,约束默认数据提交的
614
+ export interface IModelAction extends IBaseAction {
615
+ actionType: ActionType.Model;
616
+ type: ModelActionType;
617
+ domain?: string; // 查询参数
618
+ }
619
+
620
+ export enum ModelActionType {
621
+ FindOne = 'FindOne',
622
+ FindList = 'FindList',
623
+ FindAll = 'FindAll',
624
+ InsertOne = 'InsertOne',
625
+ UpdateOne = 'UpdateOne',
626
+ DeleteOne = 'DeleteOne',
627
+ DeleteOneInline = 'DeleteOneInline',
628
+ UpdateList = 'UpdateList',
629
+ DeleteList = 'DeleteList'
630
+ }
631
+
632
+ // 纯前端行为动作
633
+ export interface IClientAction extends IBaseAbstractAction {
634
+ actionType: ActionType.Client;
635
+ name: ClientActionName | string;
636
+ bindingType?: string[]; // action绑定在源模型上的哪些视图上
637
+ id?: string;
638
+ contextType: ActionContextType;
639
+ confirm?: string;
640
+ priority?: number;
641
+ tag?: string;
642
+ fun?: string;
643
+ }
644
+
645
+ export enum IActionTag {
646
+ ContextAction = 'contextFreeAction',
647
+ SingleAction = 'singleAction',
648
+ FooterAction = 'footer'
649
+ }
650
+
651
+ // 前端的动作类型
652
+ export enum ClientActionName {
653
+ ValidateForm = 'validateForm',
654
+
655
+ UpdateContext = 'updateContext',
656
+
657
+ ShowDialog = 'showDialog',
658
+ SubmitDialog = 'submitDialog',
659
+ CloseDialog = 'closeDialog',
660
+
661
+ // 这些都是纯前端行为,临时操作视图数据
662
+ InsertEmptyItemToList = 'insertEmptyItemToList',
663
+ InsertEmptyItemToBefore = 'insertEmptyItemToBefore',
664
+ InsertEmptyItemToAfter = 'insertEmptyItemToAfter',
665
+ DeleteListItem = 'deleteListItem',
666
+
667
+ ReloadData = 'reloadData',
668
+
669
+ CopyText = 'copyText',
670
+
671
+ Confirm = 'confirm',
672
+
673
+ // 根据具体实现来判断到底干什么
674
+ StartCreate = 'startCreate',
675
+
676
+ // 这些是表格行内操作
677
+ StartInlineEdit = 'startInlineEdit',
678
+ SubmitInlineEdit = 'submitInlineEdit',
679
+ CancelInlineEdit = 'cancelInlineEdit',
680
+
681
+ // history
682
+ HistoryBack = 'historyBack',
683
+
684
+ O2MCreateForm = 'O2MCreateForm',
685
+ O2MEditForm = 'O2MEditForm',
686
+ O2MDelete = 'O2MDelete',
687
+ O2MCreateFormConfirm = 'O2MCreateFormConfirm',
688
+ O2MEditFormConfirm = 'O2MEditFormConfirm',
689
+
690
+ M2MCreateTable = 'M2MCreateTable',
691
+ M2MDelete = 'M2MDelete',
692
+ M2MCreateTableConfirm = 'M2MCreateTableConfirm',
693
+ O2MCloseForm = 'O2MCloseForm'
694
+ }
695
+
696
+ // 模型默认自带的动作
697
+ export enum ModelDefaultActionName {
698
+ create = 'create',
699
+ update = 'update',
700
+ delete = 'delete',
701
+ // 跳转到详情页面的action
702
+ redirectDetailPage = 'redirectDetailPage',
703
+ // 跳转到创建页面的action
704
+ redirectCreatePage = 'redirectCreatePage',
705
+ // 跳转到编辑页面的action
706
+ redirectUpdatePage = 'redirectUpdatePage',
707
+ // 添加一行
708
+ $$internal_AddOne = '$$internal_AddOne',
709
+ // 编辑一行
710
+ $$internal_EditOne = '$$internal_EditOne',
711
+ // 复制一行
712
+ $$internal_CopyOne = '$$internal_CopyOne',
713
+ // 删除一行
714
+ $$internal_DeleteOne = '$$internal_DeleteOne',
715
+ // 创建数据后返回到列表页的serverAction
716
+ $$internal_ListInsertOneAndBackToList = '$$internal_ListInsertOneAndBackToList',
717
+ // 编辑数据后返回到列表页的serverAction
718
+ $$internal_ListUpdateOneAndBackToList = '$$internal_ListUpdateOneAndBackToList',
719
+ // 数据导入的action
720
+ $$internal_GotoListImportDialog = '$$internal_GotoListImportDialog',
721
+ // 数据导出的action
722
+ $$internal_GotoListExportDialog = '$$internal_GotoListExportDialog',
723
+ // 返回列表页viewAction
724
+ $$internal_GotoListTableRouter = '$$internal_GotoListTableRouter',
725
+ // 关闭弹窗
726
+ $$internal_DialogCancel = '$$internal_DialogCancel',
727
+ // 打开关联模型的创建弹窗
728
+ $$internal_GotoO2MCreateDialog = '$$internal_GotoO2MCreateDialog',
729
+ // 打开关联模型的编辑弹窗
730
+ $$internal_GotoO2MEditDialog = '$$internal_GotoO2MEditDialog',
731
+
732
+ // 未实现
733
+ $$internal_O2MUpdateOneAndSubmitDialog = '$$internal_O2MUpdateOneAndSubmitDialog',
734
+ // 未实现
735
+ $$internal_O2MDeleteOne = '$$internal_O2MDeleteOne',
736
+ // 未实现
737
+ $$internal_DialogSubmit = '$$internal_DialogSubmit',
738
+ // 未实现
739
+ $$internal_O2MInsertOneAndSubmitDialog = '$$internal_O2MInsertOneAndSubmitDialog',
740
+ // 未实现
741
+ $$internal_ListUpdateAndCloseDialogReloadOpenerAction = '$$internal_ListUpdateAndCloseDialogReloadOpenerAction',
742
+
743
+ // 创建数据后关闭弹窗
744
+ $$internal_ListInsertOneAndCloseDialog = '$$internal_ListInsertOneAndCloseDialog',
745
+ // 跳转到关联模型的列表弹窗
746
+ $$internal_GotoM2MListDialog = '$$internal_GotoM2MListDialog',
747
+ // 重新加载页面数据
748
+ $$internal_ReloadData = '$$internal_ReloadData',
749
+ // 校验表单
750
+ $$internal_ValidateForm = '$$internal_ValidateForm',
751
+ // 下载
752
+ $$internal_Download = '$$internal_Download',
753
+
754
+ /**
755
+ * 批量更新
756
+ */
757
+ $$internal_BatchUpdate = '$$internal_BatchUpdate',
758
+ /**
759
+ * 下载导入模板
760
+ */
761
+ $$internal_DownloadImportWorkbook = '$$internal_DownloadImportWorkbook',
762
+ /**
763
+ * 导入
764
+ */
765
+ $$internal_ImportWorkbook = '$$internal_ImportWorkbook',
766
+ /**
767
+ * 导出
768
+ */
769
+ $$internal_ExportWorkbook = '$$internal_ExportWorkbook',
770
+ /**
771
+ * 打印
772
+ */
773
+ $$internal_PrintPdfDocument = '$$internal_PrintPdfDocument'
774
+ }
775
+
776
+ export const ModelDefaultActionNames: string[] = [
777
+ ModelDefaultActionName.create,
778
+ ModelDefaultActionName.update,
779
+ ModelDefaultActionName.delete,
780
+ ModelDefaultActionName.redirectDetailPage,
781
+ ModelDefaultActionName.redirectCreatePage,
782
+ ModelDefaultActionName.redirectUpdatePage
783
+ ];
784
+
785
+ // 动作组合的类型
786
+ export enum ActionCompositionType {
787
+ Sequential = 'sequential', // 串行
788
+ Parallel = 'parallel', // 并行
789
+ ForkJoin = 'fork-join', // 并行等待
790
+ Race = 'race' // 竞争
791
+ }
792
+
793
+ // 组合动作,自身没有行为,只负责组合其他动作
794
+ export interface ICompositionAction extends IBaseAbstractAction {
795
+ actionType: ActionType.Composition;
796
+ name: ClientActionName | string;
797
+ type?: ActionCompositionType;
798
+ bindingType?: ViewType[];
799
+ contextType?: ActionContextType;
800
+ confirm?: string;
801
+ id?: string;
802
+ priority?: number;
803
+ tag?: string;
804
+ }
805
+
806
+ export type ActionRuleId = EntityId;
807
+
808
+ // 前端的自定义动作,仅作为自定义代码的索引
809
+ export interface ICustomAction extends IBaseAction {
810
+ actionType: ActionType.Custom;
811
+ code: string; // 自定义动作的编码,项目级唯一识别,取名规则:一级模块.二级模块.动作名
812
+ }
813
+
814
+ // 自定义动作的执行方法
815
+ export type CustomActionExecutor = (action: ICustomAction, vm: any, context: any) => any | Promise<any>;
816
+
817
+ export type IAction = IViewAction | IServerAction | IURLAction | IClientAction | ICompositionAction;
818
+
819
+ export enum ActionValidationScope {
820
+ Client = 'client',
821
+ Server = 'server',
822
+ Both = 'both'
823
+ }