@ibiz-template/model-helper 0.7.41-alpha.13 → 0.7.41-alpha.130
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.esm.js +9770 -3196
- package/dist/index.system.min.js +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -1
- package/out/interface/i-model-handler.d.ts +20 -0
- package/out/interface/i-model-handler.d.ts.map +1 -0
- package/out/interface/i-model-handler.js +1 -0
- package/out/interface/index.d.ts +2 -0
- package/out/interface/index.d.ts.map +1 -0
- package/out/interface/index.js +1 -0
- package/out/locale/en/index.d.ts +4 -0
- package/out/locale/en/index.d.ts.map +1 -1
- package/out/locale/en/index.js +4 -0
- package/out/locale/zh-CN/index.d.ts +4 -0
- package/out/locale/zh-CN/index.d.ts.map +1 -1
- package/out/locale/zh-CN/index.js +4 -0
- package/out/model-helper.d.ts +13 -1
- package/out/model-helper.d.ts.map +1 -1
- package/out/model-helper.js +47 -4
- package/out/model-loader.d.ts +3 -1
- package/out/model-loader.d.ts.map +1 -1
- package/out/model-loader.js +6 -0
- package/out/model-util.d.ts +3 -2
- package/out/model-util.d.ts.map +1 -1
- package/out/model-util.js +28 -20
- package/out/utils/index.d.ts +3 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +3 -0
- package/out/utils/merge-model/merge-app-codelist.d.ts +8 -0
- package/out/utils/merge-model/merge-app-codelist.d.ts.map +1 -0
- package/out/utils/merge-model/merge-app-codelist.js +35 -0
- package/out/utils/merge-model/merge-app-menu.d.ts.map +1 -1
- package/out/utils/merge-model/merge-app-menu.js +8 -3
- package/out/utils/merge-model/merge-app-uiaction-group.d.ts +7 -0
- package/out/utils/merge-model/merge-app-uiaction-group.d.ts.map +1 -1
- package/out/utils/merge-model/merge-app-uiaction-group.js +54 -2
- package/out/utils/merge-model/merge-de-drcontrol.d.ts +8 -0
- package/out/utils/merge-model/merge-de-drcontrol.d.ts.map +1 -1
- package/out/utils/merge-model/merge-de-drcontrol.js +87 -4
- package/out/utils/merge-model/merge-de-form.d.ts +15 -0
- package/out/utils/merge-model/merge-de-form.d.ts.map +1 -1
- package/out/utils/merge-model/merge-de-form.js +56 -0
- package/out/utils/merge-model/merge-model-helper.d.ts +15 -1
- package/out/utils/merge-model/merge-model-helper.d.ts.map +1 -1
- package/out/utils/merge-model/merge-model-helper.js +101 -9
- package/out/utils/merge-model/merge-treeview.d.ts.map +1 -1
- package/out/utils/merge-model/merge-treeview.js +142 -6
- package/out/utils/model-transformer/model-handler.d.ts +32 -0
- package/out/utils/model-transformer/model-handler.d.ts.map +1 -0
- package/out/utils/model-transformer/model-handler.js +24 -0
- package/out/utils/model-transformer/model-register.d.ts +9 -0
- package/out/utils/model-transformer/model-register.d.ts.map +1 -0
- package/out/utils/model-transformer/model-register.js +10 -0
- package/out/utils/model-transformer/model-transformer.d.ts +63 -0
- package/out/utils/model-transformer/model-transformer.d.ts.map +1 -0
- package/out/utils/model-transformer/model-transformer.js +125 -0
- package/package.json +8 -6
- package/src/index.ts +12 -0
- package/src/interface/i-model-handler.ts +19 -0
- package/src/interface/index.ts +1 -0
- package/src/locale/en/index.ts +24 -0
- package/src/locale/index.ts +2 -0
- package/src/locale/zh-CN/index.ts +20 -0
- package/src/model/PSSYSAPP.ts +12 -0
- package/src/model-helper.ts +804 -0
- package/src/model-loader.ts +95 -0
- package/src/model-util.ts +483 -0
- package/src/utils/format-path/format-path.ts +9 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/merge-model/merge-app-codelist.ts +42 -0
- package/src/utils/merge-model/merge-app-menu.ts +136 -0
- package/src/utils/merge-model/merge-app-uiaction-group.ts +85 -0
- package/src/utils/merge-model/merge-de-drcontrol.ts +175 -0
- package/src/utils/merge-model/merge-de-form.ts +326 -0
- package/src/utils/merge-model/merge-model-helper.ts +602 -0
- package/src/utils/merge-model/merge-model.ts +20 -0
- package/src/utils/merge-model/merge-treeview.ts +197 -0
- package/src/utils/model-transformer/model-handler.ts +36 -0
- package/src/utils/model-transformer/model-register.ts +15 -0
- package/src/utils/model-transformer/model-transformer.ts +147 -0
- package/src/utils/plural/plural.ts +30 -0
- package/src/utils/service-path-util/service-path-util.ts +361 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { IAppDERS, IApplication } from '@ibiz/model-core';
|
|
2
|
+
import { plural } from '../plural/plural';
|
|
3
|
+
import { ModelUtil } from '../../model-util';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取服务拼接递归对象
|
|
7
|
+
*/
|
|
8
|
+
export type ServicePathDeep = [IAppDERS, ServicePathDeep[]];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 服务路径项
|
|
12
|
+
*/
|
|
13
|
+
export type ServicePathItem = {
|
|
14
|
+
/**
|
|
15
|
+
* 实体代码名称(标准)
|
|
16
|
+
*
|
|
17
|
+
* @author chitanda
|
|
18
|
+
* @date 2022-08-25 18:08:35
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
codeName: string;
|
|
22
|
+
/**
|
|
23
|
+
* 实体代码名称(小写)
|
|
24
|
+
*
|
|
25
|
+
* @author chitanda
|
|
26
|
+
* @date 2022-08-25 18:08:54
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
29
|
+
lower: string;
|
|
30
|
+
/**
|
|
31
|
+
* 实体代码名称复数(小写)
|
|
32
|
+
*
|
|
33
|
+
* @author chitanda
|
|
34
|
+
* @date 2022-08-25 18:08:13
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
plural: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 服务接口项
|
|
42
|
+
*/
|
|
43
|
+
export type ServiceApiItem = {
|
|
44
|
+
/**
|
|
45
|
+
* 实体代码名称(标准)
|
|
46
|
+
*
|
|
47
|
+
* @author tony001
|
|
48
|
+
* @date 2024-05-11 15:05:54
|
|
49
|
+
* @type {string}
|
|
50
|
+
*/
|
|
51
|
+
codeName: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 实体服务接口代码标识
|
|
55
|
+
*
|
|
56
|
+
* @author tony001
|
|
57
|
+
* @date 2024-05-11 15:05:43
|
|
58
|
+
* @type {string}
|
|
59
|
+
*/
|
|
60
|
+
deApiCodeName: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 实体服务接口代码标识2(复数)
|
|
64
|
+
*
|
|
65
|
+
* @author tony001
|
|
66
|
+
* @date 2024-05-11 15:05:43
|
|
67
|
+
* @type {string}
|
|
68
|
+
*/
|
|
69
|
+
deApiCodeName2: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 服务路径拼接工具
|
|
74
|
+
*
|
|
75
|
+
* @author chitanda
|
|
76
|
+
* @date 2022-08-22 21:08:52
|
|
77
|
+
* @export
|
|
78
|
+
* @class ServicePathUtil
|
|
79
|
+
*/
|
|
80
|
+
export class ServicePathUtil {
|
|
81
|
+
/**
|
|
82
|
+
* 应用实体关系
|
|
83
|
+
*
|
|
84
|
+
* @author chitanda
|
|
85
|
+
* @date 2022-08-22 22:08:18
|
|
86
|
+
* @protected
|
|
87
|
+
* @type {Map<string, IAppDERS[]>} <应用实体 id, 应用实体父关系>
|
|
88
|
+
*/
|
|
89
|
+
protected entityRsMap: Map<string, IAppDERS[]> = new Map();
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 实体资源路径
|
|
93
|
+
*
|
|
94
|
+
* @author chitanda
|
|
95
|
+
* @date 2022-08-22 22:08:58
|
|
96
|
+
* @protected
|
|
97
|
+
* @type {Map<string, ServicePathItem[][]>}
|
|
98
|
+
*/
|
|
99
|
+
protected entityRsPathMap: Map<string, ServicePathItem[][]> = new Map();
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 实体资源加载状态关系
|
|
103
|
+
*
|
|
104
|
+
* @author tony001
|
|
105
|
+
* @date 2024-05-20 16:05:41
|
|
106
|
+
* @protected
|
|
107
|
+
* @type {Map<string, boolean>}
|
|
108
|
+
*/
|
|
109
|
+
protected entityRsLoadMap: Map<string, boolean> = new Map();
|
|
110
|
+
|
|
111
|
+
constructor(
|
|
112
|
+
protected appDataEntities: IModel[],
|
|
113
|
+
protected allDERss: IAppDERS[],
|
|
114
|
+
protected modelUtil: ModelUtil,
|
|
115
|
+
) {}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 根据应用主实体过滤从关系集合
|
|
119
|
+
*
|
|
120
|
+
* @author chitanda
|
|
121
|
+
* @date 2023-04-20 17:04:34
|
|
122
|
+
* @protected
|
|
123
|
+
* @param {string} id
|
|
124
|
+
* @return {*} {IAppDERS[]}
|
|
125
|
+
*/
|
|
126
|
+
protected filterDERSs(id: string): IAppDERS[] {
|
|
127
|
+
if (this.entityRsMap.has(id)) {
|
|
128
|
+
return this.entityRsMap.get(id)!;
|
|
129
|
+
}
|
|
130
|
+
const items = this.allDERss.filter(item => {
|
|
131
|
+
if ((item as IModel).rSMode === 2 && item.minorAppDataEntityId === id) {
|
|
132
|
+
return item;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
});
|
|
136
|
+
if (items.length > 0) {
|
|
137
|
+
this.entityRsMap.set(id, items);
|
|
138
|
+
}
|
|
139
|
+
return items;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 计算指定应用实体所有资源路径
|
|
144
|
+
*
|
|
145
|
+
* @author chitanda
|
|
146
|
+
* @date 2023-04-22 13:04:27
|
|
147
|
+
* @param {string} id
|
|
148
|
+
* @return {*} {string[]}
|
|
149
|
+
*/
|
|
150
|
+
async calcRequestPaths(id: string): Promise<string[]> {
|
|
151
|
+
const paths = await this.calcPaths(id);
|
|
152
|
+
return paths.map(path => {
|
|
153
|
+
return path.map(item => `${item.plural}/\${${item.lower}}`).join('/');
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 计算指定实体所有资源路径
|
|
159
|
+
*
|
|
160
|
+
* @author chitanda
|
|
161
|
+
* @date 2023-04-22 13:04:36
|
|
162
|
+
* @protected
|
|
163
|
+
* @param {string} id
|
|
164
|
+
* @return {*} {ServicePathItem[][]} 返回顺序为 [祖父实体,爷爷实体,父实体,当前实体]
|
|
165
|
+
*/
|
|
166
|
+
protected async calcPaths(id: string): Promise<ServicePathItem[][]> {
|
|
167
|
+
const entityRef = this.appDataEntities.find(item => item.id === id);
|
|
168
|
+
if (!entityRef) {
|
|
169
|
+
throw new Error(ibiz.i18n.t('modelHelper.utils.noFoundEntity', { id }));
|
|
170
|
+
}
|
|
171
|
+
const { codeName } = entityRef;
|
|
172
|
+
if (!this.entityRsLoadMap.has(codeName)) {
|
|
173
|
+
this.entityRsLoadMap.set(codeName, false);
|
|
174
|
+
}
|
|
175
|
+
// 需要处理完成才能获取
|
|
176
|
+
if (
|
|
177
|
+
this.entityRsPathMap.has(codeName) &&
|
|
178
|
+
this.entityRsLoadMap.get(codeName)
|
|
179
|
+
) {
|
|
180
|
+
return this.entityRsPathMap.get(codeName)!;
|
|
181
|
+
}
|
|
182
|
+
const deRss = this.filterDERSs(id);
|
|
183
|
+
if (deRss) {
|
|
184
|
+
// 已经计算过的应用实体标识
|
|
185
|
+
const ids: string[] = [id];
|
|
186
|
+
const arr = this.calcDeepPath(ids, deRss);
|
|
187
|
+
await this.deepFillPath(codeName, [codeName], arr);
|
|
188
|
+
let paths = this.entityRsPathMap.get(codeName);
|
|
189
|
+
if (paths) {
|
|
190
|
+
paths = this.sortPath(paths);
|
|
191
|
+
this.entityRsPathMap.set(codeName, paths);
|
|
192
|
+
this.entityRsLoadMap.set(codeName, true);
|
|
193
|
+
return paths;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
this.entityRsLoadMap.set(codeName, true);
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 计算递归资源路径
|
|
202
|
+
*
|
|
203
|
+
* @author chitanda
|
|
204
|
+
* @date 2023-08-23 14:08:39
|
|
205
|
+
* @protected
|
|
206
|
+
* @param {string[]} ids
|
|
207
|
+
* @param {IAppDERS[]} deRss
|
|
208
|
+
* @param {number} [num=0]
|
|
209
|
+
* @return {*} {ServicePathDeep[]}
|
|
210
|
+
*/
|
|
211
|
+
protected calcDeepPath(
|
|
212
|
+
ids: string[],
|
|
213
|
+
deRss: IAppDERS[],
|
|
214
|
+
num: number = 0,
|
|
215
|
+
): ServicePathDeep[] {
|
|
216
|
+
if (num > 10) {
|
|
217
|
+
throw new Error(ibiz.i18n.t('modelHelper.utils.maximumTier'));
|
|
218
|
+
}
|
|
219
|
+
num += 1;
|
|
220
|
+
const arr: ServicePathDeep[] = [];
|
|
221
|
+
deRss.forEach(rs => {
|
|
222
|
+
if (ids.includes(rs.majorAppDataEntityId!)) {
|
|
223
|
+
ibiz.log.warn(
|
|
224
|
+
ibiz.i18n.t('modelHelper.utils.circularRecursive'),
|
|
225
|
+
rs.majorAppDataEntityId,
|
|
226
|
+
ibiz.i18n.t('modelHelper.utils.calculatedEntities'),
|
|
227
|
+
ids,
|
|
228
|
+
);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const items = this.filterDERSs(rs.majorAppDataEntityId!);
|
|
232
|
+
arr.push([
|
|
233
|
+
rs,
|
|
234
|
+
this.calcDeepPath([...ids, rs.majorAppDataEntityId!], items, num),
|
|
235
|
+
]);
|
|
236
|
+
});
|
|
237
|
+
return arr;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 递归填充计算所有资源路径
|
|
242
|
+
*
|
|
243
|
+
* @author chitanda
|
|
244
|
+
* @date 2022-08-22 22:08:04
|
|
245
|
+
* @protected
|
|
246
|
+
* @param {string} deCodeName
|
|
247
|
+
* @param {string[]} pathNames
|
|
248
|
+
* @param {ServicePathDeep[]} items
|
|
249
|
+
*/
|
|
250
|
+
protected async deepFillPath(
|
|
251
|
+
deCodeName: string,
|
|
252
|
+
pathNames: string[],
|
|
253
|
+
items: ServicePathDeep[],
|
|
254
|
+
): Promise<void> {
|
|
255
|
+
for (let i = 0; i < items.length; i++) {
|
|
256
|
+
const item = items[i];
|
|
257
|
+
const [rs, children] = item;
|
|
258
|
+
if (children.length > 0) {
|
|
259
|
+
await this.deepFillPath(
|
|
260
|
+
deCodeName,
|
|
261
|
+
[...pathNames, rs.majorDECodeName!],
|
|
262
|
+
children,
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (!this.entityRsPathMap.has(deCodeName)) {
|
|
266
|
+
this.entityRsPathMap.set(deCodeName, []);
|
|
267
|
+
}
|
|
268
|
+
const arr = this.entityRsPathMap.get(deCodeName)!;
|
|
269
|
+
|
|
270
|
+
const serviceApiItems = await this.getServiceApiItems(pathNames);
|
|
271
|
+
const rsServiceApiItems = await this.getServiceApiItems([
|
|
272
|
+
rs.majorDECodeName!,
|
|
273
|
+
]);
|
|
274
|
+
const tempArr = [
|
|
275
|
+
...pathNames.map((pathName, index) => {
|
|
276
|
+
return {
|
|
277
|
+
codeName: pathName,
|
|
278
|
+
lower: pathName.toLowerCase(),
|
|
279
|
+
plural: serviceApiItems[index].deApiCodeName2,
|
|
280
|
+
};
|
|
281
|
+
}),
|
|
282
|
+
{
|
|
283
|
+
codeName: rs.majorDECodeName!,
|
|
284
|
+
lower: rs.majorDECodeName!.toLowerCase(),
|
|
285
|
+
plural: rsServiceApiItems[0].deApiCodeName2,
|
|
286
|
+
},
|
|
287
|
+
].reverse();
|
|
288
|
+
const targetIndex = arr.findIndex(ele => {
|
|
289
|
+
return (
|
|
290
|
+
ele
|
|
291
|
+
.map(val => {
|
|
292
|
+
return val.codeName;
|
|
293
|
+
})
|
|
294
|
+
.join('/') ===
|
|
295
|
+
tempArr
|
|
296
|
+
.map(temp => {
|
|
297
|
+
return temp.codeName;
|
|
298
|
+
})
|
|
299
|
+
.join('/')
|
|
300
|
+
);
|
|
301
|
+
});
|
|
302
|
+
if (targetIndex === -1) {
|
|
303
|
+
arr.push(tempArr);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 排序资源路径顺序
|
|
310
|
+
*
|
|
311
|
+
* @author chitanda
|
|
312
|
+
* @date 2022-08-22 22:08:44
|
|
313
|
+
* @protected
|
|
314
|
+
* @param {ServicePathItem[][]} paths
|
|
315
|
+
* @return {*} {ServicePathItem[][]}
|
|
316
|
+
*/
|
|
317
|
+
protected sortPath(paths: ServicePathItem[][]): ServicePathItem[][] {
|
|
318
|
+
return paths.sort((a, b) => {
|
|
319
|
+
return b.length - a.length;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 通过codeName数据获取相关接口标识数据
|
|
325
|
+
*
|
|
326
|
+
* @author tony001
|
|
327
|
+
* @date 2024-05-11 17:05:51
|
|
328
|
+
* @protected
|
|
329
|
+
* @param {string[]} codeNames
|
|
330
|
+
* @return {*} {Promise<ServiceApiItem[]>}
|
|
331
|
+
*/
|
|
332
|
+
protected async getServiceApiItems(
|
|
333
|
+
codeNames: string[],
|
|
334
|
+
): Promise<ServiceApiItem[]> {
|
|
335
|
+
const serviceApiItems: ServiceApiItem[] = [];
|
|
336
|
+
for (let i = 0; i < codeNames.length; i++) {
|
|
337
|
+
const appEntity = await this.modelUtil.getAppDataEntityModel(
|
|
338
|
+
codeNames[i],
|
|
339
|
+
false,
|
|
340
|
+
);
|
|
341
|
+
const serviceApiItem: ServiceApiItem = {
|
|
342
|
+
codeName: codeNames[i],
|
|
343
|
+
deApiCodeName: appEntity.dEAPICodeName,
|
|
344
|
+
deApiCodeName2: '',
|
|
345
|
+
};
|
|
346
|
+
if (appEntity.dEAPICodeName) {
|
|
347
|
+
if (!appEntity.deapicodeName2) {
|
|
348
|
+
serviceApiItem.deApiCodeName2 = plural(appEntity.dEAPICodeName);
|
|
349
|
+
}
|
|
350
|
+
const { engineVer } =
|
|
351
|
+
(await this.modelUtil.getAppModel()) as IApplication;
|
|
352
|
+
if (!engineVer || engineVer < 240) {
|
|
353
|
+
serviceApiItem.deApiCodeName2 =
|
|
354
|
+
appEntity.deapicodeName2!.toLowerCase();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
serviceApiItems.push(serviceApiItem);
|
|
358
|
+
}
|
|
359
|
+
return serviceApiItems;
|
|
360
|
+
}
|
|
361
|
+
}
|